// 慢阻肺患者档案-编辑 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' } ], addressOptions1: [], addressOptions2: [], addressOptions3: [], props: { label: 'name', value: 'code', children: 'children', }, addressVal: [], resiginAddressVal: [], diagnosisAddressVal: [], docInfo: JSON.parse(window.localStorage.getItem('docInfo')), rules: { mobile: [ { required: true, message: '请输入联系方式', trigger: 'blur' }, { min: 11, max: 11, message: '请输入正确的联系方式', trigger: 'blur' } ] }, areaType: 1 // 用于区分是普通地址选择器还是首次诊断地区选择器,诊断地区选择器只到区,并且新增不详区,1:普通 2:特殊 } }, created() { vm = this }, watch: { 'formData.isLive': { handler: function (o) { if (o == '1') { this.formData.deathTime = '' this.formData.deathReason = '' } }, deep: true, immediate: true }, // addressOptions:{ // handler(nv){ // console.log("addressOptions",nv); // }, // deep: true // } }, mounted() { var vm = this this.formData = JSON.parse(window.localStorage.getItem('editDetail')) this.getDetail() if (this.formData.liveStreet) { this.addressVal = [this.formData.liveProvince, this.formData.liveCity, this.formData.liveTown, this.formData.liveStreet] this.getDistrict(1) } else { this.addressVal = [this.formData.liveProvince, this.formData.liveCity, this.formData.liveTown] this.getDistrict(1) } this.getNation() if (this.formData.registStreet) { this.resiginAddressVal = [this.formData.registProvince, this.formData.registCity, this.formData.registTown, this.formData.registStreet] this.getDistrict(2) } else { this.resiginAddressVal = [this.formData.registProvince, this.formData.registCity, this.formData.registTown] this.getDistrict(2) } this.dicName.forEach(function (item) { vm.getDictByDictName(item) }) }, methods: { getDetail(){ var vm = this statisticAPI.jkCopdPatientDetail({ id: this.formData.id}).then(function(res){ var jkcopdPatientExpend = res.obj.jkcopdPatientExpend vm.formData.jkcopdPatientExpend = jkcopdPatientExpend vm.diagnosisAddressVal = [jkcopdPatientExpend.firstVisitProvince,jkcopdPatientExpend.firstVisitCity,jkcopdPatientExpend.firstVisitTown] vm.getDistrict(3) }) }, handleItemChange(val, type) { this.areaType = type // 获取地址 if (val.length == 1) { // 获取市 this.baseCityList(val[0]) } if (val.length == 2) { // 获取区 this.baseTownList(val) } if (val.length == 3&&type != 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'+ id] = JSON.parse(JSON.stringify(detailModelList)) console.log(vm['addressOptions'+ id],"vm['addressOptions'+ id]"); if (vm.formData.liveProvince && id == 1) { vm.baseCityList(vm.formData.liveProvince, id) } if (vm.formData.registProvince && id == 2) { vm.baseCityList(vm.formData.registProvince, id) } if(vm.diagnosisAddressVal[0] && id == 3){ vm.baseCityList(vm.diagnosisAddressVal[0], 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 var num = id if(!num){ num = this.areaType } var arr = vm['addressOptions' + num] arr.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 = [] }) arr[activeIndex].children = detailModelList if (vm.addressVal.length && id == 1) { vm.baseTownList([vm.addressVal[0], vm.addressVal[1]], id) } if (vm.resiginAddressVal.length && id == 2) { vm.baseTownList([vm.resiginAddressVal[0], vm.resiginAddressVal[1]], id) } if(vm.diagnosisAddressVal.length && id == 3){ vm.baseTownList([vm.diagnosisAddressVal[0], vm.diagnosisAddressVal[1]], id) } } }) }, //县 baseTownList(val, id) { var vm = this var provinceIndex = null var activeIndex = null var num = id if(!num){ num = this.areaType } var arr = vm['addressOptions' + num] arr.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'&& num == 3) { var detailModelList = res.list.concat({ code: '350299', name: '不详区', city: '350200', province: '350000', id: 99999 }) } for(let item of detailModelList){ if(num == 3){ item.children = null }else{ item.children = [] } } if (arr[provinceIndex].children[activeIndex]) { arr[provinceIndex].children[activeIndex].children = detailModelList if(num == 3)return if (vm.addressVal.length && id == 1) { vm.stressList([vm.addressVal[0], vm.addressVal[1], vm.addressVal[2]],id) } if (vm.resiginAddressVal.length && id == 2) { vm.stressList([vm.resiginAddressVal[0], vm.resiginAddressVal[1], vm.resiginAddressVal[2]],id) } } } }) }, //街道 stressList(val, id) { var vm = this var provinceIndex = null var activeIndex = null var xIndex = null var num = id if(!num){ num = this.areaType } var arr = vm['addressOptions' + num] arr.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 (arr[provinceIndex].children[activeIndex].children[xIndex]) { if(detailModelList.length >0){ arr[provinceIndex].children[activeIndex].children[xIndex].children = detailModelList }else{ arr[provinceIndex].children[activeIndex].children[xIndex].children = null } } } }) }, 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 = '' } if(vm.diagnosisAddressVal.length){ var address = "" vm.diagnosisAddressVal.forEach(function (item, index) { if (index == 0) { vm.formData.jkcopdPatientExpend.firstVisitProvince = item vm.formData.jkcopdPatientExpend.firstVisitProvinceName = vm.$refs.diagnosis.currentLabels[index] address += vm.$refs.diagnosis.currentLabels[index] } else if (index == 1) { vm.formData.jkcopdPatientExpend.firstVisitCity = item vm.formData.jkcopdPatientExpend.firstVisitCityName = vm.$refs.diagnosis.currentLabels[index] address += vm.$refs.diagnosis.currentLabels[index] } else if (index == 2) { vm.formData.jkcopdPatientExpend.firstVisitTown = item vm.formData.jkcopdPatientExpend.firstVisitTownName = vm.$refs.diagnosis.currentLabels[index] address += vm.$refs.diagnosis.currentLabels[index] } }) vm.formData.firstVisitArea = address } 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(res.message) } }) } else { vm.$message.error('请填写联系方式!') window.scrollTo({ top: top, behavior: 'smooth' }) } }) return false } } })