functionManage.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <script>
  2. import menuList from "@/data/json/menuList.json"
  3. import ssoList from "@/data/json/ssoList.json"
  4. import Function from "@/components/dashboard/commonFuncManage/function.vue";
  5. export default {
  6. data() {
  7. return {
  8. menuList,
  9. ssoList,
  10. customFunction: [],
  11. functions: [],
  12. ssoSystems: [],
  13. show: false,
  14. }
  15. },
  16. props: {
  17. visible: Boolean,
  18. commonFunction: Array,
  19. },
  20. components: {
  21. Function
  22. },
  23. watch: {
  24. "show": function (val) {
  25. this.toggleVisible(val)
  26. },
  27. "visible": function (val) {
  28. this.show = val
  29. },
  30. },
  31. emits: ['update:visible', 'update:commonFunction'],
  32. setup(props, context) {
  33. const methods = {
  34. toggleVisible(flag) {
  35. context.emit('update:visible', flag)
  36. },
  37. updateFunctions(arr) {
  38. context.emit('update:commonFunction', arr)
  39. }
  40. }
  41. return methods
  42. },
  43. mounted() {
  44. this.show = this.visible;
  45. this.customFunction = JSON.parse(JSON.stringify(this.commonFunction));
  46. this.getFunctions();
  47. this.ssoSystems = this.ssoList
  48. },
  49. methods: {
  50. getFunctions() {
  51. let names = this.commonFunction.map(i=>{return i.name});
  52. this.functions = [];
  53. for (let i = 0; i < this.menuList.length; i++) {
  54. let menu = this.menuList[i];
  55. let childMenus = menu.children?menu.children:[];
  56. childMenus = childMenus.filter(i=>names.indexOf(i.name)<0);
  57. childMenus.forEach(item => {
  58. this.functions.push(item)
  59. })
  60. }
  61. },
  62. handleOk() {
  63. this.$store.menuStore().commonFunction = JSON.parse(JSON.stringify(this.customFunction));
  64. this.updateFunctions(this.$store.menuStore().commonFunction)
  65. this.show = false;
  66. },
  67. handleCancel() {
  68. this.show = false
  69. },
  70. plusFunction(item) {
  71. if (this.customFunction.length>=8) {
  72. this.$message.warning('功能位已满,请先移除功能后重试')
  73. return;
  74. }
  75. if (item.isSso) {
  76. let index = this.ssoSystems.findIndex(i=>i.name==item.name)
  77. if (index) {
  78. this.ssoSystems.splice(index, 1)
  79. }
  80. } else {
  81. let index = this.functions.findIndex(i=>i.name==item.name)
  82. if (index) {
  83. this.functions.splice(index, 1)
  84. }
  85. }
  86. this.customFunction.push(item)
  87. },
  88. minusFunction(item) {
  89. let index = this.customFunction.findIndex(i => i.name==item.name);
  90. if (index) {
  91. this.customFunction.splice(index, 1);
  92. if (item.isSso) {
  93. this.ssoSystems.push(item);
  94. } else {
  95. this.functions.push(item);
  96. }
  97. }
  98. },
  99. }
  100. }
  101. </script>
  102. <template>
  103. <a-modal class="dashboard-funcManage"
  104. :visible="show"
  105. :width="1020"
  106. @ok="handleOk"
  107. @cancel="handleCancel"
  108. >
  109. <template #footer>
  110. <a-button size="small" class="footer-btn" key="back" @click="handleCancel">
  111. 取消
  112. </a-button>
  113. <a-button size="small" class="footer-btn" key="submit" type="primary" @click="handleOk">
  114. 确定
  115. </a-button>
  116. </template>
  117. <div class="funcManage-custom">
  118. <div class="funcManage-title">自定义快捷入口</div>
  119. <div class="funcManage-body">
  120. <a-row :gutter="16">
  121. <transition-group name="common-function">
  122. <a-col :span="6" v-for="(item,index) in customFunction" :key="item.name" style="margin-bottom: 12px">
  123. <Function :minus-function="minusFunction" :item="item" :type="-1"></Function>
  124. </a-col>
  125. </transition-group>
  126. </a-row>
  127. </div>
  128. </div>
  129. <div style="max-height: 400px;overflow-y: auto">
  130. <div class="funcManage-function">
  131. <div class="funcManage-title funcManage-title-border">运营管理中心</div>
  132. <div class="funcManage-body">
  133. <a-row :gutter="16">
  134. <transition-group name="common-function">
  135. <a-col :span="6" v-for="(item,index) in functions" :key="item.name" style="margin-bottom: 12px">
  136. <Function :plus-function="plusFunction" :item="item" :type="1"></Function>
  137. </a-col>
  138. </transition-group>
  139. </a-row>
  140. </div>
  141. </div>
  142. <div class="funcManage-sso">
  143. <div class="funcManage-title funcManage-title-border">单点登录</div>
  144. <div class="funcManage-body">
  145. <a-row :gutter="16">
  146. <transition-group name="common-function">
  147. <a-col :span="6" v-for="(item, index) in ssoSystems" :key="item.name" style="margin-bottom: 12px">
  148. <Function :plus-function="plusFunction" :item="item" :type="1"></Function>
  149. </a-col>
  150. </transition-group>
  151. </a-row>
  152. </div>
  153. </div>
  154. </div>
  155. </a-modal>
  156. </template>
  157. <style lang="less">
  158. .dashboard-funcManage {
  159. .footer-btn {
  160. width: 80px;
  161. height: 30px;
  162. border-radius: 5px;
  163. font-size: 16px;
  164. }
  165. .ant-btn {
  166. margin: 0 10px !important;
  167. }
  168. .funcManage-body {
  169. margin: 10px;
  170. height: auto;
  171. min-height: 200px;
  172. border: 1px solid #E3E4E6;
  173. padding: 2% 3%;
  174. }
  175. .funcManage-custom {
  176. .funcManage-body {
  177. }
  178. }
  179. .funcManage-function {
  180. margin-top: 15px;
  181. margin-bottom: 8px;
  182. .funcManage-body {
  183. }
  184. }
  185. .funcManage-sso {
  186. margin-top: 15px;
  187. margin-bottom: 8px;
  188. .funcManage-body {
  189. }
  190. }
  191. .funcManage-title {
  192. font-weight: bold;
  193. font-size: 16px;
  194. }
  195. .funcManage-title-border {
  196. padding-left: 5px;
  197. border-left: 3px solid #2EA8E6;
  198. }
  199. }
  200. </style>