paper-work-history.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <el-card>
  3. <div class="fx-row fx-end-cen mb10">
  4. <el-button icon="el-icon-refresh" circle @click="handleQuery"></el-button>
  5. </div>
  6. <dynamic-table :rows="rows" :columns="columns">
  7. <template #type="{display}">
  8. {{ translateType(display) }}
  9. </template>
  10. <template #status="{row}">
  11. <div class="homework-status">
  12. <el-badge :value="row.doneCount" type="primary">
  13. <el-tag type="primary">已完成</el-tag>
  14. </el-badge>
  15. <el-badge :value="row.totalCount - row.doneCount" type="danger">
  16. <el-tag type="danger">未完成</el-tag>
  17. </el-badge>
  18. </div>
  19. </template>
  20. <template #action="{row}">
  21. <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)">查看</el-button>
  22. </template>
  23. </dynamic-table>
  24. <pagination v-if="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  25. @pagination="getList"></pagination>
  26. </el-card>
  27. </template>
  28. <script>
  29. import { getTeacherHomeworks } from '@/api/webApi/homework'
  30. import consts from '@/common/mx-const'
  31. import DynamicTable from '@/components/dynamic-table/index'
  32. export default {
  33. name: 'paper-work-history',
  34. components: { DynamicTable },
  35. data() {
  36. return {
  37. extraData: { type: consts.enum.generateScene.paperWork.value },
  38. paperWorkType: Object.freeze(consts.enum.homeworkTypes.find(t => t.value == 1)),
  39. queryParams: {
  40. pageNum: 1,
  41. pageSize: 20
  42. },
  43. columns: [
  44. { prop: 'id', label: 'ID', width: '80px' },
  45. { prop: 'type', label: '类型', width: '120px', slotBody: 'type' },
  46. { prop: 'title', label: '标题' },
  47. { prop: 'createTime', label: '创建时间', width: '180px' },
  48. { prop: 'status', label: '状态', width: '160px', slotBody: 'status' },
  49. { prop: 'action', label: '操作', width: '120px', slotBody: 'action' }],
  50. rows: [],
  51. total: 0
  52. }
  53. },
  54. mounted() {
  55. this.getList()
  56. },
  57. methods: {
  58. handleQuery() {
  59. this.queryParams.pageNum = 1
  60. this.getList()
  61. },
  62. async getList() {
  63. const res = await getTeacherHomeworks(this.queryParams)
  64. this.rows = res.rows || res.data
  65. this.total = res.total || this.rows.length
  66. },
  67. translateType(type) {
  68. const enumType = consts.enum.homeworkTypes.find(t => t.value == type)
  69. return enumType?.label || type
  70. },
  71. handleViewDetail(row) {
  72. this.msgInfo('Not implement')
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss">
  78. .homework-status {
  79. .el-badge + .el-badge {
  80. margin-left: 15px;
  81. }
  82. .el-badge__content.is-fixed {
  83. top: 8px;
  84. }
  85. }
  86. </style>