| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- <html>
- <head>
- <style type="text/css">
- .space-scroll-content {
- box-sizing: border-box;
- height: calc(100% - 60px);
- overflow: auto;
- }
- .space-impower .el-row,
- .space-impower .el-col {
- height: 100%;
- }
- .space-impower .impower-menu {
- height: 100%;
- border-color: #dcdfe6;
- width: 130px;
- float: left;
- }
- .menu-collapse-left {
- position: absolute;
- top: 17px;
- right: -9px;
- z-index: 1000;
- opacity: 0;
- font-size: 24px;
- }
- .impower-menu .is-active .menu-collapse-left {
- opacity: 1;
- color: #dcdfe6 !important;
- }
- .impower-menu .is-active .menu-collapse-top {
- font-size: 22px;
- color: #fff !important;
- top: 18px;
- }
- /* 树 */
- .impower-tree {
- margin-left: 160px;
- padding-right: 22px;
- height: 100%;
- overflow-y: auto;
- position: relative;
- }
- .expandeBtn {
- position: fixed;
- right: 20px;
- top: 10px;
- }
- .expand-all {
- margin: 12px 0;
- position: absolute;
- top: 0px;
- right: 22px;
- z-index: 1000;
- }
- .moudule-title {
- margin-left: 6px;
- }
- /* 穿梭框 */
- .impower-transfer{
- text-align: center;
- height: 100%;
- }
-
- .el-transfer{
- height: calc(100% - 15px);
- padding-top: 15px;
- }
-
- .el-transfer-panel{
- height: 100%;
- }
-
- .el-transfer-panel__body{
- height: calc(100% - 40px - 36px - 36px);
- }
-
- .el-transfer-panel__list.is-filterable{
- height: 100%;
- }
- </style>
- </head>
- <body>
- <div id="space-content">
- <div class="space-scroll-content space-impower">
- <el-row>
- <el-col :span="10">
- <el-menu class="impower-menu" @select="handleSelect" :collapse="true">
- <el-menu-item v-for="(item, index) in moduleData" :index="item.dm">
- <i :class="item.tb"></i><i class="moudule-title">{{item.mc}}</i>
- <i class="menu-collapse-left el-icon-caret-left"></i>
- <i class="menu-collapse-left menu-collapse-top el-icon-caret-left"></i>
- </el-menu-item>
- </el-menu>
- <!-- 结构树 -->
- <div class="impower-tree niceScroll">
- <div v-if="!treeHide" class="no-choose">
- <p>选择左侧模块后进行授权</p>
- </div>
- <el-button class="expand-all" v-if="!expandedAll && treeHide" plain size="mini"
- @click="defaultexpandedAll">展开</el-button>
- <el-button class="expand-all" v-if="expandedAll && treeHide" plain size="mini"
- @click="defaultexpandedAll">收起</el-button>
- <el-tree v-if="treeHide" class="filter-tree" node-key="id" ref="tree" :data="treeData"
- :props="defaultProps" show-checkbox>
- </el-tree>
-
- </div>
- </el-col>
- <el-col :span="14">
- <div class="impower-transfer">
- <el-transfer style="text-align: left; display: inline-block" v-model="chooseDepartmentData" filterable
- :titles="['已选', '部门']" :button-texts="['到左边', '到右边']" :props="{ key: 'departmentid', label: 'name' }"
- :format="{ noChecked: '${total}', hasChecked: '${checked}/${total}' }" :data="departmentData" @change="transferChange">
- <span slot-scope="{ option }">{{ option.name }}</span>
- </el-transfer>
- </div>
- </el-col>
- </el-row>
- </div>
- <div class="space-form-btn">
- <el-button type="primary" icon="el-icon-circle-check" @click="savePermission">保存</el-button>
- <el-button icon="el-icon-circle-close" onclick="space.allFunction.closeDialog();">关闭</el-button>
- </div>
- </div>
- </body>
- <script type="text/javascript">
- space.vue = new Vue({
- el: space.appContent,
- data: function () {
- return {
- moduleData: [],
- treeHide: false,
- expandedAll: false,
- thisModule: '',
- treeData: [],
- defaultProps: {
- children: 'children',
- label: 'label'
- },
- departmentData: [],
- chooseDepartmentData: [],
- chooseDepartmentStr: ''
- }
- },
- methods: {
- handleSelect(key, val) {
- this.thisModule = key;
- this.treeHide = true;
- this.expandedAll = false;
- var _this = this;
- space.utils.ajax({
- url: '@service{ name:`getDepartmenMoudulePermission` }@',
- data: { "moduleCode": key },
- dataType: 'json',
- callback: function (data) {
- _this.treeData = data.data;
- }
- });
- },
- defaultexpandedAll() {
- if (this.expandedAll) {
- this.expandedAll = false;
- for (var i = 0; i < this.$refs.tree.store._getAllNodes().length; i++) {
- this.$refs.tree.store._getAllNodes()[i].expanded = false;
- }
- } else {
- this.expandedAll = true;
- for (var i = 0; i < this.$refs.tree.store._getAllNodes().length; i++) {
- this.$refs.tree.store._getAllNodes()[i].expanded = true;
- }
- }
- },
- savePermission() {
- if (space.utils.isNull(this.thisModule)) {
- space.message.warning("请选择模块后再进行操作");
- return;
- }
- var selectNodeAry = this.$refs.tree.getCheckedKeys();
- var selectNodeStr = selectNodeAry.join('^');
- // 叶子节点
- var selectLeafDataAry = this.$refs.tree.getCheckedKeys(true);
- var selectLeafDataStr = selectLeafDataAry.join('^');
- if(selectNodeAry.length == 0) {
- space.message.warning("至少需要勾选一个权限");
- return;
- }
- if (space.utils.isNull(this.chooseDepartmentStr)) {
- space.message.warning("至少需要选择一个部门");
- return;
- }
- space.utils.ajax({
- url: '@service{ name:`authorization_department_batch_save` }@',
- data: {
- "data": selectNodeStr,
- "leafData": selectLeafDataStr,
- "moduleCode": this.thisModule,
- "departmentidList": this.chooseDepartmentStr
- },
- dataType: 'json',
- callback: function (data) {
- space.layMsg.auto(data);
- }
- });
- },
- //参数为: 当前值、数据移动的方向('left' / 'right')、发生移动的数据 key 数组
- transferChange(value, direction, movedKeys) {
- // 保存已选择ID
- var checkArry = [];
- for (var i =0;i < this.departmentData.length;i++) {
- if (this.chooseDepartmentData.indexOf(this.departmentData[i].departmentid) < 0) {
- checkArry.push(this.departmentData[i].departmentid);
- }
- }
- this.chooseDepartmentStr = checkArry.join("^");
- }
- },
- created: function () {
- var _this = this;
- space.utils.ajax({
- url: '@service{ name:`sys.getModuleList_api` }@',
- dataType: 'json',
- callback: function (data) {
- _this.moduleData = data.data;
- }
- });
- space.utils.ajax({
- url: '@service{ name:`sys.authorization_department_list_API` }@',
- dataType: 'json',
- callback: function (data) {
- _this.departmentData = data.data;
-
- _this.departmentData.forEach(function(item){
- _this.chooseDepartmentData.push(item.departmentid);
- });
- }
- });
- }
- })
- </script>
- </html>
|