index.js 3.0 KB

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