import * as requestAPI from '../../models/dataModel' Page({ data: { inspectionList: [], scCode: '', poCode: '', current: 1, size: 10, total: 0, selectinspectionList: [] }, onLoad: function (options) { this.setData({ poCode: options?options.poCode:this.data.poCode, scCode: options?options.scCode:this.data.scCode }) }, onReady() { this.getinspectionList() }, onUnload() { }, // 获取样品单列表 getinspectionList() { //wx.showLoading({title: '加载中', icon: 'loading'}); let form = { current: this.data.current, size: this.data.size, scCode: this.data.scCode, poCode: this.data.poCode } requestAPI.getInspectionList(form).then(res => { this.setData({ inspectionList: res.data.data.records, total: res.data.data.total }) }) }, // 获取资料详情 getDetail: function (event) { let filterList = this.data.inspectionList.filter(item=>{return item.id == event.currentTarget.dataset.id}) wx.navigateTo({ url: `/pages/inspection/detail?ids=${filterList[0].id}&scpCode=${filterList[0].scpCode}&scCode=${filterList[0].scCode}&poCode=${filterList[0].poCode}&picture=${filterList[0].picture}`, }) }, selectList:function(e) { let tempList = this.data.inspectionList tempList[e.currentTarget.dataset.index].checked = !tempList[e.currentTarget.dataset.index].checked this.setData({ inspectionList: tempList }) }, // 下拉刷新 onPullDownRefresh: function () { wx.showNavigationBarLoading(); //在当前页面显示导航条加载动画 this.onLoad(); //刷新页面 setTimeout(function () { wx.hideNavigationBarLoading(); //在当前页面隐藏导航条加载动画 wx.stopPullDownRefresh(); //停止下拉动作 }, 2000) }, // 下拉加载 onReachBottom: function () { if (this.data.size > this.data.total) { return; } else { this.getinspectionList(); this.setData({ size: this.data.size+10 }) } }, openPreview: function (event) { wx.previewImage({ urls: new Array(event.currentTarget.dataset.url), }) }, // 全选反选 selectall() { let tempList = this.data.inspectionList for(let i of tempList) { i.checked =!i.checked } this.setData({ inspectionList: tempList }) }, // 进入图片选择界面 generate() { let tempList = [] let filterList = [] for(let i of this.data.inspectionList) { if(i.checked) { tempList.push(i.id) filterList.push(i) } } if(tempList.length==0) { wx.showToast({ title: `至少选择一个货号`, icon: 'warn', duration: 30000 }) return } wx.navigateTo({ url: `/pages/inspection/detail?ids=${tempList.join('-')}&scpCode='多个货号'&scCode=${filterList[0].scCode}&poCode=${filterList[0].poCode}&picture=''`, }) } })