FAQManage.vue 2.8 KB

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