From 83b82d54ef6bdd67feb6d7f4780fa6cbe92fa242 Mon Sep 17 00:00:00 2001
From: dy <dingyang@lnfxkj.tech>
Date: 星期日, 13 四月 2025 10:57:32 +0800
Subject: [PATCH] 零件统计代码提交

---
 src/views/ApsPartRouteStat/index.vue |  379 ++++++++++++++++++-----------------------------------
 1 files changed, 131 insertions(+), 248 deletions(-)

diff --git a/src/views/ApsPartRouteStat/index.vue b/src/views/ApsPartRouteStat/index.vue
index d7130b7..34b457f 100644
--- a/src/views/ApsPartRouteStat/index.vue
+++ b/src/views/ApsPartRouteStat/index.vue
@@ -1,290 +1,173 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
-      <el-form-item label="鐢熶骇鏁伴噺" prop="productionQuantity">
-        <el-input
-          v-model="queryParams.productionQuantity"
-          placeholder="璇疯緭鍏ョ敓浜ф暟閲�"
-          clearable
-          @keyup.enter="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="鏍囧噯宸ユ椂" prop="standardTime">
-        <el-input
-          v-model="queryParams.standardTime"
-          placeholder="璇疯緭鍏ユ爣鍑嗗伐鏃�"
-          clearable
-          @keyup.enter="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="宸ュ簭鎬诲伐鏃�" prop="processTotalTime">
-        <el-input
-          v-model="queryParams.processTotalTime"
-          placeholder="璇疯緭鍏ュ伐搴忔�诲伐鏃�"
-          clearable
-          @keyup.enter="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="璁捐宸ユ椂" prop="designTimes">
-        <el-input
-          v-model="queryParams.designTimes"
-          placeholder="璇疯緭鍏ヨ璁″伐鏃�"
-          clearable
-          @keyup.enter="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item>
-        <el-button type="primary" icon="Search" @click="handleQuery">鎼滅储</el-button>
-        <el-button icon="Refresh" @click="resetQuery">閲嶇疆</el-button>
-      </el-form-item>
-    </el-form>
-
     <el-row :gutter="10" class="mb8">
-      <el-col :span="1.5">
-        <el-button
-          type="primary"
-          plain
-          icon="Plus"
-          @click="handleAdd"
-          v-hasPermi="['ApsPartRouteStat:ApsPartRouteStat:add']"
-        >鏂板</el-button>
-      </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="success"
-          plain
-          icon="Edit"
-          :disabled="single"
-          @click="handleUpdate"
-          v-hasPermi="['ApsPartRouteStat:ApsPartRouteStat:edit']"
-        >淇敼</el-button>
-      </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="danger"
-          plain
-          icon="Delete"
-          :disabled="multiple"
-          @click="handleDelete"
-          v-hasPermi="['ApsPartRouteStat:ApsPartRouteStat:remove']"
-        >鍒犻櫎</el-button>
-      </el-col>
       <el-col :span="1.5">
         <el-button
           type="warning"
           plain
           icon="Download"
           @click="handleExport"
-          v-hasPermi="['ApsPartRouteStat:ApsPartRouteStat:export']"
+          v-hasPermi="['apsPartRouteStat:apsPartRouteStat:export']"
         >瀵煎嚭</el-button>
       </el-col>
-      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
-
-    <el-table v-loading="loading" :data="ApsPartRouteStatList" @selection-change="handleSelectionChange">
-      <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="宸ュ崟鍙�" align="center" prop="workOrderNo" />
-      <el-table-column label="宸ュ簭鍙�" align="center" prop="roadProcessNumber" />
-      <el-table-column label="褰撳墠宸ュ簭鍙�" align="center" prop="currentProcessNumber" />
-      <el-table-column label="鐢熶骇鏁伴噺" align="center" prop="productionQuantity" />
-      <el-table-column label="鏍囧噯宸ユ椂" align="center" prop="standardTime" />
-      <el-table-column label="宸ュ簭鎬诲伐鏃�" align="center" prop="processTotalTime" />
-      <el-table-column label="璁″垝寮�宸ユ棩" align="center" prop="processPlanStartDay" />
-      <el-table-column label="璁捐宸ユ椂" align="center" prop="designTimes" />
-      <el-table-column label="鎵规鍙�" align="center" prop="batchNumber" />
-      <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
-        <template #default="scope">
-          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['ApsPartRouteStat:ApsPartRouteStat:edit']">淇敼</el-button>
-          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['ApsPartRouteStat:ApsPartRouteStat:remove']">鍒犻櫎</el-button>
-        </template>
-      </el-table-column>
-    </el-table>
     
