spring
2025-04-16 3c510ea35b428feed7f7a1743a595e7dba634518
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
<template>
  <div>
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible"
      title="仪器设备期间核查比对记录表" width="80%" @close="resetForm">
      <el-steps :active="currentStep" align-center finish-status="success">
        <el-step title="填写设备核查对比记录"></el-step>
        <el-step title="审核"></el-step>
      </el-steps>
      <div class="form">
        <div class="form-item">
          <span style="width: 116px">核查方式:</span>
          <el-input v-model="form.checkMethod" :disabled="currentStep !== 0" clearable size="small"></el-input>
        </div>
      </div>
      <div class="form">
        <div class="form-item">
          <span style="width: 80px">A仪器名称:</span>
          <el-select v-model="form.adeviceId" :disabled="currentStep !== 0" class="table_input" clearable filterable
            placeholder="设备名称" size="small" style="width:200px" @change="(val) => changeMachineName(val, 'A')">
            <el-option v-for="item in equipOptions" :key="item.value" :label="item.label" :value="item.id">
              {{ item.label + '-' + item.value }}
            </el-option>
          </el-select>
        </div>
        <div class="form-item">
          <span style="width: 116px">A仪器编号:</span>
          <el-input v-model="form.adeviceNumber" :disabled="currentStep !== 0" clearable size="small"></el-input>
        </div>
        <div class="form-item">
          <span style="width: 150px">A仪器测定范围/不确定度:</span>
          <el-input v-model="form.arangeUncertainty" :disabled="currentStep !== 0" clearable size="small"></el-input>
        </div>
      </div>
      <div class="form">
        <div class="form-item">
          <span style="width: 80px">B仪器名称:</span>
          <el-select v-model="form.bdeviceId" :disabled="currentStep !== 0" class="table_input" clearable filterable
            placeholder="设备名称" size="small" style="width:200px" @change="(val) => changeMachineName(val, 'B')">
            <el-option v-for="item in equipOptions" :key="item.value" :label="item.label" :value="item.id">
              {{ item.label + '-' + item.value }}
            </el-option>
          </el-select>
        </div>
        <div class="form-item">
          <span style="width: 116px">B仪器编号:</span>
          <el-input v-model="form.bdeviceNumber" :disabled="currentStep !== 0" clearable size="small"></el-input>
        </div>
        <div class="form-item">
          <span style="width: 150px">B仪器测定范围/不确定度:</span>
          <el-input v-model="form.brangeUncertainty" :disabled="currentStep !== 0" clearable size="small"></el-input>
        </div>
      </div>
      <div class="form">
        <div class="form-item">
          <span style="width: 80px">C仪器名称:</span>
          <el-select v-model="form.cdeviceId" :disabled="currentStep !== 0" class="table_input" clearable filterable
            placeholder="设备名称" size="small" style="width:200px" @change="(val) => changeMachineName(val, 'C')">
            <el-option v-for="item in equipOptions" :key="item.value" :label="item.label" :value="item.id">
              {{ item.label + '-' + item.value }}
            </el-option>
          </el-select>
        </div>
        <div class="form-item">
          <span style="width: 116px">C仪器编号:</span>
          <el-input v-model="form.cdeviceNumber" :disabled="currentStep !== 0" clearable size="small"></el-input>
        </div>
        <div class="form-item">
          <span style="width: 150px">C仪器测定范围/不确定度:</span>
          <el-input v-model="form.crangeUncertainty" :disabled="currentStep !== 0" clearable size="small"></el-input>
        </div>
      </div>
      <div>
        <el-button v-if="currentStep === 0" size="small" type="primary" @click="addTableRow">添加</el-button>
      </div>
      <div style="margin: 10px 0">
        <el-table ref="yearTable" :data="recordContrastDetailsList" height="300px" style="width: 100% ;"
                  :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border>
          <el-table-column align="center" header-align="center" label="序号" type="index" width="60"></el-table-column>
          <el-table-column label="核查项目" min-width="170" prop="checkItems">
            <template slot-scope="scope">
              <el-input v-model="scope.row.checkItems" :disabled="currentStep !== 0" clearable size="small"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="A仪器示值" min-width="120" prop="indicationA">
            <template slot-scope="scope">
              <el-input v-model="scope.row.indicationA" :disabled="currentStep !== 0" clearable size="small"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="B仪器示值" min-width="120" prop="indicationB">
            <template slot-scope="scope">
              <el-input v-model="scope.row.indicationB" :disabled="currentStep !== 0" clearable size="small"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="C仪器示值" min-width="120" prop="indicationC">
            <template slot-scope="scope">
              <el-input v-model="scope.row.indicationC" :disabled="currentStep !== 0" clearable size="small"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="差值" min-width="90" prop="dvalue">
            <template slot-scope="scope">
              <el-input v-model="scope.row.dvalue" :disabled="currentStep !== 0" clearable size="small"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="相对偏差" min-width="90" prop="deviation">
            <template slot-scope="scope">
              <el-input v-model="scope.row.deviation" :disabled="currentStep !== 0" clearable size="small"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="判定" min-width="110" prop="determine">
            <template slot-scope="scope">
              <el-input v-model="scope.row.determine" :disabled="currentStep !== 0" clearable size="small"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="form">
        <div class="form-item">
          <span style="width: 116px">综合判定:</span>
          <el-input v-model="form.judgment" :disabled="currentStep !== 0" clearable size="small"></el-input>
        </div>
        <div class="form-item">
          <span style="width: 116px">审核人:</span>
          <el-select v-model="form.reviewUserId" :disabled="currentStep !== 0" placeholder="请选择" size="small"
            style="width: 100%">
            <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="resetForm">取 消</el-button>
        <el-button v-if="currentStep === 0" :loading="submitFormLoading" type="primary" @click="submitCheck">确
          定</el-button>
        <el-button v-if="currentStep === 1" :loading="submitFormLoading" @click="examine(0)">不通过</el-button>
        <el-button v-if="currentStep === 1" :loading="submitFormLoading" type="primary" @click="examine(1)">通
          过</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import {
  getExamineRecordContrast,
  reviewExamineRecordContrast,
  deviceScopeSearch,
  addExamineRecordContrast,
} from '@/api/cnas/resourceDemand/device.js'
import { selectUserCondition } from "@/api/business/inspectionTask";
export default {
  name: "equipment-check",
  // import 引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    // 这里存放数据
    return {
      dialogVisible: false,
      submitFormLoading: false,
      currentStep: 0,
      showStep: 0,
      form: {
        checkerTime: '',
        checkMethod: '',
        adeviceId: '',
        adeviceNumber: '',
        arangeUncertainty: '',
        bdeviceId: '',
        bdeviceNumber: '',
        brangeUncertainty: '',
        cdeviceId: '',
        cdeviceNumber: '',
        crangeUncertainty: '',
        recordContrastDetailsList: [],
        judgment: '',
        reviewUserId: '',
        reviewStatus: '',
        planDetailsId: '',
      },
      equipOptions: [],
      recordContrastDetailsList: [],
      userList: [],
    }
  },
  mounted() {
 
  },
  // 方法集合
  methods: {
    openDialog(row) {
      this.dialogVisible = true
      this.form.planDetailsId = row.planDetailsId
      this.getEquipOptions()
      this.getUserList()
      this.searchInfo()
    },
    searchInfo() {
      getExamineRecordContrast({ planDetailsId: this.form.planDetailsId }).then(res => {
        if (res.code === 200) {
          this.form = { ...res.data }
          this.recordContrastDetailsList = this.form.recordContrastDetailsList || []
          if (!this.form.reviewUserId) {
            this.currentStep = 0
          } else {
            this.currentStep = 1
          }
          if (this.form.reviewStatus === 1) {
            this.currentStep = 2
          }
        }
      }).catch(error => {
        console.error(error)
      })
    },
    // 赋值仪器编号
    changeMachineName(value, type) {
      const index = this.equipOptions.findIndex(item => item.id === value)
      if (index > -1) {
        if (type === 'A') {
          this.$set(this.form, 'adeviceNumber', this.equipOptions[index].value)
        }
        if (type === 'B') {
          this.$set(this.form, 'bdeviceNumber', this.equipOptions[index].value)
        }
        if (type === 'C') {
          this.$set(this.form, 'cdeviceNumber', this.equipOptions[index].value)
        }
      }
    },
    // 添加表格数据
    addTableRow() {
      this.recordContrastDetailsList.push({ checkItems: '' })
    },
    submitCheck() {
      this.form.recordContrastDetailsList = this.HaveJson(this.recordContrastDetailsList)
      this.submitFormLoading = true
      addExamineRecordContrast(this.form).then(res => {
        if (res.code == 200) {
          this.$message.success('新增成功')
          this.resetForm()
        }
        this.submitFormLoading = false
      }).catch(err => {
        this.submitFormLoading = false
      })
    },
    examine(statue) {
      const params = {
        planDetailsId: this.form.planDetailsId,
        reviewStatus: statue,
      }
      reviewExamineRecordContrast(params).then(res => {
        if (res.code == 200) {
          this.$message.success('审核成功')
          this.resetForm()
        }
        this.submitFormLoading = false
      }).catch(err => {
        this.submitFormLoading = false
      })
    },
    resetForm() {
      this.dialogVisible = false
      this.$emit('closeDialog')
    },
    // 获取所有设备
    getEquipOptions() {
      this.equipOptions = []
      deviceScopeSearch({ status: 0 }).then(res => {
        if (res.code === 200 && res.data) {
          this.equipOptions = res.data.map(m => {
            m.value = m.managementNumber
            m.label = m.deviceName
            m.id = m.id
            return m
          })
        }
      }).catch(error => {
        console.error(error)
      })
    },
    getUserList() {
      selectUserCondition().then(res => {
        this.userList = res.data
      })
    },
  },
}
</script>
 
<style scoped>
.form {
  display: flex;
  align-items: center;
}
 
.form-item {
  display: flex;
  align-items: center;
  margin-right: 20px;
}
</style>