|
@@ -1,6 +1,12 @@
|
|
|
<template>
|
|
<template>
|
|
|
<el-form ref="form" :model="form" :rules="rules">
|
|
<el-form ref="form" :model="form" :rules="rules">
|
|
|
- <div v-table-scroll-sync class="table-container">
|
|
|
|
|
|
|
+ <!-- 物品清单列多、横向滚动频繁,这里不用 v-table-scroll-sync:
|
|
|
|
|
+ 那个指令会把 .el-table__body-wrapper 的 overflow-x 设成 hidden,
|
|
|
|
|
+ 再在表格下方另插一条 12px 独立滚动条来代理。弹窗在小屏幕/内容多时
|
|
|
|
|
+ 这条代理滚动条会落到可视区之外,表格内又没有原生横向滚动条,
|
|
|
|
|
+ 结果就是横向彻底滚不动;同时 shift+滚轮也失效。
|
|
|
|
|
+ 用 el-table 原生横向滚动条,滚动条始终跟着表格底部,表头也会跟随 bodyWrapper。 -->
|
|
|
|
|
+ <div class="table-container">
|
|
|
<ele-pro-table
|
|
<ele-pro-table
|
|
|
ref="table"
|
|
ref="table"
|
|
|
:needPage="false"
|
|
:needPage="false"
|
|
@@ -1250,10 +1256,96 @@
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ // 合计行被裁一半的修复:Element 对 show-summary 的合计行是 v-show
|
|
|
|
|
+ // (data 为空时 display:none),表格初次布局时 footerWrapper 量出来
|
|
|
|
|
+ // 高度是 0,bodyHeight = 固定350 - 表头 - 0,body 把容器占满;之后
|
|
|
|
|
+ // 数据到了合计行显示出来,但 Element 不会再自动重算,合计行就被
|
|
|
|
|
+ // overflow:hidden 的表格容器裁掉。行数变化后强制重排一次,把合计
|
|
|
|
|
+ // 行高度扣回 bodyHeight。
|
|
|
|
|
+ 'form.datasource.length'() {
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ const table = this.$refs.table;
|
|
|
|
|
+ if (table && table.doLayout) {
|
|
|
|
|
+ table.doLayout();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ // 动态扩展列(电压/批准文号/强安等)到达后补齐列设置缓存:
|
|
|
|
|
+ // ele-admin 的列设置面板(getSettingCols)在 localStorage 里存在
|
|
|
|
|
+ // cacheKey+'Cols' 缓存时直接以缓存为准,而这份缓存由 tableColumnsMixin
|
|
|
|
|
+ // 在服务端列配置接口返回时写入——那次合并时动态列接口往往还没返回,
|
|
|
|
|
+ // 缓存里就永远缺动态列 → 表头有这些列、列设置面板里却没有。
|
|
|
|
|
+ // 这里把缓存里缺的动态列补进去(checked=true),并同步服务端,
|
|
|
|
|
+ // 防止下次进来又被服务端旧配置覆盖。
|
|
|
|
|
+ dynamicsColumns(cols) {
|
|
|
|
|
+ this.syncColumnsSettingCache(cols);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
mounted() {
|
|
mounted() {
|
|
|
- // this.clientEnvironmentId =
|
|
|
|
|
|
|
+ // 该物品类型可能没有任何动态字段(dynamicsColumns 一直是空数组、
|
|
|
|
|
+ // watch 永不触发),此时也要兜底把缓存里卡在中间的操作列归位到最后
|
|
|
|
|
+ this.syncColumnsSettingCache(this.dynamicsColumns);
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ // 覆写 mixin 的 getTabColumns:服务端列配置写入缓存后,动态列可能
|
|
|
|
|
+ // 尚未到达、且服务端旧清单里操作列可能卡在中间——这里统一再归位一次
|
|
|
|
|
+ //(dynamicsColumns 到达时 watch 也会兜一次,两者谁后到都以这次为准)
|
|
|
|
|
+ async getTabColumns() {
|
|
|
|
|
+ await tabMixins.methods.getTabColumns.call(this);
|
|
|
|
|
+ this.syncColumnsSettingCache(this.dynamicsColumns);
|
|
|
|
|
+ },
|
|
|
|
|
+ // 补齐/修正列设置缓存:动态列补入 + 操作列归位到末尾,并同步服务端
|
|
|
|
|
+ syncColumnsSettingCache(cols) {
|
|
|
|
|
+ if (!this.cacheKeyUrl) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ const storageKey = this.cacheKeyUrl + 'Cols';
|
|
|
|
|
+ const cached = this.getStorage(storageKey) || [];
|
|
|
|
|
+ const knownKeys = new Set(
|
|
|
|
|
+ cached.map((c) => c.columnKey || c.prop || c.id)
|
|
|
|
|
+ );
|
|
|
|
|
+ let added = false;
|
|
|
|
|
+ (cols || []).forEach((col) => {
|
|
|
|
|
+ const key = col.prop || col.columnKey;
|
|
|
|
|
+ if (key && !knownKeys.has(key)) {
|
|
|
|
|
+ cached.push({
|
|
|
|
|
+ id: key,
|
|
|
|
|
+ prop: col.prop,
|
|
|
|
|
+ columnKey: col.columnKey,
|
|
|
|
|
+ label: col.label,
|
|
|
|
|
+ checked: true,
|
|
|
|
|
+ minWidth: col.minWidth
|
|
|
|
|
+ });
|
|
|
|
|
+ added = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ // 操作列固定在最右侧,列设置面板里也应排在最后:
|
|
|
|
|
+ // 缓存顺序继承自服务端旧列清单,操作列可能卡在中间,这里统一归位
|
|
|
|
|
+ const actionIdx = cached.findIndex(
|
|
|
|
|
+ (c) => (c.columnKey || c.prop) === 'action' || c.label === '操作'
|
|
|
|
|
+ );
|
|
|
|
|
+ let moved = false;
|
|
|
|
|
+ if (actionIdx !== -1 && actionIdx !== cached.length - 1) {
|
|
|
|
|
+ const [action] = cached.splice(actionIdx, 1);
|
|
|
|
|
+ cached.push(action);
|
|
|
|
|
+ moved = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (added || moved) {
|
|
|
|
|
+ this.setStorage(storageKey, cached);
|
|
|
|
|
+ // 同步服务端列配置(复用 mixin 的防抖保存),避免下次进入时
|
|
|
|
|
+ // 服务端旧配置先到又把缓存覆盖回去
|
|
|
|
|
+ if (this.debouncedSaveColumns) {
|
|
|
|
|
+ this.debouncedSaveColumns(cached);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.saveColumns(cached);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.warn('[inventoryTable] 补齐动态列设置缓存失败:', e);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
formatPrice,
|
|
formatPrice,
|
|
|
isSaleOrderLockReadonly(row) {
|
|
isSaleOrderLockReadonly(row) {
|
|
|
if (row.hasSendRejectedOrWithdrawn == 1) {
|
|
if (row.hasSendRejectedOrWithdrawn == 1) {
|