userCenterNotificationNews.vue 12 KB

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