wfindex-view-appmenu-base.vue 25.7 KB
Newer Older
ibizdev's avatar
ibizdev committed
1 2 3 4 5 6 7 8 9 10
<template>
<div class="app-app-menu">
    <el-menu
      class="app-menu"
      :default-openeds="defaultOpeneds"
      :mode="mode"
      :menu-trigger="trigger"
      :collapse="isCollapse"
      @select="select"
      :default-active="defaultActive">
11 12
      
      <template v-if="Object.is(mode,'horizontal')">
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
            <template v-for="item0 in menus">
                <template v-if="item0.items && Array.isArray(item0.items) && item0.items.length > 0">
                    <el-submenu v-show="!item0.hidden" :index="item0.name" :popper-class="popperClass" :key="item0.id" :class="item0.textcls">
                        <template slot='title'>
                            <template v-if="item0.icon && item0.icon != ''">
                                <img :src="item0.icon" class='app-menu-icon' />
                            </template>
                            <template v-else-if="item0.iconcls && item0.iconcls != ''">
                                <i :class="[item0.iconcls, 'app-menu-icon']"></i>
                            </template>
                            <template v-else>
                                <i class='fa fa-cogs app-menu-icon'></i>
                            </template>
                            <span class='text' :title="$t('app.menus.wfindexview.' + item0.name)">{{$t('app.menus.wfindexview.' + item0.name)}}</span>
                        </template>
                        <template v-for="item1 in item0.items">
                            <template v-if="item1.items && Array.isArray(item1.items) && item1.items.length > 0">
                                <el-submenu v-show="!item1.hidden" :index="item1.name" :popper-class="popperClass" :key="item1.id" :class="item1.textcls">
                                    <template slot='title'>
                                        <template v-if="item1.icon && item1.icon != ''">
                                            <img :src="item1.icon" class='app-menu-icon' />
                                        </template>
                                        <template v-else-if="item1.iconcls && item1.iconcls != ''">
                                            <i :class="[item1.iconcls, 'app-menu-icon']"></i>
                                        </template>
                                        <span class='text' :title="$t('app.menus.wfindexview.' + item1.name)">{{$t('app.menus.wfindexview.' + item1.name)}}</span>
                                    </template>
                                    <template v-for="item2 in item1.items">
                                        <template v-if="item2.type =='MENUITEM'">
                                            <el-menu-item v-show="!item2.hidden" :index="item2.name" :key="item2.id" :class="item2.textcls">
                                                <template v-if="item2.icon && item2.icon != ''">
                                                    <img :src="item2.icon" class='app-menu-icon' />
                                                </template>
                                                <template v-else-if="item2.iconcls && item2.iconcls != ''">
                                                    <i :class="[item2.iconcls, 'app-menu-icon']"></i>
                                                </template>
                                                <template slot="title">
                                                    <span class="text" :title="$t('app.menus.wfindexview.' + item2.name)">{{$t('app.menus.wfindexview.' + item2.name)}}</span>
                                                    <template v-if="counterdata && counterdata[item2.counterid] && counterdata[item2.counterid] > 0">
                                                        <span class="pull-right">
                                                            <badge :count="counterdata[item2.counterid]" :overflow-count="9999"></badge>
                                                        </span>
                                                    </template>
                                                </template>
                                            </el-menu-item>
                                        </template>
                                    </template>
                                </el-submenu>
                            </template>
                            <template v-else>
                                <template v-if="item1.type =='MENUITEM'">
                                    <el-menu-item v-show="!item1.hidden" :index="item1.name" :key="item1.id" :class="item1.textcls">
                                        <template v-if="item1.icon && item1.icon != ''">
                                            <img :src="item1.icon" class='app-menu-icon' />
                                        </template>
                                        <template v-else-if="item1.iconcls && item1.iconcls != ''">
                                            <i :class="[item1.iconcls, 'app-menu-icon']"></i>
                                        </template>
                                        <template slot="title">
                                            <span class="text" :title="$t('app.menus.wfindexview.' + item1.name)">{{$t('app.menus.wfindexview.' + item1.name)}} </span>
                                            <template v-if="counterdata && counterdata[item1.counterid] && counterdata[item1.counterid] > 0">
                                                <span class="pull-right">
                                                    <badge :count="counterdata[item1.counterid]" :overflow-count="9999"></badge>
                                                </span>
                                            </template>
                                        </template>
                                    </el-menu-item>
                                </template>
                            </template>
                        </template>
                    </el-submenu>
                </template>
                <template v-else>
                    <template v-if="item0.type =='MENUITEM'">
                        <el-menu-item v-show="!item0.hidden" :index="item0.name" :key="item0.id" :class="item0.textcls">
                            <template v-if="item0.icon && item0.icon != ''">
                                <img :src="item0.icon" class='app-menu-icon' />
                            </template>
                            <template v-else-if="item0.iconcls && item0.iconcls != ''">
                                <i :class="[item0.iconcls, 'app-menu-icon']"></i>
                            </template>
                            <template v-else>
                                <i class='fa fa-cogs app-menu-icon'></i>
                            </template>
                            <template slot="title">
                                <span class="text" :title="$t('app.menus.wfindexview.' + item0.name)">{{$t('app.menus.wfindexview.' + item0.name)}}</span>
                                <template v-if="counterdata && counterdata[item0.counterid] && counterdata[item0.counterid] > 0">
                                    <span class="pull-right">
                                        <badge :count="counterdata[item0.counterid]" :overflow-count="9999"></badge>
                                    </span>
                                </template>
                            </template>
                        </el-menu-item>
                    </template>
                </template>
