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
<template>
  <div 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">
      <template slot="common-column-slot" slot-scope="{row, col}">
        <template v-if="col.prop=='statusText'">
          <template>
            <el-tag v-if="row[col.prop]=='确认出库'" color="#00fa9a" style="color:white;border:0">
              {{ row[col.prop] }}
            </el-tag>
            <el-tag v-else-if="row[col.prop]=='终止'" color="#ff0066" style="color:white;border:0">
              {{ row[col.prop] }}
            </el-tag>
            <el-tag v-else color="#ffff99" style="color:#888;">
              {{ row[col.prop] }}
            </el-tag>
          </template>
        </template>
        <!--审核字段-->
        <template v-else-if="col.prop=='auditing'">
          <template>
            <el-tag v-if="row[col.prop]==0" color="#ffff33" style="color:black;border:0">
              {{ dataList.translateText(col.prop, row[col.prop], col.dropdown_Id) }}
            </el-tag>
            <el-tag v-else-if="row[col.prop]==1" color="#ff0033" style="color:white;border:0">
              {{ dataList.translateText(col.prop, row[col.prop], col.dropdown_Id) }}
            </el-tag>
            <el-tag v-else-if="row[col.prop]==2" color="#33cc33" style="color:black;border:0;color:#fff;">
              {{ dataList.translateText(col.prop, row[col.prop], col.dropdown_Id) }}
            </el-tag>
            <span v-else>
              {{ row[col.prop] }}
            </span>
          </template>
        </template>
        <!--分拣状态字段-->
        <template v-else-if="col.prop == 'sortingStatus'">
          <template>
            <el-tag v-if="row[col.prop] == 1" color="#ffff33" style="color:black;border:0">
              {{ dataList.translateText( col.prop, row[col.prop], col.dropdown_Id ) }}
            </el-tag>
            <el-tag v-else-if="row[col.prop] == 2" color="#00ff99" style="color:black;border:0">
              {{ dataList.translateText( col.prop, row[col.prop], col.dropdown_Id ) }}
            </el-tag>
            <el-tag v-else-if="row[col.prop] == 3" color="#ff0000" style="color:black;border:0;color:#fff;">
              {{ dataList.translateText( col.prop, row[col.prop], col.dropdown_Id ) }}
            </el-tag>
            <el-tag v-else-if="row[col.prop] == 5" color="#6699FF" style="color:black;border:0;color:#fff;">
              {{ dataList.translateText( col.prop, row[col.prop], col.dropdown_Id ) }}
            </el-tag>
            <span v-else>
              {{ row[col.prop] }}
            </span>
          </template>
        </template>
        <!--连接字段-->
        <template v-else-if="col.prop==dataOptions.linkColumn">
          <el-link type="primary" @click.native="()=>{linkEditor(row[dataOptions.idField]);}">{{ row[col.prop] }}</el-link>
        </template>
        <template v-else>
          <template v-if="['date', 'datetime'].indexOf(col.dataType)>=0 && col.formatter">
            {{ common.formatDate(row[col.prop], col.formatter) }}
          </template>
          <template v-else-if="['byte', 'int32', 'int64', 'decimal', 'double'].indexOf(col.dataType)>=0 && col.formatter">
            {{ common.formatNumber(row[col.prop], col.formatter) }}
          </template>
          <template v-else>
            {{ row[col.prop] }}
          </template>
        </template>
      </template>
    </yrt-data-list>
 
    <!--数据编辑器Editor-->
    <yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :top.sync="editorOptions.top" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" :on-save-before="onSaveBefore" :btn-read-only="btnReadOnly" @on-change="onChange" @on-add-load-after="onEditLoadAfter" @on-edit-load-after="onEditLoadAfter" @on-blur="onBlur" @on-detail-change="onDetailChange" @on-row-change="onRowChange">
      <!--自定义按钮插槽-->
      <template slot="footer-button-region" slot-scope="{ formData }">
        <el-button :disabled="btnReadOnly.sorting" type="success" icon="el-icon-yrt-shuaxin" @click.native="multiBatchSort(formData)">分拣</el-button>
        <!--自定义审核按钮-->
        <el-button :disabled="btnReadOnly.confirm" type="success" icon="el-icon-yrt-qiyong" @click.native="onConfirm(formData)">审核</el-button>
      </template>
    </yrt-editor>
 
    <!--明细选择器-->
    <yrt-selector ref="selector-position-dialog" :config="selectorPositionConfig" :visible.sync="selectorPositionConfig.visible" :url="selectorPositionConfig.url" :set-search-default="setSearchDefault" :get-custom-where="getCustomWhere" @on-selected="onPositionSelected">
      <template slot="search-form-item">
        <el-select v-model="operationType" splaceholder="账面库存量" class="w-150">
          <el-option label="库存大于0" value=">0">
          </el-option>
          <el-option label="库存大于等于0" value=">=0">
          </el-option>
          <el-option label="库存等于0" value="=0">
          </el-option>
          <el-option label="全部" value="">
          </el-option>
        </el-select>
      </template>
    </yrt-selector>
  </div>
