Merge branch 'developer' of ssh://code.cyweb.top:30033/scj/zhxy/v3/cloud-ui into developer
This commit is contained in:
@@ -76,3 +76,19 @@ export function delObj(id: string | number) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理汇总(按条件统计各代理的项目数、预算金额、合同金额)
|
||||
*/
|
||||
export function getAgentSummary(params?: {
|
||||
deptCode?: string
|
||||
planStartDate?: string
|
||||
planEndDate?: string
|
||||
hasAcceptEvaluation?: string
|
||||
}) {
|
||||
return request({
|
||||
url: '/purchase/purchasingagent/summary',
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,20 @@ export function submitObj(obj: any) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 分配招标代理(指定或随机),仅学校统一采购或部门自行采购且委托采购中心采购时可用
|
||||
* @param applyId 采购申请ID
|
||||
* @param mode random | designated
|
||||
* @param agentId 指定模式时的代理ID
|
||||
*/
|
||||
export function assignAgent(applyId: number | string, mode: 'random' | 'designated', agentId?: string) {
|
||||
return request({
|
||||
url: '/purchase/purchasingapply/assign-agent',
|
||||
method: 'post',
|
||||
data: { id: Number(applyId), mode, agentId: agentId || undefined }
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改采购申请
|
||||
* @param obj 对象数据
|
||||
|
||||
@@ -135,14 +135,22 @@ export function getAcceptanceItems(acceptanceType: string) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载履约验收模板
|
||||
* 导出履约验收评价表(仅填写模式可导出)
|
||||
* 单期返回 docx,exportAll=true 时返回全部期数 zip
|
||||
*/
|
||||
export function downloadPerformanceAcceptanceTemplate(purchaseId: string, batch?: number) {
|
||||
export function downloadPerformanceAcceptanceTemplate(
|
||||
purchaseId: string,
|
||||
batch?: number,
|
||||
exportAll?: boolean
|
||||
) {
|
||||
const params: Record<string, any> = { purchaseId }
|
||||
if (exportAll === true) params.exportAll = true
|
||||
else if (batch != null) params.batch = batch
|
||||
return request({
|
||||
url: '/purchase/purchasingAccept/export-performance-acceptance-template',
|
||||
method: 'get',
|
||||
params: { purchaseId, batch },
|
||||
responseType: 'blob' // 重要:用于文件下载
|
||||
params,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
icon="Files"
|
||||
link
|
||||
type="primary"
|
||||
|
||||
>
|
||||
@click="openSummaryDialog"
|
||||
>
|
||||
代理汇总
|
||||
</el-button>
|
||||
<el-button
|
||||
@@ -119,19 +119,165 @@
|
||||
|
||||
<!-- 编辑、新增表单对话框 -->
|
||||
<FormDialog ref="formDialogRef" @refresh="getDataList" />
|
||||
|
||||
<!-- 代理汇总弹窗 -->
|
||||
<el-dialog
|
||||
v-model="summaryDialogVisible"
|
||||
title="代理数据汇总"
|
||||
width="85%"
|
||||
destroy-on-close
|
||||
class="agent-summary-dialog"
|
||||
>
|
||||
<el-form :model="summaryQuery" inline class="summary-query-form">
|
||||
<el-form-item label="需求部门">
|
||||
<el-select
|
||||
v-model="summaryQuery.deptCode"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px"
|
||||
>
|
||||
<el-option v-for="d in deptOptions" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="计划采购开始时间">
|
||||
<el-date-picker
|
||||
v-model="summaryQuery.planStartDate"
|
||||
type="date"
|
||||
placeholder="请选择"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 180px"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="计划采购结束时间">
|
||||
<el-date-picker
|
||||
v-model="summaryQuery.planEndDate"
|
||||
type="date"
|
||||
placeholder="请选择"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 180px"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否履约评价">
|
||||
<el-select v-model="summaryQuery.hasAcceptEvaluation" placeholder="请选择" clearable style="width: 140px">
|
||||
<el-option label="已履约评价" value="1" />
|
||||
<el-option label="未履约评价" value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="querySummary">查询</el-button>
|
||||
<el-button @click="clearSummaryQuery">清空</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table
|
||||
:data="summaryList"
|
||||
v-loading="summaryLoading"
|
||||
border
|
||||
stripe
|
||||
max-height="400"
|
||||
class="summary-table"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="agentName" label="代理机构" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column prop="projectCount" label="代理项目" width="100" align="center" />
|
||||
<el-table-column prop="budgetAmount" label="预算金额" width="140" align="right">
|
||||
<template #default="{ row }">
|
||||
{{ formatMoney(row.budgetAmount) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="contractAmount" label="合同(成交)金额" width="140" align="right">
|
||||
<template #default="{ row }">
|
||||
{{ formatMoney(row.contractAmount) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="PurchaseAgent">
|
||||
import { ref, reactive, defineAsyncComponent } from 'vue'
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { getPage, delObj } from "/@/api/finance/purchaseagent";
|
||||
import { getPage, delObj, getAgentSummary } from "/@/api/finance/purchaseagent";
|
||||
import { deptTree } from '/@/api/admin/dept';
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import { List, Document, EditPen, Clock, Search } from '@element-plus/icons-vue'
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
|
||||
/** 代理汇总弹窗 */
|
||||
const summaryDialogVisible = ref(false);
|
||||
const summaryLoading = ref(false);
|
||||
const summaryList = ref<any[]>([]);
|
||||
const summaryQuery = reactive({
|
||||
deptCode: '',
|
||||
planStartDate: '',
|
||||
planEndDate: '',
|
||||
hasAcceptEvaluation: '',
|
||||
});
|
||||
const deptOptions = ref<{ label: string; value: string }[]>([]);
|
||||
|
||||
const flattenDept = (nodes: any[], list: { label: string; value: string }[]) => {
|
||||
if (!nodes || !Array.isArray(nodes)) return;
|
||||
nodes.forEach((n: any) => {
|
||||
const code = n.deptId ?? n.id ?? n.deptCode;
|
||||
const name = n.name ?? n.deptName ?? '';
|
||||
if (code != null && String(code)) list.push({ label: name || String(code), value: String(code) });
|
||||
if (n.children?.length) flattenDept(n.children, list);
|
||||
});
|
||||
};
|
||||
|
||||
const openSummaryDialog = async () => {
|
||||
summaryDialogVisible.value = true;
|
||||
if (deptOptions.value.length === 0) {
|
||||
try {
|
||||
const res = await deptTree();
|
||||
const tree = res?.data ?? res ?? [];
|
||||
const list: { label: string; value: string }[] = [];
|
||||
flattenDept(Array.isArray(tree) ? tree : [], list);
|
||||
deptOptions.value = list;
|
||||
} catch (_) {
|
||||
deptOptions.value = [];
|
||||
}
|
||||
}
|
||||
querySummary();
|
||||
};
|
||||
|
||||
const querySummary = async () => {
|
||||
summaryLoading.value = true;
|
||||
try {
|
||||
const res = await getAgentSummary({
|
||||
deptCode: summaryQuery.deptCode || undefined,
|
||||
planStartDate: summaryQuery.planStartDate || undefined,
|
||||
planEndDate: summaryQuery.planEndDate || undefined,
|
||||
hasAcceptEvaluation: summaryQuery.hasAcceptEvaluation || undefined,
|
||||
});
|
||||
summaryList.value = res?.data && Array.isArray(res.data) ? res.data : [];
|
||||
} catch (_) {
|
||||
summaryList.value = [];
|
||||
} finally {
|
||||
summaryLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const clearSummaryQuery = () => {
|
||||
summaryQuery.deptCode = '';
|
||||
summaryQuery.planStartDate = '';
|
||||
summaryQuery.planEndDate = '';
|
||||
summaryQuery.hasAcceptEvaluation = '';
|
||||
querySummary();
|
||||
};
|
||||
|
||||
const formatMoney = (v: any) => {
|
||||
if (v == null || v === '') return '—';
|
||||
const n = Number(v);
|
||||
if (Number.isNaN(n)) return String(v);
|
||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 0, maximumFractionDigits: 2 });
|
||||
};
|
||||
|
||||
// 定义变量内容
|
||||
const tableRef = ref()
|
||||
const formDialogRef = ref()
|
||||
|
||||
@@ -59,8 +59,17 @@
|
||||
</el-col>
|
||||
</template>
|
||||
|
||||
<!-- 上传方式 -->
|
||||
<!-- 上传方式:先模版下载,再上传 -->
|
||||
<template v-if="form.acceptType === '2'">
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="模版下载">
|
||||
<el-link type="primary" :href="lyysTemplateUrl" :download="lyysTemplateDownloadName" target="_blank">
|
||||
<el-icon><Download /></el-icon>
|
||||
{{ lyysTemplateLabel }}
|
||||
</el-link>
|
||||
<!-- <div class="el-form-item__tip">下载后填写并上传;模板文件:templates/lyys-template-{{ projectTypeKey }}.docx</div>-->
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="履约验收模版" prop="templateFileIds">
|
||||
<UploadFile
|
||||
@@ -164,6 +173,14 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { Download } from '@element-plus/icons-vue'
|
||||
|
||||
/** 项目类型 A:货物 B:工程 C:服务,与 public/templates/lyys-template-A|B|C.docx 对应 */
|
||||
const LYYS_TEMPLATE_MAP: Record<string, { label: string }> = {
|
||||
A: { label: '履约验收表模板(货物)' },
|
||||
B: { label: '履约验收表模板(工程)' },
|
||||
C: { label: '履约验收表模板(服务)' },
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -171,11 +188,13 @@ const props = withDefaults(
|
||||
canFill: boolean
|
||||
readonly?: boolean
|
||||
purchaseId?: string
|
||||
/** 项目类型 A:货物 B:工程 C:服务,用于模版下载 */
|
||||
projectType?: string
|
||||
acceptanceItems?: any[]
|
||||
batchNum?: number
|
||||
previousBatchesTeams?: { batch: number; team: any[] }[]
|
||||
}>(),
|
||||
{ readonly: false, canFill: true, purchaseId: '', batchNum: 1, previousBatchesTeams: () => [] }
|
||||
{ readonly: false, canFill: true, purchaseId: '', projectType: 'A', batchNum: 1, previousBatchesTeams: () => [] }
|
||||
)
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
@@ -184,14 +203,19 @@ const formRef = ref<FormInstance>()
|
||||
const templateFileIdsStr = ref('')
|
||||
const copyFromBatch = ref<number | null>(null)
|
||||
|
||||
const projectTypeKey = computed(() => (props.projectType === 'A' || props.projectType === 'B' || props.projectType === 'C' ? props.projectType : 'A'))
|
||||
const lyysTemplateLabel = computed(() => LYYS_TEMPLATE_MAP[projectTypeKey.value]?.label || LYYS_TEMPLATE_MAP.A.label)
|
||||
const lyysTemplateDownloadName = computed(() => `${lyysTemplateLabel.value}.docx`)
|
||||
const lyysTemplateUrl = computed(() => `/templates/lyys-template-${projectTypeKey.value}.docx`)
|
||||
|
||||
const form = reactive({
|
||||
acceptType: '1',
|
||||
acceptDate: '',
|
||||
acceptContents: [] as any[],
|
||||
acceptTeam: [
|
||||
{ name: '', deptCode: '', deptName: '', roleType: '' },
|
||||
{ name: '', deptCode: '', deptName: '', roleType: '' },
|
||||
{ name: '', deptCode: '', deptName: '', roleType: '' },
|
||||
{ name: '', deptCode: '', deptName: '', teacherNo: '', roleType: '' },
|
||||
{ name: '', deptCode: '', deptName: '', teacherNo: '', roleType: '' },
|
||||
{ name: '', deptCode: '', deptName: '', teacherNo: '', roleType: '' },
|
||||
] as any[],
|
||||
templateFileIds: [] as string[],
|
||||
acceptAddress: '',
|
||||
@@ -206,6 +230,15 @@ watch(() => props.modelValue, (val) => {
|
||||
if (!props.canFill && form.acceptType === '1') {
|
||||
form.acceptType = '2'
|
||||
}
|
||||
// 编辑回显:校内成员根据 name/deptCode/deptName/teacherNo 构建 userList 供 org-selector 显示
|
||||
if (Array.isArray(form.acceptTeam)) {
|
||||
form.acceptTeam.forEach((m: any) => {
|
||||
const isIn = m.roleType === 'LEADER_IN' || m.roleType === 'MEMBER_IN'
|
||||
if (isIn && (m.name || m.teacherNo) && !(m.userList && m.userList.length)) {
|
||||
m.userList = buildUserListFromTeamItem(m)
|
||||
}
|
||||
})
|
||||
}
|
||||
}, { deep: true })
|
||||
watch(form, () => emit('update:modelValue', { ...form }), { deep: true })
|
||||
// 金额≥30万时,默认选中上传方式
|
||||
@@ -239,7 +272,7 @@ watch(() => form.templateFileIds, (arr) => {
|
||||
}, { immediate: true, deep: true })
|
||||
|
||||
const addTeam = () => {
|
||||
form.acceptTeam.push({ name: '', deptCode: '', deptName: '', roleType: '' })
|
||||
form.acceptTeam.push({ name: '', deptCode: '', deptName: '', teacherNo: '', roleType: '' })
|
||||
}
|
||||
|
||||
const removeTeam = (idx: number) => {
|
||||
@@ -254,7 +287,9 @@ const onCopyFromBatch = (n: number | null) => {
|
||||
name: m.name || '',
|
||||
deptCode: m.deptCode || '',
|
||||
deptName: m.deptName || '',
|
||||
teacherNo: m.teacherNo || '',
|
||||
roleType: m.roleType || '',
|
||||
userList: buildUserListFromTeamItem(m),
|
||||
}))
|
||||
}
|
||||
copyFromBatch.value = null
|
||||
@@ -279,6 +314,22 @@ const onRoleChange = (idx: number, val: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
/** 从接口返回的成员项构建 org-selector 所需的 userList(编辑回显用) */
|
||||
const buildUserListFromTeamItem = (t: any) => {
|
||||
if (!t?.name && !t?.teacherNo) return []
|
||||
return [
|
||||
{
|
||||
id: t.teacherNo || t.name,
|
||||
name: t.name || '',
|
||||
type: 'user',
|
||||
deptCode: t.deptCode,
|
||||
deptName: t.deptName,
|
||||
teacherNo: t.teacherNo,
|
||||
realName: t.name,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
const onTeamUserChange = (idx: number, list: any[]) => {
|
||||
const m = form.acceptTeam[idx]
|
||||
if (!m) return
|
||||
@@ -287,11 +338,13 @@ const onTeamUserChange = (idx: number, list: any[]) => {
|
||||
m.name = u.name || u.realName || ''
|
||||
m.deptCode = u.deptCode || u.commonDeptCode || ''
|
||||
m.deptName = u.deptName || u.commonDeptName || ''
|
||||
m.teacherNo = u.teacherNo ?? u.username ?? u.id ?? ''
|
||||
m.userList = list
|
||||
} else {
|
||||
m.name = ''
|
||||
m.deptCode = ''
|
||||
m.deptName = ''
|
||||
m.teacherNo = ''
|
||||
m.userList = []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,12 +133,18 @@ const syncFormFromModel = (val: Record<string, any> | undefined) => {
|
||||
|
||||
const loadContractOptions = async () => {
|
||||
if (contractLoaded.value || contractLoading.value) return
|
||||
if (form.hasContract !== '1') return
|
||||
contractLoading.value = true
|
||||
try {
|
||||
const res = await getContracts(props.purchaseId ? { id: props.purchaseId } : {})
|
||||
const list = res?.data
|
||||
contractOptions.value = Array.isArray(list) ? list : []
|
||||
contractLoaded.value = true
|
||||
// 回显时:列表中含当前合同,用其供应商名称填充(若尚未有值)
|
||||
if (form.contractId) {
|
||||
const c = contractOptions.value.find((it: any) => it.id === form.contractId)
|
||||
if (c?.supplierName) form.supplierName = c.supplierName
|
||||
}
|
||||
} catch (_) {
|
||||
contractOptions.value = []
|
||||
} finally {
|
||||
@@ -152,7 +158,17 @@ const onContractSelectVisibleChange = (visible: boolean) => {
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.modelValue, syncFormFromModel, { deep: true, immediate: true })
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val) => {
|
||||
syncFormFromModel(val)
|
||||
// 回显:已有合同ID时主动加载合同列表,以便下拉显示合同名称(后端已排除“其他申请”的合同,当前申请合同会在列表中)
|
||||
if (form.hasContract === '1' && form.contractId && props.purchaseId && !contractLoaded.value && !contractLoading.value) {
|
||||
loadContractOptions()
|
||||
}
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
)
|
||||
// resetKey 变化时强制用 modelValue 覆盖内部 form,并重置合同列表以便重新拉取
|
||||
watch(() => props.resetKey, () => {
|
||||
syncFormFromModel(props.modelValue)
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
:can-fill="canFillForm"
|
||||
:readonly="false"
|
||||
:purchase-id="String(purchaseId)"
|
||||
:project-type="acceptProjectType"
|
||||
:acceptance-items="acceptanceItems"
|
||||
:batch-num="b.batch"
|
||||
:previous-batches-teams="getPreviousBatchesTeams(b.batch)"
|
||||
@@ -82,16 +83,22 @@
|
||||
<template #footer>
|
||||
<span>
|
||||
<el-button @click="handleClose">关 闭</el-button>
|
||||
<!-- 下载履约验收模板按钮 -->
|
||||
<el-dropdown split-button type="primary" @click="handleDownloadTemplate" @command="handleDownloadTemplateCommand">
|
||||
下载履约模板
|
||||
<!-- 仅填写履约验收评价表模式可导出;单期 docx,全部期数 zip -->
|
||||
<el-dropdown
|
||||
v-if="showExportDropdown"
|
||||
split-button
|
||||
type="primary"
|
||||
@click="handleDownloadTemplate"
|
||||
@command="handleDownloadTemplateCommand"
|
||||
>
|
||||
导出履约验收评价表
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="current" :disabled="!activeBatchId">
|
||||
<el-dropdown-item command="current" :disabled="!canExportCurrentBatch">
|
||||
下载当前期({{ activeTab }}期)
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item command="all" :disabled="batches.length === 0">
|
||||
下载全部期数
|
||||
<el-dropdown-item command="all" :disabled="!canExportAllBatches">
|
||||
下载全部期数(zip)
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
@@ -165,6 +172,20 @@ const activeBatchId = computed(() => {
|
||||
return b?.id || ''
|
||||
})
|
||||
|
||||
/** 项目类型 A:货物 B:工程 C:服务,用于批次表单模版下载 */
|
||||
const acceptProjectType = computed(() => applyInfo.value?.projectType || rowProjectType.value || 'A')
|
||||
|
||||
/** 当前期是否为「填写履约验收评价表」模式,仅此模式可导出 */
|
||||
const canExportCurrentBatch = computed(() => batchForms[Number(activeTab.value)]?.acceptType === '1')
|
||||
/** 是否存在任一批次为填写模式(可导出全部期数 zip) */
|
||||
const canExportAllBatches = computed(() =>
|
||||
batches.value.some((b: any) => batchForms[b.batch]?.acceptType === '1')
|
||||
)
|
||||
/** 仅在有批次且至少一期为填写模式时显示导出下拉 */
|
||||
const showExportDropdown = computed(
|
||||
() => mainTab.value === 'batch' && batches.value.length > 0 && (canExportCurrentBatch.value || canExportAllBatches.value)
|
||||
)
|
||||
|
||||
const getPreviousBatchesTeams = (batchNum: number) => {
|
||||
const list: { batch: number; team: any[] }[] = []
|
||||
for (let n = 1; n < batchNum; n++) {
|
||||
@@ -287,12 +308,13 @@ const loadBatchDetails = async () => {
|
||||
name: t.name,
|
||||
deptCode: t.deptCode,
|
||||
deptName: t.deptName,
|
||||
teacherNo: t.teacherNo || '',
|
||||
roleType: t.roleType || '',
|
||||
})),
|
||||
}
|
||||
if (batchForms[b.batch].acceptTeam.length < 3) {
|
||||
while (batchForms[b.batch].acceptTeam.length < 3) {
|
||||
batchForms[b.batch].acceptTeam.push({ name: '', deptCode: '', deptName: '' })
|
||||
batchForms[b.batch].acceptTeam.push({ name: '', deptCode: '', deptName: '', teacherNo: '', roleType: '' })
|
||||
}
|
||||
}
|
||||
if (acceptanceItems.value.length && (!batchForms[b.batch].acceptContents || batchForms[b.batch].acceptContents.length === 0)) {
|
||||
@@ -399,48 +421,61 @@ const handleClose = () => {
|
||||
emit('refresh')
|
||||
}
|
||||
|
||||
// 下载履约验收模板
|
||||
// 导出履约验收评价表(仅填写模式可导出)
|
||||
const handleDownloadTemplate = async () => {
|
||||
if (!purchaseId.value) {
|
||||
useMessage().error('请先选择采购项目')
|
||||
return
|
||||
}
|
||||
|
||||
// 默认下载当前期
|
||||
if (!canExportCurrentBatch.value) {
|
||||
useMessage().error('仅填写履约验收评价表模式可导出,请先选择该模式并保存')
|
||||
return
|
||||
}
|
||||
await downloadTemplateForBatch(Number(activeTab.value))
|
||||
}
|
||||
|
||||
// 处理下拉菜单命令
|
||||
const handleDownloadTemplateCommand = async (command: string) => {
|
||||
if (!purchaseId.value) {
|
||||
useMessage().error('请先选择采购项目')
|
||||
return
|
||||
}
|
||||
|
||||
if (command === 'current') {
|
||||
if (!canExportCurrentBatch.value) {
|
||||
useMessage().error('当前期未选择填写履约验收评价表模式,无法导出')
|
||||
return
|
||||
}
|
||||
await downloadTemplateForBatch(Number(activeTab.value))
|
||||
} else if (command === 'all') {
|
||||
// 下载全部期数的模板
|
||||
for (const batch of batches.value) {
|
||||
await downloadTemplateForBatch(batch.batch)
|
||||
if (!canExportAllBatches.value) {
|
||||
useMessage().error('没有填写模式的分期可导出')
|
||||
return
|
||||
}
|
||||
useMessage().success(`已触发${batches.value.length}期模板下载`)
|
||||
await downloadAllBatchesAsZip()
|
||||
}
|
||||
}
|
||||
|
||||
// 为指定批次下载模板
|
||||
const downloadTemplateForBatch = async (batchNum: number) => {
|
||||
try {
|
||||
const response = await downloadPerformanceAcceptanceTemplate(String(purchaseId.value), batchNum)
|
||||
|
||||
// 使用项目中现有的工具函数处理文件下载
|
||||
const fileName = `履约验收表-${purchaseId.value}-第${batchNum}期-${new Date().getTime()}.docx`;
|
||||
const fileName = `履约验收表-${purchaseId.value}-第${batchNum}期.docx`
|
||||
handleBlobFile(response, fileName)
|
||||
|
||||
useMessage().success(`第${batchNum}期履约模板下载成功`)
|
||||
useMessage().success(`第${batchNum}期导出成功`)
|
||||
} catch (error: any) {
|
||||
console.error('下载模板失败:', error)
|
||||
useMessage().error(error?.msg || '下载履约模板失败')
|
||||
console.error('导出失败:', error)
|
||||
useMessage().error(error?.msg || '导出失败')
|
||||
}
|
||||
}
|
||||
|
||||
const downloadAllBatchesAsZip = async () => {
|
||||
try {
|
||||
const response = await downloadPerformanceAcceptanceTemplate(String(purchaseId.value), undefined, true)
|
||||
const fileName = `履约验收表-${purchaseId.value}-全部期数.zip`
|
||||
handleBlobFile(response, fileName)
|
||||
const count = batches.value.filter((b: any) => batchForms[b.batch]?.acceptType === '1').length
|
||||
useMessage().success(`已导出${count}期,请查收 zip 文件`)
|
||||
} catch (error: any) {
|
||||
console.error('导出全部期数失败:', error)
|
||||
useMessage().error(error?.msg || '导出全部期数失败')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -403,6 +403,17 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 查看时:招标代理(与实施采购信息同风格:分割线+标签值同行) -->
|
||||
<div v-if="isViewMode && dataForm.agentName" class="implement-info-block mb20">
|
||||
<el-divider content-position="left">招标代理</el-divider>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12" class="mb16">
|
||||
<div class="view-label">代理名称</div>
|
||||
<div class="view-value">{{ dataForm.agentName }}</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<!-- 查看时:实施采购信息 -->
|
||||
<div v-if="isViewMode && (dataForm.implementType || viewImplementPurchaseFiles.length)" class="implement-info-block mb20">
|
||||
<el-divider content-position="left">实施采购信息</el-divider>
|
||||
@@ -616,6 +627,8 @@ const dataForm = reactive({
|
||||
implementType: '',
|
||||
fileFlowInstId: '',
|
||||
fileFlowStatus: '',
|
||||
agentId: '',
|
||||
agentName: '',
|
||||
});
|
||||
/** 查看时展示的采购文件列表(实施采购上传的 type=130) */
|
||||
const viewImplementPurchaseFiles = ref<{ id: string; fileTitle?: string; createTime?: string; remark?: string }[]>([]);
|
||||
@@ -1147,6 +1160,8 @@ async function loadDetail(applyId: string | number) {
|
||||
implementType: detail.implementType ?? '',
|
||||
fileFlowInstId: detail.fileFlowInstId ?? '',
|
||||
fileFlowStatus: detail.fileFlowStatus ?? '',
|
||||
agentId: detail.agentId ?? '',
|
||||
agentName: detail.agentName ?? '',
|
||||
});
|
||||
setCategoryCodePath();
|
||||
currentStep.value = 0;
|
||||
|
||||
@@ -336,6 +336,61 @@
|
||||
|
||||
<!-- 实施采购:iframe 嵌入 implement.vue,供列表与流程页面使用 -->
|
||||
<ImplementForm ref="implementFormRef" @refresh="getDataList" />
|
||||
|
||||
<!-- 分配代理弹窗 -->
|
||||
<el-dialog
|
||||
v-model="assignAgentDialogVisible"
|
||||
title="分配代理"
|
||||
width="420px"
|
||||
destroy-on-close
|
||||
@close="assignAgentForm.agentId = ''; assignAgentForm.mode = 'designated'"
|
||||
>
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="分配方式">
|
||||
<el-radio-group v-model="assignAgentForm.mode">
|
||||
<el-radio label="designated">指定</el-radio>
|
||||
<el-radio label="random">随机</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="assignAgentForm.mode === 'designated'" label="招标代理">
|
||||
<el-select
|
||||
v-model="assignAgentForm.agentId"
|
||||
placeholder="请选择招标代理"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
:loading="agentListLoading"
|
||||
>
|
||||
<el-option v-for="item in agentList" :key="item.id" :label="item.agentName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="assignAgentCurrentRow?.agentName" label="当前代理">
|
||||
<span>{{ assignAgentCurrentRow.agentName }}</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span>
|
||||
<el-button @click="assignAgentDialogVisible = false">取消</el-button>
|
||||
<el-button
|
||||
v-if="assignAgentForm.mode === 'random'"
|
||||
type="primary"
|
||||
:loading="assignAgentSubmitting"
|
||||
@click="handleAssignAgentRandom"
|
||||
>
|
||||
随机分配
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
type="primary"
|
||||
:loading="assignAgentSubmitting"
|
||||
:disabled="!assignAgentForm.agentId"
|
||||
@click="handleAssignAgentDesignated"
|
||||
>
|
||||
确定
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -343,7 +398,8 @@
|
||||
import { ref, reactive, defineAsyncComponent, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { getPage, delObj, submitObj, getArchiveDownloadUrl, getApplyTemplateDownloadUrl, getFileApplyTemplateDownloadUrl } from "/@/api/finance/purchasingrequisition";
|
||||
import { getPage, delObj, submitObj, getArchiveDownloadUrl, getApplyTemplateDownloadUrl, getFileApplyTemplateDownloadUrl, assignAgent } from "/@/api/finance/purchasingrequisition";
|
||||
import { getPage as getAgentPage } from '/@/api/finance/purchaseagent';
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import { getDicts } from '/@/api/admin/dict';
|
||||
import { getTree } from '/@/api/finance/purchasingcategory';
|
||||
@@ -382,6 +438,75 @@ const currFlowCommentType = ref<'apply' | 'file'>('apply')
|
||||
|
||||
const implementFormRef = ref()
|
||||
|
||||
/** 分配代理弹窗 */
|
||||
const assignAgentDialogVisible = ref(false)
|
||||
const assignAgentCurrentRow = ref<any>(null)
|
||||
const assignAgentForm = reactive({ mode: 'designated' as 'designated' | 'random', agentId: '' })
|
||||
const agentList = ref<any[]>([])
|
||||
const agentListLoading = ref(false)
|
||||
const assignAgentSubmitting = ref(false)
|
||||
|
||||
const openAssignAgentDialog = async (row: any) => {
|
||||
assignAgentCurrentRow.value = row
|
||||
assignAgentForm.mode = 'designated'
|
||||
assignAgentForm.agentId = ''
|
||||
assignAgentDialogVisible.value = true
|
||||
agentListLoading.value = true
|
||||
try {
|
||||
const res = await getAgentPage({ size: 500, current: 1 })
|
||||
const records = res?.data?.records ?? res?.records ?? []
|
||||
agentList.value = Array.isArray(records) ? records : []
|
||||
} catch (_) {
|
||||
agentList.value = []
|
||||
} finally {
|
||||
agentListLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleAssignAgentRandom = async () => {
|
||||
const row = assignAgentCurrentRow.value
|
||||
const id = row?.id ?? row?.purchaseId
|
||||
if (id == null || id === '') {
|
||||
useMessage().warning('无法获取申请单ID')
|
||||
return
|
||||
}
|
||||
assignAgentSubmitting.value = true
|
||||
try {
|
||||
await assignAgent(Number(id), 'random')
|
||||
useMessage().success('随机分配代理成功')
|
||||
assignAgentDialogVisible.value = false
|
||||
getDataList()
|
||||
} catch (e: any) {
|
||||
useMessage().error(e?.msg || '随机分配代理失败')
|
||||
} finally {
|
||||
assignAgentSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleAssignAgentDesignated = async () => {
|
||||
const row = assignAgentCurrentRow.value
|
||||
const id = row?.id ?? row?.purchaseId
|
||||
if (id == null || id === '') {
|
||||
useMessage().warning('无法获取申请单ID')
|
||||
return
|
||||
}
|
||||
if (!assignAgentForm.agentId) {
|
||||
useMessage().warning('请选择招标代理')
|
||||
return
|
||||
}
|
||||
assignAgentSubmitting.value = true
|
||||
try {
|
||||
await assignAgent(Number(id), 'designated', assignAgentForm.agentId)
|
||||
useMessage().success('指定代理成功')
|
||||
assignAgentDialogVisible.value = false
|
||||
getDataList()
|
||||
} catch (e: any) {
|
||||
useMessage().error(e?.msg || '指定代理失败')
|
||||
} finally {
|
||||
assignAgentSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义响应式表格数据
|
||||
*/
|
||||
@@ -561,6 +686,12 @@ const getActionMenuItems = (row: any) => {
|
||||
icon: Download,
|
||||
visible: () => true,
|
||||
},
|
||||
{
|
||||
command: 'assignAgent',
|
||||
label: '分配代理',
|
||||
icon: Collection,
|
||||
visible: () => row?.purchaseMode === '2' || (row?.purchaseMode === '0' && row?.purchaseType === '4'),
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
@@ -591,6 +722,9 @@ const handleMoreCommand = (command: string, row: any) => {
|
||||
case 'downloadFileApply':
|
||||
handleDownloadFileApply(row);
|
||||
break;
|
||||
case 'assignAgent':
|
||||
openAssignAgentDialog(row);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user