home.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const hook_useOnLoad_index = require("../../../hook/use-on-load/index.js");
  4. const pagesCrm_static_schemeDetail = require("../../static/schemeDetail.js");
  5. const pagesCrm_service_home_index = require("../../service/home/index.js");
  6. require("../../../config/globalData.js");
  7. if (!Array) {
  8. const _component_noData = common_vendor.resolveComponent("noData");
  9. _component_noData();
  10. }
  11. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  12. __name: "home",
  13. setup(__props, { expose: __expose }) {
  14. common_vendor.useStore();
  15. const cardInfo = common_vendor.ref({});
  16. const deptList = common_vendor.ref([]);
  17. const deptId = common_vendor.ref("");
  18. const dateline = common_vendor.ref([]);
  19. const datelineData = common_vendor.ref({});
  20. const pIndex = common_vendor.ref(1);
  21. const noMore = common_vendor.ref(false);
  22. const { memberList, currentUser = {} } = common_vendor.mapState({
  23. memberList: "memberList",
  24. currentUser: "currentUser"
  25. });
  26. const { setCurrentUser } = common_vendor.mapMutations({
  27. setCurrentUser: "setCurrentUser"
  28. });
  29. const main = (options) => {
  30. refresh(options);
  31. };
  32. const refresh = async (options = {}) => {
  33. if (!currentUser.value) {
  34. let [user = {}] = memberList.value.filter((item) => {
  35. if (options.memberId) {
  36. return item.memberId == options.memberId;
  37. } else {
  38. return !!item.userMemberList[0].isDefaultMember;
  39. }
  40. });
  41. if (common_vendor.isEmpty(user))
  42. user = memberList.value[0];
  43. setCurrentUser(user);
  44. cardInfo.value = user;
  45. common_vendor.index.__f__("log", "at pagesCrm/business/home/home.vue:101", user);
  46. } else {
  47. cardInfo.value = currentUser.value;
  48. }
  49. noMore.value = false;
  50. getPatientExecPlanDeptList();
  51. await getPatientExecPlanList();
  52. common_vendor.index.stopPullDownRefresh();
  53. };
  54. const getPatientExecPlanDeptList = async () => {
  55. if (!cardInfo.value.memberId)
  56. return;
  57. const resp = await pagesCrm_service_home_index.GetPatientExecPlanDeptList({
  58. MemberId: cardInfo.value.memberId
  59. });
  60. deptList.value = resp;
  61. };
  62. const getPatientExecPlanList = async (e = void 0) => {
  63. if (!cardInfo.value.memberId)
  64. return;
  65. if (noMore.value)
  66. return;
  67. let PIndex = pIndex.value;
  68. if (!e) {
  69. PIndex = 1;
  70. } else {
  71. PIndex++;
  72. }
  73. const resp = await pagesCrm_service_home_index.GetPatientExecPlanList({
  74. MemberId: cardInfo.value.memberId,
  75. DeptId: deptId.value,
  76. Page: {
  77. PIndex,
  78. PSize: 10
  79. }
  80. });
  81. let data = e ? datelineData.value : {};
  82. let line = e ? dateline.value.map((item) => item.date).concat(resp.map((item) => item.ExecDate)) : resp.map((item) => item.ExecDate);
  83. resp.map((item) => {
  84. if (!data[item.ExecDate]) {
  85. data[item.ExecDate] = [item];
  86. } else {
  87. data[item.ExecDate].push(item);
  88. }
  89. });
  90. line = Array.from(new Set(line)).sort((a, b) => {
  91. return new Date(b) - new Date(a);
  92. }).map((item) => {
  93. const [year, mouth, day] = item.split("-");
  94. return {
  95. date: item,
  96. year,
  97. mouth,
  98. day
  99. };
  100. });
  101. pIndex.value = PIndex;
  102. noMore.value = !resp.length;
  103. dateline.value = line;
  104. datelineData.value = data;
  105. };
  106. const selectedDept = (item = {}) => {
  107. const { DeptCode, DeptId = "" } = item;
  108. deptId.value = DeptId;
  109. noMore.value = false;
  110. common_vendor.nextTick$1(() => getPatientExecPlanList());
  111. };
  112. const toSchemeDetail = (item, type, index) => {
  113. const path = `/pagesCrm/business/schemeDetail/schemeDetail?type=${type}&planuuid=${item.PlanUuid}&date=${item.ExecDate}&index=${index}&id=${item.Id}`;
  114. common_vendor.goToUrl(path);
  115. };
  116. const changeItemReadStatus = (date, index, status) => {
  117. datelineData.value[date][index].IsRead = status;
  118. };
  119. hook_useOnLoad_index.useOnLoad((options) => {
  120. main(options);
  121. });
  122. __expose({
  123. changeItemReadStatus
  124. });
  125. return (_ctx, _cache) => {
  126. return common_vendor.e({
  127. a: !deptId.value ? 1 : "",
  128. b: common_vendor.o(($event) => selectedDept()),
  129. c: common_vendor.f(deptList.value, (item, k0, i0) => {
  130. return {
  131. a: common_vendor.t(item.DeptName),
  132. b: item.DeptId,
  133. c: deptId.value == item.DeptId ? 1 : "",
  134. d: common_vendor.o(($event) => selectedDept(item), item.DeptId)
  135. };
  136. }),
  137. d: dateline.value.length
  138. }, dateline.value.length ? {
  139. e: common_vendor.f(dateline.value, (item, k0, i0) => {
  140. return {
  141. a: common_vendor.t(item.year),
  142. b: common_vendor.t(item.mouth),
  143. c: common_vendor.t(item.day),
  144. d: common_vendor.f(datelineData.value[item.date], (data, index, i1) => {
  145. return {
  146. a: common_vendor.t(data.DeptName),
  147. b: common_vendor.t(common_vendor.unref(pagesCrm_static_schemeDetail.schemeTypeEnum)[data.TempType]),
  148. c: data.PlanUuid,
  149. d: !data.IsRead ? 1 : "",
  150. e: common_vendor.o(($event) => toSchemeDetail(data, data.TempType, index), data.PlanUuid)
  151. };
  152. })
  153. };
  154. })
  155. } : {}, {
  156. f: common_vendor.p({
  157. ["wx:else"]: true,
  158. value: "暂无数据"
  159. })
  160. });
  161. };
  162. }
  163. });
  164. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-516c5459"]]);
  165. wx.createPage(MiniProgramPage);
  166. //# sourceMappingURL=../../../../.sourcemap/mp-weixin/pagesCrm/business/home/home.js.map