|
@@ -38,7 +38,14 @@
|
|
<span :style="{ marginLeft: '4px' }">用户列表</span>
|
|
<span :style="{ marginLeft: '4px' }">用户列表</span>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="12" :style="{ textAlign: 'right' }">
|
|
<el-col :span="12" :style="{ textAlign: 'right' }">
|
|
- <el-button size="mini" plain icon="el-icon-plus"> 添加 </el-button>
|
|
|
|
|
|
+ <el-button
|
|
|
|
+ size="mini"
|
|
|
|
+ plain
|
|
|
|
+ icon="el-icon-plus"
|
|
|
|
+ @click="openDialog()"
|
|
|
|
+ >
|
|
|
|
+ 添加
|
|
|
|
+ </el-button>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
</div>
|
|
</div>
|
|
@@ -86,6 +93,7 @@
|
|
icon="el-icon-edit"
|
|
icon="el-icon-edit"
|
|
circle
|
|
circle
|
|
size="mini"
|
|
size="mini"
|
|
|
|
+ @click="openDialog(row.id)"
|
|
></el-button>
|
|
></el-button>
|
|
<el-popconfirm
|
|
<el-popconfirm
|
|
confirm-button-text="确认"
|
|
confirm-button-text="确认"
|
|
@@ -110,25 +118,41 @@
|
|
<el-row :style="{ marginTop: '16px' }">
|
|
<el-row :style="{ marginTop: '16px' }">
|
|
<el-col :span="24" :style="{ textAlign: 'right' }">
|
|
<el-col :span="24" :style="{ textAlign: 'right' }">
|
|
<el-pagination
|
|
<el-pagination
|
|
|
|
+ :current-page="page"
|
|
:page-size="10"
|
|
:page-size="10"
|
|
layout="total, prev, pager, next"
|
|
layout="total, prev, pager, next"
|
|
- :total="400"
|
|
|
|
|
|
+ :total="total"
|
|
|
|
+ small
|
|
|
|
+ @current-change="onCurrentChange"
|
|
>
|
|
>
|
|
</el-pagination>
|
|
</el-pagination>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
|
|
+ <el-dialog
|
|
|
|
+ :title="editUserID ? '修改用户' : '新增用户'"
|
|
|
|
+ :visible.sync="dialogVisible"
|
|
|
|
+ width="40%"
|
|
|
|
+ @close="resetDialog"
|
|
|
|
+ center
|
|
|
|
+ >
|
|
|
|
+ <UserEdit :id="editUserID" />
|
|
|
|
+ </el-dialog>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { mapActions, mapState } from 'vuex';
|
|
|
|
|
|
+import { mapActions, mapState, mapGetters } from 'vuex';
|
|
import { getAllRoles } from '@/api/roles';
|
|
import { getAllRoles } from '@/api/roles';
|
|
import { deleteUser } from '@/api/users';
|
|
import { deleteUser } from '@/api/users';
|
|
|
|
|
|
|
|
+import UserEdit from './components/UserEdit.vue';
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
name: 'Users',
|
|
name: 'Users',
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ dialogVisible: false,
|
|
|
|
+ editUserID: '',
|
|
filterName: '',
|
|
filterName: '',
|
|
roles: [],
|
|
roles: [],
|
|
};
|
|
};
|
|
@@ -141,8 +165,23 @@ export default {
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapState('users', ['users', 'pageInfo']),
|
|
...mapState('users', ['users', 'pageInfo']),
|
|
|
|
+ ...mapGetters('users', ['total', 'page']),
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ resetDialog() {
|
|
|
|
+ this.editUserID = '';
|
|
|
|
+ },
|
|
|
|
+ openDialog(id) {
|
|
|
|
+ // if (id) this.editUserID = id;
|
|
|
|
+ id && (this.editUserID = id);
|
|
|
|
+ this.dialogVisible = true;
|
|
|
|
+ },
|
|
|
|
+ // 页码变化时
|
|
|
|
+ onCurrentChange(pno) {
|
|
|
|
+ // console.log(`output->pno`, pno);
|
|
|
|
+ this.$store.commit('users/setPage', { pno });
|
|
|
|
+ this.loadData();
|
|
|
|
+ },
|
|
// 删除用户
|
|
// 删除用户
|
|
async onDeleteUser(id) {
|
|
async onDeleteUser(id) {
|
|
// console.log(`output->id`, id);
|
|
// console.log(`output->id`, id);
|
|
@@ -180,6 +219,9 @@ export default {
|
|
this.roles = data.list;
|
|
this.roles = data.list;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ components: {
|
|
|
|
+ UserEdit,
|
|
|
|
+ },
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
|
|
|