role1.0
fanluyan 1 year ago
parent 2c2d771878
commit b6d67b038e

@ -25,9 +25,9 @@
<el-select v-model="formdata.role" placeholder="请选择">
<el-option
v-for="item in roleoptions"
:key="item.value"
:label="item.label"
:value="item.value"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
@ -47,7 +47,7 @@
</el-dialog>
</template>
<script>
import { addUserApi, updateUserApi } from "@/utils/api/index";
import { addUserApi, updateUserApi, getRoleList } from "@/utils/api/index";
export default {
props: {
title: String,
@ -98,6 +98,13 @@ export default {
//this.formdata = val;
this.formdata = JSON.parse(JSON.stringify(val));
},
getRoleListAll() {
getRoleList()
.then((res) => {
this.roleoptions = res.data;
})
.catch((err) => {});
},
//
submitForm() {
this.$refs.formInfo.validate((valid) => {
@ -139,12 +146,13 @@ export default {
display() {
this.isShow = true;
this.roleUser = localStorage.getItem("role");
this.getRoleListAll();
},
hide() {
this.isShow = false;
},
handleclose() {
this.$parent.deviceList();
this.$parent.userList();
},
},
mounted() {},

@ -14,6 +14,7 @@
node-key="id"
ref="tree"
highlight-current
:default-expanded-keys="defaultExpandedArr"
:props="defaultProps"
>
</el-tree>
@ -46,6 +47,7 @@ export default {
rowData: "",
premissData: [],
selectTreeNode: [],
defaultExpandedArr: [],
rules: {
name: [{ required: true, message: "请输入用户名", trigger: "blur" }],
},
@ -69,6 +71,9 @@ export default {
console.log(res);
this.treeLoading = false;
this.treeData = res.data.list;
this.treeData.forEach((item) => {
this.defaultExpandedArr.push(item.id);
});
} else {
this.$message.error(res.msg);
}
@ -83,6 +88,12 @@ export default {
if (res.code == 200) {
console.log(res);
this.premissData = res.data;
let setCheckedKeysList = this.premissData.map(function (item) {
return item.resourceId;
});
console.log(setCheckedKeysList);
this.$refs.tree.setCheckedKeys(setCheckedKeysList);
} else {
this.$message.error(res.msg);
}
@ -92,18 +103,56 @@ export default {
//
submitForm() {
console.log(this.$refs.tree.getCheckedNodes());
this.selectTreeNode = this.$refs.tree.getCheckedNodes();
console.log(this.selectTreeNode);
// changePermission()
// .then((res) => {
// if (res.code == 200) {
// console.log(res);
// } else {
// this.$message.error(res.msg);
// }
// })
// .catch((err) => {});
//
let originData = this.$refs.tree.store;
//
const checkedNodeIds = [];
//
const isAllChecked = function (node) {
const childNodes = node.root ? node.root.childNodes : node.childNodes;
childNodes.forEach((child) => {
if (child.checked) {
checkedNodeIds.push(child.data);
}
if (child.indeterminate) {
isAllChecked(child);
}
});
};
isAllChecked(originData);
console.log(checkedNodeIds);
//
let paramsList = [];
checkedNodeIds.forEach((node) => {
if ("dyValue" in node) {
console.log(node);
paramsList.push({ resourceType: 1, resourceId: node.id });
} else if ("bsManufacturer" in node) {
paramsList.push({ resourceType: 2, resourceId: node.id });
} else if ("towerid" in node) {
paramsList.push({ resourceType: 3, resourceId: node.towerid });
}
});
console.log(paramsList);
changePermission({
list: paramsList,
roleId: this.rowData.id,
})
.then((res) => {
if (res.code == 200) {
console.log(res);
this.isShow = false;
this.$message({
duration: 1500,
showClose: true,
message: "权限绑定成功",
type: "success",
});
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {});
},
display() {
this.isShow = true;

@ -36,12 +36,12 @@
show-overflow-tooltip
prop="createTime"
>
<template slot-scope="scope">{{
<template slot-scope="scope" v-if="scope.row.createTime !== null">{{
$moment(scope.row.createTime).format("yy-MM-DD HH:mm:ss")
}}</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="200">
<template slot-scope="scope">
<template slot-scope="scope" v-if="scope.row.id !== 0">
<el-button
@click.native.stop="handleResive(scope.row)"
type="text"
@ -59,7 +59,7 @@
</template>
</el-table-column>
</el-table>
<div class="pageNation">
<!-- <div class="pageNation">
<el-pagination
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
@ -70,7 +70,7 @@
background
>
</el-pagination>
</div>
</div> -->
</div>
</div>
<!-- 新增 -->

@ -29,9 +29,7 @@
prop="userName"
></el-table-column>
<el-table-column label="角色" show-overflow-tooltip prop="role">
<template slot-scope="scope">{{
scope.row.role == 1 ? "管理员" : "用户"
}}</template>
<template slot-scope="scope">{{ scope.row.role }}</template>
</el-table-column>
<el-table-column
label="创建时间"
@ -97,11 +95,11 @@ export default {
};
},
created() {
this.deviceList();
this.userList();
},
methods: {
//线
deviceList() {
userList() {
getUserList({
pageindex: this.page,
pagesize: this.pageSize,
@ -146,7 +144,7 @@ export default {
delUserApi({ uid: data.userId }).then((res) => {
if (res.code == 200) {
this.$message.success("删除成功");
this.deviceList(); //
this.userList(); //
} else {
this.$message.error(res.msg);
}
@ -164,12 +162,12 @@ export default {
//
handleCurrentChange(val) {
this.page = val;
this.deviceList();
this.userList();
},
//
handleSizeChange(val) {
this.pageSize = val;
this.deviceList();
this.userList();
},
},
};

Loading…
Cancel
Save