ProblemList.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div>
  3. <div class="fill-card">
  4. <el-table :data="problemList">
  5. <el-table-column type="expand">
  6. <template v-slot="props">
  7. <div>{{ props.row.description }}</div>
  8. </template>
  9. </el-table-column>
  10. <el-table-column prop="name" label="名称"></el-table-column>
  11. <el-table-column label="类型">
  12. <template v-slot="scope">
  13. <span>{{typeTagContent(scope.row.type) }}</span>
  14. </template>
  15. </el-table-column>
  16. <el-table-column label="上传时间">
  17. <template v-slot="scope">
  18. <span>{{format(scope.row.createdAt) }}</span>
  19. </template>
  20. </el-table-column>
  21. <el-table-column label="操作" width="200">
  22. <template v-slot="scope">
  23. <el-button
  24. type="primary"
  25. size="mini"
  26. @click="
  27. $router.push({ path: '/problem/' + scope.row.id })
  28. "
  29. >详情</el-button
  30. >
  31. <el-button
  32. type="danger"
  33. size="mini"
  34. @click="this.$store.commit('removeProblem', scope.row)"
  35. >移出试题清单</el-button
  36. >
  37. <el-button
  38. type="success"
  39. size="mini"
  40. @click="this.$store.commit('addProblem', scope.row)"
  41. >加入试题清单</el-button
  42. >
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. </div>
  47. <el-pagination
  48. background
  49. layout="prev, pager, next"
  50. :page-size="30"
  51. :total="pageInfo.total"
  52. @current-change="$emit('current-change', $event)"
  53. />
  54. </div>
  55. </template>
  56. <script>
  57. import { formatTimestamp, problemTypeToTagContent } from "@/utils/coder-utils";
  58. export default {
  59. name: "ProblemList",
  60. methods: {
  61. format(timestamp) {
  62. return formatTimestamp(timestamp);
  63. },
  64. typeTagContent(type) {
  65. return problemTypeToTagContent(type);
  66. }
  67. },
  68. props: {
  69. problemList: {
  70. type: Array,
  71. default: () => []
  72. },
  73. pageInfo: {
  74. type: Object,
  75. default: () => ({})
  76. }
  77. }
  78. };
  79. </script>