12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <template>
- <div id="index">
- <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>
- <script>
- import listFrame from '@frame/layout/admin/list-frame';
- import dataTable from '@frame/components/data-table';
- import { createNamespacedHelpers } from 'vuex';
- const { mapActions } = createNamespacedHelpers('classes');
- export default {
- metaInfo: { title: '班级管理' },
- name: 'index',
- props: {},
- components: {
- listFrame,
- dataTable,
- },
- data: () => ({
- opera: [
- {
- label: '编辑',
- icon: 'el-icon-edit',
- method: 'edit',
- },
- {
- label: '删除',
- icon: 'el-icon-delete',
- method: 'delete',
- confirm: true,
- methodZh: '删除',
- },
- ],
- fields: [
- { label: '班级名称', prop: 'name' },
- { label: '人数', prop: 'number' },
- { label: '批次', prop: 'batch' },
- ],
- list: [],
- total: 0,
- }),
- created() {
- this.search();
- },
- computed: {},
- methods: {
- ...mapActions(['query', 'delete']),
- async search({ skip = 0, limit = 15, ...info } = {}) {
- const res = await this.query({ skip, limit, ...info });
- if (this.$checkRes(res)) {
- this.$set(this, `list`, res.data);
- this.$set(this, `total`, res.total);
- }
- },
- toEdit(data) {
- this.$router.push({ path: '/classes/detail', query: { id: data.id } });
- },
- async toDelete(data) {
- const res = await this.delete(data.id);
- this.$checkRes(res, '删除成功', '删除失败');
- this.search();
- },
- },
- };
- </script>
- <style lang="less" scoped></style>
|