From b9bd29a1a81f6f7de479e3cc3fdfe3d85fc660bf Mon Sep 17 00:00:00 2001
From: he wei <858544502@qq.com>
Date: 星期三, 23 四月 2025 13:35:06 +0800
Subject: [PATCH] UA 整理提交

---
 src/views/device/locks/index.vue |  235 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 140 insertions(+), 95 deletions(-)

diff --git a/src/views/device/locks/index.vue b/src/views/device/locks/index.vue
index 3380742..0f686bb 100644
--- a/src/views/device/locks/index.vue
+++ b/src/views/device/locks/index.vue
@@ -1,29 +1,35 @@
 <script setup name="LockManage">
-	import { ref, onMounted, reactive, computed, watchEffect } from "vue";
-	// import const_theme from "@/utils/const/const_theme";
-	import store from "@/store";
+	import { ref, onMounted, reactive, computed, watchEffect, nextTick } from "vue";
+	import useStation from "@/hooks/useStationList.js";
+	const { stationName1, stationName2, stationName3, stationName4,
+		stationList1, stationList2, stationList3, stationList4,
+	} = useStation();
 
-	import { Search, Plus } from "@element-plus/icons-vue";
-	// import HdwTree from "@/components/HdwTree/index.vue";
 	import {
 		getAllLockInf,
 		delLock,
 		lockOpen,
+    openLockBl,
+    closeLockBl
 	} from '@/api/lockManager.js';
+  import { storeToRefs } from "pinia";
 
+import { useUserStore } from '@/store/user.js';
+const userStore = useUserStore();
+const { urole, permits } = storeToRefs(userStore);
 	import useWebSocket from "@/hooks/useWebsocket.js";
+  import isHasPermit from '@/utils/isHasPermit';
 
 	import addEdit from './addEdit.vue';
 	import useElement from "@/hooks/useElement.js";
 
-	const { $loading, $message, $confirm } = useElement();
+	const { $loading, $message, $confirm, $confirmPwdDo } = useElement();
 	const { sendData, message: listMessage } = useWebSocket("lockRt");
 
 	const disabled = ref(false);
 	const background = ref(false);
 	const addEditVisible = ref(false);
 	const isAdd = ref(false);
-	const isBatch = ref(false);
 
 	const currentAreaId = ref();
 
@@ -48,26 +54,27 @@
 	// 褰撳墠缂栬緫鐨勯攣瀵硅薄
 	const editLock = ref();
 
-	const isAdmin = computed(() => store.user().urole > 0);
+  // 鏄惁鏈夋帶鍒舵潈闄�
+let isCanControl = isHasPermit("control_permit", permits.value);
 
 	onMounted(() => {
+		// setTimeout(() => {
+		// 	console.log('onMounted', stationName1, stationName2, stationName3, stationName4, '=============');
 
+		// }, 2000);
+    sendMessage();
 	});
 
-	// function handleChangeTheme(val) {
-	//   console.log(val);
-	//   store.settings().changeSetting({
-	//     key: "theme",
-	//     value: val,
-	//   });
-	// }
 
 	function sendMessage() {
 		let params = {
-			areaId: currentAreaId.value,
 			lockName: filter.name.trim() || undefined,
 			lockState: filter.state,
-			lockType: filter.type,
+			// lockType: filter.type,
+      stationName1: stationName1.value || undefined,
+      stationName2: stationName2.value || undefined,
+      stationName3: stationName3.value || undefined,
+      stationName4: stationName4.value || undefined,
 			pageNum: page.pageNum,
 			pageSize: page.pageSize,
 		};
@@ -76,12 +83,6 @@
 		);
 	}
 
