received.vue 6.3 KB

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