333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
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
<script>
export default {
  data() {
    return {
      // 选择器配置参数
      selectorConfig: {
        title: '物料选择器',
        width: '1000px',
        visible: false,
        // 配置路由
        router: '/selector/s-product-selector'
      },
      selectorPositionConfig: {
        title: '物料库存选择器',
        width: '1000px',
        visible: false,
        // 配置路由
        router: '/selector/x-product-selector',
        url: '/api/common/GroupDataList'
      },
      // 明细转移是否显示
      detailtransferVisible: false,
      // 批量更改折扣率是否显示
      batchupdateVisible: false,
      // 批量拆分是否显示
      batchtransferVisible: false,
      // 批量拆分导入是否显示
      batchimportVisible: false,
      formLabelWidth: '120px',
      // 明细拆分列表
      splitDetails: [],
      // 显示确认入库对话框
      checkEnterVisible: false
    }
  },
  methods: {
    // 列表页面按钮点击事件
    buttonClick(authNode) {
      switch (authNode) {
        case 'auditing':
          // 批量审核
          this.batchAuditing(this.dataListSelections)
          return false
        case 'inTransit':
          // 确认为在途中
          this.onInTransit()
          return false
        case 'determine':
          // 付款确认
          this.determine()
          return false
        case 'forceFinish':
          // 强制完成
          this.forceFinish()
          return false
        // 导入
        case 'allImport':
          this.orderInfoImportConfig.isShowDialog = true
          return false
        // 合并
        case 'beTogether':
          this.beTogether()
          return false
        // 一键确认入库
        case 'confirmQuickEnter':
          this.confirmQuickEnter()
          return false
        // 新建
        case 'addOrder':
          this.dialogFormVisible = true
          return true
        case 'print':
          // 打印
          this.print()
          return true
        case 'labelPrint':
          // 打印物流单
          this.printExpress()
          break
      }
    },
    // 明细按钮点击事件
    detailButtonClick(authNode) {
      switch (authNode) {
        case 'detailAdd':
          // 物料明细添加
          this.detailAdd()
          return true
        case 'detailTransfer':
          // 明细转移
          this.detailTransfer()
          return true
        case 'batchUpdate':
          // 批量设置折扣率
          this.batchUpdate()
          return true
        case 'batchTransfer':
          // 批量拆分
          this.batchTransfer()
          return true
        case 'batchImport':
          // 批量拆分导入
          this.batchImport()
          return true
        // 明细添加 - 物料库存
        case 'detailAddPosition':
          this.openPositionSelected()
          return true
        // 明细导出
        case 'exportList':
          this.exportList()
          return true
        // 明细导入
        case 'importList':
          // this.importList();
          // return true;
          // 批量导入
          this.orderImportConfig.isShowDialog = true
          return false
        case 'detailSplitOrders':
          // 拆分订单
          this.splitOrder()
          return false
      }
    },
    // 编辑按钮点击事件
    editButtonClick(authNode, formData) {
      switch (authNode) {
        case 'auditing':
          // 批量审核
          this.batchAuditing([formData])
          return false
      }
    },
    // 审核
    batchAuditing(dataListSelections) {
      let isok = true
      const order_Ids = dataListSelections.map((item, index, Array) => {
        return item.order_Id
      })
      const statusText = dataListSelections.map((item, index, Array) => {
        return item.statusText
      })
      statusText.forEach(status => {
        if (status !== '新建') {
          isok = false
        }
      })
      if (isok === false) {
        this.$message.error('只有新建货单,可以审核!')
        return false
      }
      if (!order_Ids.length) {
        this.$message.error('请至少选择一行数据!')
        return false
      }
      this.$confirm('提示:确认后将无法进行修改', '确认审核', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          const url = '/api/inbound/order/batchAuditing'
          const params = {
            openNodeApi: true,
            order_Ids: order_Ids
          }
          const ref = this.dataList
          var callback = res => {
            this.common.showMsg(res)
            if (res.result) {
              ref.loadData()
            }
          }
          this.common.ajax(url, params, callback, ref)
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
        })
    },
    // 确认为在途中
    onInTransit() {
      const order_Ids = this.dataListSelections.map((item, index, Array) => {
        return item.order_Id
      })
      if (!order_Ids.length) {
        this.$message.error('请至少选择一行数据!')
        return false
      }
      const statusText = ['审核成功']
      const filterList = this.dataListSelections.filter((item, index, Array) => {
        return statusText.indexOf(item.statusText) >= 0
      })
      if (!filterList.length) {
        this.$message.error(`只有${statusText.join(',')}才可以确认为在途中!`)
        return false
      }
      this.$confirm('是否确认为在途中?', '确认为在途中', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          // order_Id = order_Id[0];
          const url = '/api/inbound/order/onInTransit'
          const params = {
            order_Ids: order_Ids,
            openNodeApi: true,
            isFullPlate: 1
          }
          const ref = this.dataList
          var callback = res => {
            this.common.showMsg(res)
            if (res.result) {
              this.$message.success(res.msg)
              ref.loadData()
            }
          }
          this.common.ajax(url, params, callback, ref)
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
        })
    },
    // 强制完成
    forceFinish() {
      let isok = true
      let order_Id = this.dataListSelections.map((item, index, Array) => {
        return item.order_Id
      })
      const statusText = this.dataListSelections.map((item, index, Array) => {
        return item.statusText
      })
      if (!order_Id.length) {
        this.$message.error('请至少选择一行数据!')
        return false
      }
      statusText.forEach(rowData => {
        if (rowData !== '部分交货') return (isok = false)
      })
      if (isok === false) {
        this.$message.error('仅可部分交货时强制完成!')
        return false
      }
      this.$confirm('强制完成后,剩余未收货物料将无法继续收货,是否继续?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          order_Id = order_Id[0]
          const url = '/api/inbound/order/forceFinish'
          const params = {
            openNodeApi: true,
            order_Id: order_Id
          }
          const ref = this.dataList
          var callback = res => {
            this.common.showMsg(res)
            if (res.result) {
              this.$message.success(res.msg)
              ref.loadData()
            }
          }
          this.common.ajax(url, params, callback, ref)
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
        })
    },
    // 导入主表和明细
    allAllImport() {
      // window.location.href = "#/inbound/purchase/inbound/import/purchase-order";
      this.$router.push('/inbound/import/purchase-order')
    },
    // 合并
    beTogether() {
      // 得到,明细选中项
      var IsOrderStatus = true // 状态
      const selectIDs = this.dataListSelections
        .map((item, index, Array) => {
          if (item.statusText !== '新建') {
            IsOrderStatus = false
          } else {
            IsOrderStatus = true
          }
          return item.order_Id
        })
        .join(',')
      if (selectIDs === '') {
        this.$message({
          message: '至少选中一行!',
          type: 'warning'
        })
        return false
      }
      if (IsOrderStatus === false) {
        this.$message({
          message: '新建状态才能合并!',
          type: 'warning'
        })
        return false
      }
 
      this.$confirm('确定要合并选中预到货单吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          // 获得已选中的ID
          const selectIDs = this.dataListSelections.map((item, index, Array) => {
            return item.order_Id
          })
          const url = '/api/inbound/order/orderMerge'
          const params = {
            order_Ids: selectIDs
          }
          this.common.ajax(url, params, res => {
            this.common.showMsg(res)
            const ref = this.dataList
            if (res.result) {
              ref.loadData()
            }
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消合并'
          })
        })
    },
    // 一键入库
    confirmQuickEnter() {
      if (this.dataListSelections.length !== 1) {
        this.$message.error('请选择一条预到货单进行操作')
        return false
      }
      const rowInfo = this.dataListSelections[0]
 
      const statusText = rowInfo.statusText
      const statusList = ['新建', '审核成功', '在途中', '部分交货']
      if (statusList.indexOf(statusText) < 0) {
        this.$message.error(`只有【${statusList.join(',')}】的单据才允许入库!`)
        return false
      }
      this.checkEnterVisible = true // 显示对话框
      var order_Id = rowInfo.order_Id
      var storage_Id = rowInfo.storage_Id
      var plateCode = rowInfo.plateCode
      this.$refs.checkEnterDialog.initData(order_Id, storage_Id, plateCode)
    },
    // 拆分订单
    splitOrder() {
      this.detailsplitimportVisible = true
      const datas = this.editorOptions.fields.filter(item => item.type === 'detail-grid')[0].options.detailSelections
      const splitDetails = JSON.parse(JSON.stringify(datas))
      const order_Id = this.editor.formData['order_Id']
      this.$refs.detailsplitDialog.initData(splitDetails, order_Id)
    },
    // 显示一次性收费项弹窗
    showFeeTtemPopup() {
      const order_Id = this.editor.formData['order_Id']
      if (!order_Id) {
        this.$message({
          message: '当前数据没有保存!',
          type: 'warning'
        })
        return
      }
      // 显示一次性收费项弹窗
      this.isFeeTtemPopupVisible = true
      this.$refs.feeTtemPopupDialog.initData(order_Id)
    },
    // 打开物料选择器
    detailAdd() {
      const selector = this.$refs['selector-dialog']
      selector.loadData()
      this.selectorConfig.visible = true
    },
    // 将选择器选择中的数据填充到明细表中
    onSelected(rows) {
      debugger
      rows.forEach(row => {
        this.$set(row, 'originPlace', row.originPlace)
        this.$set(row, 'quantity', 1)
        this.$set(row, 'totalPackageQty', 1)
        this.$set(row, 'totalWeight', row.weight)
        this.$set(row, 'taxAmount', row.ratePrice)
        this.$set(row, 'rateMoney', row.ratePrice)
        this.$set(row, 'purchaseMoney', row.purchasePrice)
        this.$set(row, 'originPlace', row.originPlace)
        this.$set(row, 'totalPackageQty', 1)
        this.$set(row, 'relationCode', row.typeName)
        this.$set(row, 'productSpec', row.productSpec)
      })
      this.editor.addDetailDataRow(rows)
      this.selectorConfig.visible = false
      this.setTotal()
    },
    // 打开库存选择器
    openPositionSelected() {
      var editorRef = this.editor
      if (!editorRef.formData.consignorName) {
        this.$message({
          message: '请选择货主!',
          type: 'warning'
        })
        return
      }
      const selector = this.$refs['selector-position-dialog']
      selector.setSearchValue('storage_Id', [editorRef.formData.storage_Id])
      selector.setSearchValue('consignor_Id', [editorRef.formData.consignor_Id])
      selector.setReadOnly('storage_Id', true) // 设为只读
      selector.setReadOnly('consignor_Id', true) // 设为只读
 
      selector.loadData()
      this.selectorPositionConfig.visible = true
    },
    // 将库存物料选择器选择中的数据填充到明细表中
    onPositionSelected(rows) {
      rows.forEach(element => {
        element.quantity = element.productStorage
        element.totalPackageQty = element.quantity
        element.singleSignCode = ''
        this.$set(element, 'ratePrice', element.purchasePrice * (1 - (element.rate || 0)))
        this.$set(element, 'taxAmount', element.ratePrice * element.productStorage)
        this.$set(element, 'rateMoney', element.ratePrice * element.productStorage)
        this.$set(element, 'originPlace', element.originPlace)
        this.$set(element, 'totalPackageQty', element.quantity)
      })
      this.editor.addDetailDataRow(rows)
      this.selectorPositionConfig.visible = false
      this.setTotal()
    },
    // 明细转移
    detailTransfer() {
      const orderList_Ids = []
      if (this.editor.detailFields[0].options.detailSelections.length < 1) {
        this.$message.error('至少选中一行明细数据!')
        return false
      }
      const order_Id = this.editor.detailFields[0].options.detailSelections[0]['order_Id']
 
      this.detailtransferVisible = true
      this.editor.detailFields[0].options.detailSelections.forEach(rowData => {
        orderList_Ids.push(rowData.orderList_Id)
      })
 
      this.$refs['detailtransfer-dialog'].order_Id = order_Id
      this.$refs['detailtransfer-dialog'].detailIdList = orderList_Ids.join(',')
      this.editor.config.visible = false
    },
    // 批量设置折扣率
    batchUpdate() {
      let orderList_Ids = []
      if (this.editor.detailFields[0].options.detailSelections.length < 1) {
        this.$message.error('至少选中一行明细数据!')
        return false
      }
      this.batchupdateVisible = true
      this.editor.detailFields[0].options.detailSelections.forEach(rowData => {
        orderList_Ids.push(rowData.orderList_Id)
      })
      orderList_Ids = orderList_Ids.join(',')
      this.$refs['batchupdate-dialog'].showDetailIdList(orderList_Ids)
    },
    // 批量拆分
    batchTransfer() {
      const rows = []
      if (this.editor.detailFields[0].options.detailSelections.length < 1) {
        this.$message.error('至少选中一行明细数据!')
        return false
      }
      this.batchtransferVisible = true
      this.editor.detailFields[0].options.detailSelections.forEach(rowData => {
        rows.push(rowData)
      })
      this.$refs['batchtransfer-dialog'].showData(rows)
    },
    // 批量拆分导入
    batchImport() {
      const rows = []
      if (this.editor.detailFields[0].options.detailSelections.length < 1) {
        this.$message.error('至少选中一行明细数据!')
        return false
      }
      this.batchimportVisible = true
      this.editor.detailFields[0].options.detailSelections.forEach(rowData => {
        rows.push(rowData)
      })
      this.$refs['batchimport-dialog'].showData(rows)
    },
    // 明细导出
    exportList() {
      const ids = []
      var formData = this.editor.formData
      var detailRows = formData['Purchase_OrderList'].rows
      detailRows.map((item, index, array) => {
        ids.push(item.orderList_Id)
      })
      var url = '/api/inbound/order/exportList'
      const params = {
        ids: ids.join(',')
      }
      var callback = res => {
        this.common.showMsg(res)
        if (res.result) {
          const url = this.common.domain + '/api/common/download?url=' + res.data.url
          window.open(url)
        }
      }
      this.common.ajax(url, params, callback, true)
    },
    // 打印条码
    printBarcode(formData, details, type) {
      // 得到,明细选中项
      var detailSelections = details[0].options.detailSelections
      if (!detailSelections.length) {
        this.$message.error('至少选择一项!')
        return
      }
      // 自定义打印字段数据
      var keyValues = [{ key: '供应商', value: formData.providerShortName }]
 
      if (['middleBarcode', 'bigBarcode'].indexOf(type) >= 0) {
        const url = '/api/basicInfo/base/productInfo/getBarcode'
        const params = {
          type: type,
          code: detailSelections.map(item => {
            return item.productModel
          })
        }
        this.common.ajax(
          url,
          params,
          res => {
            this.common.showMsg(res)
            if (res.result) {
              let rows = JSON.parse(JSON.stringify(detailSelections))
              rows = rows.filter(item => {
                return res.data.some(row => {
                  const exist = row.productModel === item.productModel
                  if (exist) {
                    item.productModel = row[type]
                  }
                  return exist
                })
              })
              this.barcodeVisible = true
              this.$refs['barcode-dialog'].showData(rows, keyValues)
            }
          },
          true
        )
      } else {
        this.barcodeVisible = true
        var rows = JSON.parse(JSON.stringify(detailSelections))
        this.$refs['barcode-dialog'].showData(rows, keyValues)
      }
    },
    // 打印物流单
    printExpress() {
      var ids = []
      this.dataListSelections.forEach(item => {
        ids.push(item[this.dataOptions.idField])
      })
      if (!ids.length) {
        this.$message.error('至少选择一项!')
        return
      }
      var url = '/api/inbound/order/getOrderIds'
      var params = {
        ids: ids
      }
      this.common.ajax(
        url,
        params,
        res => {
          this.common.showMsg(res)
          if (res.result) {
            // this.updatePrintCount(ids); // "logisticsPrint",
            window.open('/#/print/base2/purchase-order/' + res.data.join(','))
          }
        },
        this.dataList
      )
    },
    // 更新打印次数
    updatePrintCount(type, ids) {
      const url = '/api/inbound/order/updatePrintCount'
      const params = {
        ids: ids,
        type: type
      }
      this.common.ajax(url, params, res => {
        this.common.showMsg(res)
        if (res.result) {
          this.dataList.reload()
        }
      })
    }
    // 明细添加后事件
    // onAddDetailRowAfter(row) {
    //   debugger;
    //   var plateType = this.masterData.plateType;
    //   var plateType_Id = this.masterData.plateType_Id;
    //   const url = "/api/basicInfo/base/productInfo/getListByPlateType";
    //   const params = {
    //     plateType_Id: plateType_Id,
    //     plateType: plateType
    //   };
    //   var callback = res => {
    //     if (res.result) {
    //       this.editor.setDropdownData(34, res.data);
    //       // this.editor.addDetailDataRow(res.data);
    //     }
    //   };
    //   this.common.ajax(url, params, callback, true);
    // }
  }
}
</script>