-	function itemClickHandler(item) {
-		console.log(item, '====item', item.data);
-		// areaId lockName lockState lockType pageNum pageSize
-		currentAreaId.value = item.data.id;
-		sendMessage();
-	}
 
 	watchEffect(() => {
 		let _total = 0;
@@ -89,26 +90,26 @@
 		if (listMessage.value) {
 			const {
 				code,
-        data,
+				data,
 				data2
 			} = JSON.parse(listMessage.value);
 
-    if (code && data) {
-      let { list, total } = data2;
-      _list = list.map(v => {
-        v.state = { '-1': '鏈畨瑁�', 0: '宸查棴閿�', 1: '宸插紑閿�' }[v.lockState];
-        v.onlineState = { 0: '绂荤嚎', 1: '鍦ㄧ嚎' }[v.lockOnline];
-        v.type = { 1: '钃濈墮閿�', 2: 'ID閿�', 3: '瀹炰綋閿�' }[v.lockType];
-        v.modelStr = v.model == 1 ? '鍦ㄧ嚎妯″紡' : '绂荤嚎妯″紡';
-        v.blStateStr = v.blState == 0 ? '钃濈墮鍏抽棴' : '钃濈墮寮�鍚�';
-        v.ID = v.lockId % 10000000;
-        return v;
-      });
-      _total = total;
-    }
+			if (code && data) {
+				let { list, total } = data2;
+				_list = list.map(v => {
+					v.state = { 0: '宸查棴閿�', 1: '宸插紑閿�' }[v.lockState];
+					v.onlineState = { 0: '绂荤嚎', 1: '鍦ㄧ嚎' }[v.lockOnline];
+					// v.type = { 1: '钃濈墮閿�', 2: 'ID閿�', 3: '瀹炰綋閿�' }[v.lockType];
+					v.modelStr = v.model == 1 ? '鍦ㄧ嚎妯″紡' : '绂荤嚎妯″紡';
+					v.blStateStr = v.blState == 0 ? '钃濈墮鍏抽棴' : '钃濈墮寮�鍚�';
+					v.ID = v.lockId % 10000000;
+					return v;
+				});
+				_total = total;
+			}
 		}
-    tableData.value = _list;
-    page.total = _total;
+		tableData.value = _list;
+		page.total = _total;
 	});
 
 
@@ -129,7 +130,6 @@
 		} = scope;
 		editLock.value = row;
 		addEditTitle.value = '淇敼閿佸叿';
-		isBatch.value = false;
 		isAdd.value = false;
 		addEditVisible.value = true;
 	}
@@ -141,13 +141,11 @@
 
 	function add() {
 		isAdd.value = true;
-		isBatch.value = false;
 		addEditVisible.value = true;
 	}
 
 	function batchAdd() {
 		isAdd.value = true;
-		isBatch.value = true;
 		addEditVisible.value = true;
 	}
 
@@ -162,7 +160,7 @@
 		let {
 			row
 		} = scope;
-		$confirm("杩滅▼鎵撳紑璇ラ攣鍏�", () => {
+    $confirmPwdDo(() => {
 			let loading = $loading();
 			lockOpen(scope.row.lockId).then((res) => {
 				let { code, data } = res;
@@ -180,6 +178,7 @@
 				});
 
 		});
+
 	}
 
 	function del(id) {
@@ -200,25 +199,102 @@
 			});
 
 	}
+
+  function openBl(scope) {
+    $confirmPwdDo(() => {
+      let loading = $loading();
+      openLockBl(
+        scope.row.lockId
+      ).then((res) => {
+        let { code, data } = res;
+        loading.close();
+        if (code && data) {
+          console.log(data);
+          $message.success("鎿嶄綔鎴愬姛");
+          sendMessage();
+        } else {
+          $message.error("鎿嶄綔澶辫触");
+        }
+      })
+        .catch((err) => {
+          loading.close();
+          console.log(err);
+        });
+    });
+}
+
+function closeBl(scope) {
+  $confirmPwdDo(() => {
+    let loading = $loading();
+    closeLockBl(
+      scope.row.lockId
+    ).then((res) => {
+      let { code, data } = res;
+      loading.close();
+      if (code && data) {
+        console.log(data);
+        $message.success("鎿嶄綔鎴愬姛");
+        sendMessage();
+      } else {
+        $message.error("鎿嶄綔澶辫触");
+      }
+    })
+      .catch((err) => {
+        loading.close();
+        console.log(err);
+      });
+  });
+}
 </script>
 
 <template>
   <div class="page-wrapper">
