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
<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="plateCode" v-model="formData.plateCode" class="input-325" @keyup.native.enter.stop="checkPackingBarcode"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="btnSave">回库叠盘</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" :row-class-name="rowClass" :data="tableData" stripe style="width: 100%" class="scan-table" @row-dblclick="setCurrent">
        <template v-for="(item, index) in setting.fields">
          <template v-if="'positionName,scanWeight'.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>
            <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>
    </el-card>
    <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 ref="sound_scan" controls="controls" style="display:none;">
      <source 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";
export default {
  name: "outbound-scan-order-picking-shelve",
  components: {
    ScanSettingDialog
  },
  mixins: [YrtScanMixins],
  data() {
    return {
      formData: {
        productModel: null, // 物料条码
        storage_Id: 0, // 仓库ID
        storageName: null, // 仓库名称
        positionName: null, // 理货位
        shelvePosition: null, // 上架货位
        scanQty: 1 // 扫描数量
      },
      // 仓库
      dropDownStorage: [],
      // 理货位
      dropDownPositionName: [],
      // 物料数据
      tableData: [],
      // 当前正在扫描的数据
      currentRow: {},
      // 扫描列设置对话框参数
      setting: {
        visible: false,
        name: "outbound-scan-order-picking-shelve-empty",
        fields: [
          {
            prop: "plateCode",
            label: "母托盘号",
            visible: true,
            width: 150,
            order: 1
          },
          {
            prop: "plateType",
            label: "母托盘种类",
            visible: true,
            width: 110,
            order: 2
          }
        ]
      }
    };
  },
  mounted() {
    // 字段设置
    const setting = localStorage[this.setting.name + "-setting"];
    if (setting) {
      this.setting.fields = JSON.parse(setting);
    }
  },
  created() {
    this.getStorage();
    this.formData = {
      storage_Id: "",
      targetPositionName: "",
      originalPositionName: "",
      isCheckProductModel: true,
      productModel: "",
      scanQty: 1
    };
    // 一次扫描的数量
    this.scanCount = 1;
    // 扫描明细数据集合
    this.tableData = [];
    // 当前正在扫描的数据
    this.currentRow = {};
    // 已经找到的数据
    this.existRows = [];
    // 配置参数
    this.config = {
      // 支持一品多码
      sku_productToMultiBarcode: true
    };
    this.getStorage();
  },
  activated() {},
  methods: {
    // 获取仓库数据
    getStorage() {
      var url = "/api/common/loadDropDown";
      var params = {
        openNodeApi: true,
        where: "31"
      };
      var callBack = res => {
        this.common.showMsg(res);
        if (res.result) {
          if (res.data && res.data["dropdown" + params.where] && res.data["dropdown" + params.where].length > 0) {
            this.dropDownStorage = res.data["dropdown" + params.where];
          }
        }
      };
      this.common.ajax(url, params, callBack);
    },
    // 获取理货位
    getOffPosition(value) {
      this.dropDownStorage.forEach(item => {
        if (item.storage_Id === value) {
          this.formData.storage_Id = item.storage_Id;
          this.formData.storageName = item.storageName;
        }
      });
      var url = "/api/outbound/orderPickingshelve/getOffPosition";
      var params = {
        storage_Id: value
      };
      var callBack = res => {
        this.common.showMsg(res);
        this.dropDownPositionName = [];
        if (res.data) {
          this.dropDownPositionName = res.data;
          if (this.dropDownPositionName.length) {
            this.formData.positionName = this.dropDownPositionName[0].positionName;
          }
        } else {
          this.formData.positionName = null;
          this.$message.error("理货位不存在!");
          return;
        }
      };
      this.common.ajax(url, params, callBack);
    },
    // 判断扫描包装条码
    checkPackingBarcode(evt) {
      this.checkPackingProductModel(this.tableData, null, this.getProductInfo);
    },
    // 获取物料信息
    getProductInfo() {
      var storage_Id = this.formData.storage_Id; // 仓库
      var positionName = this.formData.positionName; // 理货位
      var productModel = this.formData.productModel; // 物料条码
      var shelvePosition = this.formData.shelvePosition; // 上架货位
      if (!positionName) {
        this.$message({
          message: "收货位不能为空!",
          type: "warning"
        });
        return;
      }
      if (!productModel) {
        this.$message({
          message: "条码不能为空!",
          type: "warning"
        });
        return;
      }
      var url = "/api/outbound/orderPickingshelve/getOffPositionData";
      var params = {
        storage_Id: storage_Id,
        positionName: positionName,
        productModel: productModel
      };
      this.common.ajax(
        url,
        params,
        res => {
          this.common.showMsg(res);
          if (res.result) {
            // 修改货位
            var dataRows = res.data;
            if (dataRows.length === 1) {
              this.createRow(dataRows[0], res, productModel, shelvePosition);
            } else {
              this.$message({
                message: "条码不存在,扫描失败!",
                type: "warning"
              });
              return;
            }
          }
        },
        this.$refs.form
      );
    },
    createRow(row, res, productModel, shelvePosition) {
      var count = 1;
      if (row.middleBarcode === productModel) {
        // 中包装条码
        count = row.middleUnitConvert;
      } else if (row.bigBarcode === productModel) {
        // 大包装条码
        count = row.unitConvert;
      }
      this.tableData = res.data.map(row => {
        row.finishedQuantity = count;
        row.shelvePosition = shelvePosition;
        return row;
      });
      this.currentRow = this.tableData[0];
      this.existRows = [this.currentRow];
    },
    // 确认上架
    btnSave() {
      var emptyPositionName = this.tableData
        .filter(item => {
          return !item.positionName;
        })
        .map(item => {
          return item.productModel;
        })
        .join(",");
 
      if (emptyPositionName) {
        this.$message.error("条形码[" + emptyPositionName + "]货位不能为空!");
        return;
      }
      var url = "/api/outbound/orderPickingshelve/shelveOffPositionSave";
      var params = {
        productDataList: this.tableData
      };
      var callBack = res => {
        this.common.showMsg(res);
        if (res.result) {
          this.continueScan();
        }
      };
      this.common.ajax(url, params, callBack, true);
    },
    // 重置
    onReset() {
      this.formData = {
        storage_Id: null,
        targetPositionName: "",
        originalPositionName: "",
        isCheckProductModel: true,
        productModel: "",
        scanQty: 0
      };
      this.tableData = [];
      // 当前正在扫描的数据
      this.currentRow = {};
      // 已经找到的数据
      this.existRows = [];
    },
    // 扫描成功后,接着扫描,保留仓库、理货位
    continueScan() {
      this.formData.shelvePosition = null;
      this.formData.scanQty = null;
      this.formData.productModel = null;
      this.tableData = [];
      // 当前正在扫描的数据
      this.currentRow = {};
      // 已经找到的数据
      this.existRows = [];
      this.$refs.shelvePosition.focus();
    },
    // 上架货位回车
    shelvePositionEnter() {
      if (this.formData.shelvePosition) {
        this.$refs.productModel.focus();
        this.$refs.productModel.select();
      }
    }
  }
};
</script>
 
<style lang="scss" scoped>
@import "../../../styles/scan.scss";
</style>