index.js 3.1 KB

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