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
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
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
<!--
 * @Descripttion:
 * @version:
 * @Author: zt_lc
 * @Date: 2022-06-08 15:49:37
 * @LastEditors: zt_lc
 * @LastEditTime: 2022-08-18 14:07:40
-->
<template>
  <el-dialog
    width="90%"
    title="分割表单"
    :visible.sync="innerVisible"
    append-to-body
    @close="$emit('update:currshowlist', false)"
    :show="currshowlist"
    :close-on-click-modal="false"
    class="split-task-form"
  >
    <div
      style="width: 100%;box-sizing: border-box;display:flex;margin-bottom:10px;"
    >
      <div style="line-height:32px;margin-right:10px;font-size:15px;">
        <span>任务类型</span>
      </div>
      <div>
        <el-select
          v-model="taskType"
          placeholder="请选择"
          @change="taskTypeChange"
        >
          <el-option
            v-for="item in taskTypeOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </div>
    </div>
    <div
      style="width: 100%;box-sizing: border-box;display:flex;justify-content:space-between;"
    >
      <div style="width: 23%;">
        <div style="margin-bottom:10px;">
          <el-input
            ref="sn_seach_input"
            v-model="stockFieldInfo"
            v-focus
            @keyup.enter.native="querySpliteStock"
          >
            <el-button
              slot="append"
              icon="el-icon-search"
              @click="openSelectStock"
            ></el-button>
          </el-input>
        </div>
        <div>
          <el-table :data="stockList" border style="width: 100%">
            <el-table-column
              prop="partBatchNo"
              label="SN号"
              align="center"
              width="110px"
            >
            </el-table-column>
            <el-table-column prop="adjustQty" label="可用数量" align="center">
            </el-table-column>
            <el-table-column label="报废数量" align="center">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.scrapQty"
                  placeholder="请输入"
                  @blur="changeQty(scope.row)"
                  clearable
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center" width="55px">
              <template slot-scope="scope">
                <el-button
                  size="text"
                  type="danger"
                  @click="stockDelete(scope.$index, scope.row)"
                  >删除</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <div style="width: 75%;">
        <el-table :data="splitResultList" border style="width: 100%">
          <el-table-column type="index" label="序号" align="center">
          </el-table-column>
          <el-table-column
            prop="partNo"
            label="零件号"
            align="center"
            show-overflow-tooltip
            width="125px"
          >
          </el-table-column>
          <el-table-column
            prop="partName"
            label="零件名称"
            align="center"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column prop="partBatchNo" label="SN号" align="center">
          </el-table-column>
          <el-table-column label="载具编号" align="center">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.reelNumber"
                placeholder="请输入"
                clearable
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="盘数" align="center">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.diskNum"
                placeholder="请输入"
                clearable
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="生产数量" align="center">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.productQty"
                placeholder="请输入"
                clearable
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="unit" label="单位" align="center" width="50px">
          </el-table-column>
          <el-table-column label="分段描述" align="center">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.segmentDesc"
                placeholder="请输入"
                clearable
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="ifsBatchNo" label="IFS批次号" align="center">
          </el-table-column>
          <el-table-column label="备注" align="center">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.remark"
                placeholder="请输入"
                clearable
              ></el-input>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="innerVisible = false">取 消</el-button>
      <el-button
        type="primary"
        :disabled="saveDisabled"
        v-thinclick="`dataFormSubmit`"
        >确 定</el-button
      >
    </div>
    <splitStockDialog
      :currshowlist.sync="showSplitStock"
      :paramObj="paramObj"
      @listenToStockEvent="returnSelectStock"
    />
    <splitTaskBack
      v-if="backFeed"
      ref="backFeed"
      :splitTaskBackList="stockList"
      @selectBackStock="goOnSave"
    ></splitTaskBack>
  </el-dialog>
</template>
<style>
.split-task-form .el-dialog__body {
  padding-bottom: 0px;
}
 
.split-task-form .el-dialog__body:after {
  content: '';
  clear: both;
  overflow: hidden;
  display: block;
  visibility: hidden;
}
 
.split-task-form .el-dialog__body .el-table__header th {
  padding-top: 0px;
}
 
