index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. var template = ''
  2. $.ajax('../../../component/statistics/LascModifyPatient/index.html', {
  3. data: {},
  4. dataType: 'html',
  5. cache: false,
  6. timeout: 60000,
  7. async: false,
  8. error: function (res) {},
  9. success: function (res) {
  10. template = res
  11. }
  12. })
  13. Vue.component('lasc-modify-patient', {
  14. template: template,
  15. name: 'lasc-modify-patient',
  16. props: {
  17. currentInfo: {}
  18. },
  19. data: function () {
  20. return {
  21. form: {},
  22. menophaniaAgeList: [],
  23. selAddress: '350200', // 默认值
  24. selectedStreet: '',
  25. areaList: areaDataArr,
  26. areaOptions: [], // 地区数据
  27. rules: {},
  28. streetList: [],
  29. cascaderProps: {
  30. value: 'value',
  31. label: 'label',
  32. children: 'children',
  33. expandTrigger: 'hover',
  34. checkStrictly: true, // 可以只选父级
  35. emitPath: true // 只返回最后一级的值
  36. }
  37. }
  38. },
  39. methods: {
  40. // 编辑
  41. updJkCopdPatient() {},
  42. handleItemChange(item, type) {
  43. if (type == 1) {
  44. this.form.sickProvince = item[0] || ''
  45. this.form.sickCity = item[1] || ''
  46. this.form.sickCounty = ''
  47. this.form.sickStreet = ''
  48. this.selSickStreet = ''
  49. var cityCode = (item[1] || '').substring(0, 4)
  50. var streetList = []
  51. _.filter(this.areaList.county_list, function (v, k) {
  52. if (k.indexOf(cityCode) === 0) {
  53. streetList.push({
  54. value: k,
  55. label: v,
  56. children: []
  57. })
  58. }
  59. })
  60. this.streetList = streetList
  61. console.log(this.streetList, ';;;;;;;;;;;;;;;;;;;;;;;')
  62. this.streetList.map(item => {
  63. this.fetchStreetList(item)
  64. })
  65. } else {
  66. console.log('22222222222222222', item)
  67. }
  68. },
  69. loadAreaData() {
  70. this.areaOptions = Object.keys(this.areaList.province_list).map(provinceCode => ({
  71. value: provinceCode,
  72. label: this.areaList.province_list[provinceCode],
  73. children: this.getCityChildren(provinceCode)
  74. }))
  75. },
  76. // 获取城市子节点
  77. getCityChildren(provinceCode) {
  78. const prefix = provinceCode.substring(0, 2)
  79. return Object.keys(this.areaList.city_list)
  80. .filter(cityCode => cityCode.startsWith(prefix))
  81. .map(cityCode => ({
  82. value: cityCode,
  83. label: this.areaList.city_list[cityCode]
  84. }))
  85. },
  86. fetchStreetList(item) {
  87. var params = {
  88. town: item.value
  89. }
  90. httpRequest.get('doctor/sign/getStreetListByTown', { data: params }).then(function (res) {
  91. if (res.status == 200) {
  92. var children =
  93. !res.data || !res.data.length
  94. ? []
  95. : _.map(res.data, function (v) {
  96. return {
  97. label: v.name,
  98. value: v.code
  99. }
  100. })
  101. }
  102. item.children = children
  103. })
  104. }
  105. },
  106. mounted() {
  107. // console.log('currentInfocurrentInfo: ', this.currentInfo)
  108. this.form = this.currentInfo
  109. for (var i = 8; i < 21; i++) {
  110. this.menophaniaAgeList.push(i)
  111. }
  112. // 初始化时加载地区数据
  113. this.loadAreaData()
  114. }
  115. })