|
|
@@ -33,21 +33,23 @@
|
|
|
<el-main>
|
|
|
<div class="gva-table-box">
|
|
|
<!-- 表格数据 -->
|
|
|
- <!-- 非JP机台 -->
|
|
|
<el-table ref="multipleTable"
|
|
|
v-if="! ismachine"
|
|
|
:show-overflow-tooltip="true"
|
|
|
@selection-change="selectionChange($event)"
|
|
|
:row-style="{ height: '20px' }" :selectable="checkboxT"
|
|
|
:cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
|
|
|
- :header-cell-style="{ padding: '0px' }" @row-click="getUid"
|
|
|
- highlight-current-row="true" @row-dblclick="gytableDatadoubleClick"
|
|
|
- style="width: 100%;height: 30vh" border tooltip-effect="dark" :data="gytableData" row-key="ID" >
|
|
|
- <el-table-column type="selection" width="55" />
|
|
|
+ :header-cell-style="{ padding: '0px' }" @row-click="pchzRowClick"
|
|
|
+ highlight-current-row="true" @row-dblclick="gytableDatadoubleClick" id="pchztable"
|
|
|
+ style="width: 100%;height: 30vh" border tooltip-effect="dark" :data="pchztableData" row-key="ID" >
|
|
|
<el-table-column fixed align="left" label="机台编号" prop="机台编号" width="300"/>
|
|
|
<el-table-column fixed align="left" label="机台名称" prop="机台名称" width="170"/>
|
|
|
<el-table-column fixed align="left" label="班组" prop="班组" width="100"/>
|
|
|
<el-table-column align="left" label="近7天综合达成率" prop="近7天综合达成率" width="85"/>
|
|
|
+ <!-- 近七天列表 -->
|
|
|
+ <template v-for="item in datelist">
|
|
|
+ <el-table-column align="left" sortable :label="item.display" :prop="item.prop" width="80"/>
|
|
|
+ </template>
|
|
|
<el-table-column align="left" label="实际总产量" prop="实际总产量" width="85"/>
|
|
|
<el-table-column align="left" label="排产总产量" prop="排产总产量" width="80"/>
|
|
|
<el-table-column align="left" label="实际产量1" prop="实际产量1" width="85"/>
|
|
|
@@ -73,11 +75,10 @@
|
|
|
:row-style="{ height: '20px' }" :row-class-name="totalClassName" :cell-class-name="tableDataCellClass"
|
|
|
:cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
|
|
|
:header-cell-style="{ padding: '0px' }" @row-click="getUid"
|
|
|
- highlight-current-row="true" @row-dblclick="JPgytableDatadoubleClick"
|
|
|
- style="width: 100%;height: 45vh" border tooltip-effect="dark" :data="JPgytableData" row-key="ID" >
|
|
|
- <el-table-column type="selection" width="55" />
|
|
|
+ highlight-current-row="true" @row-dblclick="JPgytableDatadoubleClick" id="pcmxtable"
|
|
|
+ style="width: 100%;height: 45vh" border tooltip-effect="dark" :data="pcmxtableData" row-key="ID" >
|
|
|
<el-table-column align="left" fixed label="日期" prop="日期" 机台编号="300"/>
|
|
|
- <el-table-column align="left" fixed label="机台编号" prop="工序" width="150"/>
|
|
|
+ <el-table-column align="left" fixed label="机台编号" prop="机台编号" width="150"/>
|
|
|
<el-table-column align="left" fixed label="班组" prop="班组" width="70"/>
|
|
|
<el-table-column align="left" label="工单编号" prop="工单编号" width="90"/>
|
|
|
<el-table-column align="left" label="印件号" prop="印件号" width="90"/>
|
|
|
@@ -104,10 +105,9 @@
|
|
|
@selection-change="selectionChange($event)"
|
|
|
:row-style="{ height: '20px' }" :selectable="checkboxT"
|
|
|
:cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
|
|
|
- :header-cell-style="{ padding: '0px' }" @row-click="getUid"
|
|
|
- highlight-current-row="true" @row-dblclick="gytableDatadoubleClick"
|
|
|
- style="width: 100%;height: 30vh" border tooltip-effect="dark" :data="gytableData" row-key="ID" >
|
|
|
- <el-table-column type="selection" width="55" />
|
|
|
+ :header-cell-style="{ padding: '0px' }" @row-click="sbhzRowClick"
|
|
|
+ highlight-current-row="true" @row-dblclick="gytableDatadoubleClick" id="sbhztable"
|
|
|
+ style="width: 100%;height: 30vh" border tooltip-effect="dark" :data="sbhztableData" row-key="ID" >
|
|
|
<el-table-column fixed align="left" label="机台编号" prop="机台编号" width="300"/>
|
|
|
<el-table-column fixed align="left" label="班组" prop="班组" width="100"/>
|
|
|
<el-table-column align="left" label="实际产量" prop="实际产量" width="85"/>
|
|
|
@@ -126,16 +126,14 @@
|
|
|
</el-table>
|
|
|
|
|
|
<el-table ref="JPmultipleTable"
|
|
|
- v-else
|
|
|
:show-overflow-tooltip="true"
|
|
|
@selection-change="selectionChange($event)"
|
|
|
:row-style="{ height: '20px' }" :row-class-name="totalClassName" :cell-class-name="tableDataCellClass"
|
|
|
:cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
|
|
|
:header-cell-style="{ padding: '0px' }" @row-click="getUid"
|
|
|
- highlight-current-row="true" @row-dblclick="JPgytableDatadoubleClick"
|
|
|
- style="width: 100%;height: 45vh" border tooltip-effect="dark" :data="JPgytableData" row-key="ID" >
|
|
|
- <el-table-column type="selection" width="55" />
|
|
|
- <el-table-column align="left" fixed label="机台编号" prop="工序" width="150"/>
|
|
|
+ highlight-current-row="true" @row-dblclick="JPgytableDatadoubleClick" id="sbmxtable"
|
|
|
+ style="width: 100%;height: 45vh" border tooltip-effect="dark" :data="sbmxtableData" row-key="ID" >
|
|
|
+ <el-table-column align="left" fixed label="机台编号" prop="机台编号" width="150"/>
|
|
|
<el-table-column align="left" fixed label="日期" prop="日期" 机台编号="300"/>
|
|
|
<el-table-column align="left" fixed label="班组" prop="班组" width="70"/>
|
|
|
<el-table-column align="left" label="工单编号" prop="工单编号" width="90"/>
|
|
|
@@ -175,14 +173,14 @@
|
|
|
<script setup>
|
|
|
// 全量引入格式化工具 请按需保留
|
|
|
import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
|
|
|
- import {PARLeftmenu,} from "@/api/mes/job.js"
|
|
|
+ import {PARLeftmenu,PARlist,PARDetail,PARlistpro,PARDetailpro} from "@/api/mes/job.js"
|
|
|
import {ref, reactive} from 'vue'
|
|
|
import * as XLSX from 'xlsx'
|
|
|
import { exportExcelFile } from '@/utils/excel'
|
|
|
import {ElMessage} from "element-plus";
|
|
|
defineOptions({name: 'Company'})
|
|
|
|
|
|
- const treeData = ref([]); // 响应式数据
|
|
|
+ const treeData = ref([]);
|
|
|
const defaultProps = {
|
|
|
label: 'label',
|
|
|
children: 'children'
|
|
|
@@ -242,6 +240,7 @@ const getTreeData = async () => {
|
|
|
.filter(dept => dept) // 过滤空部门
|
|
|
.map(dept => ({
|
|
|
label: dept.trim() || '未知部门',
|
|
|
+ rq: monthKey, // 添加月份键值
|
|
|
}))
|
|
|
};
|
|
|
yearNode.children.push(monthNode);
|
|
|
@@ -263,11 +262,39 @@ const getTreeData = async () => {
|
|
|
// 初始化加载数据
|
|
|
getTreeData();
|
|
|
|
|
|
+const ismachine = ref(false)
|
|
|
+const datelist = ref([]);
|
|
|
+const pchztableData = ref([]);
|
|
|
+const pcmxtableData = ref([]);
|
|
|
+const sbhztableData = ref([]);
|
|
|
+const sbmxtableData = ref([]);
|
|
|
// 节点点击事件处理
|
|
|
-const handleNodeClick = (nodeData) => {
|
|
|
+const handleNodeClick = async (nodeData) => {
|
|
|
console.log('节点点击:', nodeData)
|
|
|
- // 根据节点数据加载对应的内容
|
|
|
- // 可以在这里添加加载对应数据的逻辑
|
|
|
+ if(!nodeData.children){
|
|
|
+ console.log('点击了车间')
|
|
|
+ //根据是否有rq判断点击的是排产还是设备
|
|
|
+ if(!nodeData.rq){
|
|
|
+ ismachine.value = false;
|
|
|
+ const response = await PARlist({Machine:nodeData.label});
|
|
|
+ // 创建日期映射表
|
|
|
+ const dateMap = response.data.list.map(fullDate => {
|
|
|
+ const [year, month, day] = fullDate.split('-');
|
|
|
+ const shortKey = `${month.padStart(2, '0')}-${day.padStart(2, '0')}`; // 显示用 05-08
|
|
|
+ const longKey = `${month.padStart(2, '0')}月${day.padStart(2, '0')}日`; // 数据键 05月08日
|
|
|
+ return {
|
|
|
+ display: shortKey, // 表头显示
|
|
|
+ prop: longKey // 对应数据字段
|
|
|
+ };
|
|
|
+ });
|
|
|
+ datelist.value = dateMap; // 存储映射关系
|
|
|
+ pchztableData.value = response.data.data;
|
|
|
+ }else{
|
|
|
+ ismachine.value = true;
|
|
|
+ const response = await PARlistpro({Machine:nodeData.label,rq:nodeData.rq});
|
|
|
+ sbhztableData.value = response.data;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 节点展开事件处理
|
|
|
@@ -276,13 +303,103 @@ const handleNodeExpand = (nodeData, node) => {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+// 排产表格行点击事件处理
|
|
|
+const pchzRowClick = async (row) => {
|
|
|
+ console.log('行点击:', row)
|
|
|
+ const response = await PARDetail({jtbh:row.机台编号,bz:row.班组})
|
|
|
+ if (response?.code === 0 && Array.isArray(response.data)) {
|
|
|
+ pcmxtableData.value = response.data;
|
|
|
+ console.log('表格数据更新成功:', response.data);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+// 排产表格行点击事件处理
|
|
|
+const sbhzRowClick = async (row) => {
|
|
|
+ console.log('行点击:', row)
|
|
|
+ const response = await PARDetailpro({jtbh:row.机台编号,bz:row.班组})
|
|
|
+ if (response?.code === 0 && Array.isArray(response.data)) {
|
|
|
+ sbmxtableData.value = response.data;
|
|
|
+ console.log('表格数据更新成功:', response.data);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+
|
|
|
|
|
|
+//导出按钮(汇总)
|
|
|
+const hzToExcel = async () => {
|
|
|
+ try {
|
|
|
+ // 获取数据
|
|
|
+
|
|
|
+ const el = document.getElementById(ismachine.value ? 'sbhztable' : 'pchztable');
|
|
|
+ const filename = '生产效率统计汇总导出.xlsx';
|
|
|
+ const worksheet = XLSX.utils.table_to_sheet(el, { raw: true });
|
|
|
+ //从某列开始转化成数字
|
|
|
+ //设置从C列开始为数字格式
|
|
|
+ const range = XLSX.utils.decode_range(worksheet['!ref']);
|
|
|
+ for (let col = 2; col <= range.e.c; col++) { // 从C列(索引2)开始
|
|
|
+ for (let row = range.s.r + 1; row <= range.e.r; row++) { // 跳过表头行
|
|
|
+ const cellAddress = XLSX.utils.encode_cell({ r: row, c: col });
|
|
|
+ if (worksheet[cellAddress]) {
|
|
|
+ // 尝试转换为数字
|
|
|
+ const cellValue = worksheet[cellAddress].v;
|
|
|
+ const numValue = Number(cellValue);
|
|
|
+
|
|
|
+ if (!isNaN(numValue)) {
|
|
|
+ worksheet[cellAddress].t = 'n'; // 数字类型
|
|
|
+ worksheet[cellAddress].v = numValue; // 更新值
|
|
|
+ worksheet[cellAddress].z = '0'; // 数字格式
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建并导出工作簿
|
|
|
+ const wb = XLSX.utils.book_new();
|
|
|
+ XLSX.utils.book_append_sheet(wb, worksheet, 'Sheet1');
|
|
|
+ XLSX.writeFile(wb, filename);
|
|
|
+ } catch (error) {
|
|
|
+ console.error('导出失败:', error);
|
|
|
+ ElMessage.error('导出数据失败,请重试');
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
|
|
|
|
|
|
+ //导出按钮(汇总)
|
|
|
+ const mxToExcel = async () => {
|
|
|
+ try {
|
|
|
+ // 获取数据
|
|
|
+ const el = document.getElementById(ismachine.value ? 'sbmxtable' : 'pcmxtable');
|
|
|
+ const filename = '生产效率统计明细导出.xlsx';
|
|
|
+ const worksheet = XLSX.utils.table_to_sheet(el, { raw: true });
|
|
|
+ //从某列开始转化成数字
|
|
|
+ const range = XLSX.utils.decode_range(worksheet['!ref']);
|
|
|
+ for (let col = 4; col <= range.e.c; col++) { // 从C列(索引2)开始
|
|
|
+ for (let row = range.s.r + 1; row <= range.e.r; row++) { // 跳过表头行
|
|
|
+ const cellAddress = XLSX.utils.encode_cell({ r: row, c: col });
|
|
|
+ if (worksheet[cellAddress]) {
|
|
|
+ // 尝试转换为数字
|
|
|
+ const cellValue = worksheet[cellAddress].v;
|
|
|
+ const numValue = Number(cellValue);
|
|
|
+
|
|
|
+ if (!isNaN(numValue)) {
|
|
|
+ worksheet[cellAddress].t = 'n'; // 数字类型
|
|
|
+ worksheet[cellAddress].v = numValue; // 更新值
|
|
|
+ worksheet[cellAddress].z = '0'; // 数字格式
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建并导出工作簿
|
|
|
+ const wb = XLSX.utils.book_new();
|
|
|
+ XLSX.utils.book_append_sheet(wb, worksheet, 'Sheet1');
|
|
|
+ XLSX.writeFile(wb, filename);
|
|
|
+ } catch (error) {
|
|
|
+ console.error('导出失败:', error);
|
|
|
+ ElMessage.error('导出数据失败,请重试');
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
|
|
|
|