index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <template >
  2. <div class="message">
  3. <el-row>
  4. <el-col :span="12">
  5. <div class="left">
  6. <div class="select">
  7. <div>
  8. <el-button-group>
  9. <el-button
  10. size="small"
  11. :type="currentItem == 1 ? 'primary' : ''"
  12. @click="selectFun('应用')"
  13. >{{ $t("应用消息") }}</el-button
  14. >
  15. <el-button
  16. size="small"
  17. :type="currentItem == 0 ? 'primary' : ''"
  18. @click="selectFun('系统')"
  19. >{{ $t("系统消息") }}</el-button
  20. >
  21. </el-button-group>
  22. <!-- <div @click="selectFun('应用')"
  23. :style="currentItem==1 ? 'background:#3874F6;color:#ffffff;vertical-align: middle;line-height: 30px;height: 30px' : 'border:1px solid #cccccc;vertical-align: middle;line-height: 30px;height: 30px'">应用消息</div>
  24. <div @click="selectFun('系统')"
  25. :style="currentItem==0 ? 'background:#3874F6;color:#ffffff' : 'border:1px solid #cccccc'">系统消息</div>-->
  26. </div>
  27. <div class="select_right">
  28. <el-button @click="allRead" size="small">{{
  29. $t("全部标为已读")
  30. }}</el-button>
  31. </div>
  32. </div>
  33. <el-row style="margin-top: 10px">
  34. <el-col :span="14">
  35. <div style="margin-left: 16px; font-size: 14px">
  36. {{ $t("总计") }}:{{ total }}
  37. </div>
  38. </el-col>
  39. <el-col :span="10">
  40. <div style="float: right; margin-right: 16px">
  41. <el-switch
  42. style="z-index: 9999"
  43. v-model="isRead"
  44. :active-text="$t('只看未读')"
  45. active-value="1"
  46. inactive-value="0"
  47. @change="readChange"
  48. >
  49. </el-switch>
  50. </div>
  51. </el-col>
  52. </el-row>
  53. <list
  54. class="list"
  55. :list="list"
  56. @messageItemClick="messageItemClick"
  57. ref="list"
  58. ></list>
  59. <pagination
  60. :total="total"
  61. :pageSize="param.content.pageSize"
  62. :currentPage="param.content.pageNumber"
  63. @pageChange="pageChange"
  64. >
  65. </pagination>
  66. </div>
  67. </el-col>
  68. <el-col :span="12">
  69. <div class="right" v-if="message">
  70. <p class="title">{{ message.title }}</p>
  71. <p class="info">
  72. <span
  73. >{{ $t("发布于") }}:{{ message.createdate }} |
  74. {{ message.name || message.type }}</span
  75. >
  76. </p>
  77. <div class="content-txt">
  78. <!-- <p class="txt">{{message.message}}</p>-->
  79. <p class="txt">
  80. <span v-for="(item, index) in message.message">
  81. <span v-if="index === message.message.length - 1">{{
  82. $t(item)
  83. }}</span>
  84. <span v-else>{{ item + ";" }}<br /></span>
  85. </span>
  86. </p>
  87. <p
  88. class="link"
  89. @click="goDetail"
  90. v-if="currentItem == 1 && message.link"
  91. >
  92. {{ $t("请前往") }} {{ message.title }}>>
  93. </p>
  94. </div>
  95. </div>
  96. </el-col>
  97. </el-row>
  98. </div>
  99. </template>
  100. <script>
  101. import list from "@/views/message/components/list";
  102. import pagination from "@/components/pagination/Pagination1";
  103. export default {
  104. name: "",
  105. data() {
  106. return {
  107. currentItem: 1,
  108. isRead: "0",
  109. param: {
  110. classname: "system.message.Message",
  111. method: "queryMessage",
  112. content: {
  113. nocache: true,
  114. pageNumber: 1,
  115. pageSize: 15,
  116. isread: "",
  117. type: "",
  118. where: {
  119. isread: "",
  120. },
  121. },
  122. },
  123. list: [],
  124. total: 0,
  125. message: "",
  126. isAllClick: true,
  127. };
  128. },
  129. components: { list, pagination },
  130. computed: {},
  131. watch: {},
  132. created() {
  133. this.getMessageList();
  134. },
  135. methods: {
  136. async getMessageList() {
  137. this.param.content.type = this.currentItem == 0 ? "系统" : "应用";
  138. let res = await this.$api.requested(this.param);
  139. if (res.code == 1) {
  140. res.data.forEach((item) => {
  141. this.isCategory(item);
  142. });
  143. this.list = res.data;
  144. this.list.forEach((item) => {
  145. item.message = item.message.split(";");
  146. });
  147. this.message = "";
  148. if (this.list[0]) this.messageItemClick(this.list[0]);
  149. this.total = res.total;
  150. }
  151. },
  152. selectFun(data) {
  153. this.message = "";
  154. this.param.content.pageNumber = 1;
  155. this.currentItem = data == "系统" ? 0 : 1;
  156. this.getMessageList();
  157. },
  158. pageChange(n) {
  159. this.$refs.list.$refs.listScroll.scrollTop = 0;
  160. this.param.content.pageNumber = n;
  161. this.getMessageList();
  162. },
  163. async messageItemClick(data) {
  164. let res = await this.$api.requested({
  165. classname: "system.message.Message",
  166. method: "readMessage",
  167. content: {
  168. nocache: true,
  169. messageid: data.messageid,
  170. },
  171. });
  172. data.isread = 1;
  173. res.data.name = data.name;
  174. res.data.link = data.link;
  175. res.data.modules = data.modules;
  176. this.message = res.data;
  177. this.message.message = this.message.message.split(";");
  178. },
  179. async allRead() {
  180. if (!this.isAllClick) return;
  181. let res = await this.$api.requested({
  182. classname: "system.message.Message",
  183. method: "readAllMessage",
  184. content: {
  185. nocache: true,
  186. },
  187. });
  188. this.tool.showMessage(res, () => {
  189. this.list.forEach((item) => {
  190. item.isread = 1;
  191. });
  192. this.isAllClick = false;
  193. setTimeout(() => {
  194. this.isAllClick = true;
  195. }, 5000);
  196. });
  197. },
  198. //跳转到消息具体页面
  199. goDetail() {
  200. sessionStorage.setItem(
  201. "active_modules",
  202. JSON.stringify(this.message.modules)
  203. );
  204. console.log(this.message.link, "link");
  205. console.log(this.message, "message");
  206. /* this.$router.push(this.message.link.listPath)*/
  207. if (this.message.objectname === "sat_orderclueuploadbill") {
  208. setTimeout(() => {
  209. this.$store.dispatch("changeDetailDrawer", false);
  210. let route = this.$route;
  211. this.oldRoute = { path: route.path, query: route.query };
  212. this.$store.dispatch("setHistoryRouter", this.oldRoute);
  213. this.$router.push({
  214. path: "/clue_public",
  215. query: {
  216. id: this.message.objectid,
  217. portrait: "",
  218. },
  219. });
  220. });
  221. } else {
  222. if (this.message.link.detail) {
  223. setTimeout(() => {
  224. this.$store.dispatch("changeDetailDrawer", true);
  225. let route = this.$route;
  226. if (route.path !== this.message.link.detail.slice(0)) {
  227. this.oldRoute = { path: route.path, query: route.query };
  228. this.$store.dispatch("setHistoryRouter", this.oldRoute);
  229. }
  230. this.$router.push({
  231. path: this.message.link.detail,
  232. query: {
  233. id: this.message.objectid,
  234. portrait: "",
  235. },
  236. });
  237. });
  238. } else {
  239. switch (this.message.link.listPath) {
  240. case "/workreport":
  241. this.$router.push({
  242. path: this.message.link.listPath,
  243. });
  244. break;
  245. case "/notice_list":
  246. this.$router.push({
  247. path: this.message.link.listPath,
  248. });
  249. break;
  250. case "/notice_mag_list":
  251. this.$router.push({
  252. path: this.message.link.listPath,
  253. });
  254. break;
  255. case "/submitedit_one":
  256. this.$router.push({
  257. path: this.message.link.listPath,
  258. });
  259. break;
  260. case "/submitedit_more":
  261. this.$router.push({
  262. path: this.message.link.listPath,
  263. });
  264. break;
  265. case "/submit_mag":
  266. this.$router.push({
  267. path: this.message.link.listPath,
  268. });
  269. break;
  270. case "/archives_list":
  271. this.$router.push({
  272. path: this.message.link.listPath,
  273. });
  274. break;
  275. case "/archvies_mag":
  276. this.$router.push({
  277. path: this.message.link.listPath,
  278. });
  279. break;
  280. case "/archives_admag":
  281. this.$router.push({
  282. path: this.message.link.listPath,
  283. });
  284. break;
  285. case "/archives_adlist":
  286. this.$router.push({
  287. path: this.message.link.listPath,
  288. });
  289. break;
  290. case "/archives_adclass":
  291. this.$router.push({
  292. path: this.message.link.listPath,
  293. });
  294. break;
  295. case "/archives_sc_list":
  296. this.$router.push({
  297. path: this.message.link.listPath,
  298. });
  299. break;
  300. case "/archives_scmag":
  301. this.$router.push({
  302. path: this.message.link.listPath,
  303. });
  304. break;
  305. }
  306. }
  307. }
  308. },
  309. readChange() {
  310. this.isRead == "1"
  311. ? (this.param.content.isread = 0)
  312. : (this.param.content.isread = "");
  313. this.getMessageList();
  314. },
  315. isCategory(data) {
  316. JSON.parse(sessionStorage.getItem("module_info")).forEach((item1) => {
  317. item1.modules.forEach((item2) => {
  318. item2.apps.forEach((item3) => {
  319. if (item3.systemappid == data.systemappid) {
  320. data.modules = item3;
  321. data.link = { listPath: item3.path, detail: item3.path_index };
  322. return;
  323. }
  324. });
  325. });
  326. });
  327. // switch (data.objectname) {
  328. //         case 'sat_courseware':
  329. // data.name = '商学院'
  330. // JSON.parse(sessionStorage.getItem('module_info')).forEach(item1 => {
  331. // item1.modules.forEach(item2 => {
  332. // if(item2.systemmodulename == data.name) {
  333. // data.modules = item2
  334. // data.link = item2.apps[0].path
  335. // return
  336. // }
  337. // })
  338. // })
  339. //             break;
  340. //         case 'sat_sharematerial':
  341. // data.name = '推广素材'
  342. // JSON.parse(sessionStorage.getItem('module_info')).forEach(item1 => {
  343. // item1.modules.forEach(item2 => {
  344. // if(item2.systemmodulename == data.name) {
  345. // data.modules = item2
  346. // data.link = item2.apps[0].path
  347. // return
  348. // }
  349. // })
  350. // })
  351. //             break;
  352. //         case 'sat_notice':
  353. // data.name = '通告'
  354. // JSON.parse(sessionStorage.getItem('module_info')).forEach(item1 => {
  355. // item1.modules.forEach(item2 => {
  356. // if(item2.systemmodulename == data.name) {
  357. // data.modules = item2
  358. // data.link = item2.apps[0].path
  359. // return
  360. // }
  361. // })
  362. // })
  363. //             break;
  364. //         case 'sat_submitedit':
  365. // data.name = '提报'
  366. // JSON.parse(sessionStorage.getItem('module_info')).forEach(item1 => {
  367. // item1.modules.forEach(item2 => {
  368. // if(item2.systemmodulename == data.name) {
  369. // data.modules = item2
  370. // data.link = item2.apps[0].path
  371. // return
  372. // }
  373. // })
  374. // })
  375. //             break;
  376. //         case 'sat_orderclue':
  377. // data.name = '销售线索'
  378. // JSON.parse(sessionStorage.getItem('module_info')).forEach(item1 => {
  379. // item1.modules.forEach(item2 => {
  380. // if(item2.systemmodulename == data.name) {
  381. // data.modules = item2
  382. // data.link = item2.apps[0].path
  383. // return
  384. // }
  385. // })
  386. // })
  387. //             break;
  388. //         case 'sys_attachment':
  389. // data.name = '营销物料'
  390. // JSON.parse(sessionStorage.getItem('module_info')).forEach(item1 => {
  391. // item1.modules.forEach(item2 => {
  392. // if(item2.systemmodulename == data.name) {
  393. // data.modules = item2
  394. // data.link = item2.apps[0].path
  395. // return
  396. // }
  397. // })
  398. // })
  399. //             break;
  400. //      }
  401. },
  402. },
  403. };
  404. </script>
  405. <style scoped>
  406. * {
  407. box-sizing: border-box;
  408. }
  409. .message {
  410. width: 100%;
  411. margin: 0 auto;
  412. position: relative;
  413. /*min-height: calc(100vh - 199px);
  414. max-height: calc(100vh - 199px);*/
  415. height: calc(100vh - 120px);
  416. }
  417. .message .left {
  418. position: relative;
  419. padding: 20px 0 60px 0;
  420. box-shadow: 1px 0px 0px 1px #dddddd;
  421. background: #ffffff;
  422. height: calc(100vh - 120px);
  423. /*min-height: calc(100vh - 199px);
  424. max-height: calc(100vh - 199px);*/
  425. }
  426. .message .list {
  427. max-height: calc(100vh - 260px);
  428. min-height: calc(100vh - 260px);
  429. overflow: auto;
  430. }
  431. .message .select {
  432. width: 100%;
  433. height: 36px;
  434. border-radius: 4px;
  435. display: flex;
  436. justify-content: space-between;
  437. padding: 0 16px;
  438. }
  439. .message .select .select_left {
  440. display: flex;
  441. justify-content: space-between;
  442. font-size: 14px;
  443. margin-left: 16px;
  444. }
  445. .message .select .select_left div {
  446. height: 34px;
  447. text-align: center;
  448. cursor: pointer;
  449. padding: 8px 22px;
  450. transition: background 0.2s ease-in-out;
  451. }
  452. .message .select .select_left div:first-child {
  453. border-top-left-radius: 4px;
  454. border-bottom-left-radius: 4px;
  455. }
  456. .message .select .select_left div:last-child {
  457. border-top-right-radius: 4px;
  458. border-bottom-right-radius: 4px;
  459. }
  460. .message .right {
  461. padding: 20px 16px;
  462. }
  463. .message .right .title {
  464. font-size: 16px;
  465. font-weight: bold;
  466. color: #333333;
  467. }
  468. .message .right .info {
  469. font-size: 12px;
  470. font-weight: 400;
  471. color: #333333;
  472. margin: 16px 0;
  473. }
  474. .message .right .content-txt {
  475. width: 100%;
  476. padding: 20px 16px;
  477. font-size: 14px;
  478. font-weight: 400;
  479. background: #ffffff;
  480. }
  481. .message .right .content-txt .txt {
  482. color: #666666;
  483. }
  484. .message .right .content-txt .link {
  485. margin-top: 16px;
  486. color: #3874f6;
  487. font-size: 14px;
  488. cursor: pointer;
  489. }
  490. /* .message .right .content-txt p:last-child {
  491. color: #3874F6;
  492. } */
  493. /deep/.el-pagination {
  494. position: absolute;
  495. right: 16px;
  496. bottom: 0;
  497. }
  498. /deep/.el-empty {
  499. position: absolute;
  500. left: 50%;
  501. top: 50%;
  502. transform: translate(-50%, -50%);
  503. }
  504. </style>