gaoluyang
2025-02-17 b7adcaff77a5028458380ab1e86a1087f35e7b60
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
<template>
  <div class="capacity-scope">
    <div>
      <el-row class="title">
        <el-col :span="12" style="text-align: left">
          <el-radio-group v-model="radio" size="medium" fill="#409EFF" @change="refreshTable">
            <el-radio-button :label="0">检验项目参数</el-radio-button>
            <el-radio-button :label="1">检验对象</el-radio-button>
          </el-radio-group>
        </el-col>
        <el-col :span="12" style="text-align: right;">
          <el-upload v-if="radio === 0" ref='upload1'
                     style="display: inline;margin-right: 8px"
                     :action="uploadAction1"
                     :before-upload="beforeUpload1" :headers="token" :on-error="onError1"
                     :on-success="handleSuccessUp" :show-file-list="false" accept='.doc,.docx,.xls,.xlsx'>
            <el-button size="small" type="primary">导入</el-button>
          </el-upload>
          <el-button size="small" type="primary" v-if="radio === 1" @click="uploadDia = true">导入</el-button>
          <el-button size="small" type="primary" @click="openAdd()">新增</el-button>
        </el-col>
      </el-row>
    </div>
    <div>
      <el-form :model="itemParameterForm" ref="itemParameterForm" size="small" :inline="true">
        <el-form-item label="检验项" prop="inspectionItem" v-if="radio===0">
          <el-input size="small" placeholder="请输入" clearable
                    v-model="itemParameterForm.inspectionItem" @keyup.enter.native="refreshTable()">
          </el-input>
        </el-form-item>
        <el-form-item label="检验子项" prop="inspectionItemSubclass" v-if="radio===0">
          <el-input size="small" placeholder="请输入" clearable
                    v-model="itemParameterForm.inspectionItemSubclass" @keyup.enter.native="refreshTable()">
          </el-input>
        </el-form-item>
        <el-form-item label="检验对象" prop="sample">
          <el-input size="small" placeholder="请输入" clearable
                    v-model="itemParameterForm.sample" @keyup.enter.native="refreshTable()">
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="refreshTable">查 询</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="refresh">重 置</el-button>
        </el-form-item>
      </el-form>
<!--      检验项目参数表格-->
      <div class="table" v-if="radio===0">
        <lims-table :tableData="tableData" :column="column"
                    @pagination="pagination"
                    :page="page" :tableLoading="tableLoading"></lims-table>
      </div>
<!--      检验对象表格-->
      <div class="table" v-if="radio===1">
        <lims-table :tableData="testObjectTableData" :column="testObjectColumn"
                    @pagination="pagination"
                    :page="testObjectPage" :tableLoading="tableLoading"></lims-table>
      </div>
    </div>
    <!--产品维护弹框-->
    <el-dialog title="产品维护" :visible.sync="diaProduct" width="900px">
      <lims-table :tableData="productData" :column="productColumn" height="460"
                  :page="productPage" :tableLoading="productableLoading"></lims-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="diaProduct = false">取 消</el-button>
        <el-button type="primary" @click="editProduct('add')" :loading="productLoad">新 增</el-button>
      </span>
    </el-dialog>
    <!--产品维护编辑-->
    <el-dialog title="操作产品维护" :visible.sync="productEditDia" width="400px">
      <el-form :model="productEditForm" ref="productEditForm" :rules="productRules" label-position="right" label-width="100px">
        <el-form-item label="产品名称" prop="name">
          <el-input size="small" placeholder="请输入" clearable v-model="productEditForm.name"></el-input>
        </el-form-item>
        <el-form-item label="产品名称EN" prop="nameEn">
          <el-input size="small" placeholder="请输入" clearable v-model="productEditForm.nameEn">
          </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeProduct">取 消</el-button>
        <el-button :loading="uploading" type="primary" @click="submitProduct">确 认</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="uploadDia" title="数据导入" width="500px">
      <div style="margin: 0 auto;">
        <el-upload ref="upload" :action="uploadAction"
                   :auto-upload="false" :file-list="fileList"
                   :headers="token" :limit="1"
                   :on-change="beforeUpload" :on-error="onError" :on-success="onSuccess" accept=".xlsx" drag
                   name="file">
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
        </el-upload>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="uploadDia = false">取 消</el-button>
        <el-button :loading="uploading" type="primary" @click="submitUpload()">上 传</el-button>
      </span>
    </el-dialog>
    <!--检验项目参数-编辑弹框-->
    <EditForm ref="editForm" @refreshList="refreshList1"></EditForm>
    <testObjectEditForm ref="testObjectEditForm" @refreshList="refreshList"></testObjectEditForm>
    <BindPartDialog v-if="bindPartDialog" :bindPartDialog="bindPartDialog"
                    :currentRow="currentRow"
                    :type="type"
                    @closeBindPartDialog="closeBindPartDialog"></BindPartDialog>
    <BindSupplierDensityDialog v-if="bindSupplierDensityDialog"
                               :bindSupplierDensityDialog="bindSupplierDensityDialog"
                               :currentRow="currentSupplierDensityRow"
                               @closeBindPartDialog="closeBindSupplierDensityDialog"></BindSupplierDensityDialog>
  </div>
