|
|
@@ -394,6 +394,15 @@ export default {
|
|
|
this.checkForecastByMonthAndEmit && this.checkForecastByMonthAndEmit()
|
|
|
}
|
|
|
})
|
|
|
+ } else {
|
|
|
+ // 弹窗关闭:编辑态下清空选择,防止跨会话污染
|
|
|
+ if (this.isEdit) {
|
|
|
+ this.selectedRowKeys = []
|
|
|
+ this.selectedStockId = null
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.syncTableSelection && this.syncTableSelection()
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
immediate: true
|
|
|
@@ -668,7 +677,15 @@ export default {
|
|
|
forecastQuantity: Number(item.forecastQuantity || 0)
|
|
|
}))
|
|
|
// 合并接口库存数据以支持回显
|
|
|
- this.mergeEchoStoreInventory && this.mergeEchoStoreInventory().catch(() => {})
|
|
|
+ try {
|
|
|
+ if (this.mergeEchoStoreInventory) {
|
|
|
+ await this.mergeEchoStoreInventory()
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.warn('合并库存回显失败:', e)
|
|
|
+ }
|
|
|
+ // 合并完成后,规范化分页并回显选择(首屏强制回显)
|
|
|
+ this.normalizePageAfterMutations()
|
|
|
} catch (e) {
|
|
|
console.warn('映射详情明细失败:', e)
|
|
|
}
|
|
|
@@ -1227,6 +1244,8 @@ export default {
|
|
|
this.stockTableData = stockList.map(item => ({ ...item, forecastQuantity: 0 }))
|
|
|
// 根据表格中已有的物料,过滤下拉选项
|
|
|
this.updateStockSelectOptions()
|
|
|
+ // 规范化分页并回显选择(新增模式首次加载)
|
|
|
+ this.normalizePageAfterMutations()
|
|
|
} catch (e) {
|
|
|
console.error('加载用户关联商品失败:', e)
|
|
|
this.$message.error(e.message || '加载用户关联商品失败')
|
|
|
@@ -1284,7 +1303,8 @@ export default {
|
|
|
// 导入后更新下拉选项(过滤掉已在表格中的物料)
|
|
|
this.updateStockSelectOptions()
|
|
|
|
|
|
- // 导入后保持当前页不变;无需校正页码(不会超过最大页)
|
|
|
+ // 导入后保持当前页不变;规范化分页以应对边界,并同步选择回显
|
|
|
+ this.normalizePageAfterMutations()
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -1335,7 +1355,7 @@ export default {
|
|
|
// 删除后更新下拉选项(被删除的物料重新回到可选择项)
|
|
|
this.updateStockSelectOptions()
|
|
|
|
|
|
- this.$message && this.$message.success('已删除')
|
|
|
+ // [A] removed toast: deletion success message suppressed by requirement
|
|
|
} catch (e) {
|
|
|
// 用户取消不提示为错误,其他情况做日志记录
|
|
|
if (e && e !== 'cancel') {
|
|
|
@@ -1388,21 +1408,19 @@ export default {
|
|
|
|
|
|
/**
|
|
|
* 行唯一键生成函数(绑定给 :row-key)
|
|
|
+ * 更健壮的容错:依次尝试 id -> goodsId -> itemId -> code -> itemCode -> 组合键(cname/itemName + code/itemCode + brandCode + typeNo/specs)
|
|
|
* @param {import('./types').ForecastFormMixinData['stockTableData'][number]} row
|
|
|
* @returns {string | number}
|
|
|
*/
|
|
|
getRowUniqueKey(row) {
|
|
|
if (!row || typeof row !== 'object') return ''
|
|
|
- // 优先使用后端提供的 id
|
|
|
- if (row.id !== undefined && row.id !== null) return /** @type {any} */ (row.id)
|
|
|
- // 其次使用 goodsId
|
|
|
- if (row.goodsId !== undefined && row.goodsId !== null) return /** @type {any} */ (row.goodsId)
|
|
|
- // 再次使用 code
|
|
|
- if (row.code) return String(row.code)
|
|
|
- // 兜底:用可读信息组合
|
|
|
- const name = /** @type {any} */ (row.cname || '')
|
|
|
- const code = /** @type {any} */ (row.code || '')
|
|
|
- return `${String(name)}-${String(code)}`
|
|
|
+ /** @type {any} */
|
|
|
+ const anyRow = /** @type {any} */ (row)
|
|
|
+ // 简化:仅按 id -> goodsId -> code 顺序
|
|
|
+ if (anyRow.id !== undefined && anyRow.id !== null) return /** @type {any} */ (anyRow.id)
|
|
|
+ if (anyRow.goodsId !== undefined && anyRow.goodsId !== null) return /** @type {any} */ (anyRow.goodsId)
|
|
|
+ if (anyRow.code) return String(anyRow.code)
|
|
|
+ return ''
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -1471,7 +1489,7 @@ export default {
|
|
|
// 刷新下拉选项
|
|
|
this.updateStockSelectOptions()
|
|
|
|
|
|
- this.$message && this.$message.success('已删除所选物料')
|
|
|
+ // [A] removed toast: batch deletion success message suppressed by requirement
|
|
|
} catch (e) {
|
|
|
if (e && e !== 'cancel') {
|
|
|
console.error('批量删除失败:', e)
|
|
|
@@ -1541,6 +1559,12 @@ export default {
|
|
|
this.formData.brandCode = ''
|
|
|
this.formData.brandName = ''
|
|
|
}
|
|
|
+ // 品牌切换后清空选中行,刷新下拉选项并同步表格选择
|
|
|
+ this.selectedRowKeys = []
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.syncTableSelection && this.syncTableSelection()
|
|
|
+ })
|
|
|
+ this.updateStockSelectOptions && this.updateStockSelectOptions()
|
|
|
},
|
|
|
|
|
|
/**
|