// pages/inquiryForm/inquiryForm.js const app = getApp() import {nation,job} from "../../../api/common" import {sendFields} from "../../../api/sickRecord" import {throttle} from "../../../utils/util" Page({ /** * 页面的初始数据 */ data: { showDialog:false, obj:{ height:'身高', weight:'体重', marital_status:'婚姻状态', nation_id:'民族', job_id:'职业', allergy_history:'是否有过敏史?', family_history:'是否有家族病史?', is_pregnant:'是否处于备孕、妊娠、哺乳期?', is_operation:'是否做过手术?', drink_wine_status:'是否有饮酒史?', smoke_status:'是否有吸烟史?', chemical_compound_status:'是否有接触过化学物?', diagnosis_hospital:'确诊医院是?', is_take_medicine:'服用药品是?' }, showNation:false, showJob:false, showMarital:false, nationname:'', order_inquiry_id:'', jobname:'', hideGuomin:false, hideFamilysick:false, hidePregnant:false, hideOperation:false, hideChemical:false, hideHospital:false, hideDrug:false, personInfo:{}, showBtn:true, maritalColumn: [{ text: '未婚', value: 0 }, { text: '已婚 ', value: 1 }, { text: '离异 ', value: 2 }], nationcolumns:[], jobcolumns:[], list1:[], list2:[], startIndex1:1, showList:[{ isHas:false, index:1 },{ isHas:false, index:2 },{ isHas:false, index:3 },{ isHas:false, index:4 },{ isHas:false, index:5 },{ isHas:false, index:6 },{ isHas:false, index:7 },{ isHas:false, index:8 },{ isHas:false, index:9 }] }, handleIpt(e){ let key = e.target.dataset.id; let obj="personInfo."+key; if(key=='height' || key=="weight"){ this.setData({ [obj]:e.detail.value }) }else{ this.setData({ [obj]: e.detail.value }) } }, confirmDialog:throttle(function(event){ if(event.detail){ this.handleSend(); } }), handleSend(){ const {order_inquiry_id,personInfo,obj}=this.data; let dataObj={}; for (const key in obj) { if(personInfo[key] || personInfo[key]==0){ dataObj[key]=personInfo[key]; } } let res=Object.assign({},dataObj,personInfo); sendFields({ order_inquiry_id, fields:res, }).then(data=>{ wx.showToast({ title: '发送成功', icon:'none' }), wx.navigateBack() thi.setData({ showDialog:false }) }) }, handleSendFields(){ const {order_inquiry_id,personInfo,list1,list2,marital_name,jobname,nationname,obj}=this.data; console.log(personInfo) const fields=[]; for (let i = 0; i { if(item=="allergy_history"){ count++; this.setData({ 'showList[0].isHas':true, 'showList[0].index':1 }) }else if(item=="family_history"){ count++; this.setData({ 'showList[1].isHas':true, 'showList[1].index':count }) }else if(item=="is_pregnant"){ count++; this.setData({ 'showList[2].isHas':true, 'showList[2].index':count }) }else if(item=="is_operation"){ count++; this.setData({ 'showList[3].isHas':true, 'showList[3].index':count }) }else if(item=="drink_wine_status"){ count++; this.setData({ 'showList[4].isHas':true, 'showList[4].index':count }) }else if(item=="smoke_status"){ count++; this.setData({ 'showList[5].isHas':true, 'showList[5].index':count }) }else if(item=="chemical_compound_status"){ count++; this.setData({ 'showList[6].isHas':true, 'showList[6].index':count }) }else if(item=="diagnosis_hospital"){ count++; this.setData({ 'showList[7].isHas':true, 'showList[7].index':count }) }else if(item=="is_take_medicine"){ count++; this.setData({ 'showList[8].isHas':true, 'showList[8].index':count }) } }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.getNation(); this.getJob(); if(options.order_inquiry_id){ this.setData({ order_inquiry_id:options.order_inquiry_id }) } if(options.case_filled_fields){ let data=JSON.parse(options.case_filled_fields); let arr1=[]; let arr2=[]; this.setData({ personInfo:data, showBtn:false }); if(data.is_allergy_history==1){ this.setData({ hideGuomin:true }) } if(data.is_family_history==1){ this.setData({ hideFamilysick:true }) } if(data.is_operation==1){ this.setData({ hideOperation:true }) } if(data.is_pregnant==1){ this.setData({ hidePregnant:true }) } if(data.chemical_compound_status && data.chemical_compound_status!=1){ this.setData({ hideChemical:true }) } if(data.diagnosis_hospital){ this.setData({ hideHospital:true }) } if(data.is_take_medicine==1){ this.setData({ hideDrug:true }) } let {maritalColumn,jobcolumns,nationcolumns}=this.data; if(data.marital_status==0 || data.marital_status){ let select=maritalColumn.filter(item=>{return item.value==data.marital_status}); this.setData({ 'marital_name':select[0].text }) }; Object.keys(data).forEach(function(key){ if(key=="weight" || key=="height" || key=="marital_status" || key=="nation_id" || key=="job_id"){ arr1.push(key); }else{ arr2.push(key); } }) this.commonMethods(arr1,arr2); } if(options.params){ let data=JSON.parse(options.params); let {obj}=this.data; let arr1=[]; let arr2=[]; data.forEach(item => { if(item=="weight" || item=="height" || item=="marital_status" || item=="nation_id" || item=="job_id"){ arr1.push(item); }else{ arr2.push(item); } }) this.commonMethods(arr1,arr2); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, getNation(){ nation().then(data=>{ this.setData({ nationcolumns:data }) let {personInfo}=this.data; if(personInfo.nation_id || personInfo.nation_id==0){ let select=data.filter(item=>{return item.nation_id==personInfo.nation_id}); this.setData({ 'nationname':select[0].nation_name }) } }) }, getJob(){ job().then(data=>{ this.setData({ jobcolumns:data }) let {personInfo}=this.data; if(personInfo.job_id || personInfo.job_id==0){ let select=data.filter(item=>{return item.job_id==personInfo.job_id}); this.setData({ 'jobname':select[0].job_name }) } }) }, /** * 生命周期函数--监听页面显示 */ onShow() { this.setData({ img_host:app.hostConfig().imghost }); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })