Commit 3e06ae54 by 杨北旺

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

1 parent e6add4c3
...@@ -24,20 +24,20 @@ const staticRoutes = Object.freeze([{ ...@@ -24,20 +24,20 @@ const staticRoutes = Object.freeze([{
}, },
{ {
name: 'role', name: 'role',
path: '/role/index/index', path: '/role/index',
component: resolve => require([`@/views/role/index/index.vue`], resolve), component: resolve => require([`@/views/role/index.vue`], resolve),
meta: {} meta: {}
}, },
{ {
name: 'role', name: 'role',
path: '/role/create/index', path: '/role/create/:id',
component: resolve => require([`@/views/role/create/index.vue`], resolve), component: resolve => require([`@/views/role/create.vue`], resolve),
meta: {} meta: {}
}, },
{ {
name: 'role', name: 'role',
path: '/role/index/look', path: '/role/look:id',
component: resolve => require([`@/views/role/index/look.vue`], resolve), component: resolve => require([`@/views/role/look.vue`], resolve),
meta: {} meta: {}
}, },
{ {
......
...@@ -17,7 +17,7 @@ import { routes } from '@/router' ...@@ -17,7 +17,7 @@ import { routes } from '@/router'
export async function start() { export async function start() {
if (window.__POWERED_BY_QIANKUN__) return if (window.__POWERED_BY_QIANKUN__) return
const { response, request, sign, secret } = await fetchConfig() 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.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'] }) Vue.use(GLButton, { permissions: ['1-1-1-1', '2-1-1-1', '3-1-1-1'] })
render('/', routes) render('/', routes)
} }
\ No newline at end of file \ No newline at end of file
...@@ -44,6 +44,9 @@ export default { ...@@ -44,6 +44,9 @@ export default {
}, },
accountlevel: { accountlevel: {
type: Number type: Number
},
roleType:{
type:Boolean
} }
}, },
...@@ -83,8 +86,9 @@ export default { ...@@ -83,8 +86,9 @@ export default {
let params = { let params = {
accountlevel: this.accountlevel, accountlevel: this.accountlevel,
parentId: this.parentId, parentId: this.parentId,
id: this.pid id: this.pId
} }
console.log(params);
this.$apis.store.findMenuFunTreeByMerId(params).then(res => { this.$apis.store.findMenuFunTreeByMerId(params).then(res => {
this.tabMenu = res.map(item => { this.tabMenu = res.map(item => {
console.log(item) console.log(item)
...@@ -237,6 +241,7 @@ export default { ...@@ -237,6 +241,7 @@ export default {
getSelectInfo() { getSelectInfo() {
this.accountTypes = this.tabMenu.map(item => { this.accountTypes = this.tabMenu.map(item => {
let products = [] let products = []
let productList = []
item.productsArr.forEach(itm => { item.productsArr.forEach(itm => {
const checkedNodes = this.$refs[`tree_${item.accounttypeId}_${itm.productId}`] ? this.$refs[`tree_${item.accounttypeId}_${itm.productId}`][0].getCheckedNodes() : [] const checkedNodes = this.$refs[`tree_${item.accounttypeId}_${itm.productId}`] ? this.$refs[`tree_${item.accounttypeId}_${itm.productId}`][0].getCheckedNodes() : []
console.log(checkedNodes) console.log(checkedNodes)
...@@ -261,17 +266,33 @@ export default { ...@@ -261,17 +266,33 @@ export default {
}) })
} }
console.log(menuIdList, functionIdList, functionValueIdLists, list) console.log(menuIdList, functionIdList, functionValueIdLists, list)
if(this.roleType){
productList.push({
productId: itm.productId,
functionIdList: functionIdList,
// functionValue: list,
menuIdList: menuIdList
})
}else{
products.push({ products.push({
productId: itm.productId, productId: itm.productId,
functionIds: functionIdList, functionIds: functionIdList,
functionValue: list, functionValue: list,
menuIds: menuIdList menuIds: menuIdList
}) })
}
}) })
if(this.roleType){
return {
accounttypeId: item.accounttypeId,
productList
}
}else{
return { return {
accounttypeId: item.accounttypeId, accounttypeId: item.accounttypeId,
products products
} }
}
}) })
return this.accountTypes return this.accountTypes
...@@ -279,7 +300,7 @@ export default { ...@@ -279,7 +300,7 @@ export default {
}, },
mounted() { mounted() {
// this.findMenuFunTreeByMerId() this.findMenuFunTreeByMerId()
// this.findPermissionsByMerId() // this.findPermissionsByMerId()
} }
} }
......
...@@ -29,44 +29,13 @@ ...@@ -29,44 +29,13 @@
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div class="new_wrap"> <SelectProduct ref="productFrom" :roleType="true" :parentId="41712" :accountlevel="2" :pId="41713"></SelectProduct>
<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>
</div> </div>
<div style="height: 84px"></div> <div style="height: 84px"></div>
<div class="fixed_bottom"> <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"> <div class="wrap_driver">
<el-button type="primary" @click="toCreateRole">确定</el-button> <el-button type="primary" @click="toCreateRole(0)">确定</el-button>
</div> </div>
<el-button type="primary" @click="toBack">取消</el-button> <el-button type="primary" @click="toBack">取消</el-button>
</div> </div>
...@@ -74,11 +43,13 @@ ...@@ -74,11 +43,13 @@
</template> </template>
<script> <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 { export default {
name: '', name: '',
components: { components: {
AutoButton AutoButton,
SelectProduct
}, },
data() { data() {
return { return {
...@@ -94,9 +65,6 @@ export default { ...@@ -94,9 +65,6 @@ export default {
}, },
rootList: [], rootList: [],
curRootIndex: 0, curRootIndex: 0,
productList: [],
storeList: [],
curMenuIndex: 0,
pageName: '新增角色', pageName: '新增角色',
roleInfo: null, roleInfo: null,
pageType: 'create', pageType: 'create',
...@@ -108,15 +76,16 @@ export default { ...@@ -108,15 +76,16 @@ export default {
} }
}, },
created() { created() {
let query = this.$route.query let id = Number(this.$route.params.id);
this.pageType = query.page if (!id) {
if (query.page == 'create') {
this.pageName = '新增角色' this.pageName = '新增角色'
this.pageType ='create'
this.getMerchantName() this.getMerchantName()
} else { } else {
this.pageName = '修改角色' this.pageName = '修改角色'
let role = query.row this.pageType ='edit'
this.getRoleData(role.id) this.getRoleData(id)
this.editId = id
} }
}, },
methods: { methods: {
...@@ -127,7 +96,8 @@ export default { ...@@ -127,7 +96,8 @@ export default {
this.ruleForm = { this.ruleForm = {
merchantName: res.merchantName, merchantName: res.merchantName,
roleName: res.roleName, roleName: res.roleName,
roleDesc: res.roleDescription roleDesc: res.roleDescription,
merchantId:res.merchantId
} }
this.getMerchantTree(id, res.responseList) this.getMerchantTree(id, res.responseList)
}) })
...@@ -170,8 +140,6 @@ export default { ...@@ -170,8 +140,6 @@ export default {
return item return item
}) })
}) })
this.rootList = []
this.productList = []
}, },
// 选择商户权限 // 选择商户权限
selectCurAccount(item, index) { selectCurAccount(item, index) {
...@@ -185,68 +153,55 @@ export default { ...@@ -185,68 +153,55 @@ export default {
}) })
this.rootList = arr this.rootList = arr
} }
this.productList = this.rootList[0].products || []
}, },
// 选择产品的值
selectProductItem(val) {
console.log(val) // 确定按钮---处理参数---提交数据---创建为0---草稿为1
this.curMenuIndex = 0 toCreateRole(delFlag) {
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() {
let { merchantId, roleDesc, roleName } = this.ruleForm 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 = { let para = {
merchantId: merchantId, merchantId: merchantId,
roleName: roleName, roleName: roleName,
roleDescription: roleDesc, roleDescription: roleDesc,
accounttypeId: 0, delFlag,
'check[29]': 44, requestList: accountTypes,
delFlag: 0, }
requestList: [] 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) { insertRole(para) {
this.$apis.role.roleInfoData(para).then(res => { this.$apis.role.createRole(para).then(res => {
if (res) { if (res) {
history.go(-1) this.toBack()
} }
}) })
}, },
updateRole(para) { updateRole(para) {
this.$apis.role.updateRole(para).then(res => { this.$apis.role.updateRole(para).then(res => {
if (res) { if (res) {
history.go(-1) this.toBack()
} }
}) })
}, },
toBack() { toBack() {
history.go(-1) this.$router.push("/role/index");
} }
} }
} }
...@@ -276,130 +231,6 @@ export default { ...@@ -276,130 +231,6 @@ export default {
padding: 32px 0; padding: 32px 0;
background: #ffffff; 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 { .fixed_bottom {
position: fixed; position: fixed;
left: 0; left: 0;
...@@ -423,44 +254,6 @@ export default { ...@@ -423,44 +254,6 @@ export default {
.wrap { .wrap {
margin-right: 15px; 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> </style>
...@@ -2,28 +2,29 @@ ...@@ -2,28 +2,29 @@
<div class="role-home-page"> <div class="role-home-page">
<div class="top_widget"> <div class="top_widget">
<el-button size="small" icon="el-icon-plus" type="primary" @click="toCreatePage">创建角色</el-button> <el-button size="small" icon="el-icon-plus" type="primary" @click="toCreatePage">创建角色</el-button>
</div>
<div class="table_widget">
<div class="search_widget">
<div class="left_wrap">
<div v-if="accountLevel != 4" class="top_select"> <div v-if="accountLevel != 4" class="top_select">
<span class="select_label">商户名称</span> <span class="select_label">商户名称</span>
<el-select :filter-method="filterList" size="small" clearable filterable v-model="searchForm.merchantId" placeholder="请选择"> <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-option v-for="item in list" :key="item.id" :label="item.merchantName" :value="item.id"></el-option>
</el-select> </el-select>
</div> </div>
</div> <div class="top_select">
<div class="driver_line"></div> <span class="select_label">状态</span>
<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-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-option v-for="item in optionData" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select> </el-select>
</el-form-item> </div>
<el-form-item label="角色名称"> <div class="top_select">
<el-input size="small" v-model="searchForm.roleName" clearable placeholder="请输入"></el-input> <span class="select_label">角色名称</span>
</el-form-item> <el-input style="width:76%" size="small" v-model="searchForm.roleName" clearable placeholder="请输入"></el-input>
<el-form-item> </div>
</div>
<el-button type="primary" size="small" @click="toFindData">查询</el-button> <el-button type="primary" size="small" @click="toFindData">查询</el-button>
</el-form-item> </div>
</el-form>
<GLTable ref="table" :layout="layout" :tableData="tableData" :tableTotal="tableTotal" :pageConf="pageConf" :tableParams="tableParams" @refreshTable="getTableData"> <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"> <template slot="auth-button" slot-scope="scope" :data="scope.scope">
<el-button type="text" @click="toLookPage(scope.scope)">查看</el-button> <el-button type="text" @click="toLookPage(scope.scope)">查看</el-button>
...@@ -100,7 +101,7 @@ export default { ...@@ -100,7 +101,7 @@ export default {
merchantList: [], merchantList: [],
tableTotal: 0, tableTotal: 0,
accountLevel: 1, accountLevel: 1,
list:[] list: []
} }
}, },
created() { created() {
...@@ -137,9 +138,12 @@ export default { ...@@ -137,9 +138,12 @@ export default {
this.$apis.role.roleDataList(para).then(res => { this.$apis.role.roleDataList(para).then(res => {
this.tableData = res.data this.tableData = res.data
this.tableTotal = res.count this.tableTotal = res.count
this.$nextTick(() => { if (!res.data.length) {
this.$refs.table.setTableHeightFun() this.$refs.table.setTableHeightFun()
}) }
// this.$nextTick(() => {
// this.$refs.table.setTableHeightFun()
// })
}) })
}, },
getMerchantName() { getMerchantName() {
...@@ -165,20 +169,41 @@ export default { ...@@ -165,20 +169,41 @@ export default {
}, },
// 去创建角色页面 // 去创建角色页面
toCreatePage() { toCreatePage() {
this.$router.push({ path: '/role/create/index', query: { page: 'create' } }) this.$router.push("/role/create/"+0);
}, },
// 去查看角色页面 // 去查看角色页面
toLookPage(row) { toLookPage(row) {
this.$router.push({ path: '/role/index/look', query: { row } }) this.$router.push("/role/look/"+row.id);
}, },
// 去修改角色页面 // 去修改角色页面
toEditPage(row) { toEditPage(row) {
this.$router.push({ path: '/role/create/index', query: { page: 'edit', row } }) this.$router.push("/role/create/"+row.id);
}, },
// 去删除草稿 // 去删除草稿
todelete(row){ todelete(row) {
console.log(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> </script>
...@@ -191,16 +216,31 @@ export default { ...@@ -191,16 +216,31 @@ export default {
} }
.top_widget { .top_widget {
width: 100%; width: 100%;
height: 78px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; box-sizing: border-box;
padding: 0 20px 20px 0;
}
.table_widget {
width: 100%;
// height: calc(100% - 138px);
background: #ffffff; background: #ffffff;
box-shadow: 0px 10px 20px 0px rgba(88, 80, 255, 0.1);
box-sizing: border-box; box-sizing: border-box;
padding: 0 20px; 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 { .top_select {
display: flex; display: flex;
align-items: center; align-items: center;
margin-right: 30px;
.select_label { .select_label {
font-size: 14px; font-size: 14px;
font-weight: 400; font-weight: 400;
...@@ -208,17 +248,6 @@ export default { ...@@ -208,17 +248,6 @@ export default {
margin-right: 10px; margin-right: 10px;
} }
} }
} }
.driver_line {
width: 100%;
height: 20px;
}
.table_widget {
width: 100%;
// height: calc(100% - 138px);
background: #ffffff;
box-shadow: 0px 10px 20px 0px rgba(88, 80, 255, 0.1);
box-sizing: border-box;
padding: 20px;
} }
</style> </style>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<el-tree v-if="productList.length" :data="productList[curProductIndex].merchantProTreeResponses" :props="defaultProps"></el-tree> <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 v-if="productList.length == 0" class="no_data_icon">
<div class="nodata_wrap"> <div class="nodata_wrap">
<img class="icon" src="../../../assets/img/empty.png" /> <img class="icon" src="../../assets/img/empty.png" />
<span class="text">暂无数据</span> <span class="text">暂无数据</span>
</div> </div>
</div> </div>
...@@ -68,8 +68,7 @@ export default { ...@@ -68,8 +68,7 @@ export default {
} }
}, },
created() { created() {
let query = this.$route.query let id = this.$route.params.id;
let id = query.row.id
this.getRoleData(id) this.getRoleData(id)
this.getMerchantTree(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!