From 3c6bdb6f439ff7af04765259fd6a91b6d201d095 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期四, 19 六月 2025 17:12:25 +0800
Subject: [PATCH] 工单,数据中心用户查看数据的权限,合同考核每日,以及导出每日和按月

---
 src/views/system/work-order/threshold/index.vue |  373 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 291 insertions(+), 82 deletions(-)

diff --git a/src/views/system/work-order/threshold/index.vue b/src/views/system/work-order/threshold/index.vue
index 5f98f68..2f38eae 100644
--- a/src/views/system/work-order/threshold/index.vue
+++ b/src/views/system/work-order/threshold/index.vue
@@ -26,14 +26,14 @@
                 v-hasPermi="['ycl:threshold:edit']"
                 @click="showEdit('video')"
                 v-if="!ifEditVideo"
-                >淇敼
+              >淇敼
               </el-button>
               <el-button
                 size="mini"
                 type="primary"
                 @click="saveEdit('video')"
                 v-if="ifEditVideo"
-                >淇濆瓨
+              >淇濆瓨
               </el-button>
             </div>
           </div>
@@ -45,6 +45,7 @@
               justify-content: space-between;
             "
           >
+
             <div>
               <div
                 style="
@@ -64,13 +65,13 @@
                     :key="item.id"
                   >
                     <el-input
-                      v-model="videoList[index].value"
+                      v-model="videoList[index].valueAuto"
                       size="mini"
                       style="width: 100px"
                       :type="item.countType=='int'?'number':''"
                       v-if="ifEditVideo"
                     ></el-input>
-                    <span v-else>{{ item.value }}</span>
+                    <span v-else>{{ item.valueAuto }}</span>
                     <span class="unit" v-if="item.countType=='percent'">%</span>
                     <span class="unit" v-if="item.countType=='second'">绉�</span>
                   </el-form-item>
@@ -87,13 +88,13 @@
                     :key="item.id"
                   >
                     <el-input
-                      v-model="videoList[index].valueAuto"
+                      v-model="videoList[index].value"
                       size="mini"
                       style="width: 100px"
                       :type="item.countType=='int'?'number':''"
                       v-if="ifEditVideo"
                     ></el-input>
-                    <span v-else>{{ item.valueAuto }}</span>
+                    <span v-else>{{ item.value }}</span>
                     <span class="unit" v-if="item.countType=='percent'">%</span>
                     <span class="unit" v-if="item.countType=='second'">绉�</span>
                   </el-form-item>
@@ -115,14 +116,14 @@
                 v-hasPermi="['ycl:threshold:edit']"
                 @click="showEdit('face')"
                 v-if="!ifEditFace"
-                >淇敼
+              >淇敼
               </el-button>
               <el-button
                 size="mini"
                 type="primary"
                 @click="saveEdit('face')"
                 v-if="ifEditFace"
-                >淇濆瓨
+              >淇濆瓨
               </el-button>
             </div>
           </div>
@@ -153,13 +154,13 @@
                     :key="item.id"
                   >
                     <el-input
-                      v-model="faceList[index].value"
+                      v-model="faceList[index].valueAuto"
                       size="mini"
                       style="width: 100px"
                       :type="item.countType=='int'?'number':''"
                       v-if="ifEditFace"
                     ></el-input>
-                    <span v-else>{{ item.value }}</span>
+                    <span v-else>{{ item.valueAuto }}</span>
                     <span class="unit" v-if="item.countType=='percent'">%</span>
                     <span class="unit" v-if="item.countType=='second'">绉�</span>
                   </el-form-item>
@@ -176,22 +177,23 @@
                     :key="item.id"
                   >
                     <el-input
-                      v-model="faceList[index].valueAuto"
+                      v-model="faceList[index].value"
                       size="mini"
                       style="width: 100px"
                       :type="item.countType=='int'?'number':''"
                       v-if="ifEditFace"
                     ></el-input>
