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
<template>
  <div ref="container" class="page-list-container">
    <!--数据Table-->
    <yrt-data-list :ref="dataListRef" :editor-ref="editorRef" :data-options="dataOptions" :fields.sync="dataListOptions.fields" :buttons="dataListOptions.buttons" :button-click="buttonClick" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes">
    </yrt-data-list>
 
    <!--数据编辑器Editor-->
    <yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :btn-read-only="btnReadOnly" :auth-nodes="authNodes" :use-detail-slot="['lackStorage']" @on-edit-load-after="onEditLoadAfter" @on-detail-change="onDetailChange" @on-add-load-after="onEditLoadAfter">
      <!--自定义按钮插槽-->
      <template slot="footer-button-region" slot-scope="{ formData, details }">
        <!--审核按钮-->
        <el-button :disabled="btnReadOnly.auditingBtn" type="success" icon="el-icon-yrt-pan" @click.native="auditingReplenishment(formData, details)">审核</el-button>
        <!--分拣按钮-->
        <el-button :disabled="btnReadOnly.sortingBtn" type="success" icon="el-icon-yrt-pan" @click.native="sortingReplenishment(formData, details)">分拣</el-button>
      </template>
      <!--自定义字段插槽-->
      <template slot="detail-column-slot" slot-scope="{ row, col }">
        <template v-if="col.prop == 'lackStorage'">
          <div v-if="row[col.prop]||row[col.prop]==0">{{ row[col.prop] }}</div>
          <div v-else>
            <el-button size="mini" round @click="setSortingRule(row)">设置规则</el-button>
          </div>
        </template>
      </template>
    </yrt-editor>
 
    <!--明细选择器-->
    <yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" @on-selected="onSelected"></yrt-selector>
 
    <el-dialog :visible.sync="winSortingRuleVisible" title="设置订单明细分拣规则">
      <div class="dialog-info">
        <div class="dialog-left">
          <el-form :model="sortingRuleForm" label-width="150px">
            <el-form-item label="物料编号">
              <el-input v-model="sortingRuleForm.productCode" :readonly="true" type="text" placeholder="请输入物料编号"></el-input>
            </el-form-item>
            <el-form-item label="拣货货位">
              <el-input v-model="sortingRuleForm.positionName" type="text" placeholder="请输入出库货位名称"></el-input>
            </el-form-item>
            <el-form-item label="批次号">
              <el-input v-model="sortingRuleForm.batchNumber" type="text" placeholder="请输入批次号"></el-input>
            </el-form-item>
            <el-form-item label="生产日期">
              <el-date-picker v-model="sortingRuleForm.produceDate" type="date" placeholder="选择日期" style="width: 100%;"></el-date-picker>
            </el-form-item>
            <el-form-item label="拍号">
              <el-input v-model="sortingRuleForm.plateCode" type="text" placeholder="请输入拍号"></el-input>
            </el-form-item>
            <el-form-item label="唯一码">
              <el-input v-model="sortingRuleForm.singleSignCode" type="text" placeholder="请输入唯一码"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="submitSortingRuleData()">添加</el-button>
              <!-- <detail-roleflow :load-options="productPositionDetail" :where="'productCode=' + sortingRuleForm.helpProductCode">
                <template slot="content">
                  <el-button type="primary">查看库存</el-button>
                </template>
              </detail-roleflow> -->
            </el-form-item>
          </el-form>
        </div>
        <div class="dialog-right">
          <div v-if="sortingRuleList.length==0" class="tip">
            <p>[暂无规则]</p>
          </div>
          <div v-for="item in sortingRuleList" :key="item.rule_Id" class="tip">
            <p>物料编号:{{ item.productCode }}
              <span class="deleteRule-span" style="float:right" @click="deleteRule(item.rule_Id)">[关闭]
              </span>
            </p>
            <p v-if="item.positionName">拣货货位:{{ item.positionName }}</p>
            <p v-if="item.batchNumber">批次号:{{ item.batchNumber }}</p>
            <p v-if="item.produceDate">生产日期:{{ item.produceDate }}</p>
            <p v-if="item.plateCode">拍号:{{ item.plateCode }}</p>
            <p v-if="item.positionName">唯一码:{{ item.singleSignCode }}</p>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="winSortingRuleVisible = false">关闭</el-button>
 
      </div>
    </el-dialog>
 
  </div>
</template>
 
<script>
import baseLayout from "@/components/common/base-layout.vue";
import yrtSelector from "@/components/common/yrtSelector.vue";
var moment = require("moment");
 
