From b2832a9c5d287b8a11c0e7ba312bfd45f195d8df Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Tue, 20 Dec 2022 17:29:18 +0800
Subject: [PATCH] 通行证、评价页面非管理员只能看见自己的数据

---
 src/views/evaluation/evaluation.vue |  134 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 130 insertions(+), 4 deletions(-)

diff --git a/src/views/evaluation/evaluation.vue b/src/views/evaluation/evaluation.vue
index 1879619..e2c04b9 100644
--- a/src/views/evaluation/evaluation.vue
+++ b/src/views/evaluation/evaluation.vue
@@ -28,12 +28,22 @@
         </el-button>
       </template>
 
+      <template slot-scope="{row}" slot="badCommentConfirm">
+        <span v-if="row.status == 3 && !row.badCommentConfirm" style="color: red">差评类型未确认</span>
+      </template>
+
+
+
+      <template slot-scope="{type,size,row,index}" slot="menu">
+        <el-button v-if="row.status == 1" icon="el-icon-edit" :size="size" :type="type"  @click="$refs.crud.rowEdit(row,index)">评 价</el-button>
+        <el-button v-if="row.status == 3 && !row.badCommentConfirm" icon="el-icon-warning-outline" :size="size" :type="type" @click="badCommentConfirm(row)">差评确认</el-button>
+      </template>
     </avue-crud>
   </basic-container>
 </template>
 
 <script>
-  import {getList, getDetail, add, update, remove} from "@/api/evaluation/evaluation";
+  import {getPage, getDetail, add, update, remove} from "@/api/evaluation/evaluation";
   import option from "@/const/evaluation/evaluation";
   import {mapGetters} from "vuex";
 
@@ -50,11 +60,87 @@
         },
         selectionList: [],
         option: option,
+        badConfirmOption:{
+          height:'auto',
+          calcHeight: 30,
+          tip: false,
+          border: true,
+          index: true,
+          dialogClickModal: false,
+          group:[
+            {
+              label: '评价信息',
+              collapse: true,
+              prop: 'info',
+              arrow:false,
+              column:[
+                {
+                  label: "申请单号",
+                  prop: "no",
+                  type: "input",
+                  readonly:true,
+                  addDisplay: false,
+                  editDisplay: false,
+                },
+                {
+                  label: "评分",
+                  prop: "score",
+                  type: "rate",
+                  disabled:true,
+                  colors: ['#99A9BF', '#F7BA2A', '#FF9900'],
+                  rules: [{required: true, trigger: ['blur','change'],message:"请评分"}]
+                },
+                {
+                  label: "评价",
+                  prop: "comment",
+                  readonly:true,
+                  disabled:true,
+                  span:24,
+                  type: "select",
+                  multiple:true,
+                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=evaluation_comment",
+                  props:{
+                    label:"dictValue",
+                    value:"dictKey"
+                  },
+                },
+                {
+                  label: "建议与反馈",
+                  prop: "feedback",
+                  readonly:true,
+                  span:24,
+                  type: "textarea",
+                }
+              ]
+            },
+            {
+              label: '确认评价内容',
+              collapse: true,
+              prop: 'confirm',
+              arrow:false,
+              column:[
+                {
+                  label:'',
+                  span:24,
+                  gutter:18,
+                  prop:'badCommentConfirm',
+                  type:'radio',
+                  props:{
+                    label:"dictValue",
+                    value:"dictKey"
+                  },
+                  dicUrl: '/api/blade-system/dict-biz/dictionary?code=evaluation_bad_comment_confirm',
+                  rules: [{required: true, trigger: ['blur','change'],message:"请确认评价内容"}]
+                }
+              ]
+            }
+          ],
+        },
         data: []
       };
     },
     computed: {
-      ...mapGetters(["permission"]),
+      ...mapGetters(["permission","userInfo"]),
       permissionList() {
         return {
           addBtn: this.vaildData(this.permission.evaluation_add, true),
@@ -69,6 +155,9 @@
           ids.push(ele.id);
         });
         return ids.join(",");
+      },
+      permit(){
+        return this.userInfo.role_name == 'admin' || this.userInfo.role_name == 'administrator' ? true:false
       }
     },
     methods: {
@@ -86,6 +175,14 @@
         });
       },
       rowUpdate(row, index, done, loading) {
+
+        if (row.score<3){
+          //评分小于3 差评
+          row.status = 3
+        }else {
+          row.status = 2
+        }
+
         update(row).then(() => {
           this.onLoad(this.page);
           this.$message({
@@ -173,14 +270,43 @@
       },
       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;
           this.loading = false;
           this.selectionClear();
         });
-      }
+      },
+      //差评确认
+      badCommentConfirm(row){
+        this.$DialogForm.show({
+          title: '差评确认',
+          width: '70%',
+          data:row,
+          option: this.badConfirmOption,
+          callback:(res)=>{
+            update(res.data).then(() => {
+              this.onLoad(this.page);
+              this.$message({
+                type: "success",
+                message: "操作成功!"
+              });
+              res.close()
+            })
+            this.option.group.forEach(group=>{
+              group.column.forEach(item=>{
+                item.disabled = false
+              })
+            })
+          }
+        })
+      },
     }
   };
 </script>

--
Gitblit v1.9.3