|
@@ -4,9 +4,9 @@
|
|
|
<el-col :span="24" class="main">
|
|
|
<el-col :span="24" class="one">
|
|
|
<el-form
|
|
|
- :model="queryParams"
|
|
|
- ref="queryForm"
|
|
|
v-show="showSearch"
|
|
|
+ ref="queryForm"
|
|
|
+ :model="queryParams"
|
|
|
:inline="true"
|
|
|
>
|
|
|
<el-form-item label="角色名称" prop="roleName">
|
|
@@ -25,11 +25,12 @@
|
|
|
icon="el-icon-search"
|
|
|
size="mini"
|
|
|
@click="handleQuery"
|
|
|
- >搜索</el-button
|
|
|
- >
|
|
|
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
|
|
|
- >重置</el-button
|
|
|
- >
|
|
|
+ >搜索</el-button>
|
|
|
+ <el-button
|
|
|
+ icon="el-icon-refresh"
|
|
|
+ size="mini"
|
|
|
+ @click="resetQuery"
|
|
|
+ >重置</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</el-col>
|
|
@@ -58,13 +59,12 @@
|
|
|
>
|
|
|
<template slot-scope="scope">
|
|
|
<el-button
|
|
|
+ v-hasPermi="['system:role:relation']"
|
|
|
size="mini"
|
|
|
type="text"
|
|
|
icon="el-icon-refresh-right"
|
|
|
@click="toRelation(scope.row)"
|
|
|
- v-hasPermi="['system:role:relation']"
|
|
|
- >账号等级关联</el-button
|
|
|
- >
|
|
|
+ >账号等级关联</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -86,10 +86,10 @@
|
|
|
>
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
|
|
<el-form-item label="角色名称">
|
|
|
- <el-input v-model="form.roleName" disabled></el-input>
|
|
|
+ <el-input v-model="form.roleName" disabled />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="权限字符">
|
|
|
- <el-input v-model="form.roleKey" disabled></el-input>
|
|
|
+ <el-input v-model="form.roleKey" disabled />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="账号等级" prop="level">
|
|
|
<el-radio-group v-model="form.level">
|
|
@@ -99,9 +99,11 @@
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
- <el-button type="primary" size="mini" @click="onSubmit('form')"
|
|
|
- >保存</el-button
|
|
|
- >
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ size="mini"
|
|
|
+ @click="onSubmit('form')"
|
|
|
+ >保存</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</el-dialog>
|
|
@@ -109,14 +111,14 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { mapState, mapGetters, createNamespacedHelpers } from "vuex";
|
|
|
-import { listRole } from "@/api/system/role";
|
|
|
-const { mapActions: role_relation } = createNamespacedHelpers("role_relation");
|
|
|
+import { mapState, mapGetters, createNamespacedHelpers } from 'vuex'
|
|
|
+import { listRole } from '@/api/system/role'
|
|
|
+const { mapActions: role_relation } = createNamespacedHelpers('role_relation')
|
|
|
export default {
|
|
|
- name: "index",
|
|
|
- props: {},
|
|
|
+ name: 'Index',
|
|
|
components: {},
|
|
|
- data: function () {
|
|
|
+ props: {},
|
|
|
+ data: function() {
|
|
|
return {
|
|
|
// 遮罩层
|
|
|
loading: true,
|
|
@@ -130,105 +132,105 @@ export default {
|
|
|
queryParams: {
|
|
|
pageNum: 1,
|
|
|
pageSize: 10,
|
|
|
- roleName: undefined,
|
|
|
+ roleName: undefined
|
|
|
},
|
|
|
- dialog: { title: "账号关联", show: false },
|
|
|
+ dialog: { title: '账号关联', show: false },
|
|
|
// 账号关联
|
|
|
form: {},
|
|
|
rules: {
|
|
|
level: [
|
|
|
- { required: true, message: "请选择账号等级", trigger: "change" },
|
|
|
- ],
|
|
|
- },
|
|
|
- };
|
|
|
+ { required: true, message: '请选择账号等级', trigger: 'change' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
created() {
|
|
|
- this.getList();
|
|
|
- this.getDicts("sys_normal_disable").then((response) => {
|
|
|
- this.statusOptions = response.data;
|
|
|
- });
|
|
|
+ this.getList()
|
|
|
+ this.getDicts('sys_normal_disable').then((response) => {
|
|
|
+ this.statusOptions = response.data
|
|
|
+ })
|
|
|
},
|
|
|
methods: {
|
|
|
- ...role_relation(["query", "update"]),
|
|
|
+ ...role_relation(['query', 'update']),
|
|
|
/** 查询角色列表 */
|
|
|
getList() {
|
|
|
- this.loading = true;
|
|
|
+ this.loading = true
|
|
|
listRole(this.addDateRange(this.queryParams, this.dateRange)).then(
|
|
|
(response) => {
|
|
|
- this.roleList = response.rows;
|
|
|
- this.total = response.total;
|
|
|
- this.loading = false;
|
|
|
+ this.roleList = response.rows
|
|
|
+ this.total = response.total
|
|
|
+ this.loading = false
|
|
|
}
|
|
|
- );
|
|
|
+ )
|
|
|
},
|
|
|
/** 搜索按钮操作 */
|
|
|
handleQuery() {
|
|
|
- this.queryParams.pageNum = 1;
|
|
|
- this.getList();
|
|
|
+ this.queryParams.pageNum = 1
|
|
|
+ this.getList()
|
|
|
},
|
|
|
/** 重置按钮操作 */
|
|
|
resetQuery() {
|
|
|
- this.dateRange = [];
|
|
|
- this.resetForm("queryForm");
|
|
|
- this.handleQuery();
|
|
|
+ this.dateRange = []
|
|
|
+ this.resetForm('queryForm')
|
|
|
+ this.handleQuery()
|
|
|
},
|
|
|
// 账号等级关联
|
|
|
async toRelation(data) {
|
|
|
// 查询该角色关联信息
|
|
|
- let res = await this.query();
|
|
|
+ const res = await this.query()
|
|
|
if (this.$checkRes(res)) {
|
|
|
- let arr = {
|
|
|
+ const arr = {
|
|
|
id: res.data.id,
|
|
|
roleName: data.roleName,
|
|
|
- roleKey: data.roleKey,
|
|
|
- };
|
|
|
- let relation = res.data.relation.find((i) => i.role == data.roleKey);
|
|
|
- if (relation) arr.level = relation.level;
|
|
|
- this.$set(this, `form`, arr);
|
|
|
- this.dialog = { title: "账号关联", show: true };
|
|
|
+ roleKey: data.roleKey
|
|
|
+ }
|
|
|
+ const relation = res.data.relation.find((i) => i.role == data.roleKey)
|
|
|
+ if (relation) arr.level = relation.level
|
|
|
+ this.$set(this, `form`, arr)
|
|
|
+ this.dialog = { title: '账号关联', show: true }
|
|
|
}
|
|
|
},
|
|
|
// 保存
|
|
|
onSubmit(formName) {
|
|
|
- this.$refs[formName].validate(async (valid) => {
|
|
|
+ this.$refs[formName].validate(async(valid) => {
|
|
|
if (valid) {
|
|
|
- let data = {
|
|
|
+ const data = {
|
|
|
id: this.form.id,
|
|
|
- relation: [{ role: this.form.roleKey, level: this.form.level }],
|
|
|
- };
|
|
|
- let res = await this.update(data);
|
|
|
+ relation: [{ role: this.form.roleKey, level: this.form.level }]
|
|
|
+ }
|
|
|
+ const res = await this.update(data)
|
|
|
if (res.code === 200) {
|
|
|
- this.$message({ type: `success`, message: res.msg });
|
|
|
- this.toClose();
|
|
|
+ this.$message({ type: `success`, message: res.msg })
|
|
|
+ this.toClose()
|
|
|
} else {
|
|
|
- this.$message({ type: `error`, message: res.msg });
|
|
|
+ this.$message({ type: `error`, message: res.msg })
|
|
|
}
|
|
|
} else {
|
|
|
- console.log("error submit!!");
|
|
|
- return false;
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
// 账号关联关闭
|
|
|
toClose() {
|
|
|
- this.dialog = { title: "账号关联", show: false };
|
|
|
- this.getList();
|
|
|
- },
|
|
|
+ this.dialog = { title: '账号关联', show: false }
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapGetters(["roles"]),
|
|
|
+ ...mapGetters(['roles'])
|
|
|
},
|
|
|
metaInfo() {
|
|
|
- return { title: this.$route.meta.title };
|
|
|
+ return { title: this.$route.meta.title }
|
|
|
},
|
|
|
watch: {
|
|
|
test: {
|
|
|
deep: true,
|
|
|
immediate: true,
|
|
|
- handler(val) {},
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ handler(val) {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|