index.js 2.0 KB

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