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

View File

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