zck 5 ماه پیش
والد
کامیت
25ea1f5b70

+ 10 - 0
src/api/mes/job.js

@@ -1071,6 +1071,16 @@ export const StatisticEleDay = (params) => {
   })
 }
 
+
+//导出电表月数据
+export const Excel_StatisticEle = (params) => {
+  return service({
+    url: '/mes_server/work_order/Excel_StatisticEle',
+    method: 'get',
+    params
+  })
+}
+
 //获取子订单成品完成率
 export const SubOrderProgress = (params) => {
   return service({

+ 134 - 4
src/view/performance/MachineElectricity.vue

@@ -7,8 +7,8 @@
             <el-form ref="elSearchFormRef"   class="demo-form-inline" :rules="searchRule" >
               <el-form-item>
                 <!-- <el-input v-model="searchInfo" placeholder="搜索工单编号" clearable style="width: 200px;margin: 5px"></el-input>
-                <el-button type="primary" class="bt" icon="download" @click="hzToExcel" >导出到Excel(汇总)</el-button>
                 <el-button type="primary" class="bt" icon="download" @click="mxToExcel" >导出到Excel(明细)</el-button> -->
+                <el-button type="primary" class="bt" icon="download" @click="dlToExcel" >月度电量导出</el-button>
               </el-form-item>
             </el-form>
   
@@ -22,7 +22,7 @@
           <layout-sider :resize-directions="['right']" :width="190" style="margin-right: 10px;">
             <div class="JKWTree-tree" style="height: 200px">
               <h3>月份</h3>
-              <el-tree :data="treeData"  :props="defaultProps" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
+              <el-tree :data="treeData"  :props="defaultProps" class="treecolor" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
               </el-tree>
             </div>
           </layout-sider>
@@ -43,13 +43,13 @@
                         @selection-change="handleSelectionChange">
                <el-table-column  sortable align="center" label="日期" prop="日期"  width="120" />
                <el-table-column  sortable align="center" label="电表ID" prop="电表ID"  width="120" />
-               <el-table-column   align="center" label="总电量" prop="总电量"  width="110" />
                <el-table-column   align="center" label="尖电量" prop="尖电量"  width="110" />
                <el-table-column   align="center" label="峰电量" prop="峰电量"  width="110" />
                <el-table-column   align="center" label="平电量" prop="平电量"  width="110" />
                <el-table-column   align="center" label="谷电量" prop="谷电量"  width="110" />
                <el-table-column   align="center" label="起始总电量" prop="起始总电量"  width="110" />
                <el-table-column   align="center" label="结束总电量" prop="结束总电量"  width="110" />
+               <el-table-column   align="center" label="当日电量" prop="总电量"  width="110" />
                <el-table-column   align="center" label="开始时间" prop="开始时间"  width="200" />
                <el-table-column   align="center" label="结束时间" prop="结束时间"  width="200" />
               </el-table>
@@ -60,6 +60,7 @@
                  :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
               </div>
             </div>
+            
 
 <!-- 
             <div class="gva-table-box">
@@ -83,6 +84,26 @@
                  :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
               </div>
             </div> -->
+
+            <el-dialog v-model="ondlexcel"  title="月度电量导出" destroy-on-close style="height: 30%;width: 20%;">
+  <el-form-item label="选择年月" label-width="100px">
+    <el-date-picker
+			    v-model="dlrq"
+			    type="month"
+			    placeholder="选择年月"
+			    :default-value="new Date()"
+          @change="dlonchange_data"
+			    style="width: 200px;" 
+			  />
+  </el-form-item>
+
+        <template #footer>
+		    <div class="dialog-footer" style="text-align: right;">
+		      <el-button @click="dlcloseDialog">取消</el-button>
+		      <el-button type="primary" @click="dlonDialog">确定</el-button>
+		    </div>
+		  </template>
+            </el-dialog>
   
           </el-main>
         </layout-content>
@@ -95,9 +116,11 @@
   import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
   
   import {ref, reactive} from 'vue'
+    import * as XLSX from 'xlsx'
+import FileSaver from 'file-saver'
   import { exportExcelFile } from '@/utils/excel'
   import {ElMessage} from "element-plus";
-  import { Meter,StatisticEleDay,} from '@/api/mes/job'
+  import { Meter,StatisticEleDay,Excel_StatisticEle} from '@/api/mes/job'
   defineOptions({name: 'Company'})
 
   const today = new Date();
@@ -159,6 +182,17 @@ getTree()
 const hztableData = ref([])
 
 const handleNodeClick = async (node) => {
+  // 取消所有节点的颜色
+	const allNodes = document.querySelectorAll('.treecolor .el-tree-node');
+			  allNodes.forEach(node => {
+			  node.querySelector('.el-tree-node__label').style.color = '';
+	});
+	// 获取点击的节点 给当前点击的节点改变颜色【红色】
+	const clickedNodeId = node['$treeNodeId'];
+	const clickedNode = document.querySelector(`.treecolor .el-tree-node[data-key="${clickedNodeId}"]`);
+	if (clickedNode) {
+			  clickedNode.querySelector('.el-tree-node__label').style.color = 'red';
+	}
     console.log('点击节点:', node)
   if (!node.children) {
     const res = await StatisticEleDay({mid: node.mid,collectorid: node.label.split('【')[0],riqi: node.rq})
@@ -171,7 +205,103 @@ const handleNodeClick = async (node) => {
 }
 
   
+// 通用的导出Excel函数
+const exportToExcel = (data, filename = '导出数据.xlsx', sheetName = 'Sheet1') => {
+  try {
+    // 创建工作簿和工作表
+    const wb = XLSX.utils.book_new();
+    
+    // 如果data是DOM元素(表格)
+    if (typeof data === 'object' && data.nodeType === 1) {
+      const worksheet = XLSX.utils.table_to_sheet(data, { raw: true });
+      convertColumnsToNumber(worksheet);
+      XLSX.utils.book_append_sheet(wb, worksheet, sheetName);
+    } 
+    // 如果data是数组(接口数据)
+    else if (Array.isArray(data)) {
+      const worksheet = XLSX.utils.json_to_sheet(data);
+      XLSX.utils.book_append_sheet(wb, worksheet, sheetName);
+    } 
+    // 如果data已经是worksheet对象
+    else if (data['!ref']) {
+      XLSX.utils.book_append_sheet(wb, data, sheetName);
+    } else {
+      throw new Error('不支持的导出数据类型');
+    }
+    
+    // 导出文件
+    XLSX.writeFile(wb, filename);
+    return true;
+  } catch (error) {
+    console.error('导出Excel失败:', error);
+    ElMessage.error('导出失败: ' + error.message);
+    return false;
+  }
+};
 
+// 列转换为数字的通用函数
+const convertColumnsToNumber = (worksheet, startCol = 2) => {
+  const range = XLSX.utils.decode_range(worksheet['!ref']);
+  for (let col = startCol; col <= range.e.c; col++) {
+    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) && cellValue !== '') {
+          worksheet[cellAddress].t = 'n';
+          worksheet[cellAddress].v = numValue;
+          worksheet[cellAddress].z = '0';
+        }
+      }
+    }
+  }
+};
+
+const ondlexcel = ref(false)
+const dlrq = ref('')
+const dlToExcel = async=> {
+  ondlexcel.value = true
+}
+  const dlcloseDialog = () => {
+    ondlexcel.value = false
+  }
+  const dlonchange_data = (val) => {
+  if (val) {
+    // 将日期对象转换为本地时间的年月格式
+    const year = val.getFullYear()
+    const month = (val.getMonth() + 1).toString().padStart(2, '0')
+    dlrq.value = `${year}${month}`
+  } else {
+    dlrq.value = ''
+  }
+}
+
+const dlonDialog = async() => {
+  if(!dlrq.value){
+    ElMessage.error('请选择年月')
+    return
+  }
+  
+  const res = await Excel_StatisticEle({sys_rq: dlrq.value})
+  console.log('获取数据:', res)  
+  
+  if(res.code === 0){
+    // 直接使用接口返回的数据导出
+    const success = exportToExcel(
+      res.data, 
+      `电量汇总_${dlrq.value}.xlsx`,
+      '生产汇总'
+    );
+    
+    if(success) {
+      ElMessage.success('导出成功');
+    }
+  } else {
+    ElMessage.error(res.msg || '获取数据失败');
+  }
+}
   
 
   

+ 1 - 0
src/view/performance/datangbaogong.vue

@@ -476,6 +476,7 @@ const add_onSubmit = async ()=>{
 	 add_formData['尺码'] = getSpotLists.data.result.cm
 	 add_formData['总数量'] = getSpotLists.data.result.sl
 	 add_formData['剩余数量'] = getSpotLists.data.result.ci_num
+	 add_formData['上报数量'] = add_searchInfo.value.split(',')[4]
 	 add_tableData.splice(0,add_tableData.length,...getSpotLists.data.records);
 	 console.log(add_tableData)
 	 

+ 1 - 0
src/view/performance/houdaoshougong.vue

@@ -480,6 +480,7 @@ const add_onSubmit = async ()=>{
 	 add_formData['尺码'] = getSpotLists.data.result.cm
 	 add_formData['总数量'] = getSpotLists.data.result.sl
 	 add_formData['剩余数量'] = getSpotLists.data.result.ci_num
+	 add_formData['上报数量'] = add_searchInfo.value.split(',')[4]
 	 add_tableData.splice(0,add_tableData.length,...getSpotLists.data.records);
 	 console.log(add_tableData)
 	 

+ 204 - 6
src/view/yunyin/shengchanguanli/chengpinrucang.vue

@@ -6,9 +6,11 @@
             <!--          按钮部分-->
             <el-form ref="elSearchFormRef"   class="demo-form-inline" :rules="searchRule" >
               <el-form-item>
-                <!-- <el-input v-model="searchInfo" placeholder="搜索工单编号" clearable style="width: 200px;margin: 5px"></el-input>
-                <el-button type="primary" class="bt" icon="download" @click="hzToExcel" >导出到Excel(汇总)</el-button>
-                <el-button type="primary" class="bt" icon="download" @click="mxToExcel" >导出到Excel(明细)</el-button> -->
+                <!-- <el-input v-model="searchInfo" placeholder="搜索工单编号" clearable style="width: 200px;margin: 5px"></el-input> -->
+                <el-input v-model="searchInfo"  placeholder="输入订单编号" style="width: 180px;" @keyup.enter="onSubmit()"></el-input>
+                <el-button type="primary" icon="search" @click="onSubmit" title="查询"  >查询</el-button>
+                <el-button type="primary" class="bt" icon="download" @click="hzToExcel" >订单成品导出</el-button>
+                <!-- <el-button type="primary" class="bt" icon="download" @click="mxToExcel" >导出到Excel(明细)</el-button> -->
               </el-form-item>
             </el-form>
   
@@ -21,7 +23,7 @@
           <!--    左侧树侧形结构-->
           <layout-sider :resize-directions="['right']" :width="220" style="margin-right: 10px;">
             <div class="JKWTree-tree" style="height: 200px">
-              <h3>成品入仓</h3>
+              <h3>产品返工次片合格率汇总</h3>
               <el-tree :data="treeData"  :props="defaultProps"  class="treecolor" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
               </el-tree>
             </div>
@@ -44,6 +46,7 @@
                <el-table-column  sortable align="center" label="订单编号" prop="订单编号"  width="120" />
                <el-table-column  sortable align="center" label="生产款号" prop="生产款号"  width="170" />
                <el-table-column  sortable align="center" label="款式" prop="款式"  width="120" />
+               <el-table-column  sortable align="center" label="制单数量" prop="订单数量"  width="120" />
                <!-- <el-table-column   align="center" label="实裁数量" prop="实裁数量"  width="110" /> -->
                <el-table-column   align="center" label="本月总检完工数量" prop="入仓数量"  width="150" />
                <el-table-column   align="center" label="累计总检完工数量" prop="累计入仓数量"  width="150" />
@@ -76,11 +79,11 @@
                         highlight-current-row="true" @row-dblclick="updateCompanyFunc"
                         :show-overflow-tooltip="true"
                         @selection-change="handleSelectionChange">
-               <el-table-column  sortable align="center" label="订单编号" prop="订单编号"  width="120" />
                <el-table-column  sortable align="center" label="子订单编号" prop="子订单编号"  width="160" />
                <el-table-column  sortable align="center" label="PO号" prop="生产款号"  width="200" />
                <el-table-column  sortable align="center" label="颜色" prop="颜色"  width="160" />
                <el-table-column  sortable align="center" label="颜色备注" prop="颜色备注"  width="200" />
+               <el-table-column  sortable align="center" label="制单数量" prop="zdtotal"  width="120" />
                <el-table-column   align="center" label="本月总检完工数量" prop="入仓数量"  width="150" />
                <el-table-column   align="center" label="累计总检完工数量" prop="累计入仓数量"  width="150" />
                <el-table-column   align="center" label="裁剪数量" prop="裁剪数量"  width="100" />
@@ -96,6 +99,46 @@
               </div>
             </div>
   
+            <el-dialog v-model="onhzexcel"  title="汇总数据导出" destroy-on-close style="height: 30%;width: 20%;">
+  <el-form-item label="选择年月" label-width="100px">
+    <el-date-picker
+			    v-model="hzrq"
+			    type="month"
+			    placeholder="选择年月"
+			    :default-value="new Date()"
+          @change="hzonchange_data"
+			    style="width: 200px;" 
+			  />
+  </el-form-item>
+
+        <template #footer>
+		    <div class="dialog-footer" style="text-align: right;">
+		      <el-button @click="hzcloseDialog">取消</el-button>
+		      <el-button type="primary" @click="hzonDialog">确定</el-button>
+		    </div>
+		  </template>
+            </el-dialog>
+
+            <el-dialog v-model="onmxexcel"  title="明细数据导出" destroy-on-close style="height: 30%;width: 20%;">
+  <el-form-item label="选择年月" label-width="100px">
+    <el-date-picker
+			    v-model="mxrq"
+			    type="month"
+			    placeholder="选择年月"
+			    :default-value="new Date()"
+          @change="mxonchange_data"
+			    style="width: 200px;" 
+			  />
+  </el-form-item>
+
+        <template #footer>
+		    <div class="dialog-footer" style="text-align: right;">
+		      <el-button @click="mxcloseDialog">取消</el-button>
+		      <el-button type="primary" @click="mxonDialog">确定</el-button>
+		    </div>
+		  </template>
+            </el-dialog>
+
           <!-- </el-main> -->
         </layout-content>
         </layout>
@@ -105,7 +148,8 @@
   <script setup>
   // 全量引入格式化工具 请按需保留
   import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
-  
+  import * as XLSX from 'xlsx'
+import FileSaver from 'file-saver'
   import {ref, reactive} from 'vue'
   import { exportExcelFile } from '@/utils/excel'
   import {ElMessage} from "element-plus";
@@ -187,11 +231,165 @@ const tableRowClick = async(row) => {
     mxtableData.value = res.data.result
   }
 }
+
+const searchInfo = ref('')
+const onSubmit = async () => {
+  if (!searchInfo.value) {
+    ElMessage.warning('请输入订单编号');
+    return;
+  }else{
+    const res = await GetWfpList({search:searchInfo.value})
+    console.log('获取数据:', res)  
+    if(res.code === 0){
+    hztableData.value = res.data.result
+  }
+  }
+}
+
+
+// 通用的导出Excel函数
+const exportToExcel = (data, filename = '导出数据.xlsx', sheetName = 'Sheet1') => {
+  try {
+    // 创建工作簿和工作表
+    const wb = XLSX.utils.book_new();
+    
+    // 如果data是DOM元素(表格)
+    if (typeof data === 'object' && data.nodeType === 1) {
+      const worksheet = XLSX.utils.table_to_sheet(data, { raw: true });
+      convertColumnsToNumber(worksheet);
+      XLSX.utils.book_append_sheet(wb, worksheet, sheetName);
+    } 
+    // 如果data是数组(接口数据)
+    else if (Array.isArray(data)) {
+      const worksheet = XLSX.utils.json_to_sheet(data);
+      XLSX.utils.book_append_sheet(wb, worksheet, sheetName);
+    } 
+    // 如果data已经是worksheet对象
+    else if (data['!ref']) {
+      XLSX.utils.book_append_sheet(wb, data, sheetName);
+    } else {
+      throw new Error('不支持的导出数据类型');
+    }
+    
+    // 导出文件
+    XLSX.writeFile(wb, filename);
+    return true;
+  } catch (error) {
+    console.error('导出Excel失败:', error);
+    ElMessage.error('导出失败: ' + error.message);
+    return false;
+  }
+};
+
+// 列转换为数字的通用函数
+const convertColumnsToNumber = (worksheet, startCol = 2) => {
+  const range = XLSX.utils.decode_range(worksheet['!ref']);
+  for (let col = startCol; col <= range.e.c; col++) {
+    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) && cellValue !== '') {
+          worksheet[cellAddress].t = 'n';
+          worksheet[cellAddress].v = numValue;
+          worksheet[cellAddress].z = '0';
+        }
+      }
+    }
+  }
+};
+
+
   
