diff --git a/src/api/purchase/purchasingrequisition.ts b/src/api/purchase/purchasingrequisition.ts
index 5e654cf..d2ebaf1 100644
--- a/src/api/purchase/purchasingrequisition.ts
+++ b/src/api/purchase/purchasingrequisition.ts
@@ -437,3 +437,12 @@ export function getSupplementFilesByApplyId(applyId: string) {
params: { purchaseId: applyId },
});
}
+
+export function exportPurchaseApply(params?: any) {
+ return request({
+ url: '/purchase/purchasingapply/export',
+ method: 'get',
+ params,
+ responseType: 'blob',
+ });
+}
diff --git a/src/views/purchase/purchasingrequisition/index.vue b/src/views/purchase/purchasingrequisition/index.vue
index 67762ac..627c274 100644
--- a/src/views/purchase/purchasingrequisition/index.vue
+++ b/src/views/purchase/purchasingrequisition/index.vue
@@ -39,9 +39,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
查询
重置
+ 导出
@@ -206,7 +229,9 @@
>委
@@ -302,7 +327,7 @@
未知
-未发起
+ 未发起
-
@@ -319,16 +344,30 @@
- 运行中
- 已完成
- 已作废
- {{ scope.row.contractFlowStatus }}
+ {{
+ scope.row.contractFlowStatus
+ }}
添加合同
@@ -482,6 +521,7 @@ import {
saveRepresentor,
listDownloadUrls,
updateFiles,
+ exportPurchaseApply,
} from '/@/api/purchase/purchasingrequisition';
import { useMessage, useMessageBox } from '/@/hooks/message';
import { useAuth } from '/@/hooks/auth';
@@ -515,6 +555,7 @@ import {
import other from '/@/utils/other';
import { Session } from '/@/utils/storage';
import { getByPurchaseId } from '/@/api/purchase/purchasingcontract';
+import { getDeptListByLevelTwo } from '/@/api/basic/basicdept';
// 角色常量
const PURCHASE_DEPT_AUDIT_ROLE_CODE = 'PURCHASE_DEPT_AUDIT';
@@ -548,6 +589,52 @@ const dictData = ref({
categoryTreeData: [] as any[],
});
+// 搜索条件相关数据
+const purchaseTypeDeptDelegationList = ref([]); // 委托采购中心采购方式字典
+const secondDeptList = ref([]); // 二级部门列表
+
+// 采购方式搜索选项(根据采购形式动态变化)
+const purchaseTypeSearchOptions = computed(() => {
+ const mode = state.queryForm.purchaseMode;
+ if (mode === '2') {
+ // 学校统一采购:使用UNION_PURCHASE_TYPE字典
+ return dictData.value.purchaseTypeUnionList;
+ } else if (mode === '1') {
+ // 部门自行采购:合并DEPT_PURCHASE_TYPE和PURCHASE_TYPE_DEPT_DELEGATION
+ return [...dictData.value.purchaseTypeDeptList, ...purchaseTypeDeptDelegationList.value];
+ }
+ // 未选择采购形式时,显示所有选项
+ return [...dictData.value.purchaseTypeDeptList, ...purchaseTypeDeptDelegationList.value, ...dictData.value.purchaseTypeUnionList];
+});
+
+// 采购形式变化时清空采购方式
+const handlePurchaseModeChange = () => {
+ state.queryForm.purchaseType = '';
+};
+
+// 搜索条件相关数据
+const purchaseTypeDeptDelegationList = ref([]); // 委托采购中心采购方式字典
+const secondDeptList = ref([]); // 二级部门列表
+
+// 采购方式搜索选项(根据采购形式动态变化)
+const purchaseTypeSearchOptions = computed(() => {
+ const mode = state.queryForm.purchaseMode;
+ if (mode === '2') {
+ // 学校统一采购:使用UNION_PURCHASE_TYPE字典
+ return dictData.value.purchaseTypeUnionList;
+ } else if (mode === '1') {
+ // 部门自行采购:合并DEPT_PURCHASE_TYPE和PURCHASE_TYPE_DEPT_DELEGATION
+ return [...dictData.value.purchaseTypeDeptList, ...purchaseTypeDeptDelegationList.value];
+ }
+ // 未选择采购形式时,显示所有选项
+ return [...dictData.value.purchaseTypeDeptList, ...purchaseTypeDeptDelegationList.value, ...dictData.value.purchaseTypeUnionList];
+});
+
+// 采购形式变化时清空采购方式
+const handlePurchaseModeChange = () => {
+ state.queryForm.purchaseType = '';
+};
+
// 定义变量内容
const router = useRouter();
const tableRef = ref();
@@ -639,6 +726,9 @@ const state: BasicTableProps = reactive({
projectType: '',
status: '',
isCentralized: '',
+ purchaseMode: '',
+ purchaseType: '',
+ deptId: '',
},
createdIsNeed: true,
});
@@ -1072,16 +1162,25 @@ const handleArchive = (row: any) => {
// 获取字典数据和品目树数据
const loadDictData = async () => {
try {
- const [fundSourceRes, isCentralizedRes, isSpecialRes, purchaseTypeDeptRes, purchaseModeSchoolRes, purchaseTypeUnionRes, categoryTreeRes] =
- await Promise.all([
- getDicts('PURCHASE_FUND_SOURCE'),
- getDicts('PURCHASE_IS_CEN'),
- getDicts('PURCHASE_IS_SPEC'),
- getDicts('PURCHASE_TYPE_DEPT'),
- getDicts('PURCHASE_MODE_SCHOOL'),
- getDicts('PURCHASE_TYPE_UNION'),
- getTree(),
- ]);
+ const [
+ fundSourceRes,
+ isCentralizedRes,
+ isSpecialRes,
+ purchaseTypeDeptRes,
+ purchaseModeSchoolRes,
+ purchaseTypeUnionRes,
+ categoryTreeRes,
+ purchaseTypeDeptDelegationRes,
+ ] = await Promise.all([
+ getDicts('PURCHASE_FUND_SOURCE'),
+ getDicts('PURCHASE_IS_CEN'),
+ getDicts('PURCHASE_IS_SPEC'),
+ getDicts('PURCHASE_TYPE_DEPT'),
+ getDicts('PURCHASE_MODE_SCHOOL'),
+ getDicts('PURCHASE_TYPE_UNION'),
+ getTree(),
+ getDicts('PURCHASE_TYPE_DEPT_DELEGATION'),
+ ]);
// 处理资金来源字典
if (fundSourceRes.data && Array.isArray(fundSourceRes.data)) {
@@ -1162,6 +1261,14 @@ const loadDictData = async () => {
}));
}
+ // 处理委托采购中心采购方式字典
+ if (purchaseTypeDeptDelegationRes.data && Array.isArray(purchaseTypeDeptDelegationRes.data)) {
+ purchaseTypeDeptDelegationList.value = purchaseTypeDeptDelegationRes.data.map((item: any) => ({
+ label: item.label || item.dictLabel || item.name,
+ value: item.value || item.dictValue || item.code,
+ }));
+ }
+
// 处理品目树数据
if (categoryTreeRes.data && Array.isArray(categoryTreeRes.data)) {
dictData.value.categoryTreeData = categoryTreeRes.data;
@@ -1202,9 +1309,47 @@ const loadDictData = async () => {
}
};
+// 获取二级部门列表
+const loadSecondDeptList = async () => {
+ try {
+ const res = await getDeptListByLevelTwo();
+ if (res.data && Array.isArray(res.data)) {
+ secondDeptList.value = res.data.map((item: any) => ({
+ id: item.id || item.deptId,
+ name: item.name || item.deptName,
+ }));
+ }
+ } catch (err) {
+ console.error('加载二级部门列表失败', err);
+ secondDeptList.value = [];
+ }
+};
+
+// 导出功能
+const handleExport = async () => {
+ try {
+ const res: any = await exportPurchaseApply(state.queryForm);
+ downloadFile(res, '采购申请列表.xlsx');
+ } catch (err: any) {
+ useMessage().error(err.msg || '导出失败');
+ }
+};
+
+const downloadFile = (blob: Blob, fileName: string) => {
+ const url = window.URL.createObjectURL(blob);
+ const link = document.createElement('a');
+ link.href = url;
+ link.download = fileName;
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ window.URL.revokeObjectURL(url);
+};
+
// 页面加载时获取字典数据和品目树数据
onMounted(() => {
loadDictData();
+ loadSecondDeptList();
});