董国庆
2025-06-25 d8d68a0aee93073b5ec3195368ca0ed1076f66a2
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<template>
  <Card>
    <template>
      <div class="header-title" style="margin-bottom: 18px">
        <div class="header-title-left">
          <img src="@/assets/public/headercard.png" />
          <div>所属实验调度</div>
        </div>
        <el-button
          class="el-icon-plus"
          type="primary"
          v-if="isEdit"
          @click="showScheduling = true"
        >
          选择实验调度</el-button
        >
      </div>
      <Table :data="tableData" :total="0" :height="null">
        <template>
          <el-table-column
            type="index"
            label="序号"
            width="80"
          ></el-table-column>
          <el-table-column
            prop="projectName"
            label="所属项目课题方案"
          ></el-table-column>
          <el-table-column
            prop="experimentCode"
            label="实验编号"
          ></el-table-column>
          <el-table-column
            prop="experimentName"
            label="实验名称"
          ></el-table-column>
          <el-table-column
            prop="experimentDate"
            label="通知时间"
          ></el-table-column>
          <el-table-column
            prop="experimentStartTime"
            label="实验开始时间"
          ></el-table-column>
          <el-table-column
            prop="experimentEndTime"
            label="实验结束时间"
          ></el-table-column>
          <el-table-column
            prop="participantsName"
            label="参加人员"
          ></el-table-column>
          <el-table-column prop="status" label="状态">
            <template slot-scope="scope">
              <el-tag :type="getStatusType(scope.row.status)">
                {{ getStatusText(scope.row.status) }}
              </el-tag>
            </template>
          </el-table-column>
        </template>
      </Table>
      <div class="header-title" style="margin-top: 60px">
        <div class="header-title-left">
          <img src="@/assets/public/headercard.png" />
          <div>被评定实验员</div>
        </div>
        <el-button
          class="el-icon-plus"
          v-if="isEdit"
          type="primary"
          @click="addMember"
        >
          选择实验员</el-button
        >
      </div>
      <div class="member-list">
        <div class="member-list-card">
          <div class="member-item">
            <div class="member-title">实验员</div>
            <div class="member-name-box-2">
              <div
                v-for="i in selectedParticipants"
                :key="i.id"
                class="member-name"
              >
                {{ i.nickName }}
              </div>
            </div>
            <div class="member-edit" @click="handleEditMember" v-if="isEdit">
              修改
            </div>
          </div>
        </div>
      </div>
      <div class="header-title" style="margin-bottom: 18px; margin-top: 60px">
        <div class="header-title-left">
          <img src="@/assets/public/headercard.png" />
          <div>工作标准评定</div>
        </div>
      </div>
      <EvaluateTable :type="2" ref="evaluateTable" />
      <div class="add-project-footer">
        <el-button type="primary" @click="submitForm()">保存</el-button>
        <!-- <el-button>存草稿</el-button> -->
      </div>
    </template>
    <SelectMemberSimple
      ref="selectMember"
      @submit="handleMemberSubmit"
      roleType="5"
    />
    <ExperimentalScheduling
      :show="showScheduling"
      @submit="handleSchedulingSubmit"
      @close="handleSchedulingClose"
    />
  </Card>
</template>
 
<script>
import SelectMemberSimple from "@/components/SelectMemberSimple/index.vue";
import ExperimentalScheduling from "@/views/dataManagement/schemeManagement/components/experimental-scheduling";
import { getEvaluateChemist, add } from "./service.js";
import moment from "moment";
 
