userCenterNotificationNotice.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <div style="width: 100%;background: #fff;min-height: 700px;color: #666;" class="userCenterMyProject">
  3. <div style="height: 60px;line-height: 60px;padding-top: 10px;margin-left: 30px;margin-right: 30px; border-bottom: 1px solid rgba(228, 228, 228, 1);">
  4. <el-button @click="deleteItems()">{{$t('common.Delete')}}</el-button>
  5. <el-button type="warning" @click="changeReadStatus">{{$t('common.MarkRead')}}</el-button>
  6. <el-input :placeholder="$t('common.keywordSearch')" v-model="query" style="float: right;margin-top: 10px;" maxlength="10" show-word-limit>
  7. <template slot="append"><i class="el-icon-search" @click="keyWordSearch()"></i></template>
  8. </el-input>
  9. </div>
  10. <div style="margin-left: 30px;">
  11. <el-table
  12. :data="tableData"
  13. stripe
  14. highlight-current-row
  15. @selection-change="handleSelectionChange"
  16. :row-class-name="tableRowClassName"
  17. style="width: 100%" >
  18. <template slot="empty">
  19. {{$t('common.UserNoData')}}
  20. </template>
  21. <el-table-column type="selection" width="50"> </el-table-column>
  22. <el-table-column prop="title" :label="$t('common.Title')" width='200'> </el-table-column>
  23. <el-table-column prop="content" :label="$t('common.Content')" width='300'> </el-table-column>
  24. <el-table-column prop="createDate" :label="$t('common.ReceivingTime')" width="250"></el-table-column>
  25. <el-table-column prop="pushNoticeTypeDict" :label="$t('common.Type')" width="150"></el-table-column>
  26. </el-table>
  27. </div>
  28. <div style="width: 100%;text-align: center;">
  29. <el-pagination
  30. style="margin-top: 50px;height: 80px;"
  31. background
  32. layout="prev, pager, next"
  33. :total=totalCount @size-change="handleSizeChange"
  34. @current-change="handleCurrentChange">
  35. </el-pagination>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. import {changeNoticeReadStatus,selectPlatFormNotifyNotice,deleteNoticeItems} from '@/api/userCenter'
  41. export default {
  42. name: 'userCenterNotificationNotice',
  43. data () {
  44. return {
  45. formInline: {
  46. user: '',
  47. region: ''
  48. },
  49. query:'',
  50. tableData:'',
  51. pageSize:10,
  52. currentPage:1,
  53. totalCount:0,
  54. pushNoticeType:'', //消息类型
  55. ids:'', //选择的多个id串
  56. array : [], //选择的多个id数组
  57. array2: [], //选择的多个读取状态数组
  58. readStatus:'', //读取状态
  59. multipleSelection:[],
  60. statusDict: {'read': '已读','unread': '未读'},
  61. messageType:{
  62. "dict_msg_fw":this.$t('common.ServiceMessage'),
  63. "dict_msg_hd":this.$t('common.ActiveMessage'),
  64. "dict_msg_sh":this.$t('common.ReviewMessage')},
  65. }
  66. },
  67. mounted () {
  68. this.initTableData();//默认消息类型为全部
  69. },
  70. watch:{
  71. '$i18n.locale' () {
  72. this.initTableData()
  73. },
  74. },
  75. methods:{
  76. tableRowClassName({ row }) {
  77. if (row.readStatus =='unread') {
  78. return 'not-finish';
  79. }
  80. return '';
  81. },
  82. changeType(){
  83. this.messageType={
  84. "dict_msg_fw":this.$t('common.ServiceMessage'),
  85. "dict_msg_hd":this.$t('common.ActiveMessage'),
  86. "dict_msg_sh":this.$t('common.ReviewMessage')
  87. }
  88. },
  89. // tableRowClassName({ row }) {
  90. // if (row.params =='read') {
  91. // return 'finish';
  92. // }
  93. // return '';
  94. // },
  95. // 发布
  96. release(index, rows) {
  97. console.log(index, rows)
  98. },
  99. // 编辑
  100. change(index, rows) {
  101. console.log(index, rows)
  102. },
  103. // 删除
  104. deleteRow(index, rows) {
  105. console.log(index, rows)
  106. },
  107. // 撤回
  108. withdraw(index,rows) {
  109. console.log(index, rows)
  110. },
  111. handleSizeChange(val) {
  112. console.log(`每页 ${val} 条`);
  113. },
  114. handleCurrentChange(val) {
  115. console.log(`当前页: ${val}`);
  116. this.currentPage = val;
  117. this.initTableData();
  118. },
  119. handleSelectionChange(val) {
  120. this.array = [];
  121. this.array2 = [];
  122. console.log(val,'this is val')
  123. this.multipleSelection = val;
  124. var list = this.multipleSelection;
  125. if(list.length==0){
  126. this.array = [];
  127. this.array2 = [];
  128. }
  129. for(var i=0;i<list.length;i++){
  130. this.array.push(list[i].id);
  131. this.array2.push(list[i].params);
  132. }
  133. },
  134. //初始化表格数据
  135. initTableData(){
  136. this.changeType();
  137. selectPlatFormNotifyNotice(this.query, this.pageSize,this.currentPage).then(res=>{
  138. console.log(res.data);
  139. if(res.data.total>0){
  140. var list = res.data.list;
  141. for(var i=0;i<list.length;i++) {
  142. list[i].readingTime = this.YymmddFormat(new Date(list[i].readingTime));
  143. list[i].createDate = this.formatDateAndHouse(parseInt(list[i].createDate));
  144. list[i].pushNoticeTypeDict=this.messageType[list[i].pushNoticeTypeDict];
  145. }
  146. this.tableData = list;
  147. }else{
  148. this.tableData = '';
  149. }
  150. this.totalCount =Number(res.data.total);
  151. })
  152. },
  153. //中国标准时间 转 yy-MM-dd hh:mm:ss
  154. YymmddFormat(newDate) {
  155. let Month = newDate.getMonth() + 1;
  156. Month = Month >= 10 ? Month : '0' + Month;
  157. let d = newDate.getDate();
  158. d = d >= 10 ? d : '0' + d
  159. return [
  160. [newDate.getFullYear(), Month, d].join('-'), [newDate.getHours(), newDate.getMinutes(), newDate.getSeconds()].join(':')
  161. ].join(' ');
  162. },
  163. //关键词搜索
  164. keyWordSearch(){
  165. this.currentPage = 1;
  166. this.initTableData();
  167. },
  168. deleteItems(){
  169. if(this.array.length == 0){
  170. this.$message.warning(this.$i18n.locale === 'zh' ?"请先选择要删除的记录":'Please select the record to delete first');
  171. return;
  172. }else{
  173. this.$confirm(this.$t('common.Thisoperationwillpermanently'), this.$t('common.Tips'), {
  174. confirmButtonText: this.$t('common.OK'),
  175. cancelButtonText: this.$t('common.cancel'),
  176. type: 'warning'
  177. }).then(() => {
  178. deleteNoticeItems(this.array).then(res=>{
  179. })
  180. this.$message({
  181. type: 'success',
  182. message: this.$i18n.locale === 'zh' ? '删除成功!' : 'Successfully deleted'
  183. });
  184. this.currentPage = 1;
  185. this.initTableData();
  186. }).catch(() => {
  187. this.$message({
  188. type: 'info',
  189. message: this.$i18n.locale === 'zh' ? '已取消删除' : 'Deletion canceled',
  190. });
  191. });
  192. }
  193. },
  194. changeReadStatus() {
  195. var status = this.array2;
  196. if (status.indexOf('read') >= 0 || status.length == 0) {
  197. this.$message.warning(this.$t('common.Pleaseselectallunreadrecords'));
  198. } else {
  199. this.$confirm(this.$t('common.Areyousureyouwanttomarkasread'), this.$t('common.Tips'), {
  200. confirmButtonText: this.$t('common.OK'),
  201. cancelButtonText: this.$t('common.cancel'),
  202. type: 'warning'
  203. }).then(() => {
  204. console.log(this.array);
  205. changeNoticeReadStatus(this.array).then(res => {
  206. this.$message({
  207. type: 'success',
  208. message: this.$i18n.locale === 'zh' ?'更新成功!':'Update succeeded'
  209. });
  210. this.currentPage = 1;
  211. this.initTableData();
  212. })
  213. }).catch(() => {
  214. this.$message({
  215. type: 'info',
  216. message: this.$i18n.locale === 'zh' ?'已取消更新':'Update canceled'
  217. });
  218. });
  219. }
  220. }
  221. }
  222. }
  223. </script>
  224. <style scoped>
  225. .el-input {
  226. width: 200px ;
  227. }
  228. .el-form-item__content,.el-select {
  229. width: 200px !important;
  230. }
  231. .el-table thead {
  232. background: #eee;
  233. }
  234. .userCenterMyProject >>> .el-pagination .el-pager li,
  235. .userCenterMyProject >>> .el-pagination .btn-next,
  236. .userCenterMyProject >>> .el-pagination .btn-prev{
  237. width: 35px;
  238. height: 35px;
  239. line-height: 35px;
  240. }
  241. .userCenterMyProject >>> .el-pagination.is-background .el-pager li:not(.disabled).active {
  242. background: #0050d8;
  243. }
  244. .userCenterMyProject >>> .not-finish td:nth-child(2) .cell{
  245. color:#FFFFFF;
  246. background: #909399;
  247. }
  248. </style>