Browse Source

chore: 重构表单版本管理

master
wangxiang 2 years ago
parent
commit
1d50f0b6c6
  1. 2
      src/views/workflow/extension/formJson/FormJsonModal.vue
  2. 62
      src/views/workflow/extension/formJson/index.vue

2
src/views/workflow/extension/formJson/FormJsonModal.vue

@ -48,7 +48,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
mountApp: FORM_DESIGN_APP_COMPONENTS.PREVIEW mountApp: FORM_DESIGN_APP_COMPONENTS.PREVIEW
} }
}), { sandbox: { experimentalStyleIsolation: true }}); }), { sandbox: { experimentalStyleIsolation: true }});
data?.json && (formPreviewProps.options = data?.json); data?.json && (formPreviewProps.options = eval('(' + data.json + ')') );
const props: Partial<ModalProps> = { confirmLoading: false }; const props: Partial<ModalProps> = { confirmLoading: false };
props.title = '预览流程表单'; props.title = '预览流程表单';
setModalProps(props); setModalProps(props);

62
src/views/workflow/extension/formJson/index.vue

@ -6,7 +6,6 @@
> >
<template #toolbar> <template #toolbar>
<a-button <a-button
v-auth="['client_del']"
type="primary" type="primary"
:disabled="state.multiple" :disabled="state.multiple"
@click="handleDel()" @click="handleDel()"
@ -18,28 +17,25 @@
:actions="[ :actions="[
{ {
label: '预览', label: '预览',
icon: 'fa6-regular:pen-to-square', icon: 'fa6-brands:dev',
auth: ['client_edit'], onClick: handleFormPreview.bind(null, record)
onClick: handleEdit.bind(null, record)
}, },
{ {
label: '设置为主版本', label: '设置为主版本',
icon: 'ant-design:delete-outlined', icon: 'fa6-brands:dev',
color: 'error', onClick: handleSetFormPrimaryVersion.bind(null, record)
auth: ['client_del'],
onClick: handleDel.bind(null, record)
}, },
{ {
label: '删除', label: '删除',
icon: 'ant-design:delete-outlined', icon: 'fa6-brands:dev',
color: 'error', color: 'error',
auth: ['client_del'],
onClick: handleDel.bind(null, record) onClick: handleDel.bind(null, record)
}]" }]"
/> />
</template> </template>
</template> </template>
</BasicTable> </BasicTable>
<FormJsonModal @register="registerModal" @success="handleRefreshTable"/>
</div> </div>
</template> </template>
@ -50,12 +46,14 @@
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. * Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved.
* author entfrm开发团队-王翔 * author entfrm开发团队-王翔
*/ */
import { reactive, toRaw } from 'vue'; import { reactive, toRaw, unref } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { listClient, delClient } from '/@/api/platform/system/controller/client'; import { listFormDefinitionJson, delFormDefinitionJson, setPrimaryVersion } from '/@/api/platform/workflow/extension/controller/formDefinitionJson';
import { useModal } from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import { columns, searchFormSchema } from './formJson.data'; import { columns, searchFormSchema } from './formJson.data';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import FormJsonModal from './FormJsonModal.vue';
import { useRouter } from 'vue-router';
/** 类型规范统一声明定义区域 */ /** 类型规范统一声明定义区域 */
interface TableState { interface TableState {
@ -70,12 +68,13 @@
// //
multiple: true multiple: true
}); });
const { currentRoute } = useRouter();
const { createConfirm, createMessage } = useMessage(); const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal(); const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({
title: '列表', title: '表单版本管理列表',
api: listClient, api: listFormDefinitionJson,
rowKey: 'clientId', rowKey: 'id',
columns, columns,
formConfig: { formConfig: {
compact: true, compact: true,
@ -84,7 +83,6 @@
autoSubmitOnEnter: true, autoSubmitOnEnter: true,
showAdvancedButton: true, showAdvancedButton: true,
autoAdvancedLine: 3, autoAdvancedLine: 3,
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']]
}, },
rowSelection: { type: 'checkbox' }, rowSelection: { type: 'checkbox' },
useSearchForm: true, useSearchForm: true,
@ -98,43 +96,49 @@
dataIndex: 'action', dataIndex: 'action',
fixed: false fixed: false
}, },
searchInfo: {
formDefinitionId: unref(currentRoute).params.id
},
handleSearchInfoFn: () => clearSelectedRowKeys() handleSearchInfoFn: () => clearSelectedRowKeys()
}); });
/** 处理多选框选中数据 */
function handleSelectionChange(selection?: Recordable) { function handleSelectionChange(selection?: Recordable) {
const rowSelection = toRaw(selection?.keys) || []; const rowSelection = toRaw(selection?.keys) || [];
state.single = rowSelection.length != 1; state.single = rowSelection.length != 1;
state.multiple = !rowSelection.length; state.multiple = !rowSelection.length;
} }
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ function handleSetFormPrimaryVersion(record: Recordable) {
function handleAdd() { createConfirm({
openModal(true,{ _tag: 'add' }); iconType: 'warning',
title: '警告',
content: '确定设置表单该版本为主版本吗?',
onOk: async () => {
await setPrimaryVersion(record.id);
createMessage.success('设置成功!');
handleRefreshTable();
}
});
} }
/** 编辑按钮操作,行内编辑 */ function handleFormPreview(record: Recordable) {
function handleEdit(record?: Recordable) { openModal(true,{ json: record.json });
record = record || { clientId: getSelectRowKeys() };
openModal(true, { _tag: 'edit', record });
} }
/** 删除按钮操作,行内删除 */
async function handleDel(record?: Recordable) { async function handleDel(record?: Recordable) {
const clientIds = record?.clientId || getSelectRowKeys(); const ids = record?.id || getSelectRowKeys();
createConfirm({ createConfirm({
iconType: 'warning', iconType: 'warning',
title: '警告', title: '警告',
content: `是否确认删除客户端编号为${clientIds}客户端吗?`, content: `是否确认删除表单版本编号为${ids}表单吗?`,
onOk: async () => { onOk: async () => {
await delClient(clientIds); await delFormDefinitionJson(ids);
createMessage.success('删除成功!'); createMessage.success('删除成功!');
handleRefreshTable(); handleRefreshTable();
} }
}); });
} }
/** 处理表格刷新 */
function handleRefreshTable() { function handleRefreshTable() {
clearSelectedRowKeys(); clearSelectedRowKeys();
reload(); reload();

Loading…
Cancel
Save