From 50e9a40ac746c7d46bd0b9f74e98d4d478cf5e64 Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期三, 10 九月 2025 15:43:22 +0800
Subject: [PATCH] 优化二保批量导入,改为返回文件让用户自己查询对应设备型号

---
 src/views/eam/base/EamMaintenanceStandardList.vue |  132 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 117 insertions(+), 15 deletions(-)

diff --git a/src/views/eam/base/EamMaintenanceStandardList.vue b/src/views/eam/base/EamMaintenanceStandardList.vue
index 7aac372..e669c1e 100644
--- a/src/views/eam/base/EamMaintenanceStandardList.vue
+++ b/src/views/eam/base/EamMaintenanceStandardList.vue
@@ -96,9 +96,19 @@
                :pagination="ipagination" :loading="loading" :scroll="{x:'max-content'}"
                :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" :customRow='clickThenSelect'
                @change="handleTableChange">
+
+        <!--浣跨敤閮ㄩ棬-->
+        <template slot="factoryOrgCode" slot-scope="text,record">
+          {{[record.zxfactoryOrgCode_dictText].filter(item=>item).join('/')}}
+        </template>
+
         <span slot="action" slot-scope="text, record">
           <a v-has="'standard:upgrade'" v-if="record.standardStatus === 'START'"
              @click.stop="handleUpgrade(record)">鍗囩増</a>
+
+          <a-divider v-has="'standard:add:upgrade'" v-if="record.standardStatus === 'START'" type="vertical"/>
+
+          <a v-has="'standard:add:upgrade'" v-if="record.standardStatus === 'START'" @click="handleAddUpgrade(record.id)" >鍗囩増瀵煎叆</a>
 
           <template v-if="record.standardStatus === 'WAIT_SUBMIT'">
               <a v-has="'standard:edit'" @click.stop="handleEdit(record)">缂栬緫</a>
@@ -125,7 +135,7 @@
           </a-popconfirm>
           </template>
 
-          <template v-if="record.standardStatus !== 'WAIT_SUBMIT'&&record.standardStatus!=='ABOLISH'&&record.standardStatus!=='START'">
+          <template>
             <a-divider type="vertical"/>
 
             <a @click.stop="handleDetail(record)">璇︽儏</a>
@@ -169,6 +179,9 @@
 
     <!--瀹℃壒绐楀彛-->
     <maintenance-standard-approval-modal ref="maintenanceStandardApprovalModal" :selectShenpiData="selectedRowData"/>
+
+    <!--瀵煎叆鏂囦欢-->
+    <MaintenanceStandardImportModule ref="fileImportModule" @ok="getTreeDataByApi" />
   </a-card>
 </template>
 
@@ -181,6 +194,7 @@
   import LxSearchEquipmentSelect from '@views/eam/equipment/modules/LxSearchEquipmentSelect.vue'
   import MaintenanceStandardApprovalModal
     from '../../flowable/workflow/MaintenanceStandard/MaintenanceStandardApprovalModal'
+  import MaintenanceStandardImportModule from "@views/base/modules/file/MaintenanceStandardImportModule.vue";
 
 
   export default {
@@ -193,6 +207,7 @@
       }
     },
     components: {
+      MaintenanceStandardImportModule,
       MaintenanceStandardApprovalModal,
       LxSearchEquipmentSelect,
       EamMaintenanceStandardModal,
@@ -208,17 +223,27 @@
           {
             title: '缁熶竴缂栫爜',
             align: 'center',
-            dataIndex: 'equipmentCode'
+            dataIndex: 'equipmentCode',
           },
           {
             title: '璁惧鍚嶇О',
             align: 'center',
-            dataIndex: 'equipmentName'
+            dataIndex: 'equipmentName',
           },
           {
             title: '璁惧鍨嬪彿',
             align: 'center',
-            dataIndex: 'equipmentModel'
+            dataIndex: 'equipmentModel',
+          },
+          {
+            title: '浣跨敤閮ㄩ棬',
+            align: 'center',
+            scopedSlots: { customRender: 'factoryOrgCode' },
+          },
+          {
+            title: '瑙勮寖鐘舵��',
+            align: 'center',
+            dataIndex: 'standardStatus_dictText',
           },
           {
             title: '淇濆吇鍒嗙被',
@@ -241,30 +266,21 @@
             title: '淇濆吇鍛ㄦ湡',
             align: 'center',
             dataIndex: 'maintenancePeriod',
-            width: 100
           },
           {
             title: '淇濆吇鍛ㄦ湡鍗曚綅',
             align: 'center',
             dataIndex: 'periodUnit',
-            width: 120
           },
           {
             title: '鍒濆鏃ユ湡',
             align: 'center',
             dataIndex: 'initialDate',
-            width: 100
-          },
-          {
-            title: '瑙勮寖鐘舵��',
-            align: 'center',
-            dataIndex: 'standardStatus_dictText'
           },
           {
             title: '瑙勮寖鐗堟湰',
             align: 'center',
             dataIndex: 'standardVersion',
-            width: 100
           }
         ],
         url: {
@@ -276,7 +292,7 @@
           inspectionImportExcel: '/eam/maintenanceStandard/importPointInspection',
           secondMaintenanceImportExcel: '/eam/maintenanceStandard/importSecondMaintenanceStandard',
           thirdMaintenanceImportExcel: '/eam/maintenanceStandard/importThirdMaintenanceStandard',
-          inspectionXlsDownloadUrl: '瀵煎叆妯℃澘/璁惧鐐规鏍囧噯瀵煎叆妯℃澘.xlsx',
+          inspectionXlsDownloadUrl: '瀵煎叆妯℃澘/璁惧鐐规鏍囧噯瀵煎叆妯℃澘.xls',
           secondMaintenanceXlsDownloadUrl: '瀵煎叆妯℃澘/鐢熶骇璁惧浜岀骇淇濆吇瑙勮寖.docx',
           thirdMaintenanceXlsDownloadUrl: '瀵煎叆妯℃澘/鐢熶骇璁惧涓夌骇淇濆吇瑙勮寖.docx'
         },