108
            </template>  
109 110
        </template> 
        <app-menu-item v-else :isCollapse="isCollapse" :menus="menus" :ctrlName="'wfindexview'" :isFirst="true" :counterdata="counterdata" :popper-class="popperClass"></app-menu-item>
111
   
ibizdev's avatar
ibizdev committed
112 113 114 115 116
    </el-menu>
</div>
</template>

<script lang='tsx'>
117
import { Vue, Component, Prop, Provide, Emit, Watch, Model,Inject } from 'vue-property-decorator';
ibizdev's avatar
ibizdev committed
118 119 120
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
121
import { UIActionTool,Util,ViewTool } from '@/utils';
122
import NavDataService from '@/service/app/navdata-service';
123
import AppCenterService from "@service/app/app-center-service";
ibizdev's avatar
ibizdev committed
124 125
import WFIndexViewService from './wfindex-view-appmenu-service';
import WFIndexViewModel from './wfindex-view-appmenu-model';
126
import { Environment } from '@/environments/environment';
127
import AuthService from '@/authservice/auth-service';
ibizdev's avatar
ibizdev committed
128 129 130 131 132 133 134 135 136 137 138 139 140


@Component({
    components: {
      
    }
})
export default class WFIndexViewBase extends Vue implements ControlInterface {

    /**
     * 名称
     *
     * @type {string}
141
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
142
     */
ibizdev's avatar
ibizdev committed
143
    @Prop() public name?: string;
ibizdev's avatar
ibizdev committed
144 145 146 147 148

    /**
     * 视图通讯对象
     *
     * @type {Subject<ViewState>}
149
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
150
     */
ibizdev's avatar
ibizdev committed
151
    @Prop() public viewState!: Subject<ViewState>;
ibizdev's avatar
ibizdev committed
152 153 154 155 156

    /**
     * 应用上下文
     *
     * @type {*}
157
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
158
     */
159
    @Prop() public context!: any;
ibizdev's avatar
ibizdev committed
160 161 162 163 164

    /**
     * 视图参数
     *
     * @type {*}
165
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
166
     */
167
    @Prop() public viewparams!: any;
ibizdev's avatar
ibizdev committed
168 169 170 171

