|
|
|
@ -6,7 +6,7 @@
@@ -6,7 +6,7 @@
|
|
|
|
|
@ok="handleSubmit" |
|
|
|
|
> |
|
|
|
|
<BasicForm @register="registerForm"/> |
|
|
|
|
<BasicTable @register="genTableFieldTypeRegisterTable"> |
|
|
|
|
<BasicTable @register="gencodeCustomFieldRegisterTable"> |
|
|
|
|
<template #toolbar> |
|
|
|
|
<a-button |
|
|
|
|
v-show="state.tag != 'view'" |
|
|
|
@ -38,17 +38,17 @@
@@ -38,17 +38,17 @@
|
|
|
|
|
</template> |
|
|
|
|
</template> |
|
|
|
|
</BasicTable> |
|
|
|
|
<GenTableFieldTypeModal @register="genTableFieldTypeRegisterModal" @success="handleGenTableFieldType"/> |
|
|
|
|
<GencodeCustomFieldModal @register="gencodeCustomFieldRegisterModal" @success="handleGencodeCustomField"/> |
|
|
|
|
</BasicModal> |
|
|
|
|
</template> |
|
|
|
|
<script lang="ts" setup> |
|
|
|
|
import { reactive, computed } from 'vue'; |
|
|
|
|
import { BasicForm, useForm } from '/@/components/Form/index'; |
|
|
|
|
import { formSchema, genTableFieldTypeReloadColumns } from './genDataBaseType.data'; |
|
|
|
|
import { saveAndGenTableFieldType, getGenDatabaseType, selectListByType } from '/@/api/platform/system/controller/genDatabaseType'; |
|
|
|
|
import { formSchema, gencodeCustomFieldColumns } from './genCustomObj.data'; |
|
|
|
|
import { saveAndGencodeCustomField, getGencodeCustomObj, selectListByValue } from '/@/api/platform/system/controller/gencodeCustomObj'; |
|
|
|
|
import { BasicModal, ModalProps, useModal, useModalInner } from '/@/components/Modal'; |
|
|
|
|
import { BasicTable, TableAction, useTable } from '/@/components/Table'; |
|
|
|
|
import GenTableFieldTypeModal from './GenTableFieldTypeModal.vue'; |
|
|
|
|
import GencodeCustomFieldModal from './GencodeCustomFieldModal.vue'; |
|
|
|
|
import { useMessage } from '/@/hooks/web/useMessage'; |
|
|
|
|
import { isNil } from 'lodash-es'; |
|
|
|
|
import { isEmpty } from '/@/utils/is'; |
|
|
|
@ -65,7 +65,7 @@
@@ -65,7 +65,7 @@
|
|
|
|
|
const { createConfirm, createMessage } = useMessage(); |
|
|
|
|
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
|
|
|
|
const emit = defineEmits(['success', 'register']); |
|
|
|
|
const [genTableFieldTypeRegisterModal, { openModal: genTableFieldTypeOpenModal }] = useModal(); |
|
|
|
|
const [gencodeCustomFieldRegisterModal, { openModal: gencodeCustomFieldOpenModal }] = useModal(); |
|
|
|
|
const getDataSource = computed(() => state.dataSource.filter(item => item._action != 'del')); |
|
|
|
|
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, setProps, updateSchema }] = useForm({ |
|
|
|
|
labelWidth: 100, |
|
|
|
@ -73,10 +73,10 @@
@@ -73,10 +73,10 @@
|
|
|
|
|
showActionButtonGroup: false, |
|
|
|
|
baseColProps: { span: 24 } |
|
|
|
|
}); |
|
|
|
|
const [genTableFieldTypeRegisterTable] = useTable({ |
|
|
|
|
const [gencodeCustomFieldRegisterTable] = useTable({ |
|
|
|
|
dataSource: getDataSource, |
|
|
|
|
rowKey: 'id', |
|
|
|
|
columns: genTableFieldTypeReloadColumns, |
|
|
|
|
columns: gencodeCustomFieldColumns, |
|
|
|
|
useSearchForm: false, |
|
|
|
|
showTableSetting: false, |
|
|
|
|
bordered: true, |
|
|
|
@ -100,24 +100,24 @@
@@ -100,24 +100,24 @@
|
|
|
|
|
state.tag = data._tag; |
|
|
|
|
state.dataSource = []; |
|
|
|
|
const id = data.record?.id; |
|
|
|
|
const type = data.record?.type; |
|
|
|
|
const classValue = data.record?.value; |
|
|
|
|
const props: Partial<ModalProps> = { confirmLoading: false, showOkBtn: true }; |
|
|
|
|
await updateSchema({ |
|
|
|
|
field: 'type', |
|
|
|
|
field: 'value', |
|
|
|
|
componentProps: { |
|
|
|
|
disabled: state.tag != 'add' |
|
|
|
|
}, |
|
|
|
|
rules: [ |
|
|
|
|
{ |
|
|
|
|
required: true, |
|
|
|
|
message: '请选择数据库类型' |
|
|
|
|
message: '请输入完整类名' |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
validator: async (rule, value) => { |
|
|
|
|
if (!isEmpty(value)) { |
|
|
|
|
const result = await selectListByType(value); |
|
|
|
|
const list = result.filter(item => item.type != type); |
|
|
|
|
if(list?.length > 0) return Promise.reject('该数据库类型已存在'); |
|
|
|
|
const result = await selectListByValue(value); |
|
|
|
|
const list = result.filter(item => item.value != classValue); |
|
|
|
|
if(list?.length > 0) return Promise.reject('该完整类名已存在'); |
|
|
|
|
} |
|
|
|
|
return Promise.resolve(); |
|
|
|
|
}, |
|
|
|
@ -127,20 +127,20 @@
@@ -127,20 +127,20 @@
|
|
|
|
|
// 采用tag标签区分操作 |
|
|
|
|
switch (state.tag) { |
|
|
|
|
case 'add': |
|
|
|
|
props.title = '新建数据库字段类型'; |
|
|
|
|
props.title = '新建java类型'; |
|
|
|
|
break; |
|
|
|
|
case 'view': |
|
|
|
|
props.title = '查看数据库字段类型'; |
|
|
|
|
props.title = '查看java类型'; |
|
|
|
|
props.showOkBtn = false; |
|
|
|
|
const genDatabaseTypeView = await getGenDatabaseType(id); |
|
|
|
|
state.dataSource = genDatabaseTypeView?.genTableFieldTypeList || []; |
|
|
|
|
await setFieldsValue(genDatabaseTypeView); |
|
|
|
|
const getGencodeCustomObjView = await getGencodeCustomObj(id); |
|
|
|
|
state.dataSource = getGencodeCustomObjView?.gencodeCustomFieldList || []; |
|
|
|
|
await setFieldsValue(getGencodeCustomObjView); |
|
|
|
|
break; |
|
|
|
|
case 'edit': |
|
|
|
|
props.title = '编辑数据库字段类型'; |
|
|
|
|
const genDatabaseTypeEdit = await getGenDatabaseType(id); |
|
|
|
|
state.dataSource = genDatabaseTypeEdit?.genTableFieldTypeList || []; |
|
|
|
|
await setFieldsValue(genDatabaseTypeEdit); |
|
|
|
|
props.title = '编辑java类型'; |
|
|
|
|
const getGencodeCustomObjEdit = await getGencodeCustomObj(id); |
|
|
|
|
state.dataSource = getGencodeCustomObjEdit?.gencodeCustomFieldList || []; |
|
|
|
|
await setFieldsValue(getGencodeCustomObjEdit); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
// 尾部:设置处理后的最终配置数据 |
|
|
|
@ -148,15 +148,15 @@
@@ -148,15 +148,15 @@
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
function handleAdd() { |
|
|
|
|
genTableFieldTypeOpenModal(true,{ _tag: 'add' }); |
|
|
|
|
gencodeCustomFieldOpenModal(true,{ _tag: 'add' }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function handleEdit(record: Recordable, index: number) { |
|
|
|
|
genTableFieldTypeOpenModal(true, { _tag: 'edit', record, index }); |
|
|
|
|
gencodeCustomFieldOpenModal(true, { _tag: 'edit', record, index }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function handleViewEdit(record: Recordable) { |
|
|
|
|
genTableFieldTypeOpenModal(true, { _tag: 'view', record }); |
|
|
|
|
gencodeCustomFieldOpenModal(true, { _tag: 'view', record }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function handleDel(record: Recordable, index: number) { |
|
|
|
@ -172,7 +172,7 @@
@@ -172,7 +172,7 @@
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function handleGenTableFieldType(record: Recordable, index?: number) { |
|
|
|
|
function handleGencodeCustomField(record: Recordable, index?: number) { |
|
|
|
|
if (!isNil(index) && index !== -1) { |
|
|
|
|
state.dataSource.splice(index, 1, record); |
|
|
|
|
} else state.dataSource.push(record); |
|
|
|
@ -182,10 +182,10 @@
@@ -182,10 +182,10 @@
|
|
|
|
|
try { |
|
|
|
|
// 提取验证数据 |
|
|
|
|
const formData = await validate(); |
|
|
|
|
formData.genTableFieldTypeList = state.dataSource; |
|
|
|
|
formData.gencodeCustomFieldList = state.dataSource; |
|
|
|
|
// 处理提交之前逻辑 |
|
|
|
|
setModalProps({ confirmLoading: true }); |
|
|
|
|
await saveAndGenTableFieldType(formData); |
|
|
|
|
await saveAndGencodeCustomField(formData); |
|
|
|
|
// 处理提交完成之后逻辑 |
|
|
|
|
closeModal(); |
|
|
|
|
emit('success'); |
|
|
|
|