Browse Source

chore: 控件类型模块

master
wangxiang 1 year ago
parent
commit
36ea5d5026
  1. 20
      src/api/platform/system/controller/genShowType.ts
  2. 17
      src/api/platform/system/entity/genShowType.ts
  3. 2
      src/views/system/devtools/genCustomObj/GenCustomObjModal.vue
  4. 51
      src/views/system/devtools/genShowType/GenShowTypeModal.vue
  5. 154
      src/views/system/devtools/genShowType/client.data.ts
  6. 92
      src/views/system/devtools/genShowType/genShowType.data.ts
  7. 51
      src/views/system/devtools/genShowType/index.vue

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

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
import type { GenShowType, GenShowTypeParams, GenShowTypeResult } from '/@/api/platform/system/entity/genShowType';
import { defHttp } from '/@/utils/http/axios';
enum Api {
list = '/system_proxy/system/devtools/genShowType/list',
add = '/system_proxy/system/devtools/genShowType/save',
get = '/system_proxy/system/devtools/genShowType',
edit = '/system_proxy/system/devtools/genShowType/update',
del = '/system_proxy/system/devtools/genShowType/remove'
}
export const listGenShowType = (params?: Partial<GenShowTypeParams>) => defHttp.get<GenShowTypeResult>({ url: Api.list, params }, { isReturnResultResponse: true });
export const addGenShowType = (params: Partial<GenShowType>) => defHttp.post({ url: Api.add, data: params });
export const editGenShowType = (params: Partial<GenShowType>) => defHttp.put({ url: Api.edit, data: params });
export const getGenShowType = (id: string) => defHttp.get<GenShowType>({ url: `${Api.get}/${id}` });
export const delGenShowType = (ids: string) => defHttp.delete({ url: `${Api.del}/${ids}` });

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

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
import type { R } from '/#/axios';
import type { Page } from '/@/api/common/data/entity';
import type { BaseEntity } from '/@/api/common/base/entity';
export type GenShowTypeParams = Page & GenShowType;
export interface GenShowType extends BaseEntity {
id: string;
label: string;
value: string;
sort: number;
component: string;
importpath: string;
[key: string]: any;
}
export type GenShowTypeResult = R<GenShowType[]>;

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

@ -111,6 +111,7 @@ @@ -111,6 +111,7 @@
const id = data.record?.id;
const classValue = data.record?.value;
const props: Partial<ModalProps> = { confirmLoading: false, showOkBtn: true };
await setProps({ disabled: false });
await updateSchema([{
field: 'value',
componentProps: {
@ -147,6 +148,7 @@ @@ -147,6 +148,7 @@
case 'view':
props.title = '查看java类型';
props.showOkBtn = false;
await setProps({ disabled: true });
const getGencodeCustomObjView = await getGencodeCustomObj(id);
state.dataSource = getGencodeCustomObjView?.gencodeCustomFieldList || [];
state.tableVisible = getGencodeCustomObjView.type == '0';

51
src/views/system/devtools/genShowType/ClientModal.vue → src/views/system/devtools/genShowType/GenShowTypeModal.vue

@ -11,16 +11,15 @@ @@ -11,16 +11,15 @@
<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 { formSchema } from './genShowType.data';
import { addGenShowType, editGenShowType, getGenShowType } from '/@/api/platform/system/controller/genShowType';
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({
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, setProps, updateSchema }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
@ -30,41 +29,25 @@ @@ -30,41 +29,25 @@
//
await resetFields();
await clearValidate();
await setProps({ disabled: false });
//
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'
}]
});
const id = data.record?.id;
const props: Partial<ModalProps> = { confirmLoading: false, showOkBtn: true };
// tag
switch (unref(tag)) {
case 'add':
props.title = '新增客户端';
props.title = '新增控件类型';
break;
case 'view':
props.title = '查看控件类型';
props.showOkBtn = false;
await setProps({ disabled: true });
await setFieldsValue(await getGenShowType(id));
break;
case 'edit':
props.title = '编辑客户端';
await setFieldsValue(await getClient(clientId));
props.title = '编辑控件类型';
await setFieldsValue(await getGenShowType(id));
break;
}
// :
@ -81,10 +64,10 @@ @@ -81,10 +64,10 @@
// tag
switch (unref(tag)) {
case 'add':
await addClient(formData);
await addGenShowType(formData);
break;
case 'edit':
await editClient(formData);
await editGenShowType(formData);
break;
}
//

154
src/views/system/devtools/genShowType/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
}
}
];

