固定列更新

master
leo 3 years ago
parent a7b738cd34
commit 443ed7e53a

@ -1,9 +1,8 @@
<template> <template>
<lay-container fluid="true" class="content-box"> <lay-container fluid="true" class="content-box">
<FormulaView :teamId="dataInfoObj.FTeamID" :halfId="dataInfoObj.FMaterialHalfIDs"></FormulaView> <FormulaView :teamId="dataInfoObj.FTeamID" :halfId="dataInfoObj.FMaterialHalfIDs"></FormulaView>
<lay-layer area="90%" v-model="showFreezingColumnSettingBox" title="固定列设置" :end="closeFreezingSetting">
<lay-layer area="90%" v-model="showFreezingColumnSettingBox" title="固定列设置"> <FreezingColumnSetting v-if="showFreezingColumnSettingBox" :columns="originalColumns" :freezingColumns="freezingColumnSetting" @cancelClick="setFreezingColumnsSetting"></FreezingColumnSetting>
<FreezingColumnSetting v-if="showFreezingColumnSettingBox" :columns="tmpDataColumn" :freezingColumns="freezingColumnSetting" @cancelClick="setFreezingColumnsSetting"></FreezingColumnSetting>
</lay-layer> </lay-layer>
<lay-table id="dataTable" v-if="dataColumn.length>0" height="320px" :columns="dataColumn" <lay-table id="dataTable" v-if="dataColumn.length>0" height="320px" :columns="dataColumn"
:data-source="dataList" :cellStyle="cellStyle" :cellClassName="cellClassName"> :data-source="dataList" :cellStyle="cellStyle" :cellClassName="cellClassName">
@ -141,6 +140,7 @@
}; };
const showFreezingColumnSettingBox = ref(false); const showFreezingColumnSettingBox = ref(false);
const freezingColumnSetting = ref([]); const freezingColumnSetting = ref([]);
const originalColumns = ref([]);
const tmpDataColumn = ref([]); const tmpDataColumn = ref([]);
return { return {
dataColumn, dataColumn,
@ -159,6 +159,7 @@
changeVisible2, changeVisible2,
showFreezingColumnSettingBox, showFreezingColumnSettingBox,
freezingColumnSetting, freezingColumnSetting,
originalColumns,
tmpDataColumn tmpDataColumn
}; };
}, },
@ -269,6 +270,7 @@
this.editColumn = editColumn; this.editColumn = editColumn;
this.dataList = _data.rows; this.dataList = _data.rows;
this.dataColumn = dataColumn; this.dataColumn = dataColumn;
this.originalColumns = this.deepCopy(dataColumn);
setTimeout(function() { setTimeout(function() {
layer.close(idx); layer.close(idx);
@ -358,52 +360,42 @@
} }
}, },
_clickFreezingColumnSetting() { _clickFreezingColumnSetting() {
this.tmpDataColumn = this.dataColumn;
this.dataColumn = ref([]); this.dataColumn = ref([]);
this.showFreezingColumnSettingBox = true; this.showFreezingColumnSettingBox = true;
console.log('before', this.tmpDataColumn);
}, },
setFreezingColumns() { setFreezingColumns() {
this.tmpDataColumn = this.deepCopy(this.originalColumns);
let freezingColumns = []; let freezingColumns = [];
if (this.freezingColumnSetting && this.freezingColumnSetting.length > 0) { if (this.freezingColumnSetting && this.freezingColumnSetting.length > 0) {
this.freezingColumnSetting.forEach(column => { this.freezingColumnSetting.forEach(column => {
let colIndex = this.tmpDataColumn.findIndex(d => d.key === column); let colIndex = this.tmpDataColumn.findIndex(d => d.key === column);
if (colIndex >= 0) { if (colIndex >= 0) {
let proxyFc = this.tmpDataColumn.splice(colIndex, 1)[0]; let fc = this.tmpDataColumn.splice(colIndex, 1)[0];
const {proxy, revoke} = Proxy.revocable(proxyFc, {});
const fc = {...proxy};
revoke();
console.log('fc', fc);
if (fc) { if (fc) {
fc.fixed = "left"; fc.fixed = "left";
freezingColumns.push(fc); freezingColumns.push(fc);
} }
} }
}) })
}
if (freezingColumns && freezingColumns.length > 0) { this.dataColumn = freezingColumns.concat(this.tmpDataColumn);
for(let i=freezingColumns.length-1; i>=0; i--) {
this.tmpDataColumn.unshift(freezingColumns[i]);
}
// freezingColumns = freezingColumns.concat(this.tmpDataColumn);
this.dataColumn = this.tmpDataColumn;
console.log('after', this.dataColumn);
} else { } else {
this.dataColumn = this.tmpDataColumn; this.dataColumn = this.tmpDataColumn;
} }
}, },
setFreezingColumnsSetting(fcs) { setFreezingColumnsSetting(fcs) {
this.freezingColumnSetting = fcs;
if (fcs && fcs.length > 0) { if (fcs && fcs.length > 0) {
this.freezingColumnSetting = fcs;
// this.freezingColumnSetting = ["FTestCode", "FMaterialGroup", "FWorkCenter"];
this.setFreezingColumns();
} else { } else {
this.dataColumn = this.tmpDataColumn; this.dataColumn = this.originalColumns;
} }
this.showFreezingColumnSettingBox = false; this.showFreezingColumnSettingBox = false;
},
closeFreezingSetting() {
this.setFreezingColumns();
},
deepCopy(arr) {
return JSON.parse(JSON.stringify(arr))
} }
} }
} }

@ -47,10 +47,10 @@
methods: { methods: {
initPage() { initPage() {
this.columnList = this.columns; this.columnList = this.columns;
this.checkedItem = this.freezingColumns this.checkedItem = this.freezingColumns.concat();
}, },
cancelClick() { cancelClick() {
this.$emit('cancelClick'); this.$emit('cancelClick', this.freezingColumns);
}, },
submitClick() { submitClick() {
this.$emit('cancelClick', this.checkedItem); this.$emit('cancelClick', this.checkedItem);

Loading…
Cancel
Save