index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div v-show="showAll == false">
  3. <el-card style="padding: 5px; 15px;height: calc(24vh);">
  4. <div class="header-title"> <h3>最新通知 </h3> <h4 @click="go2page">查看全部</h4></div>
  5. <noticeBlock></noticeBlock>
  6. </el-card>
  7. <el-card shadow="always" v-action="'statistic.HomeStatistics.statistics'" v-ac style="margin-top: 20px;height: calc(70vh);">
  8. <todayData></todayData>
  9. </el-card>
  10. </div>
  11. <div v-show="showAll == true">
  12. <el-row :gutter="20">
  13. <el-col :span="8">
  14. <el-tabs type="border-card" v-model="activeName" class="tabs" @tab-click="handleClick">
  15. <el-tab-pane v-for="item in noticesTypes" :key="item.id" :label="item.name" :name="item.id">
  16. <!-- <el-table style="height: 800px;" :data="currentTableData" class="mt-3" v-loading="loading">
  17. <el-table-column prop="created_at" width="200" label="时间" />
  18. <el-table-column prop="title" label="">
  19. <template #default="scope">
  20. <el-tag type="success" class="title" size="default" effect="dark" @click="titleClick(scope.row)">{{
  21. scope.row.title }}</el-tag>
  22. </template>
  23. </el-table-column>
  24. </el-table> -->
  25. <div class="noticebody h-full">
  26. <div class="notice-item itme" :class="item.id == notice.id ? 'active':'' " @click="titleClick(item)" v-for="(item,index) in currentTableData" :key="index" >
  27. <el-badge v-if="item.is_read == 0" is-dot class="item">
  28. <el-icon><Bell /></el-icon>
  29. </el-badge>
  30. <el-icon v-else ><Bell /></el-icon>
  31. <label class="notices" >
  32. {{item.title}}
  33. <p class="n-time-text">{{item.created_at}}</p>
  34. </label>
  35. </div>
  36. </div>
  37. <div v-show="currentTableData.length < 1" style="display: flex;justify-content: center;">
  38. <label style="color: darkgray;"> 暂无新通知</label>
  39. </div>
  40. </el-tab-pane>
  41. <Paginate />
  42. </el-tabs>
  43. </el-col>
  44. <el-col :span="0" >
  45. <div > </div>
  46. </el-col>
  47. <el-col :span="16" style="background-color: #fff;">
  48. <div style="width: 100%;height: 40px;background-color: #fff;"><el-button class="bak-txt" @click="go2page">返回</el-button></div>
  49. <div sclass="flex h-full flex-wrap break-all" v-html="notice.content"></div>
  50. </el-col>
  51. </el-row>
  52. </div>
  53. <el-dialog draggable v-model="centerDialogVisible" :title="notice.title" width="30%" center>
  54. <div class="flex flex-wrap break-all" v-html="notice.content"></div>
  55. <template #footer>
  56. <span class="dialog-footer">
  57. <el-button @click="readNotice">我知道了</el-button>
  58. </span>
  59. </template>
  60. </el-dialog>
  61. </template>
  62. <script lang="ts" setup>
  63. import { useGetList} from '@/hook/curd/useGetList';
  64. import noticeBlock from "./dataStatistics/notices.vue";
  65. import todayData from "./dataStatistics/todayData.vue";
  66. import { Bell } from '@element-plus/icons-vue';
  67. import { ref } from 'vue'
  68. import type { TabsPaneContext } from 'element-plus'
  69. import {noticeListMine, noticesTypesList, noticeDetail, noticeRead, noticePopup } from '@/api/notice/index';
  70. import showVue from '@/components/admin/buttons/show.vue';
  71. const api = 'system/notices/notice/mine';
  72. const centerDialogVisible = ref(false)
  73. const notice = ref({})
  74. const noticesTypes = ref<object>([]);
  75. const activeName = ref(0)
  76. const showAll = ref(false)
  77. const { data, query, search, reset, loading } = useGetList(api, true);
  78. const currentTableData = computed(() => data.value?.data);
  79. const readNotice = () => {
  80. noticeRead(notice.value.id).then(res => {
  81. // console.log(res);
  82. search();
  83. })
  84. centerDialogVisible.value = false
  85. }
  86. const getFistNotice = async () => {
  87. let param = query.value;
  88. param.limit = 1;
  89. await noticeListMine(param).then(res => {
  90. let temp = res.data.shift(0);
  91. if(temp){
  92. if(showAll.value == true){
  93. titleClick(temp);
  94. }
  95. notice.value = temp;
  96. }else{
  97. notice.value = {};
  98. }
  99. })
  100. };
  101. const initNoticeOtion = (params: object) => {
  102. noticesTypesList(params).then(res => {
  103. noticesTypes.value = res.data
  104. noticesTypes.value.unshift({ id: 0, name: '全部' })
  105. })
  106. }
  107. const go2page = () =>{
  108. showAll.value = !showAll.value;
  109. if(showAll.value == true){
  110. if(notice.value.id){
  111. titleClick(notice.value);
  112. }
  113. }
  114. }
  115. const titleClick = (e) => {
  116. noticeDetail(e.id).then(res => {
  117. console.log(res);
  118. // centerDialogVisible.value = true;
  119. notice.value.id = res.data.id
  120. notice.value.title = res.data.title
  121. notice.value.content = res.data.content
  122. readNotice();
  123. })
  124. }
  125. const handleClick = (tab: TabsPaneContext, event: Event) => {
  126. console.log(tab, event, tab.props.name)
  127. activeName.value = Number(tab?.props?.name)
  128. query.value.notice_type_id = tab.props.name;
  129. search();
  130. getFistNotice();
  131. }
  132. onMounted(async () => {
  133. noticePopup().then(res => {
  134. if (res.data.id) {
  135. centerDialogVisible.value = true;
  136. notice.value.id = res.data.id
  137. notice.value.title = res.data.title
  138. notice.value.content = res.data.content
  139. }
  140. })
  141. query.value.notice_type_id = activeName;
  142. await search();
  143. initNoticeOtion({})
  144. getFistNotice();
  145. });
  146. </script>
  147. <style lang="scss" scoped>
  148. .header-title {
  149. margin-bottom: 10px;
  150. display: flex;
  151. align-items: center;
  152. justify-content:space-between;
  153. h4{
  154. margin-right: 50px;
  155. color: #29d;
  156. }
  157. }
  158. .bak-txt{
  159. border-color: aliceblue;
  160. line-height: 40px;
  161. float: right;
  162. margin-top: 20px;
  163. // color: #29d;;
  164. margin-right: 40px;
  165. }
  166. .tabs>.el-tabs__content {
  167. color: #6b778c;
  168. font-size: 32px;
  169. font-weight: 600;
  170. }
  171. .title {
  172. cursor: pointer;
  173. }
  174. .notice-item{
  175. display: flex;
  176. margin-top: 5px;
  177. }
  178. .active{
  179. color:#29d;
  180. }
  181. .notices{
  182. font-size: 20px;
  183. margin-left: 10px;
  184. line-height: 18px;;
  185. }
  186. .n-time-text{
  187. margin-top: 5px;
  188. font-size: 14px;
  189. }
  190. .logo{
  191. width: 18px;
  192. }
  193. .h-full{
  194. height: calc(60vh);
  195. }
  196. </style>