Browse Source

chore: 接口compose

master
wangxiang 1 year ago
parent
commit
8bb99b9ab5
  1. 20
      src/api/platform/system/controller/gencodeCustomField.ts
  2. 26
      src/api/platform/system/controller/gencodeCustomObj.ts
  3. 16
      src/api/platform/system/entity/gencodeCustomField.ts
  4. 17
      src/api/platform/system/entity/gencodeCustomObj.ts
  5. 97
      src/views/system/devtools/genCustomObj/ClientModal.vue
  6. 196
      src/views/system/devtools/genCustomObj/GenCustomObjModal.vue
  7. 81
      src/views/system/devtools/genCustomObj/GencodeCustomFieldModal.vue
  8. 154
      src/views/system/devtools/genCustomObj/client.data.ts
  9. 162
      src/views/system/devtools/genCustomObj/genCustomObj.data.ts
  10. 77
      src/views/system/devtools/genCustomObj/index.vue

20
src/api/platform/system/controller/gencodeCustomField.ts

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
import type { GencodeCustomFieldParams, GencodeCustomField, GencodeCustomFieldResult } from '/@/api/platform/system/entity/gencodeCustomField';
import { defHttp } from '/@/utils/http/axios';
enum Api {
list = '/system_proxy/system/devtools/gencodeCustomField/list',
add = '/system_proxy/system/devtools/gencodeCustomField/save',
get = '/system_proxy/system/devtools/gencodeCustomField',
edit = '/system_proxy/system/devtools/gencodeCustomField/update',
del = '/system_proxy/system/devtools/gencodeCustomField/remove',
}
export const listGencodeCustomField = (params?: Partial<GencodeCustomFieldParams>) => defHttp.get<GencodeCustomFieldResult>({ url: Api.list, params }, { isReturnResultResponse: true });
export const addGencodeCustomField = (params: Partial<GencodeCustomField>) => defHttp.post({ url: Api.add, data: params });
export const editGencodeCustomField = (params: Partial<GencodeCustomField>) => defHttp.put({ url: Api.edit, data: params });
export const getGencodeCustomField = (id: string) => defHttp.get<GencodeCustomField>({ url: `${Api.get}/${id}` });
export const delGencodeCustomField = (ids: string) => defHttp.delete({ url: `${Api.del}/${ids}` });

26
src/api/platform/system/controller/gencodeCustomObj.ts

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
import type { GencodeCustomObjParams, GencodeCustomObj, GencodeCustomObjResult } from '/@/api/platform/system/entity/gencodeCustomObj';
import { defHttp } from '/@/utils/http/axios';
enum Api {
list = '/system_proxy/system/devtools/gencodeCustomObj/list',
selectListByValue = '/system_proxy/system/devtools/gencodeCustomObj/selectListByValue',
add = '/system_proxy/system/devtools/gencodeCustomObj/save',
get = '/system_proxy/system/devtools/gencodeCustomObj',
edit = '/system_proxy/system/devtools/gencodeCustomObj/update',
saveAndGencodeCustomField = '/system_proxy/system/devtools/gencodeCustomObj/saveAndGencodeCustomField',
del = '/system_proxy/system/devtools/gencodeCustomObj/remove',
}
export const listGencodeCustomObj = (params?: Partial<GencodeCustomObjParams>) => defHttp.get<GencodeCustomObjResult>({ url: Api.list, params }, { isReturnResultResponse: true });
export const selectListByValue = (type: string) => defHttp.get<GencodeCustomObj[]>({ url: `${Api.selectListByValue}/${type}` });
export const addGencodeCustomObj = (params: Partial<GencodeCustomObj>) => defHttp.post({ url: Api.add, data: params });
export const editGencodeCustomObj = (params: Partial<GencodeCustomObj>) => defHttp.put({ url: Api.edit, data: params });
export const saveAndGencodeCustomField = (params: Partial<GencodeCustomObj>) => defHttp.put({ url: Api.saveAndGencodeCustomField, data: params });
export const getGencodeCustomObj = (id: string) => defHttp.get<GencodeCustomObj>({ url: `${Api.get}/${id}` });
export const delGencodeCustomObj = (ids: string) => defHttp.delete({ url: `${Api.del}/${ids}` });

