|
@@ -24,7 +24,7 @@
|
|
|
@sort-change="onSortChange"
|
|
@sort-change="onSortChange"
|
|
|
:page-size="pageSize"
|
|
:page-size="pageSize"
|
|
|
@columns-change="handleColumnChange"
|
|
@columns-change="handleColumnChange"
|
|
|
- :cache-key="cacheKeyUrl"
|
|
|
|
|
|
|
+ :cache-key="useNewColumns ? cacheKeyUrl : cacheKeyUrlOld"
|
|
|
>
|
|
>
|
|
|
<template v-slot:approvalStatus="{ row }">
|
|
<template v-slot:approvalStatus="{ row }">
|
|
|
<el-link
|
|
<el-link
|
|
@@ -36,6 +36,12 @@
|
|
|
</el-link>
|
|
</el-link>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
|
|
+ <!-- 序号:前端自己渲染行号 -->
|
|
|
|
|
+ <template v-slot:rowIndex="{ $index }">{{ $index + 1 }}</template>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 总重:前端按 用量 × 单重 计算(用量/单重改了立即跟着变) -->
|
|
|
|
|
+ <template v-slot:totalWeight="{ row }">{{ totalWeightOf(row) }}</template>
|
|
|
|
|
+
|
|
|
<template v-slot:code="{ row }">
|
|
<template v-slot:code="{ row }">
|
|
|
<el-link
|
|
<el-link
|
|
|
type="primary"
|
|
type="primary"
|
|
@@ -46,8 +52,8 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot:versions="{ row }">
|
|
<template v-slot:versions="{ row }">
|
|
|
|
|
+ <!-- 版本为空就留空,不显示"无" -->
|
|
|
<template v-if="row.versions">V{{ row.versions }}.0</template>
|
|
<template v-if="row.versions">V{{ row.versions }}.0</template>
|
|
|
- <template v-else>无</template>
|
|
|
|
|
</template>
|
|
</template>
|
|
|
<template v-slot:isTemp="{ row }">
|
|
<template v-slot:isTemp="{ row }">
|
|
|
<el-tag size="mini" v-if="row.isTemp == 1">主数据</el-tag>
|
|
<el-tag size="mini" v-if="row.isTemp == 1">主数据</el-tag>
|
|
@@ -339,24 +345,29 @@
|
|
|
width: 100
|
|
width: 100
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- prop: 'sn',
|
|
|
|
|
- label: '明细表序号',
|
|
|
|
|
|
|
+ // 序号:普通列 + 前端插槽渲染行号(见模板 v-slot:rowIndex)
|
|
|
|
|
+ // 不能用 type: 'index':index 列不在列设置缓存里,ele-pro-table(columnsSort 默认 true)
|
|
|
|
|
+ // 会把找不到缓存位置的列排到最前面,所以它永远显示在第一列。
|
|
|
|
|
+ prop: 'rowIndex',
|
|
|
|
|
+ columnKey: 'rowIndex',
|
|
|
|
|
+ label: '序号',
|
|
|
|
|
+ width: 90,
|
|
|
align: 'center',
|
|
align: 'center',
|
|
|
- width: 120,
|
|
|
|
|
- showOverflowTooltip: true
|
|
|
|
|
|
|
+ showOverflowTooltip: true,
|
|
|
|
|
+ slot: 'rowIndex'
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
prop: 'code',
|
|
prop: 'code',
|
|
|
label: '物料编码',
|
|
label: '物料编码',
|
|
|
slot: 'code',
|
|
slot: 'code',
|
|
|
showOverflowTooltip: true,
|
|
showOverflowTooltip: true,
|
|
|
- width: 120
|
|
|
|
|
|
|
+ width: 180
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
prop: 'imgCode',
|
|
prop: 'imgCode',
|
|
|
label: '零部件图号(规格型号)',
|
|
label: '零部件图号(规格型号)',
|
|
|
showOverflowTooltip: true,
|
|
showOverflowTooltip: true,
|
|
|
- width: 150
|
|
|
|
|
|
|
+ width: 120
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
prop: 'versions',
|
|
prop: 'versions',
|
|
@@ -408,6 +419,7 @@
|
|
|
{
|
|
{
|
|
|
prop: 'totalWeight',
|
|
prop: 'totalWeight',
|
|
|
label: '总重',
|
|
label: '总重',
|
|
|
|
|
+ slot: 'totalWeight',
|
|
|
showOverflowTooltip: true,
|
|
showOverflowTooltip: true,
|
|
|
align: 'right',
|
|
align: 'right',
|
|
|
width: 100
|
|
width: 100
|
|
@@ -552,7 +564,10 @@
|
|
|
radioSubmit: 1,
|
|
radioSubmit: 1,
|
|
|
currentNodeData: {},
|
|
currentNodeData: {},
|
|
|
pageSize: this.$store.state.tablePageSize,
|
|
pageSize: this.$store.state.tablePageSize,
|
|
|
- cacheKeyUrl: '68be265a-material-BOMmanage',
|
|
|
|
|
|
|
+ // 序号列由 type:index 改成 rowIndex 数据列,换 key 清一次列设置缓存
|
|
|
|
|
+ // (ele-pro-table 按列 key 从 localStorage 恢复列顺序,新列不在旧缓存里会被排到最前)
|
|
|
|
|
+ cacheKeyUrl: '68be265a-material-BOMmanage-v3',
|
|
|
|
|
+ cacheKeyUrlOld: '68be265a-material-BOMmanage-old-v1',
|
|
|
isUpload: true
|
|
isUpload: true
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
@@ -610,8 +625,55 @@
|
|
|
this.getDictList('productionType');
|
|
this.getDictList('productionType');
|
|
|
this.getAttriButeList('inventory_type');
|
|
this.getAttriButeList('inventory_type');
|
|
|
this.getRuntianConfig();
|
|
this.getRuntianConfig();
|
|
|
|
|
+ // 新老两套列方案各有自己的列设置缓存,打开页面时自愈一次
|
|
|
|
|
+ this.healColumnsCache(this.cacheKeyUrlOld, this.oldColumnsConfig);
|
|
|
|
|
+ this.healColumnsCache(this.cacheKeyUrl, this.newColumnsConfig);
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ // 总重 = 单台用量 × 单重(前端计算)
|
|
|
|
|
+ totalWeightOf(row) {
|
|
|
|
|
+ const toNumber = (v) =>
|
|
|
|
|
+ v === null || v === undefined || v === '' ? null : Number(v);
|
|
|
|
|
+ const dosage = toNumber(row && row.dosage);
|
|
|
|
|
+ const netWeight = toNumber(row && row.netWeight);
|
|
|
|
|
+ if (dosage === null || netWeight === null) {
|
|
|
|
|
+ return '';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isNaN(dosage) || isNaN(netWeight)) {
|
|
|
|
|
+ return '';
|
|
|
|
|
+ }
|
|
|
|
|
+ return (dosage * netWeight).toFixed(2);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // ele-pro-table 的列顺序是按 localStorage 里的列缓存恢复的:配置里新增/删除列之后,
|
|
|
|
|
+ // 旧缓存里没有新列 → 新列会被排到第一列(表现为“序号跑到第一列,点列重置才恢复”)。
|
|
|
|
|
+ // 这里做一次自愈:缓存的列集合与当前配置不一致就清掉,让列顺序回到配置顺序。
|
|
|
|
|
+ healColumnsCache(cacheKey, columns) {
|
|
|
|
|
+ const key = cacheKey + 'Cols';
|
|
|
|
|
+ try {
|
|
|
|
|
+ const raw = localStorage.getItem(key);
|
|
|
|
|
+ if (!raw) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const cached = JSON.parse(raw);
|
|
|
|
|
+ if (!Array.isArray(cached) || !cached.length) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const wanted = (columns || [])
|
|
|
|
|
+ .filter((c) => c && c.type !== 'index' && c.columnKey !== 'index')
|
|
|
|
|
+ .map((c) => c.columnKey || c.prop)
|
|
|
|
|
+ .filter((k) => !!k);
|
|
|
|
|
+ const cachedKeys = cached.map((c) => c.id);
|
|
|
|
|
+ // 只判断“配置里有、缓存里没有”的列(这类列才会被 ele-pro-table 排到第一列);
|
|
|
|
|
+ // 缓存里多出来的列(比如操作列)不用管。
|
|
|
|
|
+ const missing = wanted.filter((k) => !cachedKeys.includes(k));
|
|
|
|
|
+ if (missing.length) {
|
|
|
|
|
+ localStorage.removeItem(key);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ localStorage.removeItem(key);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
attributeTypeText(v) {
|
|
attributeTypeText(v) {
|
|
|
if (v) {
|
|
if (v) {
|
|
|
let a = this.attributeList.find((item) => item.value == v);
|
|
let a = this.attributeList.find((item) => item.value == v);
|