huangxiaoqiang
12 小时以前 960b33fa24c47a330e51a2c24859d681ae62caeb
Code Management/PDA-FG/pages/Empty/Empty.vue
@@ -2,278 +2,311 @@
   <view>
      <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem">
      </uni-segmented-control>
      <!-- 空托入库 -->
      <view v-show="current === 0">
         <view style="padding: 5%;">
            <uni-forms label-width="120">
               <uni-forms-item label="托盘编码">
                  <uni-easyinput type="text" :focus="barcodeFocus" v-model="PalletCode1" placeholder="请输入托盘编码"
                     ref='midInput' @input="Changebarcode()"/>
                     ref="midInput" @input="onPalletCode1Input" />
               </uni-forms-item>
               <uni-forms-item label="入库起点">
               <uni-forms-item label="搬运起点">
                  <uni-easyinput type="text" :focus="addressFocus" v-model="SourceAddress" placeholder="请输入起点"
                     ref='midInput' />
                     ref="midInput" />
               </uni-forms-item>
               <uni-forms-item label="终点区域">
                  <uni-data-select :focus="!istrue" v-model="AreaId" :localdata="range"
                     placeholder="请输选择终点区域"></uni-data-select>
                  <picker mode="selector" :range="areaNames" @change="onAreaChange">
                     <view
                        style="padding: 10px; background-color: #fff; border: 1px solid #dcdfe6; border-radius: 4px; min-height: 16px; line-height: 16px;">
                        {{ selectedAreaName || '请选择终点区域' }}
                     </view>
                  </picker>
               </uni-forms-item>
            </uni-forms>
            <button @click="InboundTask" type="primary" size="default" style="margin-top: 2%;">搬运</button>
            <button @click="inboundTask" type="primary" size="default" style="margin-top: 2%;"
               :disabled="isLoading">
               {{ isLoading ? '处理中...' : '搬运' }}
            </button>
         </view>
      </view><view v-show="current === 1">
      </view>
      <!-- 空托出库 -->
      <view v-show="current === 1">
         <view style="padding: 5%;">
            <uni-forms label-width="120">
               <uni-forms-item label="出库区域">
                  <uni-data-select :focus="!istrue" v-model="AreaId" :localdata="range"
                     placeholder="请输选择终点区域"></uni-data-select>
                  <picker mode="selector" :range="areaNames" @change="onOutAreaChange">
                     <view
                        style="padding: 10px; background-color: #fff; border: 1px solid #dcdfe6; border-radius: 4px; min-height: 16px; line-height: 16px;">
                        {{ selectedOutAreaName || '请选择出库区域' }}
                     </view>
                  </picker>
               </uni-forms-item>
               <uni-forms-item label="出库终点">
                  <uni-easyinput type="text" :focus="addressFocus" v-model="TargetAddress" placeholder="请输入起点"
                     ref='midInput' />
                  <uni-easyinput type="text" v-model="TargetAddress" placeholder="请输入出库终点" ref="targetInput" />
               </uni-forms-item>
            </uni-forms>
            <button @click="SolvePlate" type="primary" size="default" style="margin-top: 2%;">解盘</button>
            <button @click="outboundTask" type="primary" size="default" style="margin-top: 2%;"
               :disabled="isLoading">
               {{ isLoading ? '处理中...' : '出库' }}
            </button>
         </view>
      </view>
      <u-toast ref="luToast" />
   </view>
