From 29be8639dc16b5d82bddc6099b1fa5cdca75f77a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 20 十月 2026 16:28:22 +0800
Subject: [PATCH] feat(import): 统一导入弹框与模板,修复模板日期格式及上传报错

---
 src/views/structural/capabilityAndLaboratory/capability/index.vue |  122 ++++++++++++----------------------------
 1 files changed, 36 insertions(+), 86 deletions(-)

diff --git a/src/views/structural/capabilityAndLaboratory/capability/index.vue b/src/views/structural/capabilityAndLaboratory/capability/index.vue
index e5b071c..a80bb26 100644
--- a/src/views/structural/capabilityAndLaboratory/capability/index.vue
+++ b/src/views/structural/capabilityAndLaboratory/capability/index.vue
@@ -9,14 +9,9 @@
           </el-radio-group>
         </el-col>
         <el-col :span="12" style="text-align: right;">
-          <el-upload v-if="radio === 0" ref='upload1'
-                     style="display: inline;margin-right: 8px"
-                     :action="uploadAction1"
-                     :before-upload="beforeUpload1" :headers="token" :on-error="onError1"
-                     :on-success="handleSuccessUp1" :show-file-list="false" accept='.doc,.docx,.xls,.xlsx'>
-            <el-button size="small" type="primary">瀵煎叆</el-button>
-          </el-upload>
-          <el-button size="small" type="primary" v-if="radio === 1" @click="uploadDia = true">瀵煎叆</el-button>
+          <el-button v-if="radio === 0" size="small" type="primary" style="margin-right: 8px"
+                     @click="$refs.importDialog0.open()">瀵煎叆</el-button>
+          <el-button size="small" type="primary" v-if="radio === 1" @click="$refs.importDialog1.open()">瀵煎叆</el-button>
           <el-button size="small" type="primary" @click="openAdd()">鏂板</el-button>
         </el-col>
       </el-row>
@@ -92,22 +87,37 @@
         <el-button :loading="uploading" type="primary" @click="submitProduct">纭� 璁�</el-button>
       </span></template>
     </el-dialog>
-    <el-dialog v-model="uploadDia" title="鏁版嵁瀵煎叆" width="500px">
-      <div style="margin: 0 auto;">
-        <el-upload ref="upload" :action="uploadAction"
-                   :auto-upload="false" :file-list="fileList"
-                   :headers="token" :limit="1"
-                   :on-change="beforeUpload" :on-error="onError" :on-success="onSuccess" accept=".xlsx" drag
-                   name="file">
-          <lims-icon name="el-icon-upload"></lims-icon>
-          <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
-        </el-upload>
-      </div>
-      <template #footer><span  class="dialog-footer">
-        <el-button @click="uploadDia = false">鍙� 娑�</el-button>
-        <el-button :loading="uploading" type="primary" @click="submitUpload()">涓� 浼�</el-button>
-      </span></template>
-    </el-dialog>
+    <import-dialog
+      ref="importDialog0"
+      title="瀵煎叆妫�楠岄」鐩弬鏁�"
+      :action="uploadAction1"
+      accept=".xls,.xlsx"
+      template-url="/import-templates/妫�楠岄」鐩弬鏁板鍏ユā鏉�.xlsx"
+      template-name="妫�楠岄」鐩弬鏁板鍏ユā鏉�.xlsx"
+      :tips="[
+        '姣忎釜鏁版嵁琛岄兘蹇呴』濉啓锛氭楠屽璞°�佹楠岄」銆佹楠岄」绫诲瀷銆佹楠屽�肩被鍨嬨�佺壒娈婃爣璇�',
+        '妫�楠岄」绫诲瀷鍙兘濉啓鈥滈潪閲囬泦绫诲瀷鈥濇垨鈥滈噰闆嗙被鍨嬧��',
+        '妫�楠屽�肩被鍨嬪彧鑳藉~鍐欌�滄暟鍊尖�濇垨鈥滄枃鏈��',
+        '鐗规畩鏍囪瘑鍙兘濉啓鈥滄槸鈥濇垨鈥滃惁鈥�',
+        '澶氫釜浜у搧/鏂规硶/鏉′欢/璁惧缂栧彿璇风敤涓枃鍒嗗彿鈥滐紱鈥濆垎闅�',
+        '璇峰垹闄ゅ浣欑殑绌虹櫧琛岋紝绌虹櫧琛屼細瀵艰嚧瀵煎叆澶辫触'
+      ]"
+      @success="refreshTable"
+    />
+    <import-dialog
+      ref="importDialog1"
+      title="瀵煎叆妫�楠屽璞�"
+      :action="uploadAction"
+      accept=".xls,.xlsx"
+      template-url="/import-templates/妫�楠屽璞″鍏ユā鏉�.xlsx"
+      template-name="妫�楠屽璞″鍏ユā鏉�.xlsx"
+      :tips="[
+        '鈥滃満鎵�鈥濆繀椤讳笌绯荤粺涓凡鏈夌殑鍦烘墍鍚嶇О瀹屽叏涓�鑷达紝鍚﹀垯瀵煎叆澶辫触',
+        '妫�娴嬪璞°�佷骇鍝佸悕绉板繀濉�',
+        '鍚屼竴妫�娴嬪璞℃湁澶氫釜浜у搧鏃讹紝璇峰~鍐欏琛�'
+      ]"
+      @success="refreshTable"
+    />
     <!--妫�楠岄」鐩弬鏁�-缂栬緫寮规-->
     <EditForm ref="editForm" @refreshList="refreshList1"></EditForm>
     <testObjectEditForm ref="testObjectEditForm" @refreshList="refreshList"></testObjectEditForm>
