From d13cebe7fbadd396e91a989af331df8a8e7b40f8 Mon Sep 17 00:00:00 2001
From: xieb <vip_xiaobin810@163.com>
Date: Tue, 21 Jan 2025 11:40:42 +0800
Subject: [PATCH] 考核结果查看详情

---
 src/views/assessment/components/taskResult.vue |  250 +++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 217 insertions(+), 33 deletions(-)

diff --git a/src/views/assessment/components/taskResult.vue b/src/views/assessment/components/taskResult.vue
index f47bc01..ad1a7b2 100644
--- a/src/views/assessment/components/taskResult.vue
+++ b/src/views/assessment/components/taskResult.vue
@@ -2,18 +2,29 @@
     <div class="container">
         <el-page-header @back="back" class="header">
             <template #content>
-                <span>考核结果</span>
+                <span>{{ !params.type ? '个人考核结果' : '部门考核结果' }}</span>
             </template>
         </el-page-header>
-        <avue-crud ref="crud" v-model="form" v-model:search="search" :option="option" :data="data" v-model:page="page">
+        <avue-crud :option="option" v-model:search="search" v-model:page="page" v-model="form" :table-loading="loading"
+            :data="data" :before-open="beforeOpen" ref="crud" @row-update="rowUpdate" @row-save="rowSave" @row-del="rowDel"
+            @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
+            @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
+            <template #menu="{ row }">
+                <el-button type="primary" size="small" @click="handleDetail(row)">查看详情</el-button>
+            </template>
         </avue-crud>
+        <resultDetail :params="detailParams" />
     </div>
 </template>
   
 <script>
-import { ElMessageBox, ElMessage } from 'element-plus'
+import { getList } from '@/api/assessment/assessmentScore'
+import resultDetail from './resultDetail.vue'
 
 export default {
+    components: {
+        resultDetail
+    },
     props: {
         params: {
             type: Object,
@@ -24,17 +35,12 @@
     },
     data() {
         return {
+            rowData: {},
             form: {},
+            query: {},
             search: {},
-            selectionList: [],
-            data: [
-                {
-                    assessor: '张三',
-                    position: '经理',
-                    weight: 50,
-                    ratingRange: 50,
-                }
-            ],
+            loading: true,
+            data: [],
             option: {
                 height: 'auto',
                 calcHeight: 32,
@@ -42,39 +48,45 @@
                 searchMenuSpan: 6,
                 border: true,
                 index: true,
-                addBtn: true,
-                viewBtn: true,
+                addBtn: false,
+                viewBtn: false,
                 editBtn: false,
-                delBtn: true,
-                selection: true,
+                delBtn: false,
+                selection: false,
                 dialogClickModal: false,
-                menuWidth: 200,
+                menu: true,
+                searchLabelWidth: 100,
                 column: [
                     {
-                        label: "考核编号",
-                        type: 'select',
-                        hide: true,
-                        search: true
+                        label: "工号",
+                        prop: 'code',
+                        type: "input",
                     },
                     {
-                        label: "考核人",
-                        prop: "assessor",
+                        label: "被考核人",
+                        prop: "userName",
                         type: "input",
                         search: true,
                     },
                     {
-                        label: "职务",
-                        prop: "position",
-                        type: "input",
+                        label: "部门",
+                        prop: "deptName",
+                        type: "select",
+                        dicUrl: '/api/blade-system/dept/lazy-list?parentId=1737282385453543425',
+                        search: true,
+                        props: {
+                            label: 'deptName',
+                            value: 'fullName'
+                        }
                     },
                     {
-                        label: "权值",
-                        prop: "weight",
+                        label: "职务",
+                        prop: "postName",
                         type: "input",
                     },
                     {
                         label: "考核分",
-                        prop: "ratingRange",
+                        prop: "scoreVal",
                         type: "input",
                     }
                 ]
@@ -83,10 +95,41 @@
                 pageSize: 10,
                 currentPage: 1,
                 total: 1,
-            }
+            },
+            detailParams: {}
         }
     },
     watch: {
+        'params': {
+            handler(val) {
+                this.rowData = val
+                // this.query.assessmentTaskId = val.id
+                // this.query.type = val.type
+                if (val.type) {
+                    const column = [
+                        {
+                            label: "被考核部门",
+                            prop: "deptName",
+                            type: "select",
+                            dicUrl: '/api/blade-system/dept/lazy-list?parentId=1737282385453543425',
+                            search: true,
+                            props: {
+                                label: 'deptName',
+                                value: 'fullName'
+                            }
+                        },
+                        {
+                            label: "考核分数",
+                            prop: "scoreVal",
+                            type: "input",
+                        }
+                    ]
+                    this.option.column = column
+                }
+            },
+            deep: true,
+            immediate: true,
+        }
     },
     computed: {
         ids() {
@@ -99,11 +142,152 @@
     },
     methods: {
         back() {
-            this.$emit('changeIs', true)
+            this.$emit('changeIs', 0)
         },
-        sizeChange() { },
-        refreshChange() { },
+        rowSave(row, done, loading) {
+            add(row).then(() => {
+                this.onLoad(this.page);
+                this.$message({
+                    type: "success",
+                    message: "操作成功!"
+                });
+                done();
+            }, error => {
+                loading();
+                window.console.log(error);
+            });
+        },
+        rowUpdate(row, index, done, loading) {
+            update(row).then(() => {
+                this.onLoad(this.page);
+                this.$message({
+                    type: "success",
+                    message: "操作成功!"
+                });
+                done();
+            }, error => {
+                loading();
+                console.log(error);
+            });
+        },
+        rowDel(row) {
+            this.$confirm("确定将选择数据删除?", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning"
+            })
+                .then(() => {
+                    return remove(row.id);
+                })
+                .then(() => {
+                    this.onLoad(this.page);
+                    this.$message({
+                        type: "success",
+                        message: "操作成功!"
+                    });
+                });
+        },
+        handleDelete() {
+            if (this.selectionList.length === 0) {
+                this.$message.warning("请选择至少一条数据");
+                return;
+            }
+            this.$confirm("确定将选择数据删除?", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning"
+            })
+                .then(() => {
+                    return remove(this.ids);
+                })
+                .then(() => {
+                    this.onLoad(this.page);
+                    this.$message({
+                        type: "success",
+                        message: "操作成功!"
+                    });
+                    this.$refs.crud.toggleSelection();
+                });
+        },
+        // handleExport() {
+        //     let downloadUrl = `/assessmentTask/assessmentTask/export-assessmentTask?${this.website.tokenHeader}=${getToken()}`;
+        //     const {
+        //     } = this.query;
+        //     let values = {
+        //         ...this.query
+        //     };
+        //     this.$confirm("是否导出数据?", "提示", {
+        //         confirmButtonText: "确定",
+        //         cancelButtonText: "取消",
+        //         type: "warning"
+        //     }).then(() => {
+        //         NProgress.start();
+        //         exportBlob(downloadUrl, values).then(res => {
+        //             downloadXls(res.data, `考核任务表${dateNow()}.xlsx`);
+        //             NProgress.done();
+        //         })
+        //     });
+        // },
+        beforeOpen(done, type) {
+            // if (["edit", "view"].includes(type)) {
+            //     getDetail(this.form.id).then(res => {
+            //         this.form = res.data.data;
+            //     });
+            // }
+            // done();
+        },
+        searchReset() {
+            this.query = {};
+            this.onLoad(this.page);
+        },
+        searchChange(params, done) {
+            params.type = this.defaultTaskType
+            this.query = params;
+            this.page.currentPage = 1;
+            this.onLoad(this.page, params);
+            done();
+        },
+        selectionChange(list) {
+            this.selectionList = list;
+        },
+        selectionClear() {
+            this.selectionList = [];
+            this.$refs.crud.toggleSelection();
+        },
+        currentChange(currentPage) {
+            this.page.currentPage = currentPage;
+        },
+        sizeChange(pageSize) {
+            this.page.pageSize = pageSize;
+        },
+        refreshChange() {
+            this.onLoad(this.page, this.query);
+        },
         onLoad(page, params = {}) {
+            this.loading = true;
+
+            const {
+            } = this.query;
+
+            let values = {
+                ...this.query,
+                ...params
+            };
+
+            const { id, type } = this.params
+            getList(page.currentPage, page.pageSize, values, type, id).then(res => {
+                const data = res.data.data;
+                this.page.total = data.total;
+                this.data = data.records;
+                this.loading = false;
+                this.selectionClear();
+            });
+        },
+        handleDetail(row) {
+            this.detailParams = {
+                visible: true,
+                ...row
+            }
         }
     },
     mounted() {

--
Gitblit v1.9.3