| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <template>
- <view>
- <view class="px3 py2 p-fixed left0 right0 bg-color-white ">
- <u-search placeholder="请输入名称" v-model="keyword" @search="search" @custom="search">
- </u-search>
- </view>
- <view style="padding-top: 104rpx;">
- <template v-if="listData.length > 0">
- <view class="py2 px3 one-ellipsis border-bottom" v-for="(item,index) in listData" :key="index" @click="handleBack(item)">
- {{ item.name }}
- </view>
- <view class="py3">
- <u-loadmore :status="status" />
- </view>
- </template>
- <template v-else>
- <view class="empty">
- <u-empty text="暂无数据" mode="list"></u-empty>
- </view>
- </template>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- keyword: '',
- listData: [],
- status: 'loadmore',
- page: 1,
- limit: 20,
- loadMore: true
- }
- },
- onLoad() {
- this.initData()
- },
- onPullDownRefresh() {
- // 请求结束取消刷新
- this.page = 1;
- this.loadMore = true;
- this.listData = [];
- this.initData();
- uni.stopPullDownRefresh();
- },
- onReachBottom() {
- if (this.loadMore) {
- this.page++;
- this.initData();
- }
- },
- methods: {
- handleBack(item) {
- if(item.level == 1){
- uni.showToast({ icon: 'none', title: '请选择库位!', duration: 2000 });
- return;
- }
- const pages = getCurrentPages();
- const prevPage = pages[pages.length - 2];
- prevPage.backId = item.id
- prevPage.backName = item.name
-
- console.log(item.name)
- // prevPage.setData({
- // "ceshiId":item.id,
- // })
- // console.log(prevPage);
- uni.navigateBack();
- },
- search(value) {
- console.log(value);
- this.page = 1;
- this.loadMore = true;
- this.listData = [];
- this.initData();
- },
- initData() {
- const that = this
- that.status = 'loading';
- this.$Http
- .getStorePage({
- pageNum: that.page,
- pageSize: that.limit,
- filter: -1,
- keyword: that.keyword
- })
- .then((res) => {
- const data = res.data.rows;
- if (data && data.length > 0 && data.length < that.limit) {
- that.status = 'nomore';
- that.loadMore = false;
- } else if (data.length == that.limit) {
- that.status = 'loadmore';
- } else {
- that.status = 'nomore';
- }
- that.listData = [...that.listData, ...data];
- console.log(that.listData);
- })
- }
- }
- }
- </script>
- <style scoped>
- page{
- background-color: #FFFFFF;
- }
- </style>
|