panhui 5 лет назад
Родитель
Сommit
5fc07b1dd8
1 измененных файлов с 142 добавлено и 17 удалено
  1. 142 17
      src/main/vue/src/views/organization/GradeList.vue

+ 142 - 17
src/main/vue/src/views/organization/GradeList.vue

@@ -9,6 +9,7 @@
             cell-class-name="table-cell"
             :height="tableHeight1"
             :span-method="objectSpanMethod"
+            :summary-method="summaryMethod"
             show-summary
         >
             <el-table-column prop="parentLabel" label="一级指标" min-width="25" align="center">
@@ -23,7 +24,31 @@
             <el-table-column prop="score" label="分值" min-width="20" align="center"> </el-table-column>
             <el-table-column prop="score" label="评定分" min-width="20" align="center">
                 <template slot-scope="{ row }">
-                    {{ rateInfo[row.value] }}
+                    {{ getValue(row.value) }}
+                </template>
+            </el-table-column>
+            <el-table-column prop="img" label="图片" min-width="90" width="90" align="center">
+                <template slot-scope="{ row }">
+                    <div class="imgList" v-if="getImg(row.value).length > 0">
+                        <template v-for="(item, index) in getImg(row.value)">
+                            <el-image
+                                :key="index"
+                                style="width: 30px; height: 30px;"
+                                :src="item"
+                                fit="cover"
+                                :preview-src-list="getImg(row.value)"
+                            ></el-image>
+                        </template>
+                    </div>
+                </template>
+            </el-table-column>
+
+            <el-table-column label="专家评分" align="center" fixed="right" width="80">
+                <template slot-scope="{ row }">
+                    <span v-if="getExpertScore(row.value)">{{ getExpertScore(row.value) }}</span>
+                    <el-button v-else-if="isEXPERT" @click="addScore(row)" type="primary" size="mini" plain
+                        >评分</el-button
+                    >
                 </template>
             </el-table-column>
         </el-table>
@@ -44,32 +69,44 @@ export default {
             downloading: false,
             spanArr: [],
             tableHeight1: 620,
-            rateInfo: {}
+            rateList: []
         };
     },
     computed: {
+        ...mapState(['userInfo']),
         selection() {
             return this.$refs.table.selection.map(i => i.id);
+        },
+        isEXPERT() {
+            let info = [...this.userInfo.authorities].find(item => {
+                return item.name === 'ROLE_EXPERT';
+            });
+
+            return !!info;
         }
     },
     mounted() {
-        this.$http
-            .post(
-                '/rateExpertAudit/all',
-                {
-                    query: {
-                        rateId: this.$route.query.id
-                    }
-                },
-                { body: 'json' }
-            )
-            .then(res => {
-                if (!res.empty) {
-                    this.rateInfo = res.content[0];
-                }
-            });
+        this.getGride();
     },
     methods: {
+        getGride() {
+            this.$http
+                .post(
+                    '/rateExpertAudit/all',
+                    {
+                        query: {
+                            rateId: this.$route.query.id,
+                            size: 30
+                        }
+                    },
+                    { body: 'json' }
+                )
+                .then(res => {
+                    if (!res.empty) {
+                        this.rateList = res.content;
+                    }
+                });
+        },
         beforeGetData() {
             return { search: this.search };
         },
@@ -169,6 +206,86 @@ export default {
                     };
                 }
             }
+        },
+        getValue(key) {
+            let info = [...this.rateList].find(item => {
+                return item.type === key;
+            });
+
+            return info ? info.score || 0 : 0;
+        },
+        getImg(key) {
+            let info = [...this.rateList].find(item => {
+                return item.type === key;
+            });
+
+            return info ? info.img || [] : [];
+        },
+        getExpertScore(key) {
+            let info = [...this.rateList].find(item => {
+                return item.type === key;
+            });
+
+            return info ? info.expertScore || 0 : 0;
+        },
+        getInfo(key) {
+            let info = [...this.rateList].find(item => {
+                return item.type === key;
+            });
+
+            return info || {};
+        },
+        summaryMethod({ columns, data }) {
+            const sums = [];
+            columns.forEach((column, index) => {
+                if (index === 0) {
+                    sums[index] = '总分';
+                    return;
+                } else if (index === 3) {
+                    sums[index] = data.reduce((total, currentValue) => {
+                        return total + currentValue.score;
+                    }, 0);
+                    return;
+                } else if (index === 4) {
+                    sums[index] = data.reduce((total, currentValue) => {
+                        return total + this.getValue(currentValue.value);
+                    }, 0);
+                    return;
+                } else {
+                    return;
+                }
+            });
+
+            return sums;
+        },
+        addScore(row) {
+            console.log(row.score);
+            let test = /^[1-2]$/;
+            if (row.score === 3) {
+                test = /^[1-3]$/;
+            } else if (row.score === 4) {
+                test = /^[1-4]$/;
+            } else if (row.score === 5) {
+                test = /^[1-5]$/;
+            } else if (row.score === 6) {
+                test = /^[1-6]$/;
+            }
+            this.$prompt('请输入评分', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                inputPattern: test,
+                inputErrorMessage: '请输入一个不大于' + row.score + '整数'
+            })
+                .then(({ value }) => {
+                    let info = { ...this.getInfo(row.value) };
+                    info.expertScore = value;
+                    return this.$http.post('/rateExpertAudit/save', info, { body: 'json' });
+                })
+                .then(res => {
+                    this.$message.success('添加成功');
+                    this.getGride();
+                })
+                .catch(() => {});
         }
     }
 };
@@ -178,6 +295,14 @@ export default {
     height: 730px;
 }
 
+.imgList {
+    display: flex;
+    flex-wrap: wrap;
+    .el-image {
+        margin-left: 3px;
+    }
+}
+
 /deep/ .el-table {
     &::before {
         content: none;