Fixiaobai
2023-10-25 ae87b881865d0b6812aba2a8928cadb9ef6dd62a
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
<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible"
  >
    <el-form
      :model="dataForm"
      :rules="dataRule"
      ref="dataForm"
      @keyup.enter.native="dataFormSubmit()"
      label-width="120px"
      class="l-mes"
    >
      <el-row>
        <el-col :span="10"
          ><div class="grid-content bg-purple">
            <el-form-item label="订/工单号" prop="orderNo">
              <el-input
                v-model="dataForm.orderNo"
                placeholder="订/工单号"
                disabled
              ></el-input>
            </el-form-item>
 
            <el-form-item label="零件编号" prop="partNo">
              <el-input
                v-model="dataForm.partNo"
                placeholder="零件编号"
                disabled
              >
              </el-input>
            </el-form-item>
            <el-form-item label="零件批次" prop="partBatch">
              <el-input
                v-model="dataForm.partBatch"
                placeholder="零件批次"
                disabled
              ></el-input>
            </el-form-item>
            <el-form-item label="零件名称" prop="partDesc">
              <el-input
                v-model="dataForm.partDesc"
                placeholder="零件名称"
                disabled
              ></el-input>
            </el-form-item>
            <el-form-item label="模板描述" prop="templateDesc">
              <el-input
                v-model="dataForm.templateDesc"
                placeholder="模板描述"
                disabled
              ></el-input>
            </el-form-item></div
        ></el-col>
 
        <el-col :span="12"
          ><div class="grid-content bg-purple">
            <el-form-item label="检测人" prop="testUser">
              <el-input
                v-model="dataForm.testUser"
                placeholder="检测人"
                disabled
              ></el-input>
            </el-form-item>
            <el-form-item label="检测结论" prop="testResult">
              <el-select
                v-model="dataForm.testResult"
                filterable
                placeholder="请选择"
              >
                <el-option
                  v-for="(item, index) in testCheckTypeOptions"
                  :key="index"
                  :label="item.value"
                  :value="item.value"
                >
                </el-option>
              </el-select>
              <!--<el-input v-model="dataForm.testResult" placeholder="检测结论"></el-input>-->
            </el-form-item>
            <el-form-item label="检测次数" prop="testCount">
              <el-input
                type="number"
                v-model="dataForm.testCount"
                placeholder="检测次数"
              ></el-input>
            </el-form-item>
            <el-form-item label="备注" prop="remark">
              <el-input
                type="textarea"
                v-model="dataForm.remark"
                placeholder="备注"
              ></el-input>
            </el-form-item></div
        ></el-col>
      </el-row>
      <!--检测汇报关联的检验项-->
      <el-row>
        <el-tabs type="border-card">
          <el-tab-pane label="检验项">
            <el-table
              :data="dataForm.reportItems"
              height="300"
              class="tableItems"
            >
              <el-table-column
                prop="testItems"
                header-align="center"
                align="center"
                label="检测项目"
              >
                <template slot-scope="scope">
                  <el-input v-model="scope.row.testItems" disabled></el-input>
                </template>
              </el-table-column>
 
              <el-table-column
                prop="testRequirements"
                header-align="center"
                align="center"
                label="检测要求"
              >
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.testRequirements"
                    disabled
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                prop="testUnit"
                header-align="center"
                align="center"
                label="计量单位"
              >
                <template slot-scope="scope"
                  ><el-input v-model="scope.row.testUnit" disabled></el-input
                ></template>
              </el-table-column>
              <el-table-column
                prop="testMethod"
                header-align="center"
                align="center"
                label="检验方法"
              >
                <template slot-scope="scope"
                  ><el-input v-model="scope.row.testMethod" disabled></el-input
                ></template>
              </el-table-column>
              <el-table-column
                prop="testValue"
                header-align="center"
                align="center"
                label="检测值"
              >
                <template slot-scope="scope">
                  <el-form-item
                    :prop="'reportItems.' + scope.$index + '.testValue'"
                    :rules="dataRule.testValue"
                    class="testValue"
                  >
                    <el-input v-model="scope.row.testValue"></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                prop="testResult"
                header-align="center"
                align="center"
                label="检测结果"
              >
                <template slot-scope="scope">
                  <el-form-item
                    :prop="'reportItems.' + scope.$index + '.testResult'"
                    class="testResult"
                  >
                    <el-input v-model="scope.row.testResult"></el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                prop="remark"
                header-align="center"
                align="center"
                label="备注"
              >
                <template slot-scope="scope"
                  ><el-input v-model="scope.row.remark"></el-input
                ></template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </el-row>
    </el-form>
    <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 { getReportObj, addObj, putObj } from '@/api/quality/testreport'