</template>
 
<script>
import BindPartDialog from "@/components/capability/bindPartDialog.vue"
import BindSupplierDensityDialog from "@/components/capability/bindSupplierDensityDialog.vue"
import {
  addProduct,
  delItemParameter, delProduct, delTestObject, selectItemParameterList, selectProductListByObjectId,
  selectTestObjectList, upProduct,
} from "@/api/structural/capability";
import limsTable from "@/components/Table/lims-table.vue";
import EditForm from "@/components/capability/EditForm.vue";
import testObjectEditForm from "@/components/capability/testObjectEditForm.vue";
import {getToken} from "@/utils/auth";
 
export default {
  components: {limsTable, EditForm, testObjectEditForm, BindPartDialog, BindSupplierDensityDialog},
  data() {
    return {
      uploadAction: process.env.VUE_APP_BASE_API + '/capacityScope/importExcel',
      uploadAction1: process.env.VUE_APP_BASE_API + '/capacityScope/importEquipData',
      tableData: [],
      column: [
        {label: '检验项', prop: 'inspectionItem'},
        {label: '检验项EN', prop: 'inspectionItemEn'},
        {label: '检验子项', prop: 'inspectionItemSubclass'},
        {label: '检验子项EN', prop: 'inspectionItemSubclassEn'},
        {label: '检验项分类', prop: 'inspectionItemClass'},
        {label: '检验项分类EN', prop: 'inspectionItemClassEn'},
        {label: '检验对象', prop: 'sample'},
        {label: '单价(元)', prop: 'price'},
        {label: '试验室', prop: 'sonLaboratory'},
        {label: '要求描述', prop: 'askTell'},
        {label: '要求值', prop: 'ask'},
        {label: '计量单位', prop: 'unit'},
        {label: '工时(H)', prop: 'manHour'},
        {label: '预计时间(H)', prop: 'manDay'},
        {label: '工时分组', prop: 'manHourGroup'},
        {label: '创建时间', prop: 'createTime'},
        {label: '修改时间', prop: 'updateTime'},
        {label: '条件', prop: 'radiusList'},
        {
          dataType: 'action',
          fixed: 'right',
          label: '操作',
          width: '140px',
          operation: [
            {
              name: '编辑',
              type: 'text',
              clickFun: (row) => {
                this.editForm(row);
              },
            },
            {
              name: '删除',
              type: 'text',
              clickFun: (row) => {
                this.delete(row);
              },
            },
          ]
        }
      ],
      page: {
        total:0,
        size:10,
        current:1
      },
      testObjectTableData: [],
      testObjectColumn: [
        {
          dataType: 'tag',
          label: '场所',
          prop: 'laboratoryId',
          minWidth: '130',
          formatData: (params) => {
            if (params == 1) {
              return '装备电缆试验室'
            } else if (params == 5) {
              return '通信产品实验室'
            } else if (params == 6) {
              return '电力产品实验室'
            } else if (params == 8) {
              return '储能产品实验室'
            } else {
              return '射频线缆实验室'
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return 'success'
            } else if (params == 5) {
              return 'info'
            } else if (params == 6) {
              return 'warning'
            } else if (params == 8) {
              return 'danger'
            } else {
              return ''
            }
          }
        },
        {label: '检验对象', prop: 'specimenName'},
        {label: '检验对象EN', prop: 'specimenNameEn'},
        {label: '产品', prop: 'product'},
        {label: '对象代号', prop: 'code'},
        {label: '对象类型', prop: 'objectType',
          dataType: 'tag',
          formatData: (params) => {
            if (params == 1) {
              return '原材料'
            } else if (params == 2) {
              return '成品'
            } else {
              return '辅材'
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return 'success'
            } else if (params == 2) {
              return 'info'
            } else {
              return 'warning'
            }
          }},
        {label: '创建人', prop: 'createUserName'},
        {label: '更新人', prop: 'updateUserName'},
        {label: '创建时间', prop: 'createTime'},
        {label: '更新时间', prop: 'updateTime'},
        {
          dataType: 'action',
          fixed: 'right',
          label: '操作',
          width: '240px',
          operation: [
            {
              name: '编辑',
              type: 'text',
              clickFun: (row) => {
                this.editTestObjectForm(row);
              },
            },
            {
              name: '删除',
              type: 'text',
              clickFun: (row) => {
                this.deleteTest(row);
              },
            },
            {
              name: '产品维护',
              type: 'text',
              clickFun: (row) => {
                this.upProduct(row);
              },
            },
            {
              name: '零件绑定',
              type: 'text',
              clickFun: (row) => {
                this.bindPartFirst(row);
              },
            },
          ]
        }
      ],
      testObjectPage: {
        total:0,
        size:10,
        current:0
      },
      tableLoading: false,
      addOrUpdate: '',
      tree: null,
      loading: true,
      itemParameterForm: {
        inspectionItem: null,
        inspectionItemSubclass: null,
        sample: null
      },
      radio: 0,
      productLoad: false,
      diaProduct: false,
      productColumn: [
        {label: '产品名称', prop: 'name'},
        {label: '产品名称EN', prop: 'nameEn'},
        {
          dataType: 'action',
          label: '操作',
          operation: [
            {
              name: '编辑',
              type: 'text',
              clickFun: (row) => {
                this.editProduct('edit', row);
              },
            },
            {
              name: '删除',
              type: 'text',
              clickFun: (row) => {
                this.deleteProduct(row);
              },
            },
            {
              name: '零件绑定',
              type: 'text',
              clickFun: (row) => {
                this.bindPartSecond(row);
              },
            },
            {
              name: '厂家密度绑定',
              type: 'text',
              clickFun: (row) => {
                this.bindSupplierDensitySecond(row);
              },
            },
          ]
        }
      ],
      productData: [],
      productPage: {
        total:0,
        size:10,
        current:0,
        layout: 'total, prev, pager, next'
      },
      productableLoading: false,
      productEditDia: false,
      operationType: '',
      productEditForm: {
        objectId: '',
        id: '',
        name: '',
        nameEn: ''
      },
      objectId: '',
      productRules: {
        name: [{ required: true, message: '请填写产品名称', trigger: 'blur' }],
        nameEn: [{ required: true, message: '请填写产品名称EN', trigger: 'blur' }]
      },
      uploadDia: false,
      fileList: [],
      token: {Authorization: "Bearer " + getToken()},
      uploading: false,
      currentRow: {}, // 选择零件绑定本条数据的信息
      currentSupplierDensityRow: {}, // 选择零件绑定本条数据的信息
      bindSupplierDensityDialog: false,
      bindPartDialog: false,
      type: null,  // 零件绑定的类型--0:检验对象,1:产品维护
    }
  },
  created() {
    this.refreshTable()
  },
  computed: {
    title() {
      return this.addOrUpdate === 1 ? '新增' : '编辑'
    }
  },
  methods: {
    submitUpload() {
      if (this.$refs.upload.uploadFiles.length === 0) {
        this.$message.error('未选择文件')
        return
      }
      this.uploading = true
      this.$refs.upload.submit();
    },
    onSuccess(response, file, fileList) {
      this.$refs.upload.clearFiles()
      this.uploadDia = false
      this.uploading = false
      if (response.code === 201) {
        this.$message.error(response.message)
        return
      }
      this.$message.success('上传成功')
      this.productList = []
      this.refreshTable()
    },
    onError(err, file, fileList) {
      this.$message.error('上传失败')
      this.$refs.upload.clearFiles()
      this.uploading = false
    },
    beforeUpload(file, fileList) {
      if (file.size > 1024 * 1024 * 10) {
        this.$message.error('上传文件不超过10M');
        this.$refs.upload.clearFiles()
        return false;
      } else {
        return true;
      }
    },
    onError1(err, file, fileList) {
      this.$message.error('上传失败')
      this.$refs.upload1.clearFiles()
      this.uploading = false
    },
    beforeUpload1(file, fileList) {
      if (file.size > 1024 * 1024 * 10) {
        this.$message.error('上传文件不超过10M');
        this.$refs.upload1.clearFiles()
        return false;
      } else {
        return true;
      }
    },
    handleSuccessUp (response, file, fileList) {
      this.$refs.upload.clearFiles()
      if (response.code === 201) {
        this.$message.error(response.message)
        return
      }
      this.$message.success('上传成功')
      this.refreshTable()
    },
    refreshList () {
      this.refreshTable()
    },
    refreshList1 () {
      this.refreshTable()
    },
    refreshTable() {
      this.tableLoading = true
      if (this.radio === 0) {
        selectItemParameterList({...this.page, ...this.itemParameterForm}).then(res => {
          this.tableLoading = false
          if (res.code === 200) {
            this.tableData = res.data.records
            this.page.total = res.data.total
          }
        }).catch(err => {
          this.tableLoading = false
        })
      } else {
        selectTestObjectList({...this.testObjectPage, ...this.itemParameterForm}).then(res => {
          this.tableLoading = false
          if (res.code === 200) {
            this.testObjectTableData = res.data.records
            this.testObjectPage.total = res.data.total
          }
        }).catch(err => {
          this.tableLoading = false
        })
      }
    },
    refresh() {
      this.resetForm('itemParameterForm')
      this.refreshTable()
    },
    pagination (page) {
      this.page.size = page.pageNum.limit
      this.refreshTable()
    },
    // 检验项目参数新增
    openAdd() {
      if (this.radio === 0) {
        this.$refs.editForm.openDia('add')
      } else {
        this.$refs.testObjectEditForm.openDia('add')
      }
    },
    // 检验项目参数-打开修改弹框
    editForm (row) {
      this.$refs.editForm.openDia('edit', row)
    },
    // 检验项目参数-删除
    delete (row) {
      this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delItemParameter({id:row.id}).then(res => {
          if (res.code === 200) {
            this.$message.success('删除成功')
            this.refreshTable();
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      })
    },
    // 检验对象-打开修改弹框
    editTestObjectForm (row) {
      this.$refs.testObjectEditForm.openDia('edit', row)
    },
    // 检验项目参数-删除
    deleteTest (row) {
      this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delTestObject({id:row.id}).then(res => {
          if (res.code === 200) {
            this.$message.success('删除成功')
            this.refreshTable();
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      })
    },
    // 产品维护
    upProduct(row) {
      this.diaProduct = true
      this.objectId = row.id
      this.getProductList(row)
    },
    getProductList () {
      const params = {
        objectId: this.objectId,
      }
      this.productableLoading = true
      selectProductListByObjectId({...params, ...this.productPage}).then(res => {
        this.productableLoading = false
        this.productData = res.data.records
        this.productPage.total = res.data.total
      }).catch(err => {
        this.productableLoading = false
      })
    },
    // 产品维护-新增-编辑
    editProduct (type, row) {
      this.productEditDia = true
      this.operationType = type
      if (type === 'edit') {
        this.productEditForm = this.HaveJson(row)
      }
    },
    // 提交产品维护修改
    submitProduct () {
      this.$refs['productEditForm'].validate((valid) => {
        if (valid) {
          this.uploading = true
          this.productEditForm.objectId = this.objectId
          if (this.operationType === 'add') {
            addProduct(this.productEditForm).then(res => {
              this.uploading = false
              if (res.code === 200) {
                this.$message.success('新增成功')
                this.closeProduct()
                this.getProductList();
              }
            }).catch(err => {
              this.uploading = false
            })
          } else {
            upProduct(this.productEditForm).then(res => {
              this.uploading = false
              if (res.code === 200) {
                this.$message.success('新增成功')
                this.closeProduct()
                this.getProductList();
              }
            }).catch(err => {
              this.uploading = false
            })
          }
        }
      })
    },
    closeProduct() {
      this.resetForm('productEditForm')
      this.productEditDia = false
    },
    // 产品维护-删除
    deleteProduct (row) {
      this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delProduct({id:row.id}).then(res => {
          if (res.code === 200) {
            this.$message.success('删除成功')
            this.getProductList();
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      })
    },
    // 零件绑定
    bindPartFirst (row) {
      this.bindPart(row, 0)
    },
    bindPartSecond (row) {
      this.bindPart(row, 1)
    },
    // 厂家密度绑定
    bindSupplierDensitySecond (row) {
      this.bindSupplierDensity(row)
    },
    // 打开厂家密度绑定弹框
    bindSupplierDensity (row) {
      this.currentSupplierDensityRow = row
      this.bindSupplierDensityDialog = true
    },
    // 打开零件绑定弹框
    bindPart (row, index) {
      this.type = index
      this.currentRow = row
      this.bindPartDialog = true
    },
    closeBindPartDialog () {
      this.bindPartDialog = false
    },
    closeBindSupplierDensityDialog () {
      this.bindSupplierDensityDialog = false
    },
  }
}
</script>
 
<style scoped>
.title {
  height: 40px;
  line-height: 40px;
  margin-bottom: 10px;
}
</style>