index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <div v-if="isInit" class="message-main animate__animated" ref="ref_message" v-loading="loadingPage" element-loading-background="rgba(0, 0, 0, 0.7)">
  3. <div class="ma-head">
  4. <div class="mah-block"/>
  5. <span class="mah-title">通知公告</span>
  6. <span class="mah-title-en">INFORM</span>
  7. <span class="mah-back __hover" @click="$emit('update:show', false)">返回 》</span>
  8. </div>
  9. <div class="ma-content" ref="ref_messagePage">
  10. <template v-for="(item, index) in queryResult.data">
  11. <div class="mac-item" :class="{active: currentId === item.id}" @click="onMessageInfo(item)">
  12. <div class="mac-item-index">{{index + 1}}</div>
  13. <div class="mac-item-title">{{item.title}}</div>
  14. <div class="mac-item-time">{{$util.YMD(item.createTime)}}</div>
  15. </div>
  16. <div class="mac-item-line"/>
  17. </template>
  18. </div>
  19. <div class="message-info" v-if="showInfo">
  20. <div class="mi-content" v-loading="loadingInfo">
  21. <div class="mic-title">{{messageInfo.title}}</div>
  22. <div class="mic-time">{{messageInfo.createTime}}</div>
  23. <div class="mic-line"/>
  24. <div class="mic-html" v-html="messageInfo.content"/>
  25. </div>
  26. <div class="mi-buttons">
  27. <div class="__hover download" @click="onMessageDownload" v-if="messageInfo.attachmentName" v-loading="loadingDownload">下载附件</div>
  28. <div class="__hover back" @click="onMessageBack">返回</div>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script lang="ts">
  34. import {
  35. defineComponent,
  36. computed,
  37. onMounted,
  38. ref,
  39. reactive,
  40. watch,
  41. getCurrentInstance,
  42. ComponentInternalInstance,
  43. toRefs,
  44. nextTick
  45. } from 'vue'
  46. import {useStore} from 'vuex'
  47. import {useRouter, useRoute} from 'vue-router'
  48. export default defineComponent({
  49. name: '',
  50. components: {},
  51. props: {
  52. show: {
  53. required: true
  54. }
  55. },
  56. setup(props) {
  57. const store = useStore();
  58. const router = useRouter();
  59. const route = useRoute();
  60. const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
  61. const ref_message = ref()
  62. const ref_messagePage = ref()
  63. const state = reactive({
  64. isInit: false,
  65. queryParams: {
  66. page: 1,
  67. pageSize: 20
  68. },
  69. queryResult: {
  70. data: [],
  71. total: 0,
  72. totalPage: 0
  73. },
  74. currentId: null,
  75. loadingPage: true,
  76. loadingInfo: false,
  77. loadingDownload: false,
  78. messageInfo: {},
  79. showInfo: false
  80. })
  81. watch(() => props.show, (n) => {
  82. state.isInit = true
  83. nextTick(() => {
  84. if (n) {
  85. ref_message.value.classList.remove('animate__fadeOutRight')
  86. ref_message.value.classList.add('animate__fadeInRight')
  87. } else {
  88. ref_message.value.classList.remove('animate__fadeInRight')
  89. ref_message.value.classList.add('animate__fadeOutRight')
  90. }
  91. })
  92. })
  93. watch(() => state.isInit, () => {
  94. nextTick(() => {
  95. ref_messagePage.value.onscroll = () => {
  96. const scrollHeight = ref_messagePage.value.scrollHeight;
  97. const scrollTop = ref_messagePage.value.scrollTop;
  98. const clientHeight = ref_messagePage.value.clientHeight;
  99. if (scrollHeight - clientHeight == scrollTop) {
  100. if (state.queryParams.page < state.queryResult.totalPage) {
  101. state.queryParams.page++
  102. initData()
  103. }
  104. }
  105. }
  106. })
  107. })
  108. const initData = () => {
  109. state.loadingPage = true
  110. that.$api.noticeMorePage(state.queryParams).then((res: { data: {
  111. totalPage: number; dataList: never[]; totalCount: number;
  112. }; }) => {
  113. state.queryResult.data = [...state.queryResult.data, ...res.data.dataList]
  114. state.queryResult.totalPage = res.data.totalPage
  115. state.loadingPage = false
  116. }).catch(() => {
  117. state.loadingPage = false
  118. })
  119. }
  120. const onMessageInfo = (val: { id: null; }) => {
  121. state.showInfo = true
  122. state.currentId = val.id
  123. state.loadingInfo = true
  124. that.$api.noticeMoreInfo(state.currentId).then((res: { code: number; data: {}; }) => {
  125. if (res.code === 0) {
  126. state.messageInfo = res.data
  127. }
  128. state.loadingInfo = false
  129. }).catch(() => {
  130. state.loadingInfo = false
  131. })
  132. }
  133. const onMessageBack = () => {
  134. state.showInfo = false
  135. state.currentId = null
  136. state.messageInfo = {}
  137. }
  138. const onMessageDownload = () => {
  139. state.loadingDownload = true
  140. that.$api.noticeMoreInfoDownload(state.messageInfo.id).then(res => {
  141. state.loadingDownload = false
  142. }).catch(() => {
  143. state.loadingDownload = false
  144. })
  145. }
  146. onMounted(() => {
  147. if (store.getters['app/isLogin']) {
  148. initData()
  149. }
  150. })
  151. return {
  152. ...toRefs(state),
  153. ref_message,
  154. ref_messagePage,
  155. onMessageInfo,
  156. onMessageBack,
  157. onMessageDownload
  158. }
  159. },
  160. })
  161. </script>
  162. <style scoped lang="scss">
  163. $messageWidth: 990px;
  164. .message-main {
  165. z-index: 2;
  166. position: absolute;
  167. right: 0;
  168. width: $messageWidth;
  169. height: 100%;
  170. background: #31538C;
  171. box-sizing: border-box;
  172. padding-top: 30px;
  173. $mainPL: 26px;
  174. $mainPR: 22px;
  175. display: flex;
  176. flex-direction: column;
  177. .ma-head {
  178. margin: 0 $mainPR 0 $mainPL;
  179. display: flex;
  180. align-items: center;
  181. padding-bottom: 9px;
  182. border-bottom: 1px solid #0B3672;
  183. .mah-block {
  184. width: 5px;
  185. height: 25px;
  186. background: #82D6FF;
  187. }
  188. .mah-title {
  189. margin-left: 11px;
  190. font-size: 24px;
  191. font-family: FZLanTingHeiS-DB-GB;
  192. font-weight: 400;
  193. color: #32DCFB;
  194. }
  195. .mah-title-en {
  196. margin-left: 8px;
  197. font-size: 16px;
  198. font-family: FZLanTingHeiS-DB-GB;
  199. font-weight: 400;
  200. color: rgba(255, 255, 255, 0.2);
  201. }
  202. .mah-back {
  203. margin-left: auto;
  204. font-size: 16px;
  205. font-family: FZLanTingHeiS-DB-GB;
  206. font-weight: 400;
  207. color: #32DCFB;
  208. }
  209. }
  210. .ma-content {
  211. flex: 1;
  212. overflow-y: auto;
  213. .mac-item {
  214. margin: 12px 0;
  215. padding: 0 $mainPR 0 $mainPL;
  216. height: 46px;
  217. display: flex;
  218. align-items: center;
  219. .mac-item-index {
  220. padding: 4px 6px;
  221. background: #0B3672;
  222. display: flex;
  223. align-items: center;
  224. justify-content: center;
  225. font-size: 16px;
  226. font-family: FZLanTingHeiS-DB-GB;
  227. font-weight: 400;
  228. color: #FFFFFF;
  229. }
  230. .mac-item-title {
  231. flex: 1;
  232. margin-left: 10px;
  233. margin-right: 40px;
  234. font-size: 20px;
  235. font-family: FZLanTingHeiS-DB-GB;
  236. font-weight: 400;
  237. color: #FFFFFF;
  238. overflow: hidden;
  239. text-overflow: ellipsis;
  240. white-space: nowrap;
  241. }
  242. .mac-item-time {
  243. margin-left: auto;
  244. font-size: 16px;
  245. font-family: FZLanTingHeiS-DB-GB;
  246. font-weight: 400;
  247. color: #C9C9C9;
  248. }
  249. &:nth-child(1) {
  250. .mac-item-index {
  251. background-color: #FF8363;
  252. }
  253. }
  254. &:nth-child(3) {
  255. .mac-item-index {
  256. background-color: #63B841;
  257. }
  258. }
  259. &:nth-child(5) {
  260. .mac-item-index {
  261. background-color: #4481FE;
  262. }
  263. }
  264. &.active {
  265. background-color: #5A75A3;
  266. position: relative;
  267. //&:before {
  268. // position: absolute;
  269. // content: '';
  270. // left: 0;
  271. // border-top: 10px solid transparent;
  272. // border-bottom: 10px solid transparent;
  273. // border-right: 10px solid #5A75A3;
  274. // transform: translateX(-10px);
  275. //}
  276. }
  277. &:hover {
  278. cursor: pointer;
  279. background-color: #5A75A3;
  280. }
  281. }
  282. .mac-item-line {
  283. margin: 0 $mainPR 0 $mainPL;
  284. border-bottom: 1px dashed #C9C9C9;
  285. }
  286. }
  287. }
  288. .message-info {
  289. position: absolute;
  290. right: $messageWidth;
  291. height: calc(100% - 60px);
  292. width: 1373px;
  293. background-color: #ffffff;
  294. box-sizing: border-box;
  295. padding: 58px 0 22px;
  296. display: flex;
  297. flex-direction: column;
  298. .mi-content {
  299. width: 100%;
  300. height: calc(100% - 20px - 56px);
  301. display: flex;
  302. flex-direction: column;
  303. align-items: center;
  304. .mic-title {
  305. font-size: 38px;
  306. font-family: Microsoft YaHei;
  307. font-weight: 400;
  308. color: #333333;
  309. width: 100%;
  310. text-align: center;
  311. }
  312. .mic-time {
  313. margin-top: 16px;
  314. font-size: 20px;
  315. font-family: SimSun;
  316. font-weight: 400;
  317. color: #666666;
  318. }
  319. .mic-line {
  320. margin-top: 16px;
  321. width: calc(100% - 120px);
  322. height: 1px;
  323. background: #DCDCDC;
  324. }
  325. .mic-html {
  326. flex: 1;
  327. margin-top: 28px;
  328. width: 100%;
  329. padding: 0 180px;
  330. overflow-y: auto;
  331. box-sizing: border-box;
  332. font-size: 20px;
  333. font-weight: 400;
  334. color: #333333;
  335. line-height: 32px;
  336. }
  337. }
  338. .mi-buttons {
  339. margin-top: 20px;
  340. width: 100%;
  341. display: flex;
  342. align-items: center;
  343. justify-content: center;
  344. >div {
  345. width: 150px;
  346. height: 56px;
  347. font-size: 20px;
  348. font-family: FZLanTingHeiS-DB-GB;
  349. font-weight: 400;
  350. display: flex;
  351. align-items: center;
  352. justify-content: center;
  353. box-sizing: border-box;
  354. border-radius: 3px;
  355. }
  356. .download {
  357. background: #4481FE;
  358. color: #FFFFFF;
  359. margin-right: 20px;
  360. }
  361. .back {
  362. background: rgba(68,129,254,0.2);
  363. border: 1px solid #4481FE;
  364. color: #4481FE;
  365. }
  366. }
  367. }
  368. </style>