From 7623c217ad57ad1140fbf3b534fdc420ec6e4c08 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期二, 02 十二月 2025 11:15:54 +0800
Subject: [PATCH] 人脸设备标签问题

---
 src/views/system/monitor/face/index.vue |  175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 172 insertions(+), 3 deletions(-)

diff --git a/src/views/system/monitor/face/index.vue b/src/views/system/monitor/face/index.vue
index 328dd48..858227c 100644
--- a/src/views/system/monitor/face/index.vue
+++ b/src/views/system/monitor/face/index.vue
@@ -97,8 +97,8 @@
 
     <div v-hasPermi="['system:monitor:export']">
       <el-button slot="reference" type="primary" size="mini" @click="handleExport" plain >瀵煎嚭</el-button>
+      <el-button style="margin-left: 10px" type="primary" size="mini" @click="openImport" plain>瀵煎叆璁惧鏍囩</el-button>
     </div>
-
     <el-table v-loading="loading" :data="monitorList" @selection-change="handleSelectionChange">
       <el-table-column label="璁惧鍚嶇О" align="center" prop="name" width="280" fixed show-overflow-tooltip/>
       <el-table-column label="璁惧缂栫爜" align="center" prop="serialNumber" width="180"/>
@@ -146,6 +146,11 @@
       <el-table-column label="寤烘ā澶辫触鐜�" align="center" prop="failPercent" width="180" v-if="columns[12].visible"/>
       <el-table-column label="浜鸿劯鍚堟牸鐜�" align="center" prop="facePercent" width="180" v-if="columns[13].visible"/>
       <el-table-column label="澶у浘鍙敤鐜�" align="center" prop="bigUsefulPercent" width="180" v-if="columns[14].visible"/>
+      <el-table-column label="寤鸿绫诲瀷鏍囩" align="center" prop="constructTag" width="180" v-if="columns[15].visible">
+        <template slot-scope="scope">
+          <div>{{ scope.row.tag }}</div>
+        </template>
+      </el-table-column>
       <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width"  fixed="right">
           <template slot-scope="scope">
             <el-button
@@ -274,13 +279,70 @@
         <el-button @click="open = false">鍏� 闂�</el-button>
       </div>
     </el-dialog>
+    <el-dialog
+      title="瀵煎叆璁惧鏍囩"
+      width="800px"
+      :visible.sync="importShow"
+      :close-on-click-modal="false"
+      custom-class="import-dialog"
+    >
+      <div class="import-content">
+        <!-- 涓婁紶鍖哄煙 -->
+        <div class="upload-section">
+          <el-upload
+            ref="upload"
+            class="custom-upload"
+            action=""
+            drag
+            :file-list="fileList"
+            :before-upload="beforeUpload"
+            :on-change="handleFileChange"
+            :on-remove="handleFileRemove"
+            :auto-upload="false"
+            accept=".xls,.xlsx"
+          >
+            <div class="upload-content">
+              <i class="el-icon-upload"></i>
+              <div class="upload-text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+              <div class="upload-tip">鏀寔 .xls 鎴� .xlsx 鏍煎紡鏂囦欢锛屾枃浠跺ぇ灏忎笉瓒呰繃10MB</div>
+            </div>
+          </el-upload>
 
+        </div>
+
+        <!-- 鎿嶄綔鎸夐挳 -->
+        <div class="action-section">
+          <el-button
+            type="primary"
+            size="medium"
+            :loading="upload"
+            @click="handleImport"
+            class="import-btn"
+            :disabled="!currentFile"
+          >
+            {{ upload ? '瀵煎叆涓�...' : '寮�濮嬪鍏�' }}
+          </el-button>
+          <el-button
+            size="medium"
+            @click="downloadTemplate"
+            class="template-btn"
+          >
+            <i class="el-icon-download"></i>涓嬭浇妯℃澘
+          </el-button>
+        </div>
+      </div>
+
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" size="medium" @click="importShow = false">鍏� 闂�</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import { videoCount, listMonitor, getMonitor, delMonitor, addMonitor, updateMonitor } from "@/api/platform/monitor";
 import { listDept } from "@/api/system/dept";
