schangxiang@126.com
2025-09-19 9be9c3784b2881a3fa25e93ae2033dc2803c0ed0
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
 
<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">
      <template slot="common-column-slot" slot-scope="{row, col}">
        <template v-if="col.prop=='onShelveStatus'">
          <template>
            <el-tag v-if="row[col.prop]=='上架中'" color="#ffcc66" style="color:black;border:0">
              {{ row[col.prop] }}
            </el-tag>
            <el-tag v-else-if="row[col.prop]=='部分上架'" color="#ff6633" style="color:black;border:0">
              {{ row[col.prop] }}
            </el-tag>
            <el-tag v-else-if="row[col.prop]=='上架完成'" color="#33ccff" style="color:black;border:0">
              {{ row[col.prop] }}
            </el-tag>
            <el-tag v-else-if="row[col.prop]=='待上架'" color="#ffff33" style="color:black;border:0">
              {{ row[col.prop] }}
            </el-tag>
            <el-tag v-else color="#1626b6" style="color:#888;">
              {{ row[col.prop] }}
            </el-tag>
          </template>
          <!--   </template>
         </state-flow> -->
        </template>
        <template v-else-if="col.prop=='providerCode'">
          <template>
            <div v-if="row[col.prop]=='1'">
              {{ "小托盘" }}
            </div>
            <div v-else-if="row[col.prop]=='2'">
              {{ "大托盘" }}
            </div>
          </template>
          <!--   </template>
         </state-flow> -->
        </template>
        <!--分拣状态字段-->
        <template v-else-if="col.prop == 'sortingStatus'">
          <template>
            <el-tag v-if="row[col.prop] == 1" color="#ffff33" style="color:black;border:0">
              {{ $refs[dataListRef].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">
              {{ $refs[dataListRef].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;">
              {{ $refs[dataListRef].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;">
              {{ $refs[dataListRef].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=='auditing'">
          <template>
            <el-tag v-if="row[col.prop]==1" color="#ffcc66" style="color:black;border:0">
              审核失败
            </el-tag>
            <el-tag v-else-if="row[col.prop]==2" color="#33ccff" style="color:black;border:0">
              通过审核
            </el-tag>
            <el-tag v-else-if="row[col.prop]==0" color="#ffff33" style="color:black;border:0">
              待审核
            </el-tag>
          </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">
    </yrt-editor>
 
    <!--明细选择器-->
    <yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" @onSelected="onSelected"></yrt-selector>
  </div>
</template>
 
<script>
import baseLayout from "@/components/common/base-layout.vue";
import yrtSelector from "@/components/common/yrtSelector.vue";
export default {
  name: "inbound-purchase-shelve",
  components: {
    yrtSelector
  },
  mixins: [baseLayout],
  // 自定义处理权限函数
  doAuth(the) {
    // 判断当前版本是否拥有导入权限
    var authList = [{ name: "上架撤销", auth: "cancelShelve" }, { name: "强制完成上架", auth: "forceShelve" }, { name: "打印上架单", auth: "print" }];
    const names = authList.map(item => {
      return item.name;
    });
    the.common.isSaaSAuth(names, res => {
      authList.forEach(node => {
        let hasAuth = res.result;
        if (hasAuth) {
          hasAuth = res.data.some(item => {
            return item.moduleName === node.name;
          });
        }
        the.authNodes[node.auth] = hasAuth;
      });
    });
  },
  data() {
    return {
      selectorConfig: {
        title: "物料选择器",
        width: "1000px",
        visible: false,
        router: "/selector/s-product-selector"
      }
    };
  },
  methods: {
    // 列表页面按钮点击事件
    buttonClick(authNode) {
      switch (authNode) {
        case "auditing":
          // 批量审核
          this.singleAuditing();
          break;
        case "cancelShelve":
          // 撤销上架
          this.cancelShelve();
          break;
        case "forceShelve":
          // 强制完成上架
          this.forceShelve();
          break;
        case "shelveOrder":
          // 强制完成上架
          this.shelveOrder();
          break;
        case "delete":
          // 删除
          this.delete();
          return false;
      }
    },
    // 明细按钮点击事件
    detailButtonClick(authNode) {
      switch (authNode) {
        case "add":
          // 明细添加
          this.selectorConfig.visible = true;
          break;
      }
    },
    // 将选择器选择中的数据填充到明细表中
    onSelected(rows) {
      this.editor.addDetailDataRow(rows);
      this.selectorConfig.visible = false;
    },
    shelveOrder() {
      // 得到,明细选中项
      var detailSelections = this.dataListSelections;
      if (!detailSelections.length) {
        this.$message.error("至少选择一项!");
        return;
      }
      if (detailSelections.length !== 1) {
        this.$message.error("请选择一条记录进行操作");
        return;
      }
      var rows = JSON.parse(JSON.stringify(detailSelections));
 
      if (rows[0].onShelveStatus !== "尺寸异常") {
        this.$message({
          message: "只有状态为尺寸异常才可操作!",
          type: "warning"
        });
        return false;
      }
 
      this.$confirm("确定要进行入库操作吗?", "入库指令", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          // 获得已选中的ID
          // const shelve_Ids = this.dataListSelections.map((item, index, Array) => {
          //   return item.shelve_Id;
          // });
          // if (!shelve_Ids) {
          //   this.$message({
          //     message: "至少选中一行!",
          //     type: "warning"
          //   });
          //   return;
          // }
          var detailSelections = this.dataListSelections;
          if (!detailSelections.length) {
            this.$message.error("至少选择一项!");
            return;
          }
          if (detailSelections.length !== 1) {
            this.$message.error("请选择一条记录进行操作");
            return;
          }
          var rows = JSON.parse(JSON.stringify(detailSelections));
          const url = "/api/inbound/shelve/shelveOrder";
          const params = {
            shelve_Id: rows[0].shelve_Id
          };
          const ref = this.dataList;
          var callback = res => {
            this.common.showMsg(res);
            if (res.result) {
              ref.loadData();
            }
          };
          this.common.ajax(url, params, callback, ref);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    // 审核
    singleAuditing() {
      const menu_Id = this.dataOptions.menu_Id;
      this.$confirm("确定要批量进行审核操作吗?", "批量审核", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          // 获得已选中的ID
          const shelve_Ids = this.dataListSelections.map((item, index, Array) => {
            return item.shelve_Id;
          });
          if (!shelve_Ids) {
            this.$message({
              message: "至少选中一行!",
              type: "warning"
            });
            return;
          }
          const url = "/api/inbound/shelve/singleConfirm";
          const params = {
            openNodeApi: true,
            idValues: shelve_Ids,
            menu_Id: menu_Id
          };
          const ref = this.dataList;
          var callback = res => {
            this.common.showMsg(res);
            if (res.result) {
              ref.loadData();
            }
          };
          this.common.ajax(url, params, callback, ref);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    // 撤销上架
    cancelShelve() {
      const shelve_Ids = this.dataListSelections.map((item, index, Array) => {
        return item.shelve_Id;
      });
      const onShelveStatus = this.dataListSelections.map((item, index, Array) => {
        return item.onShelveStatus;
      });
      if (!shelve_Ids.length) {
        this.$message.error("请至少选择一行上架数据!");
        return false;
      }
      if (onShelveStatus === "待上架") {
        this.$message.error("只有上架的单据才可以执行取消操作!!");
        return false;
      }
      this.$confirm("确定将选中的数据撤销上架吗?", "撤销上架", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          const url = "/api/inbound/shelve/cancelShelve";
          const params = {
            shelve_Ids: shelve_Ids
          };
          const ref = this.dataList;
          var callback = res => {
            this.common.showMsg(res);
            if (res.result) {
              ref.loadData();
            }
          };
          this.common.ajax(url, params, callback, ref);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    // 强制完成上架
    forceShelve() {
      const shelve_Ids = this.dataListSelections.map((item, index, Array) => {
        return item.shelve_Id;
      });
      if (!shelve_Ids.length) {
        this.$message.error("请至少选择一行未上架数据!");
        return false;
      }
      this.$confirm("确定将选中的数据强制完成上架吗?", "强制完成上架", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          const url = "/api/inbound/shelve/forceShelve";
          const params = {
            shelve_Ids: shelve_Ids
          };
          const ref = this.dataList;
          const callback = res => {
            this.common.showMsg(res);
            if (res.result) {
              ref.loadData();
            }
          };
          this.common.ajax(url, params, callback, ref);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    // 删除
    delete() {
      if (!this.dataListSelections.length) {
        this.$message.error("至少选中一行!");
        return;
      }
      const shelve_Id = this.dataListSelections.map((item, index, Array) => {
        return item.shelve_Id;
      });
      const shelveCode = this.dataListSelections.map((item, index, Array) => {
        return item.shelveCode;
      });
 
      this.$confirm("确定要进行删除操作吗?", "删除", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          const url = "/api/inbound/shelve/deleteShelveCode";
          const params = {
            ids: shelve_Id,
            shelveCode: shelveCode
          };
          const ref = this.dataList;
          var callback = res => {
            this.common.showMsg(res);
            if (res.result) {
              ref.loadData();
            }
          };
          this.common.ajax(url, params, callback, ref);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    }
  }
};
</script>