|
|
@@ -51,6 +51,33 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
+ <!-- 编码:本行编码 + 所替代的原物品编码,一眼看清替的是哪个物料 -->
|
|
|
+ <template v-slot:productCode="{ row, $index }">
|
|
|
+ <div
|
|
|
+ v-for="(origin, originIndex) in [getOriginInfo(row)]"
|
|
|
+ :key="(origin && origin.id) || 'code-' + $index + '-' + originIndex"
|
|
|
+ class="replace-code-cell"
|
|
|
+ >
|
|
|
+ <span class="code-text" :title="row.productCode">{{
|
|
|
+ row.productCode || '-'
|
|
|
+ }}</span>
|
|
|
+ <el-tooltip v-if="origin" placement="top" effect="dark">
|
|
|
+ <div class="replace-origin-code">
|
|
|
+ <el-tag type="warning" size="mini" effect="dark">替</el-tag>
|
|
|
+ <span class="origin-code-text">{{
|
|
|
+ origin.productCode || '-'
|
|
|
+ }}</span>
|
|
|
+ </div>
|
|
|
+ <div slot="content" class="relation-tip">
|
|
|
+ <div>替原物品名称:{{ origin.productName || '-' }}</div>
|
|
|
+ <div>替原物品编码:{{ origin.productCode || '-' }}</div>
|
|
|
+ <div>规格:{{ origin.specification || '-' }}</div>
|
|
|
+ <div v-if="origin.orderNo">订单编码:{{ origin.orderNo }}</div>
|
|
|
+ </div>
|
|
|
+ </el-tooltip>
|
|
|
+ <span v-else class="relation-empty">未关联</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
<template v-slot:stockLedger="scope">
|
|
|
<el-form-item>
|
|
|
<el-popover
|
|
|
@@ -379,12 +406,23 @@ import tabMixins from '@/mixins/tableColumnsMixin';
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
},
|
|
|
+ // 原产品列表(只读详情场景直接传数组)
|
|
|
+ originList: {
|
|
|
+ type: Array,
|
|
|
+ default: () => []
|
|
|
+ },
|
|
|
+ // 编辑场景下由父组件实时提供物品清单,避免两边数据不同步
|
|
|
+ getOriginList: {
|
|
|
+ type: Function,
|
|
|
+ default: null
|
|
|
+ },
|
|
|
},
|
|
|
components: {
|
|
|
// fileMain,
|
|
|
innertboundDetailsDialog,
|
|
|
stockLedgerDialog
|
|
|
},
|
|
|
+ emits: ['relation-change'],
|
|
|
data() {
|
|
|
const defaultForm = {
|
|
|
key: null,
|
|
|
@@ -490,7 +528,7 @@ import tabMixins from '@/mixins/tableColumnsMixin';
|
|
|
align: 'center'
|
|
|
},
|
|
|
{
|
|
|
- width: 120,
|
|
|
+ width: 190,
|
|
|
prop: 'productCode',
|
|
|
label: '编码',
|
|
|
slot: 'productCode',
|
|
|
@@ -749,6 +787,46 @@ import tabMixins from '@/mixins/tableColumnsMixin';
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 取当前生效的原产品列表:优先实时 getter,其次静态数组
|
|
|
+ resolveOriginRows() {
|
|
|
+ if (typeof this.getOriginList === 'function') {
|
|
|
+ const rows = this.getOriginList();
|
|
|
+ if (Array.isArray(rows)) {
|
|
|
+ return rows;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Array.isArray(this.originList) ? this.originList : [];
|
|
|
+ },
|
|
|
+ // relationId 指向被替代的原产品(新增时是 tempId,回显时是产品 id)
|
|
|
+ getOriginInfo(row) {
|
|
|
+ const relationId = row && row.relationId;
|
|
|
+ if (
|
|
|
+ relationId === undefined ||
|
|
|
+ relationId === null ||
|
|
|
+ relationId === ''
|
|
|
+ ) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ const key = String(relationId);
|
|
|
+ return (
|
|
|
+ this.resolveOriginRows().find((item) => {
|
|
|
+ if (
|
|
|
+ item.id !== undefined &&
|
|
|
+ item.id !== null &&
|
|
|
+ item.id !== '' &&
|
|
|
+ String(item.id) === key
|
|
|
+ ) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ item.tempId !== undefined &&
|
|
|
+ item.tempId !== null &&
|
|
|
+ item.tempId !== '' &&
|
|
|
+ String(item.tempId) === key
|
|
|
+ );
|
|
|
+ }) || null
|
|
|
+ );
|
|
|
+ },
|
|
|
// 子表表头拖拽列宽持久化(scope: sub1)
|
|
|
onSub1HeaderDragend(newWidth, oldWidth, column) {
|
|
|
this.persistScopedColumnWidth(
|
|
|
@@ -1178,15 +1256,18 @@ import tabMixins from '@/mixins/tableColumnsMixin';
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
+ this.$emit('relation-change');
|
|
|
},
|
|
|
|
|
|
remove(i) {
|
|
|
this.form.datasource.splice(i, 1);
|
|
|
this.setSort();
|
|
|
+ this.$emit('relation-change');
|
|
|
},
|
|
|
// 清空表格
|
|
|
restTable() {
|
|
|
this.form.datasource = [];
|
|
|
+ this.$emit('relation-change');
|
|
|
},
|
|
|
// 重新排序
|
|
|
setSort() {
|
|
|
@@ -1253,4 +1334,40 @@ import tabMixins from '@/mixins/tableColumnsMixin';
|
|
|
align-items: center;
|
|
|
font-weight: bold;
|
|
|
}
|
|
|
+
|
|
|
+ .replace-code-cell {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ line-height: 1.5;
|
|
|
+ }
|
|
|
+
|
|
|
+ .code-text {
|
|
|
+ max-width: 100%;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ .replace-origin-code {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ max-width: 100%;
|
|
|
+ margin-top: 2px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .origin-code-text {
|
|
|
+ margin-left: 4px;
|
|
|
+ color: #e6a23c;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ .relation-empty {
|
|
|
+ margin-top: 2px;
|
|
|
+ font-size: 12px;
|
|
|
+ color: #c0c4cc;
|
|
|
+ }
|
|
|
</style>
|