hailin
2023-08-03 a4b23bbf535f10c5ecc31b16bc8177bcfc23e996
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<style scoped>
  .rawInsBox{
        height: 100%;
        width: 100%;
        overflow-y: scroll;
        display: flex;
        flex-direction: column;
  }
  .rawInsBox .title .el-button {
    height: 32px;
    border: 1px solid rgba(190, 190, 190, 0.44);
    box-shadow: 0px 2px 4px rgba(220, 220, 220, 0.41);
    padding: 0 12px;
  }
  .rawInsBox .title {
    margin-bottom: 10px;
    padding: 0 20px;
  }
  /* 检验详情 */
  .raw-detail-info{
    background: #fff;
    padding: 26px 0px 11px 80px;
  }
  .raw-detail-info >>>.el-form-item__label{
 
        color: rgb(51, 51, 51);
        font-family: 微软雅黑;
        font-size: 16px;
        font-weight: 400;
        letter-spacing: 0px;
  }
  .raw-detail-info .el-input{
        width: auto;
  }
  .raw-detail-info.raw-detail-info-edit >>>.el-input__inner{
    background:#fff;
  }
  .raw-detail-info >>>.el-input__inner{
    width: 224px;
    height: 32px;
    box-sizing: border-box;
    background: rgb(238, 238, 238);
    border: 1px solid rgb(221, 221, 221);
    border-radius:4px;
  }
  .raw-detail-info .el-form-item{
    margin-bottom: 24px;
  }
  .raw-detail-info .el-form-item .el-button {
    height: 32px;
    border: 1px solid rgba(190, 190, 190, 0.44);
    box-shadow: 0px 2px 4px rgba(220, 220, 220, 0.41);
    padding: 0 12px;
  }
 
  /* 检验项目 */
  .raw-project-table{
    padding: 24px 14px;
    background: #fff;
    flex: 1;
    /* max-height: 360px; */
    /* overflow-y: hidden; */
  }
  /* 检验结论 */
  .raw-conclusion-table{
    padding: 9px 14px;
    background: #fff;
  }
