index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. console.log("item ===>", item);
  33. const { name, hospitalDistrictId, extInfo, address } = item;
  34. const { isNotice = "Y" } = this.getExtInfo();
  35. /* 如果没有就诊须知跳转选择科室页面 */
  36. const pageType =
  37. isNotice === "N" ? "select-department" : "follow-up-notice";
  38. const [err, result] = await getRegisteredAnnouncement({
  39. hospitalId: Number(hospitalDistrictId),
  40. });
  41. if (!err && result && result.id > 0) {
  42. history[replace ? "replace" : "push"]({
  43. pageType,
  44. title: "挂号须知",
  45. componentData: {
  46. area: item,
  47. },
  48. query: {
  49. name,
  50. hospitalDistrictId,
  51. hospitalId: extInfo.hospitalId || "",
  52. subHospitalId: extInfo.subHospitalId || "",
  53. subHospitalTitle: `${name}(${address})`,
  54. },
  55. });
  56. } else {
  57. const { componentData } = this.props;
  58. const { query = {} } = this.$page.data;
  59. history[replace ? "replace" : "push"]({
  60. query: {
  61. ...query,
  62. name,
  63. hospitalDistrictId,
  64. hospitalId: extInfo.hospitalId || "",
  65. subHospitalId: extInfo.subHospitalId || "",
  66. subHospitalTitle: `${name}(${address})`,
  67. },
  68. componentData,
  69. title: "选择科室",
  70. pageType: "select-department",
  71. });
  72. }
  73. return;
  74. },
  75. },
  76. });