1
huangxiaoqiang
7 天以前 4dfe8ece141f05a163cf7d290b6fe4c520d89909
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
/*****************************************************************************************
 **  Author:jxx 2022
 **  QQ:283591387
 **完整文档见:http://v2.volcore.xyz/document/api 【代码生成页面ViewGrid】
 **常用示例见:http://v2.volcore.xyz/document/vueDev
 **后台操作见:http://v2.volcore.xyz/document/netCoreDev
 *****************************************************************************************/
//此js文件是用来自定义扩展业务代码,可以扩展一些自定义页面或者重新配置生成的代码
 
// import gridHeader from "./demo_Product/Dt_BillGroupStockDetail.vue";
// import gridHeader from './extend/printView.vue'
// import gridBody from './extend/OtherOutBound.vue'
let extension = {
  components: {
    //查询界面扩展组件
    gridHeader: '',
    gridBody: '',
    gridFooter: '',
    //新建、编辑弹出框扩展组件
    modelHeader: '',
    modelBody: '',
    modelFooter: ''
  },
  tableAction: '', //指定某张表的权限(这里填写表名,默认不用填写)
  buttons: { view: [], box: [], detail: [] }, //扩展的按钮
  methods: {
    //下面这些方法可以保留也可以删除
    onInit() {
      this.detailOptions.buttons.unshift({
        name: '其他出库', //按钮名称
        icon: 'el-icon-document', //按钮图标vue2版本见iview文档icon,vue3版本见element ui文档icon(注意不是element puls文档)
        type: 'primary',
        onClick: function () {
          this.$confirm('是否其他出库', "警告你正在使用其他出库", {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            center: true
          }).then(() => {
            this.http.post(`/api/Task/OtherOutBoundTaskAsync`, row, "正在完成任务").then((res) => {
              //示例:调用后台接口
              if (res.status) {
                this.$Message.success('任务完成')
              } else {
                this.$Message.error(res.message) //错误提示
              }
            })
          })
        }
      });
      this.boxButtons.push({
        name: '其他出库', //按钮名称
        icon: 'el-icon-document', //按钮图标:组件示例->图标
        //primary、success、warning、error、info、text、danger
        type: 'primary',
        plain: true,
        onClick: function () {
          this.$confirm('是否其他出库', "警告你正在使用其他出库", {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            center: true
          }).then(() => {
            this.http.post(`/api/Task/OtherOutBoundTaskAsync`, this.$refs.detail.rowData, "正在完成任务").then((res) => {
              if (res.status) {
                this.$Message.success(res.message)
              } else {
                this.$Message.error(res.message) //错误提示
              }
            })
          })
        }
      })
      this.boxButtons.push({
        name: '调拨出库', //按钮名称
        icon: 'el-icon-document', //按钮图标:组件示例->图标
        //primary、success、warning、error、info、text、danger
        type: 'danger',
        plain: true,
        onClick: function () {
          this.$confirm('是否调拨出库', "警告你正在使用调拨出库", {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            center: true
          }).then(() => {
            this.http.post(`/api/Task/OtherOutBoundTaskAsync`, this.$refs.detail.rowData, "正在完成任务").then((res) => {
              if (res.status) {
                this.$Message.success(res.message)
              } else {
                this.$Message.error(res.message) //错误提示
              }
            })
          })
        }
      })
      // this.detailOptions.buttons.unshift({
      //   name: '调拨出库',
      //   icon: '',
      //   type: 'primary',
      //   onClick: function (e) {
      //     let row = this.$refs.table.getSelected() //获取选中的行
      //     if (row <= 0) {
      //       //如果没有选中行
      //       this.$Message.error('请选择一行数据')
      //       return
      //     }
      //     let taskNum = row[0].taskNum
      //     this.http.post(`/api/Task/CompleteTaskAsync?taskNum=${taskNum}`, {}, "正在完成任务").then((res) => {
      //       //示例:调用后台接口
      //       if (res.status) {
      //         this.$Message.success(res.message)
      //       } else {
      //         this.$Message.error(res.message) //错误提示
      //       }
      //     })
      //   }
      // });
      this.columns.push({
        field: '操作',
        title: '操作',
        width: 90,
        fixed: 'right',
        align: 'center',
        formatter: (row) => {
          return (
            '<i style="cursor: pointer;color: #2d8cf0;"class="el-icon-view">盘点出库</i>'
          );
        },
        click: (row) => {
          this.http.post(`/api/Task/OutBoundTaskAsync?palletCode=${row.palletCode}`, {}, "正在生成任务").then((res) => {
            //示例:调用后台接口
            if (res.status) {
              this.$Message.success(row.palletCode + "出库成功");
              this.refresh();
            } else {
              this.$Message.error(res.message) //错误提示
              this.refresh();
            }
          })
        }
      });
      // this.columns.push({
      //   title: "操作",
      //   field: "操作",
      //   width: 150,
      //   align: "left", // 'center',
      //   render: (h, { row, column, index }) => {
      //     return (
      //       <div>
      //         <el-button
      //           onClick={($e) => {
      //             // this.$refs.table.load();
      //             // console.log(this.$refs.table);
      //             this.$refs.gridHeader.open(row);
      //           }}
      //           type="primary"
      //           plain
      //           style="height:26px; padding: 10px !important;"
      //         >
      //           打印
      //         </el-button> 
      //       </div>
      //     );
      //   },
      // });
 
      //示例:设置修改新建、编辑弹出框字段标签的长度
      this.boxOptions.labelWidth = 150
 
 
      this.columns.forEach((column) => {
 
        if (column.field == 'floor') {
 
          const floorMap = {
            '1F': '一楼',
            '2F': '二楼',
          };
          column.formatter = (row) => {
            return floorMap[row?.locationInfo?.floor] || ''
          }
        }
        if (column.field == 'areaId') {
 
          const floorMap = {
            '1': '一楼堆垛机区域',
            '2': '一楼AGV出库缓存区',
            '3': '一楼AGV立库缓存区',
            '4': '一楼AGV入库缓存区',
            '5': '二楼B4-G4缓存区',
            '6': '二楼B5-G5缓存区',
          };
          column.formatter = (row) => {
            return floorMap[row?.locationInfo?.areaId] || ''
          }
        }
        if (column.field == 'locationStatus') {
          const statusMap = {
            '0': '空闲',
            '1': '锁定',
            '2': '有货',
            '3': '有货禁用',
            '4': '无货禁用'
          };
          column.formatter = (row) => {
            return statusMap[row?.locationInfo?.locationStatus] || '';
          }
        }
 
      })
    },
    onInited() {
      //框架初始化配置后
      //如果要配置明细表,在此方法操作
      this.detailOptions.columns.forEach(column => {
 
      });
    },
    searchBefore(param) {
      //界面查询前,可以给param.wheres添加查询参数
      //返回false,则不会执行查询
      return true
    },
    searchAfter(result) {
      return true
    },
    addBefore(formData) {
      //新建保存前formData为对象,包括明细表,可以给给表单设置值,自己输出看formData的值
      return true
    },
    updateBefore(formData) {
      //编辑保存前formData为对象,包括明细表、删除行的Id
      return true
    },
    rowClick({ row, column, event }) {
      //查询界面点击行事件
      //this.$refs.table.$refs.table.toggleRowSelection(row) //单击行时选中当前行;
    },
    modelOpenAfter(row) {
      const isAdd = this.currentAction == 'Add';//判断是否为新建操作
      //隐藏明细表按钮
      this.detailOptions.buttons.forEach((btn) => {
        if (btn.name == '添加行') {
          btn.hidden = true;
          //或者设置只读
          //btn.readonly=true;
        }
      });
      const isDel = this.currentAction == 'Add';//判断是否为新建操作
      //隐藏明细表按钮
      this.detailOptions.buttons.forEach((btn) => {
        if (btn.name == '删除行') {
          btn.hidden = true;
          //或者设置只读
          //btn.readonly=true;
        }
      });
      this.detailOptions.buttons.forEach((btn) => {
        if (btn.name == '导入') {
          btn.hidden = true;
          //或者设置只读
          //btn.readonly=true;
        }
      });
      this.detailOptions.buttons.forEach((btn) => {
        if (btn.name == '导出') {
          btn.hidden = true;
          //或者设置只读
          //btn.readonly=true;
        }
      });
      //点击编辑、新建按钮弹出框后,可以在此处写逻辑,如,从后台获取数据
      //(1)判断是编辑还是新建操作: this.currentAction=='Add';
      //(2)给弹出框设置默认值
      //(3)this.editFormFields.字段='xxx';
      //如果需要给下拉框设置默认值,请遍历this.editFormOptions找到字段配置对应data属性的key值
      //看不懂就把输出看:console.log(this.editFormOptions)
    }
  }
}
export default extension