index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <view class="index_container">
  3. <uni-nav-bar dark :border="false" :fixed="true" title="宇光同行">
  4. </uni-nav-bar>
  5. <!-- <uni-nav-bar :border="false" :fixed="true">
  6. <template v-slot:left>研发部</template>
  7. <template v-slot:right>用户1</template>
  8. </uni-nav-bar> -->
  9. <!-- <view class="grid-body">
  10. <uni-grid :column="2" :square="false" :showBorder="false" @change="changeIndexGrid">
  11. <uni-grid-item :index="1">
  12. <view class="grid-item-box">
  13. <text class="ygoa-icon icon-checkIn"></text>
  14. <text class="text">考勤打卡</text>
  15. </view>
  16. </uni-grid-item>
  17. <uni-grid-item :index="2">
  18. <view class="grid-item-box">
  19. <text class="ygoa-icon icon-init-process"></text>
  20. <text class="text">流程申请</text>
  21. </view>
  22. </uni-grid-item>
  23. </uni-grid>
  24. </view> -->
  25. <uni-collapse>
  26. <uni-collapse-item title-border="show" :border="true" :show-animation="true" :open="false">
  27. <template v-slot:title>
  28. <uni-section title="待办消息" type="line" titleFontSize="20px"></uni-section>
  29. </template>
  30. <view class="process_container">
  31. <view class="process_list" v-if="processes">
  32. <process-list :processes="processes"></process-list>
  33. </view>
  34. <view class="no_process" v-else>
  35. <uni-section title="无待办消息"></uni-section>
  36. </view>
  37. </view>
  38. </uni-collapse-item>
  39. </uni-collapse>
  40. <uni-collapse>
  41. <uni-collapse-item title-border="show" :border="true" :show-animation="true" :open="false">
  42. <template v-slot:title>
  43. <uni-section title="公告" type="line" titleFontSize="20px"></uni-section>
  44. </template>
  45. <view class="segmented_control_container">
  46. <uni-segmented-control :current="current2" :values="items" @clickItem="onClickItem2"
  47. styleType="text" activeColor="#409eff"></uni-segmented-control>
  48. </view>
  49. <view class="content">
  50. <view @click="handleToDetail(message)" v-for="(message, index) in notices" :key="index"
  51. :class="message.if_read ? ' ' : 'message_container_unread'" class="message_container">
  52. <uni-card :is-full="true">
  53. <template v-slot:title>
  54. <uni-row>
  55. <view class="message_top_container">
  56. <uni-col :span="24">
  57. <text class="message_user">
  58. {{ message.name }}
  59. </text>
  60. </uni-col>
  61. </view>
  62. </uni-row>
  63. <uni-row>
  64. <view class="message_mid_container">
  65. <uni-col :span="16">
  66. <text class="message_title hidden_over">
  67. <text :class="message.icon" class="ygoa-icon"></text>
  68. <text class="message_title_text">{{ message.title }}</text>
  69. </text>
  70. </uni-col>
  71. <uni-col :span="8">
  72. <text class="message_time">
  73. {{ message.sendtime }}
  74. </text>
  75. </uni-col>
  76. </view>
  77. </uni-row>
  78. </template>
  79. <!-- <view class="message_bottom_container">
  80. <text class="message_content hidden_over">
  81. {{ message.content }}
  82. </text>
  83. </view> -->
  84. </uni-card>
  85. </view>
  86. </view>
  87. </uni-collapse-item>
  88. </uni-collapse>
  89. <uni-collapse>
  90. <uni-collapse-item title-border="show" :border="true" :show-animation="true" :open="true">
  91. <template v-slot:title>
  92. <uni-section title="消息" type="line" titleFontSize="20px"></uni-section>
  93. </template>
  94. <view class="segmented_control_container">
  95. <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text"
  96. activeColor="#409eff"></uni-segmented-control>
  97. </view>
  98. <view class="content">
  99. <view @click="handleToDetail(message)" v-for="(message, index) in messages" :key="index"
  100. :class="message.is_read ? ' ' : 'message_container_unread'" class="message_container">
  101. <uni-card :is-full="true">
  102. <template v-slot:title>
  103. <uni-row>
  104. <view class="message_top_container">
  105. <uni-col :span="24">
  106. <text class="message_user">
  107. {{ message.user }}
  108. </text>
  109. </uni-col>
  110. </view>
  111. </uni-row>
  112. <uni-row>
  113. <view class="message_mid_container">
  114. <uni-col :span="19">
  115. <text class="message_title hidden_over">
  116. <text :class="message.icon" class="ygoa-icon"></text>
  117. <text class="message_title_text">{{ message.title }}</text>
  118. </text>
  119. </uni-col>
  120. <uni-col :span="4">
  121. <text class="message_time">
  122. {{ message.time }}
  123. </text>
  124. </uni-col>
  125. </view>
  126. </uni-row>
  127. </template>
  128. <view class="message_bottom_container">
  129. <text class="message_content hidden_over">
  130. {{ message.content }}
  131. </text>
  132. </view>
  133. </uni-card>
  134. </view>
  135. </view>
  136. </uni-collapse-item>
  137. </uni-collapse>
  138. <view class="fab_button">
  139. <uni-fab :pattern="{icon:'headphones'}" :popMenu="false" horizontal="right"
  140. @fabClick="clickFabButton"></uni-fab>
  141. </view>
  142. <view class="checkIn_button">
  143. <uni-fab :pattern="{icon:'calendar'}" :popMenu="false" horizontal="left" @fabClick="clickCheckIn"></uni-fab>
  144. </view>
  145. </view>
  146. </template>
  147. <script setup lang="ts">
  148. import { onMounted, reactive, ref } from 'vue';
  149. import { onLoad } from '@dcloudio/uni-app'
  150. import $tab from '@/plugins/tab.js';
  151. import processList from '@/components/ygoa/processList.vue'
  152. import { useUserStore } from '@/store/user.js'
  153. onLoad((options) => {
  154. if (options.to == 'clockIn') {
  155. $tab.navigateTo('/pages/mine/clockIn/clockIn')
  156. }
  157. })
  158. import { GetMessageList, GetNoticeList } from '@/api/message.js';
  159. onMounted(() => {
  160. onClickItem({ currentIndex: 0 })
  161. onClickItem2({ currentIndex: 0 })
  162. })
  163. const userStore = useUserStore()
  164. function clickCheckIn() {
  165. console.log('clickCheckIn', userStore.user);
  166. // console.log('getUserInfo', getUserInfo());
  167. // $tab.navigateTo('/pages/mine/clockIn/clockIn')
  168. }
  169. // 分段器选项列表
  170. const items = reactive(['全部', '已读', '未读'])
  171. // 分段器选项
  172. const current = ref(-1)
  173. const current2 = ref(0)
  174. // 消息列表
  175. let messages = ref([])
  176. //公告列表
  177. let notices = ref([]);
  178. // 待办列表
  179. let processes = reactive([
  180. {
  181. id: 1,
  182. title: '账户1 的请假申请',
  183. user: '账户1',
  184. createTime: '2024/10/10',
  185. startTime: '2024/10/10',
  186. endTime: '2024/10/12',
  187. totalTime: '2',
  188. description: '请假说明请假说明请假说明请假说明请假说明',
  189. type: 'icon-apply-leave',
  190. step: 0
  191. },
  192. {
  193. id: 1,
  194. title: '账户2 的请假申请',
  195. user: '账户2',
  196. createTime: '2024/10/10',
  197. startTime: '2024/10/10',
  198. endTime: '2024/10/12',
  199. totalTime: '2',
  200. description: '请假说明请假说明',
  201. type: 'icon-apply-leave',
  202. step: 0
  203. },
  204. {
  205. id: 2,
  206. title: '账户2 的加班申请',
  207. user: '账户2',
  208. createTime: '2024/10/10',
  209. startTime: '2024/10/10 17/30/00',
  210. endTime: '2024/10/10 18/30/00',
  211. totalTime: '1',
  212. description: '加班说明加班说明',
  213. type: 'icon-apply-overtime',
  214. step: 0
  215. },
  216. ])
  217. // const msg = reactive({
  218. // msgId: '1',
  219. // title: '账户2 的加班申请',
  220. // userName: '账户2',
  221. // createTime: '2024/10/10',
  222. // icon: 'icon-announce',
  223. // is_read: '1',
  224. // msgType: '0',//0消息或1公告
  225. // })
  226. // 点击消息分段器
  227. function onClickItem({ currentIndex }) {
  228. current.value = currentIndex
  229. console.log("onClickItem", currentIndex);
  230. switch (currentIndex) {
  231. case 0:
  232. messages.value = [
  233. {
  234. id: 3,
  235. user: "账户3",
  236. title: "未读公告3未读公告3未读公告3未读公告3未读公告3未读公告3",
  237. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  238. time: "2024/10/10",
  239. icon: 'icon-announce',
  240. is_read: 0
  241. },
  242. {
  243. id: 4,
  244. user: "账户4",
  245. title: "未读通知4",
  246. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  247. time: "2024/10/10",
  248. icon: 'icon-notify',
  249. is_read: 0
  250. }
  251. ]
  252. break;
  253. case 1:
  254. console.log("case1")
  255. messages.value = [
  256. {
  257. id: 1,
  258. user: "账户1",
  259. title: "已读公告1",
  260. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  261. time: "2024/10/10",
  262. icon: 'icon-announce',
  263. is_read: 1
  264. },
  265. // {
  266. // id: 2,
  267. // user: "账户2",
  268. // title: "已读通知2",
  269. // content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  270. // time: "2024/10/10",
  271. // icon: 'icon-notify',
  272. // is_read: 1
  273. // }
  274. ];
  275. console.log(messages.value);
  276. break;
  277. case 2:
  278. messages.value = [
  279. {
  280. id: 3,
  281. user: "账户3",
  282. title: "未读公告3未读公告3未读公告3未读公告3未读公告3未读公告3",
  283. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  284. time: "2024/10/10",
  285. icon: 'icon-announce',
  286. is_read: 0
  287. },
  288. {
  289. id: 4,
  290. user: "账户4",
  291. title: "未读通知4",
  292. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  293. time: "2024/10/10",
  294. icon: 'icon-notify',
  295. is_read: 0
  296. }
  297. ]
  298. break;
  299. }
  300. }
  301. // 点击公告分段器
  302. function onClickItem2({ currentIndex }) {
  303. current2.value = currentIndex;
  304. console.log(currentIndex);
  305. switch (currentIndex) {
  306. case 0:
  307. // console.log('userStore', JSON.parse(JSON.stringify(userStore.user)))
  308. const params1 = {
  309. "notice_title": "",
  310. "p": "1",
  311. "pSize": "5",
  312. "userId": userStore.user.useId,
  313. "unitId": userStore.user.unitId,
  314. }
  315. GetNoticeList(params1).then(res => {
  316. // console.log(res);
  317. notices.value=res.returnParams.noticelist.list;
  318. })
  319. break;
  320. case 1:
  321. notices.value = [
  322. {
  323. id: 1,
  324. user: "账户1",
  325. title: "已读公告1",
  326. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  327. time: "2024/10/10",
  328. icon: 'icon-announce',
  329. is_read: 1
  330. },
  331. {
  332. id: 2,
  333. user: "账户2",
  334. title: "已读通知2",
  335. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  336. time: "2024/10/10",
  337. icon: 'icon-notify',
  338. is_read: 1
  339. }
  340. ]
  341. break;
  342. case 2:
  343. notices.value = [
  344. {
  345. id: 3,
  346. user: "账户3",
  347. title: "未读公告3未读公告3未读公告3未读公告3未读公告3未读公告3",
  348. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  349. time: "2024/10/10",
  350. icon: 'icon-announce',
  351. is_read: 0
  352. },
  353. {
  354. id: 4,
  355. user: "账户4",
  356. title: "未读通知4",
  357. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  358. time: "2024/10/10",
  359. icon: 'icon-notify',
  360. is_read: 0
  361. }
  362. ]
  363. break;
  364. }
  365. }
  366. // 点击消息
  367. function handleToDetail({ id }) {
  368. $tab.navigateTo('/pages/message/detail/index?id=' + id)
  369. console.log('handleToDetail', id);
  370. }
  371. function clickFabButton() {
  372. console.log('clickFabButton');
  373. $tab.navigateTo('/pages/message/chat/index')
  374. }
  375. </script>
  376. <style lang="scss">
  377. @import "@/static/font/ygoa/iconfont.css";
  378. .text {
  379. text-align: center;
  380. font-size: 26rpx;
  381. margin-top: 10rpx;
  382. }
  383. .grid-body {
  384. .ygoa-icon {
  385. font-size: 40px;
  386. }
  387. .grid-item-box {
  388. flex: 1;
  389. /* #ifndef APP-NVUE */
  390. display: flex;
  391. /* #endif */
  392. border-top: 1px solid #ccc;
  393. background-color: #ffffff;
  394. flex-direction: column;
  395. align-items: center;
  396. justify-content: center;
  397. padding: 15px 0;
  398. }
  399. }
  400. .segmented_control_container {
  401. // margin-top: 10px;
  402. }
  403. .message_container {
  404. border-left: #7b7b7b .4rem solid;
  405. .message_top_container {
  406. padding: 5px 5px 0;
  407. .message_user {
  408. color: #000000;
  409. }
  410. }
  411. .message_mid_container {
  412. padding: 5px;
  413. height: 1.1rem;
  414. .message_title {
  415. font-size: 1.1rem;
  416. }
  417. .message_time {
  418. font-size: 0.8rem;
  419. }
  420. }
  421. .message_bottom_container {
  422. .message_content {}
  423. }
  424. }
  425. .message_container_unread {
  426. // 未读样式
  427. border-left-color: #0f6cbd;
  428. .message_user {
  429. color: #000000;
  430. font-weight: bold;
  431. }
  432. .message_title {
  433. color: #0f6cbd;
  434. .message_title_text {
  435. font-weight: bold;
  436. }
  437. }
  438. }
  439. .hidden_over {
  440. white-space: nowrap; // 不换行
  441. overflow: hidden; // 超出内容隐藏
  442. text-overflow: ellipsis; // 超出部分显示省略号
  443. display: inline-block;
  444. max-width: 100%;
  445. }
  446. </style>