home.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <view class="container">
  3. <view class="filtration_scroll_wrapper ptb-12 plr-16">
  4. <view class="filtration--item" :class="{ actived: !deptId }" @click="selectedDept()">
  5. 全部
  6. </view>
  7. <view
  8. v-for="item in deptList"
  9. :key="item.DeptId"
  10. class="filtration--item"
  11. :class="{ actived: deptId == item.DeptId }"
  12. @click="selectedDept(item)"
  13. >
  14. {{ item.DeptName }}
  15. </view>
  16. </view>
  17. <view class="timer-list">
  18. <scroll-view
  19. v-if="dateline.length"
  20. scroll-y
  21. lower-threshold="100"
  22. bindscrolltolower="getPatientGroupPlanList"
  23. >
  24. <view class="timer" v-for="item in dateline">
  25. <view class="date">
  26. <text>{{ item.year }}</text>
  27. <text class="divider">/</text>
  28. <text>{{ item.mouth }}</text>
  29. <text class="divider">/</text>
  30. <text>{{ item.day }}</text>
  31. </view>
  32. <view class="list">
  33. <view
  34. v-for="(data, index) in datelineData[item.date]"
  35. :key="data.PlanUuid"
  36. class="wrapper"
  37. :class="{ unread: !data.IsRead }"
  38. @click="toSchemeDetail(data, data.TempType, index)"
  39. >
  40. <view>
  41. <view class="dept">{{ data.DeptName }}</view>
  42. <view class="desc">{{ schemeTypeEnum[data.TempType] }}</view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </scroll-view>
  48. <noData wx:else value="暂无数据"></noData>
  49. </view>
  50. </view>
  51. </template>
  52. <script lang="ts" setup>
  53. import { getCurrentInstance, nextTick, ref } from 'vue';
  54. import { useStore } from 'vuex';
  55. import { useOnLoad, useGetMemberIdByEncryptData } from '@/hook';
  56. import { mapState, mapGetters, mapMutations } from '@kasite/uni-app-base/store';
  57. import { common } from '@kasite/uni-app-base';
  58. import { schemeTypeEnum } from '../../static/schemeDetail';
  59. import { lastMsgContentExtract } from '../../static/chatRoom';
  60. import { GetPatientExecPlanDeptList, GetPatientExecPlanList } from '../../service';
  61. const { proxy } = getCurrentInstance();
  62. const store = useStore();
  63. const cardInfo = ref({} as any);
  64. const deptList = ref([]);
  65. const deptId = ref('');
  66. const dateline = ref([]);
  67. const datelineData = ref({});
  68. const pIndex = ref(1);
  69. const noMore = ref(false);
  70. const { memberList, currentUser = {} } = mapState({
  71. memberList: 'memberList',
  72. currentUser: 'currentUser',
  73. });
  74. const { setCurrentUser } = mapMutations({
  75. setCurrentUser: 'setCurrentUser',
  76. });
  77. const main = (options) => {
  78. console.log(options)
  79. uni.setStorageSync('openid', options.openid);
  80. /**默认查全部记录 */
  81. refresh(options);
  82. };
  83. /** 刷新 */
  84. const refresh = async (options: any = {}) => {
  85. await getEncryptData();
  86. if (!currentUser.value) {
  87. let [user = {}] = memberList.value.filter((item) => {
  88. if (options.memberId) {
  89. return item.memberId == options.memberId;
  90. } else {
  91. return !!item.userMemberList[0].isDefaultMember;
  92. }
  93. });
  94. if (common.isEmpty(user)) user = memberList.value[0];
  95. setCurrentUser(user);
  96. cardInfo.value = user;
  97. console.log(user);
  98. } else {
  99. cardInfo.value = currentUser.value;
  100. }
  101. noMore.value = false;
  102. getPatientExecPlanDeptList();
  103. // getMemberChatList()
  104. await getPatientExecPlanList();
  105. uni.stopPullDownRefresh();
  106. };
  107. /** 查询患者执行计划科室列表 */
  108. const getPatientExecPlanDeptList = async () => {
  109. if (!cardInfo.value.MemberId) return;
  110. const resp = await GetPatientExecPlanDeptList({
  111. MemberId: cardInfo.value.MemberId,
  112. });
  113. deptList.value = resp;
  114. };
  115. /** 查询患者组内执行计划列表 */
  116. const getPatientExecPlanList = async (e = undefined) => {
  117. if (!cardInfo.value.MemberId) return;
  118. if (noMore.value) return;
  119. let PIndex = pIndex.value;
  120. if (!e) {
  121. PIndex = 1;
  122. } else {
  123. PIndex++;
  124. }
  125. const resp = await GetPatientExecPlanList({
  126. MemberId: cardInfo.value.MemberId,
  127. DeptId: deptId.value,
  128. Page: {
  129. PIndex,
  130. PSize: 10,
  131. },
  132. });
  133. let data = e ? datelineData.value : {};
  134. let line = e
  135. ? dateline.value.map((item) => item.date).concat(resp.map((item) => item.ExecDate))
  136. : resp.map((item) => item.ExecDate);
  137. resp.map((item) => {
  138. if (!data[item.ExecDate]) {
  139. data[item.ExecDate] = [item];
  140. } else {
  141. data[item.ExecDate].push(item);
  142. }
  143. });
  144. line = Array.from(new Set(line))
  145. .sort((a, b) => {
  146. return new Date(b) - new Date(a);
  147. })
  148. .map((item: string) => {
  149. const [year, mouth, day] = item.split('-');
  150. return {
  151. date: item,
  152. year,
  153. mouth,
  154. day,
  155. };
  156. });
  157. pIndex.value = PIndex;
  158. noMore.value = !resp.length;
  159. dateline.value = line;
  160. datelineData.value = data;
  161. };
  162. /** 选择科室 */
  163. const selectedDept = (item: any = {}) => {
  164. const { DeptCode, DeptId = '' } = item;
  165. deptId.value = DeptId;
  166. noMore.value = false;
  167. nextTick(() => getPatientExecPlanList());
  168. };
  169. /** 查看方案详情 */
  170. const toSchemeDetail = (item, type, index) => {
  171. const path = `/pagesCrm/business/schemeDetail/schemeDetail?type=${type}&planuuid=${item.PlanUuid}&date=${item.ExecDate}&index=${index}&id=${item.Id}`;
  172. common.goToUrl(path);
  173. };
  174. const changeItemReadStatus = (date, index, status) => {
  175. datelineData.value[date][index].IsRead = status;
  176. };
  177. /** 解密 */
  178. const getEncryptData = async () => {
  179. // 只在 H5/WEB 端解析 URL 上的 EncryptData,兼容外部跳转进来的完整地址
  180. let encryptData = '';
  181. // #ifdef H5 || WEB
  182. try {
  183. // 例: https://fzsclqyy.com/KasiteWeb/module/hcrmUserCenter/index.html?EncryptData=xxx&token=xxx&openid=xxx#/
  184. // 先截掉 hash 部分,再解析 ? 后面的查询参数
  185. const url = (typeof window !== 'undefined' && window.location && window.location.href) ? window.location.href : '';
  186. const queryPart = url.split('?')[1]?.split('#')[0] || '';
  187. if (queryPart) {
  188. const params = new URLSearchParams(queryPart);
  189. encryptData = params.get('EncryptData') || '';
  190. }
  191. } catch (e) {
  192. console.error('解析 EncryptData 失败', e);
  193. }
  194. // #endif
  195. await useGetMemberIdByEncryptData(encryptData);
  196. }
  197. useOnLoad((options) => {
  198. main(options);
  199. // 兜底:监听事件总线的状态更新
  200. uni.$on('changeItemReadStatus', ({ date, index, status }) => {
  201. if (datelineData.value[date] && datelineData.value[date][index]) {
  202. datelineData.value[date][index].IsRead = status;
  203. }
  204. });
  205. });
  206. defineExpose({
  207. changeItemReadStatus,
  208. });
  209. </script>
  210. <style lang="scss" scoped>
  211. .container {
  212. display: flex;
  213. flex-direction: column;
  214. padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx);
  215. padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
  216. }
  217. .filtration {
  218. padding: 0 20rpx;
  219. }
  220. .filtration_scroll_wrapper {
  221. display: flex;
  222. overflow: auto;
  223. }
  224. .filtration--item {
  225. padding: 20rpx 40rpx;
  226. background-color: #d3d3d3;
  227. border-radius: 8rpx;
  228. word-break: keep-all;
  229. display: flex;
  230. justify-content: center;
  231. align-items: center;
  232. }
  233. .filtration--item + .filtration--item {
  234. margin-left: 20rpx;
  235. }
  236. .filtration--item.actived {
  237. background-color: var(--uni-color-primary);
  238. color: #fff;
  239. font-weight: bold;
  240. }
  241. .timer-list {
  242. height: 100%;
  243. overflow: auto;
  244. }
  245. .timer + .timer {
  246. margin-top: 20rpx;
  247. }
  248. .date {
  249. --height: 46rpx;
  250. margin: 20rpx;
  251. padding: 0 20rpx 0 56rpx;
  252. position: relative;
  253. font-weight: bold;
  254. height: var(--height);
  255. align-items: center;
  256. background-color: #e8e8e8;
  257. border-radius: var(--height);
  258. display: inline-flex;
  259. }
  260. .date::before {
  261. content: '';
  262. height: 12rpx;
  263. width: 12rpx;
  264. border-radius: 100%;
  265. border: 16rpx solid #b7bbca;
  266. position: absolute;
  267. left: 0;
  268. z-index: 1;
  269. }
  270. .date::after {
  271. content: '';
  272. width: 1rpx;
  273. height: calc(100% + 20rpx);
  274. position: absolute;
  275. left: 20rpx;
  276. bottom: -100%;
  277. background-color: #dee0e9;
  278. }
  279. .date .divider {
  280. color: var(--uni-color-primary);
  281. margin: 0 8rpx;
  282. }
  283. .timer .wrapper {
  284. padding: 24rpx 24rpx 24rpx 76rpx;
  285. position: relative;
  286. align-items: center;
  287. background-color: #fff;
  288. display: flex;
  289. justify-content: space-between;
  290. }
  291. .wrapper::before {
  292. content: '';
  293. height: 18rpx;
  294. width: 18rpx;
  295. border-radius: 100%;
  296. background-color: #dee0e9;
  297. position: absolute;
  298. left: 32rpx;
  299. }
  300. .wrapper::after {
  301. content: '';
  302. width: 1rpx;
  303. height: calc(100% + 20rpx);
  304. position: absolute;
  305. left: calc(32rpx + 8rpx);
  306. top: 0;
  307. background-color: #dee0e9;
  308. }
  309. .wrapper:last-child::after {
  310. height: 50%;
  311. }
  312. .wrapper + .wrapper {
  313. margin-top: 20rpx;
  314. }
  315. .arrow_right {
  316. width: 30rpx;
  317. height: 30rpx;
  318. }
  319. .dept {
  320. color: #909399;
  321. margin-bottom: 24rpx;
  322. font-size: 26rpx;
  323. position: relative;
  324. display: inline-block;
  325. }
  326. .unread .dept::before {
  327. content: '';
  328. height: 14rpx;
  329. width: 14rpx;
  330. border-radius: 100%;
  331. position: absolute;
  332. right: -20rpx;
  333. top: -5rpx;
  334. background-color: #fa4844;
  335. }
  336. </style>