menu弹窗美化
This commit is contained in:
@@ -18,27 +18,24 @@
|
||||
<template slot-scope="scope">
|
||||
<el-cascader
|
||||
@change="changeAuthority(scope.row)"
|
||||
v-model="scope.row.authority.authorityId"
|
||||
:options="authOptions"
|
||||
:show-all-levels="false"
|
||||
:props="{ checkStrictly: true,label:'authorityName',value:'authorityId',disabled:'disabled',emitPath:false}"
|
||||
filterable>
|
||||
</el-cascader>
|
||||
v-model="scope.row.authority.authorityId"
|
||||
:options="authOptions"
|
||||
:show-all-levels="false"
|
||||
:props="{ checkStrictly: true,label:'authorityName',value:'authorityId',disabled:'disabled',emitPath:false}"
|
||||
filterable
|
||||
></el-cascader>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="150">
|
||||
<template slot-scope="scope">
|
||||
<el-popover
|
||||
placement="top"
|
||||
width="160"
|
||||
v-model="scope.row.visible">
|
||||
<p>确定要删除此用户吗</p>
|
||||
<div style="text-align: right; margin: 0">
|
||||
<el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button>
|
||||
<el-button type="primary" size="mini" @click="deleteUser(scope.row)">确定</el-button>
|
||||
</div>
|
||||
<el-button type="text" size="small" slot="reference">删除</el-button>
|
||||
</el-popover>
|
||||
<el-popover placement="top" width="160" v-model="scope.row.visible">
|
||||
<p>确定要删除此用户吗</p>
|
||||
<div style="text-align: right; margin: 0">
|
||||
<el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button>
|
||||
<el-button type="primary" size="mini" @click="deleteUser(scope.row)">确定</el-button>
|
||||
</div>
|
||||
<el-button type="text" size="small" slot="reference">删除</el-button>
|
||||
</el-popover>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -54,7 +51,7 @@
|
||||
></el-pagination>
|
||||
|
||||
<el-dialog :visible.sync="addUserDialog" custom-class="user-dialog" title="新增用户">
|
||||
<el-form :rules="rules" ref="userForm" :model="userInfo" >
|
||||
<el-form :rules="rules" ref="userForm" :model="userInfo">
|
||||
<el-form-item label="用户名" label-width="80px" prop="username">
|
||||
<el-input v-model="userInfo.username"></el-input>
|
||||
</el-form-item>
|
||||
@@ -80,12 +77,12 @@
|
||||
<el-form-item label="用户角色" label-width="80px" prop="authorityId">
|
||||
<el-cascader
|
||||
@change="changeAuthority(scope.row)"
|
||||
v-model="userInfo.authorityId"
|
||||
:options="authOptions"
|
||||
:show-all-levels="false"
|
||||
:props="{ checkStrictly: true,label:'authorityName',value:'authorityId',disabled:'disabled',emitPath:false}"
|
||||
filterable>
|
||||
</el-cascader>
|
||||
v-model="userInfo.authorityId"
|
||||
:options="authOptions"
|
||||
:show-all-levels="false"
|
||||
:props="{ checkStrictly: true,label:'authorityName',value:'authorityId',disabled:'disabled',emitPath:false}"
|
||||
filterable
|
||||
></el-cascader>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer" slot="footer">
|
||||
@@ -99,115 +96,121 @@
|
||||
|
||||
<script>
|
||||
// 获取列表内容封装在mixins内部 getTableData方法 初始化已封装完成
|
||||
const path = process.env.VUE_APP_BASE_API
|
||||
import { getUserList, setUserAuthority, register, deleteUser } from '@/api/user'
|
||||
import { getAuthorityList } from '@/api/authority'
|
||||
import infoList from '@/components/mixins/infoList'
|
||||
import { mapGetters } from 'vuex'
|
||||
const path = process.env.VUE_APP_BASE_API;
|
||||
import {
|
||||
getUserList,
|
||||
setUserAuthority,
|
||||
register,
|
||||
deleteUser
|
||||
} from "@/api/user";
|
||||
import { getAuthorityList } from "@/api/authority";
|
||||
import infoList from "@/components/mixins/infoList";
|
||||
import { mapGetters } from "vuex";
|
||||
export default {
|
||||
name: 'Api',
|
||||
name: "Api",
|
||||
mixins: [infoList],
|
||||
data() {
|
||||
return {
|
||||
listApi: getUserList,
|
||||
path:path,
|
||||
path: path,
|
||||
authOptions: [],
|
||||
addUserDialog: false,
|
||||
userInfo: {
|
||||
username: '',
|
||||
password: '',
|
||||
nickName: '',
|
||||
headerImg: '',
|
||||
authorityId: ''
|
||||
username: "",
|
||||
password: "",
|
||||
nickName: "",
|
||||
headerImg: "",
|
||||
authorityId: ""
|
||||
},
|
||||
rules: {
|
||||
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
|
||||
username: [
|
||||
{ required: true, message: "请输入用户名", trigger: "blur" }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '请输入用户密码', trigger: 'blur' }
|
||||
{ required: true, message: "请输入用户密码", trigger: "blur" }
|
||||
],
|
||||
nickName: [
|
||||
{ required: true, message: '请输入用户昵称', trigger: 'blur' }
|
||||
{ required: true, message: "请输入用户昵称", trigger: "blur" }
|
||||
],
|
||||
authorityId: [
|
||||
{ required: true, message: '请选择用户角色', trigger: 'blur' }
|
||||
{ required: true, message: "请选择用户角色", trigger: "blur" }
|
||||
]
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('user', ['token'])
|
||||
...mapGetters("user", ["token"])
|
||||
},
|
||||
methods: {
|
||||
setOptions(authData){
|
||||
this.authOptions = []
|
||||
this.setAuthorityOptions(authData,this.authOptions)
|
||||
setOptions(authData) {
|
||||
this.authOptions = [];
|
||||
this.setAuthorityOptions(authData, this.authOptions);
|
||||
},
|
||||
setAuthorityOptions(AuthorityData,optionsData){
|
||||
AuthorityData&&AuthorityData.map(item=>{
|
||||
if(item.children.length){
|
||||
const option = {
|
||||
authorityId:item.authorityId,
|
||||
authorityName:item.authorityName,
|
||||
children:[]
|
||||
}
|
||||
this.setAuthorityOptions(item.children,option.children)
|
||||
optionsData.push(option)
|
||||
}else{
|
||||
const option = {
|
||||
authorityId:item.authorityId,
|
||||
authorityName:item.authorityName,
|
||||
setAuthorityOptions(AuthorityData, optionsData) {
|
||||
AuthorityData &&
|
||||
AuthorityData.map(item => {
|
||||
if (item.children.length) {
|
||||
const option = {
|
||||
authorityId: item.authorityId,
|
||||
authorityName: item.authorityName,
|
||||
children: []
|
||||
};
|
||||
this.setAuthorityOptions(item.children, option.children);
|
||||
optionsData.push(option);
|
||||
} else {
|
||||
const option = {
|
||||
authorityId: item.authorityId,
|
||||
authorityName: item.authorityName
|
||||
};
|
||||
optionsData.push(option);
|
||||
}
|
||||
optionsData.push(option)
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
async deleteUser(row){
|
||||
const res = await deleteUser({id:row.ID})
|
||||
if(res.code == 0){
|
||||
this.getTableData()
|
||||
row.visible = false
|
||||
async deleteUser(row) {
|
||||
const res = await deleteUser({ id: row.ID });
|
||||
if (res.code == 0) {
|
||||
this.getTableData();
|
||||
row.visible = false;
|
||||
}
|
||||
},
|
||||
async enterAddUserDialog() {
|
||||
this.$refs.userForm.validate(async valid => {
|
||||
if (valid) {
|
||||
const res = await register(this.userInfo)
|
||||
const res = await register(this.userInfo);
|
||||
if (res.code == 0) {
|
||||
this.$message({ type: 'success', message: '创建成功' })
|
||||
this.$message({ type: "success", message: "创建成功" });
|
||||
}
|
||||
await this.getTableData()
|
||||
this.closeAddUserDialog()
|
||||
await this.getTableData();
|
||||
this.closeAddUserDialog();
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
closeAddUserDialog() {
|
||||
this.$refs.userForm.resetFields()
|
||||
this.addUserDialog = false
|
||||
this.$refs.userForm.resetFields();
|
||||
this.addUserDialog = false;
|
||||
},
|
||||
handleAvatarSuccess(res) {
|
||||
this.userInfo.headerImg = res.data.file.url
|
||||
this.userInfo.headerImg = res.data.file.url;
|
||||
},
|
||||
addUser() {
|
||||
this.addUserDialog = true
|
||||
this.addUserDialog = true;
|
||||
},
|
||||
async changeAuthority(row) {
|
||||
const res = await setUserAuthority({
|
||||
uuid: row.uuid,
|
||||
authorityId: row.authority.authorityId
|
||||
})
|
||||
});
|
||||
if (res.code == 0) {
|
||||
this.$message({ type: 'success', message: '角色设置成功' })
|
||||
this.$message({ type: "success", message: "角色设置成功" });
|
||||
}
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
this.getTableData()
|
||||
const res = await getAuthorityList({ page: 1, pageSize: 999 })
|
||||
this.setOptions(res.data.list)
|
||||
this.getTableData();
|
||||
const res = await getAuthorityList({ page: 1, pageSize: 999 });
|
||||
this.setOptions(res.data.list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.button-box {
|
||||
|
||||
Reference in New Issue
Block a user