FAQManage.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div>
  3. <el-select v-model="status">
  4. <el-option value="-1" label="全部"></el-option>
  5. <el-option value="1" label="在线"></el-option>
  6. <el-option value="0" label="离线"></el-option>
  7. </el-select>
  8. <el-button type="primary" @click="getItems">查询</el-button>
  9. <el-button type="primary" @click="goAdd">添加</el-button>
  10. <el-table :data="items">
  11. <el-table-column label="问题" prop="question"></el-table-column>
  12. <el-table-column label="答案" prop="answer"></el-table-column>
  13. <el-table-column label="状态">
  14. <template slot-scope="scope">
  15. <template v-if="scope.row.status === 1">
  16. <p class="online">启用</p>
  17. </template>
  18. <template v-else>
  19. <p class="offline">禁用</p>
  20. </template>
  21. </template>
  22. </el-table-column>
  23. <el-table-column label="操作">
  24. <template slot-scope="scope">
  25. <el-button type="text" size="small" @click="goEdit(scope.row)">编辑</el-button>
  26. </template>
  27. </el-table-column>
  28. </el-table>
  29. <div class="page">
  30. <el-pagination background layout="total, prev, pager, next,jumper" @current-change="nextPage" :total="totalCount">
  31. </el-pagination>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. items: [],
  40. status: '-1',
  41. page: 1,
  42. pageSize: 20,
  43. totalCount: 0
  44. }
  45. },
  46. methods: {
  47. goAdd: function() {
  48. var row = {id:0}
  49. this.goEdit(row)
  50. },
  51. getItems: function() {
  52. this.$http
  53. .getAllFaq(
  54. { status: this.status, page: this.page, pageSize: this.pageSize },
  55. this
  56. )
  57. .then(res => {
  58. if (res.code === 0) {
  59. this.items = res.obj.list
  60. this.totalCount = res.obj.totalCount
  61. }
  62. })
  63. },
  64. nextPage: function(currentPage) {
  65. this.page = currentPage
  66. this.getItems()
  67. },
  68. goEdit: function(row) {
  69. this.$router.push({ path: '/editFAQ', query: { id: row.id } })
  70. }
  71. },
  72. mounted: function() {
  73. this.getItems()
  74. }
  75. }
  76. </script>
  77. <style>
  78. .page {
  79. margin-top: 10px;
  80. text-align: center;
  81. }
  82. .online {
  83. color: #67c23a;
  84. }
  85. .offline {
  86. color: #f56c6c;
  87. }
  88. </style>