index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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(createSubscribe({
  6. async onShow() {
  7. await this.getPatientLists();
  8. }
  9. })({
  10. data: {
  11. hospitalList: [],
  12. showPerson: false,
  13. personList: [],
  14. personItem: {},
  15. hospitalName: '',
  16. componentExtInfo: {}
  17. },
  18. props: {
  19. componentData: {}
  20. },
  21. didMount() {
  22. this.setData({
  23. componentExtInfo: this.props.componentData.componentExtInfo
  24. });
  25. this.getHospitalList();
  26. this.getPatientLists();
  27. },
  28. methods: {
  29. async getPatientLists() {
  30. const personList = await getPatientList();
  31. this.setData({
  32. personList
  33. });
  34. },
  35. async getHospitalList() {
  36. const hospitalList = await getHospitalDistrictList();
  37. this.setData({
  38. hospitalList
  39. });
  40. },
  41. async handleToBook(e) {
  42. const {
  43. hospitalDistrictId,
  44. name: hospitalName
  45. } = e.target.dataset.item;
  46. const {
  47. personList,
  48. componentExtInfo
  49. } = this.data;
  50. this.setData({
  51. hospitalDistrictId,
  52. hospitalName
  53. }); // 判就诊人列表三种情况
  54. if (personList.length === 0) {
  55. // 没有就诊人信息
  56. my.confirm({
  57. content: '您还未添加就诊人,无法进行核酸预约',
  58. confirmButtonText: '去新增',
  59. cancelButtonText: '取消',
  60. success: ({
  61. confirm
  62. }) => {
  63. if (confirm) {
  64. history.push({
  65. title: '添加就诊人',
  66. pageType: 'edit-patient'
  67. });
  68. }
  69. }
  70. });
  71. } else if (personList.length === 1) {
  72. this.setData({
  73. personItem: personList[0]
  74. }); // 有唯一就诊人(区分本人和其他人)
  75. history.push({
  76. query: {
  77. hospitalName,
  78. hospitalDistrictId,
  79. personItem: JSON.stringify(personList[0]),
  80. componentExtInfo: JSON.stringify(componentExtInfo)
  81. },
  82. title: '选择项目',
  83. pageType: 'hospital-project'
  84. });
  85. } else {
  86. // 选择就诊人
  87. this.setData({
  88. showPerson: true
  89. });
  90. }
  91. },
  92. onClosePerson() {
  93. this.setData({
  94. showPerson: false
  95. });
  96. },
  97. onPersonChange(item, index) {
  98. this.setData({
  99. personItem: item
  100. });
  101. history.push({
  102. query: {
  103. hospitalName: this.data.hospitalName,
  104. hospitalDistrictId: this.data.hospitalDistrictId,
  105. personIndex: index,
  106. personItem: JSON.stringify(item),
  107. componentExtInfo: JSON.stringify(this.data.componentExtInfo)
  108. },
  109. title: '选择项目',
  110. pageType: 'hospital-project'
  111. });
  112. }
  113. }
  114. }));