From c45680c2aca847b483e8b71fd58230c62d9338fc Mon Sep 17 00:00:00 2001 From: yaoyn Date: Tue, 4 Jun 2024 17:30:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=BD=93=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE=E9=A1=B9=EF=BC=8C=E5=BD=93?= =?UTF-8?q?=E5=80=BC=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=80=BC=E6=98=AF=E5=90=A6=E5=8F=8D=E5=90=91=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=9B=9E=E5=8E=BB=EF=BC=8C=E9=BB=98=E8=AE=A4=E4=B8=BA=E5=90=A6?= =?UTF-8?q?=EF=BC=8C=E7=94=B1=E5=90=8E=E7=AB=AF=E8=B5=8B=E5=80=BC=EF=BC=8C?= =?UTF-8?q?=E5=90=A6=E5=88=99=E4=BC=9A=E7=94=B1=E4=BA=8E=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=90=8E=E5=8A=A0=E8=BD=BD=E5=92=8C=E5=8F=8C?= =?UTF-8?q?=E5=90=91=E7=BB=91=E5=AE=9A=E5=AF=BC=E8=87=B4=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E8=B5=8B=E5=80=BC=20=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= =?UTF-8?q?=EF=BC=8C=E5=8E=BB=E6=8E=89=E5=88=97=E8=A1=A8=E8=A1=8C=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E9=97=B4=E9=9A=94=E7=AB=96=E7=BA=BF=20=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=B9=9F=E6=8B=B7=E8=B4=9D=E6=95=B0=E6=8D=AE=E5=8F=91?= =?UTF-8?q?=E8=B5=B7=E6=B5=81=E7=A8=8B=E6=88=96=E6=97=A0=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8F=91=E8=B5=B7=E6=B5=81=E7=A8=8B=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BB=8Elocalstorage=E9=87=8C=E5=8A=A0=E8=BD=BD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=8F=91=E8=B5=B7=E6=B5=81=E7=A8=8B=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95=20=E6=B5=81=E7=A8=8B=E9=85=8D=E7=BD=AE=E4=B8=AD?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=A1=AB=E5=85=85=E7=BB=84=E4=BB=B6=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=8F=AF=E9=85=8D=E7=BD=AE=E5=BF=85=E5=A1=AB=E5=92=8C?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Form/src/components/CommonInfo.vue | 17 +++- .../Table/src/components/TableAction.vue | 2 +- src/utils/helper/generatorHelper.ts | 83 +++++++++++++------ src/views/secondDev/createFlow.vue | 21 ++++- .../design/bpmn/config/formPermission.ts | 4 +- 5 files changed, 92 insertions(+), 35 deletions(-) diff --git a/src/components/Form/src/components/CommonInfo.vue b/src/components/Form/src/components/CommonInfo.vue index ea06b22..83b69a8 100644 --- a/src/components/Form/src/components/CommonInfo.vue +++ b/src/components/Form/src/components/CommonInfo.vue @@ -27,6 +27,11 @@ import {inject, ref, watchEffect} from 'vue'; type: Boolean, default: false, }, + //当值为空时,初始值是否反向更新回去,默认为否,由后端赋值,否则会由于表单数据后加载和双向绑定导致重新赋值 + updateValueWhileEmpty:{ + type: Boolean, + default: false + }, userNameWithDepartment:{ type: Boolean, default: true @@ -86,21 +91,27 @@ import {inject, ref, watchEffect} from 'vue'; const deptName=dept?.name||""; //判断传入的值 是不是当前登录人 就不需要发请求获取用户信息了 name.value = userStore.getUserInfo.name+(props.userNameWithDepartment&&(deptName||userStore.getUserInfo.departmentName)?("/"+(deptName||userStore.getUserInfo.departmentName)):""); - emit('update:value', userStore.getUserInfo.id); + if(props.updateValueWhileEmpty){ + emit('update:value', userStore.getUserInfo.id); + } } //当前部门 if (props.infoType === 1) { //判断传入的值 是不是当前登陆人的部门 就不需要发请求获取用户信息了 name.value = userStore.getUserInfo.departmentName; - emit('update:value', userStore.getUserInfo.departmentId); + if(props.updateValueWhileEmpty) { + emit('update:value', userStore.getUserInfo.departmentId); + } } //当前时间 if (props.infoType === 2) { //如果是时间 默认显示参数时间 name.value = dateUtil(new Date()).format('YYYY-MM-DD HH:mm:ss'); - emit('update:value', name.value); + if(props.updateValueWhileEmpty) { + emit('update:value', name.value); + } } } }); diff --git a/src/components/Table/src/components/TableAction.vue b/src/components/Table/src/components/TableAction.vue index 252e68a..f7cbc3a 100644 --- a/src/components/Table/src/components/TableAction.vue +++ b/src/components/Table/src/components/TableAction.vue @@ -57,7 +57,7 @@ type: Array as PropType, default: null, }, - divider: propTypes.bool.def(true), + divider: propTypes.bool.def(false), outside: propTypes.bool, stopButtonPropagation: propTypes.bool.def(false), }, diff --git a/src/utils/helper/generatorHelper.ts b/src/utils/helper/generatorHelper.ts index 1167b13..7f2ab23 100644 --- a/src/utils/helper/generatorHelper.ts +++ b/src/utils/helper/generatorHelper.ts @@ -1008,10 +1008,10 @@ ${hasTemplatePrint ? ' reactive ' : ''} formName: formName } }); - } else if (record.workflowData?.schemaId && !record.workflowData.taskIds) { + } else if (record.workflowData?.schemaId && !record.workflowData.taskIds && record.workflowData.processId) { const { processId, schemaId } = record.workflowData; router.push({ - path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow', + path: '/flow/' + schemaId + '/' + processId + '/approveFlow', query: { readonly: 1, taskId: '', @@ -1085,7 +1085,8 @@ ${hasTemplatePrint ? ' reactive ' : ''} ${ hasCopyDataButton ? ` - function handleCopyData(record: Recordable) { + async function handleCopyData(record: Recordable) { + /*//弹框添加数据 ${ formType === 'modal' ? ` @@ -1098,7 +1099,32 @@ ${hasTemplatePrint ? ' reactive ' : ''} id: record.${camelCaseString(mainTable.pkField)}, isCopy: true, });` - } + }*/ + + const result = await get${pascalMainTableName}(record['${camelCaseString(mainTable.pkField)}']); + const form={}; + const key="form_copy_"+record['${camelCaseString(mainTable.pkField)}']; + form[key]=result; + localStorage.setItem('formJsonStr', JSON.stringify(form)); + + const schemaId=record.workflowData?.schemaId||schemaIdComputedRef.value; + if(schemaId){ + router.push({ + path: '/flow/' + schemaId + '/0/createFlow', + query: { + fromKey: key + } + }); + }else{ + router.push({ + path: '/form/${lowerClassName}/0/createForm', + query: { + formPath: '${model.outputConfig.outputValue}/${lowerClassName}', + formName: formName, + fromKey: key + } + }); + } }` : '' } @@ -1481,14 +1507,14 @@ ${hasTemplatePrint ? ' reactive ' : ''} let editAndDelBtn: ActionItem[] = []; ${hasFlowRecordButton ? `let hasFlowRecord = false;` : ''} actionButtonConfig.value?.map((button) => { - if (button.code === 'view') { + if (['view', 'copyData'].includes(button.code)) { actionsList.push({ icon: button?.icon, tooltip: button?.name, - onClick: handleView.bind(null, record), + onClick: btnEvent[button.code].bind(null, record), }); } - if (['edit', 'copyData', 'delete'].includes(button.code)) { + if (['edit', 'delete'].includes(button.code)) { editAndDelBtn.push({ icon: button?.icon, tooltip: button?.name, @@ -1594,28 +1620,31 @@ ${hasTemplatePrint ? ' reactive ' : ''} } async function handleLaunchProcess(record: Recordable) { - if (record.workflowData) { - if (record.workflowData.draftId) { - let res = await getDraftInfo(record.workflowData.draftId); - let data = isValidJSON(res.formData); - if (data) { - for (let key in data) { - if (key.includes(formIdComputedRef.value)) { - formDataRef.value = data[key]; - } + const schemaId=record.workflowData?.schemaId||schemaIdComputedRef.value; + if(schemaId){ + if(record.workflowData?.draftId){ + let res = await getDraftInfo(record.workflowData.draftId); + if (isValidJSON(res.formData)) { + localStorage.setItem('draftsJsonStr', res.formData); + router.push({ + path: '/flow/' + schemaId + '/'+record.workflowData.draftId+'/createFlow' + }); + return; + } } - } - draftsId.value = record.workflowData.draftId; - } else { - const result = await get${pascalMainTableName}(record['${camelCaseString( - mainTable.pkField, - )}']); - formDataRef.value = result; + + const result = await get${pascalMainTableName}(record['${camelCaseString(mainTable.pkField)}']); + const form={}; + const key="form_"+schemaId+"_"+record['${camelCaseString(mainTable.pkField)}']; + form[key]=result; + localStorage.setItem('formJsonStr', JSON.stringify(form)); + router.push({ + path: '/flow/' + schemaId + '/0/createFlow', + query: { + fromKey: key + } + }); } - rowKeyData.value = record['${camelCaseString(mainTable.pkField)}']; - visibleLaunchProcessRef.value = true; - schemaIdRef.value = record.workflowData.schemaId; - } } function handleApproveProcess(record: Recordable) { const { processId, taskIds, schemaId } = record.workflowData; diff --git a/src/views/secondDev/createFlow.vue b/src/views/secondDev/createFlow.vue index 7d8a9e2..d7aacd0 100644 --- a/src/views/secondDev/createFlow.vue +++ b/src/views/secondDev/createFlow.vue @@ -78,11 +78,13 @@ const currentRoute = router.currentRoute.value; const rParams = currentRoute.params; const fullPath = currentRoute.fullPath; + const rQuery = currentRoute.query; const rSchemaId = rParams.arg1; const rDraftsId = rParams.arg2; const taskId = ref(); const loading = ref(false); const draftsJsonStr = localStorage.getItem('draftsJsonStr'); + const formJsonStr = localStorage.getItem('formJsonStr'); let formInformation = ref(); const opinionDlg = ref(); let pageMode = 'new'; @@ -111,6 +113,9 @@ localStorage.removeItem('draftsJsonStr'); pageMode = 'draft'; } + if (formJsonStr) { + localStorage.removeItem('formJsonStr'); + } function closeFlowChart() { showFlowChart.value = false; @@ -145,6 +150,7 @@ // 这里的顺序不能变 表单不渲染的时候 设置表单初值没用 await nextTick(); await initDraftsFormData(); + await initFromFormData(); }); async function initDraftsFormData() { @@ -162,6 +168,17 @@ } } + async function initFromFormData() { + if (formJsonStr) { + let formDataJson = JSON.parse(formJsonStr); + let formData = []; + if(rQuery.fromKey&&formDataJson[rQuery.fromKey]){ + formData.push(formDataJson[rQuery.fromKey]); + } + await formInformation.value.setFormData(formData); + } + } + async function saveDraft() { try { disableSubmit.value = true; @@ -323,8 +340,8 @@ selectIds: [] }; }); - const strictDesign=false; - if (strictDesign&&taskList.length > 0) { + const strictDesign = false; + if (strictDesign && taskList.length > 0) { notificationError('提交失败', '流程设计错误,开始后的第一个节点必须是审批人为发起人的起草节点。'); data.submitLoading = false; loading.value = false; diff --git a/src/views/workflow/design/bpmn/config/formPermission.ts b/src/views/workflow/design/bpmn/config/formPermission.ts index 2ca5c92..89045d4 100644 --- a/src/views/workflow/design/bpmn/config/formPermission.ts +++ b/src/views/workflow/design/bpmn/config/formPermission.ts @@ -22,7 +22,7 @@ export const disableTypes = [ titleType, dividerType, infoType, - autoCodeType, + //autoCodeType, 'qrcode', //二维码组件 ]; //表单字段仅仅只有查看权限 // 开关,滑块,颜色选择,评分,图片 组件权限中,必填权限为disable @@ -31,7 +31,7 @@ export const requiredDisabled = [ titleType, dividerType, infoType, - autoCodeType, + //autoCodeType, buttonType, 'switch', 'slider',