import * as requestAPI from '../../models/dataModel' Page({ data: { qcList: [], sscCode: '', pCode: '', current: 1, size: 5, total: 0, selectQCList: [] }, onLoad: function (options) { this.setData({ pCode: options?options.pCode:this.data.pCode, sscCode: options?options.sscCode:this.data.sscCode }) }, onReady() { this.getQcList() }, onUnload() { if(this.getRecordSelectList().length>0) { wx.setStorageSync('selectQcList', JSON.stringify(this.getRecordSelectList())) } }, // 获取样品单列表 getQcList() { wx.showLoading({title: '加载中', icon: 'loading'}); let form = { current: this.data.current, size: this.data.size, sscCode: this.data.sscCode, pCode: this.data.pCode } requestAPI.getQcList(form).then(res => { for (let i =0; i{return item.pid == res.data.data.records[i].pid&&item.sscId== res.data.data.records[i].sscId}) if(filterList.length !== 0) { res.data.data.records.splice(i, 1) break // 搜索全部list有则在全部list里删除 } } res.data.data.records[i].checked = false res.data.data.records[i].productImgUrl = res.data.data.records[i].pictures[0].bigPicture } // 合并已选择的list和全部list if(wx.getStorageSync('selectQcList')&&JSON.parse(wx.getStorageSync('selectQcList')).length!==0){ res.data.data.records = JSON.parse(wx.getStorageSync('selectQcList')).concat(res.data.data.records) } this.setData({ qcList: res.data.data.records, total: res.data.data.total }) }) }, // 获取样品单详情 getDetail: function (event) { wx.navigateTo({ url: `/pages/qc/detail?sscId=${event.currentTarget.dataset.sscid}&pId=${event.currentTarget.dataset.pid}`, }) }, selectList:function(e) { let tempList = this.data.qcList tempList[e.currentTarget.dataset.index].checked = !tempList[e.currentTarget.dataset.index].checked this.setData({ qcList: tempList }) }, // 记录已选择的列 getRecordSelectList() { let tempList = [] for(let i of this.data.qcList) { if(i.checked) { tempList.push(i) } } return 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.getQcList(); this.setData({ size: this.data.size+10 }) } }, openPreview: function (event) { wx.previewImage({ urls: new Array(event.currentTarget.dataset.url), }) }, // 生成QC验货初检报告 generate() { let tempList = [] for(let i of this.data.qcList) { if(i.checked) { tempList.push(i) } } requestAPI.generateQcReport(tempList).then(res=>{ wx.showToast({ title: `生成报告${res.data.data}`, icon: 'success', duration: 30000 }) wx.removeStorageSync('selectQcList') setTimeout(() => { this.getQcList() }, 500); }) } })