董国庆
2026-04-28 9dcad0c65f2564fc2fe43e21b23f9faf4a073d30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<template>
  <el-dialog :visible.sync="dialogVisible" :title="dialogTitle" width="79.17%" @close="handleClose">
    <EvaluateTable :key="`${type}-${targetId || 'empty'}-${viewJson || 'empty'}`" ref="evaluateTable" :viewJson="viewJson"
      :type="type == 'labTechnician' ? 1 : type == 'experimenter' ? 2 : 3" />
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="handleSubmit" class="submit-btn">确认评定结果</el-button>
    </div>
  </el-dialog>
</template>
 
<script>
const EVALUATION_TYPES = ['labTechnician', 'experimenter'];
 
export default {
  name: "EvaluationDialog",
  props: {
    modelValue: {
      type: Boolean,
      default: false,
    },
    type: {
      type: String,
      default: 'labTechnician'
    },
    viewJson: {
      type: String,
      default: ''
    },
    targetId: {
      type: [String, Number],
      default: ''
    }
  },
  data() {
    return {
      dialogVisible: false,
    };
  },
  computed: {
    dialogTitle() {
      return this.type === 'labTechnician' ? '化验师工作评定' : this.type === 'experimenter' ? '实验员工作评定' : '工艺工程师工作评定';
    }
  },
  watch: {
    modelValue: {
      handler(val) {
        this.dialogVisible = val;
        if (val) {
          this.$nextTick(() => {
            if (this.$refs.evaluateTable && !this.viewJson) {
              this.$refs.evaluateTable.resetData();
            }
          });
        }
      },
      immediate: true,
    },
    dialogVisible(val) {
      if (!val) {
        this.$emit('update:modelValue', false);
      }
    }
  },
  methods: {
    handleClose() {
      this.$emit('update:modelValue', false);
    },
    handleSubmit() {
      const evaluateTable = this.$refs.evaluateTable;
      if (!evaluateTable) {
        this.$message.warning('评价表格未加载完成');
        return;
      }
 
      const evaluateData = {
        type: this.type,
        activeIndex: evaluateTable.activeIndex
      };
 
      this.$emit('submit', evaluateData);
    },
  },
};
</script>
 
<style lang="less" scoped>
.dialog-footer {
  padding: 20px;
  border-top: 1px solid #eee;
 
  .submit-btn {
    min-width: 80px;
  }
}
</style>