index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <div id="index">
  3. <list-frame title="班级管理" @query="search" :total="total" :needFilter="false" @add="$router.push({ path: '/classes/detail' })">
  4. <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" @delete="toDelete"></data-table>
  5. </list-frame>
  6. </div>
  7. </template>
  8. <script>
  9. import listFrame from '@frame/layout/admin/list-frame';
  10. import dataTable from '@frame/components/data-table';
  11. import { createNamespacedHelpers } from 'vuex';
  12. const { mapActions } = createNamespacedHelpers('classes');
  13. export default {
  14. metaInfo: { title: '班级管理' },
  15. name: 'index',
  16. props: {},
  17. components: {
  18. listFrame,
  19. dataTable,
  20. },
  21. data: () => ({
  22. opera: [
  23. {
  24. label: '编辑',
  25. icon: 'el-icon-edit',
  26. method: 'edit',
  27. },
  28. {
  29. label: '删除',
  30. icon: 'el-icon-delete',
  31. method: 'delete',
  32. confirm: true,
  33. methodZh: '删除',
  34. },
  35. ],
  36. fields: [
  37. { label: '班级名称', prop: 'name' },
  38. { label: '人数', prop: 'number' },
  39. { label: '批次', prop: 'batch' },
  40. ],
  41. list: [],
  42. total: 0,
  43. }),
  44. created() {
  45. this.search();
  46. },
  47. computed: {},
  48. methods: {
  49. ...mapActions(['query', 'delete']),
  50. async search({ skip = 0, limit = 15, ...info } = {}) {
  51. const res = await this.query({ skip, limit, ...info });
  52. if (this.$checkRes(res)) {
  53. this.$set(this, `list`, res.data);
  54. this.$set(this, `total`, res.total);
  55. }
  56. },
  57. toEdit(data) {
  58. this.$router.push({ path: '/classes/detail', query: { id: data.id } });
  59. },
  60. async toDelete(data) {
  61. const res = await this.delete(data.id);
  62. this.$checkRes(res, '删除成功', '删除失败');
  63. this.search();
  64. },
  65. },
  66. };
  67. </script>
  68. <style lang="less" scoped></style>