// pageage/samplingRetestingDeliver/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { educationTypeList:[ { text:'项目11', id:'1' }, { text:'项目22', id:'2' }, ], id:"", projectId:"", retestListData:[], retestDataInfo:{}, maxDate:new Date(2100,1,1).getTime(), typeFlag:"", inspectionTime:"", sampleTime:"", loadShow:false }, /** * 获取复试类型数据 */ getRetestListChange(e){ let retestListData = [] var that = this wx.request({ url: app.globalData.szhUrl + '/system/dict/data/listData', method:"post", data:{ dictType:"fslx_value" }, header: { 'content-type': 'application/x-www-form-urlencoded' //修改此处即可 }, success(res){ if(res.data.code == 0){ let {rows} = res.data rows.forEach(item=>{ retestListData.push({ id:item.dictValue, text:item.dictLabel }) }) that.setData({ retestListData }) that.getRetestDetaiilsInfo() } } }) }, /** * 选择复试类型类型 */ onRetestListChange(e){ let {id} = e.detail this.setData({ typeFlag:id }) }, /** * 选择送检时间 */ onInspectionTime(e){ let value = e.detail this.setData({ inspectionTime:value }) }, /** * 选择取样时间 */ onSampleTime(e){ let value = e.detail this.setData({ sampleTime:value }) }, add_btn_qx(e){ wx.navigateTo({ url: '../samplingRetesting/index', }) }, /** * 数据提交 */ formSubmit(e){ let that = this let {laboratoryName,materialName,positionName,qualifiedFlag,represenNum,sampleBy,sampleNum,witnessBy} = e.detail.value let {id,projectId,inspectionTime,typeFlag,sampleTime} = this.data //数据校验 if(!that.checkRetestDataInfo(e.detail.value,this.data)){ return; } that.setData({ loadShow:true }) wx.request({ url: app.globalData.szhUrl + '/system/retestinfo/edit', method:"Post", data:{ id, //项目id projectId, //取样类型 typeFlag, //取样时间 sampleTime, //送检时间 inspectionTime, //实验室名称 laboratoryName, //物料名称 materialName, //使用部位 positionName, //是否提供合格证 qualifiedFlag, //代表数量 represenNum, //取样人 sampleBy, //取样数量(组) sampleNum, //见证人 witnessBy, //状态 resultStr:'标样中' }, header:{ 'content-type': 'application/x-www-form-urlencoded' }, success(res){ that.setData({ loadShow:false }) if(res.code == "0"){ app.toast("保存成功!") } setTimeout(()=>{ wx.navigateTo({ url: '../samplingRetesting/index', }) },1200) } }) console.log(e); }, /** * 数据校验 * @param {}} options */ checkRetestDataInfo({laboratoryName,materialName,positionName,qualifiedFlag,represenNum,sampleBy,sampleNum,witnessBy},{inspectionTime,typeFlag,sampleTime}){ if(!laboratoryName || laboratoryName.length <= 0){ app.toast("实验室名称不能为空!") return false; } if(!materialName || materialName.length <= 0){ app.toast("物料名称不能为空!") return false; } if(!positionName || positionName.length <= 0){ app.toast("使用部位名称不能为空!") return false; } if(!qualifiedFlag || qualifiedFlag.length <= 0){ app.toast("是否提供合格证不能为空!") return false; } if(!sampleNum || sampleNum.length <=0){ app.toast("实验室名称不能为空!") return false; } if(!represenNum || represenNum.length <= 0){ app.toast("取样数量不能为空!") return false; } if(!sampleBy || sampleBy.length <= 0){ app.toast("取样人名称不能为空!") return false; } if(!witnessBy || witnessBy.length <= 0){ app.toast("见证人名称不能为空!") return false; } if(!inspectionTime || inspectionTime.length <= 0){ app.toast("送检时间不能为空!") return false; } if(!typeFlag || typeFlag.length <= 0){ app.toast("复试类型不能为空!") return false; } if(!sampleTime || sampleTime.length <= 0){ app.toast("送检时间不能为空!") return false; } return true }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { let {id,projectId} = options; this.setData({ id,projectId }) this.getRetestListChange() }, /** * 获取复试回显信息 */ getRetestDetaiilsInfo(){ let that = this let {projectId,id} = this.data wx.request({ url: app.globalData.szhUrl + '/system/retestinfo/getRetestInfoById', method:"Get", data:{ projectId, id }, header:{ 'content-type': 'application/x-www-form-urlencoded' }, success(res){ res = res.data res.data.typeFlagName = that.convertRetesingName(res.data) that.setData({ typeFlag: res.data.typeFlag, inspectionTime:res.data.inspectionTime, sampleTime:res.data.sampleTime, retestDataInfo:res.data }) } }) }, /** * 置换名称 */ convertRetesingName(item){ let typeName = "" let typeFlag = item.typeFlag this.data.retestListData.forEach(item1=>{ if(typeFlag == item1.id){ typeName = item1.text } }) return typeName }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })