feat(bid): 完成物料分类体系全功能开发

1. 新增物料分类删除校验,支持校验子分类和关联物料
2. 优化物料列表查询,支持按分类及其后代分类筛选
3. 重构物料详情和编辑页面,使用级联选择器选择分类
4. 新增分类管理页面,支持增删改查分类树形结构
5. 新增物料分类初始化SQL脚本,导入标准分类体系
This commit is contained in:
2026-06-17 10:12:34 +08:00
parent 38f6246090
commit c7d4c2b0ad
9 changed files with 621 additions and 99 deletions

View File

@@ -75,7 +75,16 @@
<div class="grid-item">
<span class="grid-label">所属分类</span>
<div class="grid-value-wrap">
<el-input v-if="isEditing" v-model="form.categoryName" size="small" disabled />
<el-cascader
v-if="isEditing"
v-model="form.categoryId"
:options="categoryTreeData"
:props="{ label: 'categoryName', value: 'categoryId', children: 'children', checkStrictly: true, emitPath: false }"
placeholder="请选择分类"
clearable
filterable
size="small"
style="width:100%" />
<span v-else class="grid-value" :class="{ empty: !material.categoryName }">{{ material.categoryName || '' }}</span>
</div>
</div>
@@ -142,6 +151,7 @@
<script>
import { getMaterial, updateMaterial } from "@/api/bid/material";
import { getCategoryList } from "@/api/bid/category";
import SupplierQuoteTab from "./components/SupplierQuoteTab";
import ClientQuoteTab from "./components/ClientQuoteTab";
import CompareSection from "./components/CompareSection";
@@ -156,14 +166,21 @@ export default {
form: {},
perfParams: [],
activeTab: "supplier",
isEditing: false
isEditing: false,
categoryTreeData: []
};
},
created() {
this.materialId = this.$route.query && this.$route.query.id;
this.loadMaterial();
this.loadCategories();
},
methods: {
loadCategories() {
getCategoryList().then(res => {
this.categoryTreeData = res.data || [];
});
},
loadMaterial() {
if (!this.materialId) return;
getMaterial(this.materialId).then(res => {
@@ -201,14 +218,31 @@ export default {
this.$message.success("保存成功");
this.isEditing = false;
// 更新本地数据
this.material = { ...this.material, ...saveData };
// 更新本地数据,同步分类名称显示
const categoryName = this.findCategoryName(this.form.categoryId);
this.material = { ...this.material, ...saveData, categoryName };
this.material.perfArray = this.perfParams;
} catch (error) {
this.$message.error("保存失败:" + error.message);
}
},
// 根据categoryId从分类树中查找分类名称
findCategoryName(categoryId) {
if (!categoryId) return '';
const search = (nodes) => {
for (const n of nodes) {
if (n.categoryId === categoryId) return n.categoryName;
if (n.children && n.children.length) {
const found = search(n.children);
if (found) return found;
}
}
return '';
};
return search(this.categoryTreeData);
},
// 取消编辑
handleCancel() {
this.isEditing = false;