Tabs.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <div class="">
  3. <div class="crumbs">
  4. <el-breadcrumb separator="/">
  5. <el-breadcrumb-item><i class="el-icon-message"></i> tab选项卡</el-breadcrumb-item>
  6. </el-breadcrumb>
  7. </div>
  8. <div class="container">
  9. <el-tabs v-model="message">
  10. <el-tab-pane :label="`未读消息(${unread.length})`" name="first">
  11. <el-table :data="unread" :show-header="false" style="width: 100%">
  12. <el-table-column>
  13. <template slot-scope="scope">
  14. <span class="message-title">{{scope.row.title}}</span>
  15. </template>
  16. </el-table-column>
  17. <el-table-column prop="date" width="180"></el-table-column>
  18. <el-table-column width="120">
  19. <template slot-scope="scope">
  20. <el-button size="small" @click="handleRead(scope.$index)">标为已读</el-button>
  21. </template>
  22. </el-table-column>
  23. </el-table>
  24. <div class="handle-row">
  25. <el-button type="primary">全部标为已读</el-button>
  26. </div>
  27. </el-tab-pane>
  28. <el-tab-pane :label="`已读消息(${read.length})`" name="second">
  29. <template v-if="message === 'second'">
  30. <el-table :data="read" :show-header="false" style="width: 100%">
  31. <el-table-column>
  32. <template slot-scope="scope">
  33. <span class="message-title">{{scope.row.title}}</span>
  34. </template>
  35. </el-table-column>
  36. <el-table-column prop="date" width="150"></el-table-column>
  37. <el-table-column width="120">
  38. <template slot-scope="scope">
  39. <el-button type="danger" @click="handleDel(scope.$index)">删除</el-button>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. <div class="handle-row">
  44. <el-button type="danger">删除全部</el-button>
  45. </div>
  46. </template>
  47. </el-tab-pane>
  48. <el-tab-pane :label="`回收站(${recycle.length})`" name="third">
  49. <template v-if="message === 'third'">
  50. <el-table :data="recycle" :show-header="false" style="width: 100%">
  51. <el-table-column>
  52. <template slot-scope="scope">
  53. <span class="message-title">{{scope.row.title}}</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column prop="date" width="150"></el-table-column>
  57. <el-table-column width="120">
  58. <template slot-scope="scope">
  59. <el-button @click="handleRestore(scope.$index)">还原</el-button>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <div class="handle-row">
  64. <el-button type="danger">清空回收站</el-button>
  65. </div>
  66. </template>
  67. </el-tab-pane>
  68. </el-tabs>
  69. </div>
  70. </div>
  71. </template>
  72. <script>
  73. export default {
  74. data() {
  75. return {
  76. message: 'first',
  77. showHeader: false,
  78. unread: [{
  79. date: '2018-04-19 20:00:00',
  80. title: '【系统通知】该系统将于今晚凌晨2点到5点进行升级维护',
  81. },{
  82. date: '2018-04-19 21:00:00',
  83. title: '今晚12点整发大红包,先到先得',
  84. }],
  85. read: [{
  86. date: '2018-04-19 20:00:00',
  87. title: '【系统通知】该系统将于今晚凌晨2点到5点进行升级维护'
  88. }],
  89. recycle: [{
  90. date: '2018-04-19 20:00:00',
  91. title: '【系统通知】该系统将于今晚凌晨2点到5点进行升级维护'
  92. }]
  93. }
  94. },
  95. methods: {
  96. handleRead(index) {
  97. const item = this.unread.splice(index, 1);
  98. console.log(item);
  99. this.read = item.concat(this.read);
  100. },
  101. handleDel(index) {
  102. const item = this.read.splice(index, 1);
  103. this.recycle = item.concat(this.recycle);
  104. },
  105. handleRestore(index) {
  106. const item = this.recycle.splice(index, 1);
  107. this.read = item.concat(this.read);
  108. }
  109. },
  110. computed: {
  111. unreadNum(){
  112. return this.unread.length;
  113. }
  114. }
  115. }
  116. </script>
  117. <style>
  118. .message-title{
  119. cursor: pointer;
  120. }
  121. .handle-row{
  122. margin-top: 30px;
  123. }
  124. </style>