-    <div class="page-header">
-      <div class="hdw-card-container">
-        <hdw-card title="鍖哄煙鍒楄〃" is-full>
-          <hdw-tree @item-click="itemClickHandler"></hdw-tree>
-        </hdw-card>
-      </div>
-    </div>
+    <div class="page-header"></div>
     <div class="page-content">
-      <hdw-card is-full>
+      <yc-card is-full>
         <div class="page-content-wrapper">
           <div class="page-content-tools">
-            <el-button type="primary" size="small" :icon="Plus" @click="add">娣诲姞</el-button>
-            <el-button type="primary" size="small" :icon="Plus" @click="batchAdd">鎵归噺娣诲姞</el-button>
+            <el-button type="primary" size="small" @click="add"><svg-icon icon-class="add"></svg-icon>娣诲姞</el-button>
+            <!-- <el-button type="primary" size="small" :icon="Plus" @click="batchAdd">鎵归噺娣诲姞</el-button> -->
             |
             <div class="tools-filter">
+              <div class="tools-filter-item">
+                <div class="filter-label">鐪侊細</div>
+                <div class="filter-content">
+                  <el-select v-model="stationName1" clearable  placeholder="璇烽�夋嫨" @change="() => nextTick(() => sendMessage())" size="small"
+                    style="width: 180px">
+                    <el-option v-for="(item, idx) in stationList1" :key="'province_' + idx" :label="item" :value="item" />
+                  </el-select>
+                </div>
+              </div>
+              <div class="tools-filter-item">
+                <div class="filter-label">甯傦細</div>
+                <div class="filter-content">
+                  <el-select v-model="stationName2" clearable  placeholder="璇烽�夋嫨" @change="() => nextTick(() => sendMessage())" size="small"
+                    style="width: 180px">
+                    <el-option v-for="(item, idx) in stationList2" :key="'city_' + idx" :label="item" :value="item" />
+                  </el-select>
+                </div>
+              </div>
+              <div class="tools-filter-item">
+                <div class="filter-label">鍖哄幙锛�</div>
+                <div class="filter-content">
+                  <el-select v-model="stationName3" clearable placeholder="璇烽�夋嫨" @change="() => nextTick(() => sendMessage())" size="small"
+                    style="width: 180px">
+                    <el-option v-for="(item, idx) in stationList3" :key="'list2_' + idx" :label="item" :value="item" />
+                  </el-select>
+                </div>
+              </div>
+              <div class="tools-filter-item">
+                <div class="filter-label">鏈烘埧锛�</div>
+                <div class="filter-content">
+                  <el-select v-model="stationName4" clearable placeholder="璇烽�夋嫨" @change="() => nextTick(() => sendMessage())" size="small"
+                    style="width: 180px">
+                    <el-option v-for="(item, idx) in stationList4" :key="'list3_' + idx" :label="item" :value="item" />
+                  </el-select>
+                </div>
+              </div>
+
               <div class="tools-filter-item">
                 <div class="filter-label">閿佸叿鍚嶇О锛�</div>
                 <div class="filter-content">
@@ -231,68 +307,37 @@
                   <el-select v-model="filter.state" placeholder="璇烽�夋嫨" @change="sendMessage" size="small"
                     style="width: 180px">
                     <el-option label="--璇烽�夋嫨--" value="" />
-                    <el-option label="鏈畨瑁�" :value="-1" />
                     <el-option label="闂攣" :value="0" />
                     <el-option label="寮�閿�" :value="1" />
                   </el-select>
                 </div>
               </div>
-              <div class="tools-filter-item">
-                <div class="filter-label">閿佸叿绫诲瀷锛�</div>
-                <div class="filter-content">
-                  <el-select v-model="filter.type" @change="sendMessage" placeholder="璇烽�夋嫨" size="small"
-                    style="width: 180px">
-                    <el-option label="--璇烽�夋嫨--" value="" />
-                    <el-option label="钃濈墮閿�" :value="1" />
-                    <el-option label="ID閿�" :value="2" />
-                    <el-option label="瀹炰綋閿�" :value="3" />
-                  </el-select>
-                </div>
-              </div>
-              <!-- <div class="tools-filter-item">
-                      <div class="filter-label">涓婚锛�</div>
-                      <div class="filter-content">
-                        <el-select
-                          v-model="theme"
-                          placeholder="璇烽�夋嫨"
-                          size="small"
-                          @change="handleChangeTheme"
-                          style="width: 180px"
-                        >
-                          <el-option
-                            v-for="item in themes"
-                            :key="item.label"
-                            :label="item.label"
-                            :value="item.value"
-                          />
-                        </el-select>
-                      </div>
-                    </div> -->
             </div>
