From 29bf5936bf1da2eea81f3abe07dc738f5267c42c Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Mon, 02 Jan 2023 16:34:16 +0800
Subject: [PATCH] 修改顶部栏

---
 src/views/pass/pass.vue |   44 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/src/views/pass/pass.vue b/src/views/pass/pass.vue
index 70e5526..c3b1020 100644
--- a/src/views/pass/pass.vue
+++ b/src/views/pass/pass.vue
@@ -30,8 +30,8 @@
       <template slot-scope="{type,size,row,index}" slot="menu">
         <el-button icon="el-icon-view" :size="size" :type="type" @click="viewQr(row)">预 览</el-button>
         <el-button icon="el-icon-edit" :size="size" :type="type">导 出</el-button>
-        <el-button icon="el-icon-delete" :size="size" :type="type" >打 印</el-button>
-        <el-button icon="el-icon-delete" :size="size" :type="type">废 止</el-button>
+        <el-button icon="el-icon-delete" :size="size" :type="type" @click="goToPassView(row)">跳 转</el-button>
+        <el-button icon="el-icon-delete" :disabled="row.status == 2" :size="size" :type="type" @click="abolishPass(row)">废 止</el-button>
       </template>
     </avue-crud>
 
@@ -52,7 +52,7 @@
 </template>
 
 <script>
-  import {getList, getDetail, add, update, remove} from "@/api/pass/pass";
+  import {getPage, getDetail, add, update, remove} from "@/api/pass/pass";
   import option from "@/const/pass/pass";
   import {mapGetters} from "vuex";
   import QRCode from 'qrcodejs2';
@@ -76,7 +76,7 @@
       };
     },
     computed: {
-      ...mapGetters(["permission"]),
+      ...mapGetters(["permission","userInfo"]),
       permissionList() {
         return {
           addBtn: this.vaildData(this.permission.pass_add, true),
@@ -91,6 +91,9 @@
           ids.push(ele.id);
         });
         return ids.join(",");
+      },
+      permit(){
+        return this.userInfo.role_name == 'admin' || this.userInfo.role_name == 'administrator' ? true:false
       }
     },
     methods: {
@@ -195,7 +198,12 @@
       },
       onLoad(page, params = {}) {
         this.loading = true;
-        getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
+
+        if (!this.permit){
+          params.userId = this.userInfo.user_id
+        }
+
+        getPage(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
           const data = res.data.data;
           this.page.total = data.total;
           this.data = data.records;
@@ -221,6 +229,32 @@
         })
 
 
+      },
+      //跳转通行证预览页面
+      goToPassView(row){
+        this.$router.push({path:`/passView/${row.no}`})
+      },
+      //通行证废止
+      abolishPass(row){
+
+        this.$confirm('是否废止该通行证?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          row.status = 2
+          update(row).then(() => {
+            this.$message({
+              type: "success",
+              message: "操作成功!"
+            });
+            this.onLoad(this.page);
+          }, error => {
+            console.log(error);
+          });
+        }).catch(() => {
+
+        });
       }
     }
   };

--
Gitblit v1.9.3