123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <script>
- import menuList from "@/data/json/menuList.json"
- import ssoList from "@/data/json/ssoList.json"
- import Function from "@/components/dashboard/commonFuncManage/function.vue";
- export default {
- data() {
- return {
- menuList,
- ssoList,
- customFunction: [],
- functions: [],
- ssoSystems: [],
- show: false,
- }
- },
- props: {
- visible: Boolean,
- commonFunction: Array,
- },
- components: {
- Function
- },
- watch: {
- "show": function (val) {
- this.toggleVisible(val)
- },
- "visible": function (val) {
- this.show = val
- },
- },
- emits: ['update:visible', 'update:commonFunction'],
- setup(props, context) {
- const methods = {
- toggleVisible(flag) {
- context.emit('update:visible', flag)
- },
- updateFunctions(arr) {
- context.emit('update:commonFunction', arr)
- }
- }
- return methods
- },
- mounted() {
- this.show = this.visible;
- this.customFunction = JSON.parse(JSON.stringify(this.commonFunction));
- this.getFunctions();
- this.ssoSystems = this.ssoList
- },
- methods: {
- getFunctions() {
- let names = this.commonFunction.map(i=>{return i.name});
- this.functions = [];
- for (let i = 0; i < this.menuList.length; i++) {
- let menu = this.menuList[i];
- let childMenus = menu.children?menu.children:[];
- childMenus = childMenus.filter(i=>names.indexOf(i.name)<0);
- childMenus.forEach(item => {
- this.functions.push(item)
- })
- }
- },
- handleOk() {
- this.$store.menuStore().commonFunction = JSON.parse(JSON.stringify(this.customFunction));
- this.updateFunctions(this.$store.menuStore().commonFunction)
- this.show = false;
- },
- handleCancel() {
- this.show = false
- },
- plusFunction(item) {
- if (this.customFunction.length>=8) {
- this.$message.warning('功能位已满,请先移除功能后重试')
- return;
- }
- if (item.isSso) {
- let index = this.ssoSystems.findIndex(i=>i.name==item.name)
- if (index) {
- this.ssoSystems.splice(index, 1)
- }
- } else {
- let index = this.functions.findIndex(i=>i.name==item.name)
- if (index) {
- this.functions.splice(index, 1)
- }
- }
- this.customFunction.push(item)
- },
- minusFunction(item) {
- let index = this.customFunction.findIndex(i => i.name==item.name);
- if (index) {
- this.customFunction.splice(index, 1);
- if (item.isSso) {
- this.ssoSystems.push(item);
- } else {
- this.functions.push(item);
- }
- }
- },
- }
- }
- </script>
- <template>
- <a-modal class="dashboard-funcManage"
- :visible="show"
- :width="1020"
- @ok="handleOk"
- @cancel="handleCancel"
- >
- <template #footer>
- <a-button size="small" class="footer-btn" key="back" @click="handleCancel">
- 取消
- </a-button>
- <a-button size="small" class="footer-btn" key="submit" type="primary" @click="handleOk">
- 确定
- </a-button>
- </template>
- <div class="funcManage-custom">
- <div class="funcManage-title">自定义快捷入口</div>
- <div class="funcManage-body">
- <a-row :gutter="16">
- <transition-group name="common-function">
- <a-col :span="6" v-for="(item,index) in customFunction" :key="item.name" style="margin-bottom: 12px">
- <Function :minus-function="minusFunction" :item="item" :type="-1"></Function>
- </a-col>
- </transition-group>
- </a-row>
- </div>
- </div>
- <div style="max-height: 400px;overflow-y: auto">
- <div class="funcManage-function">
- <div class="funcManage-title funcManage-title-border">运营管理中心</div>
- <div class="funcManage-body">
- <a-row :gutter="16">
- <transition-group name="common-function">
- <a-col :span="6" v-for="(item,index) in functions" :key="item.name" style="margin-bottom: 12px">
- <Function :plus-function="plusFunction" :item="item" :type="1"></Function>
- </a-col>
- </transition-group>
- </a-row>
- </div>
- </div>
- <div class="funcManage-sso">
- <div class="funcManage-title funcManage-title-border">单点登录</div>
- <div class="funcManage-body">
- <a-row :gutter="16">
- <transition-group name="common-function">
- <a-col :span="6" v-for="(item, index) in ssoSystems" :key="item.name" style="margin-bottom: 12px">
- <Function :plus-function="plusFunction" :item="item" :type="1"></Function>
- </a-col>
- </transition-group>
- </a-row>
- </div>
- </div>
- </div>
- </a-modal>
- </template>
- <style lang="less">
- .dashboard-funcManage {
- .footer-btn {
- width: 80px;
- height: 30px;
- border-radius: 5px;
- font-size: 16px;
- }
- .ant-btn {
- margin: 0 10px !important;
- }
- .funcManage-body {
- margin: 10px;
- height: auto;
- min-height: 200px;
- border: 1px solid #E3E4E6;
- padding: 2% 3%;
- }
- .funcManage-custom {
- .funcManage-body {
- }
- }
- .funcManage-function {
- margin-top: 15px;
- margin-bottom: 8px;
- .funcManage-body {
- }
- }
- .funcManage-sso {
- margin-top: 15px;
- margin-bottom: 8px;
- .funcManage-body {
- }
- }
- .funcManage-title {
- font-weight: bold;
- font-size: 16px;
- }
- .funcManage-title-border {
- padding-left: 5px;
- border-left: 3px solid #2EA8E6;
- }
- }
- </style>
|