更新采购申请
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="mb-2">不满意可继续上传新版本(保留原文件,格式 doc/docx/pdf,单文件不超过 5MB):</div>
|
||||
<div class="mb-2">可继续上传新版本(保留原文件,格式 doc/docx/pdf,单文件不超过 5MB):</div>
|
||||
<upload-file
|
||||
v-model="implementFileIds"
|
||||
:limit="5"
|
||||
@@ -36,9 +36,9 @@
|
||||
upload-file-url="/purchase/purchasingfiles/upload"
|
||||
/>
|
||||
|
||||
<el-divider content-position="left">发起采购文件审批</el-divider>
|
||||
|
||||
|
||||
<!-- 仅部门审核角色显示:采购代表相关 -->
|
||||
<template v-if="isDeptAuditRole">
|
||||
<el-divider content-position="left">采购代表</el-divider>
|
||||
<div class="mb-2">需求部门初审需指定采购代表人,请选择一种方式:</div>
|
||||
<el-radio-group v-model="representorMode" class="mb-2">
|
||||
<el-radio label="single">指定采购代表人(单人)</el-radio>
|
||||
@@ -54,13 +54,14 @@
|
||||
<el-option v-for="m in deptMembers" :key="m.userId || m.teacherNo || m.id" :label="m.realName || m.name || m.teacherNo" :value="m.userId || m.teacherNo || m.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
</div>
|
||||
<div class="implement-footer">
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<template v-if="implementHasPurchaseFiles && !applyRow?.fileFlowInstId">
|
||||
<el-button type="primary" :loading="implementSubmitting" @click="handleImplementSubmit">保存实施采购</el-button>
|
||||
<el-button type="success" :loading="startFileFlowSubmitting" @click="handleStartFileFlow">发起采购文件审批</el-button>
|
||||
<el-button v-if="canStartFileFlow" type="success" :loading="startFileFlowSubmitting" @click="handleStartFileFlow">发起采购文件审批</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button type="primary" :loading="implementSubmitting" @click="handleImplementSubmit">确定</el-button>
|
||||
@@ -76,6 +77,18 @@ import { implementApply, getApplyFiles, startFileFlow, getDeptMembers, getObj }
|
||||
import { useMessage } from '/@/hooks/message'
|
||||
import other from '/@/utils/other'
|
||||
import UploadFile from '/@/components/Upload/index.vue'
|
||||
import { Session } from '/@/utils/storage'
|
||||
|
||||
/** 部门审核角色编码:仅该角色下显示采购代表相关页面和功能,流转至部门审核时需填写采购代表 */
|
||||
const PURCHASE_DEPT_AUDIT_ROLE_CODE = 'PURCHASE_DEPT_AUDIT'
|
||||
/** 采购中心角色编码:可保存/发起实施采购,但不出现采购代表相关内容和接口 */
|
||||
const PURCHASE_CENTER_ROLE_CODE = 'PURCHASE_CENTER'
|
||||
|
||||
const roleCode = computed(() => Session.getRoleCode() || '')
|
||||
const isDeptAuditRole = computed(() => roleCode.value === PURCHASE_DEPT_AUDIT_ROLE_CODE)
|
||||
const isPurchaseCenterRole = computed(() => roleCode.value === PURCHASE_CENTER_ROLE_CODE)
|
||||
/** 可发起采购文件审批:部门审核(需填采购代表)、采购中心(不填采购代表) */
|
||||
const canStartFileFlow = computed(() => isDeptAuditRole.value || isPurchaseCenterRole.value)
|
||||
|
||||
// 与编辑界面一致:支持流程 dynamic-link 传入 currJob/currElTab,申请单 ID 优先取 currJob.orderId
|
||||
const props = defineProps({
|
||||
@@ -153,13 +166,19 @@ const loadData = async () => {
|
||||
useMessage().warning('缺少申请单ID')
|
||||
return
|
||||
}
|
||||
const needDeptMembers = isDeptAuditRole.value
|
||||
try {
|
||||
const idStr = applyIdRaw.value || String(id)
|
||||
const [detailRes, filesRes, membersRes] = await Promise.all([
|
||||
const requests: [ReturnType<typeof getObj>, ReturnType<typeof getApplyFiles>, ReturnType<typeof getDeptMembers>?] = [
|
||||
getObj(id),
|
||||
getApplyFiles(idStr),
|
||||
getDeptMembers()
|
||||
])
|
||||
getApplyFiles(idStr)
|
||||
]
|
||||
if (needDeptMembers) requests.push(getDeptMembers())
|
||||
const results = await Promise.all(requests)
|
||||
const detailRes = results[0]
|
||||
const filesRes = results[1]
|
||||
const membersRes = needDeptMembers ? results[2] : null
|
||||
|
||||
applyRow.value = detailRes?.data ? { ...detailRes.data, id: detailRes.data.id ?? id } : { id }
|
||||
const row = applyRow.value
|
||||
if (row?.implementType) implementType.value = row.implementType
|
||||
@@ -186,7 +205,7 @@ const loadData = async () => {
|
||||
createTime: f.createTime || f.create_time,
|
||||
remark: f.remark
|
||||
}))
|
||||
deptMembers.value = membersRes?.data || []
|
||||
deptMembers.value = needDeptMembers && membersRes?.data ? membersRes.data : []
|
||||
} catch (_) {
|
||||
applyRow.value = { id }
|
||||
purchaseFileVersions.value = []
|
||||
@@ -220,8 +239,9 @@ const handleImplementSubmit = async () => {
|
||||
useMessage().warning('请至少上传一个采购文件')
|
||||
return
|
||||
}
|
||||
const single = representorMode.value === 'single' ? representorTeacherNo.value : undefined
|
||||
const multi = representorMode.value === 'multi' && representorsMulti.value?.length ? representorsMulti.value.join(',') : undefined
|
||||
// 仅部门审核角色提交采购代表;采购中心保存时不传采购代表
|
||||
const single = isDeptAuditRole.value && representorMode.value === 'single' ? representorTeacherNo.value : undefined
|
||||
const multi = isDeptAuditRole.value && representorMode.value === 'multi' && representorsMulti.value?.length ? representorsMulti.value.join(',') : undefined
|
||||
implementSubmitting.value = true
|
||||
try {
|
||||
await implementApply(id, fileIds, implementType.value, single, multi)
|
||||
@@ -240,21 +260,24 @@ const handleStartFileFlow = async () => {
|
||||
const row = applyRow.value
|
||||
const id = row?.id ?? applyId.value
|
||||
if (!id) return
|
||||
if (representorMode.value === 'single') {
|
||||
if (!representorTeacherNo.value) {
|
||||
useMessage().warning('请选择采购代表人')
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if (!representorsMulti.value?.length) {
|
||||
useMessage().warning('请选择部门多人')
|
||||
return
|
||||
// 部门审核角色必须填写采购代表;采购中心不填采购代表
|
||||
if (isDeptAuditRole.value) {
|
||||
if (representorMode.value === 'single') {
|
||||
if (!representorTeacherNo.value) {
|
||||
useMessage().warning('请选择采购代表人')
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if (!representorsMulti.value?.length) {
|
||||
useMessage().warning('请选择部门多人')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
startFileFlowSubmitting.value = true
|
||||
try {
|
||||
const single = representorMode.value === 'single' ? representorTeacherNo.value : undefined
|
||||
const multi = representorMode.value === 'multi' ? representorsMulti.value.join(',') : undefined
|
||||
const single = isDeptAuditRole.value && representorMode.value === 'single' ? representorTeacherNo.value : undefined
|
||||
const multi = isDeptAuditRole.value && representorMode.value === 'multi' ? representorsMulti.value.join(',') : undefined
|
||||
await startFileFlow(id, single, multi)
|
||||
useMessage().success('已发起采购文件审批流程')
|
||||
postMessage('purchasingimplement:submitSuccess')
|
||||
|
||||
Reference in New Issue
Block a user