From 2dfc8dc4bcd3d3cd4aed1b6054e073e140eba9c8 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Mon, 19 May 2025 16:05:50 +0800
Subject: [PATCH] Merge branch 'master' into jiangwu

---
 src/views/device/components/devicePerShare.vue |   87 ++++++++++++++++++++++++-------------------
 1 files changed, 48 insertions(+), 39 deletions(-)

diff --git a/src/views/device/components/devicePerShare.vue b/src/views/device/components/devicePerShare.vue
index 0151ddd..820fd9e 100644
--- a/src/views/device/components/devicePerShare.vue
+++ b/src/views/device/components/devicePerShare.vue
@@ -18,7 +18,6 @@
       @current-change="currentChange"
       @size-change="sizeChange"
       @refresh-change="refreshChange"
-       @on-load="onLoad"
     >
     </avue-crud>
   </basic-container>
@@ -32,8 +31,8 @@
 export default {
   data() {
     return {
-      deptId:'',
-      deviceSn:'',
+      deptId: '',
+      deviceSn: '',
       form: {},
       query: {},
       loading: true,
@@ -43,10 +42,11 @@
         total: 0,
       },
       selectionList: [],
+      deptTreeData: [],
       option: {
         lazy: true,
         tree: true,
-        height: 'atuo',
+        height: 'auto',
         calcHeight: 32,
         dialogWidth: 750,
         tip: false,
@@ -63,19 +63,19 @@
         column: [
           {
             label: '授权单位',
-            prop: 'dept_id',
+            prop: 'deptId',
             labelWidth: 130,
             type: 'tree',
-            dicData:[],
+            dicData: [],
             props: {
               label: 'name',
               value: 'id',
             },
-            span:24,
-            row:true,
-            hide:true,
-            editDisplay:false,
-            viewDisplay:false,
+            span: 24,
+            row: true,
+            hide: true,
+            editDisplay: false,
+            viewDisplay: false,
             rules: [
               {
                 required: true,
@@ -86,14 +86,14 @@
           },
           {
             label: '授权单位',
-            prop: 'dept_name',
+            prop: 'deptName',
             labelWidth: 130,
-            addDisplay:false,
+            addDisplay: false,
             editDisabled: true,
             search: true,
             searchSpan: 6,
-            span:24,
-            row:true,
+            span: 24,
+            row: true,
             rules: [
               {
                 required: true,
@@ -104,18 +104,18 @@
           },
           {
             label: '授权功能',
-            prop: 'device_per_menu_id',
+            prop: 'devicePerMenuId',
             labelWidth: 130,
             type: 'tree',
-            dicUrl: '/drone-yw/manage/api/v1/devicePerMenu/selectDeviceList',
+            dicUrl: '/blade-system/manage/api/v1/devicePerMenu/selectDeviceList',
             props: {
               label: 'name',
               value: 'id',
             },
             multiple: true,
             dataType: 'string',
-            span:24,
-            row:true,
+            span: 24,
+            row: true,
             rules: [
               {
                 required: true,
@@ -126,7 +126,7 @@
           },
           {
             label: '授权时间',
-            prop: 'create_time',
+            prop: 'createTime',
             type: 'date',
             addDisplay: false,
             editDisplay: false,
@@ -134,7 +134,6 @@
             row: true,
             width: 160,
             format: 'YYYY-MM-DD HH:mm:ss',
-            // valueFormat: 'YYYY-MM-DD HH:mm:ss',
           },
         ],
       },
@@ -160,25 +159,29 @@
     },
   },
   methods: {
-    // 初始化数据
     init(data) {
       this.deptId = data.dept_id;
       this.deviceSn = data.device_sn;
       this.getDeptTreeInfo();
-      this.onLoad(this.page);
+      this.getLoadPage(this.page);
     },
-    getDeptTreeInfo(){
-      getDeptTreeByNotItself(this.deptId,this.deviceSn).then(res => {
-        const column = this.findObject(this.option.column, 'dept_id');
+    getDeptTreeInfo() {
+      getDeptTreeByNotItself(this.deptId, this.deviceSn).then(res => {
+        const column = this.findObject(this.option.column, 'deptId');
+        this.deptTreeData = res.data.data;
         column.dicData = res.data.data;
       });
     },
     rowSave(row, done, loading) {
-      row['device_sn'] = this.deviceSn;
+      // 添加毫秒级时间戳
+      row['createTime'] = Date.now();
+      row['deviceSn'] = this.deviceSn;
+      
       add(row).then(
         () => {
           this.initFlag = false;
-          this.onLoad(this.page);
+          this.getLoadPage(this.page);
+          this.getDeptTreeInfo();
           this.$message({
             type: 'success',
             message: '操作成功!',
@@ -193,9 +196,9 @@
     },
     rowUpdate(row, index, done, loading) {
       row['device_sn'] = this.deviceSn;
-        update(row).then(
+      update(row).then(
         () => {
-          this.onLoad(this.page);
+          this.getLoadPage(this.page);
           this.$message({
             type: 'success',
             message: '操作成功!',
@@ -218,7 +221,8 @@
           return remove(row.id);
         })
         .then(() => {
-          this.onLoad(this.page);
+          this.getDeptTreeInfo();
+          this.getLoadPage(this.page);
           this.$message({
             type: 'success',
             message: '操作成功!',
@@ -227,12 +231,12 @@
     },
     searchReset() {
       this.query = {};
-      this.onLoad(this.page);
+      this.getLoadPage(this.page);
     },
     searchChange(params, done) {
       this.query = params;
       this.page.currentPage = 1;
-      this.onLoad(this.page, params);
+      this.getLoadPage(this.page, params);
       done();
     },
     selectionChange(list) {
@@ -256,7 +260,7 @@
           return remove(this.ids);
         })
         .then(() => {
-          this.onLoad(this.page);
+          this.getLoadPage(this.page);
           this.$message({
             type: 'success',
             message: '操作成功!',
@@ -269,15 +273,18 @@
     },
     currentChange(currentPage) {
       this.page.currentPage = currentPage;
+      this.getLoadPage(this.page, this.query); // 添加数据刷新
     },
     sizeChange(pageSize) {
       this.page.pageSize = pageSize;
+      this.page.currentPage = 1; // 每页条数改变时,重置到第一页
+      this.getLoadPage(this.page, this.query); // 添加数据刷新
     },
     refreshChange() {
-      this.onLoad(this.page, this.query);
+      this.getLoadPage(this.page, this.query);
     },
-    onLoad(page, params = {}) {
-      params['device_sn'] = this.deviceSn;
+    getLoadPage(page, params = {}) {
+      params['deviceSn'] = this.deviceSn;
       this.loading = true;
       getList(page.currentPage, page.pageSize, params).then(res => {
         const data = res.data.data;
@@ -285,6 +292,9 @@
         this.data = data.records;
         this.loading = false;
         this.selectionClear();
+      }).catch(err => {
+        console.error('加载数据失败:', err);
+        this.loading = false;
       });
     },
   },
@@ -298,6 +308,5 @@
 }
 .firmware_status:hover {
   cursor: pointer;
-  /* color: aqua; */
 }
-</style>
+</style>
\ No newline at end of file

--
Gitblit v1.9.3