647556386
9 天以前 70aa9b5ca249a84e5867912d551cdafbec76e54e
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/extension/outbound/outboundOrder.js
@@ -48,260 +48,260 @@
         });
       }
     }, */
      {
        name: '空托盘出库',
        type: 'primary',
        value: '空托盘出库',
        onClick: function () {
      // {
      //   name: '空托盘出库',
      //   type: 'primary',
      //   value: '空托盘出库',
      //   onClick: function () {
          const platformOptions = Array.from({ length: 1 }, (_, i) => {
            const num = 1;
            return { label: `站台${num}`, value: `1-2` };
          });
      //     const platformOptions = Array.from({ length: 1 }, (_, i) => {
      //       const num = 1;
      //       return { label: `站台${num}`, value: `1-2` };
      //     });
          const quantityOptions = Array.from({ length: 6 }, (_, i) => ({
            label: (i + 1).toString(),
            value: i + 1
          }));
      //     const quantityOptions = Array.from({ length: 6 }, (_, i) => ({
      //       label: (i + 1).toString(),
      //       value: i + 1
      //     }));
          const warehouseOptions = ref([]);
          const isLoadingWarehouses = ref(false);
      //     const warehouseOptions = ref([]);
      //     const isLoadingWarehouses = ref(false);
          const getWarehouseList = async () => {
            isLoadingWarehouses.value = true;
            try {
              const { data, status } = await http.post('/api/LocationInfo/GetLocationTypes');
              if (status && Array.isArray(data)) {
                // æ ¼å¼åŒ–仓库选项:适配ElSelect的label-value格式
                warehouseOptions.value = data.map(item => ({
                  label: item.locationTypeDesc,
                  value: item.locationType
                }));
              } else {
                ElMessage.error('获取区域列表失败');
                warehouseOptions.value = [];
              }
            } catch (err) {
              ElMessage.error('区域数据请求异常,请稍后重试');
              warehouseOptions.value = [];
            } finally {
              isLoadingWarehouses.value = false;
            }
          };
      //     const getWarehouseList = async () => {
      //       isLoadingWarehouses.value = true;
      //       try {
      //         const { data, status } = await http.post('/api/LocationInfo/GetLocationTypes');
      //         if (status && Array.isArray(data)) {
      //           // æ ¼å¼åŒ–仓库选项:适配ElSelect的label-value格式
      //           warehouseOptions.value = data.map(item => ({
      //             label: item.locationTypeDesc,
      //             value: item.locationType
      //           }));
      //         } else {
      //           ElMessage.error('获取区域列表失败');
      //           warehouseOptions.value = [];
      //         }
      //       } catch (err) {
      //         ElMessage.error('区域数据请求异常,请稍后重试');
      //         warehouseOptions.value = [];
      //       } finally {
      //         isLoadingWarehouses.value = false;
      //       }
      //     };
          const mountNode = document.createElement('div');
          document.body.appendChild(mountNode);
      //     const mountNode = document.createElement('div');
      //     document.body.appendChild(mountNode);
          const formData = reactive({
            warehouseCode: '',
            palletCode: '',
            selectedPlatform: platformOptions[0].value,
            quantity: 1
          });
      //     const formData = reactive({
      //       warehouseCode: '',
      //       palletCode: '',
      //       selectedPlatform: platformOptions[0].value,
      //       quantity: 1
      //     });
          const vnode = createVNode(ElDialog, {
            title: '空托盘出库',
            width: '500px',
            modelValue: true,
            appendToBody: true,
            onOpened: async () => {
              await getWarehouseList();
              const inputRef = vnode.component.refs.boxCodeInput;
              inputRef?.focus();
            },
            'onUpdate:modelValue': (isVisible) => {
              if (!isVisible) {
                render(null, mountNode);
                document.body.removeChild(mountNode);
              }
            },
            style: {
              padding: '20px 0',
              borderRadius: '8px'
            }
          }, {
            default: () => h(ElForm, {
              model: formData,
              rules: {
                warehouseCode: [
                  { required: true, message: '请选择区域', trigger: ['change', 'blur'] }
                ],
                palletCode: [
                  { type: 'string', message: '料箱号必须为字符串', trigger: 'blur' }
                ],
                selectedPlatform: [
                  { required: true, message: '请选择出库站台', trigger: 'change' }
                ],
                quantity: [
                  { required: true, message: '请选择空箱数量', trigger: 'change' }
                ]
              },
              ref: 'batchOutForm',
              labelWidth: '100px',
              style: {
                padding: '0 30px',
              }
            },
              [
                //   h(ElFormItem, {
                //     label: '仓库区域',
                //     prop: 'warehouseCode',
                //     style: {
                //       marginBottom: '24px'
                //     }
                //   }, [
                //     h(ElSelect, {
                //       placeholder: '请选择仓库区域',
                //       modelValue: formData.warehouseCode,
                //       'onUpdate:modelValue': (val) => {
                //         formData.warehouseCode = val;
                //       },
                //       style: {
                //         width: '100%',
                //         height: '40px',
                //         borderRadius: '4px',
                //         borderColor: '#dcdfe6'
                //       }
                //     }, warehouseOptions.value.map(platform =>
                //       h(ElOption, { label: platform.label, value: platform.value })
                //     ))
                //   ]),
                h(ElFormItem, {
                  label: '出库站台',
                  prop: 'selectedPlatform',
                  style: {
                    marginBottom: '24px'
                  }
                }, [
                  h(ElSelect, {
                    placeholder: '请选择出库站台',
                    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:'quantity',
                //     style:{
                //       marginBottom:'24px'
                //     }
                //   },[h(ElSelect,{
                //     placeholder:'请选择空箱数量',
                //     modelValue:formData.quantity,
                //     'onUpdate:modelValue':(val)=>{
                //       formData.quantity=val;
                //     },
                //     style:{
                //       width:'100%',
                //       height:'40px',
                //       borderRadius:'4px',
                //       borderColor:'#dcdfe6'
                //     },
                //     filterable:false
                //   },
                //   quantityOptions.map(option=>
                //     h(ElOption,{
                //       label:option.label,
                //       value:option.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;'
                    }
                  })
                ]),
      //     const vnode = createVNode(ElDialog, {
      //       title: '空托盘出库',
      //       width: '500px',
      //       modelValue: true,
      //       appendToBody: true,
      //       onOpened: async () => {
      //         await getWarehouseList();
      //         const inputRef = vnode.component.refs.boxCodeInput;
      //         inputRef?.focus();
      //       },
      //       'onUpdate:modelValue': (isVisible) => {
      //         if (!isVisible) {
      //           render(null, mountNode);
      //           document.body.removeChild(mountNode);
      //         }
      //       },
      //       style: {
      //         padding: '20px 0',
      //         borderRadius: '8px'
      //       }
      //     }, {
      //       default: () => h(ElForm, {
      //         model: formData,
      //         rules: {
      //           warehouseCode: [
      //             { required: true, message: '请选择区域', trigger: ['change', 'blur'] }
      //           ],
      //           palletCode: [
      //             { type: 'string', message: '料箱号必须为字符串', trigger: 'blur' }
      //           ],
      //           selectedPlatform: [
      //             { required: true, message: '请选择出库站台', trigger: 'change' }
      //           ],
      //           quantity: [
      //             { required: true, message: '请选择空箱数量', trigger: 'change' }
      //           ]
      //         },
      //         ref: 'batchOutForm',
      //         labelWidth: '100px',
      //         style: {
      //           padding: '0 30px',
      //         }
      //       },
      //         [
      //           //   h(ElFormItem, {
      //           //     label: '仓库区域',
      //           //     prop: 'warehouseCode',
      //           //     style: {
      //           //       marginBottom: '24px'
      //           //     }
      //           //   }, [
      //           //     h(ElSelect, {
      //           //       placeholder: '请选择仓库区域',
      //           //       modelValue: formData.warehouseCode,
      //           //       'onUpdate:modelValue': (val) => {
      //           //         formData.warehouseCode = val;
      //           //       },
      //           //       style: {
      //           //         width: '100%',
      //           //         height: '40px',
      //           //         borderRadius: '4px',
      //           //         borderColor: '#dcdfe6'
      //           //       }
      //           //     }, warehouseOptions.value.map(platform =>
      //           //       h(ElOption, { label: platform.label, value: platform.value })
      //           //     ))
      //           //   ]),
      //           h(ElFormItem, {
      //             label: '出库站台',
      //             prop: 'selectedPlatform',
      //             style: {
      //               marginBottom: '24px'
      //             }
      //           }, [
      //             h(ElSelect, {
      //               placeholder: '请选择出库站台',
      //               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:'quantity',
      //           //     style:{
      //           //       marginBottom:'24px'
      //           //     }
      //           //   },[h(ElSelect,{
      //           //     placeholder:'请选择空箱数量',
      //           //     modelValue:formData.quantity,
      //           //     'onUpdate:modelValue':(val)=>{
      //           //       formData.quantity=val;
      //           //     },
      //           //     style:{
      //           //       width:'100%',
      //           //       height:'40px',
      //           //       borderRadius:'4px',
      //           //       borderColor:'#dcdfe6'
      //           //     },
      //           //     filterable:false
      //           //   },
      //           //   quantityOptions.map(option=>
      //           //     h(ElOption,{
      //           //       label:option.label,
      //           //       value:option.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;
                      }
      //           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/Task/PalletOutboundTask?palletCode=' + formData.palletCode + '&endStation=' + formData.selectedPlatform, {
      //                 http.post('/api/Task/PalletOutboundTask?palletCode=' + formData.palletCode + '&endStation=' + formData.selectedPlatform, {
                      }).then(({ data, status, message }) => {
                        if (status) {
      //                 }).then(({ data, status, message }) => {
      //                   if (status) {
                          ElMessage.success(`出库成功`);
                          this.refresh();
                          render(null, mountNode);
                          document.body.removeChild(mountNode);
                        } else {
                          ElMessage.error(message || data?.message || '出库失败');
                        }
                      }).catch(() => {
                        ElMessage.error('请求失败,请稍后重试');
                      });
                    },
                    style: {
                      borderRadius: '4px',
                      padding: '8px 20px'
                    }
                  }, '确定')
                ])
              ])
          });
      //                     ElMessage.success(`出库成功`);
      //                     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);
        }
      }
      //     vnode.appContext = this.$.appContext;
      //     render(vnode, mountNode);
      //   }
      // }
    ], box: [], detail: []
  }, //扩展的按钮
  methods: {
@@ -370,10 +370,7 @@
      var EmptyTrayOutboundBtn = this.buttons.find(x => x.value == "EmptyTrayOutbound");
        if (EmptyTrayOutboundBtn != null) {
          EmptyTrayOutboundBtn.onClick = () => {
                let rows = this.$refs.table.getSelected();
                if (rows.length == 0) return this.$error("请选择数据!");
                if (rows.length >1) return this.$error("请选择数据!");
               this.$refs.gridHeader.open();
               this.$refs.gridFooter.open();
            }
        }
@@ -389,7 +386,7 @@
      let wheres = [{
        'name': 'orderType',
        'value': '0',
        'value': ['0','116'],
        'displayType': 'text'
      }];
@@ -416,6 +413,10 @@
      this.$refs.table.$refs.table.toggleRowSelection(row); //单击行时选中当前行;
    },
    modelOpenAfter(row) {
      if (this.currentAction === 'Add') { // åˆ¤æ–­å½“前是新建操作
                const currentUser = this.$store.state.userInfo?.userTrueName || 'system';
                this.editFormFields.operator = currentUser;
            }
      //点击编辑、新建按钮弹出框后,可以在此处写逻辑,如,从后台获取数据
      //(1)判断是编辑还是新建操作: this.currentAction=='Add';
      //(2)给弹出框设置默认值