feat(bid): 完成物料管理模块全功能开发

1. 新增物料详情页路由、菜单与接口,支持查看物料报价与信息
2. 重构物料列表页面,新增品牌筛选、表格样式优化与详情跳转
3. 扩展物料实体与数据库字段,新增材质、用途、性能参数等字段
4. 新增供应商/甲方报价查询、批量对比、同名称物料匹配接口
5. 新增物料详情组件,包含基础信息、供应商报价、甲方报价标签页
6. 修复比价路由跳转路径错误,调整数据库密码配置
7. 新增物料相关SQL脚本与初始化数据
This commit is contained in:
2026-05-29 08:58:58 +08:00
parent c718ec4076
commit e521b0dfeb
26 changed files with 4871 additions and 41 deletions

View File

@@ -7,6 +7,11 @@
<el-form-item label="物料编码" prop="materialCode">
<el-input v-model="queryParams.materialCode" placeholder="请输入物料编码" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="厂家/品牌" prop="brand">
<el-select v-model="queryParams.brand" placeholder="全部品牌" clearable style="width:160px" filterable>
<el-option v-for="b in brandList" :key="b" :label="b" :value="b" />
</el-select>
</el-form-item>
<el-form-item label="所属分类">
<el-select v-model="queryParams.categoryId" placeholder="全部分类" clearable style="width:160px">
<el-option v-for="c in flatCategories" :key="c.categoryId"
@@ -28,22 +33,37 @@
</el-col>
</el-row>
<el-table v-loading="loading" :data="materialList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="物料编码" prop="materialCode" width="130" />
<el-table-column label="物料名称" prop="materialName" :show-overflow-tooltip="true" />
<el-table-column label="所属分类" prop="categoryName" width="130" />
<el-table-column label="规格" prop="spec" :show-overflow-tooltip="true" width="130" />
<el-table-column label="型号" prop="modelNo" :show-overflow-tooltip="true" width="130" />
<el-table-column label="单位" prop="unit" width="70" />
<el-table-column label="品牌" prop="brand" width="100" />
<el-table
v-loading="loading"
:data="materialList"
@selection-change="handleSelectionChange"
border
stripe
style="width:100%"
:header-cell-style="{ background: '#f5f7fa', color: '#303133', fontWeight: 700, fontSize: '13px' }"
:cell-style="{ fontSize: '13px', color: '#606266' }">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="物料编码" prop="materialCode" width="140" header-align="center" align="center" />
<el-table-column label="物料名称" prop="materialName" min-width="150" :show-overflow-tooltip="true" />
<el-table-column label="所属分类" prop="categoryName" width="130" :show-overflow-tooltip="true" />
<el-table-column label="厂家/品牌" prop="brand" width="130" :show-overflow-tooltip="true" />
<el-table-column label="规格型号" prop="spec" min-width="160" :show-overflow-tooltip="true" />
<el-table-column label="材质" prop="material" width="90" header-align="center" align="center" />
<el-table-column label="用途" prop="purpose" min-width="160" :show-overflow-tooltip="true" />
<el-table-column label="性能参数" width="200" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span v-if="scope.row.performanceParams">{{ parsePerfParams(scope.row.performanceParams) }}</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="状态" align="center" width="80">
<template slot-scope="scope">
<el-switch v-model="scope.row.status" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="140">
<el-table-column label="操作" align="center" width="210" fixed="right">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-document" @click="handleDetail(scope.row)">详情</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" style="color:#f56c6c" @click="handleDelete(scope.row)">删除</el-button>
</template>
@@ -51,7 +71,8 @@
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<el-dialog :title="title" :visible.sync="open" width="640px" append-to-body>
<!-- 新增/修改对话框 -->
<el-dialog :title="title" :visible.sync="open" width="760px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="90px">
<el-row>
<el-col :span="12">
@@ -72,29 +93,64 @@
<el-input v-model="form.materialName" placeholder="请输入物料名称" />
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="规格" prop="spec">
<el-input v-model="form.spec" placeholder="如:500W/220V" />
<el-col :span="8">
<el-form-item label="厂家/品牌" prop="brand">
<el-input v-model="form.brand" placeholder="如:汇川" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="型号" prop="modelNo">
<el-input v-model="form.modelNo" placeholder="如:XD-2023A" />
<el-col :span="8">
<el-form-item label="规格型号" prop="spec">
<el-input v-model="form.spec" placeholder="如:MD500T37G" />
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="单位" prop="unit">
<el-input v-model="form.unit" placeholder="台/件" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="单位" prop="unit">
<el-input v-model="form.unit" placeholder="如:台/件/米" />
<el-form-item label="材质" prop="material">
<el-input v-model="form.material" placeholder="如:铜/铝合金/PVC" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="品牌" prop="brand">
<el-input v-model="form.brand" />
<el-form-item label="用途" prop="purpose">
<el-input v-model="form.purpose" placeholder="如:通用负载" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="备注信息" />
</el-form-item>
<el-form-item label="性能参数">
<div class="perf-params-form">
<el-button type="success" size="mini" icon="el-icon-plus" @click="addPerfRow">添加参数</el-button>
<el-table :data="perfParams" border size="small" style="margin-top:8px" max-height="240">
<el-table-column label="参数名" width="180">
<template slot-scope="scope">
<el-input v-model="scope.row.name" placeholder="如: 功率" size="small" />
</template>
</el-table-column>
<el-table-column label="参数值" width="180">
<template slot-scope="scope">
<el-input v-model="scope.row.value" placeholder="如: 37" size="small" />
</template>
</el-table-column>
<el-table-column label="单位" width="120">
<template slot-scope="scope">
<el-input v-model="scope.row.unit" placeholder="如: kW" size="small" />
</template>
</el-table-column>
<el-table-column label="操作" width="80" align="center">
<template slot-scope="scope">
<el-button type="text" size="small" style="color:#f56c6c" icon="el-icon-delete" @click="removePerfRow(scope.$index)" />
</template>
</el-table-column>
</el-table>
</div>
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input v-model="form.description" type="textarea" rows="2" />
</el-form-item>
@@ -108,7 +164,7 @@
</template>
<script>
import { listMaterial, getMaterial, addMaterial, updateMaterial, delMaterial } from "@/api/bid/material";
import { listMaterial, getMaterial, addMaterial, updateMaterial, delMaterial, listManufacturer } from "@/api/bid/material";
import { getCategoryList } from "@/api/bid/category";
export default {
@@ -117,9 +173,11 @@ export default {
return {
loading: false, multiple: true, total: 0, materialList: [],
open: false, title: "",
queryParams: { pageNum: 1, pageSize: 10, materialName: null, materialCode: null, categoryId: null },
queryParams: { pageNum: 1, pageSize: 10, materialName: null, materialCode: null, categoryId: null, brand: null, spec: null },
form: {},
flatCategories: [],
brandList: [],
perfParams: [],
rules: {
materialCode: [{ required: true, message: "物料编码不能为空", trigger: "blur" }],
materialName: [{ required: true, message: "物料名称不能为空", trigger: "blur" }],
@@ -129,6 +187,7 @@ export default {
created() {
this.getList();
this.loadCategories();
this.loadBrands();
},
methods: {
loadCategories() {
@@ -136,6 +195,9 @@ export default {
this.flatCategories = this.flattenTree(res.data || [], 0, "");
});
},
loadBrands() {
listManufacturer().then(res => { this.brandList = res.data || []; });
},
flattenTree(nodes, depth, prefix) {
let result = [];
for (const n of nodes) {
@@ -157,21 +219,70 @@ export default {
handleQuery() { this.queryParams.pageNum = 1; this.getList(); },
resetQuery() { this.resetForm("queryForm"); this.handleQuery(); },
handleSelectionChange(sel) { this.multiple = !sel.length; this.ids = sel.map(s => s.materialId); },
handleAdd() { this.reset(); this.open = true; this.title = "新增物料"; },
handleAdd() {
this.reset();
this.perfParams = [];
this.open = true;
this.title = "新增物料";
},
handleUpdate(row) {
this.reset();
getMaterial(row.materialId).then(res => { this.form = res.data; this.open = true; this.title = "修改物料"; });
getMaterial(row.materialId).then(res => {
this.form = res.data;
// 解析性能参数JSON → table
this.perfParams = this.parsePerfParamsToArray(this.form.performanceParams);
this.open = true;
this.title = "修改物料";
});
},
handleDetail(row) {
this.$router.push({ path: '/bid/material/detail', query: { id: row.materialId } });
},
handleDelete(row) {
const ids = row.materialId || (this.ids || []).join(",");
this.$modal.confirm("确认删除?").then(() => delMaterial(ids)).then(() => { this.getList(); this.$modal.msgSuccess("删除成功"); });
},
handleStatusChange(row) { updateMaterial(row); },
reset() { this.form = { status: "0" }; this.resetForm && this.resetForm("form"); },
// 性能参数
addPerfRow() {
this.perfParams.push({ name: '', value: '', unit: '' });
},
removePerfRow(index) {
this.perfParams.splice(index, 1);
},
parsePerfParams(jsonStr) {
if (!jsonStr) return '-';
try {
const obj = JSON.parse(jsonStr);
const arr = Object.keys(obj).map(k => ({ name: k, value: obj[k] }));
return arr.map(p => p.name + ': ' + p.value).join('; ');
} catch { return jsonStr; }
},
parsePerfParamsToArray(jsonStr) {
if (!jsonStr) return [];
try {
// Try [{name,value,unit}] format first
const arr = JSON.parse(jsonStr);
if (Array.isArray(arr)) return arr;
// Try {key: value} format
return Object.keys(arr).map(k => ({ name: k, value: arr[k], unit: '' }));
} catch { return []; }
},
reset() {
this.form = { status: "0" };
this.perfParams = [];
this.resetForm && this.resetForm("form");
},
cancel() { this.open = false; this.reset(); },
submitForm() {
this.$refs["form"].validate(valid => {
if (!valid) return;
// 性能参数数组 → JSON string
if (this.perfParams.length) {
this.form.performanceParams = JSON.stringify(this.perfParams);
} else {
this.form.performanceParams = null;
}
const action = this.form.materialId ? updateMaterial : addMaterial;
action(this.form).then(() => { this.$modal.msgSuccess("操作成功"); this.open = false; this.getList(); });
});
@@ -179,3 +290,59 @@ export default {
}
};
</script>
<style scoped>
.app-container {
background: #fff;
padding: 16px 20px;
border-radius: 4px;
}
/* 搜索表单样式 */
.el-form--inline .el-form-item {
margin-bottom: 16px;
}
.el-form--inline .el-form-item:last-child {
margin-bottom: 0;
}
/* 操作按钮区域间距 */
.mb8 {
margin-bottom: 12px;
}
/* 表格行高 */
>>> .el-table .el-table__row {
height: 42px;
}
/* 表头字体加粗 */
>>> .el-table thead th {
font-weight: 700;
}
/* 开关居中 */
>>> .el-table .el-switch {
margin: 0 auto;
}
/* 对话框内表格边距 */
.perf-params-form {
margin-top: 4px;
}
/* 搜索框宽度统 */
.el-input--small {
width: 160px;
}
.el-form-item:last-child .el-input--small {
width: auto;
}
/* 按钮组间距 */
.el-button + .el-button {
margin-left: 8px;
}
</style>