// 慢阻肺患者档案-编辑 var template = '' $.ajax('../../../component/statistics/CopdPatientRecordEdit/index.html',{ data: {}, dataType: 'html', cache: false, timeout: 60000, async: false, error: function(res) { }, success: function(res) { template = res } }) let vm Vue.component('copd-patient-record-edit', { template: template, props: ['editData'], data() { return { formData:{}, nationDict:[], dicName:['jkcopd_followup_status','jkcopd_isLive','jkcopd_first_area','jkcopd_first_org_level', 'jkcopd_marriage','jkcopd_occupation','jkcopd_smoke','jkcopd_drink','jkcopd_archivesStatus','jkcopd_disease_conversion','jkcopd_firstVisitType','jkcopd_educational','idCardType'], marriageArr:[], followupArr:[], idCardTypeArr:[], firstAreaArr:[], isLiveArr:[], orgLevelArr:[], occupationArr:[], smokeArr:[], drinkArr:[], archivesArr:[], conversionArr:[], firstVisitTypeArr:[], educationalArr:[], copdArr:[{value:'是',code:'1'},{value:'否',code:'0'}], addressOptions:[], props: { label: 'name', value: 'code', children: 'children' }, addressVal:[], resiginAddressVal:[], docInfo: JSON.parse(window.localStorage.getItem('docInfo')), rules: { mobile:[ { required: true, message: '请输入联系方式', trigger: 'blur' }, { min: 11, max: 11, message: '请输入正确的联系方式', trigger: 'blur' } ] } } }, created() { vm=this }, watch:{ 'formData.isLive':{ handler:function(o) { if(o=='1'){ this.formData.deathTime='' this.formData.deathReason='' } }, deep: true, immediate: true }, addressVal(value){ console.log(value,'0000000000000000000000') } }, mounted() { var vm=this this.formData= JSON.parse(window.localStorage.getItem('editDetail')) console.log(this.formData,'00000000000000000000000000000') if(this.formData.liveStreet){ this.addressVal=[this.formData.liveProvince,this.formData.liveCity,this.formData.liveTown,this.formData.liveStreet] this.getDistrict(0) }else{ this.addressVal=[this.formData.liveProvince,this.formData.liveCity,this.formData.liveTown] this.getDistrict(0) } this.getNation() if(this.formData.liveStreet){ this.resiginAddressVal=[this.formData.registProvince,this.formData.registCity,this.formData.registTown,this.formData.registStreet] this.getDistrict(1) }else{ this.resiginAddressVal=[this.formData.registProvince,this.formData.registCity,this.formData.registTown] this.getDistrict(1) } this.dicName.forEach(function(item) { vm.getDictByDictName(item) }); }, methods: { handleItemChange(val) { // 获取地址 if (val.length == 1) { // 获取市 this.baseCityList(val[0]) } if (val.length == 2) { // 获取区 this.baseTownList(val) } if (val.length == 3) { // 获取区 this.stressList(val) } }, //字典 getDictByDictName(value){ var vm=this statisticAPI.getDictByDictName({name:value}).then(function(res){ if(value=='jkcopd_marriage'){ vm.marriageArr=res.list }else if(value=='jkcopd_occupation'){ vm.occupationArr=res.list }else if(value=='jkcopd_smoke'){ vm.smokeArr=res.list }else if(value=='jkcopd_drink'){ vm.drinkArr=res.list }else if(value=='jkcopd_archivesStatus'){ vm.archivesArr=res.list }else if(value=='jkcopd_disease_conversion'){ vm.conversionArr=res.list }else if(value=='jkcopd_firstVisitType'){ vm.firstVisitTypeArr=res.list }else if(value=='jkcopd_educational'){ vm.educationalArr=res.list }else if(value=='idCardType'){ vm.idCardTypeArr=res.list }else if(value=='jkcopd_first_area'){ vm.firstAreaArr=res.list }else if(value=='jkcopd_first_org_level'){ vm.orgLevelArr=res.list }else if(value=='jkcopd_isLive'){ vm.isLiveArr=res.list }else if(value=='jkcopd_followup_status'){ vm.followupArr=res.list } }) }, getNation(){ var vm=this statisticAPI.getNationDict().then(function(res){ vm.nationDict= res.data }) }, getDistrict(id){ var vm =this homeAPI.getDistrict({ type:1 ,code:'' }).then(function(res) { var detailModelList=res.list detailModelList.forEach(function(item){ item.children = [] }) vm.addressOptions=detailModelList if(vm.formData.liveProvince&&id==0){ vm.baseCityList(vm.formData.liveProvince,id) } if(vm.formData.registProvince&&id==1){ vm.baseCityList(vm.formData.registProvince,id) } }) }, onClickNavLink(id) { var element = document.getElementById(id); var top = element.offsetTop; window.scrollTo({ top: top, behavior: 'smooth' }); }, //市 baseCityList:function(code,id){ var vm = this var activeIndex = null vm.addressOptions.forEach(function(item, index) { if (item.code == code) { activeIndex = index } }) homeAPI.getDistrict({ type:2 ,code:code }).then(function(res) { if (res.status == 200) { var detailModelList = res.list detailModelList.forEach(item => { item.children = [] }) vm.addressOptions[activeIndex].children = detailModelList if(vm.addressVal.length&&id==0){ vm.baseTownList([vm.addressVal[0], vm.addressVal[1]],id) } if(vm.resiginAddressVal.length&&id==1){ vm.baseTownList([vm.resiginAddressVal[0], vm.resiginAddressVal[1]],id) } } }) }, //县 baseTownList(val,id) { var vm = this var provinceIndex = null var activeIndex = null vm.addressOptions.forEach(function(item, index){ if (item.code == val[0]) { var children = item.children provinceIndex = index children.forEach(function(item, idx) { if (item.code == val[1]) { activeIndex = idx } }) } }) homeAPI.getDistrict({ type:3,code:val[1] }).then( function(res){ if (res.status == 200) { var detailModelList = res.list if(val[1]=='350200'){ detailModelList.forEach(function(item){ item.children = [] }) } if (vm.addressOptions[provinceIndex].children[activeIndex]) { vm.addressOptions[provinceIndex].children[activeIndex].children = detailModelList if(vm.addressVal.length&&id==0){ vm.stressList([vm.addressVal[0], vm.addressVal[1],vm.addressVal[2]]) } if(vm.resiginAddressVal.length&&id==1){ vm.stressList([vm.resiginAddressVal[0], vm.resiginAddressVal[1],vm.resiginAddressVal[2]]) } } } }) }, //街道 stressList(val) { var vm = this var provinceIndex = null var activeIndex = null var xIndex=null vm.addressOptions.forEach(function(item, index) { if (item.code == val[0]) { var children = item.children provinceIndex = index children.forEach(function(item, idx) { if (item.code == val[1]) { activeIndex = idx var xItem=item.children xItem.forEach(function(item,xianIndex){ if(item.code==val[2]){ xIndex=xianIndex } }) } }) } }) homeAPI.getDistrict({ type:4,code:val[2] }).then( function(res){ if (res.status == 200) { var detailModelList = res.list if (vm.addressOptions[provinceIndex].children[activeIndex].children[xIndex]) { vm.addressOptions[provinceIndex].children[activeIndex].children[xIndex].children = detailModelList } } }) }, cancel:function(){ EventBus.$emit('copd-reset-select') }, updJkCopdPatient(){ var vm =this this.$refs.ruleForm.validate(function(valid){ if(valid){ if(!vm.formData.mobile){ this.$message.error('请填写联系方式!') return false } if(vm.formData.sexName=='男'){ vm.formData.sex=1 }else{ vm.formData.sex=2 } if(vm.addressVal.length){ vm.addressVal.forEach(function(item,index){ if(index==0){ vm.formData.liveProvince=item vm.formData.liveProvinceName=vm.$refs.cascader.currentLabels[index] }else if(index==1){ vm.formData.liveCity=item vm.formData.liveCityName=vm.$refs.cascader.currentLabels[index] }else if(index==2){ vm.formData.liveTown=item vm.formData.liveTownName=vm.$refs.cascader.currentLabels[index] }else if(index==3){ vm.formData.liveStreet=item vm.formData.liveStreetName=vm.$refs.cascader.currentLabels[index] } }) }else{ vm.formData.liveProvince='' vm.formData.liveProvinceName='' vm.formData.liveCity='' vm.formData.liveCityName='' vm.formData.liveTown='' vm.formData.liveTownName='' vm.formData.liveStreet='' vm.formData.liveStreetName='' } if(vm.resiginAddressVal.length){ vm.resiginAddressVal.forEach(function(item,index){ if(index==0){ vm.formData.registProvince=item vm.formData.registProvinceName=vm.$refs.cas.currentLabels[index] }else if(index==1){ vm.formData.registCity=item vm.formData.registCityName=vm.$refs.cas.currentLabels[index] }else if(index==2){ vm.formData.registTown=item vm.formData.registTownName=vm.$refs.cas.currentLabels[index] }else if(index==3){ vm.formData.registStreet=item vm.formData.registStreetName=vm.$refs.cas.currentLabels[index] } }) }else{ vm.formData.registProvince='' vm.formData.registProvinceName='' vm.formData.registCity='' vm.formData.registCityName='' vm.formData.registTown='' vm.formData.registTownName='' vm.formData.registStreet='' vm.formData.registStreetName='' } statisticAPI.updJkCopdPatient({jsonData:JSON.stringify(vm.formData),doctor:vm.docInfo.code}).then( function(res){ if(res.status==200){ EventBus.$emit('copd-reset-save') } } ) }else{ vm.$message.error('请填写联系方式!') window.scrollTo({ top: top, behavior: 'smooth' }); } }) return false } } });