Browse Source

分页

voice^2
刘嘉炜 4 years ago
parent
commit
a0e2b99460
  1. 62
      src/pages/write_off/search_result/search_result.vue

62
src/pages/write_off/search_result/search_result.vue

@ -61,51 +61,54 @@ export default {
curStadium: {}, //
writeOffList: [], // ,
curDate: util.formatDate({}),
page: 1,
}
},
onReachBottom(){
let { page, curDate, curStadium } = this;
this.getList({
brand_id: curStadium.brand_id || '',
stadium_id: curStadium.id || '',
date: curDate || '',
page: ++page,
});
},
onLoad(){
this.initPage();
},
onShow(){
let { curStadium, curDate } = this;
if(curStadium&&curStadium.id)this.getList({
brand_id: curStadium.brand_id || '',
stadium_id: curStadium.id,
date: curDate,
});
let { curStadium } = this;
if(curStadium&&curStadium.id)this.refreshList();
},
methods: {
dateChange(e){
let { curStadium } = this;
this.curDate = e.detail.value;
refreshList(){
let { curDate, curStadium } = this;
this.page = 1;
this.writeOffList = [];
this.getList({
brand_id: curStadium.brand_id || '',
stadium_id: curStadium.id,
date: e.detail.value,
stadium_id: curStadium.id || '',
date: curDate || '',
});
},
dateChange(e){
this.curDate = e.detail.value;
this.$nextTick(this.refreshList);
},
stadiumChange(e){
let { stadiumList, curDate } = this;
let { stadiumList } = this;
this.curStadium = stadiumList[e.detail.value];
this.getList({
brand_id: stadiumList[e.detail.value].brand_id || '',
stadium_id: stadiumList[e.detail.value].id,
date: curDate,
});
this.$nextTick(this.refreshList);
},
async initPage(){
let { brandInfo } = this;
try{
let _storeList = await this.getStoreList({ brand_id: brandInfo.brand.id || '' });
this.stadiumList = _storeList || [];
if(_storeList.length) this.curStadium = _storeList[0];
console.warn(util.formatDate({}))
this.getList({
brand_id: brandInfo.brand.id || '',
stadium_id: _storeList[0].id,
date: util.formatDate({}),
});
this.$nextTick(this.refreshList);
}catch(err){
console.warn('加载数据失败!', err);
}
@ -118,18 +121,21 @@ export default {
})
util.routeTo(`/pages/write_off/operate/operate`, 'nT');
},
getList({ brand_id, stadium_id = '', date = '' }){
getList({ brand_id, stadium_id = '', date = '', page = 1, page_size = 15 }){
util.showLoad();
servers.get({
url: API.writeOff.listVerifyRecord,
data: { brand_id, stadium_id, date },
data: { brand_id, stadium_id, date, page, page_size },
failMsg: '加载失败!',
})
.then(res=>{
util.hideLoad();
let _list = res.list || [];
this.writeOffList = _list;
console.warn(res, 'jijjjjjjjjj')
if(page == 1)return this.writeOffList = _list;
if(!_list.length)return util.showNone('没有更多!');
this.page = page;
this.writeOffList = [...this.writeOffList, ..._list];
})
},
getStoreList({

Loading…
Cancel
Save