.split-task-form .el-dialog__body .el-table__body-wrapper {
  height: 260px;
  overflow-y: auto;
}
 
.split-task-form .el-dialog__body .el-table::before {
  height: 0px;
}
 
/*
  字符串过长时,隐藏显示省略号
   */
.inline-el-hidden {
  display: block;
  width: 93%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0 auto;
}
</style>
<script>
import {
  addSegmentationTaskRecord,
  addSegmentationTaskRecordCheck
} from '@/api/product/segmentationtaskrecord'
import ElButton from '../../../../node_modules/element-ui/packages/button/src/button.vue'
import splitStockDialog from './split-stock.vue'
import { getStock } from '@/api/product/personboard'
import { mapGetters } from 'vuex'
import splitTaskBack from './splitTask-back.vue'
export default {
  components: { ElButton, splitStockDialog, splitTaskBack },
  props: {
    currshowlist: {
      type: Boolean,
      default: false
    },
    workstationId: {
      type: Number,
      default: 0
    },
    currentDutyRecord: {
      type: Object,
      default: () => {
        return {}
      }
    },
    personBoardList: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      innerVisible: false,
      saveDisabled: false,
      taskTypeOptions: [
        {
          value: 'CENT_LINE',
          label: '分盘'
        },
        {
          value: 'MERGE_DISH',
          label: '拼盘'
        },
        {
          value: 'CHECK_CENT_LINE',
          label: '检号分盘'
        }
      ],
      taskType: null,
      stockFieldInfo: null,
      stockList: [],
      splitResultList: [],
      showSplitStock: false,
      paramObj: { workstationId: null },
      batchNo: null,
      ifsBatchNo: null,
      backFeed: false
    }
  },
  directives: {
    focus: {
      inserted: function(el, option) {
        var defClass = 'el-input'
        var defTag = 'input'
        var value = option.value || true
        if (typeof value === 'boolean')
          value = { cls: defClass, tag: defTag, foc: value }
        else
          value = {
            cls: value.cls || defClass,
            tag: value.tag || defTag,
            foc: value.foc || false
          }
        // if (el.classList.contains(value.cls) && value.foc)
        el.getElementsByTagName(value.tag)[0].focus()
      }
    }
  },
  computed: {
    ...mapGetters(['permissions', 'userInfo'])
  },
  methods: {
    isNumber(value) {
      var reg = /^[0-9]+(.[0-9]{1,4})?$/
      if (
        value == undefined ||
        value == null ||
        value === '' ||
        value.trim === ''
      ) {
        return false
      } else {
        if (!reg.test(value)) {
          return false
        } else {
          return true
        }
      }
    },
    isPositiveIntegerNumber(value) {
      var reg = /^[1-9]\d*$/
      if (
        value == undefined ||
        value == null ||
        value === '' ||
        value.trim === ''
      ) {
        return false
      } else {
        if (!reg.test(value)) {
          return false
        } else {
          return true
        }
      }
    },
    checkDiskNumQuality() {
      let flag = true
      let flagMsg = ''
      for (let i = 0; i < this.splitResultList.length; i++) {
        if (
          this.splitResultList[i].diskNum == null ||
          this.splitResultList[i].diskNum == ''
        ) {
          flag = false
          flagMsg = flagMsg + '盘数不能为空;'
        } else {
          if (!this.checkZero(this.splitResultList[i].diskNum)) {
            flag = false
            flagMsg = flagMsg + '盘数不能为0;'
          } else {
            if (!this.checkPositive(this.splitResultList[i].diskNum)) {
              flag = false
              flagMsg = flagMsg + '盘数需为正数;'
            } else {
              if (!this.checkDecimal(this.splitResultList[i].diskNum)) {
                flag = false
                flagMsg = flagMsg + '盘数最多六位小数;'
              }
            }
          }
        }
      }
      if (!flag) {
        this.$message.error(flagMsg)
      }
      return flag
    },
    checkProductQuality() {
      let flag = true
      let flagMsg = ''
      for (let i = 0; i < this.splitResultList.length; i++) {
        if (
          this.splitResultList[i].productQty == null ||
          this.splitResultList[i].productQty == ''
        ) {
          flag = false
          flagMsg = flagMsg + '生产数量不能为空;'
        } else {
          if (!this.checkZero(this.splitResultList[i].productQty)) {
            flag = false
            flagMsg = flagMsg + '生产数量不能为0;'
          } else {
            if (!this.checkPositive(this.splitResultList[i].productQty)) {
              flag = false
              flagMsg = flagMsg + '生产数量需为正数;'
            } else {
              if (!this.checkDecimal(this.splitResultList[i].productQty)) {
                flag = false
                flagMsg = flagMsg + '生产数量最多六位小数;'
              }
            }
          }
        }
      }
      if (!flag) {
        this.$message.error(flagMsg)
      }
      return flag
    },
    checkScrapQtyQuality() {
      let flag = true
      let flagMsg = ''
      for (let i = 0; i < this.stockList.length; i++) {
        if (this.stockList[i].scrapQty == '') {
          flag = true
        } else {
          if (!this.checkPositive(this.stockList[i].scrapQty)) {
            flag = false
            flagMsg = flagMsg + '报废数量需为正数;'
          } else {
            if (!this.checkDecimal(this.stockList[i].scrapQty)) {
              flag = false
              flagMsg = flagMsg + '报废数量最多六位小数;'
            }
          }
        }
      }
      if (!flag) {
        this.$message.error(flagMsg)
      }
      return flag
    },
    checkZero(value) {
      if (value == 0) {
        return false
      } else {
        return true
      }
    },
    checkPositive(value) {
      if (!/^[0-9]+.?[0-9]*$/.test(value)) {
        return false
      } else {
        return true
      }
    },
    checkDecimal(value) {
      if (
        !/(^[1-9]([0-9]+)?(\.[0-9]{1,6})?$)|(^(0){1}$)|(^[0-9]\.[0-9]{1,6}$)/.test(
          value
        )
      ) {
        return false
      } else {
        return true
      }
    },
    querySpliteStock() {
      // 根据任务类型,判断添加条数
      if (this.taskType != null) {
        if (this.workstationId && this.workstationId != null) {
          // 根据扫入的字符串信息,判断扫的是条形码,还是二维码
          if (this.stockFieldInfo != null) {
            let scanParamObject
            if (this.stockFieldInfo.indexOf('lot_batch_no') != -1) {
              // 二维码
              const scanContentJson = JSON.parse(
                this.stockFieldInfo.replace(/\n/g, '').replace(/\s*/g, '')
              )
              const partNo = scanContentJson.part_no
              this.ifsBatchNo = scanContentJson.lot_batch_no
              scanParamObject = {
                partNo: partNo,
                ifsBatchNo: this.ifsBatchNo
              }
            } else {
              // 条形码
              this.batchNo = this.stockFieldInfo
              scanParamObject = {
                partBatchNo: this.batchNo
              }
            }
            const query = Object.assign(
              { current: 0, size: 50 },
              { workstationId: this.workstationId },
              scanParamObject,
              { operationStockStatus: false }
            )
            // 合格
            getStock(query)
              .then((response) => {
                this.dealStockResponse(response)
              })
              .catch(() => {})
          } else {
            this.$message.error('请扫码')
          }
        }
      } else {
        this.$message.error('请先选择任务类型!')
      }
    },
    dealStockResponse(response) {
      const data = response.data
      if (data.code === 0) {
        const newScanSplitList = data.data.records
        if (newScanSplitList != null && newScanSplitList.length > 0) {
          const _this = this
          if (this.stockList.length > 0) {
            // 页面已有零件
            if (
              this.taskType == 'CENT_LINE' ||
              this.taskType == 'CHECK_CENT_LINE'
            ) {
              this.$message.error('只能分盘一条库存!')
            } else {
              let flag = true
              let diffFlag = true
              for (let i = 0; i < newScanSplitList.length; i++) {
                const newScanSplitItem = newScanSplitList[i]
                const partFlag = this.stockList.every((x) => {
                  return x.partId == newScanSplitItem.partId
                })
                if (!partFlag) {
                  flag = false
                  break
                }
                const isExist = this.stockList.find((x) => {
                  return x.stockId == newScanSplitItem.id
                })
                if (isExist) {
                  diffFlag = false
                  break
                }
              }
 
              if (flag) {
                if (diffFlag) {
                  newScanSplitList.forEach((item) => {
                    // 往stockList塞入值
                    _this.stockList.push({
                      oriAdjustQty: item.availableStockQuantity,
                      adjustQty: item.availableStockQuantity,
                      id: 0,
                      ifsBatchNo: item.ifsBatchNo,
                      partBatchNo: item.partBatchNo,
                      partName: item.partName,
                      partNo: item.partNo,
                      partId: item.partId,
                      scrapQty: 0,
                      stockId: item.id
                    })
                  })
                } else {
                  this.$message.error('该库存已选!')
                }
              } else {
                this.$message.error('零件需相同!')
              }
            }
          } else {
            // 页面无零件,需判断newScanSplitList的长度
            if (newScanSplitList.length > 1) {
              if (
                this.taskType == 'CENT_LINE' ||
                this.taskType == 'CHECK_CENT_LINE'
              ) {
                this.$message.error('只能分盘一条库存!')
              } else {
                newScanSplitList.forEach((item) => {
                  // 往stockList塞入值
                  _this.stockList.push({
                    oriAdjustQty: item.availableStockQuantity,
                    adjustQty: item.availableStockQuantity,
                    id: 0,
                    ifsBatchNo: item.ifsBatchNo,
                    partBatchNo: item.partBatchNo,
                    partName: item.partName,
                    partNo: item.partNo,
                    partId: item.partId,
                    scrapQty: 0,
                    stockId: item.id
                  })
                })
                // 往splitResultList塞入值
                _this.splitResultList.push({
                  partName: newScanSplitList[0].partName,
                  id: 0,
                  partNo: newScanSplitList[0].partNo,
                  partId: newScanSplitList[0].partId,
                  partBatchNo: null,
                  reelNumber: null,
                  diskNum: null,
                  productQty: null,
                  unit: newScanSplitList[0].unit,
                  segmentDesc: null,
                  ifsBatchNo: null,
                  remark: null,
                  taskType: _this.taskType,
                  productionUser: null
                })
              }
            } else {
              newScanSplitList.forEach((item) => {
                // 往stockList塞入值
                _this.stockList.push({
                  oriAdjustQty: item.availableStockQuantity,
                  adjustQty: item.availableStockQuantity,
                  id: 0,
                  ifsBatchNo: item.ifsBatchNo,
                  partBatchNo: item.partBatchNo,
                  partName: item.partName,
                  partNo: item.partNo,
                  partId: item.partId,
                  scrapQty: 0,
                  stockId: item.id
                })
              })
              // 往splitResultList塞入值
              _this.splitResultList.push({
                partName: newScanSplitList[0].partName,
                id: 0,
                partNo: newScanSplitList[0].partNo,
                partId: newScanSplitList[0].partId,
                partBatchNo: null,
                reelNumber: null,
                diskNum: null,
                productQty: null,
                unit: newScanSplitList[0].unit,
                segmentDesc: null,
                ifsBatchNo: null,
                remark: null,
                taskType: _this.taskType,
                productionUser: null
              })
            }
          }
        }
        this.stockFieldInfo = null
      } else {
        this.$message.error('获取线边仓物料信息失败')
      }
    },
    openSelectStock() {
      this.paramObj.workstationId = this.workstationId
      this.paramObj.operationStockStatus = false
      this.showSplitStock = true
    },
    returnSelectStock(param) {
      // 根据任务类型,判断添加条数
      if (this.taskType != null) {
        // 校验stockList是不是零件都一样
        if (this.stockList.length > 0) {
          if (
            this.taskType == 'CENT_LINE' ||
            this.taskType == 'CHECK_CENT_LINE'
          ) {
            this.$message.error('只能分盘一条库存!')
          } else {
            let flag = true
            let diffFlag = true
            for (let i = 0; i < this.stockList.length; i++) {
              if (this.stockList[i].partId != param.partId) {
                flag = false
                break
              }
              if (this.stockList[i].stockId == param.id) {
                diffFlag = false
                break
              }
            }
            if (flag) {
              if (diffFlag) {
                // 往stockList塞入值
                this.stockList.push({
                  oriAdjustQty: param.availableStockQuantity,
                  adjustQty: param.availableStockQuantity,
                  id: 0,
                  ifsBatchNo: param.ifsBatchNo,
                  partBatchNo: param.partBatchNo,
                  partName: param.partName,
                  partNo: param.partNo,
                  partId: param.partId,
                  scrapQty: 0,
                  stockId: param.id
                })
              } else {
                this.$message.error('该库存已选!')
              }
            } else {
              this.$message.error('零件需相同!')
            }
          }
        } else {
          // 往stockList塞入值
          this.stockList.push({
            oriAdjustQty: param.availableStockQuantity,
            adjustQty: param.availableStockQuantity,
            id: 0,
            ifsBatchNo: param.ifsBatchNo,
            partBatchNo: param.partBatchNo,
            partName: param.partName,
            partNo: param.partNo,
            partId: param.partId,
            scrapQty: 0,
            stockId: param.id
          })
          // 往splitResultList塞入值
          this.splitResultList.push({
            partName: param.partName,
            id: 0,
            partNo: param.partNo,
            partId: param.partId,
            partBatchNo: null,
            reelNumber: null,
            diskNum: null,
            productQty: null,
            unit: param.unit,
            segmentDesc: null,
            ifsBatchNo: null,
            remark: null,
            taskType: this.taskType,
            productionUser: null
          })
        }
      } else {
        this.$message.error('请先选择任务类型!')
      }
    },
    changeQty(row) {
      const flag = this.checkScrapQtyQuality()
      if (flag) {
        let scrapQty
        if (row.scrapQty == '') {
          scrapQty = 0
          row.scrapQty = 0
        } else {
          scrapQty = row.scrapQty
        }
        const newAdjustQty = Number(
          (Number(row.oriAdjustQty) - Number(scrapQty)).toFixed(6)
        )
        if (newAdjustQty < 0) {
          row.scrapQty = 0
          row.adjustQty = row.oriAdjustQty
          this.$message.error('报废数量大于可用数量!')
        } else {
          row.adjustQty = newAdjustQty
        }
      } else {
        row.scrapQty = 0
        row.adjustQty = row.oriAdjustQty
      }
    },
    dataFormSubmit() {
      if (this.splitResultList.length <= 0) {
        this.$message.error('请先选择需要分割或拼盘的库存零件!')
      } else {
        // 校验当前登录人,是否在当班人员中
        const exsitMan = this.personBoardList.find((item) => {
          return item.staffId == this.userInfo.staffId
        })
        if (exsitMan) {
          const flag = this.checkProductQuality()
          if (flag) {
            const diskFlag = this.checkDiskNumQuality()
            if (diskFlag) {
              // 校验stockList的可用数量之和要大于等于splitResultList中的盘数*生产数量
              let allAdjustQty = 0
              const inputs = []
              this.stockList.forEach((item) => {
                allAdjustQty = allAdjustQty + Number(item.adjustQty)
                inputs.push({
                  id: 0,
                  adjustQty: item.adjustQty,
                  ifsBatchNo: item.ifsBatchNo,
                  partBatchNo: item.partBatchNo,
                  partName: item.partName,
                  partNo: item.partNo,
                  scrapQty: item.scrapQty,
                  stockId: item.stockId
                })
              })
              const splitResult = this.splitResultList[0]
              const dataObj = {
                id: 0,
                diskNum: splitResult.diskNum,
                ifsBatchNo: splitResult.ifsBatchNo,
                partBatchNo: splitResult.partBatchNo,
                partId: splitResult.partId,
                partName: splitResult.partName,
                partNo: splitResult.partNo,
                productQty: splitResult.productQty,
                productionUser: null,
                reelNumber: splitResult.reelNumber,
                remark: splitResult.remark,
                segmentDesc: splitResult.segmentDesc,
                taskType: this.taskType,
                unit: splitResult.unit,
                dutyRecordId: this.currentDutyRecord.id,
                workstationId: this.workstationId,
                inputs: inputs,
                returnInputStockId: null
              }
              const allResultProductQty =
                Number(splitResult.diskNum) * Number(splitResult.productQty)
              if (Number(allAdjustQty.toFixed(6)) >= allResultProductQty) {
                addSegmentationTaskRecordCheck(dataObj)
                  .then((response) => {
                    const resData = response.data
                    if (resData.data) {
                      // 直接保存
                      this.save(null)
                    } else {
                      // 弹窗选库存
                      this.backFeed = true
                      this.$nextTick(() => {
                        this.$refs.backFeed.init()
                      })
                    }
                  })
                  .catch((error) => {
                    console.log(error)
                  })
              } else {
                this.$message.error('生产数量需小于等于可用数量!')
              }
            }
          }
        } else {
          this.$message.error('当前登录人非当班人员!')
        }
      }
    },
    goOnSave(param) {
      if (param) {
        this.save(param.stockId)
      }
    },
    save(returnInputStockId) {
      this.saveDisabled = true
      if (this.splitResultList.length <= 0) {
        this.saveDisabled = false
        this.$message.error('请先选择需要分割或拼盘的库存零件!')
      } else {
        // 校验当前登录人,是否在当班人员中
        const exsitMan = this.personBoardList.find((item) => {
          return item.staffId == this.userInfo.staffId
        })
        console.log('exsitMan', exsitMan)
        if (exsitMan) {
          const flag = this.checkProductQuality()
          if (flag) {
            const diskFlag = this.checkDiskNumQuality()
            if (diskFlag) {
              // 校验stockList的可用数量之和要大于等于splitResultList中的盘数*生产数量
              let allAdjustQty = 0
              const inputs = []
              this.stockList.forEach((item) => {
                allAdjustQty = allAdjustQty + Number(item.adjustQty)
                inputs.push({
                  id: 0,
                  adjustQty: item.adjustQty,
                  ifsBatchNo: item.ifsBatchNo,
                  partBatchNo: item.partBatchNo,
                  partName: item.partName,
                  partNo: item.partNo,
                  scrapQty: item.scrapQty,
                  stockId: item.stockId
                })
              })
              const splitResult = this.splitResultList[0]
              const dataObj = {
                id: 0,
                diskNum: splitResult.diskNum,
                ifsBatchNo: splitResult.ifsBatchNo,
                partBatchNo: splitResult.partBatchNo,
                partId: splitResult.partId,
                partName: splitResult.partName,
                partNo: splitResult.partNo,
                productQty: splitResult.productQty,
                productionUser: this.userInfo.staffName,
                reelNumber: splitResult.reelNumber,
                remark: splitResult.remark,
                segmentDesc: splitResult.segmentDesc,
                taskType: this.taskType,
                unit: splitResult.unit,
                dutyRecordId: this.currentDutyRecord.id,
                workstationId: this.workstationId,
                inputs: inputs,
                returnInputStockId: returnInputStockId
              }
              const allResultProductQty =
                Number(splitResult.diskNum) * Number(splitResult.productQty)
              if (Number(allAdjustQty.toFixed(6)) >= allResultProductQty) {
                addSegmentationTaskRecord(dataObj)
                  .then((data) => {
                    this.$message.success('保存成功')
                    this.innerVisible = false
                    this.saveDisabled = false
                    this.$emit('refreshDataList')
                  })
                  .catch((error) => {
                    this.saveDisabled = false
                    console.log(error)
                  })
              } else {
                this.$message.error('生产数量需小于等于可用数量!')
                this.saveDisabled = false
              }
            } else {
              this.saveDisabled = false
            }
          } else {
            this.saveDisabled = false
          }
        } else {
          this.$message.error('当前登录人非当班人员!')
          this.saveDisabled = false
        }
      }
    },
    stockDelete(index, row) {
      this.stockList.splice(index, 1)
      if (this.stockList.length < 1) {
        this.splitResultList = []
      }
    },
    taskTypeChange() {
      // console.log('sadasd')
      // this.$refs.sn_seach_input.focus()
      this.stockFieldInfo = null
      this.stockList = []
      this.splitResultList = []
    }
  },
  watch: {
    currshowlist() {
      this.innerVisible = this.currshowlist
      if (this.currshowlist) {
        this.taskType = null
        this.stockFieldInfo = null
        this.stockList = []
        this.splitResultList = []
        this.$nextTick(() => {
          this.$refs.sn_seach_input.focus()
        })
      }
    }
  }
}
</script>