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">
|
2024-03-29 16:41:21 +08:00
|
|
|
|
<FormInformation :key="randKey" ref="formInformation" :disabled="false"
|
|
|
|
|
|
:formAssignmentData="data.formAssignmentData" :formInfos="data.formInfos" :opinions="data.opinions"
|
|
|
|
|
|
:opinionsComponents="data.opinionsComponents" />
|
2024-02-19 17:41:26 +08:00
|
|
|
|
</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-03-29 16:41:21 +08:00
|
|
|
|
<opinion-dialog ref="opinionDlg" />
|
2024-02-05 11:27:33 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2024-03-29 16:41:21 +08:00
|
|
|
|
import { useRouter } from 'vue-router';
|
|
|
|
|
|
import userTaskItem from '/@/views/workflow/task/hooks/userTaskItem';
|
|
|
|
|
|
import FormInformation from '/@/views/secondDev/FormInformation.vue';
|
|
|
|
|
|
import ProcessInformation from '/@/views/workflow/task/components/flow/ProcessInformation.vue';
|
|
|
|
|
|
import { getStartProcessInfo, getReStartProcessInfo, reLaunch, postLaunch, postApproval, postGetNextTaskMaybeArrival } from '/@/api/workflow/task';
|
|
|
|
|
|
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
|
|
|
|
|
|
import { CloseOutlined, SendOutlined, ClockCircleOutlined, PrinterOutlined, ApartmentOutlined } from '@ant-design/icons-vue';
|
|
|
|
|
|
import { nextTick, onMounted, ref, toRaw, reactive } from 'vue';
|
|
|
|
|
|
import { postDraft, putDraft } from '/@/api/workflow/process';
|
|
|
|
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
|
|
|
import { separator } from '/@bpmn/config/info';
|
|
|
|
|
|
import { message } from 'ant-design-vue';
|
|
|
|
|
|
import OpinionDialog from '/@/components/SecondDev/OpinionDialog.vue';
|
|
|
|
|
|
import { ApproveCode, ApproveType } from '/@/enums/workflowEnum';
|
2024-03-23 12:55:27 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
const tabStore = useMultipleTabStore();
|
2024-02-05 11:27:33 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
const { t } = useI18n();
|
|
|
|
|
|
const { data, approveUserData, initProcessData, notificationSuccess, notificationError } = userTaskItem();
|
|
|
|
|
|
const currentRoute = router.currentRoute.value;
|
|
|
|
|
|
const rParams = currentRoute.params;
|
|
|
|
|
|
const fullPath = currentRoute.fullPath;
|
|
|
|
|
|
const rSchemaId = rParams.arg1;
|
|
|
|
|
|
const rDraftsId = rParams.arg2;
|
|
|
|
|
|
const taskId = ref();
|
|
|
|
|
|
const draftsJsonStr = localStorage.getItem('draftsJsonStr');
|
|
|
|
|
|
let formInformation = ref();
|
|
|
|
|
|
const opinionDlg = ref();
|
|
|
|
|
|
let pageMode = 'new';
|
|
|
|
|
|
const showFlowChart = ref(false);
|
|
|
|
|
|
const disableSubmit = ref(false);
|
|
|
|
|
|
const mainFormModels = ref();
|
|
|
|
|
|
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(逗号分隔)
|
|
|
|
|
|
});
|
2024-02-05 11:27:33 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
if (draftsJsonStr) {
|
|
|
|
|
|
localStorage.removeItem('draftsJsonStr');
|
|
|
|
|
|
pageMode = 'draft';
|
|
|
|
|
|
}
|
2024-02-21 15:52:18 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
function closeFlowChart() {
|
|
|
|
|
|
showFlowChart.value = false;
|
|
|
|
|
|
}
|
2024-02-19 17:41:26 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
function openFlowChart() {
|
|
|
|
|
|
showFlowChart.value = true;
|
|
|
|
|
|
}
|
2024-02-19 17:41:26 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
function close() {
|
|
|
|
|
|
tabStore.closeTab(currentRoute, router);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
|
rowKeyData: {
|
|
|
|
|
|
type: String
|
2024-03-23 12:55:27 +08:00
|
|
|
|
}
|
2024-03-29 16:41:21 +08:00
|
|
|
|
});
|
2024-03-23 12:55:27 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 发起流程
|
|
|
|
|
|
let res = await getStartProcessInfo(rSchemaId);
|
|
|
|
|
|
const title = res?.schemaInfo?.name;
|
|
|
|
|
|
if (title) {
|
|
|
|
|
|
const tabPrefix = pageMode === 'new' ? '新建' : '草稿';
|
|
|
|
|
|
tabStore.changeTitle(fullPath, `${tabPrefix}:${title}`);
|
2024-02-19 17:41:26 +08:00
|
|
|
|
}
|
2024-03-29 16:41:21 +08:00
|
|
|
|
initProcessData(res);
|
|
|
|
|
|
} catch (error) { }
|
|
|
|
|
|
randKey.value = Math.random() + '';
|
|
|
|
|
|
// 这里的顺序不能变 表单不渲染的时候 设置表单初值没用
|
|
|
|
|
|
await nextTick();
|
|
|
|
|
|
await initDraftsFormData();
|
|
|
|
|
|
});
|
2024-02-05 11:27:33 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
async function initDraftsFormData() {
|
|
|
|
|
|
//isPublish.value = Object.keys(data.formInfos).length > 0 ? false : true;
|
|
|
|
|
|
if (draftsJsonStr) {
|
|
|
|
|
|
let formDataJson = JSON.parse(draftsJsonStr);
|
|
|
|
|
|
let formData = [];
|
2024-02-05 11:27:33 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
data.formInfos.forEach((item) => {
|
|
|
|
|
|
if (formDataJson && item.formConfig && item.formConfig.key && formDataJson[item.formConfig.key]) {
|
|
|
|
|
|
formData.push(item.formConfig.key ? formDataJson[item.formConfig.key] : {});
|
2024-02-05 11:27:33 +08:00
|
|
|
|
}
|
2024-03-29 16:41:21 +08:00
|
|
|
|
});
|
|
|
|
|
|
await formInformation.value.setFormData(formData);
|
2024-02-05 11:27:33 +08:00
|
|
|
|
}
|
2024-03-29 16:41:21 +08:00
|
|
|
|
}
|
2024-02-20 15:03:32 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
async function saveDraft() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
disableSubmit.value = true;
|
|
|
|
|
|
let formModels = await formInformation.value.saveDraftData();
|
|
|
|
|
|
if (rDraftsId !== '0') {
|
|
|
|
|
|
let res = await putDraft(rSchemaId, formModels, rDraftsId, props.rowKeyData);
|
|
|
|
|
|
showResult(res, '保存草稿');
|
|
|
|
|
|
} else {
|
|
|
|
|
|
let res = await postDraft(rSchemaId, formModels, props.rowKeyData);
|
|
|
|
|
|
showResult(res, '保存草稿');
|
2024-02-20 15:03:32 +08:00
|
|
|
|
}
|
2024-03-29 16:41:21 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
notificationError('保存草稿');
|
2024-02-20 15:03:32 +08:00
|
|
|
|
}
|
2024-03-29 16:41:21 +08:00
|
|
|
|
}
|
2024-02-20 15:03:32 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
function showResult(res, title) {
|
|
|
|
|
|
if (res) {
|
|
|
|
|
|
notificationSuccess(title);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
notificationError(title);
|
2024-02-20 15:03:32 +08:00
|
|
|
|
}
|
2024-03-29 16:41:21 +08:00
|
|
|
|
}
|
2024-02-06 17:36:55 +08:00
|
|
|
|
|
2024-02-21 15:52:18 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
function createFlowSuccess(taskList) {
|
|
|
|
|
|
/*opinionDlg.value.toggleDialog({
|
|
|
|
|
|
isClose: true
|
|
|
|
|
|
});*/
|
|
|
|
|
|
if (taskList) {
|
|
|
|
|
|
approvalCreate();
|
|
|
|
|
|
} else {
|
2024-03-23 12:55:27 +08:00
|
|
|
|
message.success('流程发起成功');
|
2024-03-29 16:41:21 +08:00
|
|
|
|
|
|
|
|
|
|
data.submitLoading = false;
|
2024-03-23 12:55:27 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
close();
|
|
|
|
|
|
}, 500);
|
2024-02-21 15:52:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2024-02-21 15:52:18 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
async function saveLaunch() {
|
|
|
|
|
|
data.submitLoading = true;
|
|
|
|
|
|
try {
|
|
|
|
|
|
let validateForms = await formInformation.value.validateForm();
|
|
|
|
|
|
let system = formInformation.value.getSystemType();
|
2024-02-06 17:36:55 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +08:00
|
|
|
|
if (validateForms.length > 0) {
|
|
|
|
|
|
let successValidate = validateForms.filter((ele) => {
|
|
|
|
|
|
return ele.validate;
|
|
|
|
|
|
});
|
|
|
|
|
|
if (successValidate.length == validateForms.length) {
|
|
|
|
|
|
mainFormModels.value = 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(mainFormModels.value);
|
|
|
|
|
|
//如果传入了processId 代表是重新发起流程
|
|
|
|
|
|
let res;
|
|
|
|
|
|
res = await postLaunch(rSchemaId, mainFormModels.value, relationTasks, fileFolderIds, system);
|
|
|
|
|
|
|
|
|
|
|
|
// 下一节点审批人
|
|
|
|
|
|
let taskList = [];
|
|
|
|
|
|
if (res && res.length > 0) {
|
|
|
|
|
|
taskId.value = res[0].taskId
|
|
|
|
|
|
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) {
|
|
|
|
|
|
notificationError('提交失败', '流程设计错误,开始后的第一个节点必须是审批人为发起人的起草节点。');
|
2024-02-21 15:52:18 +08:00
|
|
|
|
data.submitLoading = false;
|
2024-03-29 16:41:21 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
createFlowSuccess(taskList);
|
2024-02-21 15:52:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2024-03-29 16:41:21 +08:00
|
|
|
|
createFlowSuccess();
|
2024-02-21 15:52:18 +08:00
|
|
|
|
}
|
2024-03-29 16:41:21 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
data.submitLoading = false;
|
|
|
|
|
|
notificationError(t('发起流程'), t('表单校验未通过'));
|
2024-02-21 15:52:18 +08:00
|
|
|
|
}
|
2024-02-06 17:36:55 +08:00
|
|
|
|
}
|
2024-03-29 16:41:21 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
data.submitLoading = false;
|
|
|
|
|
|
notificationError(t('发起流程'), t('发起流程失败'));
|
2024-02-06 17:36:55 +08:00
|
|
|
|
}
|
2024-03-29 16:41:21 +08:00
|
|
|
|
}
|
2024-02-19 17:41:26 +08:00
|
|
|
|
|
2024-03-29 16:41:21 +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]]);
|
|
|
|
|
|
});
|
2024-02-21 15:52:18 +08:00
|
|
|
|
}
|
2024-03-29 16:41:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
return fileFolderIds;
|
|
|
|
|
|
}
|
2024-02-21 15:52:18 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="less"></style>
|