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

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

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

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

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

Loading…
Cancel
Save