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
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
<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 ref="batchCode" v-model="formData.batchCode" class="input-300" autofocus="ture" @keyup.native.enter.stop="QueryBatchCode"></el-input>
        </el-form-item>
        <el-form-item label="出库/快递单号">
          <el-input ref="expressCode" v-model="formData.expressCode" :disabled="formData.isReadonlyExpressCode" class="input-300" @keyup.native.enter.stop="getData"></el-input>
          <!--    v-focus="focusStatus"   @focus="focus($event)" -->
          <span class="sub-item">
            <span class="sub-label">校验物料:</span>
            <el-switch v-model="formData.isValidateProductCode" @change="onIsValidateProductCodeChange"></el-switch>
          </span>
        </el-form-item>
        <!-- <el-form-item label="快递名称">
          <el-select v-model="formData.expressCorp" :disabled="formData.isReadonlyExpressCorp" placeholder="选择快递名称" class="input-300">
            <el-option label="4PX" value="4PX"></el-option>
            <el-option label="Fedex" value="Fedex"></el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="物料条码">
          <el-input ref="productModel" v-model="formData.productModel" :disabled="formData.isReadonlyProductModel" class="input-300" @keyup.native.enter.stop="checkPackingBarcode"></el-input>
          <span class="sub-item">
            <span class="sub-label">扫描数量:</span>
            <el-input-number v-model="formData.scanQty" :min="1" :disabled="formData.isReadonlyProductModel" controls-position="right" class="input-100" @change="changeScanQty"></el-input-number>
          </span>
        </el-form-item>
        <el-form-item label="包材条码">
          <el-input v-if="formData.supportMulti" ref="wrapperBarcode" v-model="formData.wrapperBarcode" :disabled="formData.lock" :rows="2" type="textarea" class="input-300" @keyup.native.enter.stop="checkWrapperBarcode"></el-input>
          <el-input v-else ref="wrapperBarcode" v-model="formData.wrapperBarcode" :disabled="formData.lock" class="input-300" @keyup.native.enter.stop="checkWrapperBarcode"></el-input>
          <span class="sub-item">
            <span class="sub-label">多个包材:</span>
            <el-switch v-model="formData.supportMulti" :disabled="formData.chkSupportMulti"></el-switch>
          </span>
          <span class="sub-item">
            <span class="sub-label">锁定:</span>
            <el-switch v-model="formData.lock"></el-switch>
          </span>
        </el-form-item>
        <el-form-item label="重量">
          <el-input ref="weight" v-model="formData.weight" :disabled="formData.lockWeight" class="input-300" @keyup.native.enter.stop="checkWeight"></el-input>
          <span class="sub-item">
            <span class="sub-label">锁定:</span>
            <el-switch v-model="formData.lockWeight"></el-switch>
          </span>
        </el-form-item>
        <el-form-item label="新快递单号">
          <el-input ref="newExpressCode" v-model="formData.newExpressCode" :disabled="!formData.isNewExpressCode" class="input-300" @keyup.native.enter.stop="checkNewExpressCode"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onPartialSave">确认发运</el-button>
        </el-form-item>
      </el-form>
      <!-- <img :src="img" class="product-img"> -->
    </el-card>
    <el-card class="scan-card body-no-padding">
      <div slot="header" class="clearfix">
        <span>扫描结果</span>
      </div>
      <el-table :data="tableData" :row-class-name="rowClass" stripe style="width: 100%" @row-click="setCurrent">
        <el-table-column prop="productModel" label="条形码" width="150">
        </el-table-column>
        <el-table-column prop="quantityOrder" label="物料数量" width="80">
        </el-table-column>
        <el-table-column prop="quantityOuter" label="已出库数量" width="100">
        </el-table-column>
        <el-table-column prop="finishedQuantity" label="已扫描数量" width="100">
        </el-table-column>
        <el-table-column prop="unFinishedQuantity" label="未扫描数量" width="100">
        </el-table-column>
        <el-table-column prop="productCode" label="物料编号" width="130">
        </el-table-column>
        <el-table-column prop="salePrice" label="单价" width="80">
        </el-table-column>
        <el-table-column prop="productSpec" label="物料规格" width="150">
        </el-table-column>
        <el-table-column prop="weight" label="单位毛重" width="80">
        </el-table-column>
        <!-- <el-table-column prop="totalWeight" label="合计重量" width="80">
        </el-table-column> -->
        <el-table-column prop="scanWeight" label="已扫重量" width="80">
          <template slot-scope="scope">
            <template>
              <el-input v-model="scope.row.scanWeight" size="mini" class="w-100pc"></el-input>
            </template>
          </template>
        </el-table-column>
        <el-table-column prop="productName" label="物料名称">
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
 
