注册selectLoadmore指令
loadMore() { // 如果没有更多数据,则不请求 if (!this.hasMore) { return; } // 如果intercept属性为true则不请求数据, if (this.loadMore.intercept) { return; } this.loadMore.intercept = true; this.productParams.pageNo++; this.getProductList(); }, // 查询产品 async getProductList() { const { data: { items, pageNo }} = await productQuery(this.productParams); this.loadMore.intercept = false; this.loading = false; this.hasMore = items.length >= 10; this.productParams.pageNo = parseInt(pageNo); // 判断当前获取的产品数据中是否存在当前选中的产品项,若存在则删除 const arr = []; items.forEach(item => { if (!this.form.productIds.includes(item.productId) && !this.productList.find(p => p.productId === item.productId)) { arr.push(item); } }); this.productList = this.productList.concat(arr); }, handleSearch(keyword) { this.loading = true; this.productParams.pageNo = 1; this.productParams.productNameFuzzy = keyword; this.productList = []; this.getProductList(); }, async getSelectProduct(productIds) { const productParams = { pageNo: 1, pageSize: 1000, productIds: productIds }; // 查询当前选中的产品的下拉选项 const { data: { items }} = await productQuery(productParams); return items; }, // 选中产品下拉框 async focusProduct() { // 清除上一次远程搜索的产品列表,并查询当前选中的产品的下拉选项 if (this.productParams.productNameFuzzy && this.form.productIds.length) { const data = await this.getSelectProduct(this.form.productIds.join(',')); this.productList = data; } // 没有数据时,自动请求第一页的数据 if (!this.form.productIds.length || this.productList.length <= this.form.productIds.length) { this.productParams.productNameFuzzy = ''; this.productParams.pageNo = 1; // 判断有选中产品时,只保留当前选中的产品数据 const arr = []; this.productList.forEach(item => { if (this.form.productIds.includes(item.productId)) { arr.push(item); } }); this.productList = arr; // 未选中时清空下拉选项 if (!this.form.productIds.length) { this.productList = []; } this.getProductList(); } }, // 删除选中时,如果请求了关键字,则清除关键字再请求第一页的数据 clearProduct() { if (this.productParams.productNameFuzzy) { this.productParams.pageNo = 1; this.productParams.productNameFuzzy = ''; this.productList = []; this.getProductList(); } }, 标签:el,productParams,pageNo,productList,item,form,productIds,select,加载 From: https://www.cnblogs.com/wxy84/p/18234693