gaoluyang
18 小时以前 29be8639dc16b5d82bddc6099b1fa5cdca75f77a
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
<template>
  <el-dialog v-model="visible" title="质量控制评价记录" width="min(960px, 94vw)" @closed="$emit('close')">
    <div class="record-code">记录编号:LMSY-CX30-JL03</div>
    <el-alert v-if="row"
              :title="`监控任务 ${row.inspectionTaskCode || row.entrustCode || ''} · ${row.monitorProject || ''}`"
              type="info"
              :closable="false"/>
    <el-alert v-if="!canEdit" :title="editNotice" :type="loaded ? 'warning' : 'info'"
              :closable="false" style="margin-top:8px"/>
    <div class="role-hint">监督员默认为计划中指定的评价人,被监督人员为计划中指定的检测员。</div>
    <el-form :model="form" label-width="150px" style="margin-top: 16px">
      <el-row :gutter="12">
        <el-col :span="12">
          <el-form-item label="检测项目">
            <el-input :model-value="row?.monitorProject" disabled/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="检测时间">
            <el-input :model-value="inspectionDateDisplay" readonly placeholder="原始记录复核后自动带入"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="检测样品">
            <el-input :model-value="row?.sampleName || row?.sample" disabled/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所用设备">
            <el-input :model-value="form.rawEquipmentDescription || ''" type="textarea"
                      :autosize="{ minRows: 1, maxRows: 6 }" readonly placeholder="原始记录复核后自动带入"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="设备规格">
            <el-input :model-value="form.rawEquipmentSpec || ''" type="textarea" :autosize="{ minRows: 1, maxRows: 6 }"
                      readonly/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="设备编号">
            <el-input :model-value="form.rawEquipmentCode || ''" type="textarea" :autosize="{ minRows: 1, maxRows: 6 }"
                      readonly/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="监督员(评价人)">
            <el-select v-model="form.supervisorUserId" filterable style="width: 100%" :disabled="!canEdit">
              <el-option v-for="person in supervisorOptions" :key="person.id" :value="person.id" :label="person.name"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="被监督人员(检测员)">
            <el-input :model-value="supervisedPersonName" disabled/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="检测情况及评价">
        <el-input v-model="form.evaluationConclusion" type="textarea" :rows="4" :disabled="!canEdit"/>
      </el-form-item>
      <el-table :data="form.resultRows" border style="width:100%">
        <el-table-column label="人员姓名" min-width="120">
          <template #default>{{ supervisedPersonName }}</template>
        </el-table-column>
        <el-table-column label="当日检测数据" min-width="180">
          <template #default="{ row: item }"><span :title="item.itemName || ''">{{
              item.measuredValue
            }} {{ item.unit === '/' ? '' : item.unit }}</span></template>
        </el-table-column>
        <el-table-column label="盲样值" min-width="180">
          <template #default="{ row: item }">
            <el-input v-model="item.referenceValue" :disabled="!canEdit" placeholder="评价人填写"/>
          </template>
        </el-table-column>
      </el-table>
      <el-checkbox v-if="canEdit" v-model="form.measurementConfirmed" style="margin:12px 0">
        已核对当日检测数据与已复核原始记录一致
      </el-checkbox>
      <el-form-item label="评价人员签字">
        <el-input
            :model-value="form.reviewUser ? `${form.reviewUser} ${form.reviewTime || ''}` : '提交后记录评价人及日期'"
            disabled/>
      </el-form-item>
      <el-form-item label="纠正措施及预防措施">
        <el-input v-model="form.correctiveAction" type="textarea" :rows="2" :disabled="!canEdit"/>
      </el-form-item>
      <el-row :gutter="12">
        <el-col :span="12">
          <el-form-item label="纠正责任人">
            <el-select v-model="form.correctiveResponsibleUserId" filterable clearable style="width:100%"
                       :disabled="!canEdit">
              <el-option v-for="person in people" :key="person.id" :value="person.id" :label="person.name"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="完成日期">
            <el-date-picker v-model="form.correctiveDueDate" type="date" value-format="YYYY-MM-DD" style="width:100%"
                            :disabled="!canEdit"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="验证情况">
        <el-input v-model="form.verificationResult" type="textarea" :rows="2" :disabled="!canEdit"/>
      </el-form-item>
      <el-row :gutter="12">
        <el-col :span="12">
          <el-form-item label="验证责任人">
            <el-select v-model="form.verificationResponsibleUserId" filterable clearable style="width:100%"
                       :disabled="!canEdit">
              <el-option v-for="person in people" :key="person.id" :value="person.id" :label="person.name"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="验证日期">
            <el-date-picker v-model="form.verificationDate" type="date" value-format="YYYY-MM-DD" style="width:100%"
                            :disabled="!canEdit"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item v-if="form.ratifyOpinion" label="批准意见">
        <el-input :model-value="form.ratifyOpinion" disabled/>
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button @click="visible = false">关闭</el-button>
      <el-button v-if="canEdit" type="primary" :loading="loading" @click="save">提交评价</el-button>
      <template v-if="canApprove">
        <el-button :loading="loading" @click="approve(false)">退回评价</el-button>
        <el-button type="primary" :loading="loading" @click="approve(true)">批准归档</el-button>
      </template>
    </template>
  </el-dialog>
