schangxiang@126.com
2025-09-19 9be9c3784b2881a3fa25e93ae2033dc2803c0ed0
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
<template>
  <div class="scan-container">
    <el-card class="scan-card">
      <div slot="header" class="clearfix">
        <span>无单收货</span>
      </div>
      <el-form ref="form" :model="formData" label-width="120px" class="scan-form">
        <!-- <el-form-item label="仓库名称">
          <el-select v-model="formData.storage_Id" placeholder="请选择仓库" class="input-300" @change="getPositionName()">
            <el-option v-for="item in storageNames" :key="item.storage_Id" :label="item.storageName" :value="item.storage_Id"></el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="移动类型">
          <el-select v-model="moveType" placeholder="请选择移动类型" class="input-300">
            <el-option v-for="item in moveTypeData" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
          <el-checkbox v-model="isChecked" @change="changeAutoPrint">自动打印</el-checkbox>
          <el-checkbox v-model="isChecked_PrintForInStore" @change="changeAutoPrint_PrintForInStore">入库口打印机</el-checkbox>
          <el-checkbox v-model="isChecked_PrintForOutStore" @change="changeAutoPrint_PrintForOutStore">出库口打印机</el-checkbox>
        </el-form-item>
        <el-form-item label="转入仓">
          <el-select v-model="toPlace" placeholder="请选择移转入仓" class="input-300" @change="getToPlace()" clearable>
            <el-option v-for="item in toPlaceData" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
          <span class="sub-item">
            <span class="sub-label">打印份数:</span>
            <el-input-number v-model="printQty" :min="0" class="input-100" controls-position="right"></el-input-number>
          </span>
        </el-form-item>
        <el-form-item label="转出仓">
          <el-select v-model="fromPlace" placeholder="请选择移转出仓" class="input-300" @change="getFromPlace()" clearable>
            <el-option v-for="item in toPlaceData" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="跟踪号">
          <el-input ref="trackingNumber" v-model="formData.trackingNumber" placeholder="请录入跟踪单号" class="input-300" @change="getTrackingNumber"></el-input>
        </el-form-item>
        <!-- <el-form-item label="销售单号">
          <el-input ref="saleCode" v-model="formData.saleCode" placeholder="请录入销售单号" class="input-300" autofocus @keyup.native.enter.stop="getData"></el-input>
        </el-form-item> -->
        <el-form-item label="物料编号">
          <!-- <el-select v-model="formData.product_Id" filterable placeholder="选择物料号" class="input-300" @change="getProductInfo()">
            <el-option v-for="item in productList" :key="item.product_Id" :label="item.productCode" :value="item.product_Id">
              <span style="float: left">{{ item.productCode }}</span>
              <span style="float: right; color: #8492a6; font-size: 13px">{{ item.productName }}</span>
            </el-option>
          </el-select> -->
 
          <el-select v-model="formData.product_Id" :remote-method="remoteMethod" filterable clearable remote reserve-keyword placeholder="选择物料号" class="input-300" @change="getProductInfo">
            <el-option v-for="item in productList" :key="item.product_Id" :label="item.productCode" :value="item.product_Id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="托盘号">
          <el-input ref="plateCode" v-model="formData.plateCode" autofocus class="input-300" @keyup.native.enter.stop="getPlateData"></el-input>
          <el-tag type="danger">注意:输入托盘号后回车,用于获取当前托盘中的所有物料,作为拼盘使用!</el-tag>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="saveCheck">确认</el-button>
          <el-button @click="onReset">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <el-card class="scan-card body-no-padding">
      <div slot="header" class="clearfix">
        <span class="padding-top-10">无单收货明细</span>
        <el-button type="text" class="floatRight" @click="setting.visible=true">字段设置</el-button>
      </div>
      <el-table ref="scan-table" :data="tableData" :row-class-name="rowClass" stripe style="width: 100%" class="scan-table" @row-dblclick="setCurrent">
        <template v-for="(item, index) in setting.fields">
          <template v-if="'positionName,scanWeight,purchasePrice,batchNumber'.indexOf(item.prop)>=0">
            <el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
              <template slot-scope="scope">
                <template>
                  <el-input v-model="scope.row[item.prop]" size="mini" class="w-100pc"></el-input>
                </template>
              </template>
            </el-table-column>
          </template>
          <template v-else-if="'produceDate,limitDate'.indexOf(item.prop)>=0">
            <el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
              <template slot-scope="scope">
                <template>
                  <el-date-picker v-model="scope.row[item.prop]" size="mini" type="date" placeholder="选择日期" class="w-110" value-format="yyyy-MM-dd" format="yyyy-MM-dd">
                  </el-date-picker>
                </template>
              </template>
            </el-table-column>
          </template>
          <template v-else-if="'productBarCode'.indexOf(item.prop)>=0">
            <el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
              <template slot-scope="scope">
                <template>
                  <el-input v-model="scope.row[item.prop]" size="mini" placeholder="请输入内容"></el-input>
                </template>
              </template>
            </el-table-column>
          </template>
          <template v-else-if="'toPlace,fromPlace,extendField04,unitConvert'.indexOf(item.prop)>=0">
            <el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
              <template slot-scope="scope">
                <template>
                  <el-input v-model="scope.row[item.prop]" size="mini" placeholder="请输入内容"></el-input>
                </template>
              </template>
            </el-table-column>
          </template>
          <template v-else-if="'finishedQuantity'.indexOf(item.prop)>=0">
            <el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
              <template slot-scope="{row}">
                <template>
                  <el-input-number v-model.number="row[item.prop]" :min="0" type="number" size="mini" class="w-100pc" @change="qtyChange(row, item.prop, index)" />
                </template>
              </template>
            </el-table-column>
          </template>
          <template v-else>
            <el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
            </el-table-column>
          </template>
        </template>
        <el-table-column fixed="right" label="操作" width="100">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="deleteRow(scope.row, scope.$index)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
 
    <el-dialog :visible.sync="dialogVisible" title="选择SKU" width="700px">
      <template>
        <el-table :data="findProductList" class="scan-table" style="width: 100%" @row-click="rowClick" @row-dblclick="(row, column, event)=>{changeProduct(row)}">
          <el-table-column prop="productCode" label="物料编号" width="180">
          </el-table-column>
          <el-table-column prop="productModel" label="条码" width="180">
          </el-table-column>
          <el-table-column prop="productName" label="物料名称">
          </el-table-column>
          <el-table-column prop="productSpec" label="物料规格">
          </el-table-column>
        </el-table>
      </template>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="changeProduct(multiProductSelected)">确 定</el-button>
      </span>
    </el-dialog>
    <scan-setting-dialog ref="setting-dialog" :visible.sync="setting.visible" :fields="setting.fields" :name="setting.name">
    </scan-setting-dialog>
 
    <!--声音文件-->
    <audio ref="sound_error" controls="controls" style="display:none;">
      <source src="@/assets/sounds/error2.mp3" type="audio/mpeg" />
    </audio>
    <audio ref="sound_correct" controls="controls" style="display:none;">
      <source src="@/assets/sounds/feixin.mp3" type="audio/mpeg" />
    </audio>
    <audio controls="controls" style="display:none;">
      <source ref="sound_scan" src="@/assets/sounds/saomiao.wav" type="audio/mpeg" />
    </audio>
 
  </div>
