index.js 15 KB

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