index.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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],['addressOptions'+ id]);
  193. if (vm.formData.liveProvince && id == 1) {
  194. console.log(1);
  195. vm.baseCityList(vm.formData.liveProvince, id)
  196. }
  197. if (vm.formData.registProvince && id == 2) {
  198. vm.baseCityList(vm.formData.registProvince, id)
  199. }
  200. if(vm.diagnosisAddressVal[0] && id == 3){
  201. vm.baseCityList(vm.diagnosisAddressVal[0], id)
  202. }
  203. })
  204. },
  205. onClickNavLink(id) {
  206. var element = document.getElementById(id)
  207. var top = element.offsetTop
  208. window.scrollTo({ top: top, behavior: 'smooth' })
  209. },
  210. //市
  211. baseCityList: function (code, id) {
  212. var vm = this
  213. var activeIndex = null
  214. var num = id
  215. if(!num){
  216. num = this.areaType
  217. }
  218. var arr = vm['addressOptions' + num]
  219. arr.forEach(function (item, index) {
  220. if (item.code == code) {
  221. activeIndex = index
  222. }
  223. })
  224. homeAPI.getDistrict({ type: 2, code: code }).then(function (res) {
  225. if (res.status == 200) {
  226. var detailModelList = res.list
  227. detailModelList.forEach(item => {
  228. item.children = []
  229. })
  230. arr[activeIndex].children = detailModelList
  231. if (vm.addressVal.length && id == 1) {
  232. console.log(2);
  233. vm.baseTownList([vm.addressVal[0], vm.addressVal[1]], id)
  234. }
  235. if (vm.resiginAddressVal.length && id == 2) {
  236. vm.baseTownList([vm.resiginAddressVal[0], vm.resiginAddressVal[1]], id)
  237. }
  238. if(vm.diagnosisAddressVal.length && id == 3){
  239. vm.baseTownList([vm.diagnosisAddressVal[0], vm.diagnosisAddressVal[1]], id)
  240. }
  241. }
  242. })
  243. },
  244. //县
  245. baseTownList(val, id) {
  246. var vm = this
  247. var provinceIndex = null
  248. var activeIndex = null
  249. var num = id
  250. if(!num){
  251. num = this.areaType
  252. }
  253. var arr = vm['addressOptions' + num]
  254. arr.forEach(function (item, index) {
  255. if (item.code == val[0]) {
  256. var children = item.children
  257. provinceIndex = index
  258. children.forEach(function (item, idx) {
  259. if (item.code == val[1]) {
  260. activeIndex = idx
  261. }
  262. })
  263. }
  264. })
  265. homeAPI.getDistrict({ type: 3, code: val[1] }).then(function (res) {
  266. if (res.status == 200) {
  267. var detailModelList = res.list
  268. if (val[1] == '350200'&& num == 3) {
  269. var detailModelList = res.list.concat({ code: '350299', name: '不详区', city: '350200', province: '350000', id: 99999 })
  270. }
  271. for(let item of detailModelList){
  272. if(num == 3){
  273. item.children = null
  274. }else{
  275. item.children = []
  276. }
  277. }
  278. if (arr[provinceIndex].children[activeIndex]) {
  279. arr[provinceIndex].children[activeIndex].children = detailModelList
  280. if(num == 3)return
  281. if (vm.addressVal.length && id == 1) {
  282. console.log(3);
  283. vm.stressList([vm.addressVal[0], vm.addressVal[1], vm.addressVal[2]],id)
  284. }
  285. if (vm.resiginAddressVal.length && id == 2) {
  286. vm.stressList([vm.resiginAddressVal[0], vm.resiginAddressVal[1], vm.resiginAddressVal[2]],id)
  287. }
  288. }
  289. }
  290. })
  291. },
  292. //街道
  293. stressList(val, id) {
  294. var vm = this
  295. var provinceIndex = null
  296. var activeIndex = null
  297. var xIndex = null
  298. var num = id
  299. if(!num){
  300. num = this.areaType
  301. }
  302. var arr = vm['addressOptions' + num]
  303. arr.forEach(function (item, index) {
  304. if (item.code == val[0]) {
  305. var children = item.children
  306. provinceIndex = index
  307. children.forEach(function (item, idx) {
  308. if (item.code == val[1]) {
  309. activeIndex = idx
  310. var xItem = item.children
  311. xItem.forEach(function (item, xianIndex) {
  312. if (item.code == val[2]) {
  313. xIndex = xianIndex
  314. }
  315. })
  316. }
  317. })
  318. }
  319. })
  320. console.log(val,provinceIndex,activeIndex, xIndex);
  321. homeAPI.getDistrict({ type: 4, code: val[2] }).then(function (res) {
  322. if (res.status == 200) {
  323. var detailModelList = res.list
  324. if (arr[provinceIndex].children[activeIndex].children[xIndex]) {
  325. if(detailModelList.length >0){
  326. arr[provinceIndex].children[activeIndex].children[xIndex].children = detailModelList
  327. }else{
  328. arr[provinceIndex].children[activeIndex].children[xIndex].children = null
  329. }
  330. }
  331. }
  332. })
  333. },
  334. cancel: function () {
  335. EventBus.$emit('copd-reset-select')
  336. },
  337. updJkCopdPatient() {
  338. var vm = this
  339. this.$refs.ruleForm.validate(function (valid) {
  340. if (valid) {
  341. if (!vm.formData.mobile) {
  342. this.$message.error('请填写联系方式!')
  343. return false
  344. }
  345. if (vm.formData.sexName == '男') {
  346. vm.formData.sex = 1
  347. } else {
  348. vm.formData.sex = 2
  349. }
  350. console.log(vm.addressVal,vm.addressVal.length);
  351. if (vm.addressVal.length) {
  352. vm.addressVal.forEach(function (item, index) {
  353. var pathNode = vm.$refs.cascader.getCheckedNodes()[0].pathNodes
  354. console.log(pathNode);
  355. if (index == 0) {
  356. vm.formData.liveProvince = item
  357. vm.formData.liveProvinceName = pathNode[index].label
  358. } else if (index == 1) {
  359. vm.formData.liveCity = item
  360. vm.formData.liveCityName = pathNode[index].label
  361. } else if (index == 2) {
  362. vm.formData.liveTown = item
  363. vm.formData.liveTownName = pathNode[index].label
  364. } else if (index == 3) {
  365. vm.formData.liveStreet = item
  366. vm.formData.liveStreetName = pathNode[index].label
  367. }
  368. })
  369. } else {
  370. vm.formData.liveProvince = ''
  371. vm.formData.liveProvinceName = ''
  372. vm.formData.liveCity = ''
  373. vm.formData.liveCityName = ''
  374. vm.formData.liveTown = ''
  375. vm.formData.liveTownName = ''
  376. vm.formData.liveStreet = ''
  377. vm.formData.liveStreetName = ''
  378. }
  379. if (vm.resiginAddressVal.length) {
  380. vm.resiginAddressVal.forEach(function (item, index) {
  381. var pathNode = vm.$refs.cas.getCheckedNodes()[0].pathNodes
  382. if (index == 0) {
  383. vm.formData.registProvince = item
  384. vm.formData.registProvinceName = pathNode[index].label
  385. } else if (index == 1) {
  386. vm.formData.registCity = item
  387. vm.formData.registCityName = pathNode[index].label
  388. } else if (index == 2) {
  389. vm.formData.registTown = item
  390. vm.formData.registTownName = pathNode[index].label
  391. } else if (index == 3) {
  392. vm.formData.registStreet = item
  393. vm.formData.registStreetName = pathNode[index].label
  394. }
  395. })
  396. } else {
  397. vm.formData.registProvince = ''
  398. vm.formData.registProvinceName = ''
  399. vm.formData.registCity = ''
  400. vm.formData.registCityName = ''
  401. vm.formData.registTown = ''
  402. vm.formData.registTownName = ''
  403. vm.formData.registStreet = ''
  404. vm.formData.registStreetName = ''
  405. }
  406. if(vm.diagnosisAddressVal.length){
  407. var address = ""
  408. vm.diagnosisAddressVal.forEach(function (item, index) {
  409. var pathNode = vm.$refs.diagnosis.getCheckedNodes()[0].pathNodes
  410. if (index == 0) {
  411. vm.formData.jkcopdPatientExpend.firstVisitProvince = item
  412. vm.formData.jkcopdPatientExpend.firstVisitProvinceName = pathNode[index].label
  413. address += pathNode[index].label
  414. } else if (index == 1) {
  415. vm.formData.jkcopdPatientExpend.firstVisitCity = item
  416. vm.formData.jkcopdPatientExpend.firstVisitCityName = pathNode[index].label
  417. address += pathNode[index].label
  418. } else if (index == 2) {
  419. vm.formData.jkcopdPatientExpend.firstVisitTown = item
  420. vm.formData.jkcopdPatientExpend.firstVisitTownName = pathNode[index].label
  421. address += pathNode[index].label
  422. }
  423. })
  424. vm.formData.firstVisitArea = address
  425. }
  426. statisticAPI.updJkCopdPatient({ jsonData: JSON.stringify(vm.formData), doctor: vm.docInfo.code }).then(function (res) {
  427. if (res.status == 200) {
  428. EventBus.$emit('copd-reset-save')
  429. }else{
  430. vm.$message.error(res.message)
  431. }
  432. })
  433. } else {
  434. vm.$message.error('请填写联系方式!')
  435. window.scrollTo({ top: top, behavior: 'smooth' })
  436. }
  437. })
  438. return false
  439. }
  440. }
  441. })