+const onhzexcel = ref(false)
+const onmxexcel = ref(false)
+const mxrq = ref('')
+const hzrq = ref('')
+const hzToExcel = async=> {
+  onhzexcel.value = true
+}
+  const hzcloseDialog = () => {
+    onhzexcel.value = false
+  }
+  const hzonchange_data = (val) => {
+  if (val) {
+    // 将日期对象转换为本地时间的年月格式
+    const year = val.getFullYear()
+    const month = (val.getMonth() + 1).toString().padStart(2, '0')
+    hzrq.value = `${year}${month}`
+  } else {
+    hzrq.value = ''
+  }
+}
 
+const hzonDialog = async() => {
+  if(!hzrq.value){
+    ElMessage.error('请选择年月')
+    return
+  }
+  
+  const res = await GetWfpList({sys_rq: hzrq.value})
+  console.log('获取数据:', res)  
   
+  if(res.code === 0){
+    // 直接使用接口返回的数据导出
+    const success = exportToExcel(
+      res.data.result, 
+      `生产数据汇总_${hzrq.value}.xlsx`,
+      '生产汇总'
+    );
+    
+    if(success) {
+      ElMessage.success('导出成功');
+    }
+  } else {
+    ElMessage.error(res.msg || '获取数据失败');
+  }
+}
+
+const mxToExcel = async=> {
+  onmxexcel.value = true
+}
+  const mxcloseDialog = () => {
+    onmxexcel.value = false
+  }
+  const mxonchange_data = (val) => {
+  if (val) {
+    // 将日期对象转换为本地时间的年月格式
+    const year = val.getFullYear()
+    const month = (val.getMonth() + 1).toString().padStart(2, '0')
+    mxrq.value = `${year}${month}`
+  } else {
+    mxrq.value = ''
+  }
+}
+
+const mxonDialog = async() => {
+  if(!mxrq.value){
+    ElMessage.error('请选择年月')
+    return
+  }
   
+  const res = await GetSubOrderStats({sys_rq: mxrq.value})
+  console.log('获取数据:', res)  
   
+  if(res.code === 0){
+    // 直接使用接口返回的数据导出
+    const success = exportToExcel(
+      res.data.result, 
+      `生产数据汇总_${hzrq.value}.xlsx`,
+      '生产汇总'
+    );
+    
+    if(success) {
+      ElMessage.success('导出成功');
+    }
+  } else {
+    ElMessage.error(res.msg || '获取数据失败');
+  }
+}
   
   
   </script>

