index.js 2.9 KB

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