@@ -131,14 +141,14 @@
   selectTestObjectList, upProduct,
 } from "@/api/structural/capability";
 import limsTable from "@/components/Table/lims-table.vue";
+import ImportDialog from "@/components/ImportDialog/index.vue";
 import EditForm from "@/views/structural/capabilityAndLaboratory/capabilityComponents/EditForm.vue";
 import testObjectEditForm from "@/views/structural/capabilityAndLaboratory/capabilityComponents/testObjectEditForm.vue";
-import {getToken} from "@/utils/auth";
 import { obtainItemParameterList } from '@/api/structural/laboratoryScope'
 
 export default {
   name: 'Capability',
-  components: {limsTable, EditForm, testObjectEditForm, BindPartDialog, BindSupplierDensityDialog},
+  components: {limsTable, ImportDialog, EditForm, testObjectEditForm, BindPartDialog, BindSupplierDensityDialog},
   data() {
     return {
       uploadAction: import.meta.env.VITE_APP_BASE_API + '/capacityScope/importExcel',
@@ -374,9 +384,6 @@
       productRules: {
         name: [{ required: true, message: '璇峰~鍐欎骇鍝佸悕绉�', trigger: 'blur' }]
       },
-      uploadDia: false,
-      fileList: [],
-      token: {Authorization: "Bearer " + getToken()},
       uploading: false,
       currentRow: {}, // 閫夋嫨闆朵欢缁戝畾鏈潯鏁版嵁鐨勪俊鎭�
       currentSupplierDensityRow: {}, // 閫夋嫨闆朵欢缁戝畾鏈潯鏁版嵁鐨勪俊鎭�
@@ -396,63 +403,6 @@
     }
   },
   methods: {
-    submitUpload() {
-      if (this.$refs.upload.uploadFiles.length === 0) {
-        this.$message.error('鏈�夋嫨鏂囦欢')
-        return
-      }
-      this.uploading = true
-      this.$refs.upload.submit();
-    },
-    onSuccess(response, file, fileList) {
-      this.$refs.upload.clearFiles()
-      this.uploadDia = false
-      this.uploading = false
-      if (response.code !== 200) {
-        this.$message.error(response.msg)
-        return
-      }
-      this.$message.success('涓婁紶鎴愬姛')
-      this.productList = []
-      this.refreshTable()
-    },
-    onError(err, file, fileList) {
-      this.$message.error('涓婁紶澶辫触')
-      this.$refs.upload.clearFiles()
-      this.uploading = false
-    },
-    beforeUpload(file, fileList) {
-      if (file.size > 1024 * 1024 * 10) {
-        this.$message.error('涓婁紶鏂囦欢涓嶈秴杩�10M');
-        this.$refs.upload.clearFiles()
-        return false;
-      } else {
-        return true;
-      }
-    },
-    onError1(err, file, fileList) {
-      this.$message.error('涓婁紶澶辫触')
-      this.$refs.upload1.clearFiles()
-      this.uploading = false
-    },
-    beforeUpload1(file, fileList) {
-      if (file.size > 1024 * 1024 * 10) {
-        this.$message.error('涓婁紶鏂囦欢涓嶈秴杩�10M');
-        this.$refs.upload1.clearFiles()
-        return false;
-      } else {
-        return true;
-      }
-    },
-    handleSuccessUp1 (response, file, fileList) {
-      this.$refs.upload1.clearFiles()
-      if (response.code !== 200) {
-        this.$message.error(response.msg)
-        return
-      }
-      this.$message.success('涓婁紶鎴愬姛')
-      this.refreshTable()
-    },
     refreshList () {
       this.refreshTable()
     },

--
Gitblit v1.9.3