index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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 $modal from '@/plugins/modal.js';
  152. import processList from '@/components/ygoa/processList.vue'
  153. import { useUserStore } from '@/store/user.js'
  154. import { GetMessageList, GetNoticeList } from '@/api/message.js';
  155. onLoad((options) => {
  156. if (options.to == 'clockIn') toClockIn()
  157. })
  158. function toClockIn() {
  159. $modal.confirm('当前未打卡,是否前往打卡').then(() => {
  160. $tab.navigateTo('/pages/mine/clockIn/clockIn')
  161. })
  162. }
  163. onMounted(() => {
  164. onClickItem({ currentIndex: 0 })
  165. onClickItem2({ currentIndex: 0 })
  166. })
  167. const userStore = useUserStore()
  168. function clickCheckIn() {
  169. console.log('clickCheckIn', userStore.user);
  170. // console.log('getUserInfo', getUserInfo());
  171. // $tab.navigateTo('/pages/mine/clockIn/clockIn')
  172. }
  173. // 分段器选项列表
  174. const items = reactive(['全部', '已读', '未读'])
  175. // 分段器选项
  176. const current = ref(-1)
  177. const current2 = ref(0)
  178. // 消息列表
  179. let messages = ref([])
  180. //公告列表
  181. let notices = ref([]);
  182. // 待办列表
  183. let processes = reactive([
  184. {
  185. id: 1,
  186. title: '账户1 的请假申请',
  187. user: '账户1',
  188. createTime: '2024/10/10',
  189. startTime: '2024/10/10',
  190. endTime: '2024/10/12',
  191. totalTime: '2',
  192. description: '请假说明请假说明请假说明请假说明请假说明',
  193. type: 'icon-apply-leave',
  194. step: 0
  195. },
  196. {
  197. id: 1,
  198. title: '账户2 的请假申请',
  199. user: '账户2',
  200. createTime: '2024/10/10',
  201. startTime: '2024/10/10',
  202. endTime: '2024/10/12',
  203. totalTime: '2',
  204. description: '请假说明请假说明',
  205. type: 'icon-apply-leave',
  206. step: 0
  207. },
  208. {
  209. id: 2,
  210. title: '账户2 的加班申请',
  211. user: '账户2',
  212. createTime: '2024/10/10',
  213. startTime: '2024/10/10 17/30/00',
  214. endTime: '2024/10/10 18/30/00',
  215. totalTime: '1',
  216. description: '加班说明加班说明',
  217. type: 'icon-apply-overtime',
  218. step: 0
  219. },
  220. ])
  221. // const msg = reactive({
  222. // msgId: '1',
  223. // title: '账户2 的加班申请',
  224. // userName: '账户2',
  225. // createTime: '2024/10/10',
  226. // icon: 'icon-announce',
  227. // is_read: '1',
  228. // msgType: '0',//0消息或1公告
  229. // })
  230. // 点击消息分段器
  231. function onClickItem({ currentIndex }) {
  232. current.value = currentIndex
  233. console.log("onClickItem", currentIndex);
  234. switch (currentIndex) {
  235. case 0:
  236. messages.value = [
  237. {
  238. id: 3,
  239. user: "账户3",
  240. title: "未读公告3未读公告3未读公告3未读公告3未读公告3未读公告3",
  241. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  242. time: "2024/10/10",
  243. icon: 'icon-announce',
  244. is_read: 0
  245. },
  246. {
  247. id: 4,
  248. user: "账户4",
  249. title: "未读通知4",
  250. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  251. time: "2024/10/10",
  252. icon: 'icon-notify',
  253. is_read: 0
  254. }
  255. ]
  256. break;
  257. case 1:
  258. console.log("case1")
  259. messages.value = [
  260. {
  261. id: 1,
  262. user: "账户1",
  263. title: "已读公告1",
  264. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  265. time: "2024/10/10",
  266. icon: 'icon-announce',
  267. is_read: 1
  268. },
  269. // {
  270. // id: 2,
  271. // user: "账户2",
  272. // title: "已读通知2",
  273. // content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  274. // time: "2024/10/10",
  275. // icon: 'icon-notify',
  276. // is_read: 1
  277. // }
  278. ];
  279. console.log(messages.value);
  280. break;
  281. case 2:
  282. messages.value = [
  283. {
  284. id: 3,
  285. user: "账户3",
  286. title: "未读公告3未读公告3未读公告3未读公告3未读公告3未读公告3",
  287. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  288. time: "2024/10/10",
  289. icon: 'icon-announce',
  290. is_read: 0
  291. },
  292. {
  293. id: 4,
  294. user: "账户4",
  295. title: "未读通知4",
  296. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  297. time: "2024/10/10",
  298. icon: 'icon-notify',
  299. is_read: 0
  300. }
  301. ]
  302. break;
  303. }
  304. }
  305. // 点击公告分段器
  306. function onClickItem2({ currentIndex }) {
  307. current2.value = currentIndex;
  308. console.log(currentIndex);
  309. switch (currentIndex) {
  310. case 0:
  311. // console.log('userStore', JSON.parse(JSON.stringify(userStore.user)))
  312. const params1 = {
  313. "notice_title": "",
  314. "p": "1",
  315. "pSize": "5",
  316. "userId": userStore.user.useId,
  317. "unitId": userStore.user.unitId,
  318. }
  319. GetNoticeList(params1).then(res => {
  320. // console.log(res);
  321. notices.value=res.returnParams.noticelist.list;
  322. })
  323. break;
  324. case 1:
  325. notices.value = [
  326. {
  327. id: 1,
  328. user: "账户1",
  329. title: "已读公告1",
  330. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  331. time: "2024/10/10",
  332. icon: 'icon-announce',
  333. is_read: 1
  334. },
  335. {
  336. id: 2,
  337. user: "账户2",
  338. title: "已读通知2",
  339. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  340. time: "2024/10/10",
  341. icon: 'icon-notify',
  342. is_read: 1
  343. }
  344. ]
  345. break;
  346. case 2:
  347. notices.value = [
  348. {
  349. id: 3,
  350. user: "账户3",
  351. title: "未读公告3未读公告3未读公告3未读公告3未读公告3未读公告3",
  352. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  353. time: "2024/10/10",
  354. icon: 'icon-announce',
  355. is_read: 0
  356. },
  357. {
  358. id: 4,
  359. user: "账户4",
  360. title: "未读通知4",
  361. content: "消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容消息内容",
  362. time: "2024/10/10",
  363. icon: 'icon-notify',
  364. is_read: 0
  365. }
  366. ]
  367. break;
  368. }
  369. }
  370. // 点击消息
  371. function handleToDetail({ id }) {
  372. $tab.navigateTo('/pages/message/detail/index?id=' + id)
  373. console.log('handleToDetail', id);
  374. }
  375. function clickFabButton() {
  376. console.log('clickFabButton');
  377. $tab.navigateTo('/pages/message/chat/index')
  378. }
  379. </script>
  380. <style lang="scss">
  381. @import "@/static/font/ygoa/iconfont.css";
  382. .text {
  383. text-align: center;
  384. font-size: 26rpx;
  385. margin-top: 10rpx;
  386. }
  387. .grid-body {
  388. .ygoa-icon {
  389. font-size: 40px;
  390. }
  391. .grid-item-box {
  392. flex: 1;
  393. /* #ifndef APP-NVUE */
  394. display: flex;
  395. /* #endif */
  396. border-top: 1px solid #ccc;
  397. background-color: #ffffff;
  398. flex-direction: column;
  399. align-items: center;
  400. justify-content: center;
  401. padding: 15px 0;
  402. }
  403. }
  404. .segmented_control_container {
  405. // margin-top: 10px;
  406. }
  407. .message_container {
  408. border-left: #7b7b7b .4rem solid;
  409. .message_top_container {
  410. padding: 5px 5px 0;
  411. .message_user {
  412. color: #000000;
  413. }
  414. }
  415. .message_mid_container {
  416. padding: 5px;
  417. height: 1.1rem;
  418. .message_title {
  419. font-size: 1.1rem;
  420. }
  421. .message_time {
  422. font-size: 0.8rem;
  423. }
  424. }
  425. .message_bottom_container {
  426. .message_content {}
  427. }
  428. }
  429. .message_container_unread {
  430. // 未读样式
  431. border-left-color: #0f6cbd;
  432. .message_user {
  433. color: #000000;
  434. font-weight: bold;
  435. }
  436. .message_title {
  437. color: #0f6cbd;
  438. .message_title_text {
  439. font-weight: bold;
  440. }
  441. }
  442. }
  443. .hidden_over {
  444. white-space: nowrap; // 不换行
  445. overflow: hidden; // 超出内容隐藏
  446. text-overflow: ellipsis; // 超出部分显示省略号
  447. display: inline-block;
  448. max-width: 100%;
  449. }
  450. </style>