Browse Source

chore: 样式调整

master
wangxiang 1 year ago
parent
commit
65c0915534
  1. 138
      src/views/system/devtools/genDataBaseType/GenDataBaseTypeModal.vue
  2. 69
      src/views/system/devtools/genDataBaseType/GenTableFieldTypeModal.vue
  3. 57
      src/views/system/devtools/genDataBaseType/genDataBaseType.data.ts

138
src/views/system/devtools/genDataBaseType/GenDataBaseTypeModal.vue

@ -1,95 +1,145 @@
<template> <template>
<BasicModal <BasicModal
v-bind="$attrs" v-bind="$attrs"
width="720px" width="820px"
@register="registerModal" @register="registerModal"
@ok="handleSubmit" @ok="handleSubmit"
> >
<BasicForm @register="registerForm"/> <BasicForm @register="registerForm"/>
<BasicTable @register="genTableFieldTypeRegisterTable">
<template #toolbar>
<a-button
type="primary"
@click="handleAdd()"
>新增</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
label: '查看',
icon: 'fa-regular:eye',
onClick: handleViewEdit.bind(null, record)
},
{
label: '编辑',
icon: 'fa6-regular:pen-to-square',
onClick: handleEdit.bind(null, record)
},
{
label: '删除',
icon: 'ant-design:delete-outlined',
color: 'error',
onClick: handleDel.bind(null, record)
}]"
/>
</template>
</template>
</BasicTable>
<GenTableFieldTypeModal @register="genTableFieldTypeRegisterModal" @success="handleGenTableFieldType"/>
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
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 './genDataBaseType.data'; import { formSchema, genTableFieldTypeReloadColumns } from './genDataBaseType.data';
import { addClient, editClient, getClient, listClient } from '/@/api/platform/system/controller/client'; import { editGenDatabaseType, getGenDatabaseType } from '/@/api/platform/system/controller/genDatabaseType';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; import { BasicModal, ModalProps, useModal, useModalInner } from '/@/components/Modal';
import { isEmpty } from '/@/utils/is'; import { BasicTable, TableAction, useTable } from '/@/components/Table';
import GenTableFieldTypeModal from './GenTableFieldTypeModal.vue';
import { useMessage } from '/@/hooks/web/useMessage';
/** 通用变量统一声明区域 */ /** 通用变量统一声明区域 */
const tag = ref<Nullable<string>>(''); const tag = ref<Nullable<string>>('');
const { createConfirm, createMessage } = useMessage();
/** 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, updateSchema }] = useForm({ const [genTableFieldTypeRegisterModal, { openModal: genTableFieldTypeOpenModal }] = useModal();
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, setProps }] = useForm({
labelWidth: 100, labelWidth: 100,
schemas: formSchema, schemas: formSchema,
showActionButtonGroup: false, showActionButtonGroup: false,
baseColProps: { span: 24 } baseColProps: { span: 24 }
}); });
const [genTableFieldTypeRegisterTable] = useTable({
dataSource: [],
rowKey: 'id',
columns: genTableFieldTypeReloadColumns,
useSearchForm: false,
showTableSetting: false,
bordered: true,
pagination: false,
clickToRowSelect: false,
showIndexColumn: false,
actionColumn: {
width: 220,
title: '操作',
dataIndex: 'action',
fixed: false
},
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => { const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => {
// //
await resetFields(); await resetFields();
await clearValidate(); await clearValidate();
await setProps({ disabled: false });
// //
tag.value = data._tag; tag.value = data._tag;
const clientId = data.record?.clientId; const id = data.record?.id;
const props: Partial<ModalProps> = { confirmLoading: false }; const props: Partial<ModalProps> = { confirmLoading: false };
await updateSchema({
field: 'clientId',
componentProps: {
disabled: unref(tag) != 'add'
},
rules: [
{
required: true,
whitespace: true,
message: '请输入客户端编码'
},
{
validator: async (rule, value) => {
if (!isEmpty(value)) {
const result = await listClient({ clientId: value });
const list = result.data?.filter(item => item.clientId != clientId);
if(list?.length > 0) return Promise.reject('该客户端编码已存在');
}
return Promise.resolve();
},
validateTrigger: 'blur'
}]
});
// tag // tag
switch (unref(tag)) { switch (unref(tag)) {
case 'add': case 'add':
props.title = '新增客户端'; props.title = '新建数据库字段类型';
break; break;
case 'view': case 'view':
props.title = '查看客户端'; props.title = '查看数据库字段类型';
await setProps({ disabled: true });
break; break;
case 'edit': case 'edit':
props.title = '编辑客户端'; props.title = '编辑数据库字段类型';
await setFieldsValue(await getClient(clientId)); await setFieldsValue(await getGenDatabaseType(id));
break; break;
} }
// : // :
setModalProps(props); setModalProps(props);
}); });
/** 处理弹出框提交 */ function handleAdd() {
genTableFieldTypeOpenModal(true,{ _tag: 'add' });
}
function handleEdit(record: Recordable) {
genTableFieldTypeOpenModal(true, { _tag: 'edit', record });
}
function handleViewEdit(record: Recordable) {
genTableFieldTypeOpenModal(true, { _tag: 'view', record });
}
async function handleDel(record: Recordable) {
createConfirm({
iconType: 'warning',
title: '警告',
content: `是否确认删除标签为${record.lable}的数据?`,
onOk: async () => {
}
});
}
function handleGenTableFieldType(record: Recordable) {
}
async function handleSubmit() { async function handleSubmit() {
try { try {
// //
const formData = await validate(); const formData = await validate();
// //
setModalProps({ confirmLoading: true }); setModalProps({ confirmLoading: true });
// tag await editGenDatabaseType(formData);
switch (unref(tag)) {
case 'add':
await addClient(formData);
break;
case 'edit':
await editClient(formData);
break;
}
// //
closeModal(); closeModal();
emit('success'); emit('success');

69
src/views/system/devtools/genDataBaseType/GenTableFieldTypeModal.vue

@ -0,0 +1,69 @@
<template>
<BasicModal
v-bind="$attrs"
width="720px"
:bodyStyle="{ 'margin-top': '25px' }"
@register="registerModal"
@ok="handleSubmit"
>
<BasicForm @register="registerForm"/>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, unref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchemaGenTableFieldType } from './genDataBaseType.data';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
import { cloneDeep } from 'lodash-es';
/** 通用变量统一声明区域 */
const tag = ref<Nullable<string>>('');
/** https://v3.cn.vuejs.org/api/options-data.html#emits */
const emit = defineEmits(['success', 'register']);
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, setProps }] = useForm({
labelWidth: 80,
schemas: formSchemaGenTableFieldType,
showActionButtonGroup: false,
baseColProps: { span: 24 }
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => {
//
await resetFields();
await clearValidate();
await setProps({ disabled: false });
//
tag.value = data._tag;
const props: Partial<ModalProps> = { confirmLoading: false };
// tag
switch (unref(tag)) {
case 'add':
props.title = '新增表字段物理类型';
break;
case 'view':
props.title = '查看表字段物理类型';
await setProps({ disabled: true });
break;
case 'edit':
props.title = '编辑表字段物理类型';
await setFieldsValue(cloneDeep(Object(data.record)));
break;
}
// :
setModalProps(props);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
//
setModalProps({ confirmLoading: true });
//
closeModal();
emit('success', formData);
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

57
src/views/system/devtools/genDataBaseType/genDataBaseType.data.ts

@ -35,42 +35,47 @@ export const formSchema: FormSchema[] = [
show: false show: false
}, },
{ {
field: 'nickName', field: 'typeId',
label: '昵称', label: '数据库类型',
component: 'Input', component: 'ApiSelect',
}, colProps: { span: 16 },
componentProps: {
api: listGenDatabaseType,
params: {
size: 99
},
labelField: 'type',
valueField: 'id',
resultField: 'data'
}
}
];
export const formSchemaGenTableFieldType: FormSchema[] = [
{ {
field: 'deptName', field: 'id',
label: '所属部门', label: 'ID',
component: 'Input', component: 'Input',
colProps: { show: false
span: 12
},
}, },
{ {
field: 'sex', field: 'label',
label: '性别', label: '标签',
component: 'Select', component: 'Input',
colProps: { required: true
span: 12
},
componentProps: {
options: [
{ label: '男', value: '0' },
{ label: '女', value: '1' }
]
},
}, },
{ {
field: 'phone', field: 'value',
label: '手机号', label: '值',
component: 'Input', component: 'Input',
required: true
}, },
{ {
field: 'email', field: 'sort',
label: '邮箱', label: '排序',
component: 'Input', component: 'Input',
}, required: true
}
]; ];
export const genTableFieldTypeReloadColumns: BasicColumn[] = [ export const genTableFieldTypeReloadColumns: BasicColumn[] = [

Loading…
Cancel
Save