fix(crm/contract): 修复产品选择组件只读逻辑并优化数据源

1. 将产品名称和材质选择框的readonly属性替换为disabled,修复禁用状态下仍可编辑的问题
2. 注释原有硬编码的产品和材质选项,改为通过字典contract_product_material动态获取
3. 新增字典数据转换逻辑,生成动态的产品选项和材质选项列表
4. 新增材质默认空值处理逻辑,避免未赋值时的异常
This commit is contained in:
2026-06-24 14:46:33 +08:00
parent 7eda414846
commit 8d2d22de50

View File

@@ -6,7 +6,7 @@
<div class="table-row table-header">
<div class="table-cell" colspan="3">
<div class="company-name">产品名称
<el-select style="width: 120px;" v-model="productName" placeholder="请选择产品名称" size="small" :readonly="readonly" filterable allow-create clearable>
<el-select style="width: 120px;" v-model="productName" placeholder="请选择产品名称" size="small" :disabled="readonly" filterable allow-create clearable>
<el-option v-for="item in productOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</div>
@@ -50,7 +50,7 @@
<el-input v-model="item.spec" placeholder="请输入规格" :readonly="readonly" size="small" />
</div>
<div class="table-cell">
<el-select v-model="item.material" placeholder="请选择材质" :readonly="readonly" size="small" filterable allow-create clearable style="width:100%;">
<el-select v-model="item.material" placeholder="请选择材质" :disabled="readonly" size="small" filterable allow-create clearable style="width:100%;">
<el-option v-for="opt in materialOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
</div>
@@ -148,28 +148,31 @@ export default {
remark: '',
productName: '',
previousProductName: '',
productMaterialMap: {
'冷硬钢卷': 'SPCC',
'镀锌钢卷': 'DX51D+Z',
'冷轧钢卷': 'DC01',
'冷轧卷(花纹)': 'DC01-H',
'镀铬钢卷': 'SPCC',
},
productOptions: [
{ label: '冷硬钢卷', value: '冷硬钢卷' },
{ label: '镀锌钢卷', value: '镀锌钢卷' },
{ label: '冷轧钢卷', value: '冷轧钢卷' },
{ label: '冷轧卷(花纹)', value: '冷轧卷(花纹)' },
{ label: '镀铬钢卷', value: '镀铬钢卷' },
],
materialOptions: [
{ label: 'SPCC', value: 'SPCC' },
{ label: 'DX51D+Z', value: 'DX51D+Z' },
{ label: 'DC01', value: 'DC01' },
{ label: 'DC01-H', value: 'DC01-H' }
]
// productMaterialMap: {
// '冷硬钢卷': 'SPCC',
// '镀锌钢卷': 'DX51D+Z',
// '冷轧钢卷': 'DC01',
// '冷轧卷(花纹)': 'DC01-H',
// '镀铬钢卷': 'SPCC',
// '镀锌管料带钢': 'DX51D+Z'
// },
// productOptions: [
// { label: '冷硬钢卷', value: '冷硬钢卷' },
// { label: '镀锌钢卷', value: '镀锌钢卷' },
// { label: '冷轧钢卷', value: '冷轧钢卷' },
// { label: '冷轧卷(花纹)', value: '冷轧卷(花纹)' },
// { label: '镀铬钢卷', value: '镀铬钢卷' },
// { label: '镀锌管料带钢', value: '镀锌管料带钢' },
// ],
// materialOptions: [
// { label: 'SPCC', value: 'SPCC' },
// { label: 'DX51D+Z', value: 'DX51D+Z' },
// { label: 'DC01', value: 'DC01' },
// { label: 'DC01-H', value: 'DC01-H' }
// ]
}
},
dicts: ['contract_product_material'],
computed: {
// 计算总数量
totalQuantity() {
@@ -213,6 +216,27 @@ export default {
};
return JSON.stringify(data, null, 2);
},
productMaterialMap() {
const o = {};
this.dict.type.contract_product_material.forEach(item => {
o[item.label] = item.value;
});
return o;
},
productOptions() {
return this.dict.type.contract_product_material.map(item => ({
label: item.label,
value: item.label
}));
},
materialOptions() {
// 先去重
const uniqueMaterials = new Set(this.dict.type.contract_product_material.map(item => item.value));
return Array.from(uniqueMaterials).map(material => ({
label: material,
value: material
}));
}
},
watch: {
// 监听jsonContent变化触发update事件
@@ -258,6 +282,7 @@ export default {
if (item.taxDivisor === undefined || item.taxDivisor === null) {
item.taxDivisor = 1.13;
}
if (item.material === undefined) item.material = '';
if (item.noTaxPrice === undefined) item.noTaxPrice = 0;
if (item.noTaxTotal === undefined) item.noTaxTotal = 0;
if (item.taxAmount === undefined) item.taxAmount = 0;