index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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, extInfo } = 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. hospitalId: extInfo.hospitalId || "",
  51. },
  52. });
  53. } else {
  54. const { componentData } = this.props;
  55. const { query = {} } = this.$page.data;
  56. history[replace ? "replace" : "push"]({
  57. query: {
  58. ...query,
  59. name,
  60. hospitalDistrictId,
  61. hospitalId: extInfo.hospitalId || "",
  62. },
  63. componentData,
  64. title: "选择科室",
  65. pageType: "select-department",
  66. });
  67. }
  68. return;
  69. },
  70. },
  71. });