16
src/api/platform/system/entity/gencodeCustomField.ts

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
import type { R } from '/#/axios';
import type { Page } from '/@/api/common/data/entity';
import type { BaseEntity } from '/@/api/common/base/entity';
export type GencodeCustomFieldParams = Page & GencodeCustomField;
export interface GencodeCustomField extends BaseEntity {
id: string;
name: string;
objId: string;
sort: number;
remarks: string;
[key: string]: any;
}
export type GencodeCustomFieldResult = R<GencodeCustomField[]>;

17
src/api/platform/system/entity/gencodeCustomObj.ts

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
import type { R } from '/#/axios';
import type { Page, CommonEntity } from '/@/api/common/data/entity';
export type GencodeCustomObjParams = Page & GencodeCustomObj;
export interface GencodeCustomObj extends CommonEntity {
id: string;
label: string;
value: string;
dataUrl: string;
tableName: string;
sort: number;
type: string;
[key: string]: any;
}
export type GencodeCustomObjResult = R<GencodeCustomObj[]>;

97
src/views/system/devtools/genCustomObj/ClientModal.vue

@ -1,97 +0,0 @@ @@ -1,97 +0,0 @@
<template>
<BasicModal
v-bind="$attrs"
width="720px"
@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 { formSchema } from './client.data';
import { addClient, editClient, getClient, listClient } from '/@/api/platform/system/controller/client';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
import { isEmpty } from '/@/utils/is';
/** 通用变量统一声明区域 */
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, updateSchema }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: { span: 24 }
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => {
//
await resetFields();
await clearValidate();
//
tag.value = data._tag;
const clientId = data.record?.clientId;
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
switch (unref(tag)) {
case 'add':
props.title = '新增客户端';
break;
case 'edit':
props.title = '编辑客户端';
await setFieldsValue(await getClient(clientId));
break;
}
// :
setModalProps(props);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
//
setModalProps({ confirmLoading: true });
// tag
switch (unref(tag)) {
case 'add':
await addClient(formData);
break;
case 'edit':
await editClient(formData);
break;
}
//
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

196
src/views/system/devtools/genCustomObj/GenCustomObjModal.vue

@ -0,0 +1,196 @@ @@ -0,0 +1,196 @@
<template>
<BasicModal
v-bind="$attrs"
width="820px"
@register="registerModal"
@ok="handleSubmit"
>
<BasicForm @register="registerForm"/>
<BasicTable @register="genTableFieldTypeRegisterTable">
<template #toolbar>
<a-button
v-show="state.tag != 'view'"
type="primary"
@click="handleAdd()"
>新增</a-button>
</template>
<template #bodyCell="{ index, 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, index)
},
{
label: '删除',
icon: 'ant-design:delete-outlined',
color: 'error',
onClick: handleDel.bind(null, record, index)
}]"
/>
</template>
</template>
</BasicTable>
<GenTableFieldTypeModal @register="genTableFieldTypeRegisterModal" @success="handleGenTableFieldType"/>
</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 { BasicModal, ModalProps, useModal, useModalInner } from '/@/components/Modal';
import { BasicTable, TableAction, useTable } from '/@/components/Table';
import GenTableFieldTypeModal from './GenTableFieldTypeModal.vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { isNil } from 'lodash-es';
import { isEmpty } from '/@/utils/is';
/** 通用变量统一声明区域 */
interface WindowState {
tag: string;
dataSource: Recordable[];
}
const state = reactive<WindowState>({
tag: '',
dataSource: []
});
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 getDataSource = computed(() => state.dataSource.filter(item => item._action != 'del'));
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, setProps, updateSchema }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: { span: 24 }
});
const [genTableFieldTypeRegisterTable] = useTable({
dataSource: getDataSource,
rowKey: 'id',
columns: genTableFieldTypeReloadColumns,
useSearchForm: false,
showTableSetting: false,
bordered: true,
pagination: false,
clickToRowSelect: false,
showIndexColumn: false,
maxHeight: 380,
actionColumn: {
width: 220,
title: '操作',
dataIndex: 'action',
fixed: false,
ifShow: () => state.tag != 'view'
},
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => {
//
await resetFields();
await clearValidate();
//
state.tag = data._tag;
state.dataSource = [];
const id = data.record?.id;
const type = data.record?.type;
const props: Partial<ModalProps> = { confirmLoading: false, showOkBtn: true };
await updateSchema({
field: 'type',
componentProps: {
disabled: state.tag != 'add'
},
rules: [
{
required: true,
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('该数据库类型已存在');
}
return Promise.resolve();
},
validateTrigger: 'blur'
}]
});
// tag
switch (state.tag) {
case 'add':
props.title = '新建数据库字段类型';
break;
case 'view':
props.title = '查看数据库字段类型';
props.showOkBtn = false;
const genDatabaseTypeView = await getGenDatabaseType(id);
state.dataSource = genDatabaseTypeView?.genTableFieldTypeList || [];
await setFieldsValue(genDatabaseTypeView);
break;
case 'edit':
props.title = '编辑数据库字段类型';
const genDatabaseTypeEdit = await getGenDatabaseType(id);
state.dataSource = genDatabaseTypeEdit?.genTableFieldTypeList || [];
await setFieldsValue(genDatabaseTypeEdit);
break;
}
// :
setModalProps(props);
});
function handleAdd() {
genTableFieldTypeOpenModal(true,{ _tag: 'add' });
}
function handleEdit(record: Recordable, index: number) {
genTableFieldTypeOpenModal(true, { _tag: 'edit', record, index });
}
function handleViewEdit(record: Recordable) {
genTableFieldTypeOpenModal(true, { _tag: 'view', record });
}
async function handleDel(record: Recordable, index: number) {
createConfirm({
iconType: 'warning',
title: '警告',
content: `是否确认删除标签为${record.label}的数据?`,
onOk: async () => {
if (record.id) {
record._action = 'del';
} else state.dataSource.splice(index, 1);
}
});
}
function handleGenTableFieldType(record: Recordable, index?: number) {
if (!isNil(index) && index !== -1) {
state.dataSource.splice(index, 1, record);
} else state.dataSource.push(record);
}
async function handleSubmit() {
try {
//
const formData = await validate();
formData.genTableFieldTypeList = state.dataSource;
//
setModalProps({ confirmLoading: true });
await saveAndGenTableFieldType(formData);
//
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

81
src/views/system/devtools/genCustomObj/GencodeCustomFieldModal.vue

@ -0,0 +1,81 @@ @@ -0,0 +1,81 @@
<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 { reactive } 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';
/** 通用变量统一声明区域 */
interface WindowState {
tag: string;
index: number;
}
const state = reactive<WindowState>({
tag: '',
index: undefined!
});
/** 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 });
//
state.tag = data._tag;
state.index = data?.index;
const genTableFieldType = cloneDeep(Object(data.record));
const props: Partial<ModalProps> = { confirmLoading: false, showOkBtn: true };
// tag
switch (state.tag) {
case 'add':
props.title = '新增表字段物理类型';
genTableFieldType._action = state.tag;
break;
case 'view':
props.title = '查看表字段物理类型';
await setProps({ disabled: true });
props.showOkBtn = false;
break;
case 'edit':
props.title = '编辑表字段物理类型';
genTableFieldType._action = state.tag;
break;
}
await setFieldsValue(genTableFieldType);
// :
setModalProps(props);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
const formData = await validate();
//
setModalProps({ confirmLoading: true });
emit('success', formData, state.index);
//
closeModal();
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

154
src/views/system/devtools/genCustomObj/client.data.ts

@ -1,154 +0,0 @@ @@ -1,154 +0,0 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
export const columns: BasicColumn[] = [
{
title: '客户端Id',
dataIndex: 'clientId',
width: 100
},
{
title: '客户端密钥',
dataIndex: 'clientSecret',
width: 100
},
{
title: '授权类型',
dataIndex: 'authorizedGrantTypes',
width: 130
},
{
title: '授权范围',
dataIndex: 'scope',
width: 90
},
{
title: '令牌过期秒数',
dataIndex: 'accessTokenValidity',
width: 130
},
{
title: '令牌过期秒数',
dataIndex: 'refreshTokenValidity',
width: 130
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 100
}
];
export const searchFormSchema: FormSchema[] = [
{
field: 'clientId',
label: '客户端编码',
component: 'Input',
componentProps: {
placeholder: '请输入客户端编码',
},
colProps: { span: 8 },
},
{
field: 'dateRange',
label: '创建时间',
component: 'RangePicker',
componentProps: {
style: { width:'100%' },
valueFormat: 'YYYY-MM-DD',
placeholder: ['开始日期','结束日期']
},
colProps: { span: 8 }
}
];
export const formSchema: FormSchema[] = [
{
field: 'id',
label: 'ID',
component: 'Input',
show: false
},
{
field: 'clientId',
label: '客户端Id',
component: 'Input',
required: true,
colProps: {
span: 12
}
},
{
field: 'clientSecret',
label: '客户端密钥',
component: 'Input',
required: true,
colProps: {
span: 12
}
},
{
field: 'authorizedGrantTypes',
label: '授权类型',
component: 'InputTextArea',
required:true,
componentProps: {
rows: 3
},
colProps: {
span: 24
}
},
{
field: 'scope',
label: '授权范围',
component: 'Input',
required:true,
colProps: {
span: 12
}
},
{
field: 'accessTokenValidity',
label: '过期秒数',
component: 'InputNumber',
componentProps: {
style: { width:'100%' },
min: 0
},
colProps: {
span: 12
}
},
{
field: 'refreshTokenValidity',
label: '刷新秒数',
component: 'InputNumber',
componentProps: {
style: { width:'100%' },
min: 0
},
colProps: {
span: 12
}
},
{
field: 'webServerRedirectUri',
label: '回调地址',
component: 'Input',
colProps: {
span: 12
}
},
{
field: 'additionalInformation',
label: '附加说明',
component: 'InputTextArea',
componentProps: {
rows: 6
},
colProps: {
span: 24
}
}
];

162
src/views/system/devtools/genCustomObj/genCustomObj.data.ts

@ -0,0 +1,162 @@ @@ -0,0 +1,162 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
export const columns: BasicColumn[] = [
{
title: '标签',
dataIndex: 'label'
},
{
title: '完整类名',
dataIndex: 'value'
},
{
title: '数据接口',
dataIndex: 'dataUrl'
},
{
title: '物理表名',
dataIndex: 'tableName'
},
{
title: '排序',
dataIndex: 'sort'
}
];
export const searchFormSchema: FormSchema[] = [
{
field: 'label',
label: '标签',
component: 'Input',
componentProps: {
placeholder: '请输入标签',
},
colProps: { span: 6 }
},
{
field: 'value',
label: '完整类名',
component: 'Input',
componentProps: {
placeholder: '请输入完整类名',
},
colProps: { span: 6 }
}
];
export const formSchema: FormSchema[] = [
{
field: 'id',
label: 'ID',
component: 'Input',
show: false
},
{
field: 'label',
label: '标签',
component: 'Input',
colProps: { span: 16 },
required: true
},
{
field: 'value',
label: '完整类名',
component: 'Input',
colProps: { span: 16 },
required: true
},
{
field: 'dataUrl',
label: '数据接口',
component: 'Input',
colProps: { span: 16 }
},
{
field: 'tableName',
label: '物理表名',
component: 'Input',
colProps: { span: 16 }
},
{
field: 'sort',
label: '排序',
component: 'InputNumber',
colProps: { span: 16 },
defaultValue: 1,
required: true,
componentProps: {
style: { width:'100%' },
min: 0
}
},
{
field: 'type',
label: '基本类型',
component: 'RadioGroup',
colProps: { span: 16 },
required: true,
defaultValue: '0',
componentProps: {
options: [
{ label: '是', value: '0' },
{ label: '否', value: '1' }
]
}
}
];
export const formSchemaGencodeCustomField: FormSchema[] = [
{
field: 'id',
label: 'ID',
component: 'Input',
show: false
},
{
field: '_action',
label: '操作标识字段',
component: 'Input',
show: false
},
{
field: 'name',
label: 'java属性',
component: 'Input',
required: true
},
{
field: 'remarks',
label: '备注',
component: 'InputTextArea',
required: true,
componentProps: {
rows: 3
}
},
{
field: 'sort',
label: '排序',
component: 'InputNumber',
componentProps: {
style: { width:'100%' },
min: 0
},
required: true
}
];
export const gencodeCustomFieldColumns: BasicColumn[] = [
{
title: 'java属性',
dataIndex: 'name'
},
{
title: '备注',
dataIndex: 'remarks'
},
{
title: '排序',
dataIndex: 'sort'
}
];

77
src/views/system/devtools/genCustomObj/index.vue

@ -4,66 +4,73 @@ @@ -4,66 +4,73 @@
@register="registerTable"
@selection-change="handleSelectionChange"
>
<template #expandedRowRender="{ record }">
<BasicTable :style="{ margin: '0px' }"
:searchInfo="{
typeId: record.id,
size: 999
}"
@register="genTableFieldTypeRegisterTable"
/>
</template>
<template #toolbar>
<a-button
v-auth="['client_add']"
type="primary"
@click="handleAdd()"
>新增客户端</a-button>
>新增</a-button>
<a-button
v-auth="['client_edit']"
type="primary"
:disabled="state.single"
@click="handleEdit()"
>修改客户端</a-button>
>修改</a-button>
<a-button
v-auth="['client_del']"
type="primary"
:disabled="state.multiple"
@click="handleDel()"
>删除客户端</a-button>
>删除</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',
auth: ['client_edit'],
onClick: handleEdit.bind(null, record)
},
{
label: '删除',
icon: 'ant-design:delete-outlined',
color: 'error',
auth: ['client_del'],
onClick: handleDel.bind(null, record)
}]"
/>
</template>
</template>
</BasicTable>
<!--弹出窗体区域-->
<ClientModal @register="registerModal" @success="handleRefreshTable"/>
<GenDataBaseTypeModal @register="registerModal" @success="handleRefreshTable"/>
</div>
</template>
<script lang="ts" setup>
import { reactive, toRaw } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { listClient, delClient } from '/@/api/platform/system/controller/client';
import { useModal } from '/@/components/Modal';
import ClientModal from './ClientModal.vue';
import { columns, searchFormSchema } from './client.data';
import GenDataBaseTypeModal from './GenDataBaseTypeModal.vue';
import {columns, genTableFieldTypeReloadColumns, searchFormSchema} from './genDataBaseType.data';
import { useMessage } from '/@/hooks/web/useMessage';
import { listGenDatabaseType, delGenDatabaseType } from '/@/api/platform/system/controller/genDatabaseType';
import { listGenTableFieldType } from '/@/api/platform/system/controller/genTableFieldType';
interface TableState {
single: boolean;
multiple: boolean;
}
/** 通用变量统一声明区域 */
const state = reactive<TableState>({
//
single: true,
@ -73,18 +80,17 @@ @@ -73,18 +80,17 @@
const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({
title: '客户端列表',
api: listClient,
rowKey: 'clientId',
title: '数据库类型列表',
api: listGenDatabaseType,
rowKey: 'id',
columns,
formConfig: {
compact: true,
labelWidth: 100,
labelWidth: 80,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
autoAdvancedLine: 3,
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']]
},
rowSelection: { type: 'checkbox' },
useSearchForm: true,
@ -96,48 +102,59 @@ @@ -96,48 +102,59 @@
width: 220,
title: '操作',
dataIndex: 'action',
//slots: { customRender: 'action' },
fixed: false
},
handleSearchInfoFn: () => clearSelectedRowKeys()
});
const [genTableFieldTypeRegisterTable] = useTable({
api: listGenTableFieldType,
rowKey: 'id',
columns: genTableFieldTypeReloadColumns,
useSearchForm: false,
showTableSetting: false,
bordered: true,
pagination: false,
clickToRowSelect: false,
showIndexColumn: false,
});
/** 处理多选框选中数据 */
function handleSelectionChange(selection?: Recordable) {
const rowSelection = toRaw(selection?.keys) || [];
state.single = rowSelection.length != 1;
state.multiple = !rowSelection.length;
}
/** 新增按钮操作,行内新增与工具栏局域新增通用 */
function handleAdd() {
openModal(true,{ _tag: 'add' });
}
/** 编辑按钮操作,行内编辑 */
function handleEdit(record?: Recordable) {
record = record || { clientId: getSelectRowKeys() };
record = record || { id: getSelectRowKeys() };
openModal(true, { _tag: 'edit', record });
}
/** 删除按钮操作,行内删除 */
function handleViewEdit(record?: Recordable) {
record = record || { id: getSelectRowKeys() };
openModal(true, { _tag: 'view', record });
}
async function handleDel(record?: Recordable) {
const clientIds = record?.clientId || getSelectRowKeys();
const ids = record?.id || getSelectRowKeys();
createConfirm({
iconType: 'warning',
title: '警告',
content: `是否确认删除客户端编号${clientIds}客户端吗?`,
content: `是否确认删除id${ids}的数据?`,
onOk: async () => {
await delClient(clientIds);
await delGenDatabaseType(ids);
createMessage.success('删除成功!');
handleRefreshTable();
}
});
}
/** 处理表格刷新 */
function handleRefreshTable() {
clearSelectedRowKeys();
reload();
}
</script>

Loading…
Cancel
Save