zouyu
2026-05-07 b0d4df5f39525ae7fe252e8ee65d85fd71dca721
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
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
<template>
  <div class="capacity-scope">
    <div class="search">
      <div>
        <el-form :model="entity" ref="entity" size="small" :inline="true">
          <el-form-item label="IFS域" prop="contract">
            <el-select @keyup.enter.native="refreshTable" v-model="entity.contract" clearable placeholder="请选择" size="small">
              <el-option label="ZTNS" value="ZTNS"/>
              <el-option label="KJNS" value="KJNS"/>
            </el-select>
          </el-form-item>
          <el-form-item label="批号" prop="updateBatchNo">
            <el-input v-model="entity.updateBatchNo" clearable placeholder="请输入" size="small"
                      @keyup.enter.native="refreshTable()">
            </el-input>
          </el-form-item>
          <el-form-item label="订单编号" prop="no">
            <el-input size="small" placeholder="请输入" clearable v-model="entity.no"
                      @keyup.enter.native="refreshTable()"></el-input>
          </el-form-item>
          <el-form-item label="规格型号" prop="specsModels">
            <el-input size="small" placeholder="请输入" clearable v-model="entity.specsModels"
                      @keyup.enter.native="refreshTable()"></el-input>
          </el-form-item>
          <el-form-item label="样品名称" prop="sample">
            <el-input size="small" placeholder="请输入" clearable v-model="entity.sample"
                      @keyup.enter.native="refreshTable()"></el-input>
          </el-form-item>
          <el-form-item label="物料属性" prop="materialProp">
            <el-select clearable size="small" v-model="entity.materialProp" style="width: 100%" @change="refreshTable()">
              <el-option v-for="dict in dict.type.material_prop_type" :key="dict.value" :label="dict.label"
                         :value="dict.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="OA审核状态" prop="operation">
            <el-select clearable size="small" v-model="entity.operation" style="width: 100%" @change="refreshTable()">
              <el-option v-for="dict in dict.type.oa_workflow_state" :key="dict.value" :label="dict.label"
                         :value="dict.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="反馈日期" prop="feedbackDateTime">
            <el-date-picker
              type="daterange"
              size="small"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              clearable
              value-format="yyyy-MM-dd"
              v-model="entity.feedbackDateTime"
              @keyup.enter.native="refreshTable()">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="供应商名称" prop="supplierName">
            <el-input size="small" placeholder="请输入" clearable v-model="entity.supplierName"
                      @keyup.enter.native="refreshTable()"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" size="mini" @click="refreshTable">查询</el-button>
            <el-button size="mini" @click="refresh">重置</el-button>
            <el-button :loading="exportLoading" type="success" size="mini" @click="exportUnqualifiedHandler">导出</el-button>
            <el-button type="primary" size="mini" @click="openInsOrderDialog">新增不合格处理</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div>
      <lims-table :tableData="tableData" :column="column"
                  :more="true" @pagination="pagination"
                  :page="page" :tableLoading="tableLoading"></lims-table>
    </div>
    <el-dialog
      title="提交"
      :show-close="false"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      :visible.sync="dialogVisible"
      width="30%">
      <span>是否确认提交OA?</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitOA" :loading="submitOALoading">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="删除"
      :show-close="false"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      :visible.sync="deleteVisible"
      width="30%">
      <span>是否确认<span style="color: #FF4902">删除</span>OA?</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="deleteVisible = false">取 消</el-button>
        <el-button type="primary" @click="cancelOA" :loading="cancelOALoading">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="选择不合格订单"
      :show-close="false"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      :visible.sync="insOrderVisible"
      width="50%">
      <el-row :gutter="20" style="margin-bottom:10px">
        <el-col :span="12">
          <el-input clearable size="small" v-model="lotBatchNo" placeholder="请输入批次号"></el-input>
        </el-col>
        <el-col :span="12">
          <el-button size="small" type="primary" @click="searchInsOrderList">搜索</el-button>
        </el-col>
      </el-row>
      <lims-table ref="insOrderTable"
                  :tableData="insOrderDataList"
                  :column="insOrderTableDataColumn"
                  :isSelection="true"
                  :selectionSelectable="insOrderSelectable"
                  :handleSelectionChange="selectMethod"
                  :rowClassName="insOrderRowClassName"
                  @pagination="insOrderPageination"
                  :height="500"
                  :page="insOrderPage"
                  :tableLoading="insOrderTableLoading">
      </lims-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="resetInsOrderForm">取 消</el-button>
        <el-button type="primary" @click="openAddUnqualifiedHandlerView">确 定</el-button>
      </span>
    </el-dialog>
    <UnPassDialog ref="unPassDialog" v-if="unPassDialog"
                  :orderId="orderId"
                  @resetForm="resetForm1"
                  :unPassDialog="unPassDialog"></UnPassDialog>
    <OAProcess ref="OAProcess"
               :OAProcess="OAProcess"
               @closeOAProcess="closeOAProcess"
               v-if="OAProcess"></OAProcess>
  </div>