</template>
<script>
   import {
      config
   } from '../../common/config';
   const innerAudioContext = uni.createInnerAudioContext();
   export default {
      data() {
         return {
            barcodeFocus:true,
            focus: false,
            istrue: false,
            addressFocus:false,
            barcodefocus: false,
            range: [],
            rangethree:[],
            group: [],
            AreaId: 0,
            acrossFloor:0,
            quantity: "",
            SourceAddress: "",
            TargetAddress: "",
            // 当前选中的tab
            items: ['空托入库', '空托出库'],
            current: 0,
            // 入库表单数据
            PalletCode1: "",
            PalletCode2: "",
            PalletCode3: "",
            materSn: "",
            items: ['空托入库','空托出库'],
            current: 0
            SourceAddress: "",
            // 出库表单数据
            TargetAddress: "",
            // 区域选择
            areaList: [], // 区域数据 [{id, name}]
            areaNames: [], // 区域名称数组
            AreaId: "", // 入库选中的区域ID
            selectedAreaName: "", // 入库选中的区域名称
            outAreaId: "", // 出库选中的区域ID
            selectedOutAreaName: "", // 出库选中的区域名称
            // 焦点控制
            barcodeFocus: true,
            addressFocus: false,
            // 加载状态
            isLoading: false,
         }
      },
      onLoad(res) {
         this.range = config.AreaId;
         this.rangethree = config.AcrossFloor;
      onLoad() {
         this.queryAreaInfo();
      },
      methods: {
         // 分段选择器点击事件
         onClickItem(e) {
            if (this.current != e.currentIndex) {
            if (this.current !== e.currentIndex) {
               this.current = e.currentIndex;
               this.resetForm();
            }
         },
         // 重置表单
         resetForm() {
            this.PalletCode1 = "";
            this.SourceAddress = "";
            this.TargetAddress = "";
            this.AreaId = "";
            this.selectedAreaName = "";
            this.outAreaId = "";
            this.selectedOutAreaName = "";
            this.barcodeFocus = true;
            this.addressFocus = false;
         },
         // 播放语音提示
         voiceSpeech(src) {
            innerAudioContext.src = src; // '../../static/success.mp3';
            innerAudioContext.src = src;
            innerAudioContext.play();
         },
         InboundTask() {
            if (this.PalletCode1.length <= 0 && this.SourceAddress.length) {
         // 查询区域信息
         queryAreaInfo() {
            this.$u.post('/api/Dt_AreaInfo/QueryAreaInfo').then(res => {
               if (res.status && res.data && Array.isArray(res.data)) {
                  this.areaList = res.data;
                  this.areaNames = res.data.map(item => item.name);
                  console.log('区域数据加载成功', this.areaList);
               } else {
                  this.$refs.luToast.show({
                     title: res.message || "加载区域数据失败",
                     type: "error"
                  });
               }
            }).catch(err => {
               console.error('QueryAreaInfo error:', err);
               this.$refs.luToast.show({
                  title: "托盘编码跟绑定货位不能为空",
                  title: "网络请求失败",
                  type: "error"
               })
               });
            });
         },
         // 入库区域选择
         onAreaChange(e) {
            const index = e.detail.value;
            if (this.areaList[index]) {
               this.selectedAreaName = this.areaList[index].name;
               this.AreaId = this.areaList[index].id;
            }
         },
         // 出库区域选择
         onOutAreaChange(e) {
            const index = e.detail.value;
            if (this.areaList[index]) {
               this.selectedOutAreaName = this.areaList[index].name;
               this.outAreaId = this.areaList[index].id;
            }
         },
         // 托盘编码输入事件
         onPalletCode1Input() {
            this.barcodeFocus = false;
            this.$nextTick(() => {
               if (this.PalletCode1 && this.PalletCode1 !== '') {
                  this.addressFocus = true;
               }
            });
         },
         // 入库任务
         inboundTask() {
            // 表单验证
            if (!this.PalletCode1 || this.PalletCode1.trim() === "") {
               this.$refs.luToast.show({
                  title: "托盘编码不能为空",
                  type: "error"
               });
               this.barcodeFocus = true;
               return;
            }
            var param = {
               "PalletCode": this.PalletCode1,
               "Position": this.SourceAddress,
               "TargetAddress": this.TargetAddress,
               "AreaId": this.AreaId,
            if (!this.SourceAddress || this.SourceAddress.trim() === "") {
               this.$refs.luToast.show({
                  title: "搬运起点不能为空",
                  type: "error"
               });
               this.addressFocus = true;
               return;
            }
            if (!this.AreaId) {
               this.$refs.luToast.show({
                  title: "请选择终点区域",
                  type: "error"
               });
               return;
            }
            if (this.isLoading) return;
            this.isLoading = true;
            const param = {
               PalletCode: this.PalletCode1.trim(),
               Position: this.SourceAddress.trim(),
               AreaId: this.AreaId,
               IsFull: false,
            };
            this.$u.post('/api/Task/RequestInboundTaskAsync', param).then(res => {
               this.isLoading = false;
               if (res.status) {
                  this.$refs.luToast.show({
                     title: res.message,
                     title: res.message || "入库任务创建成功",
                     type: "success"
                  })
                  });
                  this.voiceSpeech('../../static/success.mp3');
                  // 重置表单
                  this.PalletCode1 = "";
                  this.SourceAddress = "";
                  this.TargetAddress = "";
                  this.AreaId = "";
                  this.istrue = false;
                  this.selectedAreaName = "";
                  this.barcodeFocus = true;
                  this.addressFocus = false;
               } else {
                  this.$refs.luToast.show({
                     title: res.message,
                     title: res.message || "入库任务创建失败",
                     type: "error"
                  })
                  });
                  this.barcodeFocus = true;
               }
            })
         },
         SendTask() {
            if (this.PalletCode3.length <= 0 && this.SourceAddress3.length) {
            }).catch(err => {
               this.isLoading = false;
               console.error('InboundTask error:', err);
               this.$refs.luToast.show({
                  title: "托盘编码跟绑定货位不能为空",
                  title: "网络请求失败",
                  type: "error"
               })
               return;
            }
            var param = {
               "PalletCode": this.PalletCode3,
               "Position": this.SourceAddress3,
               "AreaId": this.acrossFloor,
               "DoubleTray":1,
            }
            this.$u.post('/api/Task/RequestInboundTaskAsync', param).then(res => {
               if (res.status) {
                  this.$refs.luToast.show({
                     title: res.message,
                     type: "success"
                  })
                  this.PalletCode3 = "";
                  this.SourceAddress3 = "";
                  this.acrossFloor = "";
                  this.istrue = false;
               } else {
                  this.$refs.luToast.show({
                     title: res.message,
                     type: "error"
                  })
               }
            })
         },
         GroupPlate() {
            if (this.PalletCode2.length <= 0 && this.InBoundOrder.length) {
               this.$refs.luToast.show({
                  title: "请输入起点站台",
                  type: "error"
               })
               return;
            }
            var param = {
               "PalletCode": this.PalletCode2,
               "groups": this.group
            }
            this.$u.post('/api/BoxingInfo/AddGroupPlateAsync', param).then(res => {
               if (res.status) {
                  this.$refs.luToast.show({
                     title: res.message,
                     type: "success"
                  })
                  this.PalletCode2 = "";
                  this.group = [];
                  this.barcodefocus = false;
               } else {
                  this.$refs.luToast.show({
                     title: res.message,
                     type: "error"
                  })
               }
            })
         },
         SolvePlate() {
            if (this.PalletCode3.length <= 0) {
               this.$refs.luToast.show({
                  title: "请输入托盘条码",
                  type: "error"
               })
               return;
            }
            var param = {
               "PalletCode": this.PalletCode3,
            }
            this.$u.post('/api/BoxingInfo/DeleteGroupPlateAsync', param).then(res => {
               if (res.status) {
                  this.$refs.luToast.show({
                     title: res.message,
                     type: "success"
                  })
                  this.PalletCode3 = "";
                  this.barcodefocus = false;
               } else {
                  this.$refs.luToast.show({
                     title: res.message,
                     type: "error"
                  })
               }
            })
         },
         updateFocus() {
            this.$nextTick(() => {
               this.materSn = '';
               if (!this.focus) {
                  this.focus = true;
               }
               });
               this.barcodeFocus = true;
            });
         },
         snInput() {
            this.$nextTick(() => {
               var matObj = {
                  orderNo: this.materSn,
               }
               var temp = this.group.find(x => x.orderNo == matObj.orderNo);
               if (!temp) {
                  this.$u.post('/api/InboundOrder/GetInboundOrderInfo?orderNo=' + this.materSn, "").then(
                     res => {
                        if (res.status) {
                           this.group.push(res.data);
                           setTimeout(this.updateFocus, 200);
                           setTimeout(() => {
                              this.voiceSpeech('../../static/success.mp3');
                           }, 100);
                        } else {
                           this.$refs.luToast.show({
                              title: res.message,
                              type: "error"
                           })
                        }
                     })
         // 出库任务
         outboundTask() {
            if (!this.outAreaId) {
               this.$refs.luToast.show({
                  title: "请选择出库区域",
                  type: "error"
               });
               return;
            }
            if (this.isLoading) return;
            this.isLoading = true;
            const param = {
               AreaId: this.outAreaId,
               TargetAddress: this.TargetAddress,
               IsFull: false,
            };
            this.$u.post('/api/Task/RequestOutboundTaskAsync', param).then(res => {
               this.isLoading = false;
               if (res.status) {
                  this.$refs.luToast.show({
                     title: res.message || "出库任务创建成功",
                     type: "success"
                  });
                  this.voiceSpeech('../../static/success.mp3');
                  // 重置表单
                  this.TargetAddress = "";
                  this.outAreaId = "";
                  this.selectedOutAreaName = "";
               } else {
                  this.$refs.luToast.show({
                     title: "扫码重复",
                     title: res.message || "出库任务创建失败",
                     type: "error"
                  })
                  setTimeout(this.updateFocus, 200);
                  setTimeout(() => {
                     this.voiceSpeech('../../static/fail.mp3');
                  }, 100);
                  });
               }
            }).catch(err => {
               this.isLoading = false;
               console.error('OutboundTask error:', err);
               this.$refs.luToast.show({
                  title: "网络请求失败",
                  type: "error"
               });
            });
         },
      },
            })
         },
         Changebarcode() {
            this.barcodeFocus = false;
            this.$nextTick(function(x) {
               if (this.PalletCode1 != '') {
                  this.addressFocus = true;
               }
            })
         },
         inputChangebarcode() {
            this.$nextTick(() => {
               this.$u.post('/api/BoxingInfo/GetPalletCodeInfo?palletCode=' + this.PalletCode2, "").then(
                  res => {
                     if (res.status) {
                        this.group = res.data;
                        console.log(this.group);
                        setTimeout(this.updateFocus, 200);
                        setTimeout(() => {
                           this.voiceSpeech('../../static/success.mp3');
                        }, 100);
                     }
                  })
            })
         },
         removeScanItem(orderNo) {
            this.group = this.group.filter(item => item.orderNo !== orderNo);
         }
      // 页面卸载时销毁音频
      onUnload() {
         innerAudioContext.destroy();
      }
   }
</script>
@@ -288,57 +321,5 @@
      background-color: #efeff4;
      min-height: 100%;
      height: auto;
   }
   .tips {
      color: #67c23a;
      font-size: 14px;
      line-height: 40px;
      text-align: center;
      background-color: #f0f9eb;
      height: 0;
      opacity: 0;
      transform: translateY(-100%);
      transition: all 0.3s;
   }
   .tips-ani {
      transform: translateY(0);
      height: 40px;
      opacity: 1;
   }
   .content {
      width: 100%;
      display: flex;
   }
   .list-picture {
      width: 100%;
      height: 145px;
   }
   .thumb-image {
      width: 100%;
      height: 100%;
   }
   .ellipsis {
      display: flex;
      overflow: hidden;
   }
   .uni-ellipsis-1 {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
   }
   .uni-ellipsis-2 {
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
   }
</style>