heshaofeng
2025-11-04 b01d33fb2262722cda8aa5b40d2fa9a5dee5b9be
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js
@@ -1,8 +1,8 @@
//此js文件是用来自定义扩展业务代码,可以扩展一些自定义页面或者重新配置生成的代码
import http from '@/api/http.js'
import { defineAsyncComponent } from "vue";
import { ElMessage } from 'element-plus'; // å¼•å…¥ElMessage,解决提示无反应
import { h,createVNode, render,reactive  } from 'vue';
import { ElDialog , ElForm, ElFormItem, ElInput, ElButton, ElMessage ,ElSelect, ElOption} from 'element-plus';
import gridBody from './extend/outOrderDetail.vue'
let extension = {
@@ -42,7 +42,169 @@
            createDate: selectedRows[0].createDate || new Date().toLocaleDateString()  // å‡ºåº“日期
          });
        }
      },
      {
  name: '空托盘出库',
  type: 'primary',
  value: '空托盘出库',
  onClick: function () {
    // 2. ç”Ÿæˆ3-12站台选项(默认第一个为站台3)
    const platformOptions = Array.from({ length: 10 }, (_, i) => {
      const num = i + 3;
      return { label: `站台${num}`, value: `PLATFORM${num.toString().padStart(3, '0')}` };
    });
    const mountNode = document.createElement('div');
    document.body.appendChild(mountNode);
    // 3. è¡¨å•数据(默认选中站台3)
    const formData = reactive({
      palletCode: '',
      selectedPlatform: platformOptions[0].value // é»˜è®¤ç»‘定站台3的value
    });
    const vnode = createVNode(ElDialog, {
      title: '空托盘出库',
      width: '500px', // å¾®è°ƒå®½åº¦æ›´åè°ƒ
      modelValue: true,
      appendToBody: true,
      'onUpdate:modelValue': (isVisible) => {
        if (!isVisible) {
          render(null, mountNode);
          document.body.removeChild(mountNode);
        }
      },
      style: {
        padding: '20px 0', // å¼¹çª—内上下留白,避免内容紧贴边框
        borderRadius: '8px' // è½»å¾®åœ†è§’,提升质感
      }
    }, {
      default: () => h(ElForm, {
        model: formData,
        rules: {
          palletCode: [
            { type: 'string', message: '料箱号必须为字符串', trigger: 'blur' }
          ],
          selectedPlatform: [
            { required: true, message: '请选择出库站台', trigger: 'change' }
          ]
        },
        ref: 'batchOutForm',
        labelWidth: '100px', // å›ºå®šæ ‡ç­¾å®½åº¦ï¼Œç¡®ä¿å¯¹é½
        style: {
          padding: '0 30px', // è¡¨å•左右留白,增加呼吸感
        }
      }, [
        // å‡ºåº“站台(上,优化样式)
        h(ElFormItem, {
          label: '出库站台',
          prop: 'selectedPlatform',
          style: {
            marginBottom: '24px' // è¡¨å•项间距优化
          }
        }, [
          h(ElSelect, {
            placeholder: '请选择出库站台(3-12)',
            modelValue: formData.selectedPlatform,
            'onUpdate:modelValue': (val) => {
              formData.selectedPlatform = val;
            },
            style: {
              width: '100%',
              height: '40px', // ç»Ÿä¸€ç»„件高度
              borderRadius: '4px',
              borderColor: '#dcdfe6'
            }
          }, platformOptions.map(platform =>
            h(ElOption, { label: platform.label, value: platform.value })
          ))
        ]),
        // æ‰˜ç›˜ç¼–号(下,优化样式)
        h(ElFormItem, {
          label: '料箱号',
          prop: 'palletCode',
          style: {
            marginBottom: '16px' // ä¸ŽæŒ‰é’®åŒºæ‹‰å¼€åˆç†é—´è·
          }
        }, [
          h(ElInput, {
            type: 'text',
            placeholder: '可选输入料箱号,不填则自动分配空料箱',
            modelValue: formData.palletCode,
            'onUpdate:modelValue': (val) => {
              formData.palletCode = val;
            },
            style: {
              width: '100%',
              height: '40px', // ä¸Žé€‰æ‹©å™¨é«˜åº¦ç»Ÿä¸€
              borderRadius: '4px',
              borderColor: '#dcdfe6'
            },
            attrs: {
              placeholderStyle: 'color: #909399;' // å ä½æ–‡å­—颜色优化,更柔和
            }
          })
        ]),
        // åº•部按钮区(样式优化)
        h('div', {
          style: {
            textAlign: 'right',
            marginTop: '8px',
            paddingRight: '4px' // æŒ‰é’®ä¸Žå³ä¾§å¯¹é½å¾®è°ƒ
          }
        }, [
          h(ElButton, {
            type: 'text',
            onClick: () => {
              render(null, mountNode);
              document.body.removeChild(mountNode);
              ElMessage.info('取消出库操作');
            },
            style: {
              marginRight: '8px',
              color: '#606266' // å–消按钮颜色优化
            }
          }, '取消'),
          h(ElButton, {
            type: 'primary',
            onClick: async () => {
              const formRef = vnode.component.refs.batchOutForm;
              try {
                await formRef.validate();
              } catch (err) {
                return;
              }
              http.post('/api/wmsTask/BatchOutboundTask', {
                palletCode: formData.palletCode,
                platform: formData.selectedPlatform
              }).then(({ data, status, message }) => {
                if (status) {
                  ElMessage.success(`出库成功,分配的托盘编号:${data.palletCode || formData.palletCode}`);
                  this.refresh();
                  render(null, mountNode);
                  document.body.removeChild(mountNode);
                } else {
                  ElMessage.error(message || data?.message || '出库失败');
                }
              }).catch(() => {
                ElMessage.error('请求失败,请稍后重试');
              });
            },
            style: {
              borderRadius: '4px',
              padding: '8px 20px' // æŒ‰é’®å†…边距优化,点击区域更舒适
            }
          }, '确定')
        ])
      ])
    });
    vnode.appContext = this.$.appContext;
    render(vnode, mountNode);
  }
}
    ], box: [], detail: [] }, //扩展的按钮
    methods: {
       //下面这些方法可以保留也可以删除