-                    <span v-else>{{ item.valueAuto }}</span>
+                    <span v-else>{{ item.value }}</span>
                     <span class="unit" v-if="item.countType=='percent'">%</span>
                     <span class="unit" v-if="item.countType=='second'">绉�</span>
-                    </el-form-item
+                  </el-form-item
                   >
                 </el-form>
               </div>
             </div>
           </div>
-        </el-card></el-col
+        </el-card>
+      </el-col
       >
       <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
         <el-card style="margin-bottom: 20px; height: 350px; margin-right: 20px;color: #656565;">
@@ -205,14 +207,14 @@
                 v-hasPermi="['ycl:threshold:edit']"
                 @click="showEdit('car')"
                 v-if="!ifEditCar"
-                >淇敼
+              >淇敼
               </el-button>
               <el-button
                 size="mini"
                 type="primary"
                 @click="saveEdit('car')"
                 v-if="ifEditCar"
-                >淇濆瓨
+              >淇濆瓨
               </el-button>
             </div>
           </div>
@@ -243,13 +245,13 @@
                     :key="item.id"
                   >
                     <el-input
-                      v-model="carList[index].value"
+                      v-model="carList[index].valueAuto"
                       size="mini"
                       style="width: 100px"
                       :type="item.countType=='int'?'number':''"
                       v-if="ifEditCar"
                     ></el-input>
-                    <span v-else>{{ item.value }}</span>
+                    <span v-else>{{ item.valueAuto }}</span>
                     <span class="unit" v-if="item.countType=='percent'">%</span>
                     <span class="unit" v-if="item.countType=='second'">绉�</span>
                   </el-form-item>
@@ -266,13 +268,13 @@
                     :key="item.id"
                   >
                     <el-input
-                      v-model="carList[index].valueAuto"
+                      v-model="carList[index].value"
                       size="mini"
                       style="width: 100px"
                       :type="item.countType=='int'?'number':''"
                       v-if="ifEditCar"
                     ></el-input>
-                    <span v-else>{{ item.valueAuto }}</span>
+                    <span v-else>{{ item.value }}</span>
                     <span class="unit" v-if="item.countType=='percent'">%</span>
                     <span class="unit" v-if="item.countType=='second'">绉�</span>
                   </el-form-item>
@@ -280,24 +282,18 @@
               </div>
             </div>
           </div>
-        </el-card></el-col
+        </el-card>
+      </el-col
       >
     </el-row>
+
     <el-row class="content-warp">
-      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
-        <el-form-item label="璁惧缂栫爜" prop="serialNumber">
+      <div class="header鈥攖ext" style="margin-bottom: 5px">宸ュ崟鐧藉悕鍗�</div>
+      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" @submit.native.prevent>
+        <el-form-item label="鍏抽敭瀛�" prop="keyword">
           <el-input
-            v-model="queryParams.serialNumber"
-            placeholder="璁惧缂栫爜"
-            clearable
-            @keyup.enter.native="getWhiteList"
-            @clear="getWhiteList"
-          />
-        </el-form-item>
-        <el-form-item label="鐐逛綅鍚嶇О" prop="pointName">
-          <el-input
-            v-model="queryParams.pointName"
-            placeholder="鐐逛綅鍚嶇О"
+            v-model="queryParams.keyword"
+            placeholder="璁惧缂栫爜/鐐逛綅鍚�"
             clearable
             @keyup.enter.native="getWhiteList"
             @clear="getWhiteList"
@@ -309,22 +305,76 @@
       </el-form>
     </el-row>
     <el-row class="content-warp">