</template>
<script>
import baseLayout from "@/components/common/base-layout.vue";
import yrtSelector from "@/components/common/yrtSelector.vue";
 
export default {
  name: "storage-borrow-enterreturn",
  components: {
    yrtSelector
    // outerImport
  },
  mixins: [baseLayout],
  data() {
    return {
      selectorConfig: {
        title: "物料选择器",
        width: "1000px",
        visible: false,
        // 配置路由
        router: "/selector/s-product-selector",
        // 编辑规则验证
        rules: {
          positionType: [{ required: true, message: "请选择货位类型", trigger: "blur" }]
        }
      },
      selectorPositionConfig: {
        title: "物料库存选择器",
        width: "1000px",
        visible: false,
        // 配置路由
        router: "/selector/x-product-selector",
        url: "/api/common/GroupDataList"
      },
      // 自动加载借入单字段
      jiazaienter: [
        "consignorName",
        "consignor_Id",
        "consignorCode",
        "storageName",
        "dept_Id",
        "deptName",
        "applyDate",
        "provider_Id",
        "providerCode",
        "providerShortName",
        "shippingName",
        "shippingAddress",
        "mobile",
        "storage_Id"
      ]
    };
  },
  // 自定义初始化数据
  init(the) {
    var userInfo = the.common.getUserInfo();
    // 设置经手人不是超级管理员,不允许编辑
    if (!userInfo.isAdministrator) {
      the.editorOptions.fields.forEach(cols => {
        cols.columns &&
          cols.columns.forEach(col => {
            col.fields.forEach(item => {
              if (item.options.prop === "UserTrueName") {
                item.options.disabled = true;
              }
            });
          });
      });
    }
  },
  methods: {
    // 明细按钮点击事件
    detailButtonClick(authNode) {
      switch (authNode) {
        case "detailAdd":
          // 明细添加
          this.openPositionSelected();
          return true;
      }
    },
    // 打开库存选择器
    openPositionSelected() {
      var editorRef = this.editor;
      if (!editorRef.formData.consignorName) {
        this.$message({
          message: "请选择货主!",
          type: "warning"
        });
        return;
      }
      const selector = this.$refs["selector-position-dialog"];
      selector.setSearchValue("consignor_Id", [editorRef.formData.consignor_Id]);
      selector.setSearchValue("storage_Id", [editorRef.formData.storage_Id]);
      if (editorRef.formData.positionType) {
        selector.setSearchValue("positionType", [editorRef.formData.positionType]);
      }
      selector.setReadOnly("storage_Id", true); // 设为只读
      selector.setReadOnly("consignor_Id", true); // 设为只读
      selector.loadData();
      this.selectorPositionConfig.visible = true;
    },
    // 将选择器选择中的数据填充到明细表中
    onPositionSelected(rows) {
      rows.forEach(item => {
        item.weight = 0;
        if (item.productStorage !== 0 && item.totalWeight) {
          item.weight = Math.Round(item.totalWeight / item.productStorage, 2);
          item.totalWeight = 0;
          item.quantity = item.usingStorage;
        }
      });
      this.editor.addDetailDataRow(rows);
      this.selectorPositionConfig.visible = false;
    },
    // 分拣
    multiBatchSort(formData) {
      this.$confirm("请点击“开始分拣”按钮进行出库单分拣,判断库存是否满足出库?", "分拣", {
        confirmButtonText: "开始分拣",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        if (!formData.borrowEnterReturn_Id) {
          this.$message({
            message: "当前数据没有保存!",
            type: "warning"
          });
          return;
        }
        const the = this;
        this.isAuditing = true;
        if (formData.statusText !== "新建") {
          this.$message({
            message: "只有新建状态才允许审核操作!",
            type: "warning"
          });
          return;
        }
        const url = "/api/storage/borrowEnterReturn/startSorting";
        const borrowEnterReturn_Id = formData.borrowEnterReturn_Id;
        const params = {
          borrowEnterReturn_Id: borrowEnterReturn_Id
        };
        var callback = res => {
          the.common.showMsg(res);
          if (res.msg) {
            this.dataList.reload();
            this.editorOptions.config.visible = false;
          }
        };
        this.common.ajax(url, params, callback, true);
      });
    },
    // 开始审核
    onConfirm(formData) {
      this.$confirm("请点击“确认审核”按钮进行审核?", "确认审核", {
        confirmButtonText: "确认审核",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        if (!formData.borrowEnterReturn_Id) {
          this.$message({
            message: "当前数据没有保存!",
            type: "warning"
          });
          return;
        }
        const the = this;
        this.isAuditing = true;
        if (formData.sortingStatus !== 2) {
          this.$message({
            message: "只有分拣成功状态允许确认审核操作!",
            type: "warning"
          });
          return;
        }
        const url = "/api/storage/borrowEnterReturn/onConfirm";
        const borrowEnterReturn_Id = formData.borrowEnterReturn_Id;
        const params = {
          borrowEnterReturn_Id: borrowEnterReturn_Id
        };
        var callback = res => {
          the.common.showMsg(res);
          if (res.msg) {
            this.dataList.reload();
            this.editorOptions.config.visible = false;
          }
        };
        this.common.ajax(url, params, callback, true);
      });
    },
    // 输入预到货单失去焦点加载主表信息
    // onBlur(ref, val, row, field) {
    //   if (field.label === "借入单号") {
    //     const borrowEnterCode = val;
    //     const url = "/api/storage/borrowEnterReturn/getByCode";
    //     const params = {
    //       borrowEnterCode: borrowEnterCode
    //     };
    //     const callback = res => {
    //       this.common.showMsg(res);
    //       if (res.result) {
    //         this.jiazaienter.forEach(fieldName => {
    //           this.$set(this.editor.formData, fieldName, res.data[fieldName]);
    //         });
    //         if (res.data.storageBorrowEnterList) {
    //           // 默认为第一个明细表名称
    //           var rows = this.editor.formData["Storage_BorrowEnterReturnList"].rows;
 
    //           res.data.storageBorrowEnterList.forEach(item => {
    //             var isExist = false;
    //             rows.forEach(temp => {
    //               if (item.borrowEnterList_Id === temp.borrowEnterList_Id) {
    //                 isExist = true;
    //               }
    //             });
    //             if (!isExist) {
    //               this.editor.addDetailDataRow([item]);
    //             }
    //           });
    //         }
    //       }
    //     };
    //     this.common.ajax(url, params, callback, true);
    //   }
    // },
 
    // 主表数据改变
    onChange(ref, val, field, formData) {
      switch (field.options.prop) {
        case "storageName":
          this.$refs["selector-position-dialog"].setSearchValue("storageName", formData.storageName);
          this.$refs["selector-position-dialog"].loadData();
          break;
        case "consignorName":
          this.$refs["selector-position-dialog"].setSearchValue("consignorName", formData.consignorName);
          this.$refs["selector-position-dialog"].loadData();
          break;
      }
      if (field.label === "借入单号") {
        const url = "/api/storage/borrowEnterReturn/getByCode";
        const ref = this.dataList;
        const params = {
          code: formData.borrowEnterCode,
          consignor_Id: formData.consignor_Id
        };
        this.common.ajax(
          url,
          params,
          res => {
            this.common.showMsg(res);
            if (res) {
              this.jiazaienter.forEach(rows => {
                this.$set(this.editor.formData, rows, res.rows);
              });
              this.$set(formData, "consignor_Id", res.data.consignor_Id);
              this.$set(formData, "consignorCode", res.data.consignorCode);
              this.$set(formData, "consignorName", res.data.consignorName);
              this.$set(formData, "storage_Id", res.data.storage_Id);
              this.$set(formData, "storageName", res.data.storageName);
              this.$set(formData, "applyDate", res.data.applyDate);
              if (res.data.storageBorrowEnterList) {
                // 默认为第一个明细表名称
                var subTableView = this.editor.detailFields[0].subTableView;
                var rows = this.editor.formData[subTableView].rows;
                if (rows.length) {
                  rows = this.editor.formData[subTableView].rows = [];
                }
                for (var i = 0; i < res.data.storageBorrowEnterList.length; i++) {
                  var item = res.data.storageBorrowEnterList[i];
                  if (rows.length) {
                    rows.forEach(temp => {
                      if (item.borrowEnterList_Id !== temp.borrowEnterList_Id) {
                        this.editor.addDetailDataRow(item);
                      }
                    });
                  } else {
                    this.editor.addDetailDataRow(res.data.storageBorrowEnterList);
                    break;
                  }
                }
              }
            }
          },
          ref
        );
      }
    },
    // 对选择器默认值操作
    setSearchDefault(searchData) {},
 
    // 表格下拉框字段改变事件
    onRowChange(ref, val, field) {
      // 货主和仓库改变
      if (["consignorName", "storageName"].indexOf(field.options.prop) >= 0) {
        window.setTimeout(() => {
          this.getDefaultItems();
        }, 200);
      }
    }
  }
};
</script>