    /**
     * 视图状态事件
     *
ibizdev's avatar
ibizdev committed
172
     * @public
ibizdev's avatar
ibizdev committed
173
     * @type {(Subscription | undefined)}
174
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
175
     */
ibizdev's avatar
ibizdev committed
176
    public viewStateEvent: Subscription | undefined;
ibizdev's avatar
ibizdev committed
177 178 179 180 181

    /**
     * 获取部件类型
     *
     * @returns {string}
182
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
183
     */
ibizdev's avatar
ibizdev committed
184
    public getControlType(): string {
ibizdev's avatar
ibizdev committed
185 186 187 188 189 190 191 192 193
        return 'APPMENU'
    }



    /**
     * 建构部件服务对象
     *
     * @type {WFIndexViewService}
194
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
195
     */
ibizdev's avatar
ibizdev committed
196
    public service: WFIndexViewService = new WFIndexViewService({ $store: this.$store });
ibizdev's avatar
ibizdev committed
197 198 199 200 201 202 203
    


    /**
     * 关闭视图
     *
     * @param {any} args
204
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
205
     */
ibizdev's avatar
ibizdev committed
206
    public closeView(args: any): void {
ibizdev's avatar
ibizdev committed
207 208 209 210 211 212 213
        let _this: any = this;
        _this.$emit('closeview', [args]);
    }

    /**
     *  计数器刷新
     *
214
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
215 216 217 218 219 220 221 222 223 224 225 226 227
     */
    public counterRefresh(){
        const _this:any =this;
        if(_this.counterServiceArray && _this.counterServiceArray.length >0){
            _this.counterServiceArray.forEach((item:any) =>{
                if(item.refreshData && item.refreshData instanceof Function){
                    item.refreshData();
                }
            })
        }
    }


228

ibizdev's avatar
ibizdev committed
229 230 231 232
    /**
     * 获取多项数据
     *
     * @returns {any[]}
233
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
234 235 236 237 238 239 240 241 242
     */
    public getDatas(): any[] {
        return [];
    }

    /**
     * 获取单项树
     *
     * @returns {*}
243
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
244 245 246 247 248
     */
    public getData(): any {
        return null;
    }

249 250 251 252
    /**
     * 导航模式(route:面包屑模式、tab:分页导航模式)
     *
     * @type {string}
253
     * @memberof WFIndexViewBase
254 255 256 257 258 259 260
     */
    @Prop({default:'tab'}) public navModel?:string;

    /**
     * 视图标识
     *
     * @type {string}
261
     * @memberof WFIndexViewBase
262 263 264
     */
    @Prop() public viewtag!:string;

ibizdev's avatar
ibizdev committed
265 266 267
    /**
     * 菜单模型
     *
ibizdev's avatar
ibizdev committed
268
     * @public
ibizdev's avatar
ibizdev committed
269
     * @type {WFIndexViewModel}
270
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
271
     */
ibizdev's avatar
ibizdev committed
272
    public menuMode: WFIndexViewModel = new WFIndexViewModel();
ibizdev's avatar
ibizdev committed
273 274 275 276 277

    /**
     * 显示处理提示
     *
     * @type {boolean}
278
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
279
     */
ibizdev's avatar
ibizdev committed
280
    @Prop({ default: true }) public showBusyIndicator?: boolean;
ibizdev's avatar
ibizdev committed
281 282 283 284

    /**
     * 菜单数据
     *
ibizdev's avatar
ibizdev committed
285
     * @public
ibizdev's avatar
ibizdev committed
286
     * @type {any[]}
287
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
288 289
     */
    @Provide()
ibizdev's avatar
ibizdev committed
290
    public menus: any[] = [];
ibizdev's avatar
ibizdev committed
291 292 293 294 295

    /**
     * 菜单收缩改变
     *
     * @type {boolean}
296
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
297
     */
ibizdev's avatar
ibizdev committed
298
    @Model() public collapsechange?: boolean;
ibizdev's avatar
ibizdev committed
299 300 301 302 303 304

