index.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import history from "../../utils/history";
  2. import { getHospitalDistrictList } from "./service";
  3. import { getRegisteredAnnouncement } from "../../../../core/utils/ywtService";
  4. Component({
  5. props: {
  6. height: "100vh",
  7. componentData: {},
  8. },
  9. methods: {
  10. getExtInfo() {
  11. const { componentData } = this.props;
  12. const { componentExtInfo } = componentData;
  13. return componentExtInfo || {};
  14. },
  15. async onService() {
  16. const list = await getHospitalDistrictList();
  17. /* 如果只有一个院区直接跳转到挂号须知 */
  18. if (list.length === 1) {
  19. this.toNextPage(list[0], true);
  20. }
  21. return {
  22. list,
  23. pagination: {
  24. total: list.length,
  25. },
  26. };
  27. },
  28. onItemTap({ target: { dataset } }) {
  29. this.toNextPage(dataset.item);
  30. },
  31. async toNextPage(item, replace) {
  32. const { name, hospitalDistrictId } = item;
  33. const { isNotice = "Y" } = this.getExtInfo();
  34. /* 如果没有就诊须知跳转选择科室页面 */
  35. const pageType =
  36. isNotice === "N" ? "select-department" : "follow-up-notice";
  37. const [err, result] = await getRegisteredAnnouncement({
  38. hospitalId: Number(hospitalDistrictId),
  39. });
  40. if (!err && result && result.id > 0) {
  41. history[replace ? "replace" : "push"]({
  42. pageType,
  43. title: "挂号须知",
  44. componentData: {
  45. area: item,
  46. },
  47. query: {
  48. name,
  49. hospitalDistrictId,
  50. },
  51. });
  52. } else {
  53. const { componentData } = this.props;
  54. const { query = {} } = this.$page.data;
  55. history[replace ? "replace" : "push"]({
  56. query: {
  57. ...query,
  58. name,
  59. hospitalDistrictId,
  60. },
  61. componentData,
  62. title: "选择科室",
  63. pageType: "select-department",
  64. });
  65. }
  66. return;
  67. },
  68. },
  69. });