|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div id="index">
|
|
|
- <list-frame title="寝室管理" @query="search" :needFilter="false" @add="$router.push({ path: '/bedroom/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: '/bedroom/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/components/data-table';
|
|
|
+import { createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions } = createNamespacedHelpers('bedroom');
|
|
|
export default {
|
|
|
metaInfo: { title: '寝室管理' },
|
|
|
name: 'index',
|
|
@@ -31,8 +33,8 @@ export default {
|
|
|
},
|
|
|
],
|
|
|
fields: [
|
|
|
- { label: '寝室号', prop: 'no' },
|
|
|
- { label: '人数', prop: 'num' },
|
|
|
+ { label: '寝室号', prop: 'code' },
|
|
|
+ { label: '人数', prop: 'number' },
|
|
|
{ label: '批次', prop: 'batch' },
|
|
|
{
|
|
|
label: '男女限制',
|
|
@@ -43,25 +45,29 @@ export default {
|
|
|
},
|
|
|
{ label: '楼层', prop: 'floor' },
|
|
|
],
|
|
|
- list: [
|
|
|
- { id: 1, no: '501', batch: '1', num: 6, gender: '1', floor: '5楼' },
|
|
|
- { id: 2, no: '502', batch: '2', num: 4, gender: '0', floor: '1楼' },
|
|
|
- ],
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
}),
|
|
|
- created() {},
|
|
|
+ created() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
computed: {},
|
|
|
methods: {
|
|
|
- search({ skip = 0, limit = 15, ...info } = {}) {
|
|
|
- console.log(`in search`);
|
|
|
+ ...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) {
|
|
|
- console.log(`in toEdit`);
|
|
|
- console.log(data);
|
|
|
- this.$router.push({ path: '/place/detail', query: { id: data.id } });
|
|
|
+ this.$router.push({ path: '/bedroom/detail', query: { id: data.id } });
|
|
|
},
|
|
|
- toDelete(data) {
|
|
|
- console.log(`in toDelete`);
|
|
|
- console.log(data);
|
|
|
+ async toDelete(data) {
|
|
|
+ const res = await this.delete(data.id);
|
|
|
+ this.$checkRes(res, '删除成功', '删除失败');
|
|
|
+ this.search();
|
|
|
},
|
|
|
},
|
|
|
};
|