From cc6914dff1a91dd00e3a86d5daae2c3dba2d6ba8 Mon Sep 17 00:00:00 2001
From: gaoluyang <gaoluyang@rengu.cc>
Date: 星期三, 24 七月 2024 16:28:00 +0800
Subject: [PATCH] 检测中心-班次时间配置功能

---
 src/components/view/a5-capacity-scope.vue |   89 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 86 insertions(+), 3 deletions(-)

diff --git a/src/components/view/a5-capacity-scope.vue b/src/components/view/a5-capacity-scope.vue
index 03e20ff..51d954c 100644
--- a/src/components/view/a5-capacity-scope.vue
+++ b/src/components/view/a5-capacity-scope.vue
@@ -38,13 +38,21 @@
     height: calc(100% - 60px - 80px - 10px - 40px);
     padding: 20px;
   }
+
+  >>> .el-upload {
+    width: 100% !important;
+  }
+
+  >>> .el-upload-dragger {
+    width: 100% !important;
+  }
 </style>
 
 <template>
   <div class="capacity-scope">
     <div>
       <el-row class="title">
-        <el-col :span="12">
+        <el-col :span="12" style="text-align: left">
           <el-radio-group v-model="radio" @input="selectorSwitch" size="medium" fill="#3A7BFA" v-if="select==3">
             <el-radio-button label="0">妫�楠岄」鐩弬鏁�</el-radio-button>
             <el-radio-button label="1">妫�楠屽璞�</el-radio-button>
@@ -56,8 +64,9 @@
           <el-button size="medium" @click="$refs.itemParameterTable.openUpload()" v-if="inPower">
             <i class="el-icon-upload2" style="color: #3A7BFA;"></i>
             <span style="color: #3A7BFA;">瀵煎叆</span></el-button>
+          <el-button size="medium" type="primary" v-if="radio == 1 && importExcel" @click="uploadDia = true">瀵煎叆</el-button>
           <el-button size="medium" type="primary" @click="openAdd" v-if="addPower">鏂板</el-button>
-           <el-button size="medium" icon="el-icon-delete">鍒犻櫎</el-button>
+          <el-button size="medium" icon="el-icon-delete">鍒犻櫎</el-button>
         </el-col>
       </el-row>
     </div>
@@ -86,9 +95,12 @@
         </div>
       </div>
       <div class="table">
-        <ValueTable ref="itemParameterTable" :url="$api.capacityScope.selectItemParameterList"
+        <ValueTable ref="itemParameterTable" :url="$api.capacityScope.selectItemParameterList" v-if="PROJECT === '妫�娴嬩腑蹇�'"
           :upUrl="$api.capacityScope.upItemParameter" :delUrl="$api.capacityScope.delItemParameter"
           :inputUrl="$api.capacityScope.importData" :componentData="itemParameterData" :key="upIndex" />
+        <ValueTable ref="itemParameterTable" :url="$api.capacityScope.selectItemParameterList" v-if="PROJECT === '瑁呭鐢电紗'"
+                    :upUrl="$api.capacityScope.upItemParameter" :delUrl="$api.capacityScope.delItemParameter"
+                    :inputUrl="$api.capacityScope.importEquipData" :componentData="itemParameterData" :key="upIndex" />
       </div>
     </div>
     <div class="bodys">
@@ -118,6 +130,20 @@
       <span slot="footer" class="dialog-footer">
         <el-button @click="diaProduct = false">鍙� 娑�</el-button>
         <el-button type="primary" @click="openAdd2" :loading="productLoad">鏂� 澧�</el-button>
+      </span>
+    </el-dialog>
+    <el-dialog title="鏁版嵁瀵煎叆" :visible.sync="uploadDia" width="500px">
+      <div style="margin: 0 auto;">
+        <el-upload ref="upload" drag :action="javaApi + $api.capacityScope.importExcel" :headers="token" :file-list="fileList" name="file"
+          :auto-upload="false" accept=".xlsx" :limit="1" :on-change="beforeUpload" :on-success="onSuccess"
+          :on-error="onError">
+          <i class="el-icon-upload"></i>
+          <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+        </el-upload>
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="uploadDia = false">鍙� 娑�</el-button>
+        <el-button type="primary" @click="submitUpload()" :loading="uploading">涓� 浼�</el-button>
       </span>
     </el-dialog>
   </div>
@@ -320,9 +346,28 @@
           requiredUp: ['name','nameEn'],
         },
         inPower: true,
+        importExcel: false,
+        uploadDia: false,
+        fileList: [],
+        token: null,
+        uploading: false,
+      }
+    },
+    created() {
+      if (this.PROJECT === '瑁呭鐢电紗') {
+        this.itemParameterData.requiredUp = ['sonLaboratory', 'inspectionItem', 'inspectionItemType', 'inspectionValueType',
+          'unit', 'manDay', 'templateId'
+        ]
+      } else {
+        this.itemParameterData.requiredUp = ['sonLaboratory', 'inspectionItem', 'inspectionItemType', 'inspectionValueType',
+          'unit', 'method', 'manDay', 'templateId'
+        ]
       }
     },
     mounted() {
+      this.token = {
+        'token': sessionStorage.getItem('token')
+      },
       this.itemParameterEntityCopy = this.HaveJson(this.itemParameterData.entity)
       this.testObjectDataEntityCopy = this.HaveJson(this.testObjectData.entity)
       this.selectEnumByCategory()
@@ -339,6 +384,39 @@
       this.getPower('0')
     },
     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 == 201) {
+          this.$message.error(response.message)
+          return
+        }
+        this.$message.success('涓婁紶鎴愬姛')
+        this.standardList = []
+        this.productList = []
+        this.refreshTable()
+      },
+      onError(err, file, fileList) {
+        this.$message.error('涓婁紶澶辫触')
+        this.$refs.upload.clearFiles()
+        this.uploading = false
+      },
+      beforeUpload(file, fileList) {
+        if (file.raw.type != 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
+          this.$message.error('涓婁紶鏂囦欢鏍煎紡涓嶆纭�');
+          this.$refs.upload.clearFiles()
+          return false;
+        }
+      },
       selectorSwitch(radio) {
         if (this.radio === '0') {
           this.showItemParameter = true;
@@ -514,6 +592,7 @@
         let product = false
         let select = 0
         let inPower=false
+        let importExcel = false
         for (var i = 0; i < power.length; i++) {
           if (power[i].menuMethod == 'selectItemParameterList') {
             select += 1
@@ -547,6 +626,9 @@
             if (power[i].menuMethod == 'selectProductListByObjectId') {
               product = true
             }
+            if (power[i].menuMethod == 'importExcel') {
+              importExcel = true
+            }
           }
         }
         if (radio === '0') {
@@ -570,6 +652,7 @@
         this.addPower = add
         this.inPower=inPower
         this.select = select
+        this.importExcel = importExcel
         if (select == 1 || select == 3) this.radio = radio
         else if (select == 2) this.radio = '1'
         else this.radio = '-1'

--
Gitblit v1.9.3