2024-02-05 11:27:33 +08:00
|
|
|
|
<template>
|
2024-02-19 17:41:26 +08:00
|
|
|
|
<div class="page-bg-wrap">
|
2024-02-21 15:52:18 +08:00
|
|
|
|
<div class="geg-flow-page">
|
|
|
|
|
|
<div class="top-toolbar">
|
2024-02-19 17:41:26 +08:00
|
|
|
|
<a-space :size="10" wrap>
|
2024-03-23 12:55:27 +08:00
|
|
|
|
<a-button style="margin-right: 10px" @click="close">
|
2024-02-19 17:41:26 +08:00
|
|
|
|
<slot name="icon">
|
|
|
|
|
|
<close-outlined />
|
|
|
|
|
|
</slot>
|
|
|
|
|
|
关闭
|
|
|
|
|
|
</a-button>
|
2024-03-23 12:55:27 +08:00
|
|
|
|
<a-button type="primary" :disabled="data.submitLoading" @click="saveLaunch">
|
2024-02-19 17:41:26 +08:00
|
|
|
|
<slot name="icon">
|
|
|
|
|
|
<send-outlined />
|
|
|
|
|
|
</slot>
|
|
|
|
|
|
提交
|
|
|
|
|
|
</a-button>
|
2024-03-23 12:55:27 +08:00
|
|
|
|
<a-button :disabled="data.submitLoading" @click="saveDraft">
|
2024-02-19 17:41:26 +08:00
|
|
|
|
<slot name="icon">
|
|
|
|
|
|
<clock-circle-outlined />
|
|
|
|
|
|
</slot>
|
|
|
|
|
|
暂存
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
<a-button>
|
|
|
|
|
|
<slot name="icon">
|
|
|
|
|
|
<printer-outlined />
|
|
|
|
|
|
</slot>
|
|
|
|
|
|
打印
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
<a-button @click="openFlowChart">
|
|
|
|
|
|
<slot name="icon">
|
|
|
|
|
|
<apartment-outlined />
|
|
|
|
|
|
</slot>
|
|
|
|
|
|
流程图
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
</a-space>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="flow-content">
|
|
|
|
|
|
<FormInformation :key="randKey" ref="formInformation" :disabled="false" :formAssignmentData="data.formAssignmentData" :formInfos="data.formInfos" :opinions="data.opinions" :opinionsComponents="data.opinionsComponents" />
|
|
|
|
|
|
</div>
|
2024-02-06 17:36:55 +08:00
|
|
|
|
</div>
|
2024-02-19 17:41:26 +08:00
|
|
|
|
<a-modal :visible="showFlowChart" centered class="geg" closable title="流程图" width="1200px">
|
|
|
|
|
|
<process-information :process-id="processId" :xml="data.xml" />
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<a-button type="primary" @click="closeFlowChart">关闭</a-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</a-modal>
|
2024-02-05 11:27:33 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2024-02-06 17:36:55 +08:00
|
|
|
|
import { useRouter } from 'vue-router';
|
|
|
|
|
|
import userTaskItem from '/@/views/workflow/task/hooks/userTaskItem';
|
|
|
|
|
|
import FormInformation from '/@/views/secondDev/FormInformation.vue';
|
2024-02-19 17:41:26 +08:00
|
|
|
|
import ProcessInformation from '/@/views/workflow/task/components/flow/ProcessInformation.vue';
|
2024-02-21 15:52:18 +08:00
|
|
|
|
import { getStartProcessInfo, getReStartProcessInfo, reLaunch, postLaunch } from '/@/api/workflow/task';
|
2024-02-06 17:36:55 +08:00
|
|
|
|
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
|
2024-02-19 17:41:26 +08:00
|
|
|
|
import { CloseOutlined, SendOutlined, ClockCircleOutlined, PrinterOutlined, ApartmentOutlined } from '@ant-design/icons-vue';
|
2024-02-06 17:36:55 +08:00
|
|
|
|
import { nextTick, onMounted, ref, toRaw } from 'vue';
|
2024-02-20 15:03:32 +08:00
|
|
|
|
import { postDraft, putDraft } from '/@/api/workflow/process';
|
|
|
|
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
2024-02-21 15:52:18 +08:00
|
|
|
|
import { separator } from '/@bpmn/config/info';
|
2024-03-23 12:55:27 +08:00
|
|
|
|
import { message } from 'ant-design-vue';
|
|
|
|
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
const tabStore = useMultipleTabStore();
|
2024-02-05 11:27:33 +08:00
|
|
|
|
|
2024-02-20 15:03:32 +08:00
|
|
|
|
const { t } = useI18n();
|
2024-02-21 15:52:18 +08:00
|
|
|
|
const { data, approveUserData, initProcessData, notificationSuccess, notificationError } = userTaskItem();
|
2024-02-28 16:16:17 +08:00
|
|
|
|
const currentRoute = router.currentRoute.value;
|
|
|
|
|
|
const rParams = currentRoute.params;
|
|
|
|
|
|
const fullPath = currentRoute.fullPath;
|
|
|
|
|
|
const rSchemaId = rParams.arg1;
|
|
|
|
|
|
const rDraftsId = rParams.arg2;
|
2024-02-20 15:03:32 +08:00
|
|
|
|
const draftsJsonStr = localStorage.getItem('draftsJsonStr');
|
2024-02-06 17:36:55 +08:00
|
|
|
|
let formInformation = ref();
|
2024-02-21 15:52:18 +08:00
|
|
|
|
let pageMode = 'new';
|
2024-02-19 17:41:26 +08:00
|
|
|
|
const showFlowChart = ref(false);
|
2024-02-20 15:03:32 +08:00
|
|
|
|
const disableSubmit = ref(false);
|
2024-02-06 17:36:55 +08:00
|
|
|
|
let randKey = ref('randkey'); // 强制表单重新渲染
|
2024-02-05 11:27:33 +08:00
|
|
|
|
|
2024-02-21 15:52:18 +08:00
|
|
|
|
if (draftsJsonStr) {
|
|
|
|
|
|
localStorage.removeItem('draftsJsonStr');
|
|
|
|
|
|
pageMode = 'draft';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-02-19 17:41:26 +08:00
|
|
|
|
function closeFlowChart() {
|
|
|
|
|
|
showFlowChart.value = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function openFlowChart() {
|
|
|
|
|
|
showFlowChart.value = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-23 12:55:27 +08:00
|
|
|
|
function close() {
|
|
|
|
|
|
tabStore.closeTab(currentRoute, router);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-02-06 17:36:55 +08:00
|
|
|
|
const props = defineProps({
|
|
|
|
|
|
schemaId: {
|
|
|
|
|
|
type: String,
|
2024-02-19 17:41:26 +08:00
|
|
|
|
required: true
|
2024-02-06 17:36:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
draftsId: {
|
2024-02-19 17:41:26 +08:00
|
|
|
|
type: String
|
2024-02-06 17:36:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
taskId: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
required: false,
|
2024-02-19 17:41:26 +08:00
|
|
|
|
default: ''
|
2024-02-06 17:36:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
processId: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
required: false,
|
2024-02-19 17:41:26 +08:00
|
|
|
|
default: ''
|
2024-02-06 17:36:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
formData: {
|
2024-02-19 17:41:26 +08:00
|
|
|
|
type: Object
|
2024-02-06 17:36:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
formId: {
|
2024-02-19 17:41:26 +08:00
|
|
|
|
type: String
|
2024-02-06 17:36:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
rowKeyData: {
|
2024-02-19 17:41:26 +08:00
|
|
|
|
type: String
|
|
|
|
|
|
}
|
2024-02-06 17:36:55 +08:00
|
|
|
|
});
|
2024-02-05 11:27:33 +08:00
|
|
|
|
|
2024-02-06 17:36:55 +08:00
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
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);
|
2024-02-05 11:27:33 +08:00
|
|
|
|
|
2024-02-06 17:36:55 +08:00
|
|
|
|
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);
|
|
|
|
|
|
const title = res?.schemaInfo?.name;
|
|
|
|
|
|
if (title) {
|
2024-02-21 15:52:18 +08:00
|
|
|
|
const tabPrefix = pageMode === 'new' ? '新建' : '草稿';
|
2024-02-28 16:16:17 +08:00
|
|
|
|
tabStore.changeTitle(fullPath, `${tabPrefix}:${title}`);
|
2024-02-06 17:36:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
initProcessData(res);
|
2024-02-05 11:27:33 +08:00
|
|
|
|
}
|
2024-02-06 17:36:55 +08:00
|
|
|
|
} catch (error) {}
|
|
|
|
|
|
randKey.value = Math.random() + '';
|
2024-02-20 15:03:32 +08:00
|
|
|
|
// 这里的顺序不能变 表单不渲染的时候 设置表单初值没用
|
|
|
|
|
|
await nextTick();
|
|
|
|
|
|
await initDraftsFormData();
|
2024-02-06 17:36:55 +08:00
|
|
|
|
});
|
2024-02-05 11:27:33 +08:00
|
|
|
|
|
2024-02-06 17:36:55 +08:00
|
|
|
|
async function initDraftsFormData() {
|
|
|
|
|
|
//isPublish.value = Object.keys(data.formInfos).length > 0 ? false : true;
|
2024-02-20 15:03:32 +08:00
|
|
|
|
if (draftsJsonStr) {
|
|
|
|
|
|
let formDataJson = JSON.parse(draftsJsonStr);
|
2024-02-06 17:36:55 +08:00
|
|
|
|
let formData = [];
|
2024-02-05 11:27:33 +08:00
|
|
|
|
|
2024-02-06 17:36:55 +08:00
|
|
|
|
data.formInfos.forEach((item) => {
|
2024-02-19 17:41:26 +08:00
|
|
|
|
if (formDataJson && item.formConfig && item.formConfig.key && formDataJson[item.formConfig.key]) {
|
2024-02-06 17:36:55 +08:00
|
|
|
|
formData.push(item.formConfig.key ? formDataJson[item.formConfig.key] : {});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
await formInformation.value.setFormData(formData);
|
2024-02-05 11:27:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-02-20 15:03:32 +08:00
|
|
|
|
|
|
|
|
|
|
async function saveDraft() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
disableSubmit.value = true;
|
|
|
|
|
|
let formModels = await formInformation.value.saveDraftData();
|
2024-02-28 16:16:17 +08:00
|
|
|
|
if (rDraftsId !== '0') {
|
2024-02-20 15:03:32 +08:00
|
|
|
|
let res = await putDraft(rSchemaId, formModels, rDraftsId, props.rowKeyData);
|
2024-03-23 12:55:27 +08:00
|
|
|
|
showResult(res, '保存草稿');
|
2024-02-20 15:03:32 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
let res = await postDraft(rSchemaId, formModels, props.rowKeyData);
|
2024-03-23 12:55:27 +08:00
|
|
|
|
showResult(res, '保存草稿');
|
2024-02-20 15:03:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
2024-03-23 12:55:27 +08:00
|
|
|
|
notificationError('保存草稿');
|
2024-02-20 15:03:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showResult(res, title) {
|
|
|
|
|
|
if (res) {
|
|
|
|
|
|
notificationSuccess(title);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
notificationError(title);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-02-06 17:36:55 +08:00
|
|
|
|
|
2024-02-21 15:52:18 +08:00
|
|
|
|
|
2024-03-23 12:55:27 +08:00
|
|
|
|
function flowSuccess() {
|
|
|
|
|
|
/*opinionDlg.value.toggleDialog({
|
|
|
|
|
|
isClose: true
|
|
|
|
|
|
});*/
|
|
|
|
|
|
message.success('流程发起成功');
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
close();
|
|
|
|
|
|
}, 500);
|
2024-02-21 15:52:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function saveLaunch() {
|
|
|
|
|
|
data.submitLoading = true;
|
|
|
|
|
|
try {
|
|
|
|
|
|
let validateForms = await formInformation.value.validateForm();
|
|
|
|
|
|
let system = formInformation.value.getSystemType();
|
|
|
|
|
|
|
|
|
|
|
|
if (validateForms.length > 0) {
|
|
|
|
|
|
let successValidate = validateForms.filter((ele) => {
|
|
|
|
|
|
return ele.validate;
|
|
|
|
|
|
});
|
|
|
|
|
|
if (successValidate.length == validateForms.length) {
|
|
|
|
|
|
let formModels = await formInformation.value.getFormModels();
|
|
|
|
|
|
let relationTasks = [];
|
|
|
|
|
|
if (data.predecessorTasks && data.predecessorTasks.length > 0) {
|
|
|
|
|
|
relationTasks = data.predecessorTasks.map((ele) => {
|
|
|
|
|
|
return { taskId: ele.taskId, schemaId: ele.schemaId };
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
let fileFolderIds = getUploadFileFolderIds(formModels);
|
|
|
|
|
|
//如果传入了processId 代表是重新发起流程
|
|
|
|
|
|
let res;
|
|
|
|
|
|
if (props.processId) {
|
|
|
|
|
|
res = await reLaunch(props.processId, props.schemaId, formModels, relationTasks, fileFolderIds, system);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
res = await postLaunch(rSchemaId, formModels, relationTasks, fileFolderIds, system);
|
|
|
|
|
|
}
|
2024-02-06 17:36:55 +08:00
|
|
|
|
|
2024-02-21 15:52:18 +08:00
|
|
|
|
// 下一节点审批人
|
|
|
|
|
|
let taskList = [];
|
|
|
|
|
|
if (res && res.length > 0) {
|
|
|
|
|
|
taskList = res
|
|
|
|
|
|
.filter((ele) => {
|
|
|
|
|
|
return ele.isMultiInstance == false && ele.isAppoint == true;
|
|
|
|
|
|
})
|
|
|
|
|
|
.map((ele) => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
taskId: ele.taskId,
|
|
|
|
|
|
taskName: ele.taskName,
|
|
|
|
|
|
provisionalApprover: ele.provisionalApprover,
|
|
|
|
|
|
selectIds: []
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
if (taskList.length > 0) {
|
2024-03-23 12:55:27 +08:00
|
|
|
|
notificationError('提交失败', '流程设计错误,开始后的第一个节点必须是审批人为发起人的起草节点。');
|
2024-02-21 15:52:18 +08:00
|
|
|
|
data.submitLoading = false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
data.submitLoading = false;
|
2024-03-23 12:55:27 +08:00
|
|
|
|
flowSuccess();
|
2024-02-21 15:52:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
data.submitLoading = false;
|
2024-03-23 12:55:27 +08:00
|
|
|
|
flowSuccess();
|
2024-02-21 15:52:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
data.submitLoading = false;
|
|
|
|
|
|
notificationError(t('发起流程'), t('表单校验未通过'));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
data.submitLoading = false;
|
|
|
|
|
|
notificationError(t('发起流程'), t('发起流程失败'));
|
2024-02-06 17:36:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-02-19 17:41:26 +08:00
|
|
|
|
|
2024-02-21 15:52:18 +08:00
|
|
|
|
function getUploadFileFolderIds(formModels) {
|
|
|
|
|
|
let fileFolderIds = [];
|
|
|
|
|
|
let uploadComponentIds = formInformation.value.getUploadComponentIds();
|
|
|
|
|
|
uploadComponentIds.forEach((ids) => {
|
|
|
|
|
|
if (ids.includes(separator)) {
|
|
|
|
|
|
let arr = ids.split(separator);
|
|
|
|
|
|
if (arr.length == 2 && formModels[arr[0]][arr[1]]) {
|
|
|
|
|
|
fileFolderIds.push(formModels[arr[0]][arr[1]]);
|
|
|
|
|
|
} else if (arr.length == 3 && formModels[arr[0]][arr[1]] && Array.isArray(formModels[arr[0]][arr[1]])) {
|
|
|
|
|
|
formModels[arr[0]][arr[1]].forEach((o) => {
|
|
|
|
|
|
fileFolderIds.push(o[arr[2]]);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
return fileFolderIds;
|
2024-02-19 17:41:26 +08:00
|
|
|
|
}
|
2024-02-21 15:52:18 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="less"></style>
|