fix(approval): 上传附件先建空草稿,不再要求先填完表单
八个审批表单页的 uploadFiles 由 ensureDraft(全量校验)改为 ensureInstance:
未建实例时调 createEmptyDraft 只拿实例 id,附件可先传;保存/提交仍走原校验。
后端新增 POST /approval/instance/{flowCode}/draft,空草稿不能提交。
This commit is contained in:
@@ -52,6 +52,19 @@ export async function saveDocument(flowCode: string, data: Record<string, any>)
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 只建空草稿,返回实例id。上传附件前需要实例,但不校验表单字段。
|
||||
*/
|
||||
export async function createEmptyDraft(flowCode: string) {
|
||||
const res = await request.post<ApiResult<number>>(
|
||||
THINK_API_URL + '/approval/instance/' + flowCode + '/draft'
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data as number;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交或重提
|
||||
*/
|
||||
|
||||
@@ -101,6 +101,7 @@ import { computed, reactive, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import {
|
||||
createEmptyDraft,
|
||||
getInstance,
|
||||
saveCompletion,
|
||||
submitInstance
|
||||
@@ -224,6 +225,24 @@ async function ensureDraft(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件只需要实例 id:不校验表单,未建实例时先建空草稿
|
||||
*/
|
||||
async function ensureInstance(): Promise<number> {
|
||||
if (instanceId.value) {
|
||||
return instanceId.value;
|
||||
}
|
||||
try {
|
||||
const id = await createEmptyDraft('completion');
|
||||
instanceId.value = id;
|
||||
mode.value = 'edit';
|
||||
return id;
|
||||
} catch (error: any) {
|
||||
showError(error?.message || '创建草稿失败', null);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDraft() {
|
||||
const id = await ensureDraft();
|
||||
if (!id) {
|
||||
@@ -330,7 +349,7 @@ async function uploadFiles(files: Array<{ path: string; name?: string; size?: nu
|
||||
if (!files.length) {
|
||||
return;
|
||||
}
|
||||
const id = await ensureDraft();
|
||||
const id = await ensureInstance();
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ import { computed, reactive, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import {
|
||||
createEmptyDraft,
|
||||
getInstance,
|
||||
saveCoordination,
|
||||
saveDocument,
|
||||
@@ -296,6 +297,24 @@ async function ensureDraft(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件只需要实例 id:不校验表单,未建实例时先建空草稿
|
||||
*/
|
||||
async function ensureInstance(): Promise<number> {
|
||||
if (instanceId.value) {
|
||||
return instanceId.value;
|
||||
}
|
||||
try {
|
||||
const id = await createEmptyDraft(flowCode.value);
|
||||
instanceId.value = id;
|
||||
mode.value = 'edit';
|
||||
return id;
|
||||
} catch (error: any) {
|
||||
showError(error?.message || '创建草稿失败', null);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDraft() {
|
||||
const id = await ensureDraft();
|
||||
if (!id) {
|
||||
@@ -402,7 +421,7 @@ async function uploadFiles(files: Array<{ path: string; name?: string; size?: nu
|
||||
if (!files.length) {
|
||||
return;
|
||||
}
|
||||
const id = await ensureDraft();
|
||||
const id = await ensureInstance();
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,12 @@
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { getInstance, saveDocument, submitInstance } from '@/api/approval/instance';
|
||||
import {
|
||||
createEmptyDraft,
|
||||
getInstance,
|
||||
saveDocument,
|
||||
submitInstance
|
||||
} from '@/api/approval/instance';
|
||||
import { deleteAttachment, uploadAttachment } from '@/api/approval/attachment';
|
||||
import type { ApprovalAttachment } from '@/api/approval/model';
|
||||
import { showError, showSuccess } from '@/utils/app';
|
||||
@@ -308,6 +313,24 @@ async function ensureDraft(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件只需要实例 id:不校验表单,未建实例时先建空草稿
|
||||
*/
|
||||
async function ensureInstance(): Promise<number> {
|
||||
if (instanceId.value) {
|
||||
return instanceId.value;
|
||||
}
|
||||
try {
|
||||
const id = await createEmptyDraft(FLOW_CODE);
|
||||
instanceId.value = id;
|
||||
mode.value = 'edit';
|
||||
return id;
|
||||
} catch (error: any) {
|
||||
showError(error?.message || '创建草稿失败', null);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDraft() {
|
||||
const id = await ensureDraft();
|
||||
if (!id) {
|
||||
@@ -414,7 +437,7 @@ async function uploadFiles(files: Array<{ path: string; name?: string; size?: nu
|
||||
if (!files.length) {
|
||||
return;
|
||||
}
|
||||
const id = await ensureDraft();
|
||||
const id = await ensureInstance();
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,12 @@ import { computed, reactive, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import Decimal from 'decimal.js';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { getInstance, saveDocument, submitInstance } from '@/api/approval/instance';
|
||||
import {
|
||||
createEmptyDraft,
|
||||
getInstance,
|
||||
saveDocument,
|
||||
submitInstance
|
||||
} from '@/api/approval/instance';
|
||||
import { deleteAttachment, uploadAttachment } from '@/api/approval/attachment';
|
||||
import type { ApprovalAttachment } from '@/api/approval/model';
|
||||
import { showError, showSuccess } from '@/utils/app';
|
||||
@@ -383,6 +388,24 @@ async function ensureDraft(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件只需要实例 id:不校验表单,未建实例时先建空草稿
|
||||
*/
|
||||
async function ensureInstance(): Promise<number> {
|
||||
if (instanceId.value) {
|
||||
return instanceId.value;
|
||||
}
|
||||
try {
|
||||
const id = await createEmptyDraft(FLOW_CODE);
|
||||
instanceId.value = id;
|
||||
mode.value = 'edit';
|
||||
return id;
|
||||
} catch (error: any) {
|
||||
showError(error?.message || '创建草稿失败', null);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDraft() {
|
||||
const id = await ensureDraft();
|
||||
if (!id) {
|
||||
@@ -489,7 +512,7 @@ async function uploadFiles(files: Array<{ path: string; name?: string; size?: nu
|
||||
if (!files.length) {
|
||||
return;
|
||||
}
|
||||
const id = await ensureDraft();
|
||||
const id = await ensureInstance();
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,12 @@
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { getInstance, saveDocument, submitInstance } from '@/api/approval/instance';
|
||||
import {
|
||||
createEmptyDraft,
|
||||
getInstance,
|
||||
saveDocument,
|
||||
submitInstance
|
||||
} from '@/api/approval/instance';
|
||||
import { deleteAttachment, uploadAttachment } from '@/api/approval/attachment';
|
||||
import type { ApprovalAttachment } from '@/api/approval/model';
|
||||
import { showError, showSuccess } from '@/utils/app';
|
||||
@@ -234,6 +239,24 @@ async function ensureDraft(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件只需要实例 id:不校验表单,未建实例时先建空草稿
|
||||
*/
|
||||
async function ensureInstance(): Promise<number> {
|
||||
if (instanceId.value) {
|
||||
return instanceId.value;
|
||||
}
|
||||
try {
|
||||
const id = await createEmptyDraft(FLOW_CODE);
|
||||
instanceId.value = id;
|
||||
mode.value = 'edit';
|
||||
return id;
|
||||
} catch (error: any) {
|
||||
showError(error?.message || '创建草稿失败', null);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDraft() {
|
||||
const id = await ensureDraft();
|
||||
if (!id) {
|
||||
@@ -340,7 +363,7 @@ async function uploadFiles(files: Array<{ path: string; name?: string; size?: nu
|
||||
if (!files.length) {
|
||||
return;
|
||||
}
|
||||
const id = await ensureDraft();
|
||||
const id = await ensureInstance();
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,12 @@ import { computed, reactive, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import Decimal from 'decimal.js';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { getInstance, saveDocument, submitInstance } from '@/api/approval/instance';
|
||||
import {
|
||||
createEmptyDraft,
|
||||
getInstance,
|
||||
saveDocument,
|
||||
submitInstance
|
||||
} from '@/api/approval/instance';
|
||||
import { deleteAttachment, uploadAttachment } from '@/api/approval/attachment';
|
||||
import type { ApprovalAttachment } from '@/api/approval/model';
|
||||
import { showError, showSuccess } from '@/utils/app';
|
||||
@@ -429,6 +434,24 @@ async function ensureDraft(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件只需要实例 id:不校验表单,未建实例时先建空草稿
|
||||
*/
|
||||
async function ensureInstance(): Promise<number> {
|
||||
if (instanceId.value) {
|
||||
return instanceId.value;
|
||||
}
|
||||
try {
|
||||
const id = await createEmptyDraft(FLOW_CODE);
|
||||
instanceId.value = id;
|
||||
mode.value = 'edit';
|
||||
return id;
|
||||
} catch (error: any) {
|
||||
showError(error?.message || '创建草稿失败', null);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDraft() {
|
||||
const id = await ensureDraft();
|
||||
if (!id) {
|
||||
@@ -535,7 +558,7 @@ async function uploadFiles(files: Array<{ path: string; name?: string; size?: nu
|
||||
if (!files.length) {
|
||||
return;
|
||||
}
|
||||
const id = await ensureDraft();
|
||||
const id = await ensureInstance();
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,12 @@
|
||||
import { computed, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { getInstance, saveDocument, submitInstance } from '@/api/approval/instance';
|
||||
import {
|
||||
createEmptyDraft,
|
||||
getInstance,
|
||||
saveDocument,
|
||||
submitInstance
|
||||
} from '@/api/approval/instance';
|
||||
import { deleteAttachment, uploadAttachment } from '@/api/approval/attachment';
|
||||
import type { ApprovalAttachment } from '@/api/approval/model';
|
||||
import { showError, showSuccess } from '@/utils/app';
|
||||
@@ -411,6 +416,24 @@ async function ensureDraft(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件只需要实例 id:不校验表单,未建实例时先建空草稿
|
||||
*/
|
||||
async function ensureInstance(): Promise<number> {
|
||||
if (instanceId.value) {
|
||||
return instanceId.value;
|
||||
}
|
||||
try {
|
||||
const id = await createEmptyDraft(FLOW_CODE);
|
||||
instanceId.value = id;
|
||||
mode.value = 'edit';
|
||||
return id;
|
||||
} catch (error: any) {
|
||||
showError(error?.message || '创建草稿失败', null);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDraft() {
|
||||
const id = await ensureDraft();
|
||||
if (!id) {
|
||||
@@ -517,7 +540,7 @@ async function uploadFiles(files: Array<{ path: string; name?: string; size?: nu
|
||||
if (!files.length) {
|
||||
return;
|
||||
}
|
||||
const id = await ensureDraft();
|
||||
const id = await ensureInstance();
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,12 @@
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { getInstance, saveDocument, submitInstance } from '@/api/approval/instance';
|
||||
import {
|
||||
createEmptyDraft,
|
||||
getInstance,
|
||||
saveDocument,
|
||||
submitInstance
|
||||
} from '@/api/approval/instance';
|
||||
import { deleteAttachment, uploadAttachment } from '@/api/approval/attachment';
|
||||
import { listThinkSite } from '@/api/think/thinkSite';
|
||||
import type { ApprovalAttachment } from '@/api/approval/model';
|
||||
@@ -379,6 +384,24 @@ async function ensureDraft(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件只需要实例 id:不校验表单,未建实例时先建空草稿
|
||||
*/
|
||||
async function ensureInstance(): Promise<number> {
|
||||
if (instanceId.value) {
|
||||
return instanceId.value;
|
||||
}
|
||||
try {
|
||||
const id = await createEmptyDraft(FLOW_CODE);
|
||||
instanceId.value = id;
|
||||
mode.value = 'edit';
|
||||
return id;
|
||||
} catch (error: any) {
|
||||
showError(error?.message || '创建草稿失败', null);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDraft() {
|
||||
const id = await ensureDraft();
|
||||
if (!id) {
|
||||
@@ -485,7 +508,7 @@ async function uploadFiles(files: Array<{ path: string; name?: string; size?: nu
|
||||
if (!files.length) {
|
||||
return;
|
||||
}
|
||||
const id = await ensureDraft();
|
||||
const id = await ensureInstance();
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user