+import { importData } from "@/api/platform/monitorConstruction";
 export default {
   name: "Monitor",
   dicts: ['sys_normal_disable','platform_yes_no','camera_state'],
@@ -303,7 +365,8 @@
         { key: 11, label: `涓婁紶鍙婃椂鐜嘸, visible: false },
         { key: 12, label: `寤烘ā澶辫触鐜嘸, visible: false },
         { key: 13, label: `浜鸿劯鍚堟牸鐜嘸, visible: false },
-        { key: 14, label: `澶у浘涓嶅彲鐢ㄩ噺`, visible: false }
+        { key: 14, label: `澶у浘涓嶅彲鐢ㄩ噺`, visible: false },
+        {key: 15, label: `寤鸿绫诲瀷`, visible: true}
       ],
       count: {
         totalPosts: 0,
@@ -361,7 +424,12 @@
         address: [
           { required: true, message: "鍦板潃涓嶈兘涓虹┖", trigger: "blur" }
         ],
-      }
+      },
+
+      importShow: false,
+      upload: false,
+      fileList: [],
+      currentFile: null,
     };
   },
   created() {
@@ -372,6 +440,63 @@
     });
   },
   methods: {
+    beforeUpload(file) {
+      // 鏂囦欢楠岃瘉閫昏緫
+      const isExcel = file.type.includes('spreadsheet') ||
+        file.name.endsWith('.xls') ||
+        file.name.endsWith('.xlsx');
+      const isLt10M = file.size / 1024 / 1024 < 10;
+
+      if (!isExcel) {
+        this.$message.error('鍙兘涓婁紶 Excel 鏂囦欢!');
+        return false;
+      }
+      if (!isLt10M) {
+        this.$message.error('鏂囦欢澶у皬涓嶈兘瓒呰繃 10MB!');
+        return false;
+      }
+
+      return true;
+    },
+    handleFileRemove(){
+      this.currentFile = null;
+    },
+    handleFileChange(file, fileList) {
+      this.currentFile = file;
+    },
+
+    async handleImport() {
+      if (!this.currentFile) {
+        this.$message.warning('璇峰厛閫夋嫨瑕佸鍏ョ殑鏂囦欢');
+        return;
+      }
+
+      this.upload = true;
+      // 杩欓噷鎵ц涓婁紶閫昏緫
+      // 涓婁紶瀹屾垚鍚�
+      const formData = new FormData();
+      formData.append('file', this.currentFile.raw);
+
+      await importData(formData).then(res =>{
+        if (res.code === 200){
+          this.$message.success("瀵煎叆鎴愬姛");
+        }
+      })
+      this.upload = false;
+      this.importShow = false;
+    },
+
+    downloadTemplate() {
+      // 涓嬭浇妯℃澘鏂囦欢閫昏緫
+      this.download("monitorConstruction/importTemplate", {}, `璁惧鏍囩妯℃澘.xlsx`);
+    },
+    openImport(){
+      this.fileList = []
+      this.currentFile = null;
+      this.importShow = true;
+      this.upload = false;
+
+    },
     clickTab(active) {
       if (active === 0) {
         this.queryParams.provinceTag = true
@@ -500,6 +625,50 @@
 </script>
 
 <style lang="scss" scoped>
+.custom-upload{
+  width: 100%;
+  height: 100%;
+
+}
+.custom-upload ::v-deep .el-upload-dragger {
+  width: 500px;
+  height: 200px;
+  padding: 0; /* 绉婚櫎榛樿鐨勫唴杈硅窛 */
+  margin: 0 0 0 125px;
+}
+
+.custom-upload ::v-deep .el-upload-dragger .el-icon-upload {
+  margin-top: 0; /* 璋冩暣鍥炬爣鐨勪笂杈硅窛 */
+}
+
+/* 纭繚鑷畾涔夊唴瀹瑰尯鍩熷厖婊℃暣涓嫋鎷藉尯鍩� */
+.custom-upload .upload-content {
+  width: 100%;
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  align-items: center;
+}
+.action-section {
+  display: flex;
+  justify-content: center;
+  gap: 15px;
+  margin-top: 25px;
+}
+.import-content {
+  padding: 10px 0;
+}
+.upload-section {
+  width: 100%;
+  margin-bottom: 20px;
+}
+.el-upload{
+  width: 100%;
+}
+.el-upload .el-upload-dragger{
+  width: 100%;
+}
 .tab {
   padding: 5px 15px;
 }

--
Gitblit v1.8.0