|
|
@ -216,6 +216,7 @@ |
|
|
:height="trackingTableHeight" |
|
|
:height="trackingTableHeight" |
|
|
v-loading="dataListLoading" |
|
|
v-loading="dataListLoading" |
|
|
@sort-change="handleTrackingTableSortChange" |
|
|
@sort-change="handleTrackingTableSortChange" |
|
|
|
|
|
@header-dragend="handleTrackingColumnResize" |
|
|
@selection-change="selectionChange" |
|
|
@selection-change="selectionChange" |
|
|
@row-click="rowClick" |
|
|
@row-click="rowClick" |
|
|
style="width: 100%; margin-top: 8px" |
|
|
style="width: 100%; margin-top: 8px" |
|
|
@ -1275,7 +1276,7 @@ import { |
|
|
searchBusinessInfo8 |
|
|
searchBusinessInfo8 |
|
|
} from '@/api/factory/site.js' |
|
|
} from '@/api/factory/site.js' |
|
|
import { queryCustomerList } from '@/api/customer/customer' |
|
|
import { queryCustomerList } from '@/api/customer/customer' |
|
|
import { getTableUserListLanguage } from '@/api/table.js' |
|
|
|
|
|
|
|
|
import { getTableUserListLanguage, updateColumnSize, saveTableUser } from '@/api/table.js' |
|
|
import Chooselist from '@/views/modules/common/Chooselist_eam' |
|
|
import Chooselist from '@/views/modules/common/Chooselist_eam' |
|
|
import Sortable from 'sortablejs' |
|
|
import Sortable from 'sortablejs' |
|
|
|
|
|
|
|
|
@ -1710,6 +1711,8 @@ export default { |
|
|
searchProjectManagerOptions: [], |
|
|
searchProjectManagerOptions: [], |
|
|
searchPicOptions: [], |
|
|
searchPicOptions: [], |
|
|
trackingColumnList: cloneDefaultTrackingColumns(), |
|
|
trackingColumnList: cloneDefaultTrackingColumns(), |
|
|
|
|
|
trackingColumnsLoaded: false, |
|
|
|
|
|
trackingColumnsPersisted: false, |
|
|
processColumns: cloneDefaultProcessColumns(), |
|
|
processColumns: cloneDefaultProcessColumns(), |
|
|
processCodeLabelMap: buildProcessCodeLabelMapByRows(cloneDefaultProcessColumns()), |
|
|
processCodeLabelMap: buildProcessCodeLabelMapByRows(cloneDefaultProcessColumns()), |
|
|
trackingTableSortProp: '', |
|
|
trackingTableSortProp: '', |
|
|
@ -2086,6 +2089,7 @@ export default { |
|
|
return mergedRows |
|
|
return mergedRows |
|
|
}, |
|
|
}, |
|
|
loadTrackingColumns () { |
|
|
loadTrackingColumns () { |
|
|
|
|
|
this.trackingColumnsLoaded = false |
|
|
const queryTableUser = { |
|
|
const queryTableUser = { |
|
|
userId: this.$store.state.user.name, |
|
|
userId: this.$store.state.user.name, |
|
|
functionId: this.getTrackingColumnFunctionId(), |
|
|
functionId: this.getTrackingColumnFunctionId(), |
|
|
@ -2093,7 +2097,12 @@ export default { |
|
|
languageCode: this.$i18n && this.$i18n.locale ? this.$i18n.locale : '' |
|
|
languageCode: this.$i18n && this.$i18n.locale ? this.$i18n.locale : '' |
|
|
} |
|
|
} |
|
|
return getTableUserListLanguage(queryTableUser).then(({ data }) => { |
|
|
return getTableUserListLanguage(queryTableUser).then(({ data }) => { |
|
|
const rows = data && Array.isArray(data.rows) ? data.rows : [] |
|
|
|
|
|
|
|
|
if (!data || data.code !== 0 || !Array.isArray(data.rows)) { |
|
|
|
|
|
throw new Error('加载用户动态列失败') |
|
|
|
|
|
} |
|
|
|
|
|
const rows = data.rows |
|
|
|
|
|
this.trackingColumnsLoaded = true |
|
|
|
|
|
this.trackingColumnsPersisted = rows.length > 0 |
|
|
// 不按 status 过滤:隐藏列也要读回来,才能按用户设置真正不展示。 |
|
|
// 不按 status 过滤:隐藏列也要读回来,才能按用户设置真正不展示。 |
|
|
// 用户完全没有动态列配置时,才回退到本页代码里的默认列。 |
|
|
// 用户完全没有动态列配置时,才回退到本页代码里的默认列。 |
|
|
this.trackingColumnList = rows.length > 0 |
|
|
this.trackingColumnList = rows.length > 0 |
|
|
@ -2107,6 +2116,48 @@ export default { |
|
|
return this.trackingColumnList |
|
|
return this.trackingColumnList |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
handleTrackingColumnResize (newWidth, oldWidth, column) { |
|
|
|
|
|
// 工序、Comments、操作等非用户动态列不调用此配置接口。 |
|
|
|
|
|
const item = column && this.trackingColumnList.find(row => row.columnProp === column.property) |
|
|
|
|
|
const width = Math.round(Number(newWidth)) |
|
|
|
|
|
if (!item || !Number.isFinite(width) || width <= 0 || newWidth === oldWidth) { |
|
|
|
|
|
return Promise.resolve() |
|
|
|
|
|
} |
|
|
|
|
|
const userId = this.$store.state.user.name |
|
|
|
|
|
const functionId = this.getTrackingColumnFunctionId() |
|
|
|
|
|
const tableId = this.getTrackingColumnTableId() |
|
|
|
|
|
if (!this.trackingColumnsLoaded || this.isBlankValue(userId) || this.isBlankValue(functionId) || this.isBlankValue(tableId)) { |
|
|
|
|
|
this.$message.warning('动态列配置尚未加载成功,列宽未保存,请刷新后重试') |
|
|
|
|
|
return Promise.resolve() |
|
|
|
|
|
} |
|
|
|
|
|
this.$set(item, 'columnWidth', width) |
|
|
|
|
|
// 仅提交身份字段和宽度,避免覆盖显隐、顺序、固定位置等其他用户配置。 |
|
|
|
|
|
const payload = { userId, functionId, tableId, columnProp: item.columnProp, columnWidth: width } |
|
|
|
|
|
// 串行保存,连续拖动时最后一次宽度不会被先发后到的请求覆盖。 |
|
|
|
|
|
const queue = this._trackingColumnWidthSaveQueue || Promise.resolve() |
|
|
|
|
|
this._trackingColumnWidthSaveQueue = queue.then(async () => { |
|
|
|
|
|
let response |
|
|
|
|
|
if (!this.trackingColumnsPersisted) { |
|
|
|
|
|
// 后端没有默认列配置时,本页使用代码默认列;首次拖动初始化整组,不能只写一列。 |
|
|
|
|
|
const columns = this.trackingColumnList.map((row, index) => Object.assign({}, row, { |
|
|
|
|
|
userId, |
|
|
|
|
|
functionId, |
|
|
|
|
|
tableId, |
|
|
|
|
|
sortLv: row.sortLv == null ? index + 1 : row.sortLv |
|
|
|
|
|
})) |
|
|
|
|
|
response = await saveTableUser(columns) |
|
|
|
|
|
} else { |
|
|
|
|
|
response = await updateColumnSize(payload) |
|
|
|
|
|
} |
|
|
|
|
|
if (!response || !response.data || response.data.code !== 0) { |
|
|
|
|
|
throw new Error('列宽保存失败') |
|
|
|
|
|
} |
|
|
|
|
|
this.trackingColumnsPersisted = true |
|
|
|
|
|
}).catch(() => { |
|
|
|
|
|
this.$message.warning('列宽保存失败,当前宽度仅临时生效,请重新拖动以重试') |
|
|
|
|
|
}) |
|
|
|
|
|
return this._trackingColumnWidthSaveQueue |
|
|
|
|
|
}, |
|
|
isTrackingColumnVisible (column) { |
|
|
isTrackingColumnVisible (column) { |
|
|
if (!column) { |
|
|
if (!column) { |
|
|
return false |
|
|
return false |
|
|
|