index.js 13 KB

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