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,
|
schemaId: string,
|
||||||
formData: Array<Recordable>,
|
formData: Array<Recordable>,
|
||||||
dataId?: string,
|
dataId?: string,
|
||||||
|
processId='',
|
||||||
|
taskId='',
|
||||||
mode: ErrorMessageMode = 'modal',
|
mode: ErrorMessageMode = 'modal',
|
||||||
) {
|
) {
|
||||||
return defHttp.post<boolean>(
|
return defHttp.post<boolean>(
|
||||||
{
|
{
|
||||||
url: Api.Draft,
|
url: Api.Draft,
|
||||||
params: { formData, schemaId, dataId },
|
params: { formData, schemaId, dataId, processId, taskId },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
errorMessageMode: mode,
|
errorMessageMode: mode,
|
||||||
@ -109,12 +111,14 @@ export async function putDraft(
|
|||||||
formData: Array<Recordable>,
|
formData: Array<Recordable>,
|
||||||
id: string,
|
id: string,
|
||||||
dataId?: string,
|
dataId?: string,
|
||||||
|
processId='',
|
||||||
|
taskId='',
|
||||||
mode: ErrorMessageMode = 'modal',
|
mode: ErrorMessageMode = 'modal',
|
||||||
) {
|
) {
|
||||||
return defHttp.put<boolean>(
|
return defHttp.put<boolean>(
|
||||||
{
|
{
|
||||||
url: Api.Draft,
|
url: Api.Draft,
|
||||||
params: { formData, schemaId, id, dataId },
|
params: { formData, schemaId, id, dataId, processId, taskId },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
errorMessageMode: mode,
|
errorMessageMode: mode,
|
||||||
@ -139,7 +143,7 @@ export async function deleteDraft(ids: string[], mode: ErrorMessageMode = 'modal
|
|||||||
/**
|
/**
|
||||||
* @description: 获取草稿详情
|
* @description: 获取草稿详情
|
||||||
*/
|
*/
|
||||||
export async function getDraftInfo(id: string, mode: ErrorMessageMode = 'modal') {
|
export async function getDraftInfo(id: string, taskId, userId, mode: ErrorMessageMode = 'modal') {
|
||||||
return defHttp.get<{
|
return defHttp.get<{
|
||||||
formData: string;
|
formData: string;
|
||||||
name: string;
|
name: string;
|
||||||
@ -148,7 +152,7 @@ export async function getDraftInfo(id: string, mode: ErrorMessageMode = 'modal')
|
|||||||
}>(
|
}>(
|
||||||
{
|
{
|
||||||
url: Api.DraftInfo,
|
url: Api.DraftInfo,
|
||||||
params: { id },
|
params: { id, taskId, userId },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
errorMessageMode: mode,
|
errorMessageMode: mode,
|
||||||
|
|||||||
@ -10,6 +10,12 @@
|
|||||||
</slot>
|
</slot>
|
||||||
关闭
|
关闭
|
||||||
</a-button>
|
</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()">
|
<a-button v-if="!readonly && hasBtnApprove" type="primary" @click="onApproveClick()">
|
||||||
<slot name="icon">
|
<slot name="icon">
|
||||||
<check-circle-outlined />
|
<check-circle-outlined />
|
||||||
@ -86,6 +92,9 @@
|
|||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
import { useUserStore } from '/@/store/modules/user';
|
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 spinning = ref(false);
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@ -105,6 +114,7 @@
|
|||||||
const taskId = ref(rQuery.taskId);
|
const taskId = ref(rQuery.taskId);
|
||||||
const processId = ref(rParams.arg2);
|
const processId = ref(rParams.arg2);
|
||||||
const readonly = ref(!!rQuery.readonly); // 查看流程会触发只读模式
|
const readonly = ref(!!rQuery.readonly); // 查看流程会触发只读模式
|
||||||
|
const rDraftsId = ref(rQuery.draftId || '')
|
||||||
const renderKey = ref('');
|
const renderKey = ref('');
|
||||||
const formConfigs = ref();
|
const formConfigs = ref();
|
||||||
const opinionDlg = ref();
|
const opinionDlg = ref();
|
||||||
@ -115,7 +125,13 @@
|
|||||||
const hasBtnApprove = ref(true);
|
const hasBtnApprove = ref(true);
|
||||||
const hasBtnReject = ref(false);
|
const hasBtnReject = ref(false);
|
||||||
const hasBtnFinish = ref(false);
|
const hasBtnFinish = ref(false);
|
||||||
|
let draftData = {}
|
||||||
const drawNode = ref('');
|
const drawNode = ref('');
|
||||||
|
const props = defineProps({
|
||||||
|
rowKeyData: {
|
||||||
|
type: String
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let approvalData = reactive({
|
let approvalData = reactive({
|
||||||
isCountersign: false,
|
isCountersign: false,
|
||||||
@ -135,7 +151,6 @@
|
|||||||
nextTaskUser: {} // 格式为taskKey: 用户id(逗号分隔)
|
nextTaskUser: {} // 格式为taskKey: 用户id(逗号分隔)
|
||||||
});
|
});
|
||||||
let approvedType = ref(ApproveType.AGREE);
|
let approvedType = ref(ApproveType.AGREE);
|
||||||
|
|
||||||
function onMoreClick(e) {
|
function onMoreClick(e) {
|
||||||
const key = e.key;
|
const key = e.key;
|
||||||
if (key === 'flowchart') {
|
if (key === 'flowchart') {
|
||||||
@ -194,6 +209,56 @@
|
|||||||
function close() {
|
function close() {
|
||||||
tabStore.closeTab(currentRoute, router);
|
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) {
|
async function onApproveClick(isAutoAgreeBreak = false) {
|
||||||
openSpinning();
|
openSpinning();
|
||||||
@ -360,6 +425,7 @@
|
|||||||
}
|
}
|
||||||
renderKey.value = Math.random() + '';
|
renderKey.value = Math.random() + '';
|
||||||
getBackNode();
|
getBackNode();
|
||||||
|
setDraft()
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -97,18 +97,29 @@ function tableActions(record) {
|
|||||||
|
|
||||||
async function handleEdit(record) {
|
async function handleEdit(record) {
|
||||||
try {
|
try {
|
||||||
let res = await getDraftInfo(record.id);
|
|
||||||
/*processData.draftsId = record.id;
|
/*processData.draftsId = record.id;
|
||||||
processData.schemaId = res.schemaId;
|
processData.schemaId = res.schemaId;
|
||||||
processData.draftsJsonStr = res.formData;
|
processData.draftsJsonStr = res.formData;
|
||||||
processData.visible = true;*/
|
processData.visible = true;*/
|
||||||
localStorage.setItem('draftsJsonStr', res.formData);
|
const { schemaId, processId, taskId, id } = record;
|
||||||
router.push({
|
if(taskId){
|
||||||
path: `/flow/${res.schemaId}/${record.id}/createFlow`,
|
router.push({
|
||||||
query: {
|
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
|
||||||
createType: 'drafts'
|
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) { }
|
} catch (error) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user