zouyu
2023-11-17 d8ac6057eaad648687699e25a575f3b7b8c1b102
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
<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-card class="operation-capacity" header="检测汇报">
        <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="请选择"
                  disabled
                >
                  <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="检测次数"
                  disabled
                ></el-input>
              </el-form-item>
              <el-form-item label="备注" prop="remark">
                <el-input
                  v-model="dataForm.remark"
                  placeholder="备注"
                  disabled
                ></el-input>
              </el-form-item></div
          ></el-col>
        </el-row>
      </el-card>
      <!--检测汇报关联的检验项-->
      <el-card class="operation-capacity" header="不合格处理">
        <el-row>
          <el-col :span="10">
            <el-form-item label="数量" prop="number">
              <el-input v-model="dataForm.number" placeholder="数量"></el-input>
            </el-form-item>
            <el-form-item label="原因" prop="remarks">
              <el-input
                v-model="dataForm.remarks"
                placeholder="原因"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="处理类型" prop="type">
              <el-input
                v-model="dataForm.type"
                placeholder="处理类型"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
    </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 { getObj } from '@/api/basic/part'
import { dir } from '@/api/quality/template'
import {
  getReportProcessingObj,
  putReportProcessingObj
} from '../../../api/quality/testreport'
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,
        number: '',
        remarks: '',
        updateUser: '',
        updateTime: '',
        type: ''
      },
      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
          getReportProcessingObj(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) {
            putReportProcessingObj(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>