health-education.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. "use strict";
  2. const common_vendor = require("../../../../common/vendor.js");
  3. const pagesCrm_business_schemeDetail_template_props = require("./props.js");
  4. require("../../../../config/globalData.js");
  5. const pagesCrm_service_schemeDetail_index = require("../../../service/schemeDetail/index.js");
  6. const pagesCrm_static_path = require("../../../static/path.js");
  7. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  8. __name: "health-education",
  9. props: pagesCrm_business_schemeDetail_template_props.props,
  10. setup(__props) {
  11. const props = __props;
  12. const list = common_vendor.ref([]);
  13. const option = common_vendor.ref({});
  14. const isAllRead = common_vendor.ref(0);
  15. const init = async (datas) => {
  16. if (datas && !datas.length)
  17. return;
  18. datas.forEach((item) => {
  19. try {
  20. if (typeof item.PushContent == "string") {
  21. item.PushContent = JSON.parse(item.PushContent);
  22. }
  23. } catch (e) {
  24. }
  25. });
  26. let isRead = 1;
  27. for (let i = 0; i < datas.length; i++) {
  28. if (!datas[i].IsRead) {
  29. isRead = 0;
  30. break;
  31. }
  32. }
  33. list.value = datas;
  34. option.value = datas[0];
  35. isAllRead.value = isRead;
  36. };
  37. const toArticle = async (row) => {
  38. const {
  39. PushContent: { Title, Id },
  40. Id: planid
  41. } = row;
  42. const index = list.value.findIndex((item) => item.Id == planid);
  43. const plan = list.value[index];
  44. let readRes = plan.IsRead;
  45. if (!plan.IsRead) {
  46. const resp = await pagesCrm_service_schemeDetail_index.PatientRead({
  47. Id: planid
  48. });
  49. readRes = !!resp;
  50. }
  51. list.value[index].IsRead = readRes;
  52. const isAllRead2 = list.value.reduce((res, item) => {
  53. return res && item.IsRead;
  54. }, true);
  55. let pages = getCurrentPages();
  56. let parentPage = pages[pages.length - 2];
  57. parentPage.$vm.changeItemReadStatus(props.date, props.index, isAllRead2);
  58. common_vendor.goToUrl(pagesCrm_static_path.path.article(Id));
  59. };
  60. common_vendor.watch(
  61. () => props.content,
  62. (v) => {
  63. init(v);
  64. },
  65. {
  66. immediate: true,
  67. deep: true
  68. }
  69. );
  70. return (_ctx, _cache) => {
  71. return common_vendor.e({
  72. a: common_vendor.t(_ctx.memberName),
  73. b: common_vendor.t(option.value.ExecDate),
  74. c: option.value.IsRead
  75. }, option.value.IsRead ? {
  76. d: common_vendor.t(isAllRead.value ? "完成" : "未完成")
  77. } : {}, {
  78. e: common_vendor.f(list.value, (item, index, i0) => {
  79. return {
  80. a: common_vendor.t(item.IsRead ? "已阅读" : "未阅读"),
  81. b: common_vendor.n(item.IsRead ? "read" : "unread"),
  82. c: common_vendor.t(index + 1),
  83. d: common_vendor.t(item.PushContent.Title),
  84. e: common_vendor.o(($event) => toArticle(item), index),
  85. f: index
  86. };
  87. })
  88. });
  89. };
  90. }
  91. });
  92. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-6ca65693"]]);
  93. wx.createComponent(Component);
  94. //# sourceMappingURL=../../../../../.sourcemap/mp-weixin/pagesCrm/business/schemeDetail/template/health-education.js.map