代码生成器修改,流程新建,表单新建,流程审批等页面修改

This commit is contained in:
GAOANG
2024-03-29 16:41:21 +08:00
parent d55f879846
commit 788cfac511
6 changed files with 754 additions and 704 deletions

View File

@ -825,12 +825,14 @@ ${hasTemplatePrint ? ' reactive ' : ''}
const btnEvent = ${btnEvent} const btnEvent = ${btnEvent}
const { currentRoute } = useRouter(); const { currentRoute } = useRouter();
const router = useRouter();
${ ${
hasTemplatePrint hasTemplatePrint
? `const printMenuId = computed(() => currentRoute.value.meta.menuId as string);` ? `const printMenuId = computed(() => currentRoute.value.meta.menuId as string);`
: '' : ''
} }
const formIdComputedRef = computed(() => currentRoute.value.meta.formId as string); const formIdComputedRef = computed(() => currentRoute.value.meta.formId as string);
const schemaIdComputedRef = computed(() => currentRoute.value.meta.schemaId as string);
${ ${
hasStartWorkButton hasStartWorkButton
@ -1000,16 +1002,17 @@ ${hasTemplatePrint ? ' reactive ' : ''}
hasAddButton hasAddButton
? ` ? `
function handleAdd() { function handleAdd() {
${ if (schemaIdComputedRef.value) {
formType === 'modal' router.push({
? ` path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow'
openModal(true, { });
isUpdate: false, } else {
});` router.push({
: ` path: '/form/${lowerClassName}/0/createForm',
openDrawer(true, { query: {
isUpdate: false, formPath: '${model.outputConfig.outputValue}/${lowerClassName}'
});` }
});
} }
}` }`
: '' : ''
@ -1021,9 +1024,11 @@ ${hasTemplatePrint ? ' reactive ' : ''}
${ ${
formType === 'modal' formType === 'modal'
? ` ? `
openModal(true, { router.push({
id: record.${camelCaseString(mainTable.pkField)}, path: '/form/${lowerClassName}/' + record.id + '/updateForm',
isUpdate: true, query: {
formPath: '${model.outputConfig.outputValue}/${lowerClassName}'
}
});` });`
: ` : `
openDrawer(true, { openDrawer(true, {
@ -1303,9 +1308,11 @@ ${hasTemplatePrint ? ' reactive ' : ''}
${ ${
formType === 'modal' formType === 'modal'
? ` ? `
openModal(true, { router.push({
isView: true, path: '/form/${lowerClassName}/' + record.id + '/viewForm',
id: record.${camelCaseString(mainTable.pkField)}, query: {
formPath: '${model.outputConfig.outputValue}/${lowerClassName}'
}
});` });`
: ` : `
openDrawer(true, { openDrawer(true, {
@ -1547,10 +1554,13 @@ ${hasTemplatePrint ? ' reactive ' : ''}
} }
} }
function handleApproveProcess(record: Recordable) { function handleApproveProcess(record: Recordable) {
visibleApproveProcessRef.value = true; const { processId, taskIds, schemaId } = record.workflowData;
schemaIdRef.value = record.workflowData.schemaId; router.push({
processIdRef.value = record.workflowData.processId; path: '/flow/' + schemaId + '/' + processId + '/approveFlow',
taskIdRef.value = record.workflowData.taskIds[0]; query: {
taskId: taskIds[0]
}
});
} }
function handleCloseLaunch() { function handleCloseLaunch() {
visibleLaunchProcessRef.value = false; visibleLaunchProcessRef.value = false;

View File

@ -36,16 +36,9 @@
</a-dropdown> </a-dropdown>
</a-space> </a-space>
</div> </div>
<FormInformation <FormInformation :key="renderKey" ref="formInformation" :disabled="readonly"
:key="renderKey" :formAssignmentData="data.formAssignmentData" :formInfos="data.formInfos" :opinions="data.opinions"
ref="formInformation" :opinionsComponents="data.opinionsComponents" @get-form-configs="(config) => (formConfigs = config)" />
:disabled="readonly"
:formAssignmentData="data.formAssignmentData"
:formInfos="data.formInfos"
:opinions="data.opinions"
:opinionsComponents="data.opinionsComponents"
@get-form-configs="(config) => (formConfigs = config)"
/>
<Title :font-size="18" default-value="流转信息"></Title> <Title :font-size="18" default-value="流转信息"></Title>
<flow-history :items="getTaskRecords()"></flow-history> <flow-history :items="getTaskRecords()"></flow-history>
<opinion-dialog ref="opinionDlg" /> <opinion-dialog ref="opinionDlg" />

View File

@ -36,7 +36,9 @@
</a-space> </a-space>
</div> </div>
<div class="flow-content"> <div class="flow-content">
<FormInformation :key="randKey" ref="formInformation" :disabled="false" :formAssignmentData="data.formAssignmentData" :formInfos="data.formInfos" :opinions="data.opinions" :opinionsComponents="data.opinionsComponents" /> <FormInformation :key="randKey" ref="formInformation" :disabled="false"
:formAssignmentData="data.formAssignmentData" :formInfos="data.formInfos" :opinions="data.opinions"
:opinionsComponents="data.opinionsComponents" />
</div> </div>
</div> </div>
<a-modal :visible="showFlowChart" centered class="geg" closable title="流程图" width="1200px"> <a-modal :visible="showFlowChart" centered class="geg" closable title="流程图" width="1200px">
@ -45,6 +47,7 @@
<a-button type="primary" @click="closeFlowChart">关闭</a-button> <a-button type="primary" @click="closeFlowChart">关闭</a-button>
</template> </template>
</a-modal> </a-modal>
<opinion-dialog ref="opinionDlg" />
</div> </div>
</template> </template>
@ -53,14 +56,16 @@
import userTaskItem from '/@/views/workflow/task/hooks/userTaskItem'; import userTaskItem from '/@/views/workflow/task/hooks/userTaskItem';
import FormInformation from '/@/views/secondDev/FormInformation.vue'; import FormInformation from '/@/views/secondDev/FormInformation.vue';
import ProcessInformation from '/@/views/workflow/task/components/flow/ProcessInformation.vue'; import ProcessInformation from '/@/views/workflow/task/components/flow/ProcessInformation.vue';
import { getStartProcessInfo, getReStartProcessInfo, reLaunch, postLaunch } from '/@/api/workflow/task'; import { getStartProcessInfo, getReStartProcessInfo, reLaunch, postLaunch, postApproval, postGetNextTaskMaybeArrival } from '/@/api/workflow/task';
import { useMultipleTabStore } from '/@/store/modules/multipleTab'; import { useMultipleTabStore } from '/@/store/modules/multipleTab';
import { CloseOutlined, SendOutlined, ClockCircleOutlined, PrinterOutlined, ApartmentOutlined } from '@ant-design/icons-vue'; import { CloseOutlined, SendOutlined, ClockCircleOutlined, PrinterOutlined, ApartmentOutlined } from '@ant-design/icons-vue';
import { nextTick, onMounted, ref, toRaw } from 'vue'; import { nextTick, onMounted, ref, toRaw, reactive } from 'vue';
import { postDraft, putDraft } from '/@/api/workflow/process'; import { postDraft, putDraft } from '/@/api/workflow/process';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { separator } from '/@bpmn/config/info'; import { separator } from '/@bpmn/config/info';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import OpinionDialog from '/@/components/SecondDev/OpinionDialog.vue';
import { ApproveCode, ApproveType } from '/@/enums/workflowEnum';
const router = useRouter(); const router = useRouter();
const tabStore = useMultipleTabStore(); const tabStore = useMultipleTabStore();
@ -72,12 +77,31 @@
const fullPath = currentRoute.fullPath; const fullPath = currentRoute.fullPath;
const rSchemaId = rParams.arg1; const rSchemaId = rParams.arg1;
const rDraftsId = rParams.arg2; const rDraftsId = rParams.arg2;
const taskId = ref();
const draftsJsonStr = localStorage.getItem('draftsJsonStr'); const draftsJsonStr = localStorage.getItem('draftsJsonStr');
let formInformation = ref(); let formInformation = ref();
const opinionDlg = ref();
let pageMode = 'new'; let pageMode = 'new';
const showFlowChart = ref(false); const showFlowChart = ref(false);
const disableSubmit = ref(false); const disableSubmit = ref(false);
const mainFormModels = ref();
let randKey = ref('randkey'); // 强制表单重新渲染 let randKey = ref('randkey'); // 强制表单重新渲染
let approvalData = reactive({
isCountersign: false,
isAddOrSubSign: false,
stampInfo: {
stampId: '',
password: ''
},
buttonConfigs: [],
approvedType: ApproveType.AGREE,
approvedResult: ApproveCode.AGREE,
approvedContent: '',
rejectNodeActivityId: '',
rejectNodeActivityIds: [],
circulateConfigs: [],
nextTaskUser: {} // 格式为taskKey: 用户id逗号分隔
});
if (draftsJsonStr) { if (draftsJsonStr) {
localStorage.removeItem('draftsJsonStr'); localStorage.removeItem('draftsJsonStr');
@ -97,29 +121,6 @@
} }
const props = defineProps({ const props = defineProps({
schemaId: {
type: String,
required: true
},
draftsId: {
type: String
},
taskId: {
type: String,
required: false,
default: ''
},
processId: {
type: String,
required: false,
default: ''
},
formData: {
type: Object
},
formId: {
type: String
},
rowKeyData: { rowKeyData: {
type: String type: String
} }
@ -127,23 +128,6 @@
onMounted(async () => { onMounted(async () => {
try { try {
if (props.processId) {
// 重新发起
let res = await getReStartProcessInfo(props.taskId, props.processId);
res.taskApproveOpinions = [];
initProcessData(res);
} else if (props.schemaId && props.formId) {
let res = await getStartProcessInfo(props.schemaId);
if (props.formData && props.formId) {
res.formInfos.map((m) => {
if (m.formConfig.formId === props.formId) {
m.formData = toRaw(props.formData);
}
});
}
initProcessData(res);
} else {
// 发起流程 // 发起流程
let res = await getStartProcessInfo(rSchemaId); let res = await getStartProcessInfo(rSchemaId);
const title = res?.schemaInfo?.name; const title = res?.schemaInfo?.name;
@ -152,7 +136,6 @@
tabStore.changeTitle(fullPath, `${tabPrefix}${title}`); tabStore.changeTitle(fullPath, `${tabPrefix}${title}`);
} }
initProcessData(res); initProcessData(res);
}
} catch (error) { } } catch (error) { }
randKey.value = Math.random() + ''; randKey.value = Math.random() + '';
// 这里的顺序不能变 表单不渲染的时候 设置表单初值没用 // 这里的顺序不能变 表单不渲染的时候 设置表单初值没用
@ -200,16 +183,81 @@
} }
function flowSuccess() { function createFlowSuccess(taskList) {
/*opinionDlg.value.toggleDialog({ /*opinionDlg.value.toggleDialog({
isClose: true isClose: true
});*/ });*/
if (taskList) {
approvalCreate();
} else {
message.success('流程发起成功'); message.success('流程发起成功');
data.submitLoading = false;
setTimeout(() => { setTimeout(() => {
close(); close();
}, 500); }, 500);
} }
}
async function approvalCreate() {
const params = await getApproveParams();
let fileFolderIds = getUploadFileFolderIds(mainFormModels.value);
let system = formInformation.value.getSystemType();
const nextNodes = await postGetNextTaskMaybeArrival(params);
opinionDlg.value.toggleDialog({
action: 'agree',
nextNodes,
callback: (args) => {
approvalData.approvedContent = args.opinion;
approvalData.nextTaskUser = args.nextTaskUser;
onFinish({});
}
});
}
function flowSuccess() {
opinionDlg.value.toggleDialog({
isClose: true
});
message.success('操作成功');
setTimeout(() => {
close();
}, 500);
}
function flowFail() {
opinionDlg.value.stopLoading();
}
async function onFinish(values) {
try {
if (/*validateSuccess.value*/ true) {
let params = await getApproveParams();
await postApproval(params);
flowSuccess();
data.submitLoading = false;
}
} catch (error) {
flowFail();
}
}
async function getApproveParams() {
let formModels = mainFormModels.value;
let system = formInformation.value.getSystemType();
let fileFolderIds = getUploadFileFolderIds(formModels);
return {
approvedType: approvalData.approvedType,
approvedResult: approvalData.approvedResult, // approvalData.approvedType 审批结果 如果为 4 就需要传buttonCode
approvedContent: approvalData.approvedContent,
formData: formModels,
rejectNodeActivityId: approvalData.rejectNodeActivityId,
taskId: taskId.value,
fileFolderIds,
circulateConfigs: approvalData.circulateConfigs,
/*stampId: values.stampId,
stampPassword: values.password,*/
isOldSystem: system,
nextTaskUser: approvalData.nextTaskUser
};
}
async function saveLaunch() { async function saveLaunch() {
data.submitLoading = true; data.submitLoading = true;
try { try {
@ -221,25 +269,22 @@
return ele.validate; return ele.validate;
}); });
if (successValidate.length == validateForms.length) { if (successValidate.length == validateForms.length) {
let formModels = await formInformation.value.getFormModels(); mainFormModels.value = await formInformation.value.getFormModels();
let relationTasks = []; let relationTasks = [];
if (data.predecessorTasks && data.predecessorTasks.length > 0) { if (data.predecessorTasks && data.predecessorTasks.length > 0) {
relationTasks = data.predecessorTasks.map((ele) => { relationTasks = data.predecessorTasks.map((ele) => {
return { taskId: ele.taskId, schemaId: ele.schemaId }; return { taskId: ele.taskId, schemaId: ele.schemaId };
}); });
} }
let fileFolderIds = getUploadFileFolderIds(formModels); let fileFolderIds = getUploadFileFolderIds(mainFormModels.value);
//如果传入了processId 代表是重新发起流程 //如果传入了processId 代表是重新发起流程
let res; let res;
if (props.processId) { res = await postLaunch(rSchemaId, mainFormModels.value, relationTasks, fileFolderIds, system);
res = await reLaunch(props.processId, props.schemaId, formModels, relationTasks, fileFolderIds, system);
} else {
res = await postLaunch(rSchemaId, formModels, relationTasks, fileFolderIds, system);
}
// 下一节点审批人 // 下一节点审批人
let taskList = []; let taskList = [];
if (res && res.length > 0) { if (res && res.length > 0) {
taskId.value = res[0].taskId
taskList = res taskList = res
.filter((ele) => { .filter((ele) => {
return ele.isMultiInstance == false && ele.isAppoint == true; return ele.isMultiInstance == false && ele.isAppoint == true;
@ -256,12 +301,10 @@
notificationError('提交失败', '流程设计错误,开始后的第一个节点必须是审批人为发起人的起草节点。'); notificationError('提交失败', '流程设计错误,开始后的第一个节点必须是审批人为发起人的起草节点。');
data.submitLoading = false; data.submitLoading = false;
} else { } else {
data.submitLoading = false; createFlowSuccess(taskList);
flowSuccess();
} }
} else { } else {
data.submitLoading = false; createFlowSuccess();
flowSuccess();
} }
} else { } else {
data.submitLoading = false; data.submitLoading = false;

View File

@ -1,33 +1,34 @@
<template> <template>
<PageLayout :layoutClass="currentRoute.path == '/workflow/launch' ? '!p-2' : currentRoute.path == '/task/processtasks' ? '!p-0 !pr-7px' : ''" :searchConfig="searchConfig" :title="t('流程模板列表')" @search="search" @scroll-height="scrollHeight"> <PageLayout
:layoutClass="currentRoute.path == '/workflow/launch' ? '!p-2' : currentRoute.path == '/task/processtasks' ? '!p-0 !pr-7px' : ''"
:searchConfig="searchConfig" :title="t('流程模板列表')" @search="search" @scroll-height="scrollHeight">
<template #left> <template #left>
<BasicTree :clickRowToExpand="true" :fieldNames="{ key: 'id', title: 'name' }" :title="t('流程模板分类')" :treeData="data.treeData" search @select="handleSelect" /> <BasicTree :clickRowToExpand="true" :fieldNames="{ key: 'id', title: 'name' }" :title="t('流程模板分类')"
:treeData="data.treeData" search @select="handleSelect" />
</template> </template>
<template #search></template> <template #search></template>
<template #right> <template #right>
<div v-if="data.list.length > 0" :style="{ overflowY: 'auto', height: tableOptions.scrollHeight + 30 + 'px' }"> <div v-if="data.list.length > 0"
:style="{ overflowY: 'auto', height: tableOptions.scrollHeight + 30 + 'px' }">
<div class="list-page-box"> <div class="list-page-box">
<TemplateCard v-for="(item, index) in data.list" :key="index" :item="item" @click="launchProcessInTab(item.id)" /> <TemplateCard v-for="(item, index) in data.list" :key="index" :item="item"
@click="launchProcessInTab(item.id)" />
</div> </div>
<div class="page-box"> <div class="page-box">
<a-pagination <a-pagination v-model:current="data.pagination.current" v-model:pageSize="data.pagination.pageSize"
v-model:current="data.pagination.current"
v-model:pageSize="data.pagination.pageSize"
:pageSizeOptions="['18', '36', '54', '72']" :pageSizeOptions="['18', '36', '54', '72']"
:show-total="(total) => t(`共 {total} 条数据`, { total })" :show-total="(total) => t(`共 {total} 条数据`, { total })" :showSizeChanger="true"
:showSizeChanger="true" :total="data.pagination.total" @change="getList" />
:total="data.pagination.total"
@change="getList"
/>
</div> </div>
</div> </div>
<div v-else> <div v-else>
<EmptyBox /> <EmptyBox />
</div> </div>
<LaunchProcess v-if="visibleLaunchProcess" :schemaId="data.schemaId" @close="visibleLaunchProcess = false" /> <LaunchProcess v-if="visibleLaunchProcess" :schemaId="data.schemaId"
@close="visibleLaunchProcess = false" />
</template> </template>
</PageLayout> </PageLayout>
</template> </template>

View File

@ -4,7 +4,9 @@
<TableAction :actions="tableActions(record)" /> <TableAction :actions="tableActions(record)" />
</template> </template>
</BasicTable> </BasicTable>
<LaunchProcess v-if="processData.visible" :draftsId="processData.draftsId" :draftsJsonStr="processData.draftsJsonStr" :schemaId="processData.schemaId" @close="processData.visible = false" /> <LaunchProcess v-if="processData.visible" :draftsId="processData.draftsId"
:draftsJsonStr="processData.draftsJsonStr" :schemaId="processData.schemaId"
@close="processData.visible = false" />
</template> </template>
<script setup> <script setup>

View File

@ -114,6 +114,15 @@
}); });
const router = useRouter(); const router = useRouter();
const { currentRoute } = router; const { currentRoute } = router;
onMounted(() => {
bus.on(FLOW_PROCESSED, onFlowProcessed);
});
onUnmounted(() => {
bus.off(FLOW_PROCESSED, onFlowProcessed);
});
watch( watch(
() => unref(currentRoute), () => unref(currentRoute),
(val) => { (val) => {
@ -134,14 +143,6 @@
function onFlowProcessed() { function onFlowProcessed() {
reload(); reload();
} }
onMounted(() => {
bus.on(FLOW_PROCESSED, onFlowProcessed);
});
onUnmounted(() => {
bus.off(FLOW_PROCESSED, onFlowProcessed);
});
</script> </script>
<style scoped></style> <style scoped></style>