JeecgBoot3.6.1中实现编码校验唯一性
文章目录
前言
提示:以下是本篇文章正文内容,下面案例可供参考
在我们项目开发中,可能会用到一些数据字典,字典中会用到一些code值,会以外键的形式出现在别的表中,我们角色数据字典为例
vue使用的版本为3.0
下面的代码解析,熟悉vue3的小伙伴可以忽略
一、前端页面:role.data.ts
1.关键代码示例
import {
BasicColumn } from '/@/components/Table';
import {
FormSchema } from '/@/components/Table';
import {
isRoleExist } from './role.api';
//列表数据
export const columns: BasicColumn[] = [
{
title: '角色名称',
align: 'center',
dataIndex: 'roleName',
},
{
title: '角色编码',
align: 'center',
dataIndex: 'roleCode',
},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
{
label: '角色编码',
field: 'roleCode',
component: 'Input',
//colProps: {span: 6},
},
];
//表单数据
export const formSchema: FormSchema[] = [
{
label: '角色名称',
field: 'roleName',
component: 'Input',
dynamicRules: ({
model, schema }) => {
return [
{
required: true, message: '请输入角色名称!' },
{
max: 30, message