    /**
     * 监听菜单收缩
     *
     * @param {*} newVal
     * @param {*} oldVal
305
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
306 307 308 309 310 311 312 313 314 315 316 317
     */
    @Watch('collapsechange')
    onCollapsechangeChange(newVal: any, oldVal: any) {
        if (newVal !== this.isCollapse) {
            this.isCollapse = !this.isCollapse;
        }
    }

    /**
     * 当前模式,菜单在顶部还是在底部
     *
     * @type {*}
318
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
319 320 321 322
     */
    @Prop() mode: any;

    /**
323
     * 应用起始页面
ibizdev's avatar
ibizdev committed
324
     *
325
     * @type {boolean}
326
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
327 328 329
     */
    @Prop({ default: false }) isDefaultPage?: boolean;

330 331 332 333 334 335 336 337
    /**
     * 空白视图模式
     *
     * @type {boolean}
     * @memberof WFIndexViewBase
     */
    @Prop({ default: false }) isBlankMode?:boolean;

ibizdev's avatar
ibizdev committed
338 339 340 341
    /**
     * 默认打开视图
     *
     * @type {*}
342
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
343 344 345 346 347 348 349
     */
    @Prop() defPSAppView: any;

    /**
     * 默认激活的index
     *
     * @type {*}
350
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
351 352 353 354 355 356 357
     */
    @Provide() defaultActive: any = null;

    /**
     * 当前选中主题
     *
     * @type {*}
358
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
359 360 361 362 363 364 365
     */
    @Prop() selectTheme: any;

    /**
     * 默认打开的index数组
     *
     * @type {any[]}
366
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
367
     */
ibizdev's avatar
ibizdev committed
368
    @Provide() public defaultOpeneds: any[] = [];
ibizdev's avatar
ibizdev committed
369 370 371 372 373

    /**
     * 是否展开
     *
     * @type {boolean}
374
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
375
     */
ibizdev's avatar
ibizdev committed
376
    @Provide() public isCollapse: boolean = false;
ibizdev's avatar
ibizdev committed
377 378 379 380 381

    /**
     * 触发方式,默认click
     *
     * @type {string}
382
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
383 384 385 386 387 388 389
     */
    @Provide() trigger: string = 'click';

    /**
     * 计数器数据
     *
     * @type {*}
390
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
391
     */
ibizdev's avatar
ibizdev committed
392
    public counterdata: any = {};
393 394 395 396 397 398 399 400 401

    /**
     * 建构权限服务对象
     *
     * @type {AuthService}
     * @memberof WFIndexViewBase
     */
    public authService:AuthService = new AuthService({ $store: this.$store });

ibizdev's avatar
ibizdev committed
402 403 404
    /**
     * vue  生命周期
     *
405
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
406
     */
ibizdev's avatar
ibizdev committed
407
    public created() {
ibizdev's avatar
ibizdev committed
408 409 410 411 412 413
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
414
     *  @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
415
     */    
ibizdev's avatar
ibizdev committed
416
    public afterCreated(){
ibizdev's avatar
ibizdev committed
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
        if (Object.is(this.mode, 'horizontal')) {
            this.trigger = 'hover';
        }
        if (this.viewState) {
            this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
                if (!Object.is(tag, this.name)) {
                    return;
                }
                this.load(data);
            });
        }
    }

    /**
     * vue 生命周期
     *
433
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
434
     */
ibizdev's avatar
ibizdev committed
435
    public destroyed() {
ibizdev's avatar
ibizdev committed
436 437 438 439 440 441
        this.afterDestroy();
    }

    /**
     * 执行destroyed后的逻辑
     *
442
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
443
     */
ibizdev's avatar
ibizdev committed
444
    public afterDestroy() {
ibizdev's avatar
ibizdev committed
445 446 447 448 449 450 451 452 453
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
    }


    /**
     * 处理菜单默认选中项
     *
ibizdev's avatar
ibizdev committed
454
     * @public
455
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
456
     */
