home.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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 } 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. /**默认查全部记录 */
  79. refresh(options);
  80. };
  81. /** 刷新 */
  82. const refresh = async (options: any = {}) => {
  83. if (!currentUser.value) {
  84. let [user = {}] = memberList.value.filter((item) => {
  85. if (options.memberId) {
  86. return item.memberId == options.memberId;
  87. } else {
  88. return !!item.userMemberList[0].isDefaultMember;
  89. }
  90. });
  91. if (common.isEmpty(user)) user = memberList.value[0];
  92. setCurrentUser(user);
  93. cardInfo.value = user;
  94. console.log(user);
  95. } else {
  96. cardInfo.value = currentUser.value;
  97. }
  98. noMore.value = false;
  99. getPatientExecPlanDeptList();
  100. // getMemberChatList()
  101. await getPatientExecPlanList();
  102. uni.stopPullDownRefresh();
  103. };
  104. /** 查询患者执行计划科室列表 */
  105. const getPatientExecPlanDeptList = async () => {
  106. if (!cardInfo.value.memberId) return;
  107. const resp = await GetPatientExecPlanDeptList({
  108. MemberId: cardInfo.value.memberId,
  109. });
  110. deptList.value = resp;
  111. };
  112. /** 查询患者组内执行计划列表 */
  113. const getPatientExecPlanList = async (e = undefined) => {
  114. if (!cardInfo.value.memberId) return;
  115. if (noMore.value) return;
  116. let PIndex = pIndex.value;
  117. if (!e) {
  118. PIndex = 1;
  119. } else {
  120. PIndex++;
  121. }
  122. const resp = await GetPatientExecPlanList({
  123. MemberId: cardInfo.value.memberId,
  124. DeptId: deptId.value,
  125. Page: {
  126. PIndex,
  127. PSize: 10,
  128. },
  129. });
  130. let data = e ? datelineData.value : {};
  131. let line = e
  132. ? dateline.value.map((item) => item.date).concat(resp.map((item) => item.ExecDate))
  133. : resp.map((item) => item.ExecDate);
  134. resp.map((item) => {
  135. if (!data[item.ExecDate]) {
  136. data[item.ExecDate] = [item];
  137. } else {
  138. data[item.ExecDate].push(item);
  139. }
  140. });
  141. line = Array.from(new Set(line))
  142. .sort((a, b) => {
  143. return new Date(b) - new Date(a);
  144. })
  145. .map((item: string) => {
  146. const [year, mouth, day] = item.split('-');
  147. return {
  148. date: item,
  149. year,
  150. mouth,
  151. day,
  152. };
  153. });
  154. pIndex.value = PIndex;
  155. noMore.value = !resp.length;
  156. dateline.value = line;
  157. datelineData.value = data;
  158. };
  159. /** 选择科室 */
  160. const selectedDept = (item: any = {}) => {
  161. const { DeptCode, DeptId = '' } = item;
  162. deptId.value = DeptId;
  163. noMore.value = false;
  164. nextTick(() => getPatientExecPlanList());
  165. };
  166. /** 查看方案详情 */
  167. const toSchemeDetail = (item, type, index) => {
  168. const path = `/pagesCrm/business/schemeDetail/schemeDetail?type=${type}&planuuid=${item.PlanUuid}&date=${item.ExecDate}&index=${index}&id=${item.Id}`;
  169. common.goToUrl(path);
  170. };
  171. const changeItemReadStatus = (date, index, status) => {
  172. datelineData.value[date][index].IsRead = status;
  173. };
  174. useOnLoad((options) => {
  175. main(options);
  176. // 兜底:监听事件总线的状态更新
  177. uni.$on('changeItemReadStatus', ({ date, index, status }) => {
  178. if (datelineData.value[date] && datelineData.value[date][index]) {
  179. datelineData.value[date][index].IsRead = status;
  180. }
  181. });
  182. });
  183. defineExpose({
  184. changeItemReadStatus,
  185. });
  186. </script>
  187. <style lang="scss" scoped>
  188. .container {
  189. display: flex;
  190. flex-direction: column;
  191. padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx);
  192. padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
  193. }
  194. .filtration {
  195. padding: 0 20rpx;
  196. }
  197. .filtration_scroll_wrapper {
  198. display: flex;
  199. overflow: auto;
  200. }
  201. .filtration--item {
  202. padding: 20rpx 40rpx;
  203. background-color: #d3d3d3;
  204. border-radius: 8rpx;
  205. word-break: keep-all;
  206. display: flex;
  207. justify-content: center;
  208. align-items: center;
  209. }
  210. .filtration--item + .filtration--item {
  211. margin-left: 20rpx;
  212. }
  213. .filtration--item.actived {
  214. background-color: var(--uni-color-primary);
  215. color: #fff;
  216. font-weight: bold;
  217. }
  218. .timer-list {
  219. height: 100%;
  220. overflow: auto;
  221. }
  222. .timer + .timer {
  223. margin-top: 20rpx;
  224. }
  225. .date {
  226. --height: 46rpx;
  227. margin: 20rpx;
  228. padding: 0 20rpx 0 56rpx;
  229. position: relative;
  230. font-weight: bold;
  231. height: var(--height);
  232. align-items: center;
  233. background-color: #e8e8e8;
  234. border-radius: var(--height);
  235. display: inline-flex;
  236. }
  237. .date::before {
  238. content: '';
  239. height: 12rpx;
  240. width: 12rpx;
  241. border-radius: 100%;
  242. border: 16rpx solid #b7bbca;
  243. position: absolute;
  244. left: 0;
  245. z-index: 1;
  246. }
  247. .date::after {
  248. content: '';
  249. width: 1rpx;
  250. height: calc(100% + 20rpx);
  251. position: absolute;
  252. left: 20rpx;
  253. bottom: -100%;
  254. background-color: #dee0e9;
  255. }
  256. .date .divider {
  257. color: var(--uni-color-primary);
  258. margin: 0 8rpx;
  259. }
  260. .timer .wrapper {
  261. padding: 24rpx 24rpx 24rpx 76rpx;
  262. position: relative;
  263. align-items: center;
  264. background-color: #fff;
  265. display: flex;
  266. justify-content: space-between;
  267. }
  268. .wrapper::before {
  269. content: '';
  270. height: 18rpx;
  271. width: 18rpx;
  272. border-radius: 100%;
  273. background-color: #dee0e9;
  274. position: absolute;
  275. left: 32rpx;
  276. }
  277. .wrapper::after {
  278. content: '';
  279. width: 1rpx;
  280. height: calc(100% + 20rpx);
  281. position: absolute;
  282. left: calc(32rpx + 8rpx);
  283. top: 0;
  284. background-color: #dee0e9;
  285. }
  286. .wrapper:last-child::after {
  287. height: 50%;
  288. }
  289. .wrapper + .wrapper {
  290. margin-top: 20rpx;
  291. }
  292. .arrow_right {
  293. width: 30rpx;
  294. height: 30rpx;
  295. }
  296. .dept {
  297. color: #909399;
  298. margin-bottom: 24rpx;
  299. font-size: 26rpx;
  300. position: relative;
  301. display: inline-block;
  302. }
  303. .unread .dept::before {
  304. content: '';
  305. height: 14rpx;
  306. width: 14rpx;
  307. border-radius: 100%;
  308. position: absolute;
  309. right: -20rpx;
  310. top: -5rpx;
  311. background-color: #fa4844;
  312. }
  313. </style>