index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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. },
  11. success: function(res) {
  12. template = res
  13. }
  14. })
  15. let vm
  16. Vue.component('copd-patient-record-edit', {
  17. template: template,
  18. props: ['editData'],
  19. data() {
  20. return {
  21. formData:{},
  22. nationDict:[],
  23. 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'],
  24. marriageArr:[],
  25. followupArr:[],
  26. idCardTypeArr:[],
  27. firstAreaArr:[],
  28. isLiveArr:[],
  29. orgLevelArr:[],
  30. occupationArr:[],
  31. smokeArr:[],
  32. drinkArr:[],
  33. archivesArr:[],
  34. conversionArr:[],
  35. firstVisitTypeArr:[],
  36. educationalArr:[],
  37. copdArr:[{value:'是',code:'1'},{value:'否',code:'0'}],
  38. addressOptions:[],
  39. props: {
  40. label: 'name',
  41. value: 'code',
  42. children: 'children'
  43. },
  44. addressVal:[],
  45. resiginAddressVal:[],
  46. docInfo: JSON.parse(window.localStorage.getItem('docInfo')),
  47. rules: {
  48. mobile:[
  49. { required: true, message: '请输入联系方式', trigger: 'blur' },
  50. { min: 11, max: 11, message: '请输入正确的联系方式', trigger: 'blur' }
  51. ]
  52. }
  53. }
  54. },
  55. created() {
  56. vm=this
  57. },
  58. watch:{
  59. 'formData.isLive':{
  60. handler:function(o) {
  61. if(o=='1'){
  62. this.formData.deathTime=''
  63. this.formData.deathReason=''
  64. }
  65. },
  66. deep: true,
  67. immediate: true
  68. },
  69. addressVal(value){
  70. console.log(value,'0000000000000000000000')
  71. }
  72. },
  73. mounted() {
  74. var vm=this
  75. this.formData= JSON.parse(window.localStorage.getItem('editDetail'))
  76. console.log(this.formData,'00000000000000000000000000000')
  77. if(this.formData.liveStreet){
  78. this.addressVal=[this.formData.liveProvince,this.formData.liveCity,this.formData.liveTown,this.formData.liveStreet]
  79. this.getDistrict(0)
  80. }else{
  81. this.addressVal=[this.formData.liveProvince,this.formData.liveCity,this.formData.liveTown]
  82. this.getDistrict(0)
  83. }
  84. this.getNation()
  85. if(this.formData.liveStreet){
  86. this.resiginAddressVal=[this.formData.registProvince,this.formData.registCity,this.formData.registTown,this.formData.registStreet]
  87. this.getDistrict(1)
  88. }else{
  89. this.resiginAddressVal=[this.formData.registProvince,this.formData.registCity,this.formData.registTown]
  90. this.getDistrict(1)
  91. }
  92. this.dicName.forEach(function(item) {
  93. vm.getDictByDictName(item)
  94. });
  95. },
  96. methods: {
  97. handleItemChange(val) {
  98. // 获取地址
  99. if (val.length == 1) {
  100. // 获取市
  101. this.baseCityList(val[0])
  102. }
  103. if (val.length == 2) {
  104. // 获取区
  105. this.baseTownList(val)
  106. }
  107. if (val.length == 3) {
  108. // 获取区
  109. this.stressList(val)
  110. }
  111. },
  112. //字典
  113. getDictByDictName(value){
  114. var vm=this
  115. statisticAPI.getDictByDictName({name:value}).then(function(res){
  116. if(value=='jkcopd_marriage'){
  117. vm.marriageArr=res.list
  118. }else if(value=='jkcopd_occupation'){
  119. vm.occupationArr=res.list
  120. }else if(value=='jkcopd_smoke'){
  121. vm.smokeArr=res.list
  122. }else if(value=='jkcopd_drink'){
  123. vm.drinkArr=res.list
  124. }else if(value=='jkcopd_archivesStatus'){
  125. vm.archivesArr=res.list
  126. }else if(value=='jkcopd_disease_conversion'){
  127. vm.conversionArr=res.list
  128. }else if(value=='jkcopd_firstVisitType'){
  129. vm.firstVisitTypeArr=res.list
  130. }else if(value=='jkcopd_educational'){
  131. vm.educationalArr=res.list
  132. }else if(value=='idCardType'){
  133. vm.idCardTypeArr=res.list
  134. }else if(value=='jkcopd_first_area'){
  135. vm.firstAreaArr=res.list
  136. }else if(value=='jkcopd_first_org_level'){
  137. vm.orgLevelArr=res.list
  138. }else if(value=='jkcopd_isLive'){
  139. vm.isLiveArr=res.list
  140. }else if(value=='jkcopd_followup_status'){
  141. vm.followupArr=res.list
  142. }
  143. })
  144. },
  145. getNation(){
  146. var vm=this
  147. statisticAPI.getNationDict().then(function(res){
  148. vm.nationDict= res.data
  149. })
  150. },
  151. getDistrict(id){
  152. var vm =this
  153. homeAPI.getDistrict({ type:1 ,code:'' }).then(function(res) {
  154. var detailModelList=res.list
  155. detailModelList.forEach(function(item){
  156. item.children = []
  157. })
  158. vm.addressOptions=detailModelList
  159. if(vm.formData.liveProvince&&id==0){
  160. vm.baseCityList(vm.formData.liveProvince,id)
  161. }
  162. if(vm.formData.registProvince&&id==1){
  163. vm.baseCityList(vm.formData.registProvince,id)
  164. }
  165. })
  166. },
  167. onClickNavLink(id) {
  168. var element = document.getElementById(id);
  169. var top = element.offsetTop;
  170. window.scrollTo({ top: top, behavior: 'smooth' });
  171. },
  172. //市
  173. baseCityList:function(code,id){
  174. var vm = this
  175. var activeIndex = null
  176. vm.addressOptions.forEach(function(item, index) {
  177. if (item.code == code) {
  178. activeIndex = index
  179. }
  180. })
  181. homeAPI.getDistrict({ type:2 ,code:code }).then(function(res) {
  182. if (res.status == 200) {
  183. var detailModelList = res.list
  184. detailModelList.forEach(item => {
  185. item.children = []
  186. })
  187. vm.addressOptions[activeIndex].children = detailModelList
  188. if(vm.addressVal.length&&id==0){
  189. vm.baseTownList([vm.addressVal[0], vm.addressVal[1]],id)
  190. }
  191. if(vm.resiginAddressVal.length&&id==1){
  192. vm.baseTownList([vm.resiginAddressVal[0], vm.resiginAddressVal[1]],id)
  193. }
  194. }
  195. })
  196. },
  197. //县
  198. baseTownList(val,id) {
  199. var vm = this
  200. var provinceIndex = null
  201. var activeIndex = null
  202. vm.addressOptions.forEach(function(item, index){
  203. if (item.code == val[0]) {
  204. var children = item.children
  205. provinceIndex = index
  206. children.forEach(function(item, idx) {
  207. if (item.code == val[1]) {
  208. activeIndex = idx
  209. }
  210. })
  211. }
  212. })
  213. homeAPI.getDistrict({ type:3,code:val[1] }).then( function(res){
  214. if (res.status == 200) {
  215. var detailModelList = res.list
  216. if(val[1]=='350200'){
  217. detailModelList.forEach(function(item){
  218. item.children = []
  219. })
  220. }
  221. if (vm.addressOptions[provinceIndex].children[activeIndex]) {
  222. vm.addressOptions[provinceIndex].children[activeIndex].children = detailModelList
  223. if(vm.addressVal.length&&id==0){
  224. vm.stressList([vm.addressVal[0], vm.addressVal[1],vm.addressVal[2]])
  225. }
  226. if(vm.resiginAddressVal.length&&id==1){
  227. vm.stressList([vm.resiginAddressVal[0], vm.resiginAddressVal[1],vm.resiginAddressVal[2]])
  228. }
  229. }
  230. }
  231. })
  232. },
  233. //街道
  234. stressList(val) {
  235. var vm = this
  236. var provinceIndex = null
  237. var activeIndex = null
  238. var xIndex=null
  239. vm.addressOptions.forEach(function(item, index) {
  240. if (item.code == val[0]) {
  241. var children = item.children
  242. provinceIndex = index
  243. children.forEach(function(item, idx) {
  244. if (item.code == val[1]) {
  245. activeIndex = idx
  246. var xItem=item.children
  247. xItem.forEach(function(item,xianIndex){
  248. if(item.code==val[2]){
  249. xIndex=xianIndex
  250. }
  251. })
  252. }
  253. })
  254. }
  255. })
  256. homeAPI.getDistrict({ type:4,code:val[2] }).then( function(res){
  257. if (res.status == 200) {
  258. var detailModelList = res.list
  259. if (vm.addressOptions[provinceIndex].children[activeIndex].children[xIndex]) {
  260. vm.addressOptions[provinceIndex].children[activeIndex].children[xIndex].children = detailModelList
  261. }
  262. }
  263. })
  264. },
  265. cancel:function(){
  266. EventBus.$emit('copd-reset-select')
  267. },
  268. updJkCopdPatient(){
  269. var vm =this
  270. this.$refs.ruleForm.validate(function(valid){
  271. if(valid){
  272. if(!vm.formData.mobile){
  273. this.$message.error('请填写联系方式!')
  274. return false
  275. }
  276. if(vm.formData.sexName=='男'){
  277. vm.formData.sex=1
  278. }else{
  279. vm.formData.sex=2
  280. }
  281. if(vm.addressVal.length){
  282. vm.addressVal.forEach(function(item,index){
  283. if(index==0){
  284. vm.formData.liveProvince=item
  285. vm.formData.liveProvinceName=vm.$refs.cascader.currentLabels[index]
  286. }else if(index==1){
  287. vm.formData.liveCity=item
  288. vm.formData.liveCityName=vm.$refs.cascader.currentLabels[index]
  289. }else if(index==2){
  290. vm.formData.liveTown=item
  291. vm.formData.liveTownName=vm.$refs.cascader.currentLabels[index]
  292. }else if(index==3){
  293. vm.formData.liveStreet=item
  294. vm.formData.liveStreetName=vm.$refs.cascader.currentLabels[index]
  295. }
  296. })
  297. }else{
  298. vm.formData.liveProvince=''
  299. vm.formData.liveProvinceName=''
  300. vm.formData.liveCity=''
  301. vm.formData.liveCityName=''
  302. vm.formData.liveTown=''
  303. vm.formData.liveTownName=''
  304. vm.formData.liveStreet=''
  305. vm.formData.liveStreetName=''
  306. }
  307. if(vm.resiginAddressVal.length){
  308. vm.resiginAddressVal.forEach(function(item,index){
  309. if(index==0){
  310. vm.formData.registProvince=item
  311. vm.formData.registProvinceName=vm.$refs.cas.currentLabels[index]
  312. }else if(index==1){
  313. vm.formData.registCity=item
  314. vm.formData.registCityName=vm.$refs.cas.currentLabels[index]
  315. }else if(index==2){
  316. vm.formData.registTown=item
  317. vm.formData.registTownName=vm.$refs.cas.currentLabels[index]
  318. }else if(index==3){
  319. vm.formData.registStreet=item
  320. vm.formData.registStreetName=vm.$refs.cas.currentLabels[index]
  321. }
  322. })
  323. }else{
  324. vm.formData.registProvince=''
  325. vm.formData.registProvinceName=''
  326. vm.formData.registCity=''
  327. vm.formData.registCityName=''
  328. vm.formData.registTown=''
  329. vm.formData.registTownName=''
  330. vm.formData.registStreet=''
  331. vm.formData.registStreetName=''
  332. }
  333. statisticAPI.updJkCopdPatient({jsonData:JSON.stringify(vm.formData),doctor:vm.docInfo.code}).then(
  334. function(res){
  335. if(res.status==200){
  336. EventBus.$emit('copd-reset-save')
  337. }
  338. }
  339. )
  340. }else{
  341. vm.$message.error('请填写联系方式!')
  342. window.scrollTo({ top: top, behavior: 'smooth' });
  343. }
  344. })
  345. return false
  346. }
  347. }
  348. });