</template>
 
<script>
import {mapGetters} from '@/utils/store-compat';
import {selectUserCondition} from '@/api/performance/class';
import {
  getInspectionEvaluation,
  submitInspectionEvaluation,
  approveInspectionEvaluation
} from '@/api/cnas/process/ensureResults/qualityMonitor';
 
export default {
  name: 'InspectionEvaluationDialog',
  emits: ['close'],
  data() {
    return {visible: false, loading: false, loaded: false, loadError: '', row: null, people: [], form: {resultRows: []}}
  },
  computed: {
    ...mapGetters(['userId']),
    canEdit() {
      return this.loaded && this.form.evaluationEditable === true
    },
    inspectionDateDisplay() {
      const dates = this.form.rawInspectionDates || []
      if (!dates.length) return ''
      return dates.length === 1 ? dates[0] : `${dates[0]} ~ ${dates[dates.length - 1]}`
    },
    editNotice() {
      if (!this.loaded) return '正在读取评价记录和编辑权限…'
      return this.loadError || this.form.evaluationEditReason || '当前账号只能查看评价记录'
    },
    canApprove() {
      return !!this.form.detailsEvaluateId && this.form.isFinish !== 1 && Number(this.userId) === Number(this.row?.planRatifyUserId)
    },
    supervisedPersonName() {
      const id = this.form.inspectorUserId || this.row?.inspectorUserId
      return this.people.find(person => Number(person.id) === Number(id))?.name
        || this.form.inspectorName || this.row?.inspectorName || ''
    },
    supervisorOptions() {
      const inspectorId = Number(this.form.inspectorUserId || this.row?.inspectorUserId)
      // 监督员默认就是计划中的评价人,因此这里不能把评价人排除掉;只排除被监督的检测员
      const options = this.people.filter(person => Number(person.id) !== inspectorId)
      // 已保存的监督员如果不在人员下拉列表中(被角色/状态过滤或已停用),补一条选项保证能反显
      const savedId = this.form.supervisorUserId
      if (savedId && !options.some(person => Number(person.id) === Number(savedId))) {
        const saved = this.people.find(person => Number(person.id) === Number(savedId))
        options.unshift({
          id: savedId,
          name: saved?.name || this.form.supervisorName || `用户 ${savedId}`
        })
      }
      return options
    }
  },
  methods: {
    open(row) {
      this.row = row
      this.loaded = false
      this.loadError = ''
      this.form = {
        qualityMonitorDetailsId: row.qualityMonitorDetailsId,
        inspectorUserId: row.inspectorUserId,
        resultRows: [],
        measurementConfirmed: false
      }
      this.visible = true
      selectUserCondition({type: 1}).then(res => {
        this.people = res.data || []
      })
      getInspectionEvaluation(row.qualityMonitorDetailsId).then(res => {
        if (res.data) {
          this.form = {...res.data, resultRows: res.data.resultRows || [], measurementConfirmed: false}
          // 兜底:历史评价记录没有监督员时,默认带出计划评价人
          if (!this.form.supervisorUserId && this.row?.evaluatorUserId) {
            this.form.supervisorUserId = this.row.evaluatorUserId
            this.form.supervisorName = this.people.find(person => Number(person.id) === Number(this.row.evaluatorUserId))?.name || ''
          }
        }
      }).catch(() => {
        this.loadError = '评价记录读取失败,请刷新后重试'
      }).finally(() => {
        this.loaded = true
      })
    },
    save() {
      if (!this.form.supervisorUserId || !this.form.evaluationConclusion?.trim() || !this.form.resultRows?.length || this.form.resultRows.some(item => !item.measuredValue || !item.referenceValue?.trim()) || !this.form.measurementConfirmed) {
        this.$message.warning('请选择监督员,填写检测情况及评价、盲样值,并核对原始记录检测数据')
        return
      }
      this.loading = true
      submitInspectionEvaluation(this.form).then(() => {
        this.$message.success('评价已提交')
        this.visible = false
      }).finally(() => {
        this.loading = false
      })
    },
    approve(approved) {
      this.$prompt('请输入批准或退回意见', approved ? '批准评价' : '退回评价', {inputValue: this.form.ratifyOpinion || ''}).then(({value}) => {
        this.loading = true
        approveInspectionEvaluation({
          qualityMonitorDetailsId: this.row.qualityMonitorDetailsId,
          approved,
          opinion: value
        }).then(() => {
          this.$message.success(approved ? '评价已归档' : '评价已退回')
          this.visible = false
        }).finally(() => {
          this.loading = false
        })
      }).catch(() => {
      })
    }
  }
}
</script>
 
<style scoped>
.role-hint {
  margin-top: 8px;
  font-size: 12px;
  line-height: 18px;
  color: var(--el-text-color-secondary);
}
</style>