schangxiang@126.com
2025-09-10 3d43ffa3152110b7823f9fa6320c08a6ae02358a
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
<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-input v-model="formData.orderPrintCode" autofocus class="input-300" @keyup.native.enter.stop="getData"></el-input>
        </el-form-item>
        <el-form-item label="包材条码">
          <el-input ref="wrapperBarcode" v-model="formData.wrapperBarcode" class="input-300" @keyup.native.enter.stop="bathSet(1)"></el-input>
        </el-form-item>
        <el-form-item label="重量(KG)">
          <el-input ref="weight" v-model.number="formData.weight" :step="0.01" type="number" class="input-300" @keyup.native.enter.stop="bathSet(2)"></el-input>
        </el-form-item>
        <el-form-item>
          <!-- <el-button type="primary">设置选中项的包材和重量</el-button> -->
          <el-button type="primary" @click="onSubmit">确认发货</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>扫描结果</span>
      </div>
      <el-table :data="tableData" stripe style="width: 100%">
        <el-table-column prop="orderCode" label="订单编号" width="150">
        </el-table-column>
        <el-table-column prop="expressCorpName" label="快递公司" width="100">
        </el-table-column>
        <el-table-column prop="expressCode" label="快递单号" width="130">
        </el-table-column>
        <el-table-column prop="statusText" label="订单状态" width="100">
        </el-table-column>
        <el-table-column prop="totalQuantityOrder" label="合计数量" width="80">
        </el-table-column>
        <el-table-column prop="wrapperBarcode" label="包装条码" width="150">
        </el-table-column>
        <el-table-column prop="weight" label="订单重量(KG)">
          <template slot-scope="{row}">
            <el-input-number v-model.number="row.weight" :min="0" :step="0.01" size="mini" class="w-150" controls-position="right"></el-input-number>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
 
<script>
export default {
  name: "outbound-scan-order-send-batch",
  data() {
    return {
      formData: {
        orderCode: null,
        orderPrintCode: "", // 波次号
        wrapperBarcode: "", // 包装条码
        weight: "" // 重量
      },
      // 明细数据
      tableData: []
    };
  },
  methods: {
    // 获得数据
    getData() {
      var the = this;
      var orderPrintCode = the.formData.orderPrintCode;
      if (!orderPrintCode) {
        this.$message.error("波次号不能为空");
        return;
      }
      const url = "/api/outbound/orderSendBatch/getData";
      const parment = {
        orderPrintCode: orderPrintCode
      };
      const callback = res => {
        the.common.showMsg(res);
        if (res.result) {
          if (res.data.length > 0) {
            the.tableData = res.data;
            this.$refs.wrapperBarcode.focus();
          } else {
            this.$message.error(orderPrintCode + ",没有可发货的数据!");
            return;
          }
        }
      };
      the.common.ajax(url, parment, callback, the.$refs["form"]);
    },
    // 包材条码和重量回车事件
    bathSet(code) {
      if (code === 1) {
        var wrapperBarcode = this.formData.wrapperBarcode;
        this.tableData.forEach(rowData => {
          this.$set(rowData, "wrapperBarcode", wrapperBarcode);
        });
        this.$refs.weight.focus();
      }
      if (code === 2) {
        var weight = this.formData.weight;
        this.tableData.forEach(rowData => {
          this.$set(rowData, "weight", weight);
        });
      }
    },
    // 提交数据
    onSubmit() {
      const the = this;
      var orderPrintCode = this.formData.orderPrintCode;
      if (!this.formData.orderPrintCode) {
        this.$message.error("波次号不能为空!");
        return;
      }
      var dataList = [];
      this.tableData.forEach(rowData => {
        var orderCode = rowData.orderCode;
        var wrapperBarcode = this.formData.wrapperBarcode;
        const weight = rowData.weight || this.formData.weight;
 
        dataList.push({
          orderCode: orderCode,
          wrapperBarcode: wrapperBarcode,
          weight: weight
        });
      });
      if (!dataList.length) {
        this.$message.error("明细不能为空!");
        return;
      }
      const url = "/api/outbound/orderSendBatch/saveScan";
      const params = {
        orderPrintCode: orderPrintCode,
        dataList: dataList,
        weight: this.formData.weight || 0
      };
      var callback = res => {
        the.common.showMsg(res);
        if (res.result) {
          this.onReset();
        }
      };
      the.common.ajax(url, params, callback, true);
    },
    // 重置数据
    onReset() {
      this.formData = {
        orderCode: null,
        orderPrintCode: "", // 波次号
        wrapperBarcode: "", // 包装条码
        weight: "" // 重量
      };
      // 明细数据
      this.tableData = [];
    }
  }
};
</script>
 
<style lang="scss" scoped>
@import "../../../styles/scan.scss";
</style>