-      <el-button size="small" type="success" @click="addOpen">鏂板</el-button>
-      <el-button size="small" type="danger" @click="bathDelete">鍒犻櫎</el-button>
+      <el-button size="small" type="success" @click="whiteOpen" plain>鏂板</el-button>
+      <el-button size="small" type="danger" @click="bathDelete" plain>鍒犻櫎</el-button>
+      <el-button type="primary" plain icon="el-icon-top" v-loading="download" size="mini" @click="handleExport"
+      >瀵煎嚭鐧藉悕鍗�
+      </el-button>
+      <el-popover style="margin-left: 10px" placement="bottom" trigger="hover" content="瀵煎叆鐧藉悕鍗�">
+        <div class="bottom_">
+          <el-upload
+            ref="upload"
+            class="upload-demo"
+            drag
+            :action="importUrl"
+            :file-list="fileList"
+            :before-upload="beforeUpload"
+          >
+            <i class="el-icon-upload"></i>
+            <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+            <div class="el-upload__tip" slot="tip">鍙兘涓婁紶xls/xlsx鏂囦欢</div>
+          </el-upload>
+        </div>
+        <div>
+          <el-button class="bottom_" type="primary" size="small" v-loading="upload" @click="handleImport"
+          >瀵煎叆
+          </el-button>
+        </div>
+        <el-button type="primary" size="small" plain icon="el-icon-bottom" slot="reference">瀵煎叆鐧藉悕鍗�</el-button>
+      </el-popover>
+
+      <el-popover style="margin-left: 10px" placement="bottom" content="娣诲姞鏁呴殰绫诲瀷">
+        <div class="bottom_">
+          <el-form ref = "addErrorForm" :model="addErrorForm" v-loading="addErrorLoading" rules="addErrorFormRules" :inline="true" >
+            <el-form-item label="鏁呴殰绫诲瀷" prop="errorTypeList">
+              <el-select v-model="addErrorForm.errorTypeList" multiple>
+                <el-option v-for="dict in dict.type.error_type"
+                           :value="dict.value"
+                           :key="dict.value"
+                           :label="dict.label"/>
+              </el-select>
+            </el-form-item>
+          </el-form>
+        </div>
+        <div>
+          <el-button class="bottom_" type="primary" size="small" @click="addError" plain>纭</el-button>
+        </div>
+        <el-button style="margin-left: 10px" size="small" type="primary" slot="reference" plain>娣诲姞鏁呴殰绫诲瀷</el-button>
+      </el-popover>
+
     </el-row>
+
     <el-row class="content-warp">
       <el-col :span="24">
         <el-table v-loading="loading" :data="workOrderWhiteList" @selection-change="handleSelectionChange">
           <el-table-column type="selection" width="55" align="center" prop="id"/>
           <el-table-column label="璁惧缂栫爜" align="center" prop="serialNumber"/>
           <el-table-column label="鐐逛綅鍚嶇О" align="center" prop="pointName"/>
-          <el-table-column label="鍒涘缓浜�" align="center" prop="createBy"/>
+          <el-table-column label="鏁呴殰绫诲瀷" align="center" prop="errorType"/>
           <el-table-column label="澶囨敞" align="center" prop="remark"/>
+          <el-table-column label="鎿嶄綔" align="center" fixed="right" class-name="small-padding fixed-width">
+            <template slot-scope="scope">
+              <el-button size="mini" type="text" icon="el-icon-edit" @click="handleWhiteUpdate(scope.row)"
+              >淇敼
+              </el-button>
+            </template>
+          </el-table-column>
         </el-table>
 
         <pagination
           v-show="total>0"
           :total="total"
+          :auto-scroll="false"
           :page.sync="queryParams.pageNum"
           :limit.sync="queryParams.pageSize"
           @pagination="getWhiteList"
@@ -332,29 +382,56 @@
       </el-col>
     </el-row>
 
-<!--    鏂板鐧藉悕鍗�-->
+    <!--    鏂板鐧藉悕鍗�-->
     <el-dialog
-      title="鏂板鐧藉悕鍗�"
-      :visible.sync="addShow"
+      :title="title"
+      :visible.sync="whiteShow"
       width="500px"
       :close-on-click-modal="false"
-      :before-close="addClose">
+      :before-close="whiteClose">
       <div>
