fix: 修复新建流程页面,用户取消后无法再次提交的bug
This commit is contained in:
@ -169,13 +169,13 @@
|
|||||||
async function setFieldsValue(record) {
|
async function setFieldsValue(record) {
|
||||||
flowConfig.draftsFormData = record;
|
flowConfig.draftsFormData = record;
|
||||||
}
|
}
|
||||||
async function workflowSubmit() {
|
async function workflowSubmit(saveRowKey) {
|
||||||
let values = {};
|
let values = {};
|
||||||
try {
|
try {
|
||||||
values = await SystemFormRef.value.validate();
|
values = await SystemFormRef.value.validate();
|
||||||
// 提交表单
|
// 提交表单
|
||||||
if (visible.value) {
|
if (visible.value) {
|
||||||
let id = await submit();
|
let id = await submit(saveRowKey);
|
||||||
let rowKey = getRowKey();
|
let rowKey = getRowKey();
|
||||||
values[rowKey] = id;
|
values[rowKey] = id;
|
||||||
values['_id'] = id
|
values['_id'] = id
|
||||||
@ -184,7 +184,7 @@
|
|||||||
return values;
|
return values;
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
async function submit() {
|
async function submit(saveRowKey) {
|
||||||
let saveValId = '';
|
let saveValId = '';
|
||||||
let values = await SystemFormRef.value.validate();
|
let values = await SystemFormRef.value.validate();
|
||||||
let rowKey = getRowKey();
|
let rowKey = getRowKey();
|
||||||
@ -198,6 +198,10 @@
|
|||||||
} else {
|
} else {
|
||||||
// 新增
|
// 新增
|
||||||
saveValId = await SystemFormRef.value.add(values);
|
saveValId = await SystemFormRef.value.add(values);
|
||||||
|
if (saveRowKey) {
|
||||||
|
// 把rowKey写回去,新建流程的时候防止取消了重复提交
|
||||||
|
props.workflowConfig.formModel[rowKey] = saveValId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return saveValId;
|
return saveValId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -239,13 +239,13 @@
|
|||||||
return formModes;
|
return formModes;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getFormModels() {
|
async function getFormModels(saveRowKey) {
|
||||||
let formModes = {};
|
let formModes = {};
|
||||||
|
|
||||||
for (let index = 0; index < forms.configs.length; index++) {
|
for (let index = 0; index < forms.configs.length; index++) {
|
||||||
const ele = forms.configs[index];
|
const ele = forms.configs[index];
|
||||||
if (ele.formType == FormType.SYSTEM) {
|
if (ele.formType == FormType.SYSTEM) {
|
||||||
let values = await itemRefs.value[index].workflowSubmit();
|
let values = await itemRefs.value[index].workflowSubmit(saveRowKey);
|
||||||
formModes[ele.formKey] = values;
|
formModes[ele.formKey] = values;
|
||||||
} else {
|
} else {
|
||||||
formModes[ele.formKey] = ele.formModel;
|
formModes[ele.formKey] = ele.formModel;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page-bg-wrap">
|
<div class="page-bg-wrap">
|
||||||
<a-spin tip="Loading..." :spinning="loading">
|
<a-spin :spinning="loading" tip="加载中...">
|
||||||
<div class="geg-flow-page">
|
<div class="geg-flow-page">
|
||||||
<div class="top-toolbar">
|
<div class="top-toolbar">
|
||||||
<a-space :size="10" wrap>
|
<a-space :size="10" wrap>
|
||||||
@ -10,7 +10,7 @@
|
|||||||
</slot>
|
</slot>
|
||||||
关闭
|
关闭
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button type="primary" :disabled="data.submitLoading" @click="saveLaunch">
|
<a-button :disabled="data.submitLoading" type="primary" @click="saveLaunch">
|
||||||
<slot name="icon">
|
<slot name="icon">
|
||||||
<send-outlined />
|
<send-outlined />
|
||||||
</slot>
|
</slot>
|
||||||
@ -37,9 +37,7 @@
|
|||||||
</a-space>
|
</a-space>
|
||||||
</div>
|
</div>
|
||||||
<div class="flow-content">
|
<div class="flow-content">
|
||||||
<FormInformation :key="randKey" ref="formInformation" :disabled="false"
|
<FormInformation :key="randKey" ref="formInformation" :disabled="false" :formAssignmentData="data.formAssignmentData" :formInfos="data.formInfos" :opinions="data.opinions" :opinionsComponents="data.opinionsComponents" />
|
||||||
: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">
|
||||||
@ -79,11 +77,11 @@ const { t } = useI18n();
|
|||||||
const { data, approveUserData, initProcessData, notificationSuccess, notificationError } = userTaskItem();
|
const { data, approveUserData, initProcessData, notificationSuccess, notificationError } = userTaskItem();
|
||||||
const currentRoute = router.currentRoute.value;
|
const currentRoute = router.currentRoute.value;
|
||||||
const rParams = currentRoute.params;
|
const rParams = currentRoute.params;
|
||||||
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 taskId = ref();
|
||||||
const loading = ref(false)
|
const loading = ref(false);
|
||||||
const draftsJsonStr = localStorage.getItem('draftsJsonStr');
|
const draftsJsonStr = localStorage.getItem('draftsJsonStr');
|
||||||
let formInformation = ref();
|
let formInformation = ref();
|
||||||
const opinionDlg = ref();
|
const opinionDlg = ref();
|
||||||
@ -188,7 +186,6 @@ function showResult(res, title) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function createFlowSuccess(taskList) {
|
function createFlowSuccess(taskList) {
|
||||||
/*opinionDlg.value.toggleDialog({
|
/*opinionDlg.value.toggleDialog({
|
||||||
isClose: true
|
isClose: true
|
||||||
@ -199,24 +196,23 @@ function createFlowSuccess(taskList) {
|
|||||||
message.success('流程发起成功');
|
message.success('流程发起成功');
|
||||||
|
|
||||||
data.submitLoading = false;
|
data.submitLoading = false;
|
||||||
loading.value = false
|
loading.value = false;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
bus.emit(CREATE_FLOW, {});
|
bus.emit(CREATE_FLOW, {});
|
||||||
close();
|
close();
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function approvalCreate() {
|
async function approvalCreate() {
|
||||||
const params = await getApproveParams();
|
const params = await getApproveParams();
|
||||||
let fileFolderIds = getUploadFileFolderIds(mainFormModels.value);
|
|
||||||
let system = formInformation.value.getSystemType();
|
|
||||||
const nextNodes = await postGetNextTaskMaybeArrival(params);
|
const nextNodes = await postGetNextTaskMaybeArrival(params);
|
||||||
opinionDlg.value.toggleDialog({
|
opinionDlg.value.toggleDialog({
|
||||||
action: 'agree',
|
action: 'agree',
|
||||||
nextNodes,
|
nextNodes,
|
||||||
rejectCancel: () => {
|
rejectCancel: () => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
data.submitLoading = false;
|
||||||
},
|
},
|
||||||
callback: (args) => {
|
callback: (args) => {
|
||||||
approvalData.approvedContent = args.opinion;
|
approvalData.approvedContent = args.opinion;
|
||||||
@ -225,6 +221,7 @@ async function approvalCreate() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function flowSuccess() {
|
function flowSuccess() {
|
||||||
opinionDlg.value.toggleDialog({
|
opinionDlg.value.toggleDialog({
|
||||||
isClose: true
|
isClose: true
|
||||||
@ -235,9 +232,11 @@ function flowSuccess() {
|
|||||||
close();
|
close();
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
function flowFail() {
|
function flowFail() {
|
||||||
opinionDlg.value.stopLoading();
|
opinionDlg.value.stopLoading();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onFinish(values) {
|
async function onFinish(values) {
|
||||||
try {
|
try {
|
||||||
if (/*validateSuccess.value*/ true) {
|
if (/*validateSuccess.value*/ true) {
|
||||||
@ -245,12 +244,13 @@ async function onFinish(values) {
|
|||||||
await postApproval(params);
|
await postApproval(params);
|
||||||
flowSuccess();
|
flowSuccess();
|
||||||
data.submitLoading = false;
|
data.submitLoading = false;
|
||||||
loading.value = false
|
loading.value = false;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
flowFail();
|
flowFail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getApproveParams() {
|
async function getApproveParams() {
|
||||||
let formModels = mainFormModels.value;
|
let formModels = mainFormModels.value;
|
||||||
let system = formInformation.value.getSystemType();
|
let system = formInformation.value.getSystemType();
|
||||||
@ -273,7 +273,7 @@ async function getApproveParams() {
|
|||||||
|
|
||||||
async function saveLaunch() {
|
async function saveLaunch() {
|
||||||
data.submitLoading = true;
|
data.submitLoading = true;
|
||||||
loading.value = true
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
let validateForms = await formInformation.value.validateForm();
|
let validateForms = await formInformation.value.validateForm();
|
||||||
let system = formInformation.value.getSystemType();
|
let system = formInformation.value.getSystemType();
|
||||||
@ -283,13 +283,13 @@ async function saveLaunch() {
|
|||||||
return ele.validate;
|
return ele.validate;
|
||||||
});
|
});
|
||||||
if (successValidate.length == validateForms.length) {
|
if (successValidate.length == validateForms.length) {
|
||||||
mainFormModels.value = await formInformation.value.getFormModels();
|
mainFormModels.value = await formInformation.value.getFormModels(true);
|
||||||
for (let i in mainFormModels.value) {
|
for (let i in mainFormModels.value) {
|
||||||
const item = mainFormModels.value[i]
|
const item = mainFormModels.value[i];
|
||||||
if (!item['_id']) {
|
if (!item['_id']) {
|
||||||
throw new Error('发起失败');
|
throw new Error('发起失败');
|
||||||
} else {
|
} else {
|
||||||
delete item['_id']
|
delete item['_id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let relationTasks = [];
|
let relationTasks = [];
|
||||||
@ -299,6 +299,10 @@ async function saveLaunch() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
let fileFolderIds = getUploadFileFolderIds(mainFormModels.value);
|
let fileFolderIds = getUploadFileFolderIds(mainFormModels.value);
|
||||||
|
if (taskId.value) {
|
||||||
|
// 如果在草稿节点取消,重新从草稿开始走
|
||||||
|
return createFlowSuccess(true);
|
||||||
|
}
|
||||||
//如果传入了processId 代表是重新发起流程
|
//如果传入了processId 代表是重新发起流程
|
||||||
let res;
|
let res;
|
||||||
res = await postLaunch(rSchemaId, mainFormModels.value, relationTasks, fileFolderIds, system);
|
res = await postLaunch(rSchemaId, mainFormModels.value, relationTasks, fileFolderIds, system);
|
||||||
@ -306,7 +310,7 @@ async function saveLaunch() {
|
|||||||
// 下一节点审批人
|
// 下一节点审批人
|
||||||
let taskList = [];
|
let taskList = [];
|
||||||
if (res && res.length > 0) {
|
if (res && res.length > 0) {
|
||||||
taskId.value = res[0].taskId
|
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;
|
||||||
@ -322,7 +326,7 @@ async function saveLaunch() {
|
|||||||
if (taskList.length > 0) {
|
if (taskList.length > 0) {
|
||||||
notificationError('提交失败', '流程设计错误,开始后的第一个节点必须是审批人为发起人的起草节点。');
|
notificationError('提交失败', '流程设计错误,开始后的第一个节点必须是审批人为发起人的起草节点。');
|
||||||
data.submitLoading = false;
|
data.submitLoading = false;
|
||||||
loading.value = false
|
loading.value = false;
|
||||||
} else {
|
} else {
|
||||||
createFlowSuccess(taskList);
|
createFlowSuccess(taskList);
|
||||||
}
|
}
|
||||||
@ -332,12 +336,12 @@ async function saveLaunch() {
|
|||||||
} else {
|
} else {
|
||||||
data.submitLoading = false;
|
data.submitLoading = false;
|
||||||
notificationError(t('发起流程'), t('表单校验未通过'));
|
notificationError(t('发起流程'), t('表单校验未通过'));
|
||||||
loading.value = false
|
loading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
data.submitLoading = false;
|
data.submitLoading = false;
|
||||||
loading.value = false
|
loading.value = false;
|
||||||
notificationError(t('发起流程'), t('发起流程失败'));
|
notificationError(t('发起流程'), t('发起流程失败'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -300,13 +300,13 @@
|
|||||||
}
|
}
|
||||||
return formModes;
|
return formModes;
|
||||||
}
|
}
|
||||||
async function getFormModels() {
|
async function getFormModels(saveRowKey) {
|
||||||
let formModes = {};
|
let formModes = {};
|
||||||
|
|
||||||
for (let index = 0; index < forms.configs.length; index++) {
|
for (let index = 0; index < forms.configs.length; index++) {
|
||||||
const ele = forms.configs[index];
|
const ele = forms.configs[index];
|
||||||
if (ele.formType == FormType.SYSTEM) {
|
if (ele.formType == FormType.SYSTEM) {
|
||||||
let values = await itemRefs.value[index].workflowSubmit();
|
let values = await itemRefs.value[index].workflowSubmit(saveRowKey);
|
||||||
formModes[ele.formKey] = values;
|
formModes[ele.formKey] = values;
|
||||||
} else {
|
} else {
|
||||||
formModes[ele.formKey] = ele.formModel;
|
formModes[ele.formKey] = ele.formModel;
|
||||||
|
|||||||
Reference in New Issue
Block a user