92
src/views/system/devtools/genShowType/genShowType.data.ts

@ -0,0 +1,92 @@ @@ -0,0 +1,92 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
export const columns: BasicColumn[] = [
{
title: '标签',
dataIndex: 'label',
width: 100
},
{
title: '值',
dataIndex: 'value',
width: 100
},
{
title: 'ui组件',
dataIndex: 'component',
width: 130
},
{
title: '引入路径',
dataIndex: 'importpath',
width: 90
},
{
title: '排序',
dataIndex: 'sort',
width: 130
}
];
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',
required: true
},
{
field: 'value',
label: '值',
component: 'Input',
required: true
},
{
field: 'component',
label: 'UI组件',
component: 'Input'
},
{
field: 'importpath',
label: '引入路径',
component: 'Input'
},
{
field: 'sort',
label: '排序',
component: 'InputNumber',
componentProps: {
style: { width:'100%' },
min: 0
},
required: true
}
];

51
src/views/system/devtools/genShowType/index.vue

@ -6,38 +6,38 @@ @@ -6,38 +6,38 @@
>
<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)
}]"
/>
@ -45,17 +45,17 @@ @@ -45,17 +45,17 @@
</template>
</BasicTable>
<!--弹出窗体区域-->
<ClientModal @register="registerModal" @success="handleRefreshTable"/>
<GenShowTypeModal @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 { listGenShowType, delGenShowType } from '/@/api/platform/system/controller/genShowType';
import { useModal } from '/@/components/Modal';
import ClientModal from './ClientModal.vue';
import { columns, searchFormSchema } from './client.data';
import GenShowTypeModal from './GenShowTypeModal.vue';
import { columns, searchFormSchema } from './genShowType.data';
import { useMessage } from '/@/hooks/web/useMessage';
interface TableState {
@ -73,9 +73,8 @@ @@ -73,9 +73,8 @@
const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({
title: '客户端列表',
api: listClient,
rowKey: 'clientId',
api: listGenShowType,
rowKey: 'id',
columns,
formConfig: {
compact: true,
@ -83,8 +82,7 @@ @@ -83,8 +82,7 @@
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
autoAdvancedLine: 3,
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']]
autoAdvancedLine: 3
},
rowSelection: { type: 'checkbox' },
useSearchForm: true,
@ -96,7 +94,6 @@ @@ -96,7 +94,6 @@
width: 220,
title: '操作',
dataIndex: 'action',
//slots: { customRender: 'action' },
fixed: false
},
handleSearchInfoFn: () => clearSelectedRowKeys()
@ -109,35 +106,37 @@ @@ -109,35 +106,37 @@
state.multiple = !rowSelection.length;
}
/** 新增按钮操作,行内新增与工具栏局域新增通用 */
function handleAdd() {
openModal(true,{ _tag: 'add' });
}
/** 编辑按钮操作,行内编辑 */
function handleViewEdit(record?: Recordable) {
record = record || { id: getSelectRowKeys() };
openModal(true, { _tag: 'view', record });
}
function handleEdit(record?: Recordable) {
record = record || { clientId: getSelectRowKeys() };
record = record || { id: getSelectRowKeys() };
openModal(true, { _tag: 'edit', 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 delGenShowType(ids);
createMessage.success('删除成功!');
handleRefreshTable();
}
});
}
/** 处理表格刷新 */
function handleRefreshTable() {
clearSelectedRowKeys();
reload();
}
</script>

Loading…
Cancel
Save