ibizdev's avatar
ibizdev committed
457
    public doMenuSelect(): void {
458
        if (!this.isDefaultPage || this.isBlankMode) {
ibizdev's avatar
ibizdev committed
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
            return;
        }
        const appFuncs: any[] = this.menuMode.getAppFuncs();
        if (this.$route && this.$route.matched && this.$route.matched.length == 2) { // 存在二级路由
            const [{ }, matched] = this.$route.matched;
            const appfunc: any = appFuncs.find((_appfunc: any) => Object.is(_appfunc.routepath, matched.path) && Object.is(_appfunc.appfuncyype, 'APPVIEW'));
            if (appfunc) {
                this.computeMenuSelect(this.menus, appfunc.appfunctag);
            }
            return;
        } else if (this.defPSAppView && Object.keys(this.defPSAppView).length > 0) { // 存在默认视图
            const appfunc: any = appFuncs.find((_appfunc: any) => Object.is(_appfunc.routepath, this.defPSAppView.routepath) && Object.is(_appfunc.appfuncyype, 'APPVIEW'));
            if (appfunc) {
                this.computeMenuSelect(this.menus, appfunc.appfunctag);
            }
            const viewparam: any = {};
            const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, this.defPSAppView.deResParameters, this.defPSAppView.parameters, [], viewparam);
            this.$router.push(path);
            return;
        }

        this.computeMenuSelect(this.menus, '');
        let item = this.compute(this.menus, this.defaultActive);
        if (Object.keys(item).length === 0) {
            return;
        }
ibizdev's avatar
ibizdev committed
485 486 487
        if(!item.hidden){
            this.click(item);
        }
ibizdev's avatar
ibizdev committed
488 489 490 491 492
    }

    /**
     * 计算菜单选中项
     *
ibizdev's avatar
ibizdev committed
493
     * @public
ibizdev's avatar
ibizdev committed
494 495 496
     * @param {any[]} items
     * @param {string} appfunctag
     * @returns {boolean}
497
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
498
     */
ibizdev's avatar
ibizdev committed
499
    public computeMenuSelect(items: any[], appfunctag: string): boolean {
ibizdev's avatar
ibizdev committed
500 501
        const appFuncs: any[] = this.menuMode.getAppFuncs();
        return items.some((item: any) => {
502
            if (Object.is(appfunctag, '') && !Object.is(item.appfunctag, '') && item.opendefault) {
ibizdev's avatar
ibizdev committed
503 504 505 506 507 508 509
                const appfunc = appFuncs.find((_appfunc: any) => Object.is(_appfunc.appfunctag, item.appfunctag));
                if (appfunc.routepath) {
                    this.defaultActive = item.name;
                    this.setHideSideBar(item);
                    return true;
                }
            }
510
            if (Object.is(item.appfunctag, appfunctag) && item.opendefault) {
ibizdev's avatar
ibizdev committed
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
                this.setHideSideBar(item);
                this.defaultActive = item.name;
                return true;
            }
            if (item.items && item.items.length > 0) {
                const state = this.computeMenuSelect(item.items, appfunctag);
                if (state) {
                    this.defaultOpeneds.push(item.name);
                    return true;
                }
            }
            return false;
        });
    }

    /**
     * 获取菜单项数据
     *
ibizdev's avatar
ibizdev committed
529
     * @public
ibizdev's avatar
ibizdev committed
530 531 532
     * @param {any[]} items
     * @param {string} name
     * @returns
533
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
534
     */
