Commit 67bb8798 authored by trumansdo's avatar trumansdo
Browse files

done: 完成代码生成以外的功能

todo: 代码生成、前端架构调整、样式调整
parent e27ca5d7
......@@ -5,7 +5,7 @@
* @LastEditors: 一日看尽长安花
* @Description: 与业务有关的非纯api的js
*/
import { getOrgsByParent } from '@/api/org';
import { getOrgsByParent } from '@/api/core_org';
/**
* @description: 异步载入级联器的数据
......
......@@ -6,7 +6,7 @@
* @LastEditors: 一日看尽长安花
*/
import { constantRoutes } from '@/router';
import { getRoutes } from '@/api/role';
import { getRoutes } from '@/api/core_role';
import { default as asyncRoutesMap } from '@/router/maps/index';
import { deepClone, objectMerge } from '@/utils/index';
import { isExists, isNotExists } from '@/utils/object-util';
......
import { login, logout, getInfo } from '@/api/user';
import { login, logout, getInfo } from '@/api/admin_users';
import { getToken, setToken, removeToken } from '@/utils/auth';
import router, { resetRouter } from '@/router';
......
......@@ -84,7 +84,7 @@
</div>
</template>
<script>
import { saveDictData, updateDictData } from '@/api/dicts';
import { saveDictData, updateDictData } from '@/api/admin_dicts';
export default {
name: 'DictEditPopup',
......
......@@ -126,8 +126,8 @@ import {
deleteDictData,
exportDictExcel,
importExcel
} from '@/api/dicts';
import { download } from '@/api/file';
} from '@/api/admin_dicts';
import { download } from '@/api/core_file';
export default {
name: 'DictManager',
......
......@@ -126,7 +126,7 @@ import {
createFuncNode,
updateFuncNode,
delFuncNodesByParent
} from '@/api/func';
} from '@/api/admin_funcs';
import SelFuncDialog from './select_dialog';
export default {
......
......@@ -37,7 +37,7 @@
</template>
<script>
/** 功能点管理 */
import { funcs } from '@/api/func';
import { funcs } from '@/api/admin_funcs';
export default {
name: 'SelFuncDialog',
......
......@@ -139,8 +139,8 @@ import {
createMenuItem,
updateMenuItem,
delMenuItemsByParent
} from '@/api/menu';
import { funcs } from '@/api/func';
} from '@/api/admin_menus';
import { funcs } from '@/api/admin_funcs';
import SelFuncDialog from '@/views/functions/select_dialog';
import SelMenuDialog from './select_dialog';
......
<!--
* @Author: 一日看尽长安花
* @since: 2020-07-19 16:33:05
* @LastEditTime: 2020-08-02 13:40:08
* @LastEditors: 一日看尽长安花
* @Description:
-->
<template>
<!-- vue实例外创建 -->
<div class="sp-edit-form-popup">
<el-dialog
ref="editDialog"
:title="title"
:visible.sync="visible"
:destroy-on-close="true"
:close-on-click-modal="false"
:close-on-press-escape="false"
:show-close="false"
@open="initDialog"
>
<div class="sp-edit-form">
<el-form
ref="editPopupForm"
:model="data_"
:rules="rules"
label-width="120px"
>
<el-form-item label="角色名称" required prop="name">
<el-input
v-model="data_.name"
placeholder="请输入角色名称"
></el-input>
</el-form-item>
<el-form-item label="角色代码" required prop="code">
<el-input
v-model="data_.code"
placeholder="请输入角色代码"
></el-input>
</el-form-item>
<el-form-item label="角色类型" required prop="type">
<el-select v-model="data_.type" placeholder="请选择角色类型">
<el-option
v-for="item in roleOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
</el-form>
</div>
<template #footer>
<div class="sp-edit-form-btn">
<el-button @click="close">取 消</el-button>
<el-button type="primary" @click="submit">
确 定
</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script>
import { saveOrgData, updateOrgData } from '@/api/admin_orgs';
export default {
name: 'DictEditPopup',
components: {},
props: {
visible: {
type: Boolean,
default: false
},
title: {
type: String,
default: '编辑'
},
data: {
type: Object,
default: function() {
return {};
}
}
},
data() {
return {
data_: {},
roleOptions: [
{
value: 'R0',
label: '操作角色'
},
{
value: 'R1',
label: '工作流角色'
}
],
rules: {
name: [{ required: true, message: '请输入角色名称' }],
code: [{ required: true, message: '请输入角色代码' }],
type: [{ required: true, message: '请选择角色类型' }]
}
};
},
methods: {
initDialog() {
this.data_ = this.data;
if (this.data_.id) {
this.title = '编辑';
} else {
this.title = '新增';
}
},
submit() {
this.$refs['editPopupForm'].validate(valid => {
if (valid) {
if (this.data_.id) {
this.updateData();
} else {
this.addData();
}
} else {
return false;
}
});
},
addData() {
const _that = this;
saveOrgData(this.data_).then(res => {
const { code, message, data } = { ...res };
// 通过中间路由刷新当前路由
_that.$nextTick(() => {
_that.$notify({
title: '成功',
message: '添加成功',
type: 'success',
duration: 2000,
onClose: function() {
_that.$router.replace('/refresh');
}
});
});
});
},
updateData() {
const _that = this;
updateOrgData(this.data_).then(res => {
const { code, message, data } = { ...res };
// 通过中间路由刷新当前路由
_that.$nextTick(() => {
_that.$notify({
title: '成功',
message: '修改成功',
type: 'success',
duration: 2000,
onClose: function() {
_that.$router.replace('/refresh');
}
});
});
});
},
close() {
this.$emit('update:visible', false);
}
}
};
</script>
<!--
* @Author: 一日看尽长安花
* @since: 2020-07-12 16:32:51
* @LastEditTime: 2020-08-02 13:47:08
* @LastEditors: 一日看尽长安花
* @Description:
-->
<template>
<div class="sp-view-page">
<div class="sp-search-inline-pane">
<el-form :inline="true" :model="searchData">
<el-form-item label="编码">
<el-input
v-model="searchData.code"
placeholder="请输入编码"
></el-input>
</el-form-item>
<el-form-item label="名称">
<el-input
v-model="searchData.name"
placeholder="请输入名称"
></el-input>
</el-form-item>
</el-form>
</div>
<div class="sp-opr-btn-group">
<div class="sp-func-btn">
<el-button class="el-icon-plus" type="primary" @click="addRecord">
增加
</el-button>
</div>
<div class="sp-func-btn">
<el-button
class="el-icon-delete-solid"
type="primary"
@click="delRecord"
>
删除
</el-button>
</div>
<div class="sp-func-btn">
<el-button
class="el-icon-delete-solid"
type="primary"
@click="delRecord"
>
查看用户
</el-button>
</div>
<div class="sp-search-btn">
<el-button class="el-icon-search" type="primary" @click="onSearch">
查询
</el-button>
</div>
</div>
<el-table
ref="dataTable"
:data="tableData"
border
fit
highlight-current-row
>
<el-table-column label="#" type="selection"> </el-table-column>
<el-table-column prop="id" label="id"> </el-table-column>
<el-table-column prop="code" label="机构代码"> </el-table-column>
<el-table-column prop="name" label="机构名称"> </el-table-column>
<el-table-column prop="parent_org_text" label="上一级机构">
</el-table-column>
<el-table-column prop="type_text" label="机构类型"> </el-table-column>
<el-table-column prop="create_time" label="创建时间">
<template slot-scope="scope">
<span>
{{ scope.row.create_time | parseTime('{y}-{m}-{d} {h}:{i}') }}
</span>
</template></el-table-column
>
<el-table-column label="操作" width="150">
<template slot-scope="scope">
<el-button size="mini" @click="handleEdit(scope.$index, scope.row)">
编辑
</el-button>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="pageQuery.total > 0"
:total="pageQuery.total"
:page.sync="pageQuery.page"
:limit.sync="pageQuery.limit"
@pagination="getList"
/>
<edit-popup :visible.sync="editVisible" :data="rowData"></edit-popup>
</div>
</template>
<script>
import Pagination from '@/components/Pagination'; // secondary package based on el-pagination
import EditPopup from './edit_popup';
import { getOrgs, getOrgById, deleteOrgData } from '@/api/admin_orgs';
import { download } from '@/api/core_file';
export default {
name: 'OrgManager',
components: { Pagination, EditPopup },
props: {},
data() {
return {
searchData: {},
tableData: [],
loading: true,
pageQuery: { page: 1, limit: 10, total: 0 },
editVisible: false,
rowData: {}
};
},
mounted() {
this.getList();
},
methods: {
getList() {
const queryParam = Object.assign({}, this.searchData, this.pageQuery);
getOrgs(queryParam).then(res => {
const { code, message, data, count, total } = { ...res };
this.pageQuery.total = total;
this.tableData = data;
});
},
onSearch() {
this.getList();
},
addRecord() {
this.rowData = {};
this.editVisible = true;
},
handleEdit(index, row) {
this.rowData = row;
this.editVisible = true;
},
handleDelete(index, row) {
const Vue = this;
this.$confirm('确定删除该角色?', '删除', {
type: 'warning '
})
.then(() => {
deleteOrgData({ ids: [row.id] })
.then(result => {
this.$nextTick(() => {
this.$notify({
title: '成功',
message: '删除角色数据成功',
type: 'success',
duration: 2000,
onClose: function() {
Vue.$router.replace('/refresh');
}
});
});
})
.catch(err => {
this.$nextTick(() => {
this.$notify({
title: '失败',
message: '删除角色数据失败',
type: 'error',
duration: 2000
});
});
});
})
.catch(action => {});
},
delRecord() {
const _table = this.$refs.dataTable;
const isSelection = _table.selection.length > 0 ? true : false;
if (!isSelection) {
this.$message({
type: 'warning',
message: '请选择数据'
});
return;
}
this.$confirm('确定删除所选角色?', '删除', {
type: 'warning '
}).then(() => {
const _selList = _table.selection;
const ids = _selList.map(item => item.id);
deleteOrgData({ ids: ids }).then(response => {
const { code, message, data } = { ...response };
this.onSearch();
});
});
}
}
};
</script>
<style scoped>
.sp-view-page {
padding: 5px 10px;
}
.sp-opr-btn-group {
display: flex;
align-items: center;
justify-content: flex-start;
padding: 3px 0;
column-gap: 5px;
}
.sp-func-btn {
}
.sp-search-btn {
position: absolute;
right: 5px;
}
</style>
......@@ -20,13 +20,20 @@
</el-table-column>
<el-table-column align="center" label="Operations">
<template slot-scope="scope">
<el-button type="primary" size="small" @click="handleEdit(scope)">Edit</el-button>
<el-button type="danger" size="small" @click="handleDelete(scope)">Delete</el-button>
<el-button type="primary" size="small" @click="handleEdit(scope)">
Edit
</el-button>
<el-button type="danger" size="small" @click="handleDelete(scope)">
Delete
</el-button>
</template>
</el-table-column>
</el-table>
<el-dialog :visible.sync="dialogVisible" :title="dialogType==='edit'?'Edit Role':'New Role'">
<el-dialog
:visible.sync="dialogVisible"
:title="dialogType === 'edit' ? 'Edit Role' : 'New Role'"
>
<el-form :model="role" label-width="80px" label-position="left">
<el-form-item label="Name">
<el-input v-model="role.name" placeholder="Role Name" />
......@@ -34,7 +41,7 @@
<el-form-item label="Desc">
<el-input
v-model="role.description"
:autosize="{ minRows: 2, maxRows: 4}"
:autosize="{ minRows: 2, maxRows: 4 }"
type="textarea"
placeholder="Role Description"
/>
......@@ -52,7 +59,9 @@
</el-form-item>
</el-form>
<div style="text-align:right;">
<el-button type="danger" @click="dialogVisible=false">Cancel</el-button>
<el-button type="danger" @click="dialogVisible = false">
Cancel
</el-button>
<el-button type="primary" @click="confirmRole">Confirm</el-button>
</div>
</el-dialog>
......@@ -60,16 +69,17 @@
</template>
<script>
import path from 'path'
import { deepClone } from '@/utils'
import { getRoutes, getRoles, addRole, deleteRole, updateRole } from '@/api/role'
import path from 'path';
import { deepClone } from '@/utils';
import { getRoutes, addRole, deleteRole, updateRole } from '@/api/core_role';
import { getRoles } from '@/api/admin_roles';
const defaultRole = {
key: '',
name: '',
description: '',
routes: []
}
};
export default {
data() {
......@@ -84,89 +94,93 @@ export default {
children: 'children',
label: 'title'
}
}
};
},
computed: {
routesData() {
return this.routes
return this.routes;
}
},
created() {
// Mock: get all routes and roles list from server
this.getRoutes()
this.getRoles()
this.getRoutes();
this.getRoles();
},
methods: {
async getRoutes() {
const res = await getRoutes()
this.serviceRoutes = res.data
this.routes = this.generateRoutes(res.data)
const res = await getRoutes();
this.serviceRoutes = res.data;
this.routes = this.generateRoutes(res.data);
},
async getRoles() {
const res = await getRoles()
this.rolesList = res.data
const res = await getRoles();
this.rolesList = res.data;
},
// Reshape the routes structure so that it looks the same as the sidebar
generateRoutes(routes, basePath = '/') {
const res = []
const res = [];
for (let route of routes) {
// skip some route
if (route.hidden) { continue }
if (route.hidden) {
continue;
}
const onlyOneShowingChild = this.onlyOneShowingChild(route.children, route)
const onlyOneShowingChild = this.onlyOneShowingChild(
route.children,
route
);
if (route.children && onlyOneShowingChild && !route.alwaysShow) {
route = onlyOneShowingChild
route = onlyOneShowingChild;
}
const data = {
path: path.resolve(basePath, route.path),
title: route.meta && route.meta.title
}
};
// recursive child routes
if (route.children) {
data.children = this.generateRoutes(route.children, data.path)
data.children = this.generateRoutes(route.children, data.path);
}
res.push(data)
res.push(data);
}
return res
return res;
},
generateArr(routes) {
let data = []
let data = [];
routes.forEach(route => {
data.push(route)
data.push(route);
if (route.children) {
const temp = this.generateArr(route.children)
const temp = this.generateArr(route.children);
if (temp.length > 0) {
data = [...data, ...temp]
data = [...data, ...temp];
}
}
})
return data
});
return data;
},
handleAddRole() {
this.role = Object.assign({}, defaultRole)
this.role = Object.assign({}, defaultRole);
if (this.$refs.tree) {
this.$refs.tree.setCheckedNodes([])
this.$refs.tree.setCheckedNodes([]);
}
this.dialogType = 'new'
this.dialogVisible = true
this.dialogType = 'new';
this.dialogVisible = true;
},
handleEdit(scope) {
this.dialogType = 'edit'
this.dialogVisible = true
this.checkStrictly = true
this.role = deepClone(scope.row)
this.dialogType = 'edit';
this.dialogVisible = true;
this.checkStrictly = true;
this.role = deepClone(scope.row);
this.$nextTick(() => {
const routes = this.generateRoutes(this.role.routes)
this.$refs.tree.setCheckedNodes(this.generateArr(routes))
const routes = this.generateRoutes(this.role.routes);
this.$refs.tree.setCheckedNodes(this.generateArr(routes));
// set checked state of a node not affects its father and child nodes
this.checkStrictly = false
})
this.checkStrictly = false;
});
},
handleDelete({ $index, row }) {
this.$confirm('Confirm to remove the role?', 'Warning', {
......@@ -174,55 +188,68 @@ export default {
cancelButtonText: 'Cancel',
type: 'warning'
})
.then(async() => {
await deleteRole(row.key)
this.rolesList.splice($index, 1)
.then(async () => {
await deleteRole(row.key);
this.rolesList.splice($index, 1);
this.$message({
type: 'success',
message: 'Delete succed!'
})
});
})
.catch(err => { console.error(err) })
.catch(err => {
console.error(err);
});
},
generateTree(routes, basePath = '/', checkedKeys) {
const res = []
const res = [];
for (const route of routes) {
const routePath = path.resolve(basePath, route.path)
const routePath = path.resolve(basePath, route.path);
// recursive child routes
if (route.children) {
route.children = this.generateTree(route.children, routePath, checkedKeys)
route.children = this.generateTree(
route.children,
routePath,
checkedKeys
);
}
if (checkedKeys.includes(routePath) || (route.children && route.children.length >= 1)) {
res.push(route)
if (
checkedKeys.includes(routePath) ||
(route.children && route.children.length >= 1)
) {
res.push(route);
}
}
return res
return res;
},
async confirmRole() {
const isEdit = this.dialogType === 'edit'
const isEdit = this.dialogType === 'edit';
const checkedKeys = this.$refs.tree.getCheckedKeys()
this.role.routes = this.generateTree(deepClone(this.serviceRoutes), '/', checkedKeys)
const checkedKeys = this.$refs.tree.getCheckedKeys();
this.role.routes = this.generateTree(
deepClone(this.serviceRoutes),
'/',
checkedKeys
);
if (isEdit) {
await updateRole(this.role.key, this.role)
await updateRole(this.role.key, this.role);
for (let index = 0; index < this.rolesList.length; index++) {
if (this.rolesList[index].key === this.role.key) {
this.rolesList.splice(index, 1, Object.assign({}, this.role))
break
this.rolesList.splice(index, 1, Object.assign({}, this.role));
break;
}
}
} else {
const { data } = await addRole(this.role)
this.role.key = data.key
this.rolesList.push(this.role)
const { data } = await addRole(this.role);
this.role.key = data.key;
this.rolesList.push(this.role);
}
const { description, key, name } = this.role
this.dialogVisible = false
const { description, key, name } = this.role;
this.dialogVisible = false;
this.$notify({
title: 'Success',
dangerouslyUseHTMLString: true,
......@@ -232,30 +259,30 @@ export default {
<div>Description: ${description}</div>
`,
type: 'success'
})
});
},
// reference: src/view/layout/components/Sidebar/SidebarItem.vue
onlyOneShowingChild(children = [], parent) {
let onlyOneChild = null
const showingChildren = children.filter(item => !item.hidden)
let onlyOneChild = null;
const showingChildren = children.filter(item => !item.hidden);
// When there is only one child route, the child route is displayed by default
if (showingChildren.length === 1) {
onlyOneChild = showingChildren[0]
onlyOneChild.path = path.resolve(parent.path, onlyOneChild.path)
return onlyOneChild
onlyOneChild = showingChildren[0];
onlyOneChild.path = path.resolve(parent.path, onlyOneChild.path);
return onlyOneChild;
}
// Show parent if there are no child route to display
if (showingChildren.length === 0) {
onlyOneChild = { ... parent, path: '', noShowingChildren: true }
return onlyOneChild
onlyOneChild = { ...parent, path: '', noShowingChildren: true };
return onlyOneChild;
}
return false
return false;
}
}
}
};
</script>
<style lang="scss" scoped>
......
......@@ -62,7 +62,7 @@
</div>
</template>
<script>
import { saveRoleData, updateRoleData } from '@/api/roles';
import { saveRoleData, updateRoleData } from '@/api/admin_roles';
export default {
name: 'DictEditPopup',
......
......@@ -102,8 +102,8 @@
import Pagination from '@/components/Pagination'; // secondary package based on el-pagination
import EditPopup from './edit_popup';
import { getRoles, getRoleById, deleteRoleData } from '@/api/roles';
import { download } from '@/api/file';
import { getRoles, getRoleById, deleteRoleData } from '@/api/admin_roles';
import { download } from '@/api/core_file';
export default {
name: 'RoleManager',
......
<!--
* @Author: 一日看尽长安花
* @since: 2020-05-30 12:53:38
* @LastEditTime: 2020-08-15 21:13:05
* @LastEditors: 一日看尽长安花
* @Description:
-->
<template>
<!-- vue实例外创建 -->
<div id="menu-manager" class="sp-transfer_editor--two">
<div class="sp-side_panel--left">
<el-radio-group v-model="selectRoleId" size="medium" @change="changeRole">
<el-row v-for="item in rolesDatas" :key="item.id">
<el-col>
<el-radio :key="item.id" :label="item.id" border>
{{ item.name }}
</el-radio>
</el-col>
</el-row>
</el-radio-group>
</div>
<div class="sp-side_panel--right">
<el-row v-for="(item, index) in roleDataFunctions" :key="index">
<el-col>
<span class="demonstration">{{ item.label }}</span>
<el-cascader
:ref="'cascader' + index"
v-model="cascaderValues['val' + index]"
:options="allOptions['options' + index]"
clearable
@change="changeSelect('cascader' + index)"
></el-cascader>
</el-col>
</el-row>
</div>
</div>
</template>
<script>
import {
getRoles,
getRoleDataFunctions,
saveRoleDataFunction
} from '@/api/admin_roles';
export default {
name: 'RoleDataFuncAuthManager',
components: {},
props: {},
data() {
return {
rolesDatas: [],
roleDataFunctions: [],
selectRoleId: undefined,
cascaderValues: {},
allOptions: {}
};
},
watch: {},
mounted() {
this.init();
},
methods: {
changeRole(roleId) {
this.getRoleDataFunctions(roleId);
},
init() {
getRoles().then(res => {
const { data, code, message } = { ...res };
this.rolesDatas = data;
if (data.length > 0) {
this.selectRoleId = data[0].id;
this.getRoleDataFunctions(this.selectRoleId);
}
});
},
getRoleDataFunctions(roleId) {
getRoleDataFunctions({ role_id: roleId }).then(res => {
const { data, code, message } = { ...res };
this.roleDataFunctions = data;
const _that = this;
this.roleDataFunctions.forEach((v, i) => {
_that.cascaderValues['val' + i] = v.accesses[0].tail.data_access_type;
_that.allOptions['options' + i] = v.accesses;
});
});
},
changeSelect(refName) {
const node = this.$refs[refName][0].getCheckedNodes()[0];
const _that = this;
if (node) {
// 选中
const _data = node.data;
const params = {
role_id: this.selectRoleId,
fn_id: _data.tail.id,
access_type: _data.value
};
saveRoleDataFunction(params).then(res => {
const { code, message, data } = { ...res };
_that.$message({
message: '设置成功',
type: 'success'
});
});
} else {
// 不选择
_that.$message({
message: '不允许为空',
type: 'warn'
});
}
}
}
};
</script>
<style lang="scss" scoped>
.el-row {
margin: 0.68rem;
}
.demonstration {
color: #606266;
margin-right: 1rem;
}
.sp-transfer_editor--two {
display: flex;
justify-content: space-between;
align-items: stretch;
margin: 10px;
min-height: 84vh;
max-height: 84vh;
}
%sp-side_panel--common {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 0%;
box-shadow: 2px 2px 6px 1px #aaa;
padding: 10px;
margin: 0 10px;
}
.sp-side_panel--left {
@extend %sp-side_panel--common;
overflow-y: scroll;
}
.sp-side_panel--right {
@extend %sp-side_panel--common;
overflow-y: scroll;
}
</style>
<!--
* @Author: 一日看尽长安花
* @since: 2020-05-30 12:53:38
* @LastEditTime: 2020-08-15 15:09:07
* @LastEditors: 一日看尽长安花
* @Description:
-->
<template>
<!-- vue实例外创建 -->
<div id="menu-manager" class="sp-transfer_editor--two">
<div class="sp-side_panel--left">
<el-radio-group
v-model="formModel.roleId"
size="medium"
@change="changeRole"
>
<el-row v-for="item in rolesData" :key="item.id">
<el-col>
<el-radio :key="item.id" :label="item.id" border>
{{ item.name }}
</el-radio>
</el-col>
</el-row>
</el-radio-group>
</div>
<div class="sp-side_panel--right">
<el-input v-model="filterText" placeholder="输入关键字进行过滤">
</el-input>
<el-tree
key="treeKey"
ref="tree"
:data="funcTreeData"
node-key="id"
show-checkbox
default-expand-all
highlight-current
:expand-on-click-node="false"
:filter-node-method="filterNode"
@check="nodeSelected"
>
<template v-slot="{ node: node, data: data }">
<div :class="['sp-tree_node', 'sp-tree_node_type--' + data.type]">
<span>{{ data.name }}</span>
</div>
</template>
</el-tree>
</div>
</div>
</template>
<script>
import {
getRoles,
getFunctionIdsByRole,
updateRoleFunctions
} from '@/api/admin_roles';
import { funcs } from '@/api/admin_funcs';
export default {
name: 'RoleFuncAuthManager',
components: {},
props: {},
data() {
return {
filterText: '',
rolesData: [],
roleFunctionIds: [],
funcTreeData: [],
formModel: {
roleId: undefined
},
rules: {}
};
},
watch: {
filterText(val) {
this.$refs.tree.filter(val);
}
},
mounted() {
this.getRoleList();
this.getFuncTree();
},
methods: {
changeRole(roleId) {
getFunctionIdsByRole({ role_id: roleId }).then(res => {
const { data, code, message } = { ...res };
this.roleFunctionIds = data;
this.$refs.tree.setCheckedKeys(this.roleFunctionIds);
});
},
getRoleList() {
getRoles().then(res => {
const { data, code, message } = { ...res };
this.rolesData = data;
});
},
getFuncTree() {
funcs().then(res => {
const { code, message, data } = { ...res };
const vmNode = [
{
id: -1,
name: '平台',
children: data
}
];
this.funcTreeData = vmNode;
});
},
filterNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
getTreeBranchIds(node) {
let ids = [];
ids.push(node.id);
const _children = node.children;
for (let i = 0; i < _children.length; i++) {
const child = _children[i];
let _child_ids = this.getTreeBranchIds(child);
ids = ids.concat(_child_ids);
}
return ids;
},
nodeSelected(selectedNode, allSelectedNodes) {
if (!this.formModel.roleId) {
this.$message({
message: '请选择一个角色',
type: 'warning'
});
this.getTreeBranchIds(selectedNode).forEach((v, i) => {
this.$refs.tree.setChecked(v, false, true);
});
return;
}
const selectedNodes = this.$refs.tree.getCheckedNodes(false, true);
const functions = selectedNodes.map(n => {
return { id: n.id, type: n.type, name: n.name };
});
updateRoleFunctions({
role_id: this.formModel.roleId,
functions: functions
}).then(res => {
const { code, message, data } = { ...res };
this.$message({
message: '设置成功',
type: 'success'
});
});
}
}
};
</script>
<style lang="scss" scoped>
.el-row {
margin: 0.68rem;
}
.sp-transfer_editor--two {
display: flex;
justify-content: space-between;
align-items: stretch;
margin: 10px;
min-height: 84vh;
max-height: 84vh;
}
%sp-side_panel--common {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 0%;
box-shadow: 2px 2px 6px 1px #aaa;
padding: 10px;
margin: 0 10px;
}
.sp-side_panel--left {
@extend %sp-side_panel--common;
overflow-y: scroll;
}
.sp-side_panel--right {
@extend %sp-side_panel--common;
overflow-y: scroll;
}
.sp-tree_node {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
padding-left: 6px;
border-radius: 5px;
}
%sp-tree_node_type {
box-shadow: 1px 1px 1px 1px #e8f4ff;
}
.sp-tree_node_type--FN0 {
@extend %sp-tree_node_type;
background: linear-gradient(to right, #ff03035e, transparent);
}
.sp-tree_node_type--FN1 {
@extend %sp-tree_node_type;
background: linear-gradient(to right, #fff5035e, transparent);
}
.sp-tree_node_type--FN2 {
@extend %sp-tree_node_type;
background: linear-gradient(to right, #033cff5e, transparent);
}
</style>
<style lang="scss">
.el-tree-node {
margin-top: 5px;
}
</style>
......@@ -70,7 +70,7 @@
</template>
<script>
import SpCascader from '@/components/Wrapper/SpCascader';
import { addUserRoles } from '@/api/user';
import { addUserRoles } from '@/api/admin_users';
import { handleCascaderValue } from '@/services/dict';
export default {
name: 'AddUserRole',
......
......@@ -61,7 +61,7 @@
</div>
</template>
<script>
import { changePassword } from '@/api/user';
import { changePassword } from '@/api/admin_users';
export default {
name: 'ChangePassword',
components: {},
......
......@@ -181,10 +181,10 @@ import {
updateUserData,
deleteUserData,
exportExcelUserData
} from '@/api/user';
import { download } from '@/api/file';
import { immaditeLoadDicts } from '@/api/dict';
import { immaditeLoadOrgs } from '@/api/org';
} from '@/api/admin_users';
import { download } from '@/api/core_file';
import { immaditeLoadDicts } from '@/api/core_dict';
import { immaditeLoadOrgs } from '@/api/core_org';
import { layzyLoadDictTree, handleCascaderValue } from '@/services/dict';
import { layzyLoadOrgTree } from '@/services/org';
......
......@@ -116,9 +116,9 @@
</template>
<script>
import Pagination from '@/components/Pagination';
import { immaditeLoadRoles } from '@/api/role';
import { immaditeLoadOrgs } from '@/api/org';
import { getUserRoles, getUserById, deleteUserRoles } from '@/api/user';
import { immaditeLoadRoles } from '@/api/core_role';
import { immaditeLoadOrgs } from '@/api/core_org';
import { getUserRoles, getUserById, deleteUserRoles } from '@/api/admin_users';
import AddUserRole from './add-user-role';
import SpTreeSelect from '@/components/Wrapper/SpTreeSelect';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment