From c832bf2e80ac465e71b7a1c1f7a59d4252030989 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Tue, 05 Aug 2025 17:33:08 +0800
Subject: [PATCH] feat:事件工单滚动条

---
 src/views/device/components/devicePerShare.vue |  254 ++++++++++++++++++++++++--------------------------
 1 files changed, 124 insertions(+), 130 deletions(-)

diff --git a/src/views/device/components/devicePerShare.vue b/src/views/device/components/devicePerShare.vue
index bc8c5ff..2ee9ac6 100644
--- a/src/views/device/components/devicePerShare.vue
+++ b/src/views/device/components/devicePerShare.vue
@@ -1,38 +1,23 @@
 <template>
   <basic-container>
-    <avue-crud
-      :option="option"
-      :table-loading="loading"
-      :data="data"
-      v-model:page="page"
-      ref="crud"
-      @row-del="rowDel"
-      v-model="form"
-      :permission="permissionList"
-      @row-save="rowSave"
-      @row-update="rowUpdate"
-      :before-open="beforeOpen"
-      @search-change="searchChange"
-      @search-reset="searchReset"
-      @selection-change="selectionChange"
-      @current-change="currentChange"
-      @size-change="sizeChange"
-      @refresh-change="refreshChange"
-    >
+    <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" ref="crud" @row-del="rowDel"
+      v-model="form" :permission="permissionList" @row-save="rowSave" @row-update="rowUpdate" :before-open="beforeOpen"
+      @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
+      @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange">
     </avue-crud>
   </basic-container>
 </template>
 
 <script>
-import { getList, remove, add, update } from '@/api/device/devicePerShare';
-import { getDeptTreeByNotItself } from '@/api/system/dept';
-import { mapGetters } from 'vuex';
+import { getList, remove, add, update } from '@/api/device/devicePerShare'
+import { getDeptTreeByNotItself } from '@/api/system/dept'
+import { mapGetters } from 'vuex'
 
 export default {
-  data() {
+  data () {
     return {
-      deptId:'',
-      deviceSn:'',
+      deptId: '',
+      deviceSn: '',
       form: {},
       query: {},
       loading: true,
@@ -42,11 +27,10 @@
         total: 0,
       },
       selectionList: [],
+      deptTreeData: [],
       option: {
         lazy: true,
         tree: true,
-        height: 'atuo',
-        calcHeight: 32,
         dialogWidth: 750,
         tip: false,
         searchShow: true,
@@ -59,22 +43,26 @@
         excelBtn: false,
         dialogClickModal: false,
         grid: false,
+
+        height: 'auto',
+        calcHeight: 20,
+
         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,
@@ -85,14 +73,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,
@@ -103,18 +91,18 @@
           },
           {
             label: '授权功能',
-            prop: 'device_per_menu_id',
+            prop: 'devicePerMenuId',
             labelWidth: 130,
             type: 'tree',
-            dicUrl: '/blade-system',
+            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,
@@ -125,7 +113,7 @@
           },
           {
             label: '授权时间',
-            prop: 'create_time',
+            prop: 'createTime',
             type: 'date',
             addDisplay: false,
             editDisplay: false,
@@ -133,122 +121,122 @@
             row: true,
             width: 160,
             format: 'YYYY-MM-DD HH:mm:ss',
-            // valueFormat: 'YYYY-MM-DD HH:mm:ss',
           },
         ],
       },
       data: [],
-    };
+    }
   },
   computed: {
     ...mapGetters(['permission']),
-    permissionList() {
+    permissionList () {
       return {
         addBtn: this.validData(this.permission.airport_add, true),
         viewBtn: this.validData(this.permission.airport_view, true),
         delBtn: this.validData(this.permission.airport_delete, true),
         editBtn: this.validData(this.permission.airport_edit, true),
-      };
+      }
     },
-    ids() {
-      let ids = [];
+    ids () {
+      let ids = []
       this.selectionList.forEach(ele => {
-        ids.push(ele.id);
-      });
-      return ids.join(',');
+        ids.push(ele.id)
+      })
+      return ids.join(',')
     },
   },
   methods: {
-    // 初始化数据
-    init(data) {
-      this.deptId = data.dept_id;
-      this.deviceSn = data.device_sn;
-      this.getDeptTreeInfo();
-      this.getLoadPage(this.page);
+    init (data) {
+      this.deptId = data.dept_id
+      this.deviceSn = data.device_sn
+      this.getDeptTreeInfo()
+      this.getLoadPage(this.page)
     },
-    getDeptTreeInfo(){
-      getDeptTreeByNotItself(this.deptId,this.deviceSn).then(res => {
-        const column = this.findObject(this.option.column, 'dept_id');
-        column.dicData = res.data.data;
-      });
+    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;
+    rowSave (row, done, loading) {
+      // 添加毫秒级时间戳
+      row['createTime'] = Date.now()
+      row['deviceSn'] = this.deviceSn
+
       add(row).then(
         () => {
-          this.initFlag = false;
-          this.getLoadPage(this.page);
-          // 刷新机构树
-          this.getDeptTreeInfo();
+          this.initFlag = false
+          this.getLoadPage(this.page)
+          this.getDeptTreeInfo()
           this.$message({
             type: 'success',
             message: '操作成功!',
-          });
-          done();
+          })
+          done()
         },
         error => {
-          window.console.log(error);
-          loading();
+          window.console.log(error)
+          loading()
         }
-      );
+      )
     },
-    rowUpdate(row, index, done, loading) {
-      row['device_sn'] = this.deviceSn;
-        update(row).then(
+    rowUpdate (row, index, done, loading) {
+      row['device_sn'] = this.deviceSn
+      update(row).then(
         () => {
-          this.getLoadPage(this.page);
+          this.getLoadPage(this.page)
           this.$message({
             type: 'success',
             message: '操作成功!',
-          });
-          done();
+          })
+          done()
         },
         error => {
-          window.console.log(error);
-          loading();
+          window.console.log(error)
+          loading()
         }
-      );
+      )
     },
-    rowDel(row) {
+    rowDel (row) {
       this.$confirm('确定将选择数据删除?', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning',
       })
         .then(() => {
-          return remove(row.id);
+          return remove(row.id)
         })
         .then(() => {
-          // 刷新机构树
-          this.getDeptTreeInfo();
-          this.getLoadPage(this.page);
+          this.getDeptTreeInfo()
+          this.getLoadPage(this.page)
           this.$message({
             type: 'success',
             message: '操作成功!',
-          });
-        });
+          })
+        })
     },
-    searchReset() {
-      this.query = {};
-      this.getLoadPage(this.page);
+    searchReset () {
+      this.query = {}
+      this.getLoadPage(this.page)
     },
-    searchChange(params, done) {
-      this.query = params;
-      this.page.currentPage = 1;
-      this.getLoadPage(this.page, params);
-      done();
+    searchChange (params, done) {
+      this.query = params
+      this.page.currentPage = 1
+      this.getLoadPage(this.page, params)
+      done()
     },
-    selectionChange(list) {
-      this.selectionList = list;
+    selectionChange (list) {
+      this.selectionList = list
     },
-    selectionClear() {
-      this.selectionList = [];
-      this.$refs.crud.toggleSelection();
+    selectionClear () {
+      this.selectionList = []
+      this.$refs.crud.toggleSelection()
     },
-    handleDelete() {
+    handleDelete () {
       if (this.selectionList.length === 0) {
-        this.$message.warning('请选择至少一条数据');
-        return;
+        this.$message.warning('请选择至少一条数据')
+        return
       }
       this.$confirm('确定将选择数据删除?', {
         confirmButtonText: '确定',
@@ -256,42 +244,48 @@
         type: 'warning',
       })
         .then(() => {
-          return remove(this.ids);
+          return remove(this.ids)
         })
         .then(() => {
-          this.getLoadPage(this.page);
+          this.getLoadPage(this.page)
           this.$message({
             type: 'success',
             message: '操作成功!',
-          });
-          this.$refs.crud.toggleSelection();
-        });
+          })
+          this.$refs.crud.toggleSelection()
+        })
     },
-    beforeOpen(done, type) {
-      done();
+    beforeOpen (done, type) {
+      done()
     },
-    currentChange(currentPage) {
-      this.page.currentPage = currentPage;
+    currentChange (currentPage) {
+      this.page.currentPage = currentPage
+      this.getLoadPage(this.page, this.query) // 添加数据刷新
     },
-    sizeChange(pageSize) {
-      this.page.pageSize = pageSize;
+    sizeChange (pageSize) {
+      this.page.pageSize = pageSize
+      this.page.currentPage = 1 // 每页条数改变时,重置到第一页
+      this.getLoadPage(this.page, this.query) // 添加数据刷新
     },
-    refreshChange() {
-      this.getLoadPage(this.page, this.query);
+    refreshChange () {
+      this.getLoadPage(this.page, this.query)
     },
-    getLoadPage(page, params = {}) {
-      params['device_sn'] = this.deviceSn;
-      this.loading = true;
+    getLoadPage (page, params = {}) {
+      params['deviceSn'] = this.deviceSn
+      this.loading = true
       getList(page.currentPage, page.pageSize, params).then(res => {
-        const data = res.data.data;
-        this.page.total = data.total;
-        this.data = data.records;
-        this.loading = false;
-        this.selectionClear();
-      });
+        const data = res.data.data
+        this.page.total = data.total
+        this.data = data.records
+        this.loading = false
+        this.selectionClear()
+      }).catch(err => {
+        console.error('加载数据失败:', err)
+        this.loading = false
+      })
     },
   },
-};
+}
 </script>
 
 <style>
@@ -299,8 +293,8 @@
   background-color: aqua;
   border-radius: 4px;
 }
+
 .firmware_status:hover {
   cursor: pointer;
-  /* color: aqua; */
 }
 </style>

--
Gitblit v1.9.3