ibizdev's avatar
ibizdev committed
535
    public compute(items: any[], name: string) {
ibizdev's avatar
ibizdev committed
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557
        const item: any = {};
        items.some((_item: any) => {
            if (name && Object.is(_item.name, name)) {
                Object.assign(item, _item);
                this.setHideSideBar(_item);
                return true;
            }
            if (_item.items && Array.isArray(_item.items)) {
                const subItem = this.compute(_item.items, name);
                if (Object.keys(subItem).length > 0) {
                    Object.assign(item, subItem);
                    return true;
                }
            }
            return false;
        });
        return item;
    }

    /**
     * 设置是否隐藏菜单栏
     *
ibizdev's avatar
ibizdev committed
558
     * @public
ibizdev's avatar
ibizdev committed
559
     * @param {*} item
560
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
561
     */
ibizdev's avatar
ibizdev committed
562
    public setHideSideBar(item: any): void {
ibizdev's avatar
ibizdev committed
563 564 565 566 567 568 569 570 571 572 573
        if (item.hidesidebar) {
            this.$emit('collapsechange', true);
        }
    }

    /**
     * 菜单项选中处理
     *
     * @param {*} index
     * @param {any[]} indexs
     * @returns
574
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
575
     */
ibizdev's avatar
ibizdev committed
576
    public select(index: any, indexs: any[]) {
ibizdev's avatar
ibizdev committed
577 578 579 580 581 582 583 584 585 586
        let item = this.compute(this.menus, index);
        if (Object.keys(item).length === 0) {
            return;
        }
        this.click(item);
    }

    /**
     * 菜单点击
     *
ibizdev's avatar
ibizdev committed
587
     * @public
ibizdev's avatar
ibizdev committed
588
     * @param {*} item 菜单数据
589
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
590
     */
ibizdev's avatar
ibizdev committed
591
    public click(item: any) {
ibizdev's avatar
ibizdev committed
592
        if (item) {
593
            let navDataService = NavDataService.getInstance(this.$store);
594 595 596
            if(Object.is(this.navModel,"route")){
                navDataService.removeNavData(this.viewtag);
            }
ibizdev's avatar
ibizdev committed
597
            switch (item.appfunctag) {
ibizdev's avatar
ibizdev committed
598 599
                case 'Auto3': 
                    this.clickAuto3(item);
ibizdev's avatar
ibizdev committed
600
                    return;
601 602 603
                case 'Auto2': 
                    this.clickAuto2(item);
                    return;
ibizdev's avatar
ibizdev committed
604 605
                case 'Auto1': 
                    this.clickAuto1(item);
ibizdev's avatar
ibizdev committed
606
                    return;
607 608
                case 'Auto4': 
                    this.clickAuto4(item);
ibizdev's avatar
ibizdev committed
609 610 611 612 613 614 615
                    return;
                default:
                    console.warn('未指定应用功能');
            }
        }
    }

616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
    
    /**
     * 发布流程
     *
     * @param {*} [item={}]
     * @memberof WFIndexView
     */
    public clickAuto3(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'wfremodels', parameterName: 'wfremodel' },
            { pathName: 'editview', parameterName: 'editview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        if(Object.is(this.$route.fullPath,path)){
            return;
        }
        this.$nextTick(function(){
            this.$router.push(path);
        })
    }
    
    /**
     * 用户组
     *
     * @param {*} [item={}]
     * @memberof WFIndexView
     */
    public clickAuto2(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'wfgroups', parameterName: 'wfgroup' },
            { pathName: 'gridview', parameterName: 'gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        if(Object.is(this.$route.fullPath,path)){
            return;
        }
        this.$nextTick(function(){
            this.$router.push(path);
        })
    }
    
    /**
     * 流程定义
     *
     * @param {*} [item={}]
     * @memberof WFIndexView
     */
    public clickAuto1(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'wfprocessdefinitions', parameterName: 'wfprocessdefinition' },
            { pathName: 'gridview', parameterName: 'gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        if(Object.is(this.$route.fullPath,path)){
            return;
        }
        this.$nextTick(function(){
            this.$router.push(path);
        })
    }
    
    /**
     * 我的待办
     *
     * @param {*} [item={}]
     * @memberof WFIndexView
     */
    public clickAuto4(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'wftasks', parameterName: 'wftask' },
            { pathName: 'gridview', parameterName: 'gridview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        if(Object.is(this.$route.fullPath,path)){
            return;
        }
        this.$nextTick(function(){
            this.$router.push(path);
        })
    }
