角色增删改查
parent
dc83c28dc5
commit
c71cfda1d8
@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
class="addUserDialog"
|
||||
title="权限绑定"
|
||||
:visible.sync="isShow"
|
||||
:close-on-click-modal="false"
|
||||
width="470px"
|
||||
@close="handleclose"
|
||||
>
|
||||
绑定权限
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="isShow = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submitForm()">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
import { addRole, updateRole } from "@/utils/api/index";
|
||||
export default {
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
roleUser: "",
|
||||
isShow: false,
|
||||
|
||||
formdata: {},
|
||||
rules: {
|
||||
name: [{ required: true, message: "请输入用户名", trigger: "blur" }],
|
||||
},
|
||||
xgrules: {
|
||||
name: [{ required: true, message: "请输入用户名", trigger: "blur" }],
|
||||
},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
//判断
|
||||
getdataform(val) {
|
||||
this.formdata = JSON.parse(JSON.stringify(val));
|
||||
},
|
||||
// 保存确定操作
|
||||
submitForm() {
|
||||
this.$refs.formInfo.validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.title == "新增") {
|
||||
addRole(this.formdata)
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.$message({
|
||||
duration: 1500,
|
||||
showClose: true,
|
||||
message: "添加成功",
|
||||
type: "success",
|
||||
});
|
||||
this.isShow = false;
|
||||
} else {
|
||||
this.$message.error(res.msg);
|
||||
}
|
||||
})
|
||||
.catch((err) => {});
|
||||
} else {
|
||||
updateRole(this.formdata)
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.$message.success("修改成功");
|
||||
this.isShow = false;
|
||||
} else {
|
||||
this.$message.error(res.msg);
|
||||
}
|
||||
})
|
||||
.catch((err) => {});
|
||||
}
|
||||
} else {
|
||||
console.log("error submit!!");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
display() {
|
||||
this.isShow = true;
|
||||
this.roleUser = localStorage.getItem("role");
|
||||
},
|
||||
hide() {
|
||||
this.isShow = false;
|
||||
},
|
||||
handleclose() {
|
||||
this.$parent.roleListAll();
|
||||
},
|
||||
},
|
||||
mounted() {},
|
||||
};
|
||||
</script>
|
||||
<style lang="less">
|
||||
.addUserDialog {
|
||||
.el-form-item {
|
||||
.el-input,
|
||||
.el-select,
|
||||
.el-input-number {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue