123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449 |
- // 慢阻肺患者档案-编辑
- 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
- }
- }
- })
|