index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. },
  19. props: {
  20. componentData: {},
  21. },
  22. didMount() {
  23. this.setData({
  24. componentExtInfo: this.props.componentData.componentExtInfo,
  25. });
  26. this.getHospitalList();
  27. this.getPatientLists();
  28. // 获取路由信息
  29. },
  30. methods: {
  31. async getPatientLists() {
  32. const personList = await getPatientList();
  33. this.setData({
  34. personList,
  35. });
  36. },
  37. async getHospitalList() {
  38. const hospitalList = await getHospitalDistrictList();
  39. this.setData({
  40. hospitalList,
  41. });
  42. },
  43. async handleToBook(e) {
  44. const { hospitalDistrictId, name: hospitalName } =
  45. e.target.dataset.item;
  46. const { personList, componentExtInfo } = this.data;
  47. this.setData({
  48. hospitalDistrictId,
  49. hospitalName,
  50. }); // 判就诊人列表三种情况
  51. if (personList.length === 0) {
  52. // 没有就诊人信息
  53. my.confirm({
  54. content: "您还未添加就诊人,无法进行核酸预约",
  55. confirmButtonText: "去新增",
  56. cancelButtonText: "取消",
  57. success: ({ confirm }) => {
  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. })
  110. );