@@ -303,7 +319,6 @@
         dataIndex: 'action',
         align: 'center',
         scopedSlots: { customRender: 'action' },
-        width: 200,
         fixed: 'right'
       }
       this.columns = [...this.columns, operationColumn]
@@ -392,6 +407,93 @@
         this.$refs.maintenanceStandardApprovalModal.handleDetail(record)
       },
 
+      /**
+       * 鐐瑰嚮鍗囩増瀵煎叆鏃惰Е鍙戞椂瑙﹀彂
+       * @param record
+       */
+      handleAddUpgrade(id){
+        this.$refs.fileImportModule.upload(id);
+        this.$refs.fileImportModule.title="鍗囩増瀵煎叆"
+      },
+
+
+      getTreeDataByApi(){
+        this.loadData();
+      },
+
+      /* 瀵煎叆 */
+      handleImportExcel(info) {
+        this.loading = true;
+
+        if (info.file.status === 'done') {
+          this.loading = false;
+
+          // 妫�鏌ュ搷搴斿唴瀹规槸鍚︿负CSV鏍煎紡锛堝寘鍚湭鎵惧埌鐨勮澶囩紪鐮侊級
+          if (info.file.response && typeof info.file.response === 'string' &&
+            info.file.response.includes('鏈壘鍒扮殑璁惧缂栫爜')) {
+
+            // 鍒涘缓CSV鏂囦欢骞朵笅杞�
+            const blob = new Blob([info.file.response], { type: 'text/csv;charset=utf-8' });
+            const downloadUrl = window.URL.createObjectURL(blob);
+            const link = document.createElement('a');
+            link.href = downloadUrl;
+            link.setAttribute('download', '鏈壘鍒扮殑璁惧缂栫爜.csv');
+            document.body.appendChild(link);
+            link.click();
+            document.body.removeChild(link);
+            window.URL.revokeObjectURL(downloadUrl);
+
+            // 鏄剧ず鎻愮ず淇℃伅
+            this.$notification.warning({
+              message: '瀵煎叆瀹屾垚',
+              description: '瀵煎叆鎴愬姛浣嗗瓨鍦ㄦ湭鎵惧埌鐨勮澶囩紪鐮侊紝宸蹭笅杞芥湭鎵惧埌鐨勮澶囩紪鐮佸垪琛�'
+            });
+
+            this.loadData();
+            return;
+          }
+
+          // 澶勭悊甯歌JSON鍝嶅簲
+          if (info.file.response && info.file.response.success) {
+            this.$notification.success({
+              message: '瀵煎叆鎴愬姛',
+              description: info.file.response.message || `${info.file.name} 鏂囦欢涓婁紶鎴愬姛`
+            });
+            this.loadData();
+          } else {
+            const fileName = info.file.name || '鏈煡鏂囦欢';
+            const errorMessage = info.file.response && info.file.response.message
+              ? info.file.response.message
+              : '瀵煎叆澶辫触锛屾湭鐭ラ敊璇�';
+
+            this.$notification.error({
+              message: '瀵煎叆澶辫触',
+              description: `${fileName} ${errorMessage}`
+            });
+          }
+        } else if (info.file.status === 'error') {
+          this.loading = false;
+
+          const fileName = info.file.name || '鏈煡鏂囦欢';
+          let errorMessage = '涓婁紶澶辫触锛屾湭鐭ラ敊璇�';
+
+          if (info.file.response) {
+            if (info.file.response.message) {
+              errorMessage = info.file.response.message;
+            } else if (info.file.response.error) {
+              errorMessage = info.file.response.error;
+            }
+          } else if (info.file.error) {
+            errorMessage = info.file.error.message || info.file.error;
+          }
+
+          this.$notification.error({
+            message: '涓婁紶澶辫触',
+            description: `${fileName} ${errorMessage}`
+          });
+        }
+      },
+
       batchDel() {
         var ids = ''
         for (var a = 0; a < this.selectedRowKeys.length; a++) {

--
Gitblit v1.9.3