import { getObj } from '@/api/basic/part'
import { dir } from '@/api/quality/template'
export default {
  data() {
    return {
      visible: false,
      showTask: false,
      updateData: false,
      testCheckTypeOptions: [],
      dataForm: {
        id: 0,
        testTaskId: '',
        testResult: '',
        testTime: '',
        testUser: '',
        testCount: '',
        remark: '',
        orderNo: '',
        reportItems: [],
        templates: [],
        tasks: [],
        items: [],
        taskId: null,
        partNo: '',
        partBatch: '',
        partDesc: '',
        templateId: 0,
        templateDesc: '',
        testReportId: 0
      },
      dataRule: {
        partNo: [
          { required: true, message: '零件编号不能为空', trigger: 'blur' }
        ],
        testResult: [
          { required: true, message: '检测结论不能为空', trigger: 'blur' }
        ],
        testTime: [
          { required: true, message: '检测时间不能为空', trigger: 'blur' }
        ],
        testCount: [
          { required: true, message: '检测次数不能为空', trigger: 'blur' }
        ],
        testValue: [
          { required: true, message: '检测值不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    init(id) {
      this.initCheckType('check_type')
      this.updateData = false
      this.initDefaultForm()
      this.dataForm.id = id || 0
      this.visible = true
      this.$nextTick(() => {
        this.$refs.dataForm.resetFields()
        if (this.dataForm.id) {
          this.updateData = true
          getReportObj(this.dataForm.id).then((response) => {
            this.dataForm = response.data.data
            this.dataForm.templateDesc =
              response.data.data.templates[0].qtplDesc
            this.dataForm.partBatch = response.data.data.tasks[0].partBatch
            this.getPartById(response.data.data.tasks[0].partId)
          })
        }
      })
    },
    // 初始化表单
    initDefaultForm() {
      ;(this.dataForm.id = 0),
        (this.dataForm.testTaskId = null),
        (this.dataForm.testResult = null),
        (this.dataForm.testTime = null),
        (this.dataForm.testUser = null),
        (this.dataForm.testCount = null),
        (this.dataForm.remark = null),
        (this.dataForm.orderNo = null),
        (this.dataForm.templates = []),
        (this.dataForm.tasks = []),
        (this.dataForm.items = []),
        (this.dataForm.reportItems = [])
      ;(this.dataForm.partNo = null),
        (this.dataForm.partBatch = null),
        (this.dataForm.partDesc = null),
        (this.dataForm.templateId = 0),
        (this.dataForm.templateDesc = null)
    },
    // 表单提交
    dataFormSubmit() {
      this.$refs.dataForm.validate((valid) => {
        if (valid) {
          if (this.dataForm.id) {
            putObj(this.dataForm).then((data) => {
              this.$message.success('修改成功')
              this.visible = false
              this.$emit('refreshDataList')
            })
          } else {
            addObj(this.dataForm).then((data) => {
              this.$message.success('添加成功')
              this.visible = false
              this.$emit('refreshDataList')
            })
          }
        }
      })
    },
    // 修改时根据零件id 获取零件信息
    getPartById(id) {
      getObj(id).then((response) => {
        this.dataForm.partNo = response.data.data.partNo
        this.dataForm.partDesc = response.data.data.description
      })
    },
    // 数据字典获取
    initCheckType(index) {
      dir(index).then((res) => {
        this.testCheckTypeOptions = res.data.data
      })
    }
  }
}
</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>