index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import history from '../../utils/history';
  2. import { getHospitalDistrictList } from '../select-hospital-area/service';
  3. import { getPatientList } from '../edit-patient/service';
  4. Component({
  5. data: {
  6. hospitalList: [],
  7. showPerson: false,
  8. personList: [],
  9. personItem: {},
  10. hospitalName: '',
  11. componentExtInfo: {}
  12. },
  13. props: {
  14. componentData: {}
  15. },
  16. didMount() {
  17. this.setData({
  18. componentExtInfo: this.props.componentData.componentExtInfo
  19. });
  20. this.getHospitalList();
  21. this.getPatientLists();
  22. },
  23. methods: {
  24. async getPatientLists() {
  25. const personList = await getPatientList();
  26. this.setData({
  27. personList
  28. });
  29. },
  30. async getHospitalList() {
  31. const hospitalList = await getHospitalDistrictList();
  32. this.setData({
  33. hospitalList
  34. });
  35. },
  36. async handleToBook(e) {
  37. const {
  38. hospitalDistrictId,
  39. name: hospitalName
  40. } = e.target.dataset.item;
  41. const {
  42. personList,
  43. componentExtInfo
  44. } = this.data;
  45. this.setData({
  46. hospitalDistrictId,
  47. hospitalName
  48. }); // 判就诊人列表三种情况
  49. if (personList.length === 0) {
  50. // 没有就诊人信息
  51. my.confirm({
  52. content: '您还未添加就诊人,无法进行核酸预约',
  53. confirmButtonText: '去新增',
  54. cancelButtonText: '取消',
  55. success: ({
  56. confirm
  57. }) => {
  58. if (confirm) {
  59. history.push({
  60. title: '添加就诊人',
  61. pageType: 'edit-patient'
  62. });
  63. }
  64. }
  65. });
  66. } else if (personList.length === 1) {
  67. this.setData({
  68. personItem: personList[0]
  69. }); // 有唯一就诊人(区分本人和其他人)
  70. history.push({
  71. query: {
  72. hospitalName,
  73. hospitalDistrictId,
  74. personItem: JSON.stringify(personList[0]),
  75. componentExtInfo: JSON.stringify(componentExtInfo)
  76. },
  77. title: '选择项目',
  78. pageType: 'hospital-project'
  79. });
  80. } else {
  81. // 选择就诊人
  82. this.setData({
  83. showPerson: true
  84. });
  85. }
  86. },
  87. onClosePerson() {
  88. this.setData({
  89. showPerson: false
  90. });
  91. },
  92. onPersonChange(item, index) {
  93. this.setData({
  94. personItem: item
  95. });
  96. history.push({
  97. query: {
  98. hospitalName: this.data.hospitalName,
  99. hospitalDistrictId: this.data.hospitalDistrictId,
  100. personIndex: index,
  101. personItem: JSON.stringify(item),
  102. componentExtInfo: JSON.stringify(this.data.componentExtInfo)
  103. },
  104. title: '选择项目',
  105. pageType: 'hospital-project'
  106. });
  107. }
  108. }
  109. });