|
|
@@ -4,56 +4,20 @@
|
|
|
<save slot="btn" @click.native="save()"></save>
|
|
|
</handle-top>
|
|
|
<role-info-handle ref="info"></role-info-handle>
|
|
|
- <el-row class="power1">
|
|
|
- <el-col :span="24" class="title-box">
|
|
|
- <p class="title">角色授权</p>
|
|
|
- </el-col>
|
|
|
- <el-col :span="10">
|
|
|
- <role-power-left :roleData="power" @currentItemChange="currentItemChange">
|
|
|
- <search @searchActive="searchActive()" @clearData="clearData()" slot="search"></search>
|
|
|
- <!-- <pagination :total="6"
|
|
|
- slot="page"
|
|
|
- :pageSize="3"
|
|
|
- :currentPage="1"
|
|
|
- @pageChange="pageChange">
|
|
|
- </pagination> -->
|
|
|
- </role-power-left>
|
|
|
- </el-col>
|
|
|
- <el-col :span="14">
|
|
|
- <role-power-right :roleData="currentItem" @powerChange="powerChange"></role-power-right>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
+ <role-power-select ref="power"></role-power-select>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import HandleTop from '@/components/handle-top/HandleTop'
|
|
|
import roleInfoHandle from '@/SManagement/user/role-edit/components/roleInfoHandle'
|
|
|
-import RolePowerLeft from '@/SManagement/user/role-edit/components/RolePowerLeft'
|
|
|
-import RolePowerRight from '@/SManagement/user/role-edit/components/RolePowerRight'
|
|
|
-import search from '@/components/search/index'
|
|
|
-import Pagination from '@/components/pagination/Pagination'
|
|
|
-
|
|
|
+import RolePowerSelect from '@/SManagement/user/role-edit/components/RolePowerSelect'
|
|
|
import save from '@/SManagement/archives_upload/components/save'
|
|
|
-import { log } from '@antv/g2plot/lib/utils'
|
|
|
export default {
|
|
|
name: 'roleEdit',
|
|
|
data () {
|
|
|
return {
|
|
|
- auth:{
|
|
|
- "classname": "sale.role.role",
|
|
|
- "method": "add_appauth",
|
|
|
- "content": {
|
|
|
- "roleid": '',
|
|
|
- "systemapps": [
|
|
|
- {
|
|
|
- "systemappid": '',
|
|
|
- "optionids": []
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- },
|
|
|
- //角色新增
|
|
|
+ //角色新建
|
|
|
add: {
|
|
|
"classname": "sale.role.role",
|
|
|
"method": "insertormodify_role",
|
|
|
@@ -63,95 +27,90 @@ export default {
|
|
|
"remarks":""
|
|
|
}
|
|
|
},
|
|
|
- pullPower: {
|
|
|
- "classname": "sale.role.role",
|
|
|
- "method": "query_appselect",
|
|
|
- "content": {
|
|
|
- "roleid": this.roleid,
|
|
|
- }
|
|
|
- },
|
|
|
- roleid: this.$route.params.data ? this.$route.params.data.roleid : this.$route.query.id,
|
|
|
- //拉取的权限列表
|
|
|
- power: [],
|
|
|
- //编辑逻辑时数据储存
|
|
|
- editData:'',
|
|
|
- //选中的模块数据
|
|
|
- currentItem:0,
|
|
|
- currentApp:[],
|
|
|
- //授权数据
|
|
|
- systemapps:[]
|
|
|
+ roleid: parseInt(window.sessionStorage.getItem('currentEditRole')) == 0 ? 0 : JSON.parse(window.sessionStorage.getItem('currentEditRole')).roleid,
|
|
|
+ editData: parseInt(window.sessionStorage.getItem('currentEditRole')) == 0 ? 0 : JSON.parse(window.sessionStorage.getItem('currentEditRole')),
|
|
|
+ allPower:[]
|
|
|
};
|
|
|
},
|
|
|
- components: { HandleTop, save, roleInfoHandle, search, RolePowerLeft, RolePowerRight ,Pagination},
|
|
|
+ components: {roleInfoHandle,HandleTop,save,RolePowerSelect},
|
|
|
computed: {
|
|
|
},
|
|
|
watch: {
|
|
|
},
|
|
|
created () {
|
|
|
- this.roleEdit()
|
|
|
- this.getRoleAdd()
|
|
|
+ this.init()
|
|
|
},
|
|
|
methods: {
|
|
|
- //编辑角色
|
|
|
- roleEdit() {
|
|
|
- this.editData = this.$route.params.data
|
|
|
- if(this.$route.params.data) {
|
|
|
- this.add.content.roleid = this.$route.params.data.roleid
|
|
|
- this.add.content.rolename = this.$route.params.data.rolename
|
|
|
- this.add.content.remarks = this.$route.params.data.remarks
|
|
|
+ //初始化
|
|
|
+ init() {
|
|
|
+ if(this.editData) {
|
|
|
this.$nextTick(() => {
|
|
|
- this.$refs.info.ruleForm.name = this.$route.params.data.rolename
|
|
|
- this.$refs.info.ruleForm.descript = this.$route.params.data.remarks
|
|
|
+ this.$refs.info.ruleForm.name = this.editData.rolename
|
|
|
+ this.$refs.info.ruleForm.descript = this.editData.remarks
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- //获取功能列表
|
|
|
- getRoleAdd () {
|
|
|
- if(this.editData) this.pullPower.content.roleid = this.editData.roleid
|
|
|
- this.$api.requested(this.pullPower).then(res => {
|
|
|
- this.power = res.data
|
|
|
- this.currentItem = res.data[0]
|
|
|
- console.log(res);
|
|
|
+ //计算选中的所有权限
|
|
|
+ getAllPower() {
|
|
|
+ this.$refs.power.tempPowerList.forEach(item => {
|
|
|
+ if(item.optionids.length < 1) return
|
|
|
+ let result = this.allPower.find(item2 => item2.systemappid == item.systemappid)
|
|
|
+ if(result == undefined) {
|
|
|
+ let obj = {}
|
|
|
+ obj.systemappid = item.systemappid
|
|
|
+ obj.optionids = item.optionids
|
|
|
+ this.allPower.push(obj)
|
|
|
+ } else {
|
|
|
+ result.optionids = result.optionids
|
|
|
+ }
|
|
|
})
|
|
|
+ console.log(this.allPower);
|
|
|
+
|
|
|
},
|
|
|
- currentItemChange(data) {
|
|
|
- this.currentItem = data
|
|
|
- console.log(data);
|
|
|
- },
|
|
|
- save () {
|
|
|
- this.$refs.info.$refs.ruleForm.validate((val) => {
|
|
|
+ save() {
|
|
|
+ this.add.content.rolename = this.$refs.info.ruleForm.name
|
|
|
+ this.add.content.remarks = this.$refs.info.ruleForm.descript
|
|
|
+ this.getAllPower()
|
|
|
+ this.$refs.info.$refs.ruleForm.validate(val => {
|
|
|
if(val) {
|
|
|
- if(this.$route.params.data) {
|
|
|
- this.auth.content.roleid = this.roleid
|
|
|
- this.auth.content.systemapps = this.systemapps
|
|
|
- this.$api.requested(this.auth).then( res => {
|
|
|
- console.log(res);
|
|
|
-
|
|
|
+ if(this.editData != 0) {
|
|
|
+ console.log(11111111);
|
|
|
+
|
|
|
+ this.$api.requested({
|
|
|
+ "classname": "sale.role.role",
|
|
|
+ "method": "add_appauth",
|
|
|
+ "content": {
|
|
|
+ "roleid": this.roleid,
|
|
|
+ "systemapps": this.allPower
|
|
|
+ }
|
|
|
+ }).then( res => {
|
|
|
if(res.code == 1) {
|
|
|
this.$notify({
|
|
|
title:'提示',
|
|
|
- message:'修改成功',
|
|
|
+ message:'编辑成功',
|
|
|
type:'success'
|
|
|
})
|
|
|
this.$router.back()
|
|
|
} else {
|
|
|
this.$notify({
|
|
|
title:'提示',
|
|
|
- message:'修改失败',
|
|
|
+ message:'编辑失败',
|
|
|
type:'warning'
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
- this.add.content.rolename = this.$refs.info.ruleForm.name
|
|
|
- this.add.content.remarks = this.$refs.info.ruleForm.descript
|
|
|
+ console.log(22222222222221);
|
|
|
this.$api.requested(this.add).then( res => {
|
|
|
if(res.code == 1) {
|
|
|
- this.auth.content.roleid = res.data.roleid
|
|
|
- this.auth.content.systemapps = this.systemapps
|
|
|
- console.log(this.auth);
|
|
|
-
|
|
|
- this.$api.requested(this.auth).then( res => {
|
|
|
+ this.$api.requested({
|
|
|
+ "classname": "sale.role.role",
|
|
|
+ "method": "add_appauth",
|
|
|
+ "content": {
|
|
|
+ "roleid": res.data.roleid,
|
|
|
+ "systemapps": this.allPower
|
|
|
+ }
|
|
|
+ }).then( res => {
|
|
|
if(res.code == 1) {
|
|
|
this.$notify({
|
|
|
title:'提示',
|
|
|
@@ -170,43 +129,8 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
})
|
|
|
- },
|
|
|
- //获取所有需要授权数据
|
|
|
- getAllPower() {
|
|
|
- let is
|
|
|
- this.currentApp.apps.forEach(item => {
|
|
|
- is = this.systemapps.find(item2 => item2.systemappid == item.systemappid)
|
|
|
- if(is == undefined) {
|
|
|
- let obj = {}
|
|
|
- obj.systemappid = item.systemappid
|
|
|
- obj.optionids = item.optionids
|
|
|
- this.systemapps.push(obj)
|
|
|
- } else {
|
|
|
- is.systemappid = item.systemappid
|
|
|
- is.optionids = item.optionids
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- },
|
|
|
- searchActive (data) {
|
|
|
-
|
|
|
- },
|
|
|
- clearData () {
|
|
|
-
|
|
|
- },
|
|
|
- pageChange() {
|
|
|
-
|
|
|
- },
|
|
|
- powerChange(data) {
|
|
|
- this.currentItem.clients[0].modules.forEach(item => {
|
|
|
- if(item.systemmoduleid == data.systemmoduleid) {
|
|
|
- item = data
|
|
|
- }
|
|
|
- })
|
|
|
- this.currentApp = data
|
|
|
- this.getAllPower()
|
|
|
}
|
|
|
},
|
|
|
};
|