Merge branch 'dev-gaoang' into 'dev'
feat: 流程中暂存草稿逻辑 See merge request itc-framework/ma/2024/front!63
This commit is contained in:
@ -74,12 +74,14 @@ export async function postDraft(
|
||||
schemaId: string,
|
||||
formData: Array<Recordable>,
|
||||
dataId?: string,
|
||||
processId='',
|
||||
taskId='',
|
||||
mode: ErrorMessageMode = 'modal',
|
||||
) {
|
||||
return defHttp.post<boolean>(
|
||||
{
|
||||
url: Api.Draft,
|
||||
params: { formData, schemaId, dataId },
|
||||
params: { formData, schemaId, dataId, processId, taskId },
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
@ -109,12 +111,14 @@ export async function putDraft(
|
||||
formData: Array<Recordable>,
|
||||
id: string,
|
||||
dataId?: string,
|
||||
processId='',
|
||||
taskId='',
|
||||
mode: ErrorMessageMode = 'modal',
|
||||
) {
|
||||
return defHttp.put<boolean>(
|
||||
{
|
||||
url: Api.Draft,
|
||||
params: { formData, schemaId, id, dataId },
|
||||
params: { formData, schemaId, id, dataId, processId, taskId },
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
@ -139,7 +143,7 @@ export async function deleteDraft(ids: string[], mode: ErrorMessageMode = 'modal
|
||||
/**
|
||||
* @description: 获取草稿详情
|
||||
*/
|
||||
export async function getDraftInfo(id: string, mode: ErrorMessageMode = 'modal') {
|
||||
export async function getDraftInfo(id: string, taskId, userId, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.get<{
|
||||
formData: string;
|
||||
name: string;
|
||||
@ -148,7 +152,7 @@ export async function getDraftInfo(id: string, mode: ErrorMessageMode = 'modal')
|
||||
}>(
|
||||
{
|
||||
url: Api.DraftInfo,
|
||||
params: { id },
|
||||
params: { id, taskId, userId },
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
|
||||
@ -10,6 +10,12 @@
|
||||
</slot>
|
||||
关闭
|
||||
</a-button>
|
||||
<a-button @click="saveDraft" v-if="!readonly">
|
||||
暂存
|
||||
</a-button>
|
||||
<a-button @click="setDraft" v-if="rDraftsId && !readonly">
|
||||
从草稿导入
|
||||
</a-button>
|
||||
<a-button v-if="!readonly && hasBtnApprove" type="primary" @click="onApproveClick()">
|
||||
<slot name="icon">
|
||||
<check-circle-outlined />
|
||||
@ -86,6 +92,9 @@
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { deleteDraft, postDraft, putDraft, getDraftInfo } from '/@/api/workflow/process';
|
||||
import { TaskTypeUrl } from '/@/enums/workflowEnum';
|
||||
|
||||
|
||||
const spinning = ref(false);
|
||||
const userStore = useUserStore();
|
||||
@ -105,6 +114,7 @@
|
||||
const taskId = ref(rQuery.taskId);
|
||||
const processId = ref(rParams.arg2);
|
||||
const readonly = ref(!!rQuery.readonly); // 查看流程会触发只读模式
|
||||
const rDraftsId = ref(rQuery.draftId || '')
|
||||
const renderKey = ref('');
|
||||
const formConfigs = ref();
|
||||
const opinionDlg = ref();
|
||||
@ -115,7 +125,13 @@
|
||||
const hasBtnApprove = ref(true);
|
||||
const hasBtnReject = ref(false);
|
||||
const hasBtnFinish = ref(false);
|
||||
let draftData = {}
|
||||
const drawNode = ref('');
|
||||
const props = defineProps({
|
||||
rowKeyData: {
|
||||
type: String
|
||||
}
|
||||
});
|
||||
|
||||
let approvalData = reactive({
|
||||
isCountersign: false,
|
||||
@ -135,7 +151,6 @@
|
||||
nextTaskUser: {} // 格式为taskKey: 用户id(逗号分隔)
|
||||
});
|
||||
let approvedType = ref(ApproveType.AGREE);
|
||||
|
||||
function onMoreClick(e) {
|
||||
const key = e.key;
|
||||
if (key === 'flowchart') {
|
||||
@ -194,6 +209,56 @@
|
||||
function close() {
|
||||
tabStore.closeTab(currentRoute, router);
|
||||
}
|
||||
async function setDraft(needModal = true) {
|
||||
let formData = [];
|
||||
let params = {
|
||||
taskId: taskId.value,
|
||||
userId: userStore.getUserInfo.id,
|
||||
}
|
||||
let res = await getDraftInfo('', taskId.value, userStore.getUserInfo.id)
|
||||
if(res) {
|
||||
draftData = JSON.parse(res.formData)
|
||||
rDraftsId.value = res.id
|
||||
if(!needModal) return
|
||||
Modal.confirm({
|
||||
title: () => '提示',
|
||||
content: () => '确认使用草稿覆盖当前数据?',
|
||||
onOk: async () => {
|
||||
data.formInfos.forEach((item) => {
|
||||
if (draftData && item.formConfig && item.formConfig.key && draftData[item.formConfig.key]) {
|
||||
formData.push(item.formConfig.key ? draftData[item.formConfig.key] : {});
|
||||
}
|
||||
});
|
||||
await formInformation.value.setFormData(formData);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
async function saveDraft() {
|
||||
try {
|
||||
spinning.value = true;
|
||||
let formModels = await formInformation.value.saveDraftData();
|
||||
if (rDraftsId.value) {
|
||||
let res = await putDraft(schemaId.value, formModels, rDraftsId.value, props.rowKeyData, processId.value, taskId.value);
|
||||
showResult(res, '保存草稿');
|
||||
} else {
|
||||
let res = await postDraft(schemaId.value, formModels, props.rowKeyData, processId.value, taskId.value );
|
||||
showResult(res, '保存草稿');
|
||||
}
|
||||
setDraft(false)
|
||||
spinning.value = false;
|
||||
} catch (error) {
|
||||
spinning.value = false;
|
||||
notificationError('保存草稿');
|
||||
}
|
||||
}
|
||||
function showResult(res, title) {
|
||||
if (res) {
|
||||
notificationSuccess(title);
|
||||
} else {
|
||||
notificationError(title);
|
||||
}
|
||||
}
|
||||
|
||||
async function onApproveClick(isAutoAgreeBreak = false) {
|
||||
openSpinning();
|
||||
@ -360,6 +425,7 @@
|
||||
}
|
||||
renderKey.value = Math.random() + '';
|
||||
getBackNode();
|
||||
setDraft()
|
||||
} catch (error) {}
|
||||
});
|
||||
|
||||
|
||||
@ -97,18 +97,29 @@ function tableActions(record) {
|
||||
|
||||
async function handleEdit(record) {
|
||||
try {
|
||||
let res = await getDraftInfo(record.id);
|
||||
/*processData.draftsId = record.id;
|
||||
processData.schemaId = res.schemaId;
|
||||
processData.draftsJsonStr = res.formData;
|
||||
processData.visible = true;*/
|
||||
localStorage.setItem('draftsJsonStr', res.formData);
|
||||
router.push({
|
||||
path: `/flow/${res.schemaId}/${record.id}/createFlow`,
|
||||
query: {
|
||||
createType: 'drafts'
|
||||
}
|
||||
});
|
||||
const { schemaId, processId, taskId, id } = record;
|
||||
if(taskId){
|
||||
router.push({
|
||||
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
|
||||
query: {
|
||||
taskId: taskId,
|
||||
draftId: id,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let res = await getDraftInfo(record.id);
|
||||
localStorage.setItem('draftsJsonStr', res.formData);
|
||||
router.push({
|
||||
path: `/flow/${schemaId}/${id}/createFlow`,
|
||||
query: {
|
||||
createType: 'drafts'
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) { }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user