var vm = new Vue({ el: '#app', data: function () { return { isLoading: false, userInfo: { "loginGuid": '', "loginAccount": '', }, data: [], loading: false, finished: false, refreshing: false, current: 0, pageIndex: 0, limit: 20, totalPage: 0, totalCount: 0, checked: true, id: '', searchKeyword: '', // 搜索关键词 originalData: [], // 保存原始数据 } }, mounted() { var that = this; this.userInfo = { loginGuid: this.GetLoginInfor().loginGuid, loginAccount: this.GetLoginInfor().loginAccount, }; this.onLoad(); }, methods: { // 新增搜索处理方法 handleSearch() { this.pageIndex = 0; this.data = []; this.finished = false; this.isSearching = true; this.onLoad(); }, onLoad() { if (this.refreshing) { this.data = []; this.refreshing = false; } let result = "未完成"; if (this.current === 1) { result = "已完成"; } this.pageIndex++; var that = this; that.AxiosHttp("post", 'Ipqc/getPageXj', { pageIndex: that.pageIndex, limit: that.limit, createUser: that.userInfo.loginAccount, result: result, keyword: that.searchKeyword.trim(), // 新增搜索参数 }, false) .then(function (res) { var json = res; if (json.status == 0) { //this.$notify({ type: 'success', message: json.data.tbBillList }); if (that.pageIndex === 1) { // 如果是第一页,直接覆盖原数据 that.data = json.data.tbBillList; } else { if (json.data.tbBillList.length > 0) { // 如果是下一页,追加新数据 let thisData = that.data; that.data = [...thisData, ...json.data.tbBillList]; } } that.totalCount = json.totalCount; that.totalPage = Math.ceil(that.totalCount / that.limit); that.loading = false; if (that.pageIndex >= that.totalPage) { that.finished = true; } } else { that.$toast.fail(json.message); } }) .catch(function (error) { that.$toast.fail("网络错误,请重试!"); console.log(error); }); }, onRefresh() { // 清空列表数据 this.finished = false; // 重新加载数据 // 将 loading 设置为 true,表示处于加载状态 this.loading = true; this.pageIndex = 0; this.onLoad(); }, onClickTab(name, title) { this.current = name; this.pageIndex = 0; this.onLoad(); } } })