<script>
import YrtScanMixins from "@/components/common/yrtScanMixins.vue";
export default {
  name: "ooutbound-scan-order-send-fast",
  mixins: [YrtScanMixins],
  data() {
    return {
      formData: {
        batchCode: "",
        expressCode: "",
        expressCorp: null,
        productModel: null,
        newExpressCode: null,
        isValidateProductCode: true, // 是否校验物料
        isReadonlyExpressCode: true, // 快递单号只读
        isReadonlyExpressCorp: true, // 快递名称只读
        isReadonlyProductModel: true, // 物料条码和扫描数量
        isNewExpressCode: true, // 新快递单号
        lock: false, // 包装条码锁定
        lockWeight: false, // 重量锁定
        // 当前正在扫描的数据
        currentRow: {},
        // 已经找到的数据
        existRows: [],
        chkSupportMulti: false, // 多个包材
        wrapperBarcode: null, // 包装条码
        weight: null // 重量
      },
      // 系统配置参数
      config: {
        sku_productToMultiBarcode: true
      },
      // 待扫描数据集合
      tableData: [],
      img: null
    };
  },
  watch: {
    tableData: {
      handler: function(val) {},
      deep: true
    }
  },
  activated() {
    const isValidateProductCode = localStorage["out_isValidateProductCode"];
    if (isValidateProductCode) {
      this.formData.isValidateProductCode = isValidateProductCode === "true";
    }
  },
  methods: {
    // 是否校验物料切换
    onIsValidateProductCodeChange(val) {
      localStorage["out_isValidateProductCode"] = this.formData.isValidateProductCode;
      this.tableData.forEach(rowData => {
        rowData.unFinishedQuantity = this.formData.isValidateProductCode ? rowData.quantityOrder - rowData.quantityOuter : 0;
        rowData.finishedQuantity = this.formData.isValidateProductCode ? 0 : rowData.quantityOrder - rowData.quantityOuter;
      });
 
      this.formData.isReadonlyProductModel = !val;
    },
    // 重量回车事件
    checkWeight() {
      var isFinished = this.checkFinished();
      var isValidateProductCode = this.formData.isValidateProductCode === true;
      // 校验物料并且已经扫描完毕并且重量已经锁定
      if (!this.checkIsOuted()) {
        if ((isValidateProductCode && isFinished) || !isValidateProductCode) {
          this.formData.formData.isValidateProductCode = false;
          this.save();
        }
      }
    },
    // 波次回车之后,快递单号置为可用
    QueryBatchCode() {
      const batchCode = this.formData.batchCode;
      if (!batchCode) {
        this.$message.error("波次号不能为空!");
        return;
      }
      this.formData.isReadonlyExpressCode = false;
      this.$nextTick(() => {
        this.$refs.expressCode.focus();
        this.$refs.expressCode.select();
      });
    },
    getData() {
      var batchCode = this.formData.batchCode;
      var expressCode = this.formData.expressCode;
      if (!batchCode) {
        this.$message.error("波次号不能为空!");
        return;
      }
      if (!expressCode) {
        this.$message.error("快递单号不能为空!");
        return;
      }
      const url = "/api/outbound/outScan/getData";
      const params = {
        openNodeApi: true,
        expressCode: expressCode,
        batchCode: batchCode,
        isNoScanBatchCode: true
      };
      this.common.ajax(
        url,
        params,
        res => {
          this.common.showMsg(res);
 
          if (res.result && res.data) {
            var isValidateProductCode = this.formData.isValidateProductCode;
            res.data.forEach(rowData => {
              rowData.unFinishedQuantity = this.formData.isValidateProductCode ? rowData.quantityOrder - rowData.quantityOuter : 0;
              rowData.finishedQuantity = this.formData.isValidateProductCode ? 0 : rowData.quantityOrder - rowData.quantityOuter;
            });
            this.tableData = res.data;
 
            // 如果需要校验物料,则呈现明细信息,否则直接 闪电发货
            if (isValidateProductCode) {
              this.formData.isReadonlyProductModel = false;
              this.formData.expressCorp = res.Msg;
              this.$nextTick(() => {
                this.$refs.productModel.focus();
                this.$refs.productModel.select();
              });
            } else {
              if (this.formData.lock === false) {
                // 这里应该给包装条码焦点
                this.$refs.wrapperBarcode.focus();
                this.$refs.wrapperBarcode.select();
              } else if (this.formData.lockWeight === false) {
                // 这里应该改重量(kg)焦点
                this.$refs.weight.focus();
                this.$refs.weight.select();
              } else {
                this.save();
              }
            }
          }
        },
        true
      );
    },
    // 扫描物料条码回车
    checkPackingBarcode(evt) {
      this.checkPackingProductModel(this.detailDataList, null);
    },
    // 缓存图片
    loadImg(code) {
      var the = this;
      const url = "/api/outbound/outScan/getProductImg";
      const params = {
        openNodeApi: true,
        orderCode: code
      };
      var callback = res => {
        the.common.showMsg(res);
        if (res.result) {
          var url = res.data;
          this.img = url;
        }
      };
      the.common.ajax(url, params, callback);
    },
 
    // 判断扫描是否完成
    checkFinished() {
      var isFinished = this.tableData.every(item => {
        return item.unFinishedQuantity <= 0;
      });
      return isFinished;
    },
    // 判断是否有出库数量
    checkIsOuted() {
      const isOuted = this.tableData.some(item => {
        return item.finishedQuantity > 0;
      });
      return isOuted;
    },
    // 扫描手工更改扫描数量
    changeScanQty() {
      if (this.currentRow) {
        this.currentRow.finishedQuantity = this.formData.scanQty;
        this.currentRow.unFinishedQuantity = Math.Round(this.currentRow.quantityOrder - this.formData.scanQty - this.currentRow.quantityOuter, 4);
      }
    },
    // 包材条码回车事件
    checkWrapperBarcode() {
      if (this.formData.chkSupportMulti === false) {
        var isFinished = this.checkFinished();
        var isValidateProductCode = this.formData.isValidateProductCode;
        var isLockWeight = this.formData.lockWeight;
        // 重量已经锁定
        if (isLockWeight) {
          // 校验物料并且已经扫描完毕
          if (isValidateProductCode && isFinished) {
            this.save();
          } else if (!isValidateProductCode) {
            this.save();
          }
        } else {
          this.$refs.weight.focus();
          this.$refs.weight.select();
        }
      }
    },
    // 部分打包出库后,新快递单号获取焦点,输入完新快递单号回车之后,物料条码输入框获取焦点
    checkNewExpressCode() {
      this.$refs.productModel.focus();
    },
    // 完全出库后重置
    reset() {
      this.formData = {
        batchCode: "",
        expressCode: "",
        expressCorp: null,
        productModel: null,
        newExpressCode: null,
        isValidateProductCode: true,
        isReadonlyExpressCode: true, // 快递单号只读
        isReadonlyExpressCorp: true, // 快递名称只读
        isReadonlyProductModel: true, // 物料条码和扫描数量
        isNewExpressCode: false, // 需要新快递单号
        lock: false, // 包装条码锁定
        lockWeight: false, // 重量锁定
        // 当前正在扫描的数据
        currentRow: {},
        // 已经找到的数据
        existRows: [],
        chkSupportMulti: false, // 多个包材
        wrapperBarcode: null, // 包装条码
        weight: null // 重量
      };
      this.$refs.batchCode.focus();
    },
    // 部分发运
    onPartialSave() {
      // 波次
      var batchCode = this.formData.batchCode;
      // 快递单号
      var expressCode = this.formData.expressCode;
      // 包装条码
      var wrapperBarcode = this.formData.wrapperBarcode;
      // 重量
      var weight = this.formData.weight;
      // 新快递单号
      var newExpressCode = this.formData.newExpressCode;
 
      if (!batchCode) {
        this.$message.error("波次单号不能为空!");
        return;
      }
      if (!expressCode) {
        this.$message.error("快递单号不能为空!");
        return;
      }
 
      var isFinished = this.checkFinished();
      var isOuted = this.checkIsOuted();
      // 未扫描数量有大于0的,或者 已出库数量有大于0的 ,才能部分发运
      if (isFinished && !isOuted) {
        this.$message.error("不满足部分打包的条件!");
        return;
      }
      var dataArray = this.tableData
        .filter(m => {
          return m.finishedQuantity > 0;
        })
        .map(item => {
          return {
            orderCode: item.orderCode,
            order_Id: item.order_Id,
            caseNumber: null,
            orderList_Id: item.orderList_Id,
            scanCount: item.finishedQuantity,
            weight: item.weight,
            totalWeight: item.scanWeight
          };
        });
      if (!dataArray.length) {
        this.$message.error("没有可出库单数量");
        return;
      }
 
      const url = "/api/outbound/outScan/outPartialSaveScan";
      const params = {
        openNodeApi: true,
        expressCode: expressCode,
        wrapperBarcode: wrapperBarcode,
        newExpressCode: newExpressCode,
        data: dataArray,
        weight: weight
      };
      const callBack = res => {
        this.common.showMsg(res);
        if (res.result) {
          this.onReset();
        }
      };
      this.common.ajax(url, params, callBack, true);
    },
    // 重置
    onReset() {
      this.formData.batchCode = null;
      this.formData.expressCode = null;
      this.formData.productModel = null;
      this.formData.newExpressCode = null;
      this.formData.isReadonlyExpressCode = true;
      this.formData.isReadonlyExpressCorp = true;
      this.formData.isReadonlyProductModel = true;
      this.formData.isNewExpressCode = false;
      this.formData.currentRow = {};
      this.formData.existRows = [];
      this.formData.wrapperBarcode = null;
      this.formData.weight = null;
      this.tableData = [];
 
      this.$refs.batchCode.focus();
      this.$refs.batchCode.select();
    }
  }
};
</script>
 
<style lang="scss" scoped>
@import "../../../styles/scan.scss";
</style>