export default {
  name: "AddTesterWorkerEvaluate",
  components: {
    ExperimentalScheduling,
    SelectMemberSimple,
  },
  data() {
    return {
      showScheduling: false,
      participantsData: [],
      selectedParticipants: [],
      tableData: [],
      isEdit: true, // 是否为编辑模式
      // 状态映射表
      statusTypeMap: {
        "-1": "info",
        1: "warning",
        2: "success",
        3: "info",
      },
      statusTextMap: {
        "-1": "草稿箱",
        1: "待确认",
        2: "已确认",
        3: "已封存",
      },
    };
  },
  async created() {
    // const userInfo = JSON.parse(sessionStorage.getItem("userInfo") || "{}");
    // this.userRole = userInfo.roleType || "";
    // 检查是否为编辑模式
    this.participantsData = [];
    this.selectedParticipants = [];
    this.tableData = [];
    this.isEdit = true; // 是否为编辑模式
 
    if (this.$route.query.id) {
      this.isEdit = this.$route.query.type === "view" ? false : true;
      this.editId = this.$route.query.id;
      await this.loadEditData();
    }
  },
  methods: {
    handleSchedulingClose() {
      this.showScheduling = false;
    },
    handleSchedulingSubmit(data) {
      console.log("data data", data);
      this.tableData = data || [];
      if (data && data.length > 0 && data[0].id) {
        getEvaluateChemist({ dispatchId: data[0].id })
          .then((res) => {
            console.log("获取参加人员列表:", res);
            if (res) {
              this.participantsData = res.map((item) => {
                return {
                  ...item,
                  roleType: 5,
                };
              });
            } else {
              this.$message.error(res.msg || "获取参加人员列表失败");
            }
          })
          .catch((err) => {
            this.$message.error("获取参加人员列表失败");
            console.error("获取参加人员列表失败:", err);
          });
      }
    },
    getStatusType(status) {
      return this.statusTypeMap[status] || "info";
    },
    getStatusText(status) {
      return this.statusTextMap[status] || "未知";
    },
    handleEditMember() {
      this.$refs.selectMember.open(
        this.participantsData,
        this.selectedParticipants
      );
    },
    // ===== 人员相关方法 =====
    addMember() {
      if (this.tableData.length == 0) {
        this.$message.error("请先选择所属实验调度");
        return;
      }
      this.$refs.selectMember.open(this.participantsData, []);
    },
    handleMemberSubmit(selectedMembers) {
      this.selectedParticipants = selectedMembers;
      this.$refs.selectMember.close();
    },
    // 将分数转换为评定值
    getEvaluateValue(score) {
      // 2分 = 良好(1), 1分 = 正确(2), 0分 = 失误(3)
      const scoreMap = {
        2: 1, // 良好
        1: 2, // 正确
        0: 3, // 失误
      };
      return scoreMap[score] || 3; // 默认返回失误
    },
    submitForm() {
      const evaluateTable = this.$refs.evaluateTable;
      if (!evaluateTable) {
        this.$message.warning("评价表格未加载完成");
        return;
      }
      const activeIndex = evaluateTable.activeIndex;
 
      const evaluateData = {
        evaluateOne: this.getEvaluateValue(activeIndex[0].score),
        evaluateTwo: this.getEvaluateValue(activeIndex[1].score),
        evaluateThree: this.getEvaluateValue(activeIndex[2].score),
        evaluateFour: this.getEvaluateValue(activeIndex[3].score),
        evaluateFive: this.getEvaluateValue(activeIndex[4].score),
        evaluateSix: this.getEvaluateValue(activeIndex[5].score),
        evaluateTime: moment().format("YYYY-MM-DD HH:mm:ss"),
        resultEvaluateJson: JSON.stringify(activeIndex),
        dispatchId: this.tableData[0]?.id,
        evaluateType: 3,
        userId: this.selectedParticipants[0].userId,
        dispatchId: this.tableData[0]?.id,
        status: 1,
      };
 
      console.log("11111111111", evaluateTable.activeIndex);
      console.log("2222222222222222", evaluateData);
      add(evaluateData).then((res) => {
        if (res.code == 200) {
          this.$message.success("保存成功");
          this.$router.back();
        } else {
          this.$message.error(res.msg || "保存失败");
        }
      });
    },
  },
};
</script>
 
<style scoped lang="less">
.el-form--inline .el-form-item {
  margin-right: 83px;
}
 
.header-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 13px;
 
  .header-title-left {
    display: flex;
    align-items: center;
    gap: 13px;
 
    img {
      width: 12px;
      height: 19px;
    }
 
    div {
      flex-shrink: 0;
      font-weight: bold;
      font-size: 18px;
      color: #222222;
      line-height: 27px;
      font-family: "Source Han Sans CN Bold Bold";
 
      &:before {
        content: "*";
        color: #f56c6c;
        margin-right: 4px;
      }
    }
  }
}
 
.member-list {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
 
  .member-list-card {
    position: relative;
    width: 340px;
    height: 400px;
    border-radius: 8px;
    border: 1px solid #dcdfe6;
    background: linear-gradient(
      to bottom,
      rgba(255, 77, 79, 0.2) 0%,
      rgba(255, 242, 194, 0) 70%
    );
 
    .member-item {
      height: 100%;
      display: flex;
      flex-direction: column;
 
      .member-title {
        margin-top: 20px;
        width: 100%;
        font-family: "Source Han Sans CN Bold Bold";
        font-weight: bold;
        font-size: 16px;
        color: rgba(0, 0, 0, 0.8);
        line-height: 16px;
        text-align: center;
      }
 
      .member-name-box-2 {
        padding: 0 20px;
        padding-top: 40px;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 20px;
        justify-content: center;
      }
 
      .member-name {
        width: 60px;
        height: 60px;
        background: #7d8b79;
        border-radius: 50%;
        text-align: center;
        line-height: 60px;
        font-weight: 500;
        font-size: 16px;
        color: #ffffff;
      }
 
      .member-edit {
        cursor: pointer;
        position: absolute;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        font-weight: 400;
        font-size: 12px;
        color: #ff4d4f;
        line-height: 22px;
        width: 40px;
        background: #fff1f0;
        border-radius: 4px;
        border: 1px solid #ffccc7;
        text-align: center;
      }
    }
  }
}
 
.add-project-footer {
  display: flex;
  gap: 20px;
  margin-top: 43px;
 
  button {
    width: 220px;
  }
}
</style>