index.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. // 慢阻肺患者档案-编辑
  2. var template = ''
  3. $.ajax('../../../component/statistics/CopdPatientRecordEdit/index.html', {
  4. data: {},
  5. dataType: 'html',
  6. cache: false,
  7. timeout: 60000,
  8. async: false,
  9. error: function (res) {},
  10. success: function (res) {
  11. template = res
  12. }
  13. })
  14. let vm
  15. Vue.component('copd-patient-record-edit', {
  16. template: template,
  17. props: ['editData'],
  18. data() {
  19. return {
  20. formData: {},
  21. nationDict: [],
  22. dicName: [
  23. 'jkcopd_followup_status',
  24. 'jkcopd_isLive',
  25. 'jkcopd_first_area',
  26. 'jkcopd_first_org_level',
  27. 'jkcopd_marriage',
  28. 'jkcopd_occupation',
  29. 'jkcopd_smoke',
  30. 'jkcopd_drink',
  31. 'jkcopd_archivesStatus',
  32. 'jkcopd_disease_conversion',
  33. 'jkcopd_firstVisitType',
  34. 'jkcopd_educational',
  35. 'idCardType'
  36. ],
  37. marriageArr: [],
  38. followupArr: [],
  39. idCardTypeArr: [],
  40. firstAreaArr: [],
  41. isLiveArr: [],
  42. orgLevelArr: [],
  43. occupationArr: [],
  44. smokeArr: [],
  45. drinkArr: [],
  46. archivesArr: [],
  47. conversionArr: [],
  48. firstVisitTypeArr: [],
  49. educationalArr: [],
  50. copdArr: [
  51. { value: '是', code: '1' },
  52. { value: '否', code: '0' }
  53. ],
  54. addressOptions1: [],
  55. addressOptions2: [],
  56. addressOptions3: [],
  57. props: {
  58. label: 'name',
  59. value: 'code',
  60. children: 'children'
  61. },
  62. addressVal: [],
  63. resiginAddressVal: [],
  64. diagnosisAddressVal: [],
  65. docInfo: JSON.parse(window.localStorage.getItem('docInfo')),
  66. rules: {
  67. mobile: [
  68. { required: true, message: '请输入联系方式', trigger: 'blur' },
  69. { min: 11, max: 11, message: '请输入正确的联系方式', trigger: 'blur' }
  70. ]
  71. },
  72. areaType: 1 // 用于区分是普通地址选择器还是首次诊断地区选择器,诊断地区选择器只到区,并且新增不详区,1:普通 2:特殊
  73. }
  74. },
  75. created() {
  76. vm = this
  77. },
  78. watch: {
  79. 'formData.isLive': {
  80. handler: function (o) {
  81. if (o == '1') {
  82. this.formData.deathTime = ''
  83. this.formData.deathReason = ''
  84. }
  85. },
  86. deep: true,
  87. immediate: true
  88. },
  89. // addressOptions:{
  90. // handler(nv){
  91. // console.log("addressOptions",nv);
  92. // },
  93. // deep: true
  94. // }
  95. },
  96. mounted() {
  97. var vm = this
  98. this.formData = JSON.parse(window.localStorage.getItem('editDetail'))
  99. this.getDetail()
  100. if (this.formData.liveStreet) {
  101. this.addressVal = [this.formData.liveProvince, this.formData.liveCity, this.formData.liveTown, this.formData.liveStreet]
  102. this.getDistrict(1)
  103. } else {
  104. this.addressVal = [this.formData.liveProvince, this.formData.liveCity, this.formData.liveTown]
  105. this.getDistrict(1)
  106. }
  107. this.getNation()
  108. if (this.formData.registStreet) {
  109. this.resiginAddressVal = [this.formData.registProvince, this.formData.registCity, this.formData.registTown, this.formData.registStreet]
  110. this.getDistrict(2)
  111. } else {
  112. this.resiginAddressVal = [this.formData.registProvince, this.formData.registCity, this.formData.registTown]
  113. this.getDistrict(2)
  114. }
  115. this.dicName.forEach(function (item) {
  116. vm.getDictByDictName(item)
  117. })
  118. },
  119. methods: {
  120. getDetail(){
  121. var vm = this
  122. statisticAPI.jkCopdPatientDetail({ id: this.formData.id}).then(function(res){
  123. var jkcopdPatientExpend = res.obj.jkcopdPatientExpend
  124. vm.formData.jkcopdPatientExpend = jkcopdPatientExpend
  125. vm.diagnosisAddressVal = [jkcopdPatientExpend.firstVisitProvince,jkcopdPatientExpend.firstVisitCity,jkcopdPatientExpend.firstVisitTown]
  126. vm.getDistrict(3)
  127. })
  128. },
  129. handleItemChange(val, type) {
  130. this.areaType = type
  131. // 获取地址
  132. if (val.length == 1) {
  133. // 获取市
  134. this.baseCityList(val[0])
  135. }
  136. if (val.length == 2) {
  137. // 获取区
  138. this.baseTownList(val)
  139. }
  140. if (val.length == 3&&type != 3) {
  141. // 获取区
  142. this.stressList(val)
  143. }
  144. },
  145. //字典
  146. getDictByDictName(value) {
  147. var vm = this
  148. statisticAPI.getDictByDictName({ name: value }).then(function (res) {
  149. if (value == 'jkcopd_marriage') {
  150. vm.marriageArr = res.list
  151. } else if (value == 'jkcopd_occupation') {
  152. vm.occupationArr = res.list
  153. } else if (value == 'jkcopd_smoke') {
  154. vm.smokeArr = res.list
  155. } else if (value == 'jkcopd_drink') {
  156. vm.drinkArr = res.list
  157. } else if (value == 'jkcopd_archivesStatus') {
  158. vm.archivesArr = res.list
  159. } else if (value == 'jkcopd_disease_conversion') {
  160. vm.conversionArr = res.list
  161. } else if (value == 'jkcopd_firstVisitType') {
  162. vm.firstVisitTypeArr = res.list
  163. } else if (value == 'jkcopd_educational') {
  164. vm.educationalArr = res.list
  165. } else if (value == 'idCardType') {
  166. vm.idCardTypeArr = res.list
  167. } else if (value == 'jkcopd_first_area') {
  168. vm.firstAreaArr = res.list
  169. } else if (value == 'jkcopd_first_org_level') {
  170. vm.orgLevelArr = res.list
  171. } else if (value == 'jkcopd_isLive') {
  172. vm.isLiveArr = res.list
  173. } else if (value == 'jkcopd_followup_status') {
  174. vm.followupArr = res.list
  175. }
  176. })
  177. },
  178. getNation() {
  179. var vm = this
  180. statisticAPI.getNationDict().then(function (res) {
  181. vm.nationDict = res.data
  182. })
  183. },
  184. getDistrict(id) {
  185. var vm = this
  186. homeAPI.getDistrict({ type: 1, code: '' }).then(function (res) {
  187. var detailModelList = res.list
  188. detailModelList.forEach(function (item) {
  189. item.children = []
  190. })
  191. vm['addressOptions'+ id] = JSON.parse(JSON.stringify(detailModelList))
  192. console.log(vm['addressOptions'+ id],"vm['addressOptions'+ id]");
  193. if (vm.formData.liveProvince && id == 1) {
  194. vm.baseCityList(vm.formData.liveProvince, id)
  195. }
  196. if (vm.formData.registProvince && id == 2) {
  197. vm.baseCityList(vm.formData.registProvince, id)
  198. }
  199. if(vm.diagnosisAddressVal[0] && id == 3){
  200. vm.baseCityList(vm.diagnosisAddressVal[0], id)
  201. }
  202. })
  203. },
  204. onClickNavLink(id) {
  205. var element = document.getElementById(id)
  206. var top = element.offsetTop
  207. window.scrollTo({ top: top, behavior: 'smooth' })
  208. },
  209. //市
  210. baseCityList: function (code, id) {
  211. var vm = this
  212. var activeIndex = null
  213. var num = id
  214. if(!num){
  215. num = this.areaType
  216. }
  217. var arr = vm['addressOptions' + num]
  218. arr.forEach(function (item, index) {
  219. if (item.code == code) {
  220. activeIndex = index
  221. }
  222. })
  223. homeAPI.getDistrict({ type: 2, code: code }).then(function (res) {
  224. if (res.status == 200) {
  225. var detailModelList = res.list
  226. detailModelList.forEach(item => {
  227. item.children = []
  228. })
  229. arr[activeIndex].children = detailModelList
  230. if (vm.addressVal.length && id == 1) {
  231. vm.baseTownList([vm.addressVal[0], vm.addressVal[1]], id)
  232. }
  233. if (vm.resiginAddressVal.length && id == 2) {
  234. vm.baseTownList([vm.resiginAddressVal[0], vm.resiginAddressVal[1]], id)
  235. }
  236. if(vm.diagnosisAddressVal.length && id == 3){
  237. vm.baseTownList([vm.diagnosisAddressVal[0], vm.diagnosisAddressVal[1]], id)
  238. }
  239. }
  240. })
  241. },
  242. //县
  243. baseTownList(val, id) {
  244. var vm = this
  245. var provinceIndex = null
  246. var activeIndex = null
  247. var arr = vm['addressOptions' + id]
  248. arr.forEach(function (item, index) {
  249. if (item.code == val[0]) {
  250. var children = item.children
  251. provinceIndex = index
  252. children.forEach(function (item, idx) {
  253. if (item.code == val[1]) {
  254. activeIndex = idx
  255. }
  256. })
  257. }
  258. })
  259. homeAPI.getDistrict({ type: 3, code: val[1] }).then(function (res) {
  260. if (res.status == 200) {
  261. var detailModelList = res.list
  262. if (val[1] == '350200'&& id == 3) {
  263. var detailModelList = res.list.concat({ code: '350299', name: '不详区', city: '350200', province: '350000', id: 99999 })
  264. }
  265. for(let item of detailModelList){
  266. if(id == 3){
  267. item.children = null
  268. }else{
  269. item.children = []
  270. }
  271. }
  272. if (arr[provinceIndex].children[activeIndex]) {
  273. arr[provinceIndex].children[activeIndex].children = detailModelList
  274. if(id == 3)return
  275. if (vm.addressVal.length && id == 1) {
  276. vm.stressList([vm.addressVal[0], vm.addressVal[1], vm.addressVal[2]],id)
  277. }
  278. if (vm.resiginAddressVal.length && id == 2) {
  279. vm.stressList([vm.resiginAddressVal[0], vm.resiginAddressVal[1], vm.resiginAddressVal[2]],id)
  280. }
  281. }
  282. }
  283. })
  284. },
  285. //街道
  286. stressList(val, id) {
  287. var vm = this
  288. var provinceIndex = null
  289. var activeIndex = null
  290. var xIndex = null
  291. var arr = vm['addressOptions' + id]
  292. arr.forEach(function (item, index) {
  293. if (item.code == val[0]) {
  294. var children = item.children
  295. provinceIndex = index
  296. children.forEach(function (item, idx) {
  297. if (item.code == val[1]) {
  298. activeIndex = idx
  299. var xItem = item.children
  300. xItem.forEach(function (item, xianIndex) {
  301. if (item.code == val[2]) {
  302. xIndex = xianIndex
  303. }
  304. })
  305. }
  306. })
  307. }
  308. })
  309. homeAPI.getDistrict({ type: 4, code: val[2] }).then(function (res) {
  310. if (res.status == 200) {
  311. var detailModelList = res.list
  312. if (arr[provinceIndex].children[activeIndex].children[xIndex]) {
  313. arr[provinceIndex].children[activeIndex].children[xIndex].children = detailModelList
  314. }
  315. }
  316. })
  317. },
  318. cancel: function () {
  319. EventBus.$emit('copd-reset-select')
  320. },
  321. updJkCopdPatient() {
  322. var vm = this
  323. this.$refs.ruleForm.validate(function (valid) {
  324. if (valid) {
  325. if (!vm.formData.mobile) {
  326. this.$message.error('请填写联系方式!')
  327. return false
  328. }
  329. if (vm.formData.sexName == '男') {
  330. vm.formData.sex = 1
  331. } else {
  332. vm.formData.sex = 2
  333. }
  334. if (vm.addressVal.length) {
  335. vm.addressVal.forEach(function (item, index) {
  336. if (index == 0) {
  337. vm.formData.liveProvince = item
  338. vm.formData.liveProvinceName = vm.$refs.cascader.currentLabels[index]
  339. } else if (index == 1) {
  340. vm.formData.liveCity = item
  341. vm.formData.liveCityName = vm.$refs.cascader.currentLabels[index]
  342. } else if (index == 2) {
  343. vm.formData.liveTown = item
  344. vm.formData.liveTownName = vm.$refs.cascader.currentLabels[index]
  345. } else if (index == 3) {
  346. vm.formData.liveStreet = item
  347. vm.formData.liveStreetName = vm.$refs.cascader.currentLabels[index]
  348. }
  349. })
  350. } else {
  351. vm.formData.liveProvince = ''
  352. vm.formData.liveProvinceName = ''
  353. vm.formData.liveCity = ''
  354. vm.formData.liveCityName = ''
  355. vm.formData.liveTown = ''
  356. vm.formData.liveTownName = ''
  357. vm.formData.liveStreet = ''
  358. vm.formData.liveStreetName = ''
  359. }
  360. if (vm.resiginAddressVal.length) {
  361. vm.resiginAddressVal.forEach(function (item, index) {
  362. if (index == 0) {
  363. vm.formData.registProvince = item
  364. vm.formData.registProvinceName = vm.$refs.cas.currentLabels[index]
  365. } else if (index == 1) {
  366. vm.formData.registCity = item
  367. vm.formData.registCityName = vm.$refs.cas.currentLabels[index]
  368. } else if (index == 2) {
  369. vm.formData.registTown = item
  370. vm.formData.registTownName = vm.$refs.cas.currentLabels[index]
  371. } else if (index == 3) {
  372. vm.formData.registStreet = item
  373. vm.formData.registStreetName = vm.$refs.cas.currentLabels[index]
  374. }
  375. })
  376. } else {
  377. vm.formData.registProvince = ''
  378. vm.formData.registProvinceName = ''
  379. vm.formData.registCity = ''
  380. vm.formData.registCityName = ''
  381. vm.formData.registTown = ''
  382. vm.formData.registTownName = ''
  383. vm.formData.registStreet = ''
  384. vm.formData.registStreetName = ''
  385. }
  386. if(vm.diagnosisAddressVal.length){
  387. var address = ""
  388. vm.diagnosisAddressVal.forEach(function (item, index) {
  389. if (index == 0) {
  390. vm.formData.jkcopdPatientExpend.firstVisitProvince = item
  391. vm.formData.jkcopdPatientExpend.firstVisitProvinceName = vm.$refs.diagnosis.currentLabels[index]
  392. address += vm.$refs.diagnosis.currentLabels[index]
  393. } else if (index == 1) {
  394. vm.formData.jkcopdPatientExpend.firstVisitCity = item
  395. vm.formData.jkcopdPatientExpend.firstVisitCityName = vm.$refs.diagnosis.currentLabels[index]
  396. address += vm.$refs.diagnosis.currentLabels[index]
  397. } else if (index == 2) {
  398. vm.formData.jkcopdPatientExpend.firstVisitTown = item
  399. vm.formData.jkcopdPatientExpend.firstVisitTownName = vm.$refs.diagnosis.currentLabels[index]
  400. address += vm.$refs.diagnosis.currentLabels[index]
  401. }
  402. })
  403. vm.formData.firstVisitArea = address
  404. }
  405. statisticAPI.updJkCopdPatient({ jsonData: JSON.stringify(vm.formData), doctor: vm.docInfo.code }).then(function (res) {
  406. if (res.status == 200) {
  407. EventBus.$emit('copd-reset-save')
  408. }
  409. })
  410. } else {
  411. vm.$message.error('请填写联系方式!')
  412. window.scrollTo({ top: top, behavior: 'smooth' })
  413. }
  414. })
  415. return false
  416. }
  417. }
  418. })