-    <pagination
-      v-show="total>0"
-      :total="total"
-      v-model:page="queryParams.pageNum"
-      v-model:limit="queryParams.pageSize"
-      @pagination="getList"
-    />
-
-    <!-- 娣诲姞鎴栦慨鏀归浂浠剁粺璁¤〃瀵硅瘽妗� -->
-    <el-dialog :title="title" v-model="open" width="500px" append-to-body>
-      <el-form ref="ApsPartRouteStatRef" :model="form" :rules="rules" label-width="80px">
-        <el-form-item label="鐢熶骇鏁伴噺" prop="productionQuantity">
-          <el-input v-model="form.productionQuantity" placeholder="璇疯緭鍏ョ敓浜ф暟閲�" />
-        </el-form-item>
-        <el-form-item label="鏍囧噯宸ユ椂" prop="standardTime">
-          <el-input v-model="form.standardTime" placeholder="璇疯緭鍏ユ爣鍑嗗伐鏃�" />
-        </el-form-item>
-        <el-form-item label="宸ュ簭鎬诲伐鏃�" prop="processTotalTime">
-          <el-input v-model="form.processTotalTime" placeholder="璇疯緭鍏ュ伐搴忔�诲伐鏃�" />
-        </el-form-item>
-        <el-form-item label="璁捐宸ユ椂" prop="designTimes">
-          <el-input v-model="form.designTimes" placeholder="璇疯緭鍏ヨ璁″伐鏃�" />
-        </el-form-item>
-      </el-form>
-      <template #footer>
-        <div class="dialog-footer">
-          <el-button type="primary" @click="submitForm">纭� 瀹�</el-button>
-          <el-button @click="cancel">鍙� 娑�</el-button>
-        </div>
-      </template>
-    </el-dialog>
+    <vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid>
   </div>
 </template>
 
-<script setup name="ApsPartRouteStat">
-import { listApsPartRouteStat, getApsPartRouteStat, delApsPartRouteStat, addApsPartRouteStat, updateApsPartRouteStat } from "@/api/ApsPartRouteStat/ApsPartRouteStat";
+<script setup name="apsPartRouteStat">
+import { query } from "@/api/apsPartRouteStat/apsPartRouteStat";
+import { ref } from "vue";
+import * as XLSX from 'xlsx';
 
 const { proxy } = getCurrentInstance();
 
-const ApsPartRouteStatList = ref([]);
-const open = ref(false);
 const loading = ref(true);
-const showSearch = ref(true);
-const ids = ref([]);
-const single = ref(true);
-const multiple = ref(true);
-const total = ref(0);
-const title = ref("");
+const gridRef = ref();
+const height = ref(document.documentElement.clientHeight - 130 + "px;")
+const headers = ref([]);
+const exportData = ref([]);
 