ibizdev's avatar
ibizdev committed
708 709 710 711 712

    /**
     * 数据加载
     *
     * @param {*} data
713
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
714
     */
ibizdev's avatar
ibizdev committed
715
    public load(data: any) {
ibizdev's avatar
ibizdev committed
716 717 718 719 720 721 722
        this.handleMenusResource(this.menuMode.getAppMenuItems());
    }

    /**
     * 通过统一资源标识计算菜单
     *
     * @param {*} data
723
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
724 725
     */
    public handleMenusResource(inputMenus:Array<any>){
726
        if(this.$store.getters['authresource/getEnablePermissionValid']){
ibizdev's avatar
ibizdev committed
727
            this.computedEffectiveMenus(inputMenus);
728
            this.computeParentMenus(inputMenus);
ibizdev's avatar
ibizdev committed
729
        }
730 731
        this.dataProcess(inputMenus);
        this.menus = inputMenus;
ibizdev's avatar
ibizdev committed
732 733 734
        this.doMenuSelect();
    }

ibizdev's avatar
ibizdev committed
735 736 737
    /**
     * 计算有效菜单项
     *
738
     * @param {*} inputMenus
739
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
740 741 742
     */
    public computedEffectiveMenus(inputMenus:Array<any>){
        inputMenus.forEach((_item:any) =>{
743
            if(!this.authService.getMenusPermission(_item)){
ibizdev's avatar
ibizdev committed
744 745 746 747 748 749 750 751
                _item.hidden = true;
                if (_item.items && _item.items.length > 0) {
                    this.computedEffectiveMenus(_item.items);
                }
            }
        })
    }

752 753 754 755 756 757 758 759 760 761 762 763 764
    /**
     * 计算父项菜单项是否隐藏
     *
     * @param {*} inputMenus
     * @memberof WFIndexViewBase
     */
    public computeParentMenus(inputMenus:Array<any>){
        if(inputMenus && inputMenus.length >0){
            inputMenus.forEach((item:any) =>{
                if(item.hidden && item.items && item.items.length >0){
                    item.items.map((singleItem:any) =>{
                        if(!singleItem.hidden){
                            item.hidden = false;
765 766 767 768 769 770 771 772
                        }else{
                            if(singleItem.items && singleItem.items.length >0){
                                singleItem.items.map((grandsonItem:any) =>{
                                    if(!grandsonItem.hidden){
                                        item.hidden = false;
                                    }
                                })
                            }
773
                        }
774 775
                        if(item.items && item.items.length >0){
                            this.computeParentMenus(item.items);
776 777 778 779 780 781 782
                        }
                    })
                }
            })
        }
    }

ibizdev's avatar
ibizdev committed
783 784 785
    /**
     * 数据处理
     *
ibizdev's avatar
ibizdev committed
786
     * @public
ibizdev's avatar
ibizdev committed
787
     * @param {any[]} items
788
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
789
     */
ibizdev's avatar
ibizdev committed
790
    public dataProcess(items: any[]): void {
ibizdev's avatar
ibizdev committed
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805
        items.forEach((_item: any) => {
            if (_item.expanded) {
                this.defaultOpeneds.push(_item.name);
            }
            if (_item.items && _item.items.length > 0) {
                this.dataProcess(_item.items)
            }
        });
    }

    /**
     * 提示框主题样式
     *
     * @readonly
     * @type {string}
806
     * @memberof WFIndexViewBase
ibizdev's avatar
ibizdev committed
807 808 809 810 811 812 813 814 815 816 817
     */
    get popperClass(): string {
        return 'app-popper-menu ' + this.selectTheme;
    }
    
}
</script>

<style lang='less'>
@import './wfindex-view-appmenu.less';
</style>