刘磊
2025-01-08 1d044540ee1b7041c7e89bdfe6d1339c99e80a4e
Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/stock/Dt_BillGroupStock.jsx
@@ -26,14 +26,10 @@
    //下面这些方法可以保留也可以删除
    onInit() {
      //框架初始化配置前,
      //示例:在按钮的最前面添加一个按钮
      this.buttons.unshift({
        //也可以用push或者splice方法来修改buttons数组
        name: '直接出库', //按钮名称
        icon: 'el-icon-document', //按钮图标vue2版本见iview文档icon,vue3版本见element ui文档icon(注意不是element puls文档)
        type: 'primary', //按钮样式vue2版本见iview文档button,vue3版本见element ui文档button
        onClick: function () {
          this.$Message.success('点击了按钮')
      let OutBoundBtn = this.buttons.find((x) => x.value == 'OutBound')
      if (OutBoundBtn) {
        OutBoundBtn.onClick = function () {
          // this.$Message.success('点击了按钮')
          let row = this.$refs.table.getSelected() //获取选中的行
          if (row <= 0) {
            //如果没有选中行
@@ -42,16 +38,49 @@
          }
          let locationCode = row[0].locationCode
          let palletCode = row[0].palletCode
          this.http.get(`/api/Task/CreateAndSendOutboundTask?locationCode=${locationCode}&palletCode=${palletCode}`, {}, "正在创建任务").then((res) => {
            //示例:调用后台接口
            if (res.status) {
              this.$Message.success('创建任务成功')
            } else {
              this.$Message.error(res.message) //错误提示
            }
          })
          this.http
            .get(
              `/api/Task/CreateAndSendOutboundTask?locationCode=${locationCode}&palletCode=${palletCode}`,
              {},
              '正在创建任务'
            )
            .then((res) => {
              //示例:调用后台接口
              if (res.status) {
                this.$Message.success('创建任务成功')
                this.refresh() //刷新表格
              } else {
                this.$Message.error(res.message) //错误提示
              }
            })
        }
      })
      }
      //示例:在按钮的最前面添加一个按钮
      // this.buttons.unshift({
      //   //也可以用push或者splice方法来修改buttons数组
      //   name: '直接出库', //按钮名称
      //   icon: 'el-icon-document', //按钮图标vue2版本见iview文档icon,vue3版本见element ui文档icon(注意不是element puls文档)
      //   type: 'primary', //按钮样式vue2版本见iview文档button,vue3版本见element ui文档button
      //   onClick: function () {
      //     this.$Message.success('点击了按钮')
      //     let row = this.$refs.table.getSelected() //获取选中的行
      //     if (row <= 0) {
      //       //如果没有选中行
      //       this.$Message.error('请选择一行数据')
      //       return
      //     }
      //     let locationCode = row[0].locationCode
      //     let palletCode = row[0].palletCode
      //     this.http.get(`/api/Task/CreateAndSendOutboundTask?locationCode=${locationCode}&palletCode=${palletCode}`, {}, "正在创建任务").then((res) => {
      //       //示例:调用后台接口
      //       if (res.status) {
      //         this.$Message.success('创建任务成功')
      //       } else {
      //         this.$Message.error(res.message) //错误提示
      //       }
      //     })
      //   }
      // })
      //示例:设置修改新建、编辑弹出框字段标签的长度
      this.boxOptions.labelWidth = 150
@@ -78,6 +107,34 @@
      //     );
      //   },
      // });
      this.columns.forEach((column) => {
        //修改颜色
        if (column.field == 'roadwayNo') {
          column.formatter = (row) => {
            console.log("🚀 ~ this.columns.forEach ~ row:", row)
            return '<span style="color: #2d8cf0;">' + row?.locationInfo?.roadwayNo + '</span>'
          }
        }
        //格式化日期
        // 检查当前列的字段是否为 'locationStatus'
        if (column.field == 'locationStatus') {
          // 使用对象字面量来映射 'locationStatus' 的值和对应的文本
          const statusMap = {
            '-1': '全部',
            '0': '空闲',
            '1': '锁定',
            '2': '有货',
            '3': '有货禁用',
            '4': '无货禁用'
          };
          // 定义一个格式化函数,根据 'locationStatus' 的值返回相应的文本
          column.formatter = (row) => {
            // 使用 statusMap 对象来获取对应的文本,如果没有匹配则返回 '未知状态'
            return statusMap[row?.locationInfo?.locationStatus] || '未知状态';
          }
        }
      })
    },
    onInited() {
      //框架初始化配置后
@@ -103,7 +160,7 @@
    },
    rowClick({ row, column, event }) {
      //查询界面点击行事件
      this.$refs.table.$refs.table.toggleRowSelection(row) //单击行时选中当前行;
      // this.$refs.table.$refs.table.toggleRowSelection(row) //单击行时选中当前行;
    },
    modelOpenAfter(row) {
      //点击编辑、新建按钮弹出框后,可以在此处写逻辑,如,从后台获取数据