</template>
 
<script>
import YrtScanMixins from '@/components/common/yrtScanMixins.vue'
import ScanSettingDialog from '@/components/common/components/scanSettingDialog.vue'
var moment = require('moment')
 
export default {
  name: 'scan-purchase-noBillscan',
  components: {
    ScanSettingDialog
  },
  mixins: [YrtScanMixins],
  data() {
    return {
      moveTypeData: [
        {
          value: '0',
          label: '无'
        },
        {
          value: '202',
          label: '从成本中心退料202'
        },
        {
          value: '232',
          label: '从销售订单中退料232'
        },
        {
          value: '311(1)',
          label: '移库311(E)平库至立库'
        },
        {
          value: '262',
          label: '从生产订单中退料262'
        }
      ],
      moveType: '0',
      isChecked: true,
      isChecked_PrintForInStore:true,//是否选中 入库口打印机
      isChecked_PrintForOutStore:false,// 是否选中 出库口打印机
      printQty: 1,
 
      toPlaceData: [
        {
          value: 'G021',
          label: 'G021'
        },
        {
          value: 'G022',
          label: 'G022'
        },
        {
          value: 'G023',
          label: 'G023'
        },
        {
          value: 'G024',
          label: 'G024'
        },
        {
          value: 'G025',
          label: 'G025'
        },
        {
          value: 'G028',
          label: 'G028'
        },
        {
          value: 'G044',
          label: 'G044'
        }
      ],
      //清空默认值 【EditBy shaocx,2022-10-22】
      //toPlace: 'G021',
      //fromPlace: 'G028',
      toPlace: '',
      fromPlace: '',
      formData: {
        // 仓库ID
        storage_Id: 87,
        storageName: '立体库',
        positionName: '收货暂存区', // 货位id
        consignor_Id: 30,
        consignorCode: 'GX30',
        consignorName: '广州西门子',
        productModel: null,
        scanQty: null,
        provider_Id: '',
        providerCode: '',
        providerShortName: ''
      },
      tableDataSKU: [{}],
      positionName: '收货暂存区',
      // 供应商
      providerShortNames: null,
      // 货主
      consignorNames: null,
      // 仓库
      storageNames: null,
      productList: [],
      ALLproductList: [],
      // 收货位候选项
      positionList: [],
      // 是否展示SKU
      showProduct: false,
      dialogVisible: false,
      // SKU列表
      findProductList: [],
      // 明细数据
      tableData: [],
 
      // 仓库信息
      storageInfo: {},
 
      // 当前正在扫描的数据  {}
      currentRow: null,
      // 已经找到的数据
      existRows: [],
      // 装箱方式:0:常规扫描,1:一品一箱,2:多品一箱
      caseMode: 0,
      // 是否弹出一码多拍
      isCount: false,
      // 一次扫描的数量
      scanCount: 1,
      // 装箱新增行
      caseNewRows: [],
      // 配置参数
      config: {
        // 自动生成上架单
        in_generateShelve: true,
        // 是否启用装箱操作
        in_caseNumber: false,
        // 支持一品多码
        sku_productToMultiBarcode: true,
        caseMode: 0
      },
      // 多个物料时需要选择一个物料
      multiProductSelected: {},
      // 扫描列设置对话框参数
      setting: {
        visible: false,
        name: 'scan-purchase-noBillscan',
        fields: [
          {
            prop: 'extendField04',
            label: '跟踪号',
            visible: true,
            width: 170,
            order: 1
          },
          {
            prop: 'productCode',
            label: '物料编码',
            visible: true,
            width: 170,
            order: 1
          },
          {
            prop: 'productName',
            label: '物料名称',
            visible: true,
            width: 175,
            order: 2
          },
          {
            prop: 'productSpec',
            label: '物料规格',
            visible: true,
            width: 80,
            order: 12
          },
          // ,
          // {
          //   prop: "bigUnit",
          //   label: "采购单位",
          //   visible: true,
          //   width: 90,
          //   order: 4
          // }
          {
            prop: 'finishedQuantity',
            label: '本次收货数量',
            visible: true,
            width: 130,
            order: 6
          },
          {
            prop: 'limitDate',
            label: '限用日期',
            visible: true,
            width: 120,
            order: 7
          },
          {
            prop: 'quantity',
            label: '库存单位收货数量',
            visible: true,
            width: 160,
            order: 10
          },
          {
            prop: 'smallUnit',
            label: '库存单位',
            visible: true,
            width: 80,
            order: 11
          },
          {
            prop: 'unitConvert',
            label: '换算关系',
            visible: true,
            width: 80,
            order: 12
          },
          {
            prop: 'toPlace',
            label: '转入仓',
            visible: true,
            width: 80,
            order: 11
          },
          {
            prop: 'fromPlace',
            label: '转出仓',
            visible: true,
            width: 80,
            order: 12
          },
          {
            prop: 'positionName',
            label: '货位',
            visible: false,
            width: 80,
            order: 12
          }
        ]
      }
    }
  },
  // 监听数据
  watch: {
    // 当前行扫描数据改变后,将扫描数量也改变
    currentRow: {
      handler: function(rowData) {
        this.formData.scanQty = rowData.finishedQuantity
      },
      deep: true
    }
  },
  mounted() {
    this.getStorageList()
    this.getProductList()
    this.getConsignorList()
    this.getProvider()
    // 字段设置
    const setting = localStorage[this.setting.name + '-setting']
    if (setting) {
      this.setting.fields = JSON.parse(setting)
    }
  },
  methods: {
    //自动打印checkbox选中事件
    changeAutoPrint(){
      if(this.isChecked){
        this.isChecked_PrintForInStore=true
        this.isChecked_PrintForOutStore=false
      }else{
        this.isChecked_PrintForInStore=false
        this.isChecked_PrintForOutStore=false
      }
    },
    changeAutoPrint_PrintForInStore(){
      if(this.isChecked_PrintForInStore){
        this.isChecked_PrintForOutStore=false
      }else{
          this.isChecked_PrintForOutStore=true
      }
    },
    changeAutoPrint_PrintForOutStore(){
      if(this.isChecked_PrintForOutStore){
        this.isChecked_PrintForInStore=false
      }else{
          this.isChecked_PrintForInStore=true
      }
    },
    // 获取供应商列表
    getProvider() {
      const url = '/api/basicInfo/base/provider/getList'
      const params = {
        openNodeApi: true
      }
      var callback = res => {
        if (res.result) {
          this.providerShortNames = res.data
        }
      }
      this.common.ajax(url, params, callback, true)
    },
 
    // 获取仓库
    getStorageList() {
      const url = '/api/basicInfo/base/storage/getList'
      const params = {}
      var callback = res => {
        if (res.result) {
          debugger
          this.storageNames = res.data
        }
      }
      this.common.ajax(url, params, callback, true)
    },
    // 获取物料
    getProductList() {
      const url = '/api/basicInfo/base/productInfo/getProductList'
      const params = {}
      var callback = res => {
        if (res.result) {
          debugger
          this.productList = res.data
        }
      }
      this.common.ajax(url, params, callback, true)
    },
    // 获取货主名称下拉框
    getConsignorList() {
      const url = '/api/basicInfo/base/consignor/getList'
      const params = {}
      var callback = res => {
        if (res.result) {
          this.consignorNames = res.data
        }
      }
      this.common.ajax(url, params, callback, true)
    },
    // 根据仓库获取货位
    getPositionName() {
      var url = '/api/inbound/inScan/getPosition'
      // 仓库
      for (var index3 in this.storageNames) {
        if (this.storageNames[index3].storage_Id === this.formData.storage_Id) {
          this.formData.storage_Id = this.storageNames[index3].storage_Id
          this.formData.storageName = this.storageNames[index3].storageName
        }
      }
 
      for (var index in this.consignorNames) {
        if (this.consignorNames[index].consignor_Id === this.formData.consignor_Id) {
          this.formData.consignorCode = this.consignorNames[index].consignorCode
          this.formData.consignorName = this.consignorNames[index].consignorName
        }
      }
 
      for (var index2 in this.providerShortNames) {
        if (this.providerShortNames[index2].provider_Id === this.formData.provider_Id) {
          this.formData.providerCode = this.providerShortNames[index2].providerCode
          this.formData.providerShortName = this.providerShortNames[index2].providerShortName
        }
      }
      var params = {
        openNodeApi: true,
        storage_Id: this.formData.storage_Id
      }
      this.common.ajax(
        url,
        params,
        res => {
          if (res.result) {
            this.storageInfo = res.data
            this.positionList = res.dynamic
            if (this.positionList.length) {
              this.formData.positionName = this.positionList[0].positionName
            }
          } else {
            this.storageInfo = {}
            this.positionList = []
          }
          // 条码框获得焦点
          // this.$refs.productModel.focus();
          this.$refs.productModel.select()
        },
        true
      )
    },
    // 判断扫描包装条码
    checkPackingBarcode(evt) {
      this.checkPackingProductModel(this.tableData, null, this.getProductInfo)
    },
    // 获取物料信息
    getProductInfo() {
      var product_Id = this.formData.product_Id // masterData.productModel;
      // if (!productModel) {
      //   this.$message({
      //     message: "条码不能为空!",
      //     type: "warning"
      //   });
      //   return;
      // }
      var url = '/api/basicInfo/base/productInfo/find'
      var params = {
        openNodeApi: true,
        product_Id: product_Id
      }
      this.common.ajax(
        url,
        params,
        res => {
          this.common.showMsg(res)
          if (res.result) {
            this.findProductList = []
            for (var index in res.data) {
              this.$set(this.findProductList, this.findProductList.length, res.data[index])
              debugger
              if (res.data.length === 1) {
                this.changeProduct(res.data[0].product_Id, res.data[0].productName)
              }
            }
            // this.focus("productModel");
          } else {
            this.$refs.sound_error.play() // 播放声音
          }
        },
        true
      )
    },
    // 选中行
    rowClick(row, column, event) {
      this.multiProductSelected = row
    },
    // 选择物料
    changeProduct(row, column, event) {
      this.dialogVisible = false
      var positionName = this.positionName
      // var productModel = this.formData.productModel;
      var count = 1
      if (this.isCount) {
        for (var index in this.findProductList) {
          if (this.findProductList[index].product_Id === row.product_Id) {
            this.currentRow = this.findProductList[index]
            break
          }
        }
      } else {
        for (var index1 in this.findProductList) {
          if (this.findProductList[index1].product_Id === row) {
            this.currentRow = this.findProductList[index1]
          }
        }
      }
 
      // if (this.currentRow.middleBarcode === productModel) {
      //   // 中包装条码
      //   count = this.currentRow.middleUnitConvert;
      // } else if (this.currentRow.bigBarcode === productModel) {
      //   // 大包装条码
      //   count = this.currentRow.unitConvert;
      // }
      var limitDate = moment(new Date())
        .add(1, 'years')
        .format('YYYY-MM-DD')
 
      this.$set(this.currentRow, 'positionName', positionName) //货位
      this.$set(this.currentRow, 'limitDate', limitDate) //限用日期
      this.$set(this.currentRow, 'finishedQuantity', count) //本次收货数量
      this.$set(this.currentRow, 'fromPlace', this.fromPlace) //转出仓
      this.$set(this.currentRow, 'extendField04', this.formData.trackingNumber) //跟踪号
      this.$set(this.currentRow, 'unitConvert', 1) //换算关系
      this.$set(this.currentRow, 'toPlace', this.toPlace) //转入仓
 
      this.$set(this.currentRow, 'quantity', this.currentRow.unitConvert * this.currentRow.finishedQuantity) //库存单位收货数量
      this.$set(this.currentRow, 'scanWeight', count * this.currentRow.weight)
      this.$set(this.tableData, this.tableData.length, this.currentRow)
      this.existRows.push(this.currentRow)
      this.sortRow()
      this.showProduct = false
    },
    // 获得托盘上的物料明细数据
    getPlateData() {
      var _this=this;
      var plateCode = this.formData.plateCode
      if (!plateCode) {
        this.$message.error('托盘号不能为空!')
        return
      }
      // orderPrintCode = orderPrintCode.trim();
      this.tableData = []
      this.isChecked=true
      this.isChecked_PrintForInStore=false
      this.isChecked_PrintForOutStore=true
      const url = '/api/outbound/orderJx/getScanData'
      const params = {
        plateCode: plateCode,
        isall: true  //加载全部数据 【EditBy shaocx,2022-10-19】
      }
      var callback = res => {
        if (res.result) {
            this.findProductList = []
            for (var index in res.data) {
              var data=new Object();
              data.product_Id=res.data[index].product_Id;//商品ID
              //debugger
              data.extendField04=res.data[index].extendField04;//跟踪号
              data.productCode=res.data[index].productCode;//物料编码
              data.productName=res.data[index].productName;//物料名称
              data.finishedQuantity=res.data[index].productStorage;//当前托盘数量
              data.productSpec=res.data[index].productSpec;//物料规格
              data.limitDate=res.data[index].limitDate;//限用日期
              data.smallUnit=res.data[index].smallUnit;//库存单位
              data.unitConvert=res.data[index].unitConvert;//换算关系
              this.$set(this.findProductList, this.findProductList.length, data)
 
              this.changeProductForPlate(data.product_Id, data)
            }
        } else {
          this.$message.error(res.msg)
        }
      }
      this.common.ajax(url, params, callback, this.$refs['form'])
    },
    // 选择物料(有托盘号的情况) 【EditBy shaocx,2022-10-18】
    changeProductForPlate(row, materialData) {
      this.dialogVisible = false
      var positionName = this.positionName
      // var productModel = this.formData.productModel;
      var count = 1
      if (this.isCount) {
        for (var index in this.findProductList) {
          if (this.findProductList[index].product_Id === row.product_Id) {
            this.currentRow = this.findProductList[index]
            break
          }
        }
      } else {
        for (var index1 in this.findProductList) {
          if (this.findProductList[index1].product_Id === row) {
            this.currentRow = this.findProductList[index1]
          }
        }
      }
 
      // if (this.currentRow.middleBarcode === productModel) {
      //   // 中包装条码
      //   count = this.currentRow.middleUnitConvert;
      // } else if (this.currentRow.bigBarcode === productModel) {
      //   // 大包装条码
      //   count = this.currentRow.unitConvert;
      // }
 
      this.$set(this.currentRow, 'smallUnit', materialData.smallUnit) //库存单位
 
      this.$set(this.currentRow, 'positionName', positionName) //货位
      this.$set(this.currentRow, 'limitDate', materialData.limitDate) //限用日期
      this.$set(this.currentRow, 'finishedQuantity', materialData.finishedQuantity) //本次收货数量
      this.$set(this.currentRow, 'fromPlace', this.fromPlace) //转出仓
      this.$set(this.currentRow, 'extendField04',materialData.extendField04) //跟踪号
      this.$set(this.currentRow, 'unitConvert',materialData.unitConvert) //换算关系
      this.$set(this.currentRow, 'toPlace', this.toPlace) //转入仓
 
      this.$set(this.currentRow, 'quantity', this.currentRow.unitConvert * this.currentRow.finishedQuantity) //库存单位收货数量
      this.$set(this.currentRow, 'scanWeight', count * this.currentRow.weight)
      this.$set(this.tableData, this.tableData.length, this.currentRow)
      this.existRows.push(this.currentRow)
      this.sortRow()
      this.showProduct = false
    },
    getToPlace() {
      this.$set(this.currentRow, 'toPlace', this.toPlace)
      for (var item of this.tableData) {
        item.toPlace = this.toPlace
      }
      this.existRows.push(this.currentRow)
    },
    getFromPlace() {
      this.$set(this.currentRow, 'fromPlace', this.fromPlace)
      for (var item of this.tableData) {
        item.fromPlace = this.fromPlace
      }
      this.existRows.push(this.currentRow)
    },
    remoteMethod(query) {
      const url = 'api/basicInfo/base/productInfo/getList'
      const params = { name: query }
      var callback = res => {
        if (res.result) {
          this.ALLproductList = res.data
          this.productList = res.data
        }
      }
      this.common.ajax(url, params, callback, true)
    },
    // getTrackingNumber() {
    //   debugger;
    //   this.$set(this.currentRow, "extendField04", this.formData.trackingNumber);
    //   // for (var item of this.tableData) {
    //   //   item.extendField04 = this.formData.trackingNumber;
    //   // }
    //   this.existRows.push(this.currentRow);
    // },
 
    // 排序高亮行靠前
    sortRow() {
      this.tableData.forEach(element => {
        element.sortIndex = 0
      })
      this.currentRow.sortIndex = 1
      this.tableData = this.tableData.sort(function(a, b) {
        return b.sortIndex - a.sortIndex
      })
      this.tableData.forEach(element => {
        element.sortIndex = 0
      })
    },
    // 确认入库
    saveCheck() {
      debugger
      var emptyPositionName = this.tableData.filter(item => item.product_Id && item.finishedQuantity > 0 && !item.positionName)
      if (emptyPositionName.length) {
        this.$message.error('[' + emptyPositionName.join(',') + ']货位不能为空!')
        this.$refs.sound_error.play() // 播放声音
        return
      }
      debugger
      var dataList = this.tableData.filter(item => item.product_Id && item.quantity > 0).map(item => {
        return {
          storage_Id: 87,
          storageName: '立体库',
          trackingNumber: this.formData.trackingNumber,
          saleCode: this.formData.saleCode,
          providerShortName: this.formData.providerShortName,
          product_Id: item.product_Id,
          finishedQuantity: item.finishedQuantity,
          positionName: item.positionName,
          produceDate: item.produceDate,
          purchasePrice: item.purchasePrice,
          batchNumber: item.batchNumber,
          productSpec: item.productSpec,
          plateCode: item.plateCode,
          weight: item.weight,
          totalWeight: item.scanWeight,
          consignor_Id: 30,
          consignorCode: 'GX30',
          consignorName: '广州西门子',
          poCode: this.formData.poCode,
          quantity: item.quantity,
          limitDate: item.limitDate,
          productCode: item.productCode,
          toPlace: this.toPlace, // 转入仓
          fromPlace: this.fromPlace, // 转出仓
          extendField04: item.extendField04 // 跟踪号
        }
      })
      if (this.moveType === '311(1)') {
        this.moveType = '311'
      }
      const detailList = JSON.stringify(
        dataList.map(m => {
          return {
            MaterialCode: m.productCode,
            Quantity: m.finishedQuantity, // 本次收货量
            // Plant: m.extendField02, // 工厂
            MoveType: this.moveType,
            toPlace: this.toPlace, // 转入仓
            fromPlace: this.fromPlace, // 转出仓
            trackingNumber: m.extendField04 || null
          }
        })
      )
      if (dataList.length <= 0) {
        this.$message.error('没有扫描可用的数据!')
        return
      }
      //判断取值isChecked [EditBy shaocx,2022-06-21]
      let _printFlag=1  // 0不打印 1:入库口打印机 2:出库口打印机
      if(this.isChecked){
        _printFlag=1 //默认 入库口打印机
        if(this.isChecked_PrintForOutStore){
          _printFlag=2 //表示是 出库口打印机
        }
      }else{
        _printFlag=0
      }
  var creator = localStorage.getItem("creator") || ''; //创建人  
      var url = '/api/inbound/inScan/purchaseEnterNoBillSave'
      var params = {
        creator:creator,
        dataList: dataList,
        detailList: detailList,
        moveType: this.moveType,
        //isChecked: this.isChecked,
        isChecked: _printFlag,
        printQty: this.printQty
      }
      debugger
      this.common.ajax(
        url,
        params,
        res => {
          this.common.showMsg(res)
          if (res.result) {
            this.onReset()
            this.$refs.sound_correct.play() // 播放声音
          } else {
            this.$refs.sound_error.play() // 播放声音
          }
        },
        true
      )
    },
    // 明细数量改变
    qtyChange(row, prop, index) {
      if (prop === 'finishedQuantity') {
        // if (row.receivedQuantity > row.bigQty) {
        //   this.$message.error("数量不可超过PO单位数量");
        //   return;
        // }
        row.quantity = Math.Round((row.finishedQuantity || 0) * row.unitConvert)
      }
    },
    onReset() {
      this.formData = {
        storage_Id: 87,
        storageName: '立体库',
        // positionName: null, // 货位id
        // consignor_Id: null,
        // onsignorCode: null,
        // consignorName: null,
        productModel: null,
        scanQty: null,
        provider_Id: '',
        providerCode: '',
        providerShortName: ''
      }
      this.toPlace = null
      this.fromPlace = null
      this.tableData = []
      this.moveType = '0'
    },
    // 删除明细
    deleteRow(row, index) {
      debugger
      // const arriveQuantity = row.arriveQuantity;
      // const mainRow = this.tableData.find(item => item.isMain && item.orderList_Id === row.orderList_Id);
      // mainRow.arriveQuantity += arriveQuantity;
      // mainRow.unFinishedQuantity += arriveQuantity;
      this.tableData.splice(index, 1)
    }
  }
}
</script>
 
<style lang="scss" scoped>
@import '../../../styles/scan.scss';
</style>
<style lang="css">
.row-active {
  background-color: skyblue !important;
}
</style>