zck 10 месяцев назад
Родитель
Сommit
02a45bed51
1 измененных файлов с 51 добавлено и 4 удалено
  1. 51 4
      src/view/performance/QualityAssessment/SemiFinishedRework.vue

+ 51 - 4
src/view/performance/QualityAssessment/SemiFinishedRework.vue

@@ -28,6 +28,7 @@
               highlight-current-row="true"   border @selection-change="handleSelectionChange" id="table"
               :row-style="{ height: '20px' }"  :header-cell-style="{ padding: '0px' }"
               :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+              show-summary    :summary-method="getSummaries"
               :show-overflow-tooltip="true" @row-click="Click" @row-dblclick="doubleClick">
               <el-table-column align="left"  label="单据编号" prop="单据编号" width="138" />
               <el-table-column align="left"  label="订单编号" prop="订单编号" width="105" />
@@ -364,6 +365,7 @@ const GetAddr =  () => {
 GetAddr()
 
 //物理地址获取机台编号
+const ismachine = ref(false)
 const getMachineMacdata = async () => {
   console.log("机台获取物理地址",Machine.value)
   try {
@@ -373,6 +375,7 @@ const getMachineMacdata = async () => {
 	}
   console.log("机台获取物理地址",data.data)
   ReworkTeam['zb'] = data.data.组别;
+  ismachine.value = true;
   } catch (error) {
     console.error(error)
   }
@@ -398,12 +401,18 @@ const handleNodeClick = async (node) => {
 	}
   try {
     //获取汇总数据
-    const response = await ApiSubPieceAnd({
-      Sys_rq: node.label, 
+    const params = {
+      Sys_rq: node.label,
       page: 1,
       limit: 50,
       code: '返工'
-    });
+    };
+    
+    // 如果获取了机台编号,添加组别条件
+    if (ismachine.value) {
+      params.组别 = ReworkTeam['zb'];
+    }
+    const response = await ApiSubPieceAnd(params);
     //获取详情数据
     const excelresponse = await ApiSubPieceAndReworkList({
       Sys_rq: node.label, 
@@ -411,6 +420,9 @@ const handleNodeClick = async (node) => {
       limit: 50,
       code: '返工'
     });
+    
+    
+
     if (response.code === 0 && response.data?.data) {
       // 清空并更新表格数据
       tableData.splice(0, tableData.length, ...response.data.data);
@@ -432,6 +444,41 @@ const handleNodeClick = async (node) => {
 
 };
 
+	//合计
+	const getSummaries = (param) => {  
+	  const { columns, data } = param;  
+	  const sums = {};  
+	  //选择你希望合计的列
+	  const summableLabels = [ "返工数量"];
+	  columns.forEach((column, index) => {  
+		  if (index === 1) {  
+			  sums[index] = '总返工数量';  
+			  return;  
+		  }  
+	
+		  if (summableLabels.includes(column.label)) {  
+			  const values = data.map(item => Number(item[column.property]));  
+	
+			  // 检查数组中是否所有值都是 NaN  
+			  if (!values.every(value => isNaN(value))) {  
+				  sums[index] = values.reduce((prev, curr) => {  
+					  const value = Number(curr);  
+					  if (!isNaN(value)) {  
+						  return prev + value; 
+					  }  
+					  return prev;  
+				  }, 0);  
+				  // 如果需要,可以在这里添加单位  
+				  // sums[index] += ' 件';  
+			  } else {  
+				   sums[index] = 'N/A';  
+			  }  
+		  }  
+	  });  
+	
+	  return sums;  
+  };  
+
 const searchinfo = ref('');
 
 const onSearch = async () => { // 搜索按钮触发的事件处理函数,根据需要修改逻辑和接口调用
@@ -440,7 +487,7 @@ const onSearch = async () => { // 搜索按钮触发的事件处理函数,根
         Sys_rq:'',
         page: 1,
         limit: 50,
-        code: '次片'
+        code: '返工'
       });
       if (response.code === 0 && response.data?.data) {
         // 清空并更新表格数据