received.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div class="received">
  3. <div class="r_header">
  4. <div class="r_h_title">已收通知</div>
  5. <div class="r_h_right">
  6. <div class="r_h_r_total">
  7. 共(
  8. <div>{{ pageData.total }}</div>
  9. )封
  10. </div>
  11. <el-input
  12. style="width: 250px;"
  13. placeholder="请输入关键词"
  14. v-model="searchValue"
  15. >
  16. <i slot="suffix" class="el-input__icon el-icon-search" style="cursor: pointer;font-size: 18px;color: #000;" @click="getData()"></i>
  17. </el-input>
  18. </div>
  19. </div>
  20. <div class="r_content" v-loading="tableLoading">
  21. <el-table
  22. :data="tableData"
  23. :header-cell-style="{ background: '#f1f1f1', fontSize: '17px' }"
  24. style="width: 100%"
  25. @row-click="showNoticeDetail"
  26. :row-style="{cursor:'pointer'}"
  27. height="calc(100%)"
  28. >
  29. <el-table-column
  30. fixed
  31. prop="title"
  32. label="通知标题"
  33. width="auto"
  34. min-width="200"
  35. >
  36. <template slot-scope="scope">
  37. <span v-html="scope.row.title"></span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="状态 " width="150" align="center">
  41. <template slot-scope="scope">
  42. <span class="status" :class="`status_${scope.row.status}`">{{
  43. status[scope.row.status]
  44. }}</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column prop="type" label="类型 " width="150" align="center">
  48. </el-table-column>
  49. <el-table-column
  50. prop="create_at"
  51. label="时间 "
  52. width="250"
  53. align="center"
  54. >
  55. </el-table-column>
  56. <el-table-column
  57. prop="publisherName"
  58. label="发布者 "
  59. width="300"
  60. align="center"
  61. >
  62. </el-table-column>
  63. <el-table-column
  64. prop="source"
  65. label="发布来源"
  66. width="200"
  67. align="center"
  68. >
  69. </el-table-column>
  70. </el-table>
  71. </div>
  72. <div class="r_bottom">
  73. <el-pagination
  74. @size-change="handleSizeChange"
  75. @current-change="handleCurrentChange"
  76. :current-page="pageData.nowPage"
  77. :page-sizes="[10, 20, 30, 40]"
  78. :page-size="pageData.size"
  79. layout="sizes, prev, pager, next"
  80. :total="pageData.total"
  81. >
  82. </el-pagination>
  83. </div>
  84. <noticeDetailDialog ref="noticeDetailDialogRef"/>
  85. </div>
  86. </template>
  87. <script>
  88. import noticeDetailDialog from '../dialog/noticeDetailDialog.vue';
  89. export default {
  90. components: {
  91. noticeDetailDialog
  92. },
  93. data() {
  94. return {
  95. userId: this.$route.query.userid,
  96. org: this.$route.query.org,
  97. oid: this.$route.query.oid,
  98. tableLoading: false,
  99. status: ["未读", "已读"],
  100. searchValue: "",
  101. tableData: [],
  102. copyData: [],
  103. pageData: {
  104. nowPage: 1,
  105. total: 0,
  106. size: 20
  107. }
  108. };
  109. },
  110. methods: {
  111. handleSizeChange(val) {
  112. this.pageData.size = val;
  113. this.getData();
  114. },
  115. handleCurrentChange(val) {
  116. this.pageData.nowPage = val;
  117. this.getData();
  118. },
  119. getData() {
  120. if (this.tableLoading) return;
  121. this.tableLoading = true;
  122. let params = [
  123. {
  124. uid: this.userId,
  125. status: "",
  126. type: "",
  127. source: "",
  128. pUid: "",
  129. searchValue: this.searchValue,
  130. pageNum: this.pageData.nowPage,
  131. pageSize: this.pageData.size
  132. }
  133. ];
  134. this.ajax
  135. .post(this.$store.state.api + "select_noticeCenter", params)
  136. .then(res => {
  137. let _resData = res.data[0];
  138. if (_resData.length > 0) {
  139. _resData.forEach(item => {
  140. item.content = JSON.parse(item.content);
  141. })
  142. this.copyData = _resData;
  143. this.tableData = _resData;
  144. this.pageData.total = res.data[1][0].total;
  145. } else {
  146. this.copyData = [];
  147. this.pageData.total = 0;
  148. this.pageData.nowPage = 1;
  149. }
  150. this.tableLoading = false;
  151. // this.tableData = res.data.list
  152. // this.pageData.total = res.data.total
  153. })
  154. .catch(e => {
  155. console.log(e);
  156. this.$message.error("获取通知失败");
  157. this.tableLoading = false;
  158. });
  159. },
  160. showNoticeDetail(row){
  161. this.$refs.noticeDetailDialogRef.open(row)
  162. if(row.status!=1){
  163. this.changeStatus(row.id,1)
  164. }
  165. },
  166. changeStatus(id,newStatus){
  167. let params = [{
  168. uid:this.userId,
  169. id:id,
  170. status:newStatus
  171. }]
  172. this.ajax.post(this.$store.state.api+"update_noticeCenter_statusByid",params).then(res=>{
  173. if(res.data==1){
  174. this.tableData.find(i=>i.id===id).status = newStatus;
  175. console.log("更新状态成功");
  176. }
  177. }).catch(err=>{
  178. console.log("更新状态失败",err);
  179. })
  180. }
  181. },
  182. mounted() {
  183. this.getData();
  184. }
  185. };
  186. </script>
  187. <style scoped>
  188. .received {
  189. width: calc(100%);
  190. height: 100%;
  191. padding: 20px 20px;
  192. background: #fff;
  193. border: solid 1px #dfdfe0;
  194. border-radius: 4px;
  195. box-sizing: border-box;
  196. }
  197. .r_header {
  198. width: 100%;
  199. height: 80px;
  200. display: flex;
  201. box-sizing: border-box;
  202. align-items: center;
  203. justify-content: space-between;
  204. }
  205. .r_h_right {
  206. width: fit-content;
  207. display: flex;
  208. align-items: center;
  209. }
  210. .r_h_r_total {
  211. width: fit-content;
  212. margin-right: 20px;
  213. display: flex;
  214. align-items: center;
  215. }
  216. .r_h_r_total > div {
  217. display: flex;
  218. color: #5398e3;
  219. }
  220. .r_h_title {
  221. font-size: 28px;
  222. font-weight: bold;
  223. }
  224. .r_content {
  225. width: 100%;
  226. height: calc(100% - 80px - 40px);
  227. overflow: auto;
  228. box-sizing: border-box;
  229. padding: 20px 0px;
  230. border-top: solid 1px #dfdfe0;
  231. }
  232. .status {
  233. padding: 0px 10px;
  234. border-radius: 4px;
  235. height: 30px;
  236. width: fit-content;
  237. display: flex;
  238. align-items: center;
  239. justify-content: center;
  240. margin: 0 auto;
  241. }
  242. .status_0 {
  243. background: #f3f4f6;
  244. color: #4d5765;
  245. border: solid 1px #d4d8dd;
  246. }
  247. .status_1 {
  248. background: #ecfdf5;
  249. color: #10664e;
  250. border: solid 1px #abf4d3;
  251. }
  252. .r_bottom {
  253. width: 100%;
  254. height: 40px;
  255. display: flex;
  256. align-items: center;
  257. justify-content: flex-end;
  258. }
  259. </style>