1000910037_edit.jsp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <html>
  2. <head>
  3. <style type="text/css">
  4. .space-scroll-content {
  5. box-sizing: border-box;
  6. height: calc(100% - 60px);
  7. overflow: auto;
  8. }
  9. .space-impower .el-row,
  10. .space-impower .el-col {
  11. height: 100%;
  12. }
  13. .space-impower .impower-menu {
  14. height: 100%;
  15. border-color: #dcdfe6;
  16. width: 130px;
  17. float: left;
  18. }
  19. .menu-collapse-left {
  20. position: absolute;
  21. top: 17px;
  22. right: -9px;
  23. z-index: 1000;
  24. opacity: 0;
  25. font-size: 24px;
  26. }
  27. .impower-menu .is-active .menu-collapse-left {
  28. opacity: 1;
  29. color: #dcdfe6 !important;
  30. }
  31. .impower-menu .is-active .menu-collapse-top {
  32. font-size: 22px;
  33. color: #fff !important;
  34. top: 18px;
  35. }
  36. /* 树 */
  37. .impower-tree {
  38. margin-left: 160px;
  39. padding-right: 22px;
  40. height: 100%;
  41. overflow-y: auto;
  42. position: relative;
  43. }
  44. .expandeBtn {
  45. position: fixed;
  46. right: 20px;
  47. top: 10px;
  48. }
  49. .expand-all {
  50. margin: 12px 0;
  51. position: absolute;
  52. top: 0px;
  53. right: 22px;
  54. z-index: 1000;
  55. }
  56. .moudule-title {
  57. margin-left: 6px;
  58. }
  59. /* 穿梭框 */
  60. .impower-transfer{
  61. text-align: center;
  62. height: 100%;
  63. }
  64. .el-transfer{
  65. height: calc(100% - 15px);
  66. padding-top: 15px;
  67. }
  68. .el-transfer-panel{
  69. height: 100%;
  70. }
  71. .el-transfer-panel__body{
  72. height: calc(100% - 40px - 36px - 36px);
  73. }
  74. .el-transfer-panel__list.is-filterable{
  75. height: 100%;
  76. }
  77. </style>
  78. </head>
  79. <body>
  80. <div id="space-content">
  81. <div class="space-scroll-content space-impower">
  82. <el-row>
  83. <el-col :span="10">
  84. <el-menu class="impower-menu" @select="handleSelect" :collapse="true">
  85. <el-menu-item v-for="(item, index) in moduleData" :index="item.dm">
  86. <i :class="item.tb"></i><i class="moudule-title">{{item.mc}}</i>
  87. <i class="menu-collapse-left el-icon-caret-left"></i>
  88. <i class="menu-collapse-left menu-collapse-top el-icon-caret-left"></i>
  89. </el-menu-item>
  90. </el-menu>
  91. <!-- 结构树 -->
  92. <div class="impower-tree niceScroll">
  93. <div v-if="!treeHide" class="no-choose">
  94. <p>选择左侧模块后进行授权</p>
  95. </div>
  96. <el-button class="expand-all" v-if="!expandedAll && treeHide" plain size="mini"
  97. @click="defaultexpandedAll">展开</el-button>
  98. <el-button class="expand-all" v-if="expandedAll && treeHide" plain size="mini"
  99. @click="defaultexpandedAll">收起</el-button>
  100. <el-tree v-if="treeHide" class="filter-tree" node-key="id" ref="tree" :data="treeData"
  101. :props="defaultProps" show-checkbox>
  102. </el-tree>
  103. </div>
  104. </el-col>
  105. <el-col :span="14">
  106. <div class="impower-transfer">
  107. <el-transfer style="text-align: left; display: inline-block" v-model="chooseDepartmentData" filterable
  108. :titles="['已选', '部门']" :button-texts="['到左边', '到右边']" :props="{ key: 'departmentid', label: 'name' }"
  109. :format="{ noChecked: '${total}', hasChecked: '${checked}/${total}' }" :data="departmentData" @change="transferChange">
  110. <span slot-scope="{ option }">{{ option.name }}</span>
  111. </el-transfer>
  112. </div>
  113. </el-col>
  114. </el-row>
  115. </div>
  116. <div class="space-form-btn">
  117. <el-button type="primary" icon="el-icon-circle-check" @click="savePermission">保存</el-button>
  118. <el-button icon="el-icon-circle-close" onclick="space.allFunction.closeDialog();">关闭</el-button>
  119. </div>
  120. </div>
  121. </body>
  122. <script type="text/javascript">
  123. space.vue = new Vue({
  124. el: space.appContent,
  125. data: function () {
  126. return {
  127. moduleData: [],
  128. treeHide: false,
  129. expandedAll: false,
  130. thisModule: '',
  131. treeData: [],
  132. defaultProps: {
  133. children: 'children',
  134. label: 'label'
  135. },
  136. departmentData: [],
  137. chooseDepartmentData: [],
  138. chooseDepartmentStr: ''
  139. }
  140. },
  141. methods: {
  142. handleSelect(key, val) {
  143. this.thisModule = key;
  144. this.treeHide = true;
  145. this.expandedAll = false;
  146. var _this = this;
  147. space.utils.ajax({
  148. url: '@service{ name:`getDepartmenMoudulePermission` }@',
  149. data: { "moduleCode": key },
  150. dataType: 'json',
  151. callback: function (data) {
  152. _this.treeData = data.data;
  153. }
  154. });
  155. },
  156. defaultexpandedAll() {
  157. if (this.expandedAll) {
  158. this.expandedAll = false;
  159. for (var i = 0; i < this.$refs.tree.store._getAllNodes().length; i++) {
  160. this.$refs.tree.store._getAllNodes()[i].expanded = false;
  161. }
  162. } else {
  163. this.expandedAll = true;
  164. for (var i = 0; i < this.$refs.tree.store._getAllNodes().length; i++) {
  165. this.$refs.tree.store._getAllNodes()[i].expanded = true;
  166. }
  167. }
  168. },
  169. savePermission() {
  170. if (space.utils.isNull(this.thisModule)) {
  171. space.message.warning("请选择模块后再进行操作");
  172. return;
  173. }
  174. var selectNodeAry = this.$refs.tree.getCheckedKeys();
  175. var selectNodeStr = selectNodeAry.join('^');
  176. // 叶子节点
  177. var selectLeafDataAry = this.$refs.tree.getCheckedKeys(true);
  178. var selectLeafDataStr = selectLeafDataAry.join('^');
  179. if(selectNodeAry.length == 0) {
  180. space.message.warning("至少需要勾选一个权限");
  181. return;
  182. }
  183. if (space.utils.isNull(this.chooseDepartmentStr)) {
  184. space.message.warning("至少需要选择一个部门");
  185. return;
  186. }
  187. space.utils.ajax({
  188. url: '@service{ name:`authorization_department_batch_save` }@',
  189. data: {
  190. "data": selectNodeStr,
  191. "leafData": selectLeafDataStr,
  192. "moduleCode": this.thisModule,
  193. "departmentidList": this.chooseDepartmentStr
  194. },
  195. dataType: 'json',
  196. callback: function (data) {
  197. space.layMsg.auto(data);
  198. }
  199. });
  200. },
  201. //参数为: 当前值、数据移动的方向('left' / 'right')、发生移动的数据 key 数组
  202. transferChange(value, direction, movedKeys) {
  203. // 保存已选择ID
  204. var checkArry = [];
  205. for (var i =0;i < this.departmentData.length;i++) {
  206. if (this.chooseDepartmentData.indexOf(this.departmentData[i].departmentid) < 0) {
  207. checkArry.push(this.departmentData[i].departmentid);
  208. }
  209. }
  210. this.chooseDepartmentStr = checkArry.join("^");
  211. }
  212. },
  213. created: function () {
  214. var _this = this;
  215. space.utils.ajax({
  216. url: '@service{ name:`sys.getModuleList_api` }@',
  217. dataType: 'json',
  218. callback: function (data) {
  219. _this.moduleData = data.data;
  220. }
  221. });
  222. space.utils.ajax({
  223. url: '@service{ name:`sys.authorization_department_list_API` }@',
  224. dataType: 'json',
  225. callback: function (data) {
  226. _this.departmentData = data.data;
  227. _this.departmentData.forEach(function(item){
  228. _this.chooseDepartmentData.push(item.departmentid);
  229. });
  230. }
  231. });
  232. }
  233. })
  234. </script>
  235. </html>