-        <el-form :model="addForm" label-position="top" :rules="addFormRules" ref="addForm" size="small">
-          <el-form-item label="璁惧缂栫爜" prop="serialNumber">
-            <el-input v-model="addForm.serialNumber"></el-input>
+        <el-form :model="whiteForm" label-position="top" :rules="whiteFormRules" ref="whiteForm" size="small"
+                 class="add-form">
+          <el-form-item label="鐐逛綅" prop="serialNumber">
+            <el-select
+              v-model="whiteForm.pointName"
+              filterable
+              remote
+              reserve-keyword
+              :disabled="whiteForm.id"
+              placeholder="鍥芥爣鐮�/鐐逛綅鍚嶇О鎼滅储"
+              :remote-method="remoteGetPoints"
+              @change="setPointId"
+              :loading="selectLoading"
+              style="width: 460px">
+              <el-option
+                v-for="item in pointList"
+                :key="item.id"
+                :label="item.value"
+                :value="item.value">
+              </el-option>
+            </el-select>
+          </el-form-item>
+          <el-form-item label="鏁呴殰绫诲瀷" prop="errorTypeList">
+            <el-select v-model="whiteForm.errorTypeList" multiple>
+              <el-option v-for="dict in dict.type.error_type"
+                         :value="dict.value"
+                         :key="dict.value"
+                         :label="dict.label"/>
+            </el-select>
           </el-form-item>
           <el-form-item label="澶囨敞淇℃伅" prop="remark">
-            <el-input v-model="addForm.remark"></el-input>
+            <el-input v-model="whiteForm.remark"></el-input>
           </el-form-item>
         </el-form>
       </div>
       <span slot="footer" class="dialog-footer">
-        <el-button @click="addClose">鍙� 娑�</el-button>
-        <el-button type="primary" @click="addSubmit">鏂� 澧�</el-button>
+        <el-button @click="whiteClose">鍙� 娑�</el-button>
+        <el-button type="primary" @click="whiteSubmit">纭� 瀹�</el-button>
       </span>
     </el-dialog>
   </div>
+
 </template>
 
 <script>
@@ -362,29 +439,38 @@
   listThreshold,
   getThreshold,
   updateThreshold,
