diff --git a/src/views/finance/purchasingrequisition/add.vue b/src/views/finance/purchasingrequisition/add.vue
index 969bc00..befe035 100644
--- a/src/views/finance/purchasingrequisition/add.vue
+++ b/src/views/finance/purchasingrequisition/add.vue
@@ -10,12 +10,12 @@
-
+
-
+
-
+ filterable
+ :show-all-levels="true"
+ style="width: 100%"
+ @change="handleCategoryChange" />
@@ -125,7 +126,7 @@
-
+
部门自行采购
@@ -154,7 +155,7 @@
@@ -174,7 +175,7 @@
@@ -194,7 +195,7 @@
@@ -209,7 +210,7 @@
-
+
服务类网上商城
@@ -265,7 +266,7 @@
@@ -292,36 +293,39 @@
无
-
-
-
- 请输入三家供应商名称,用逗号分隔
-
-
-
-
- 下载《服务商城项目需求模板(邀请比选)》模版
-
-
-
+
+
+
+
+
+ 请输入三家供应商名称,用逗号分隔
+
+
+
+
+ 下载《服务商城项目需求模板(邀请比选)》模版
+
+
+
+
+
-
+
学校统一采购
-
+
+
+
+
+ 有
+ 无
+
+
+
+
+
+
+
+ 请输入三家供应商名称,用逗号或分号分隔
+
+
+
+
+ 下载《服务商城项目需求模板(邀请比选)》模版
+
+
+
+
+
+
+
+ 下载《服务商城项目需求模板(公开比选)》模版
+
+
+
+
+
([]);
+const categoryCodePath = ref([]); // 级联选择器的路径数组
const fundSourceList = ref([]);
const isCentralizedList = ref([]);
const isSpecialList = ref([]);
@@ -612,6 +686,14 @@ const purchaseModeSchoolList = ref([]);
const purchaseTypeUnionList = ref([]);
const loading = ref(false);
+// 采购方式ID常量
+const PURCHASE_TYPE_IDS = {
+ BUSINESS_NEGOTIATION: '77b429c146fc9e12ba4c5573da19ad70', // 商务洽谈
+ MARKET_PURCHASE: 'd522054027140e4d76e074cd96ecfc12', // 市场采购
+ ONLINE_MALL: 'e8723b4e3c3d51deb54f9349482ea894', // 网上商城
+ ENTRUST_CENTER: '981bf052a0b30b028a4a89ae490c9b1d' // 委托采购中心
+};
+
// 判断是否为部门自行采购(是否集采=0)
const isDeptPurchase = computed(() => {
return dataForm.isCentralized === '0';
@@ -622,6 +704,31 @@ const stepTwoTitle = computed(() => {
return isDeptPurchase.value ? '部门自行采购' : '学校统一采购';
});
+// 根据 code 查找完整路径(用于回显)
+const findCategoryPath = (data: any[], targetCode: string, path: string[] = []): string[] | null => {
+ for (const item of data) {
+ const currentPath = [...path, item.code];
+ if (item.code === targetCode) {
+ return currentPath;
+ }
+ if (item.children && item.children.length > 0) {
+ const found = findCategoryPath(item.children, targetCode, currentPath);
+ if (found) return found;
+ }
+ }
+ return null;
+};
+
+// 级联选择器变化处理
+const handleCategoryChange = (value: string[]) => {
+ if (value && value.length > 0) {
+ // 取最后一个值作为选中的 code
+ dataForm.categoryCode = value[value.length - 1];
+ } else {
+ dataForm.categoryCode = '';
+ }
+};
+
// 从品目编码中获取项目类型和属性
const getCategoryInfo = () => {
if (!dataForm.categoryCode || categoryTreeData.value.length === 0) {
@@ -678,20 +785,53 @@ const showAutoInviteSelect = computed(() => {
return budget >= 50000 && budget < 400000 && isServiceCategory.value && isSpecialServiceCategory.value;
});
-// 判断是否显示自动公开比选模版(40万<=金额<100万,服务类目,特殊服务类目)
+// 判断是否显示学校统一采购的自动邀请比选模版(5万<=金额<40万,服务类目,特殊服务类目)
+const showAutoInviteSelectSchool = computed(() => {
+ if (isDeptPurchase.value) return false;
+ if (!dataForm.budget) return false;
+ const budget = dataForm.budget;
+ return budget >= 50000 && budget < 400000 && isSpecialServiceCategory.value;
+});
+
+// 判断是否显示自动公开比选模版(40万<=金额<100万,特殊服务类目:isMallService=1、isProjectService=1)
const showAutoPublicSelect = computed(() => {
if (isDeptPurchase.value) return false;
if (!dataForm.budget) return false;
const budget = dataForm.budget;
- return budget >= 400000 && budget < 1000000 && isServiceCategory.value && isSpecialServiceCategory.value;
+ return budget >= 400000 && budget < 1000000 && isSpecialServiceCategory.value;
});
-// 监听品目编码变化,自动设置采购方式
-watch(() => dataForm.categoryCode, (newVal) => {
- if (isAutoSelectPurchaseType.value && !dataForm.purchaseType) {
- const onlineMallOption = purchaseTypeDeptList.value.find(item => item.value === 'online_mall');
- if (onlineMallOption) {
- dataForm.purchaseType = 'online_mall';
+// 判断学校统一采购是否需要自动设置采购方式(5万<=金额<40万,服务类目,特殊服务类目)
+const isAutoSelectPurchaseTypeUnion = computed(() => {
+ if (isDeptPurchase.value) return false;
+ if (!dataForm.budget) return false;
+ const budget = dataForm.budget;
+ return budget >= 50000 && budget < 400000 && isSpecialServiceCategory.value;
+});
+
+// 监听品目编码和预算金额变化,自动设置采购方式
+watch([() => dataForm.categoryCode, () => dataForm.budget], () => {
+ // 部门自行采购:自动设置网上商城
+ if (isAutoSelectPurchaseType.value && isDeptPurchase.value) {
+ // 查找网上商城选项(通过id或value匹配)
+ const onlineMallOption = purchaseTypeDeptList.value.find(item =>
+ item.id === PURCHASE_TYPE_IDS.ONLINE_MALL ||
+ item.value === PURCHASE_TYPE_IDS.ONLINE_MALL
+ );
+ if (onlineMallOption && dataForm.purchaseType !== onlineMallOption.value) {
+ dataForm.purchaseType = onlineMallOption.value;
+ }
+ }
+
+ // 学校统一采购:自动设置网上商城采购方式
+ if (isAutoSelectPurchaseTypeUnion.value && !isDeptPurchase.value) {
+ // 查找学校统一采购方式字典中包含"网上商城"的选项
+ const onlineMallOption = purchaseTypeUnionList.value.find(item => {
+ const label = item.label || item.dictLabel || item.name || '';
+ return label.includes('网上商城') || label.includes('商城');
+ });
+ if (onlineMallOption && dataForm.purchaseTypeUnion !== onlineMallOption.value) {
+ dataForm.purchaseTypeUnion = onlineMallOption.value;
}
}
}, { immediate: true });
@@ -783,6 +923,16 @@ const nextStep = async () => {
try {
const fieldsToValidate = ['projectName', 'applyDate', 'fundSource', 'budget', 'isCentralized', 'isSpecial', 'categoryCode'];
await formRef.value?.validateField(fieldsToValidate);
+
+ // 打印品目编码的值
+ console.log('品目编码值 (categoryCode):', dataForm.categoryCode);
+ console.log('品目编码路径 (categoryCodePath):', categoryCodePath.value);
+ console.log('品目编码完整信息:', {
+ code: dataForm.categoryCode,
+ path: categoryCodePath.value,
+ categoryInfo: getCategoryInfo()
+ });
+
currentStep.value = 1;
} catch (error) {
useMessage().warning('请完善第一步信息');
@@ -882,7 +1032,7 @@ const getIsCentralizedDict = async () => {
// 获取是否特殊情况字典
const getIsSpecialDict = async () => {
try {
- const res = await getDicts('PURCHASE_IS_SPECIAL');
+ const res = await getDicts('PURCHASE_IS_SPEC');
isSpecialList.value = [];
if (res.data && Array.isArray(res.data)) {
isSpecialList.value = res.data.map((item: any) => ({
@@ -914,8 +1064,9 @@ const getPurchaseTypeDeptDict = async () => {
purchaseTypeDeptList.value = [];
if (res.data && Array.isArray(res.data)) {
purchaseTypeDeptList.value = res.data.map((item: any) => ({
+ id: item.id,
label: item.label || item.dictLabel || item.name,
- value: item.value || item.dictValue || item.code
+ value: item.id || item.dictValue || item.code
}));
}
} catch (err) {
@@ -1075,6 +1226,27 @@ const handleTempStore = async () => {
}
};
+// 设置品目编码回显路径
+const setCategoryCodePath = () => {
+ if (dataForm.categoryCode && categoryTreeData.value.length > 0) {
+ const path = findCategoryPath(categoryTreeData.value, dataForm.categoryCode);
+ if (path) {
+ categoryCodePath.value = path;
+ } else {
+ categoryCodePath.value = [];
+ }
+ } else {
+ categoryCodePath.value = [];
+ }
+};
+
+// 监听 categoryTreeData 变化,设置回显路径
+watch(() => categoryTreeData.value, () => {
+ if (dataForm.categoryCode) {
+ setCategoryCodePath();
+ }
+}, { deep: true });
+
// 初始化
onMounted(async () => {
await Promise.all([
@@ -1086,6 +1258,10 @@ onMounted(async () => {
getPurchaseModeSchoolDict(),
getPurchaseTypeUnionDict(),
]);
+ // 如果有 categoryCode,设置回显路径
+ if (dataForm.categoryCode) {
+ setCategoryCodePath();
+ }
});
diff --git a/src/views/finance/purchasingrequisition/form.vue b/src/views/finance/purchasingrequisition/form.vue
index 3055e13..c9937a6 100644
--- a/src/views/finance/purchasingrequisition/form.vue
+++ b/src/views/finance/purchasingrequisition/form.vue
@@ -109,16 +109,17 @@
-
+ style="width: 100%"
+ @change="handleCategoryChange" />
@@ -638,6 +639,7 @@ const dataForm = reactive({
servicePublicSelectSchool: '',
});
const categoryTreeData = ref([]);
+const categoryCodePath = ref([]); // 级联选择器的路径数组
const selectedCategory = ref(null);
const fundSourceList = ref([]);
const isCentralizedList = ref([]);
@@ -667,6 +669,45 @@ const stepTwoTitle = computed(() => {
return isDeptPurchase.value ? '部门自行采购' : '学校统一采购';
});
+// 根据 code 查找完整路径(用于回显)
+const findCategoryPath = (data: any[], targetCode: string, path: string[] = []): string[] | null => {
+ for (const item of data) {
+ const currentPath = [...path, item.code];
+ if (item.code === targetCode) {
+ return currentPath;
+ }
+ if (item.children && item.children.length > 0) {
+ const found = findCategoryPath(item.children, targetCode, currentPath);
+ if (found) return found;
+ }
+ }
+ return null;
+};
+
+// 级联选择器变化处理
+const handleCategoryChange = (value: string[]) => {
+ if (value && value.length > 0) {
+ // 取最后一个值作为选中的 code
+ dataForm.categoryCode = value[value.length - 1];
+ } else {
+ dataForm.categoryCode = '';
+ }
+};
+
+// 设置品目编码回显路径
+const setCategoryCodePath = () => {
+ if (dataForm.categoryCode && categoryTreeData.value.length > 0) {
+ const path = findCategoryPath(categoryTreeData.value, dataForm.categoryCode);
+ if (path) {
+ categoryCodePath.value = path;
+ } else {
+ categoryCodePath.value = [];
+ }
+ } else {
+ categoryCodePath.value = [];
+ }
+};
+
// 从品目编码中获取项目类型和属性
const getCategoryInfo = () => {
if (!dataForm.categoryCode || categoryTreeData.value.length === 0) {
@@ -848,6 +889,7 @@ const openDialog = async (type: 'add' | 'edit' | 'view', rowData?: any) => {
currentStep.value = 0;
// 重置表单
+ categoryCodePath.value = []; // 重置级联选择器路径
Object.assign(dataForm, {
id: '',
projectName: '',
@@ -904,6 +946,10 @@ const openDialog = async (type: 'add' | 'edit' | 'view', rowData?: any) => {
getObj(rowData.id)
.then((res) => {
Object.assign(dataForm, res.data || {});
+ // 设置品目编码回显路径
+ if (dataForm.categoryCode) {
+ setCategoryCodePath();
+ }
if (type === 'edit' || type === 'view') {
currentStep.value = 1;
}
@@ -914,6 +960,9 @@ const openDialog = async (type: 'add' | 'edit' | 'view', rowData?: any) => {
.finally(() => {
loading.value = false;
});
+ } else {
+ // 新增时重置路径
+ categoryCodePath.value = [];
}
});
};
@@ -1002,7 +1051,7 @@ const getIsCentralizedDict = async () => {
// 获取是否特殊情况字典
const getIsSpecialDict = async () => {
try {
- const res = await getDicts('PURCHASE_IS_SPECIAL');
+ const res = await getDicts('PURCHASE_IS_SPEC');
isSpecialList.value = [];
if (res.data && Array.isArray(res.data)) {
isSpecialList.value = res.data.map((item: any) => ({
@@ -1202,6 +1251,13 @@ const handleTempStore = async () => {
}
};
+// 监听 categoryTreeData 变化,设置回显路径
+watch(() => categoryTreeData.value, () => {
+ if (dataForm.categoryCode) {
+ setCategoryCodePath();
+ }
+}, { deep: true });
+
// 暴露变量
defineExpose({
openDialog,