Commit 3e06ae54 by 杨北旺

角色管理/创建角色/修改角色

1 parent e6add4c3
const staticRoutes = Object.freeze([{
name: 'account',
path: '/account/index',
meta: {},
component: resolve => require([`@/views/account/index.vue`], resolve)
},
{
name: 'addAccount',
path: '/account/addAccount/:id',
meta: {},
component: resolve => require([`@/views/account/addAccount.vue`], resolve)
},
{
name: 'editAccount',
path: '/account/editAccount/:id',
meta: {},
component: resolve => require([`@/views/account/editAccount.vue`], resolve)
},
{
name: 'detailAccount',
path: '/account/detailAccount/:id',
meta: {},
component: resolve => require([`@/views/account/detailAccount.vue`], resolve)
},
{
name: 'role',
path: '/role/index/index',
component: resolve => require([`@/views/role/index/index.vue`], resolve),
meta: {}
},
{
name: 'role',
path: '/role/create/index',
component: resolve => require([`@/views/role/create/index.vue`], resolve),
meta: {}
},
{
name: 'role',
path: '/role/index/look',
component: resolve => require([`@/views/role/index/look.vue`], resolve),
meta: {}
},
{
name: 'employee',
path: '/employee/editEmployee',
meta: {},
component: resolve => require([`@/views/employee/editEmployee.vue`], resolve)
}
name: 'account',
path: '/account/index',
meta: {},
component: resolve => require([`@/views/account/index.vue`], resolve)
},
{
name: 'addAccount',
path: '/account/addAccount/:id',
meta: {},
component: resolve => require([`@/views/account/addAccount.vue`], resolve)
},
{
name: 'editAccount',
path: '/account/editAccount/:id',
meta: {},
component: resolve => require([`@/views/account/editAccount.vue`], resolve)
},
{
name: 'detailAccount',
path: '/account/detailAccount/:id',
meta: {},
component: resolve => require([`@/views/account/detailAccount.vue`], resolve)
},
{
name: 'role',
path: '/role/index',
component: resolve => require([`@/views/role/index.vue`], resolve),
meta: {}
},
{
name: 'role',
path: '/role/create/:id',
component: resolve => require([`@/views/role/create.vue`], resolve),
meta: {}
},
{
name: 'role',
path: '/role/look:id',
component: resolve => require([`@/views/role/look.vue`], resolve),
meta: {}
},
{
name: 'employee',
path: '/employee/editEmployee',
meta: {},
component: resolve => require([`@/views/employee/editEmployee.vue`], resolve)
}
])
export default staticRoutes
\ No newline at end of file
......@@ -15,9 +15,9 @@ import { Http, utils } from 'glsx-common'
import render from './render'
import { routes } from '@/router'
export async function start() {
if (window.__POWERED_BY_QIANKUN__) return
const { response, request, sign, secret } = await fetchConfig()
Vue.prototype.$http = new Http({ response, request, sign, secret, alert: message.error, headers: { TGT: 'scrm-base-d476ca63-6084-4428-a690-d4475451dd9f-rop' } })
Vue.use(GLButton, { permissions: ['1-1-1-1', '2-1-1-1', '3-1-1-1'] })
render('/', routes)
if (window.__POWERED_BY_QIANKUN__) return
const { response, request, sign, secret } = await fetchConfig()
Vue.prototype.$http = new Http({ response, request, sign, secret, alert: message.error, headers: { TGT: 'scrm-base-57a2c9a4-42bd-4821-8af0-02e98a473594-rop' } })
Vue.use(GLButton, { permissions: ['1-1-1-1', '2-1-1-1', '3-1-1-1'] })
render('/', routes)
}
\ No newline at end of file
......@@ -44,6 +44,9 @@ export default {
},
accountlevel: {
type: Number
},
roleType:{
type:Boolean
}
},
......@@ -83,8 +86,9 @@ export default {
let params = {
accountlevel: this.accountlevel,
parentId: this.parentId,
id: this.pid
id: this.pId
}
console.log(params);
this.$apis.store.findMenuFunTreeByMerId(params).then(res => {
this.tabMenu = res.map(item => {
console.log(item)
......@@ -237,6 +241,7 @@ export default {
getSelectInfo() {
this.accountTypes = this.tabMenu.map(item => {
let products = []
let productList = []
item.productsArr.forEach(itm => {
const checkedNodes = this.$refs[`tree_${item.accounttypeId}_${itm.productId}`] ? this.$refs[`tree_${item.accounttypeId}_${itm.productId}`][0].getCheckedNodes() : []
console.log(checkedNodes)
......@@ -261,17 +266,33 @@ export default {
})
}
console.log(menuIdList, functionIdList, functionValueIdLists, list)
products.push({
productId: itm.productId,
functionIds: functionIdList,
functionValue: list,
menuIds: menuIdList
})
if(this.roleType){
productList.push({
productId: itm.productId,
functionIdList: functionIdList,
// functionValue: list,
menuIdList: menuIdList
})
}else{
products.push({
productId: itm.productId,
functionIds: functionIdList,
functionValue: list,
menuIds: menuIdList
})
}
})
return {
accounttypeId: item.accounttypeId,
products
}
if(this.roleType){
return {
accounttypeId: item.accounttypeId,
productList
}
}else{
return {
accounttypeId: item.accounttypeId,
products
}
}
})
return this.accountTypes
......@@ -279,7 +300,7 @@ export default {
},
mounted() {
// this.findMenuFunTreeByMerId()
this.findMenuFunTreeByMerId()
// this.findPermissionsByMerId()
}
}
......
......@@ -29,44 +29,13 @@
</div>
</el-form-item>
</el-form>
<div class="new_wrap">
<div class="root_menu_line">
<div v-for="(item, index) in rootList" :key="index" class="menu_item" :class="curRootIndex == index ? 'menu_item_active' : ''" @click="selectRootItem(index)">
{{ item.accounttypeName }}
</div>
</div>
</div>
<div class="product_line_wrap">
<div class="label_title">选择产品</div>
<div class="product_con">
<el-checkbox v-for="(item, index) in productList" :key="index" :false-label="item.productId" :true-label="item" @change="selectProductItem">
<div class="check_text">{{ item.productName }}</div>
</el-checkbox>
</div>
</div>
<div class="product_root_wrap">
<div class="label_title">请选择产品权限</div>
</div>
<div class="product_root_content_wrap">
<div class="content_menu_line">
<div v-for="(item, index) in storeList" :key="index" class="menu_line_item" :class="curMenuIndex == index ? 'menu_line_item_active' : ''" @click="selectMenuItem(index)">{{ item.productName }}</div>
</div>
<div class="content_menu_con">
<el-tree v-if="treeDataList.length" :data="treeDataList" :props="defaultProps"></el-tree>
<div v-if="treeDataList.length == 0" class="no_data_icon">
<div class="nodata_wrap">
<img class="icon" src="../../../assets/img/empty.png" />
<span class="text">暂无数据</span>
</div>
</div>
</div>
</div>
<SelectProduct ref="productFrom" :roleType="true" :parentId="41712" :accountlevel="2" :pId="41713"></SelectProduct>
</div>
<div style="height: 84px"></div>
<div class="fixed_bottom">
<el-button v-if="pageType == 'create'" type="primary">草稿</el-button>
<el-button v-if="pageType == 'create'" type="primary" @click="toCreateRole(1)">草稿</el-button>
<div class="wrap_driver">
<el-button type="primary" @click="toCreateRole">确定</el-button>
<el-button type="primary" @click="toCreateRole(0)">确定</el-button>
</div>
<el-button type="primary" @click="toBack">取消</el-button>
</div>
......@@ -74,11 +43,13 @@
</template>
<script>
import AutoButton from '../../../components/auto-button/index.vue'
import AutoButton from '../../components/auto-button/index.vue'
import SelectProduct from '../account/components/selectProduct.vue'
export default {
name: '',
components: {
AutoButton
AutoButton,
SelectProduct
},
data() {
return {
......@@ -94,9 +65,6 @@ export default {
},
rootList: [],
curRootIndex: 0,
productList: [],
storeList: [],
curMenuIndex: 0,
pageName: '新增角色',
roleInfo: null,
pageType: 'create',
......@@ -108,15 +76,16 @@ export default {
}
},
created() {
let query = this.$route.query
this.pageType = query.page
if (query.page == 'create') {
let id = Number(this.$route.params.id);
if (!id) {
this.pageName = '新增角色'
this.pageType ='create'
this.getMerchantName()
} else {
this.pageName = '修改角色'
let role = query.row
this.getRoleData(role.id)
this.pageType ='edit'
this.getRoleData(id)
this.editId = id
}
},
methods: {
......@@ -127,7 +96,8 @@ export default {
this.ruleForm = {
merchantName: res.merchantName,
roleName: res.roleName,
roleDesc: res.roleDescription
roleDesc: res.roleDescription,
merchantId:res.merchantId
}
this.getMerchantTree(id, res.responseList)
})
......@@ -170,8 +140,6 @@ export default {
return item
})
})
this.rootList = []
this.productList = []
},
// 选择商户权限
selectCurAccount(item, index) {
......@@ -185,68 +153,55 @@ export default {
})
this.rootList = arr
}
this.productList = this.rootList[0].products || []
},
// 选择产品的值
selectProductItem(val) {
console.log(val)
this.curMenuIndex = 0
if (typeof val === 'number') {
let arr = this.storeList.filter(el => {
return val != el.productId
})
this.storeList = arr
} else {
this.storeList.push(val)
}
},
selectRootItem(index) {
this.curRootIndex = index
this.productList = []
this.storeList = []
this.productList = this.rootList[index].products || []
},
// 产品筛选显示-隐藏
selectMenuItem(index) {
this.curMenuIndex = index
this.treeDataList = this.storeList[index].merchantProTreeResponses
},
// 确定按钮---处理参数---提交数据
toCreateRole() {
// 确定按钮---处理参数---提交数据---创建为0---草稿为1
toCreateRole(delFlag) {
let { merchantId, roleDesc, roleName } = this.ruleForm
if(!merchantId){
this.$message.error("请选择所属商户");
return
}
if(!roleName){
this.$message.error("请输入角色名称");
return
}
if (this.$refs.productFrom.getSelectInfo().length == 0) {
this.$message.error("请选择产品");
return;
}
let accountTypes = JSON.stringify(this.$refs.productFrom.getSelectInfo())
let para = {
merchantId: merchantId,
roleName: roleName,
roleDescription: roleDesc,
accounttypeId: 0,
'check[29]': 44,
delFlag: 0,
requestList: []
delFlag,
requestList: accountTypes,
}
if(this.pageType=='edit'){
para.id = this.editId
this.updateRole(para)
}else{
this.insertRole(para)
}
console.log(this.ruleForm)
console.log(para)
// if(this.pageType=='edit'){
// this.updateRole(para)
// }else{
// this.insertRole(para)
// }
},
insertRole(para) {
this.$apis.role.roleInfoData(para).then(res => {
this.$apis.role.createRole(para).then(res => {
if (res) {
history.go(-1)
this.toBack()
}
})
},
updateRole(para) {
this.$apis.role.updateRole(para).then(res => {
if (res) {
history.go(-1)
this.toBack()
}
})
},
toBack() {
history.go(-1)
this.$router.push("/role/index");
}
}
}
......@@ -276,130 +231,6 @@ export default {
padding: 32px 0;
background: #ffffff;
}
.new_wrap {
box-sizing: border-box;
width: 100%;
padding: 0 22px;
}
.root_menu_line {
height: 36px;
background: #f4f6fc;
border-radius: 4px;
display: flex;
align-items: center;
.menu_item {
width: 180px;
height: 32px;
text-align: center;
line-height: 32px;
color: #333333;
font-size: 14px;
margin-right: 2px;
background: #f4f6fc;
cursor: pointer;
border-radius: 2px;
}
.menu_item_active {
color: #5850ff;
background: #ffffff;
}
}
.product_line_wrap {
margin-top: 25px;
display: flex;
align-items: center;
.label_title {
box-sizing: border-box;
width: 100px;
font-size: 14px;
font-weight: 500;
color: #333333;
text-align: right;
padding: 0 12px 0 0;
}
.product_con {
display: flex;
align-items: center;
/deep/ .el-checkbox {
display: flex;
align-items: center;
}
.check_text {
max-width: 140px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
}
.product_root_wrap {
margin-top: 30px;
.label_title {
font-size: 14px;
font-weight: 500;
color: #333333;
padding-left: 30px;
}
}
.product_root_content_wrap {
// width: 100%;
box-sizing: border-box;
background: #f4f6fc;
border-radius: 4px;
margin: 0 20px;
margin-top: 10px;
padding: 0 10px;
.content_menu_line {
height: 50px;
width: 100%;
box-sizing: border-box;
padding-top: 10px;
display: flex;
.menu_line_item {
// width: 112px;
padding: 0 38px;
height: 40px;
text-align: center;
line-height: 40px;
color: #666666;
font-size: 14px;
border-radius: 4px 4px 0px 0px;
cursor: pointer;
}
.menu_line_item_active {
color: #322ad9;
background: #ffffff;
}
}
.content_menu_con {
// height: 100%;
min-height: 380px;
background: #ffffff;
border-radius: 0px 4px 4px 4px;
}
.no_data_icon {
height: 150px;
display: flex;
align-items: center;
justify-content: center;
.nodata_wrap {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.icon {
width: 64px;
height: 41px;
}
.text {
font-size: 14px;
font-weight: 400;
color: #262626;
margin-top: 10px;
}
}
}
}
.fixed_bottom {
position: fixed;
left: 0;
......@@ -423,44 +254,6 @@ export default {
.wrap {
margin-right: 15px;
}
// height: 40px;
}
// .root_wrap {
// display: flex;
// min-width: 80px;
// .root_name {
// padding: 0 16px;
// height: 30px;
// border-radius: 4px 0 0 4px;
// font-size: 14px;
// font-weight: 400;
// color: #ffffff;
// line-height: 30px;
// background: #d2d2d2;
// cursor: pointer;
// border: 1px solid #d2d2d2;
// }
// .root_icon {
// width: 30px;
// height: 30px;
// border: 1px solid #d2d2d2;
// border-left: none;
// border-radius: 0 4px 4px 0;
// cursor: pointer;
// }
// .show-icon {
// display: none;
// }
// }
// .root_wrap:hover > .root_name {
// background: #999999;
// border: 1px solid #999999;
// }
// .root_wrap:hover > .root_icon > .show-icon {
// display: block;
// text-align: center;
// line-height: 30px;
// font-size: 20px;
// color: #d2d2d2;
// }
</style>
......@@ -2,28 +2,29 @@
<div class="role-home-page">
<div class="top_widget">
<el-button size="small" icon="el-icon-plus" type="primary" @click="toCreatePage">创建角色</el-button>
<div v-if="accountLevel != 4" class="top_select">
<span class="select_label">商户名称</span>
<el-select :filter-method="filterList" size="small" clearable filterable v-model="searchForm.merchantId" placeholder="请选择">
<el-option v-for="item in list" :key="item.id" :label="item.merchantName" :value="item.id"></el-option>
</el-select>
</div>
</div>
<div class="driver_line"></div>
<div class="table_widget">
<el-form :inline="true" :model="searchForm" class="follow-form-item">
<el-form-item label="状态">
<el-select size="small" v-model="searchForm.delFlag" placeholder="请选择">
<el-option v-for="item in optionData" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="角色名称">
<el-input size="small" v-model="searchForm.roleName" clearable placeholder="请输入"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="toFindData">查询</el-button>
</el-form-item>
</el-form>
<div class="search_widget">
<div class="left_wrap">
<div v-if="accountLevel != 4" class="top_select">
<span class="select_label">商户名称</span>
<el-select :filter-method="filterList" size="small" clearable filterable v-model="searchForm.merchantId" placeholder="请选择">
<el-option v-for="item in list" :key="item.id" :label="item.merchantName" :value="item.id"></el-option>
</el-select>
</div>
<div class="top_select">
<span class="select_label">状态</span>
<el-select size="small" v-model="searchForm.delFlag" placeholder="请选择">
<el-option v-for="item in optionData" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
</div>
<div class="top_select">
<span class="select_label">角色名称</span>
<el-input style="width:76%" size="small" v-model="searchForm.roleName" clearable placeholder="请输入"></el-input>
</div>
</div>
<el-button type="primary" size="small" @click="toFindData">查询</el-button>
</div>
<GLTable ref="table" :layout="layout" :tableData="tableData" :tableTotal="tableTotal" :pageConf="pageConf" :tableParams="tableParams" @refreshTable="getTableData">
<template slot="auth-button" slot-scope="scope" :data="scope.scope">
<el-button type="text" @click="toLookPage(scope.scope)">查看</el-button>
......@@ -100,7 +101,7 @@ export default {
merchantList: [],
tableTotal: 0,
accountLevel: 1,
list:[]
list: []
}
},
created() {
......@@ -137,9 +138,12 @@ export default {
this.$apis.role.roleDataList(para).then(res => {
this.tableData = res.data
this.tableTotal = res.count
this.$nextTick(() => {
if (!res.data.length) {
this.$refs.table.setTableHeightFun()
})
}
// this.$nextTick(() => {
// this.$refs.table.setTableHeightFun()
// })
})
},
getMerchantName() {
......@@ -165,20 +169,41 @@ export default {
},
// 去创建角色页面
toCreatePage() {
this.$router.push({ path: '/role/create/index', query: { page: 'create' } })
this.$router.push("/role/create/"+0);
},
// 去查看角色页面
toLookPage(row) {
this.$router.push({ path: '/role/index/look', query: { row } })
this.$router.push("/role/look/"+row.id);
},
// 去修改角色页面
toEditPage(row) {
this.$router.push({ path: '/role/create/index', query: { page: 'edit', row } })
this.$router.push("/role/create/"+row.id);
},
// 去删除草稿
todelete(row){
console.log(row);
},
todelete(row) {
this.$confirm('此操作将永久删除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.$apis.role.deleteRole({ id: row.id }).then(res => {
if (res) {
this.getTableData()
this.$message({
type: 'success',
message: '删除成功!'
})
}
})
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
}
}
}
</script>
......@@ -191,27 +216,10 @@ export default {
}
.top_widget {
width: 100%;
height: 78px;
display: flex;
align-items: center;
justify-content: space-between;
background: #ffffff;
box-sizing: border-box;
padding: 0 20px;
.top_select {
display: flex;
align-items: center;
.select_label {
font-size: 14px;
font-weight: 400;
color: #333333;
margin-right: 10px;
}
}
}
.driver_line {
width: 100%;
height: 20px;
padding: 0 20px 20px 0;
}
.table_widget {
width: 100%;
......@@ -221,4 +229,25 @@ export default {
box-sizing: border-box;
padding: 20px;
}
.search_widget {
padding: 0 0 20px 0;
display: flex;
align-items: center;
justify-content: space-between;
.left_wrap {
display: flex;
align-items: center;
.top_select {
display: flex;
align-items: center;
margin-right: 30px;
.select_label {
font-size: 14px;
font-weight: 400;
color: #333333;
margin-right: 10px;
}
}
}
}
</style>
......@@ -34,7 +34,7 @@
<el-tree v-if="productList.length" :data="productList[curProductIndex].merchantProTreeResponses" :props="defaultProps"></el-tree>
<div v-if="productList.length == 0" class="no_data_icon">
<div class="nodata_wrap">
<img class="icon" src="../../../assets/img/empty.png" />
<img class="icon" src="../../assets/img/empty.png" />
<span class="text">暂无数据</span>
</div>
</div>
......@@ -68,8 +68,7 @@ export default {
}
},
created() {
let query = this.$route.query
let id = query.row.id
let id = this.$route.params.id;
this.getRoleData(id)
this.getMerchantTree(id)
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!