99 lines
3.0 KiB
JavaScript
99 lines
3.0 KiB
JavaScript
const mobileMixins = {
|
|
data() {
|
|
return {
|
|
tableData: [],
|
|
mLoading: false,
|
|
finished: false,
|
|
loading: false,
|
|
refreshing: false,
|
|
formData: {},
|
|
pageForm: {
|
|
pageNumber: 1,
|
|
pageSize: 5,
|
|
totalCount: 0
|
|
},
|
|
themeColor: '#004e64',
|
|
pageDataUrl: null,
|
|
yearList: []
|
|
}
|
|
},
|
|
filters: {
|
|
date(value) {
|
|
return value ? moment(value).format('YYYY-MM-DD') : ''
|
|
}
|
|
},
|
|
methods: {
|
|
async pageData() {
|
|
this.mLoading = true
|
|
if (this.pageDataUrl == null) {
|
|
this.pageDataUrl = loc() + '/pageData'
|
|
}
|
|
$.post(this.pageDataUrl, this.pageForm, (res) => {
|
|
const {code, data} = res
|
|
if (this.refreshing) {
|
|
this.tableData = [];
|
|
this.refreshing = false;
|
|
}
|
|
this.loading = false;
|
|
|
|
if (code === 0) {
|
|
this.tableData = this.tableData.concat(data.list)
|
|
this.pageForm.totalCount = data.totalCount
|
|
|
|
if (this.tableData.length === 0) {
|
|
this.finished = true;
|
|
} else {
|
|
this.none_data = false
|
|
if (this.tableData.length >= this.pageForm.totalCount) {
|
|
this.finished = true;
|
|
this.pageForm.pageNumber++
|
|
}
|
|
}
|
|
}
|
|
})
|
|
this.mLoading = false
|
|
},
|
|
async onRefresh() {
|
|
this.tableData = []
|
|
this.refreshing = true;
|
|
this.finished = false;
|
|
this.pageForm.pageNumber = 0
|
|
this.loading = true;
|
|
await this.pageData();
|
|
},
|
|
GetQueryString(name) {
|
|
const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
|
const r = window.location.search.substr(1).match(reg);
|
|
if (r != null) return unescape(r[2]);
|
|
return "";
|
|
},
|
|
createYearList() {
|
|
for (let i = new Date().getFullYear() - 50; i <= new Date().getFullYear(); i++) {
|
|
this.yearList.unshift({value: i, text: i + '年'},)
|
|
}
|
|
},
|
|
startLoading() {
|
|
this.vLoading = vant.Toast.loading({
|
|
message: '加载中...',
|
|
forbidClick: true,
|
|
duration: 0
|
|
})
|
|
},
|
|
closeLoading() {
|
|
setTimeout(() => {
|
|
this.vLoading.close()
|
|
}, 500)
|
|
},
|
|
doSearch() {
|
|
this.tableKey = new Date().getTime()
|
|
this.pageForm.pageNumber = 1
|
|
this.pageForm.totalCount = 0
|
|
this.tableData = []
|
|
this.pageData()
|
|
}
|
|
},
|
|
created() {
|
|
this.createYearList()
|
|
}
|
|
}
|