|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div id="index">
|
|
|
- <list-frame title="班级管理" @query="search" :needFilter="false" @add="$router.push({ path: '/classes/detail' })">
|
|
|
- <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" @deltet="toDelete"></data-table>
|
|
|
+ <list-frame title="班级管理" @query="search" :total="total" :needFilter="false" @add="$router.push({ path: '/classes/detail' })">
|
|
|
+ <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" @delete="toDelete"></data-table>
|
|
|
</list-frame>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -9,6 +9,8 @@
|
|
|
<script>
|
|
|
import listFrame from '@frame/layout/admin/list-frame';
|
|
|
import dataTable from '@frame/layout/admin/data-table';
|
|
|
+import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: mapClass } = createNamespacedHelpers('classes');
|
|
|
export default {
|
|
|
metaInfo: { title: '班级管理' },
|
|
|
name: 'index',
|
|
@@ -28,32 +30,41 @@ export default {
|
|
|
label: '删除',
|
|
|
icon: 'el-icon-delete',
|
|
|
method: 'delete',
|
|
|
+ confirm: true,
|
|
|
+ methodZh: '删除',
|
|
|
},
|
|
|
],
|
|
|
fields: [
|
|
|
{ label: '班级名称', prop: 'name' },
|
|
|
- { label: '人数', prop: 'num' },
|
|
|
+ { label: '人数', prop: 'number' },
|
|
|
{ label: '批次', prop: 'batch' },
|
|
|
],
|
|
|
- list: [
|
|
|
- { id: 1, name: '501', batch: '1', num: 6 },
|
|
|
- { id: 2, name: '502', batch: '2', num: 4 },
|
|
|
- ],
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
}),
|
|
|
- created() {},
|
|
|
+ created() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
computed: {},
|
|
|
methods: {
|
|
|
- search({ skip = 0, limit = 15, ...info } = {}) {
|
|
|
- console.log(`in search`);
|
|
|
+ ...mapClass(['query', 'delete']),
|
|
|
+ async search({ skip = 0, limit = 15, ...info } = {}) {
|
|
|
+ const res = await this.query({ skip, limit, ...info });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ console.log(res);
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
+ this.$set(this, `total`, res.total);
|
|
|
+ }
|
|
|
},
|
|
|
toEdit(data) {
|
|
|
- console.log(`in toEdit`);
|
|
|
- console.log(data);
|
|
|
- this.$router.push({ path: '/place/detail', query: { id: data.id } });
|
|
|
+ this.$router.push({ path: '/classes/detail', query: { id: data.id } });
|
|
|
},
|
|
|
- toDelete(data) {
|
|
|
+ async toDelete(data) {
|
|
|
console.log(`in toDelete`);
|
|
|
console.log(data);
|
|
|
+ const res = await this.delete(data.id);
|
|
|
+ this.$checkRes(res, '删除成功', '删除失败');
|
|
|
+ this.search();
|
|
|
},
|
|
|
},
|
|
|
};
|