-} from "@/api/platform/threshold";
-import {
+  importData,
   editCar,
   editFace,
   getCar,
   getFace,
   getVideo,
-} from "../../../../api/platform/threshold";
-
-import {
   getWhiteList,
+  getWhite,
   addWhiteList,
   bathDelete,
-} from "@/api/platform/work-order";
+  updateWhite,
+  whiteExport
+} from "@/api/platform/threshold";
+
+import {pointSelectData} from "@/api/platform/point";
+import {addError} from "../../../../api/platform/threshold";
 
 export default {
-  dicts: ["image_qualify", "video_qualify"],
+  dicts: ["image_qualify", "video_qualify", "error_type"],
   name: "Threshold",
   data() {
     return {
+      download: false,
+      addErrorLoading: false,
+      scrollPosition: 0, // 鐢ㄤ簬淇濆瓨婊氬姩浣嶇疆
+      // 涓嬫媺鍔犺浇
+      selectLoading: false,
       ifEditVideo: false,
       ifEditFace: false,
       ifEditCar: false,
+      // 鐐逛綅list
+      pointList: [],
       indicators: [],
       // 閬僵灞�
       loading: true,
@@ -421,6 +507,13 @@
       videoForm: {},
       carForm: {},
       faceForm: {},
+      addErrorForm: {},
+      // 鏂板妗嗘牎楠�
+      addErrorFormRules: {
+        errorTypeList: [
+          {required: true, message: "璇烽�夋嫨鏁呴殰绫诲瀷", trigger: "blur"}
+        ],
+      },
       // 琛ㄥ崟鏍¢獙
       faceRules: {
         monitorType: [
@@ -489,17 +582,25 @@
       // 鐧藉悕鍗曞垪琛�
       workOrderWhiteList: [],
       // 鏂板妗�
-      addShow: false,
-      addForm: {
+      whiteShow: false,
+      whiteForm: {
         serialNumber: "",
         remark: "",
       },
       // 鏂板妗嗘牎楠�
-      addFormRules: {
+      whiteFormRules: {
         serialNumber: [
-          {required: true, message: "璁惧缂栫爜涓嶈兘涓虹┖", trigger: "blur"},
+          {required: true, message: "璁惧涓嶈兘涓虹┖", trigger: "blur"},
+        ],
+        errorTypeList: [
+          {required: true, message: "璇烽�夋嫨鏁呴殰绫诲瀷", trigger: "blur"}
         ],
       },
+      // 瀵煎叆鏂囦欢璺緞
+      importUrl: '',
+      fileList: [],
+      importFile: null,
+      upload: false,
     };
   },
   created() {
@@ -507,6 +608,43 @@
     this.getWhiteList();
   },
   methods: {
+    setPointId(selectedValue) {
+      const selectedItem = this.pointList.find(item => item.value === selectedValue);
+      this.whiteForm.serialNumber = selectedItem.id
+    },
+    // 杩滅▼鎼滅储鐐逛綅
+    remoteGetPoints(query) {
+      if (query !== '') {
+        this.selectLoading = true;
+        let data = {
+          "keyword": query
+        }
+        pointSelectData(data).then(res => {
+          this.pointList = res.data;
+          this.selectLoading = false;
+        })
+      } else {
+        this.pointList = [];
+      }
+    },
+    handleExport() {
+      this.download = true
+      whiteExport().then(res => {
+        // 灏嗕簩杩涘埗鏁版嵁杞崲涓� Blob 瀵硅薄
+        let blob = new Blob([res], {type: 'application/octet-stream'});
+
+        // 鍒涘缓涓嬭浇閾炬帴
+        let downloadLink = document.createElement('a');
+        downloadLink.href = URL.createObjectURL(blob);
+        downloadLink.setAttribute('download', "宸ュ崟鐧藉悕鍗曟竻鍗�.xlsx"); // 璁剧疆涓嬭浇鏂囦欢鐨勬枃浠跺悕
+        downloadLink.style.display = 'none';
+        // 娣诲姞鍒伴〉闈㈠苟瑙﹀彂涓嬭浇
+        document.body.appendChild(downloadLink);
+        downloadLink.click();
+        document.body.removeChild(downloadLink);
+        this.download = false
+      })
+    },
     showEdit(value) {
       if (value == "video") {
         this.videoList = JSON.parse(JSON.stringify(this.thresholdList.video));
@@ -602,6 +740,7 @@
       });
     },
     getWhiteList() {
+      // 淇濆瓨褰撳墠婊氬姩浣嶇疆
       this.loading = true;
       getWhiteList(this.queryParams).then((response) => {
         this.workOrderWhiteList = response.data;
@@ -716,16 +855,16 @@
         });
       }
     },
-    handleUpdate(row) {
-      this.reset();
-      const id = row.id || this.ids;
-      getThreshold(id).then((response) => {
-        this.form = response.data;
-        this.indicators = JSON.parse(this.form.indicator);
-        this.videoOpen = true;
-        this.title = "淇敼杩愮淮闃堝��";
-      });
-    },
+    // handleUpdate(row) {
+    //   this.reset();
+    //   const id = row.id || this.ids;
+    //   getThreshold(id).then((response) => {
+    //     this.form = response.data;
+    //     this.indicators = JSON.parse(this.form.indicator);
+    //     this.videoOpen = true;
+    //     this.title = "淇敼杩愮淮闃堝��";
+    //   });
+    // },
     /** 鎻愪氦鎸夐挳 */
     submitForm() {
       this.$refs["form"].validate((valid) => {
@@ -853,33 +992,66 @@
       }
     },
     // 鎵撳紑鏂板妗�
-    addOpen() {
-      this.addShow = true;
+    whiteOpen() {
+      this.title = "鏂板鐧藉悕鍗�"
+      this.whiteShow = true;
     },
     // 鍏抽棴鏂板妗�
-    addClose() {
-      this.addShow = false;
-      this.addReset();
+    whiteClose() {
+      this.whiteShow = false;
+      this.whiteReset();
     },
-    // 鏂板妗嗘彁浜�
-    addSubmit() {
-      this.$refs["addForm"].validate((valid) => {
+    // 鏂板鏁呴殰绫诲瀷
+    addError() {
+      this.$refs["addErrorForm"].validate((valid) => {
         if (valid) {
-          addWhiteList(this.addForm).then((response) => {
-            this.$modal.msgSuccess("鏂板鎴愬姛");
-            this.addShow = false;
+          this.addErrorLoading = true
+          addError(this.addErrorForm).then((response) => {
+            this.$modal.msgSuccess("娣诲姞鎴愬姛");
             this.getWhiteList();
-            this.addReset();
           });
+          this.addErrorLoading = false
+        }
+      });
+    },
+    // 鐧藉悕鍗曟鎻愪氦
+    whiteSubmit() {
+      this.$refs["whiteForm"].validate((valid) => {
+        if (valid) {
+          if (this.whiteForm.id != null) {
+            updateWhite(this.whiteForm).then((response) => {
+              this.$modal.msgSuccess("淇敼鎴愬姛");
+              this.whiteShow = false;
+              this.getWhiteList();
+              this.whiteReset();
+            });
+          } else {
+            addWhiteList(this.whiteForm).then((response) => {
+              this.$modal.msgSuccess("鏂板鎴愬姛");
+              this.whiteShow = false;
+              this.getWhiteList();
+              this.whiteReset();
+            });
+          }
         }
       });
     },
     // 鏂板妗嗛噸缃�
-    addReset() {
-      this.addForm = {
+    whiteReset() {
+      this.whiteForm = {
         serialNumber: "",
         remark: "",
       };
+    },
+    /** 淇敼鎸夐挳鎿嶄綔 */
+    handleWhiteUpdate(row) {
+      this.whiteReset();
+      const id = row.id
+      getWhite(id).then(response => {
+        this.whiteForm = response.data;
+        this.title = "淇敼鐧藉悕鍗�";
+        this.whiteShow = true;
+      });
     },
     // 澶氶�夋閫変腑鏁版嵁
     handleSelectionChange(selection) {
@@ -894,25 +1066,52 @@
         this.$modal.msgSuccess("鎵归噺鍒犻櫎鎴愬姛");
         this.ids = [];
       })
+    },
+    beforeUpload(file) {
+      this.importFile = file
+      this.fileList = [file]
+      return false
+    },
+    // 瀵煎叆鐧藉悕鍗�
+    handleImport() {
+      this.upload = true;
+      let formData = new FormData()
+      formData.append("file", this.importFile)
+      importData(formData).then(res => {
+        this.$message.success("瀵煎叆鎴愬姛")
+        this.upload = false
+        this.fileList = []
+        this.getWhiteList()
+      }).catch(() => {
+        this.upload = false
+      })
     }
   }
 };
 </script>
 <style scoped>
+.add-form /deep/ .el-form-item {
+  margin-bottom: 20px;
+}
+
 ::v-deep .el-input-half-width {
   width: calc(50% - 6px); /* 鍑忓幓涓�浜涢棿闅� */
 }
+
 ::v-deep .table-row {
   display: flex;
   flex-direction: row;
 }
+
 ::v-deep .table-row-item {
   width: 120px;
   text-align: center;
 }
+
 .fixedWidth {
   width: 200px;
 }
+
 .threshold {
   display: flex;
   flex-direction: row;
@@ -922,17 +1121,27 @@
   font-weight: bold;
   font-size: large;
 }
+
 ::v-deep .el-form-item {
   margin-bottom: 0px; /* 鏍规嵁闇�姹傝皟鏁磋繖涓�� */
 }
+
 ::v-deep .el-form-item__label {
   color: #8d8d8d;
 }
+
 .unit {
   margin-left: 5px;
   display: inline-block;
 }
+
 .content-warp {
   margin-top: 10px;
 }
+
+.bottom_ {
+  width: 100%;
+  margin-bottom: 8px;
+}
+
 </style>

--
Gitblit v1.8.0