-            <el-button type="primary" size="small" :icon="Search" @click="sendMessage">鏌ヨ</el-button>
+            <el-button type="primary" size="small" @click="sendMessage"><svg-icon icon-class="search"></svg-icon>鏌ヨ</el-button>
           </div>
           <div class="page-content-table">
             <div class="pos-rel">
               <div class="pos-abs">
                 <el-table stripe :data="tableData" border style="width: 100%; height: 100%">
-                  <el-table-column type="index" width="50" />
+                  <el-table-column type="index" fixed="left" width="50" />
                   <el-table-column prop="type" label="绫诲瀷" width="180" />
                   <el-table-column prop="lockName" label="閿佸叿鍚嶇О" width="180" />
                   <el-table-column prop="ID" label="閿両D" width="120" />
-                  <el-table-column prop="areaPath" label="鍏宠仈鍖哄煙" min-width="180" />
+                  <el-table-column prop="stationName" label="鏈烘埧" min-width="180" />
                   <el-table-column prop="modelStr" label="鎺у埗妯″紡" width="180" />
                   <el-table-column prop="onlineState" label="鍦ㄧ嚎鐘舵��" width="180" />
-                  <el-table-column prop="state" label="瀹夎鐘舵��" width="180" />
+                  <!-- <el-table-column prop="state" label="瀹夎鐘舵��" width="180" /> -->
                   <el-table-column prop="blStateStr" label="钃濈墮鐘舵��" width="180" />
                   <!-- <el-table-column prop="lockImg" label="閿佸叿鍥剧墖" width="180" /> -->
                   <!-- <el-table-column prop="address" label="鍦板潃" /> -->
                   <el-table-column align="center" fixed="right" label="鎿嶄綔" width="300">
                     <template #default="scope">
                       <el-button type="danger" size="small"
-                        v-if="isAdmin && scope.row.lockOnline == 1 && scope.row.lockState == 0"
+                        v-if="isCanControl && scope.row.lockOnline == 1 && scope.row.lockState == 0"
                         @click="open(scope)">杩滅▼寮�閿�</el-button>
-                      <el-button type="primary" v-if="scope.row.blState == 0" size="small" @click="edit(scope)">寮�鍚摑鐗�</el-button>
-                      <el-button type="primary" v-else size="small" @click="edit(scope)">鍏抽棴钃濈墮</el-button>
+                      <el-button type="primary" v-if="isCanControl && scope.row.blState == 0" size="small"
+                        @click="openBl(scope)">寮�鍚摑鐗�</el-button>
+                      <el-button type="primary" v-if="isCanControl && scope.row.blState == 1" size="small" @click="closeBl(scope)">鍏抽棴钃濈墮</el-button>
                       <el-button type="primary" size="small" @click="edit(scope)">缂栬緫</el-button>
                       <el-button type="danger" size="small" @click="confirmDel(scope)">鍒犻櫎</el-button>
                     </template>
@@ -312,12 +357,12 @@
             <div class="page-tool"></div>
           </div>
         </div>
-      </hdw-card>
+      </yc-card>
     </div>
     <div class="page-footer"></div>
     <!-- 缂栬緫 鏂板缓 -->
-    <el-dialog v-model="addEditVisible" :title="addEditTitle" width="500" align-center :close-on-click-modal="false">
-      <add-edit v-if="addEditVisible" :isBatch="isBatch" :info="editLock" :isAdd="isAdd" @close="addEditVisible = false"
+    <el-dialog v-model="addEditVisible" :title="addEditTitle" width="640" align-center :close-on-click-modal="false">
+      <add-edit v-if="addEditVisible" :info="editLock" :isAdd="isAdd" @close="addEditVisible = false"
         @ok="okHandle"></add-edit>
     </el-dialog>
   </div>

--
Gitblit v1.9.1