Fixiaobai
2023-11-16 4bf457a5c8433c9ec6f0ec86b2c1c20c5e667391
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
<template>
  <el-dialog
    :title="!dataForm.id ? '不合格处理' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible"
  >
    <!--检测汇报关联的检验项-->
    <el-card class="operation-capacity" header="不合格处理">
      <el-form
        :model="dataForm"
        :rules="dataRule"
        ref="dataForm"
        label-width="120px"
        class="l-mes"
      >
        <el-row>
          <el-col :span="8">
            <el-form-item label="编号" prop="processNo">
              <el-input v-model="dataForm.processNo" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="申请人" prop="initiatingOrganization">
              <el-input
                v-model="dataForm.initiatingOrganization"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="接收人" prop="receiver">
              <el-input v-model="dataForm.receiver" placeholder=""></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="原因" prop="reason">
              <el-input v-model="dataForm.reason" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="原因类型" prop="causeType">
              <el-select
                v-model="dataForm.causeType"
                placeholder="原因类型"
                filterable
                style="width: 100%"
              >
                <el-option
                  v-for="item in causeTypeOptions"
                  :key="item.id"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="整改措施" prop="correctiveMeasures">
              <el-input
                v-model="dataForm.correctiveMeasures"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="申请处理方式" prop="processMode">
              <el-select
                v-model="dataForm.processMode"
                placeholder="申请处理方式"
                style="width: 100%"
              >
                <el-option
                  v-for="item in processModeOptions"
                  :key="item.id"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="种类" prop="type">
              <el-select
                v-model="dataForm.type"
                placeholder="种类"
                style="width: 100%"
              >
                <el-option
                  v-for="item in typeOptions"
                  :key="item.id"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="不合格类别" prop="unqualifiedType">
              <el-select
                v-model="dataForm.unqualifiedType"
                placeholder="不合格类别"
                style="width: 100%"
              >
                <el-option
                  v-for="item in unqualifiedTypeOptions"
                  :key="item.id"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="不合格处理描述" prop="unqualifiedDesc">
              <el-input
                :maxlength="200"
                v-model="dataForm.unqualifiedDesc"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8"> </el-col>
          <el-col :span="7"> </el-col>
        </el-row>
      </el-form>
    </el-card>
    <el-card class="operation-capacity" header="不合格零件">
      <el-table
        stripe
        ref="applyPartList"
        :data="applyPartList"
        height="200px"
        :row-style="{ height: '26px' }"
      >
        <el-table-column
          label="系统编号"
          prop="systemNo"
          align="center"
          min-width="75px"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          label="零件批号"
          prop="lotBatchNo"
          align="center"
          min-width="75px"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          label="零件编号"
          prop="partNo"
          align="center"
          min-width="75px"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          label="零件名称"
          prop="partDesc"
          align="center"
          min-width="75px"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          label="不合格数量"
          prop="unqualifiedArrived"
          align="center"
          min-width="75px"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          label="备注"
          prop="remark"
          align="center"
          min-width="75px"
          :show-overflow-tooltip="true"
        ></el-table-column>
      </el-table>
    </el-card>
 
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>
 
<script>
import {
  getUnqualifiedProcess,
  addUnqualifiedProcess,
  putUnqualifiedProcess
} from '@/api/quality/unqualifiedprocess'
import { remote } from '@/api/admin/dict'
import { mapGetters } from 'vuex'
 
export default {
  props: {
    applyPartList: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      visible: false,
      dataForm: {
        id: 0,
        processNo: '',
        reason: '',
        processMode: '',
        initiatingOrganization: null,
        receiver: null,
        correctiveMeasures: null,
        causeType: null,
        mainProcessNo: null,
        unqualifiedDesc: null,
        type: null,
        unqualifiedType: null,
        processResult: null
      },
      dataRule: {
        causeType: [
          { required: true, message: '原因类型不能为空', trigger: 'blur' }
        ],
        unqualifiedDesc: [
          { required: true, message: '不合格处理描述', trigger: 'blur' }
        ]
      },
      causeTypeOptions: [],
      processModeOptions: [],
      typeOptions: [],
      unqualifiedTypeOptions: []
    }
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  methods: {
    getCauseType() {
      remote('unqualified_reason_type').then((response) => {
        if (response.data.code === 0) {
          this.causeTypeOptions = response.data.data
        }
      })
    },
    getProcessMode() {
      remote('unqualified_process_mode').then((response) => {
        if (response.data.code === 0) {
          this.processModeOptions = response.data.data
        }
      })
    },
    getType() {
      remote('unqualified_handle_type').then((response) => {
        if (response.data.code === 0) {
          this.typeOptions = response.data.data
        }
      })
    },
    getUnqualifiedType() {
      remote('unqualified_handle_category').then((response) => {
        if (response.data.code === 0) {
          this.unqualifiedTypeOptions = response.data.data
        }
      })
    },
    init(id) {
      this.getCauseType()
      this.getProcessMode()
      this.getType()
      this.getUnqualifiedType()
      this.dataForm.id = id || 0
      this.visible = true
      this.$nextTick(() => {
        this.$refs.dataForm.resetFields()
        if (this.dataForm.id) {
          getUnqualifiedProcess(this.dataForm.id).then((response) => {
            this.dataForm = response.data.data
          })
        } else {
          this.dataForm.initiatingOrganization = this.userInfo.staffName
        }
      })
    },
    // 表单提交
    dataFormSubmit() {
      this.$refs.dataForm.validate((valid) => {
        if (valid) {
          if (this.dataForm.id) {
            /* putUnqualifiedProcess(this.dataForm).then((data) => {
              this.$message.success('修改成功')
              this.visible = false
              this.$emit('refreshDataList')
            }) */
          } else {
            if (this.applyPartList && this.applyPartList.length > 0) {
              const qualityUnqualifiedProcess = []
 
              this.applyPartList.forEach((applyPart) => {
                qualityUnqualifiedProcess.push({
                  id: 0,
                  processNo: this.dataForm.processNo,
                  reason: this.dataForm.reason,
                  processMode: this.dataForm.processMode,
                  initiatingOrganization: this.dataForm.initiatingOrganization,
                  receiver: this.dataForm.receiver,
                  correctiveMeasures: this.dataForm.correctiveMeasures,
                  causeType: this.dataForm.causeType,
                  unqualifiedDesc: this.dataForm.unqualifiedDesc,
                  type: this.dataForm.type,
                  unqualifiedType: this.dataForm.unqualifiedType,
                  applyPartId: applyPart.id,
                  unqualifiedQuantity: applyPart.unqualifiedArrived
                })
              })
 
              addUnqualifiedProcess(qualityUnqualifiedProcess).then((data) => {
                this.$message.success('添加成功')
                this.visible = false
                this.$emit('refreshDataList')
              })
            } else {
              this.$message.warning('请选择不合格零件')
            }
          }
        }
      })
    }
  }
}
</script>
<style>
.tableItems td {
  padding: 0px 0px !important;
}
 
.testResult {
  padding-bottom: 0px !important;
  padding-top: 17px !important;
}
 
.testResult .el-form-item__content {
  margin-left: 0px !important;
}
 
.testValue {
  padding-bottom: 0px !important;
  padding-top: 17px !important;
}
 
.testValue .el-form-item__content {
  margin-left: 0px !important;
}
</style>