update 产线平衡分析

This commit is contained in:
lb 2023-11-28 19:31:08 +08:00
parent 978291e68a
commit c0daa74a84
2 changed files with 63 additions and 39 deletions

View File

@ -11,10 +11,9 @@
@tab-click="handleTabClick"
style="height: 100%">
<el-tab-pane :label="'\u2002数据列表\u2002'" name="table">
<!-- @emitFun="handleEmitFun"> -->
<base-table
v-if="activeName == 'table'"
:span-method="mergeColumnHandler"
v-if="activeName == 'table' && ready"
:span-method="mergeRow"
:page="1"
:limit="999"
:table-props="tableProps"
@ -32,10 +31,6 @@
</div>
</el-tab-pane>
</el-tabs>
<!-- <SearchBar :formConfigs="[{ label: '产线平衡分析图', type: 'title' }]" /> -->
<!-- </div>
<div v-else class="no-data-bg"></div> -->
</div>
</template>
@ -98,6 +93,11 @@ export default {
startTime: null,
endTime: null,
},
sectionMap: {},
lastSection: null,
currRowIndex: 0,
spanArr: [],
ready: false,
};
},
@ -156,8 +156,11 @@ export default {
const { data, nameData } = await this.getCT();
await this.buildProps(nameData);
await this.buildTableData(data);
const xxxx = this.tableData;
debugger;
this.tableData = this.tableData.sort((a, b) => {
if (a.sectionName < b.sectionName) return 1;
return -1;
});
this.ready = true;
},
buildProps(nameData) {
@ -208,38 +211,60 @@ export default {
},
async buildTableData(data) {
/** 处理 工段 分组 */
const sectionList = data.map((item) => {});
},
const sectionArr = Array.from(
new Set(data.map((item) => item.sectionName))
).sort();
this.sectionMap = sectionArr.reduce(
(sum, curr) => ({ ...sum, [curr]: 0 }),
{}
);
this.spanArr = Array.from(sectionArr, () => 0);
setRowSpan(arr) {
let count = 0;
arr.forEach((item, index) => {
if (index === 0) {
this.spanArr.push(1);
} else {
if (item === arr[index - 1]) {
this.spanArr[count] += 1;
this.spanArr.push(0);
} else {
count = index;
this.spanArr.push(1);
}
return new Promise((resolve, reject) => {
/** 处理 工段 分组 */
data.map((item) => {
this.sectionMap[item.sectionName]++;
/** 处理 设备 */
const row = {
equName: item.equName,
sectionName: item.sectionName,
};
item.data.forEach((eq) => {
const date = eq.dynamicName;
eq.children.forEach((sub) => {
if (sub.dynamicName == '设备CT')
row[date + '_eq_ct'] = sub.dynamicValue;
if (sub.dynamicName == '设备TT')
row[date + '_eq_tt'] = sub.dynamicValue;
if (sub.dynamicName == '产线CT')
row[date + '_pl_ct'] = sub.dynamicValue;
if (sub.dynamicName == '产线TT')
row[date + '_pl_tt'] = sub.dynamicValue;
});
});
this.tableData.push(row);
});
/** 生成span数组 */
const tmp = [0];
for (const [index, key] of sectionArr.entries()) {
tmp[index + 1] = tmp[index] + this.sectionMap[key];
}
console.log('tep', tmp);
this.spanArr = tmp;
resolve();
});
},
/** 合并table列的规则 */
mergeColumnHandler({ row, column, rowIndex, columnIndex }) {
if (columnIndex == 0) {
if (this.spanArr[rowIndex]) {
return [
this.spanArr[rowIndex], // row span
1, // col span
];
} else {
return [0, 0];
mergeRow({ row, column, rowIndex, columnIndex }) {
if (columnIndex == 1) {
const span = this.sectionMap[row.sectionName];
if (this.spanArr.includes(rowIndex)) {
console.log('span...');
return [span, 1];
}
return [0, 0];
}
},
@ -319,6 +344,7 @@ export default {
// this.dataListLoading = false;
});
},
handleSearchBarBtnClick(btn) {
switch (btn.btnName) {
case 'search':

View File

@ -33,7 +33,7 @@
:data-value="fc.id"
class="factory-list__item"
:class="{ 'is-current': fc.id == currentFactory?.id }">
<span>
<span :data-value="fc.id">
{{ fc.label }}
</span>
<svg-icon
@ -98,9 +98,7 @@
</base-table>
</el-tab-pane>
<el-tab-pane :label="'\u3000柱状图\u3000'" name="graph">
<div
class="graph"
style="height: 100%;">
<div class="graph" style="height: 100%">
<!-- graph -->
<Graph
v-if="list.length"