spring
5 天以前 2f26ba8f2c8f5c67e5ed16f4e89baaef82d70a3b
pages/product/feed/locationList.vue
@@ -4,9 +4,9 @@
         <u-search v-model="keywords" placeholder="请输入库位名称" @clear="search" @custom="search" @search="search">
         </u-search>
      </view>
      <scroll-view class="scroll-list" scroll-y="true" >
      <scroll-view class="scroll-list" scroll-y="true">
         <u-cell-group class="list" :border="false">
            <view v-if="locationList==0" class="nodata">
            <view v-if="locationList == 0" class="nodata">
               <view>未查到数据</view>
            </view>
            <view v-else class="content" v-for="(item, index) in locationList" :key="item.locNo" :index="index"
@@ -32,15 +32,15 @@
                     库位类型:
                  </view>
                  <view class="_content">
                     {{ getLocTypeName(item.locType)}}
                     {{ getLocTypeName(item.locType) }}
                  </view>
               </view>
               <view class="row-list">
                  <view class="_label">
                     库位状态:
                  </view>
                  <view class="_content">
                     {{getLocStatus(item.locStatus)}}
                  <view class="_content">
                     {{ getLocStatus(item.locStatus) }}
                  </view>
               </view>
            </view>
@@ -50,147 +50,148 @@
   </view>
</template>
<script>
   import scan from "@/components/scan/scan.vue";
   export default {
      components: {
         scan
import scan from "@/components/scan/scan.vue";
export default {
   components: {
      scan
   },
   data() {
      return {
         originList: [],
         locationList: [],
         keywords: "",
         dictType: "warehouse_type",
         listLocType: []
      };
   },
   onLoad(params) {
      //获取数 库位状态
      this.$u.api.dictData({
         dictType: this.dictType
      }).then(res => {
         this.listLocType = res.data;
      });
      if (params && params.workstationNo !== "undefined") {
         this.loadList(params.workstationNo);
      }
   },
   onShow() {
      let that = this
      uni.$off('scan') // 每次进来先 移除全局自定义事件监听器
      uni.$on('scan', function (data) {
         console.log('onscan');
         //扫码成功后的回调,你可以写自己的逻辑代码在这里
         console.log('扫码结果:', data.code);
         that.search(data.code);
      })
   },
   onNavigationBarButtonTap(e) {
      uni.scanCode({
         success: res => {
            try {
               const result = JSON.parse(res.result)
            } catch (e) { }
         }
      });
   },
   methods: {
      getLocTypeName(locType) {
         let reDate = ""
         let that = this
         //判断数组中是否存在
         let list = that.listLocType.filter(item => item.value == locType)
         if (list.length > 0) {
            reDate = list[0].label
         }
         return reDate
      },
      data() {
         return {
            originList: [],
            locationList: [],
            keywords: "",
            dictType: "warehouse_type",
            listLocType: []
         };
      },
      onLoad(params) {
         //获取数 库位状态
         this.$u.api.dictData({
            dictType: this.dictType
         }).then(res => {
            this.listLocType = res.data;
         });
         if (params && params.workstationNo !== "undefined") {
            this.loadList(params.workstationNo);
      getLocStatus(locStatus) {
         let reDate = ""
         switch (locStatus) {
            case 1:
               reDate = "使用";
               break;
            case 0:
               reDate = "停用";
               break;
         }
         return reDate;
      },
      onShow() {
      selectLocation(location) {
         this.refreshLastPage(location)
      },
      //刷新上一个页面
      refreshLastPage(location) {
         // 告知 A.vue 更新数据
         // 获取页面栈
         let pages = getCurrentPages()
         let that = this
         // 获取上一页栈
         let prevPage = pages[pages.length - 2]
         uni.$off('scan') // 每次进来先 移除全局自定义事件监听器
         uni.$on('scan', function(data) {
            console.log('onscan');
            //扫码成功后的回调,你可以写自己的逻辑代码在这里
            console.log('扫码结果:', data.code);
            that.search(data.code);
         // 触发上一页 upData 函数(并携带参数)
         prevPage.$vm.setLocation(location)
         // 返回上一页
         uni.navigateBack({
            delta: 1
         })
      },
      onNavigationBarButtonTap(e) {
         uni.scanCode({
            success: res => {
               try {
                  const result = JSON.parse(res.result)
               } catch (e) {}
            }
      search(value) {
         let that = this
         if (value) {
            that.locationList = that.originList.filter(item => item.locName.includes(value))
         } else {
            that.locationList = that.originList
         }
      },
      loadList(workstationNo) {
         let params = {
            workstationNo: workstationNo
         }
         //根据工作站编号获取进行中的工单&&对应的线边仓
         this.$u.api.pigxFeed.getBasicInfoForPdaFeedByWorkstationNo(params).then(res => {
            this.originList = res.data.locationList
            this.locationList = this.originList
         });
      },
      methods: {
         getLocTypeName(locType) {
            let reDate = ""
            let that = this
            //判断数组中是否存在
            let list = that.listLocType.filter(item => item.value == locType)
            if (list.length > 0) {
               reDate = list[0].label
            }
            return reDate
         },
         getLocStatus(locStatus) {
            let reDate = ""
            switch (locStatus) {
               case 1:
                  reDate = "使用";
                  break;
               case 0:
                  reDate = "停用";
                  break;
            }
            return reDate;
         },
         selectLocation(location) {
            this.refreshLastPage(location)
         },
         //刷新上一个页面
         refreshLastPage(location) {
            // 告知 A.vue 更新数据
            // 获取页面栈
            let pages = getCurrentPages()
            // 获取上一页栈
            let prevPage = pages[pages.length - 2]
            // 触发上一页 upData 函数(并携带参数)
            prevPage.$vm.setLocation(location)
            // 返回上一页
            uni.navigateBack({
               delta: 1
            })
         },
         search(value) {
            let that = this
            if (value) {
               that.locationList = that.originList.filter(item => item.locName.includes(value))
            } else {
               that.locationList = that.originList
            }
         },
         loadList(workstationNo) {
            let params = {
               workstationNo: workstationNo
            }
            //根据工作站编号获取进行中的工单&&对应的线边仓
            this.$u.api.pigxFeed.getBasicInfoForPdaFeedByWorkstationNo(params).then(res => {
               this.originList = res.data.locationList
               this.locationList = this.originList
            });
         },
      }
   };
   }
};
</script>
<style lang="scss">
   .list .content {
      font-size: 12px;
      background-color: #efefef;
      box-sizing: border-box;
      border-radius: 14rpx;
      margin: 8px;
      padding: 5px 10px;
      box-shadow: none;
   }
.list .content {
   font-size: 12px;
   background-color: #efefef;
   box-sizing: border-box;
   border-radius: 14rpx;
   margin: 8px;
   padding: 5px 10px;
   box-shadow: none;
}
   .row-list {
      display: flex;
      flex-direction: row;
   }
.row-list {
   display: flex;
   flex-direction: row;
}
   .row-list ._label {
      flex: 0.8;
      color: #909399;
   }
.row-list ._label {
   flex: 0.8;
   color: #909399;
}
   .row-list ._content {
      flex: 1.5;
      text-align: right;
   }
   .nodata{width: 20%;margin: auto;}
.row-list ._content {
   flex: 1.5;
   text-align: right;
}
.nodata {
   width: 20%;
   margin: auto;
}
</style>