export default {
  name: "storage-replenishment",
  components: { yrtSelector },
  mixins: [baseLayout],
  data() {
    return {
      // 选择器配置参数
      selectorConfig: {
        title: "物料选择器",
        width: "1000px",
        visible: false,
        // 配置路由
        router: "/selector/s-product-selector"
      },
      sortingRuleForm: {
        productCode: "",
        positionName: "",
        batchNumber: "",
        produceDate: "",
        plateCode: "",
        singleSignCode: ""
      },
      winSortingRuleVisible: false,
      sortingRuleList: [],
      selectRuleRow: null
    };
  },
  methods: {
    // 明细按钮点击事件
    detailButtonClick(authNode) {
      switch (authNode) {
        case "add":
          // 明细添加
          this.detailAdd();
          break;
      }
    },
    // 列表页面按钮点击事件
    buttonClick(authNode) {
      switch (authNode) {
        case "auditingSorting":
          // 审核分拣
          this.auditingSorting();
          break;
      }
    },
    // 明细添加
    detailAdd() {
      this.selectorConfig.visible = true;
      this.$refs["selector-dialog"].loadData();
    }, // 将选择器选择中的数据填充到明细表中
    onSelected(rows) {
      rows = rows.map(v => {
        v.outQuantity = 0;
        v.sortingStatus = 1;
        return v;
      });
      this.editor.addDetailDataRow(rows);
      this.selectorConfig.visible = false;
    },
    // 数据加载后
    onEditLoadAfter(formData) {
      var auditing = formData.auditing;
      var billStatus = formData.billStatus;
      var sortingStatus = formData.sortingStatus;
      if (auditing === 2) {
        // 审核成功
        this.$set(this.btnReadOnly, "auditingBtn", true);
        this.$set(this.btnReadOnly, "sortingBtn", false);
        this.btnReadOnly.stop = false; // 可编辑
        this.btnReadOnly.open = true; // 不可编辑
      }
      // else {
      //   this.$set(this.btnReadOnly, "auditingBtn", false);
      //   this.$set(this.btnReadOnly, "sortingBtn", true);
      //   this.btnReadOnly.stop = true; // 不可编辑
      // }
      if (billStatus === "完全补货") {
        this.$set(this.btnReadOnly, "auditingBtn", true);
        this.$set(this.btnReadOnly, "sortingBtn", true);
        this.btnReadOnly.open = true;
        this.btnReadOnly.stop = true;
      }
      if (sortingStatus === 2) {
        this.$set(this.btnReadOnly, "auditingBtn", true);
        this.$set(this.btnReadOnly, "sortingBtn", true);
        this.btnReadOnly.open = true;
        this.btnReadOnly.stop = true;
        // this.btnReadOnly.auditingBtn = true;
        // this.btnReadOnly.sortingBtn = true;
      }
      if (billStatus === "终止") {
        this.$set(this.btnReadOnly, "auditingBtn", true);
        this.$set(this.btnReadOnly, "sortingBtn", true);
        this.btnReadOnly.open = false;
        this.btnReadOnly.stop = true;
      }
      if (billStatus === "新建") {
        this.$set(this.btnReadOnly, "auditingBtn", false);
        this.$set(this.btnReadOnly, "sortingBtn", true);
        this.btnReadOnly.open = true;
        this.btnReadOnly.stop = false;
      }
    },
    // 审核
    auditingReplenishment(formData, details) {
      var auditing = formData.auditing;
      var replenishment_Id = formData.replenishment_Id;
      if (auditing === 2) {
        this.$message.error("已经通过审核!");
        return;
      }
      const url = "/api/storage/replenishment/confirm";
      const params = {
        replenishment_Id: replenishment_Id,
        auditing: 2,
        remark: ""
      };
      const ref = this.dataList;
      var callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          ref.loadData();
          this.editorOptions.config.visible = false;
        }
      };
      this.common.ajax(url, params, callback, ref);
    },
    // 分拣
    sortingReplenishment(formData, details) {
      var auditing = formData.auditing;
      var replenishment_Id = formData.replenishment_Id;
      var billStatus = formData.billStatus;
      if (billStatus === "完全补货") {
        this.$message.error("完全补货不能进行分拣!");
        return;
      }
      if (auditing !== 2) {
        this.$message.error("当前数据没有通过审核!");
        return;
      }
      const url = "/api/storage/replenishment/startSorting";
      const params = {
        replenishment_Id: replenishment_Id
      };
      const ref = this.dataList;
      var callback = res => {
        this.common.showMsg(res);
        ref.loadData();
        this.editor.reload();
      };
      this.common.ajax(url, params, callback, ref);
    },
    // 明细字段改变
    onDetailChange(ref, val, row, field) {
      // 合计数量求和
      let transferQuantity = 0;
      let subTotalMoney = 0.0;
      var formData = this.editor.formData;
      var detailRows = formData["Storage_ReplenishmentList"].rows;
      detailRows.forEach(item => {
        if (item.transferQuantity && item.purchasePrice) {
          item.subTotalMoney = parseFloat((item.transferQuantity * item.purchasePrice).toFixed(4));
        }
        if (item.transferQuantity) {
          transferQuantity += item.transferQuantity;
        }
        if (item.subTotalMoney) {
          subTotalMoney += item.subTotalMoney;
        }
      });
      this.editor.changeValue("totalQuantity", parseFloat(transferQuantity.toFixed(4)));
      this.editor.changeValue("totalMoney", parseFloat(subTotalMoney).toFixed(4));
    },
    // 设置分拣规则
    setSortingRule(row) {
      this.winSortingRuleVisible = true;
      this.selectRuleRow = row;
      this.sortingRuleForm.productCode = this.selectRuleRow["productCode"];
      this.sortingRuleForm.helpProductCode = "'" + this.selectRuleRow["productCode"] + "'";
      this.getSortingRuleList();
    },
    // 获取分拣列表
    getSortingRuleList() {
      const url = "/api/storage/replenishment/replenishmentGetSortingRule";
      var replenishmentList_Id = this.selectRuleRow["replenishmentList_Id"];
      const params = { replenishmentList_Id: replenishmentList_Id };
      var callback = res => {
        if (res.result) {
          var dataList = [];
          res.data.forEach(element => {
            element.produceDate = element.produceDate ? moment(element.produceDate).format("YYYY-MM-DD") : null;
            dataList.push(element);
          });
          this.sortingRuleList = dataList;
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 提交分拣规则
    submitSortingRuleData() {
      var consignor_Id = this.editor.formData["consignor_Id"];
      var consignorCode = this.editor.formData["consignorCode"];
      var consignorName = this.editor.formData["consignorName"];
      var storage_Id = this.editor.formData["storage_Id"];
      var storageName = this.editor.formData["storageName"];
 
      var replenishment_Id = this.editor.formData["replenishment_Id"];
      var replenishmentCode = this.editor.formData["replenishmentCode"];
      var positionName = this.sortingRuleForm.positionName;
      var batchNumber = this.sortingRuleForm.batchNumber;
      var produceDate = this.sortingRuleForm.produceDate;
      var plateCode = this.sortingRuleForm.plateCode;
      var singleSignCode = this.sortingRuleForm.singleSignCode;
      var product_Id = this.selectRuleRow["product_Id"];
      var productCode = this.selectRuleRow["productCode"];
      var ProductName = this.selectRuleRow["ProductName"];
      var replenishmentList_Id = this.selectRuleRow["replenishmentList_Id"];
 
      const url = "/api/storage/replenishment/sortingRule";
      const params = {
        consignor_Id: consignor_Id,
        consignorCode: consignorCode,
        consignorName: consignorName,
        storage_Id: storage_Id,
        storageName: storageName,
 
        replenishmentList_Id: replenishmentList_Id,
        replenishment_Id: replenishment_Id,
        replenishmentCode: replenishmentCode,
 
        positionName: positionName,
        batchNumber: batchNumber,
        produceDate: produceDate,
        plateCode: plateCode,
        singleSignCode: singleSignCode,
 
        product_Id: product_Id,
        productCode: productCode,
        ProductName: ProductName
      };
      this.common.ajax(url, params, res => {
        this.common.showMsg(res);
        if (res.result) {
          this.getSortingRuleList();
          this.sortingRuleForm.positionName = "";
          this.sortingRuleForm.batchNumber = "";
          this.sortingRuleForm.produceDate = "";
          this.sortingRuleForm.plateCode = "";
          this.sortingRuleForm.singleSignCode = "";
        }
      });
    },
    // 关闭分拣规则
    deleteRule(rule_Id) {
      this.$confirm("确实要关闭当前规则吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          const url = "/api/storage/replenishment/deleteSortingRule";
          const params = { rule_Id: rule_Id };
          var callback = res => {
            this.common.showMsg(res);
            if (res.result) {
              this.getSortingRuleList();
            }
          };
          this.common.ajax(url, params, callback, true);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    // 审核分拣
    auditingSorting() {
      const the = this;
      this.$confirm("确定要批量进行审核分拣操作吗?", "批量审核分拣", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          // 获得已选中的ID
          var isStatusText = true;
          const selectIDs = the.dataListSelections
            .map((item, index, array) => {
              if (item.billStatus !== "新建") {
                isStatusText = false;
              }
              return item.replenishment_Id;
            })
            .join(",");
          if (selectIDs === "") {
            this.$message({
              message: "至少选中一行!",
              type: "warning"
            });
            return;
          }
          if (isStatusText !== true) {
            this.$message({
              message: "选中项含有不是新建状态的订单!",
              type: "warning"
            });
            return;
          }
          const url = "/api/storage/replenishment/confirmSorting";
          const params = {
            selectIDs: selectIDs
          };
          const ref = the.dataList;
          var callback = res => {
            the.common.showMsg(res);
            if (res.result) {
              ref.loadData();
            }
          };
          the.common.ajax(url, params, callback, ref);
        })
        .catch(() => {
          the.$message({
            type: "info",
            message: "已取消"
          });
        });
    }
  }
};
</script>
 
<style rel="stylesheet/scss" scoped>
.tip {
  padding: 8px 16px;
  background-color: #ecf8ff;
  border-radius: 4px;
  border-left: 5px solid #50bfff;
  margin: 5px 0;
}
.dialog-info {
  overflow: hidden;
  width: 100%;
}
.dialog-left {
  float: left;
  width: 45%;
}
.dialog-right {
  margin-left: 30px;
  float: left;
  width: 45%;
}
.deleteRule-span {
  cursor: pointer;
}
.page-list-container {
  min-height: calc(100vh - 110px);
  overflow: hidden;
  position: relative;
}
 
@media screen and (max-height: 900px) {
  .page-list-container {
    min-height: 600px;
  }
}
</style>