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

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

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

Loading…
Cancel
Save