|
|
@ -17,14 +17,15 @@ |
|
|
|
import { ref, unref } from 'vue'; |
|
|
|
import { ref, unref } from 'vue'; |
|
|
|
import { BasicForm, useForm } from '/@/components/Form/index'; |
|
|
|
import { BasicForm, useForm } from '/@/components/Form/index'; |
|
|
|
import { formSchema } from './tenant.data'; |
|
|
|
import { formSchema } from './tenant.data'; |
|
|
|
import { addTenant, editTenant, getTenant } from '/@/api/platform/system/controller/tenant'; |
|
|
|
import {addTenant, editTenant, getTenant, listTenant} from '/@/api/platform/system/controller/tenant'; |
|
|
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
|
|
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
|
|
|
|
|
|
|
import {isEmpty} from "/@/utils/is"; |
|
|
|
|
|
|
|
|
|
|
|
/** 通用变量统一声明区域 */ |
|
|
|
/** 通用变量统一声明区域 */ |
|
|
|
const tag = ref<Nullable<string>>(''); |
|
|
|
const tag = ref<Nullable<string>>(''); |
|
|
|
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
|
|
|
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
|
|
|
const emit = defineEmits(['success', 'register']); |
|
|
|
const emit = defineEmits(['success', 'register']); |
|
|
|
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate }] = useForm({ |
|
|
|
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ |
|
|
|
labelWidth: 100, |
|
|
|
labelWidth: 100, |
|
|
|
schemas: formSchema, |
|
|
|
schemas: formSchema, |
|
|
|
showActionButtonGroup: false, |
|
|
|
showActionButtonGroup: false, |
|
|
@ -38,6 +39,26 @@ |
|
|
|
tag.value = data._tag; |
|
|
|
tag.value = data._tag; |
|
|
|
const tenantId = data.record?.id; |
|
|
|
const tenantId = data.record?.id; |
|
|
|
const props: Partial<ModalProps> = { confirmLoading: false }; |
|
|
|
const props: Partial<ModalProps> = { confirmLoading: false }; |
|
|
|
|
|
|
|
await updateSchema({ |
|
|
|
|
|
|
|
field: 'code', |
|
|
|
|
|
|
|
rules: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
required: true, |
|
|
|
|
|
|
|
whitespace: true, |
|
|
|
|
|
|
|
message: '请输入多租户编码' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
validator: async (rule, value) => { |
|
|
|
|
|
|
|
if (!isEmpty(value)) { |
|
|
|
|
|
|
|
const result = await listTenant({ code: value }); |
|
|
|
|
|
|
|
const list = result.data?.filter(item => item.id != tenantId); |
|
|
|
|
|
|
|
if(list?.length > 0) return Promise.reject('该多租户编码已存在'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Promise.resolve(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
validateTrigger: 'blur' |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
}); |
|
|
|
// 采用tag标签区分操作 |
|
|
|
// 采用tag标签区分操作 |
|
|
|
switch (unref(tag)) { |
|
|
|
switch (unref(tag)) { |
|
|
|
case 'add': |
|
|
|
case 'add': |
|
|
|