+ 3 - 3
src/view/yunyin/shengchanguanli/gongdanziliao.vue

@@ -786,7 +786,7 @@
 		  
 		  
 		  <el-dialog v-model="ddzl_dialogFormVisible" :before-close="dd_closeDialog" title="修改订单资料"
-			style="height: 100%;width:90%;margin: 0px 0px 0px 6%;" top="0%" destroy-on-close >
+			style="height: 70%;width:90%;margin: 0px 0px 0px 6%;" top="0%" destroy-on-close >
 			<!-- 主布局,分为左右两部分 -->
 			<el-row>
 			  <!-- 左侧部分,包括第一列和第二列 -->
@@ -980,7 +980,7 @@
 			  </div>
 			</el-form>
 		  </div>
-		  <el-tag><span style="font-size: 18px;margin-left: 10px;">关联订单面料明细</span></el-tag>
+		  <!-- <el-tag><span style="font-size: 18px;margin-left: 10px;">关联订单面料明细</span></el-tag>
 		  <el-table ref="multipleTable"
 								:row-style="{ height: '30px' }"
 								:cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
@@ -1006,7 +1006,7 @@
 							  </template>
 							</el-table-column>
 							
-					  </el-table>
+					  </el-table> -->
 			<!-- 底部操作按钮 -->
 			<template #footer>
 			  <div class="dialog-footer" style="text-align: right;">