</template>
 
<script>
import {getIfsByAll} from "@/api/business/rawMaterialOrder";
import UnPassDialog from "./components/unPassDialog.vue";
import OAProcess from "./components/OAProcess.vue";
import limsTable from "@/components/Table/lims-table.vue";
import {deleteUnqualifiedHandler, page, pushOA,exportUnqualifiedHandler} from "@/api/business/unqualifiedHandler";
import {transformExcel} from '@/utils/file'
export default {
  components: {
    limsTable,
    OAProcess,
    UnPassDialog,
  },
  dicts: ['material_prop_type','oa_workflow_state'],
  data() {
    return {
      lotBatchNo:null,
      insOrderVisible:false,
      insOrderTableLoading:false,
      insOrderDataList:[],
      insOrderTableDataColumn:[
        {
          label: 'IFS域',
          prop: 'contract',
          width: '120px',
          dataType: 'tag',
          formatData: (params) => {
            return params
          },
          formatType: (params) => {
            if (params === 'ZTNS') {
              return ''
            } else if (params === 'KJNS') {
              return 'success'
            }else {
              return null
            }
          }
 
        },
        { label: '委托编号', prop: 'entrustCode', width: "160px", },
        {
          dataType: 'tag',
          label: '检验状态',
          prop: 'inspectStatus',
          formatData: (params) => {
            if (params == 0) {
              return '检验中'
            } else if (params == 1) {
              return '合格'
            } else if (params == 2) {
              return '不合格'
            } else if (params == 3) {
              return '未下单'
            } else if (params == 4) {
              return '让步放行'
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 0) {
              return 'warning'
            } else if (params == 1) {
              return 'success'
            } else if (params == 2) {
              return 'danger'
            } else if (params == 3) {
              return 'info'
            } else if (params == 4) {
              return ''
            } else {
              return null
            }
          }
        },
        { label: '订单号', prop: 'orderNo' },
        { label: '抵达的采购数量', prop: 'purQtyInStore' ,width:'160' },
        { label: '下发时间', prop: 'sendTime',width:'160' },
        { label: '批号', prop: 'updateBatchNo',width:'160' },
        { label: '零件号', prop: 'partNo',width:'140' },
        { label: '零件描述', prop: 'partDesc' },
        { label: '供应商名称', prop: 'supplierName' },
        { label: '不合格描述', prop: 'unqualifiedDesc',width:'160' },
        {
          dataType: 'tag',
          label: '免检',
          prop: 'isExemption',
          formatData: (params) => {
            if (params == 1) {
              return '免检'
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return 'success'
            } else {
              return null
            }
          }
        },
        {
          label: '样品名称',
          prop: 'sampleName',
          width: "160px"
        },
        { label: '样品型号', prop: 'sampleModel' },
        { label: '检验人', prop: 'userName' },
        {
          label: '物料属性',
          prop: 'materialProp',
          formatData: (params) => {
            if (!params) return null
 
            for (let i = 0; i < this.dict.type.material_prop_type.length; i++) {
              const item = this.dict.type.material_prop_type[i]
              if (item.value == params) {
                return item.label
              }
            }
            return null
          }
        },
        {
          dataType: 'tag',
          label: '物料类型',
          prop: 'isExpire',
          formatData: (params) => {
            if (params == 1) {
              return '过期物料'
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return 'info'
            } else {
              return null
            }
          }
        },
        { label: '单位', prop: 'buyUnitMeas' },
        { label: '接收时间', prop: 'receiverDate',width:'160' },
        { label: '报检时间', prop: 'declareDate',width:'160' },
      ],
      insOrderPage:{
        total: 0,
        size: 20,
        current: 1
      },
      handlerId: null,
      contract:null,
      entity: {
        contract: null,
        sample: null,
        specsModels: null,
        supplierName: null,
        feedbackDateTime:[],
        materialProp: null,
        operation:null
      },
      tableData: [],
      tableLoading: false,
      column: [
        {
          label: 'IFS域',
          prop: 'contract',
          width: '80px',
          dataType: 'tag',
          formatData: (params) => {
            return params
          },
          formatType: (params) => {
            if (params === 'ZTNS') {
              return ''
            } else if (params === 'KJNS') {
              return 'success'
            }else {
              return null
            }
          }
 
        },
        { label: '编号', prop: 'no', width: "160px", },
        {
          label: "OA审核状态",
          prop: "operation",
          width: "100px",
          dataType: "tag",
          formatData: (params) => {
            return params
          },
          formatType: (params) => {
            if(params){
              this.dict.type.oa_workflow_state.forEach(item => {
                if(item.value === params){
                  params = item.raw.listClass
                }
              });
            }
            return params
          },
        },
        { label: '订单号', prop: 'orderNo' },
        {
          label: "零件号",
          prop: "partNo",
          width: "160px",
          dataType: "link",
          linkMethod: "openUnPassDialog",
        },
        { label: '零件描述', prop: 'partDesc',width: "160px" },
        {
          label: '物料属性',
          prop: 'materialProp',
          formatData: (params) => {
            if (!params) return null
 
            for (let i = 0; i < this.dict.type.material_prop_type.length; i++) {
              const item = this.dict.type.material_prop_type[i]
              if (item.value == params) {
                return item.label
              }
            }
            return null
          }
        },
        { label: '物料名称', prop: 'materialName',width: "160px" },
        { label: '生产批次', prop: 'productionBatch',width: "160px" },
        { label: '到货数量', prop: 'cargoQuantity' },
        { label: '规格型号', prop: 'specsModels' },
        { label: '报检日期', prop: 'inspectTime' },
        { label: '状态', prop: 'statusDB' },
        { label: '反馈人', prop: 'feedbackUser' },
        { label: '要检验的采购数量', prop: 'qtyToInspect',width: "140px" },
        { label: '反馈日期', prop: 'feedbackTime',width: "100px" },
        {
          label: "分类",
          prop: "classification",
          width: "100px",
          dataType: "tag",
          formatData: (params) => {
            if (params == 0) {
              return "一类不合格";
            } else if(params == 1) {
              return "二类不合格";
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 0) {
              return "warning";
            } else if(params == 1) {
              return "info";
            } else {
              return "null";
            }
          },
        },
        { label: '供应商名称', prop: 'supplierName' },
        {
          label: "不合格归属",
          prop: "offGradeAscription",
          width: "120px",
          dataType: "tag",
          formatData: (params) => {
            if (params == 0) {
              return "检测不合格";
            } else if(params == 1) {
              return "生产反馈不合格";
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 0) {
              return "danger";
            } else if(params == 1) {
              return "warning";
            } else {
              return "null";
            }
          },
        },
        { label: '不合格描述', prop: 'unqualifiedDesc',width: "160px" },
        {
          dataType: 'action',
          fixed: 'right',
          label: '操作',
          width: '220px',
          operation: [
            {
              name: (row)=>{
                return row.requestId !== null && row.operation==='退回' ? '重新提交' : '提交OA'
              },
              type: 'text',
              clickFun: (row) => {
                this.openOA(row);
              },
              disabled: (row, index) => {
                return row.requestId !== null && row.operation!=='退回'  // 有requestId说明已经提交过OA,不可再次提交
              }
            },
            {
              name: '查看OA流程',
              type: 'text',
              clickFun: (row) => {
                this.OAView(row);
              },
            },
            {
              name: '删除',
              type: 'text',
              clickFun: (row) => {
                this.deleteOA(row);
              },
              disabled: (row, index) => {
                return row.requestId !== null && row.operation!=='退回'  // 有requestId说明已经提交过OA,不可再次提交
              }
            },
          ]
        }
      ],
      page: {
        total: 0,
        size: 20,
        current: 1
      },
      statusList: [],
      dialogVisible: false, // 确认提交OA弹框
      unPassDialog: false, // 不合格处理弹框
      orderId: '',
      OAProcess: false, // OA流程弹框
      submitOALoading: false, // OA流程弹框提交按钮loading
      deleteVisible: false, // OA流程删除弹框
      cancelOALoading: false, // OA流程删除弹框提交按钮loading
      exportLoading:false
    };
  },
  mounted() {
    this.refreshTable()
  },
  methods: {
    getInsOrderRowId(row) {
      if (!row) {
        return ''
      }
      const currentId = row.enterOrderId || row.insOrderId || row.orderId || row.id
      return currentId ? String(currentId) : ''
    },
    getExistingInsOrderIds() {
      const ids = new Set()
      this.tableData.forEach(row => {
        ['insOrderId'].forEach(key => {
          if (row[key] !== undefined && row[key] !== null && row[key] !== '') {
            ids.add(String(row[key]))
          }
        })
      })
      return ids
    },
    isDisabledInsOrderRow(row) {
      const currentId = this.getInsOrderRowId(row)
      if (!currentId) {
        return false
      }
      return this.getExistingInsOrderIds().has(currentId)
    },
    insOrderSelectable(row) {
      return !this.isDisabledInsOrderRow(row)
    },
    insOrderRowClassName({ row }) {
      return this.isDisabledInsOrderRow(row) ? 'disabled-selection-row' : ''
    },
    resetInsOrderForm(){
      this.insOrderDataList = []
      this.lotBatchNo = null
      this.orderId = ''
      this.$nextTick(()=>{
        this.insOrderVisible = false
      })
    },
    openInsOrderDialog(){
      this.insOrderVisible = true
    },
    searchInsOrderList(){
      this.insOrderTableLoading = true
      const params = {
        updateBatchNo: this.lotBatchNo,
        isInspect: 1,
        ...this.insOrderPage
      }
      getIfsByAll(params).then(res => {
        this.insOrderTableLoading = false
        if (res.code === 200) {
          this.insOrderDataList = res.data.records
          this.insOrderPage.total = res.data.total
        }
      }).catch(err => {
        this.insOrderTableLoading = false
      })
    },
    insOrderPageination(page){
      this.insOrderPage.size = page.limit
      this.searchInsOrderList()
    },
    selectMethod(val){
      if (!val || val.length === 0) {
        this.orderId = ''
        return
      }
 
      const currentRow = val[val.length - 1]
      this.orderId = this.getInsOrderRowId(currentRow)
 
      if (val.length > 1 && this.$refs.insOrderTable && this.$refs.insOrderTable.$refs.multipleTable) {
        this.$refs.insOrderTable.$refs.multipleTable.clearSelection()
        this.$refs.insOrderTable.$refs.multipleTable.toggleRowSelection(currentRow, true)
      }
    },
    //打开新增不合格处理弹框
    openAddUnqualifiedHandlerView(){
      if(!this.orderId){
        this.$message.warning("请选择一条订单记录")
        return;
      }
      this.insOrderVisible = false
      this.unPassDialog = true;
      this.$nextTick(() => {
        this.$refs.unPassDialog.getInsOrder('add');
      });
    },
    exportUnqualifiedHandler(){
      this.exportLoading = true
      const newEntity = { ...this.entity }
      if (newEntity.feedbackDateTime && newEntity.feedbackDateTime.length > 0) {
        newEntity.feedbackStartTime = newEntity.feedbackDateTime[0]
        newEntity.feedbackEndTime = newEntity.feedbackDateTime[1]
      }
      exportUnqualifiedHandler({...newEntity}).then(res=>{
        transformExcel(res,'不合格处理记录.xlsx')
        this.exportLoading = false
      }).catch(error=>{
        console.error(error)
      })
    },
    refreshTable() {
      this.tableLoading = true
      const newEntity = { ...this.entity }
      if (newEntity.feedbackDateTime && newEntity.feedbackDateTime.length > 0) {
        newEntity.feedbackStartTime = newEntity.feedbackDateTime[0]
        newEntity.feedbackEndTime = newEntity.feedbackDateTime[1]
      }
      page({ ...this.page, ...newEntity }).then(res => {
        this.tableLoading = false
        this.tableData = res.data.records
        this.page.total = res.data.total
      }).catch(err => {
        this.tableLoading = false
      })
    },
    // 重置
    refresh() {
      this.resetForm('entity')
      this.refreshTable()
    },
    // 分页切换
    pagination(page) {
      this.page.size = page.limit
      this.refreshTable()
    },
    // 打开不合格处理弹框
    openUnPassDialog (row) {
      this.unPassDialog = true
      this.$nextTick(() => {
        this.$refs.unPassDialog.getInsOrder('view', row)
      })
    },
    // 关闭不合格处理弹框
    resetForm1 () {
      this.$refs.unPassDialog.$refs['unPassForm'].resetFields();
      this.unPassDialog = false
      this.$nextTick(()=>{
        this.refreshTable('page')
      })
    },
    // 打开删除OA确认弹框
    deleteOA (row) {
      this.handlerId = row.handlerId
      this.deleteVisible = true
    },
    // 提交删除申请
    cancelOA () {
      this.de = true
      deleteUnqualifiedHandler({id: this.handlerId,}).then(res => {
        this.cancelOALoading = false
        if (res.code === 200) {
          this.deleteVisible = false
          this.$message.success('删除成功')
          this.refreshTable('page')
        }
      }).catch(error => {
        this.cancelOALoading = false
        console.error(error);
      });
    },
    // 查看提交OA的数据
    openOA (row) {
      this.handlerId = row.handlerId
      this.contract = row.contract
      if(row && row.requestId !== null  ){
        // 重新提交OA,打开编辑弹框
        this.unPassDialog = true
        this.$nextTick(() => {
          this.$refs.unPassDialog.getInsOrder('resubmit', row)
        })
      }else{
        this.dialogVisible = true
      }
    },
    // 查看OA流程
    OAView (row) {
      this.OAProcess = true
      this.$nextTick(() => {
        this.$refs.OAProcess.getInfo(row.handlerId,row?row.unqualifiedDesc:"")
      })
    },
    // 关闭查看OA流程的弹框
    closeOAProcess () {
      this.OAProcess = false
    },
    //提交OA
    submitOA(row) {
      // 提交OA
      this.submitOALoading = true
      pushOA({handlerId: this.handlerId,contract:this.contract}).then(res => {
        this.submitOALoading = false
        if (res.code === 200) {
          this.dialogVisible = false
          this.$message.success('提交成功')
          this.refreshTable('page')
        }
      }).catch(error => {
        this.submitOALoading = false
        console.error(error);
      });
    }
  }
};
</script>
 
<style scoped>
.capacity-scope >>> .disabled-selection-row td {
  background-color: #f5f7fa !important;
  color: #c0c4cc;
}
</style>