123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <template>
- <view class="warp">
- <view class="content1">
- <u-search placeholder="输入仓库名称" :show-action="false" v-model="inputKeyword"></u-search>
- </view>
- <view class="content2" v-if="!inputKeyword&&newSelectList.length!=0">
- <view class="title" v-if="">最新选择</view>
- <view class="item-contnet">
- <view class="item-list" v-for="(item,index) in newSelectList" :key="index" @click="confirm(item)">
- {{item.warehouseName}}
- </view>
- </view>
- </view>
- <view class="content2" v-if="!inputKeyword&&moreList.length!=0 ">
- <view class="title" v-if="">更多仓库</view>
- <view class="item-contnet">
- <view class="item-list" v-for="(item,index) in moreList" :key="index" @click="confirm(item)">
- {{item.warehouseName}}
- </view>
- </view>
- </view>
- <view class="content3" v-if="inputKeyword">
- <view class="search-item-list" v-for="(item,index) in filterNewList" :key="index" @click="confirm(item)">
- {{item.warehouseName}}
- </view>
- </view>
- </view>
- </template>
- <script>
- import helper from '@/common/helper.js';
- export default {
- data() {
- return {
- inputKeyword: '',
- newList: [],
- newSelectList: [],
- filterNewList: [],
- moreList: [],
- compId: '',
- warehouseType: "",
- }
- },
- onShow() {
- this.newSelectList = uni.getStorageSync('theWarehouseList1');
- },
- onLoad(options) {
- this.warehouseType = options.warehouseType
- // this.compId = helper.theWarehouse.compId
- this.getWarehouse()
- },
- watch: {
- inputKeyword(val) {
- this.filterNewList = this.newList.filter(function(item) {
- if (item.warehouseName.indexOf(val) > -1) {
- return item
- }
- })
- }
- },
- methods: {
- confirm(item) {
- let _list = uni.getStorageSync('theWarehouseList1');
- if (_list == '') {
- _list = []
- }
- if (_list.length <= 20) {
- _list = _list.filter(function(val) {
- if (val.warehouseName != item.warehouseName) {
- return val
- }
- })
- _list.unshift(item)
- } else {
- _list.unshift(item).pop(item)
- }
- uni.setStorageSync('theWarehouseList1', _list);
- uni.setStorageSync('theWarehouse1', item);
- uni.navigateBack({
- delta: 1
- })
- },
- getWarehouse() {
- uni.showLoading({
- title: '查询仓库',
- mask: true
- })
- var that = this
- this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouse', {
- compId: uni.getStorageSync("pcUserInfo").compId,
- warehouseType: '1'
- }).then(res => {
- uni.hideLoading()
- if (res.data.data.length != 0) {
- that.newList = res.data.data
- that.moreList = res.data.data
- }
- })
- },
- }
- }
- </script>
- <style scoped lang="scss">
- .content1 {
- background: white;
- padding: 20rpx;
- border-radius: 0 0 20rpx 20rpx;
- }
- .content2 {
- background: white;
- margin-top: 20rpx;
- padding: 20rpx;
- border-radius: 20rpx 20rpx 0 0;
- .title {
- font-size: 28rpx;
- font-weight: 400;
- color: #AFB3BF;
- }
- .item-contnet {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- }
- .item-list {
- width: 45%;
- background: #F5F6F9;
- margin: 20rpx 0;
- padding: 10rpx 15rpx;
- border-radius: 30rpx;
- text-align: center;
- }
- }
- .content3 {
- height: calc(100vh - 192rpx);
- background: white;
- padding: 20rpx;
- box-sizing: border-box;
- }
- .search-item-list {
- margin: 20rpx;
- border-bottom: 1px solid #EEEEEE;
- padding-bottom: 20rpx;
- }
- </style>
|