-const data = reactive({
-  form: {},
-  queryParams: {
-    pageNum: 1,
-    pageSize: 10,
-    workOrderNo: null,
-    roadProcessNumber: null,
-    currentProcessNumber: null,
-    productionQuantity: null,
-    standardTime: null,
-    processTotalTime: null,
-    processPlanStartDay: null,
-    designTimes: null,
-    batchNumber: null
+const gridOptions = reactive({
+  border: true,
+  loading: false,
+  showOverflow: true,
+  showHeaderOverflow: true,
+  showFooterOverflow: true,
+  height: height,
+  columnConfig: {
+    resizable: true
   },
-  rules: {
-    roadProcessNumber: [
-      { required: true, message: "宸ュ簭鍙蜂笉鑳戒负绌�", trigger: "blur" }
-    ],
-    processPlanStartDay: [
-      { required: true, message: "璁″垝寮�宸ユ棩涓嶈兘涓虹┖", trigger: "blur" }
-    ],
+  scrollX: {
+    enabled: true,
+    gt: 0,
+    threshold: 50
+  },
+  scrollY: {
+    enabled: true,
+    gt: 0,
+    threshold: 50
   }
 });
 
-const { queryParams, form, rules } = toRefs(data);
+let rowKey = 0
+let colKey = 0
+let tableColumn = []
+let tableData = []
+let merges = [];
 
 /** 鏌ヨ闆朵欢缁熻琛ㄥ垪琛� */
 function getList() {
   loading.value = true;
-  listApsPartRouteStat(queryParams.value).then(response => {
-    ApsPartRouteStatList.value = response.rows;
-    total.value = response.total;
-    loading.value = false;
-  });
-}
+  query().then(response => {
+    if(response.code == '200'){
+      loading.value = true;
+      const colList = []
+      let headersOne = []
+      let headersTwo = []
+      headersOne.push('鏃ユ湡');
+      headersTwo.push('璧勬簮缁�');
+      colList.push({
+          field: 'dateCol',
+          title: '鏃ユ湡',
+          children: [
+            { field: `resourceName`, title: '璧勬簮缁�', width: 100},
+          ],
+          width: 160
+        })
+      response.planTitle.forEach(item => {
+        headersOne.push(item);
+        headersOne.push('');
+        headersOne.push('');
+        headersTwo.push('璁捐宸ユ椂');
+        headersTwo.push('闇�姹傚伐鏃�');
+        headersTwo.push('浜ц兘璐熻嵎');
+        colKey++
+        colList.push({
+          field: `dateColTime${colKey}`,
+          title: item,
+          children: [
+          { field: `designTimes${colKey}`, title: '璁捐宸ユ椂', width: 100},
+          { field: `requireTimes${colKey}`, title: '闇�姹傚伐鏃�', width: 100},
+          { field: `capacityLoad${colKey}`, title: '浜ц兘璐熻嵎', width: 100},
+          ],
+          width: 160
+        })
+      });
 
-// 鍙栨秷鎸夐挳
-function cancel() {
-  open.value = false;
-  reset();
-}
+      headers.value.push(headersOne);
+      headers.value.push(headersTwo);
 
-// 琛ㄥ崟閲嶇疆
-function reset() {
-  form.value = {
-    id: null,
-    workOrderNo: null,
-    roadProcessNumber: null,
-    currentProcessNumber: null,
-    productionQuantity: null,
-    standardTime: null,
-    processTotalTime: null,
-    processPlanStartDay: null,
-    designTimes: null,
-    delFlag: null,
-    createBy: null,
-    batchNumber: null
-  };
-  proxy.resetForm("ApsPartRouteStatRef");
-}
+      const columnList = [...tableColumn, ...colList]
+      const dataList = []
+      let startCol = 1;
 
-/** 鎼滅储鎸夐挳鎿嶄綔 */
-function handleQuery() {
-  queryParams.value.pageNum = 1;
-  getList();
-}
-
-/** 閲嶇疆鎸夐挳鎿嶄綔 */
-function resetQuery() {
-  proxy.resetForm("queryRef");
-  handleQuery();
-}
-
-// 澶氶�夋閫変腑鏁版嵁
-function handleSelectionChange(selection) {
-  ids.value = selection.map(item => item.id);
-  single.value = selection.length != 1;
-  multiple.value = !selection.length;
-}
-
-/** 鏂板鎸夐挳鎿嶄綔 */
-function handleAdd() {
-  reset();
-  open.value = true;
-  title.value = "娣诲姞闆朵欢缁熻琛�";
-}
-
-/** 淇敼鎸夐挳鎿嶄綔 */
-function handleUpdate(row) {
-  reset();
-  const _id = row.id || ids.value
-  getApsPartRouteStat(_id).then(response => {
-    form.value = response.data;
-    open.value = true;
-    title.value = "淇敼闆朵欢缁熻琛�";
-  });
-}
-
-/** 鎻愪氦鎸夐挳 */
-function submitForm() {
-  proxy.$refs["ApsPartRouteStatRef"].validate(valid => {
-    if (valid) {
-      if (form.value.id != null) {
-        updateApsPartRouteStat(form.value).then(response => {
-          proxy.$modal.msgSuccess("淇敼鎴愬姛");
-          open.value = false;
-          getList();
-        });
-      } else {
-        addApsPartRouteStat(form.value).then(response => {
-          proxy.$modal.msgSuccess("鏂板鎴愬姛");
-          open.value = false;
-          getList();
-        });
+      //鑾峰彇map
+      response.planTable.forEach(mapItem => {
+        rowKey++
+        let lastCol = startCol + 2;
+        merges.push({ s: { r: 0, c: startCol }, e: { r: 0, c:  lastCol} });
+        startCol = lastCol + 1;
+        let data = [];
+        const item = {
+          id: `${rowKey}`
+        }
+        for (const [key, listValue] of Object.entries(mapItem)) {
+          data.push(key);
+          item[`resourceName`] = key;
+          let tableKey = 0;
+          listValue.forEach(listItem => {
+            tableKey++
+            item[`designTimes${tableKey}`] = listItem.designTimes;
+            item[`requireTimes${tableKey}`] = listItem.requireTimes;
+            item[`capacityLoad${tableKey}`] = listItem.capacityLoad;
+            data.push(listItem.designTimes);
+            data.push(listItem.requireTimes);
+            data.push(listItem.capacityLoad);
+          });
+        }
+        exportData.value.push(data);
+        dataList.push(item);
+      });
+        
+      const $grid = gridRef.value
+      if ($grid) {
+        tableColumn = columnList
+        tableData = [...tableData, ...dataList]
+        $grid.loadColumn(tableColumn)
+        $grid.loadData(tableData)
+        gridOptions.loading = false
       }
+
+      loading.value = false;
     }
   });
 }
 
-/** 鍒犻櫎鎸夐挳鎿嶄綔 */
-function handleDelete(row) {
-  const _ids = row.id || ids.value;
-  proxy.$modal.confirm('鏄惁纭鍒犻櫎闆朵欢缁熻琛ㄧ紪鍙蜂负"' + _ids + '"鐨勬暟鎹」锛�').then(function() {
-    return delApsPartRouteStat(_ids);
-  }).then(() => {
-    getList();
-    proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
-  }).catch(() => {});
-}
-
 /** 瀵煎嚭鎸夐挳鎿嶄綔 */
 function handleExport() {
-  proxy.download('ApsPartRouteStat/ApsPartRouteStat/export', {
-    ...queryParams.value
-  }, `ApsPartRouteStat_${new Date().getTime()}.xlsx`)
+
+  // 鍚堝苟琛ㄥご鍜屾暟鎹�
+  const finalData = [...headers.value, ...exportData.value];
+
+  // 灏嗘暟鎹浆鎹负 worksheet
+  const ws = XLSX.utils.aoa_to_sheet(finalData);
+
+  // 鍚堝苟鍗曞厓鏍硷紙濡傛灉闇�瑕侊級
+  /* ws['!merges'] = [
+    { s: { r: 0, c: 1 }, e: { r: 0, c: 3 } },
+    { s: { r: 0, c: 0 }, e: { r: 0, c: 0 } }
+  ]; */
+
+  ws['!merges'] = merges;
+  
+  // 鍒涘缓 workbook
+  const wb = XLSX.utils.book_new();
+  // 灏� worksheet 娣诲姞鍒� workbook 涓�
+  XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
+  // 瀵煎嚭鏂囦欢
+  XLSX.writeFile(wb, `apsPartRouteStat_${new Date().getTime()}.xlsx`);
 }
 
 getList();

--
Gitblit v1.9.3