</style>
 
 
<template>
  <div class="rawInsBox">
    <div class="title">
      <el-row>
        <el-col :span="12" style="line-height: 32px;">原材料检验</el-col>
        <el-col :span="12" style="text-align: right;">
          <el-button icon="el-icon-download" @click="()=>{goBack()}">返 回</el-button>
        </el-col>
      </el-row>
    </div>
    <div class="raw-detail-info" :class="detailId===null?'raw-detail-info-edit':''">
        <el-form v-model="detailInfo" label-position="right" label-width="120px" >
            <el-row>
                <el-col :span="7">
                    <el-form-item label="来料日期:">
                        <el-input v-if="detailId!==null" :disabled="detailId!==null" v-model="detailInfo.formTime"></el-input>
                        <el-date-picker
                          v-else
                          type="date"
                          v-model="detailInfo.formTime"
                          placeholder="选择日期">
                        </el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="规格型号:">
                        <el-input :disabled="detailId!==null" v-model="detailInfo.specifications"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="原材料编码:">
                        <el-input :disabled="detailId!==null" v-model="detailInfo.code"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
             <el-row>
                <el-col :span="7">
                    <el-form-item label="原材料名称:">
                        <el-input :disabled="detailId!==null" v-model="detailInfo.name"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="数量:">
                        <el-input placeholder="请输入检验数量" :disabled="detailId!==null" v-model="detailInfo.number"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="单位:">
                        <el-input placeholder="请输入检验单位" :disabled="detailId!==null" v-model="detailInfo.unit"></el-input>
                    </el-form-item>
                </el-col>
                <el-col  :span="3">
                    <el-form-item v-show="detailId===null" label="" label-width="100px">
                        <el-button  @click="addNewRawInspect">保存提交</el-button>
                    </el-form-item>
                </el-col>
            </el-row>
             <el-row>
                
                <el-col :span="7">
                    <el-form-item v-show="detailId!==null" label="报检日期:">
                        <el-input :disabled="detailId!==null" v-model="detailInfo.createTime"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="14">
                    <el-form-item v-show="detailId!==null" label="报检人:">
                        <el-input :disabled="detailId!==null" v-model="detailInfo.userName"></el-input>
                    </el-form-item>
                </el-col>
                
            </el-row>
        </el-form>
        <!-- <el-form v-show="detailId ===null" v-model="rawInsParams" label-position="right" label-width="120px" >
            <el-row>
                <el-col :span="7">
                    <el-form-item label="订单号:">
                        <el-input placeholder="请输入订单号" v-model="rawInsParams.orderNumber"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="客户名称:">
                        <el-input placeholder="请输入客户名称" v-model="rawInsParams.customerName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="工程名称:">
                        <el-input placeholder="请输入工程名称"  v-model="rawInsParams.projectName"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
             <el-row>
                <el-col :span="7">
                    <el-form-item label="质量追溯号:">
                        <el-input  placeholder="请输入质量追溯号"  v-model="rawInsParams.qualityTraceability"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="项目名称:">
                        <el-select placeholder="请输入项目名称" v-model="rawInsParams.material">
                          <el-option v-for="item in materialOptions" :key="item.id" :label="item.name" :value="item.name"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="产品编码:">
                        <el-input placeholder="产品编码" disabled  v-model="code"></el-input>
                    </el-form-item>
                </el-col>
                
            </el-row>
             <el-row>
                <el-col :span="7">
                    <el-form-item label="规格型号:">
                        <el-input  v-model="detailInfo.specificationsModel"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="单位:">
                        <el-input placeholder="请输入单位"  v-model="rawInsParams.unit"></el-input>
                    </el-form-item>
                </el-col>
                <el-col  :span="7">
                    <el-form-item label="数量">
                      <el-input  placeholder="请输入产品编码"  v-model="rawInsParams.qualityTraceability"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
             <el-row>
                <el-col :span="21">
                    <el-form-item label="主机工:">
                        <el-input placeholder="请输入主机工"  v-model="rawInsParams.userId"></el-input>
                    </el-form-item>
                </el-col>
                <el-col  :span="3">
                    <el-form-item label="" label-width="100px">
                        <el-button  @click="addNewRawInspect">保存提交</el-button>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form> -->
    </div>
    <div class="title">
      <el-row>
        <el-col :span="12" style="line-height: 32px;">检验项目</el-col>
      </el-row>
    </div>
    <div class="raw-project-table">
        <el-table
            :data="projectTable"
            style="width: 100%"
            max-height="320"
            >
            <el-table-column
                type="index"
                label="序号"
                width="100"
                >
            </el-table-column>
            <el-table-column
                prop="name"
                label="项目"
                width="212">
            </el-table-column>
            <el-table-column
                prop="unit"
                label="单位"
                width="148">
            </el-table-column>
            <el-table-column
                prop="required"
                label="标准"
                width="254">
            </el-table-column>
            <el-table-column
                prop="internal"
                label="内控值"
                width="291">
            </el-table-column>
            <el-table-column
                prop="testValue"
                label="检查值"
                width="371">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.testValue" @blur="changeState(scope.row)"></el-input>
                </template>
            </el-table-column>
            <el-table-column
                prop="deviceName"
                label="试验设备"
                width="248"
                >
            </el-table-column>
            <el-table-column
                prop="testState"
                label="结论"
                 width="98"
                >
                <template slot-scope="scope">
                  <span v-show="scope.row.testState!=null" :style="{color: scope.row.testState===1?'#67C23A':'#F56C6C'}">{{scope.row.testState===1?'合格':'不合格'}}</span>
                  <span v-show="scope.row.testState==null">暂未结论</span>
                </template>
            </el-table-column>
    </el-table>
    </div>
    <div class="title">
      <el-row>
        <el-col :span="12" style="line-height: 32px;">检验结论</el-col>
      </el-row>
    </div>
    <div class="raw-conclusion-table">
        <el-table :data="conclusionTable">
            <el-table-column
                prop="code"
                label="物料编号"
                width="353">
            </el-table-column>
            <el-table-column
                prop="name"
                label="物料名称"
                width="353">
            </el-table-column>
            <el-table-column
                prop="names"
                label="检验员"
                width="542">
                <template slot-scope="scope">
                  <span v-for="item in scope.row.names" :key="item.username" :style="{marginRight:'8px'}">{{item}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="testState"
                label="检验结论"
                width="362">
                 <template slot-scope="scope">
                  <span v-show="scope.row.testState!=null" :style="{color: scope.row.testState===1?'#67C23A':'#F56C6C'}">{{scope.row.testState===1?'合格':'不合格'}}</span>
                  <span v-show="scope.row.testState==null">暂未结论</span>
                </template>
            </el-table-column>
             <el-table-column
                label="操作"
                width="120">
                <template>
                    <el-button type="text" size="small" @click.once="submitSave">上报</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
  </div>
</template>
 
<script>
import RawIns from './raw-ins.vue'
export default {
    components:{RawIns},
    props:['goBack','detailId'],
    created(){
      // 清空
      this.detailInfo = {}
      if(this.detailId){
        console.log(this.detailId)
        this.getDetailInfo()
      }else{
        this.getOptions()
      }  
    },
    mounted(){
    },
    computed:{
      conclusionTable(){
        // console.log(this.projectTable)
        // console.log(this.projectTable.map(item=>item.userName))
        const conclusion = {}
        conclusion.name = this.detailInfo.name
        conclusion.code = this.detailInfo.code
        conclusion.names= [...new Set(this.projectTable.map(item=>item.userName))]
        console.log(this.projectTable.filter(item=>item.testState===0))
        if(this.projectTable.filter(item=>item.testState===null).length){
          conclusion.testState = null
          return [conclusion]
        }
        if(this.projectTable.filter(item=>item.testState===0).length>0){
          conclusion.testState= 0
        }else{
          conclusion.testState= 1
        }
        return [conclusion]
      },
      // 产品编码
      // code(){
      //   const material= this.materialOptions.filter(item=>item.name===this.rawInsParams.material)[0]
      //   return  material && material.code
      // }
    },
    data() {
        return {
          // 详情页就是详情信息
          detailInfo:{},
          projectTable:[],
          // 新建检验单参数对象
          rawInsParams:{},
          // 项目名称options
          materialOptions:[]
        }
    },
    methods:{
      // 获取报检单详情信息
      async getDetailInfo() {
        const {data} = await this.$axios.get(this.$api.url.selectRawInspectsListById+`${this.detailId}`,{params:{id:this.detailId}})
        this.detailInfo  = data
        this.projectTable = data.rawInsProducts
        // console.log(this.projectTable)
      },
      // 新增检验单
      addNewRawInspect() {
        console.log(this.detailInfo)
      },
      // 修改项目的检测值改变结论
      async changeState(row){
        // console.log(row)
        const res = await this.$axios.post(this.$api.url.updaterawInsProduct,{...row},{headers:{'Content-Type':'application/json'}})
        this.$message.success('提交成功')
        this.getDetailInfo()//重新刷新信息数据
      },
      async submitSave() {
        const res = await this.$axios.post(this.$api.url.updateRawInspectsById+`${this.detailId}`)
        this.$message.success('提交成功')
        this.getDetailInfo()
      },
      async getOptions() {
        const {data} = await this.$axios.get(this.$api.url.listMaterial) 
        this.materialOptions = data
      }
     }
}
</script>