sys-permissionmpickup-view-base.vue 27.4 KB
Newer Older
1 2
<template>
<div class="view-container dempickupview sys-permissionmpickup-view">
3
    <app-studioaction :viewTitle="$t(model.srfCaption)" viewName="sys_permissionmpickupview"></app-studioaction>
4
    <card class='view-card view-no-caption  view-no-toolbar' :dis-hover="true" :padding="0" :bordered="false">
5
        <div class='view-top-messages'>
6 7 8
        </div>
        <div class="content-container pickup-view">
        <div class='view-body-messages'>
9
        </div>
10 11 12 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
            <div class="translate-contant">
                <div class="center" :style="{width : !isShowButton ? '100%' : ''}">
    <view_pickupviewpanel 
        :viewState="viewState"  
        :viewparams="JSON.parse(JSON.stringify(viewparams))" 
        :context="JSON.parse(JSON.stringify(context))" 
        :isSingleSelect="isSingleSelect"
        :selectedData="selectedData"
        :isShowButton="isShowButton"
        name="pickupviewpanel"  
        ref='pickupviewpanel' 
        @selectionchange="pickupviewpanel_selectionchange($event)"  
        @activated="pickupviewpanel_activated($event)"  
        @load="pickupviewpanel_load($event)"  
        @closeview="closeView($event)">
    </view_pickupviewpanel>
                </div>
                <div v-if="isShowButton" class="translate-buttons">
                    <div class="buttons">
                        <i-button type="primary" :title="this.containerModel.view_rightbtn.text"
                            :disabled="this.containerModel.view_rightbtn.disabled"
                            @click="onCLickRight">
                            <i class="el-icon-arrow-right"></i>
                        </i-button>
                        <i-button type="primary" :title="this.containerModel.view_leftbtn.text"
                            :disabled="this.containerModel.view_leftbtn.disabled"
                            @click="onCLickLeft">
                            <i class="el-icon-arrow-left"></i>
                        </i-button>
                        <i-button type="primary" :title="this.containerModel.view_allrightbtn.text"
                            @click="onCLickAllRight">
                            <i class="el-icon-d-arrow-right"></i>
                        </i-button>
                        <i-button type="primary" :title="this.containerModel.view_allleftbtn.text"
                            @click="onCLickAllLeft">
                            <i class="el-icon-d-arrow-left"></i>
                        </i-button>
                    </div>
                    </div>
                    <div v-if="isShowButton" class="right">
                        <div class="mpicker-select">
                            <div v-for="(item, index) in viewSelections" :key="index" :class="item._select ? 'select' : ''" @click="selectionsClick(item)" @dblclick="selectionsDBLClick(item)">
                                <span>{{item.srfmajortext}}</span>
                            </div>
                        </div>
                    </div>
                </div>
                <card v-if="isShowButton" :dis-hover="true" :bordered="false" class="footer">
                    <row :style="{ textAlign: 'right' }">
                        <i-button type="primary"  :disabled="this.viewSelections.length > 0 ? false : true" @click="onClickOk">{{this.containerModel.view_okbtn.text}}</i-button>
                            &nbsp;&nbsp;
                        <i-button @click="onClickCancel">{{this.containerModel.view_cancelbtn.text}}</i-button>
                    </row>
                </card>   
64
        </div>
65 66
        <div class='view-bottom-messages'>
        </div>
67 68 69 70 71 72
    </card>
</div>
</template>


<script lang='tsx'>
73
import { Vue, Component, Prop, Provide, Emit, Watch,Inject } from 'vue-property-decorator';
74
import { UIActionTool,Util } from '@/utils';
75
import NavDataService from '@/service/app/navdata-service';
76
import { Subject,Subscription } from 'rxjs';
77
import SysPermissionService from '@/service/sys-permission/sys-permission-service';
78
import SysPermissionAuthService from '@/authservice/sys-permission/sys-permission-auth-service';
79 80 81 82

import MPickupViewEngine from '@engine/view/mpickup-view-engine';


83
import SysPermissionUIService from '@/uiservice/sys-permission/sys-permission-ui-service';
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

@Component({
    components: {
    },
})
export default class SYS_PERMISSIONMPickupViewBase extends Vue {

    /**
     * 实体服务对象
     *
     * @type {SysPermissionService}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public appEntityService: SysPermissionService = new SysPermissionService;

99
    /**
100
     * 实体UI服务对象
101
     *
102
     * @type SysPermissionUIService
103 104
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
105
    public appUIService: SysPermissionUIService = new SysPermissionUIService(this.$store);
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
    
    /**
     * 数据变化
     *
     * @param {*} val
     * @returns {*}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    @Emit() 
    public viewDatasChange(val: any):any {
        return val;
    }

    /**
     * 传入视图上下文
     *
     * @type {string}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    @Prop() public viewdata!: string;

    /**
     * 传入视图参数
     *
     * @type {string}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    @Prop() public viewparam!: string;

    /**
     * 视图默认使用
     *
     * @type {boolean}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    @Prop({ default: true }) public viewDefaultUsage!: boolean;

143 144 145 146 147 148
    /**
     * 视图默认使用
     *
     * @type {string}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
149
    @Inject({from:'navModel',default: 'tab'})
150 151
    public navModel!:string;

152 153 154 155 156 157
	/**
	 * 视图标识
	 *
	 * @type {string}
	 * @memberof SYS_PERMISSIONMPickupViewBase
	 */
158
	public viewtag: string = '86bd4f6d4f771870e10b9717046a1b14';
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200

	/**
	 * 自定义视图导航上下文集合
	 *
	 * @type {*}
	 * @memberof SYS_PERMISSIONMPickupViewBase
	 */
    public customViewNavContexts:any ={
    };

	/**
	 * 自定义视图导航参数集合
	 *
	 * @type {*}
	 * @memberof SYS_PERMISSIONMPickupViewBase
	 */
    public customViewParams:any ={
    };

    /**
     * 视图模型数据
     *
     * @type {*}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public model: any = {
        srfCaption: 'entities.syspermission.views.mpickupview.caption',
        srfTitle: 'entities.syspermission.views.mpickupview.title',
        srfSubTitle: 'entities.syspermission.views.mpickupview.subtitle',
        dataInfo: ''
    }

    /**
     * 视图参数变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    @Watch('viewparam',{immediate: true, deep: true})
    onParamData(newVal: any, oldVal: any) {
        if(newVal){
201 202
            this.viewparams = {};
            if(typeof newVal == 'string') {
203
                Object.assign(this.viewparams, JSON.parse(this.viewparam));
204 205
            }else{
                this.viewparams = Util.deepCopy(this.viewparam);
206
            }
207 208
            if(this.viewparams.selectedData){
                this.selectedData = JSON.stringify(this.viewparams.selectedData);
209
                this.viewSelections = this.viewparams.selectedData;
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
            }

        } 
    }

    /**
     * 处理应用上下文变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    @Watch('viewdata')
    onViewData(newVal: any, oldVal: any) {
        const _this: any = this;
225
        
226
        if (!Object.is(newVal, oldVal) && _this.engine) {
227 228 229 230
            this.$nextTick(()=>{
              _this.parseViewParam();
              _this.engine.load();
            });
231
        } else if(!Object.is(newVal, oldVal) && _this.refresh && _this.refresh instanceof Function) {
232
            _this.refresh();
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
        }
    }

    /**
     * 容器模型
     *
     * @type {*}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public containerModel: any = {
        view_pickupviewpanel: { name: 'pickupviewpanel', type: 'PICKUPVIEWPANEL' },
        view_okbtn: { name: 'okbtn', type: 'button', text: '确定', disabled: true },
        view_cancelbtn: { name: 'cancelbtn', type: 'button', text: '取消', disabled: false },
        view_leftbtn: { name: 'leftbtn', type: 'button', text: '左移', disabled: true },
        view_rightbtn: { name: 'rightbtn', type: 'button', text: '右移', disabled: true },
        view_allleftbtn: { name: 'allleftbtn', type: 'button', text: '全部左移', disabled: true },
        view_allrightbtn: { name: 'allrightbtn', type: 'button', text: '全部右移', disabled: true },
    };

    /**
     *  计数器刷新
     *
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    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();
                }
            })
        }
    }

    /**
     * 视图状态订阅对象
     *
     * @public
     * @type {Subject<{action: string, data: any}>}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public viewState: Subject<ViewState> = new Subject();



    /**
     * 视图引擎
     *
     * @public
     * @type {Engine}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public engine: MPickupViewEngine = new MPickupViewEngine();

    /**
     * 引擎初始化
     *
     * @public
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public engineInit(): void {
        this.engine.init({
            view: this,
            pickupviewpanel: this.$refs.pickupviewpanel,
            keyPSDEField: 'syspermission',
            majorPSDEField: 'permissionname',
            isLoadDefault: true,
        });
    }

304 305 306 307 308 309 310 311
    /**
     * 应用导航服务
     *
     * @type {*}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public  navDataService = NavDataService.getInstance(this.$store);

312 313 314 315 316 317 318 319 320
    /**
    * 导航服务事件
    *
    * @public
    * @type {(Subscription | undefined)}
    * @memberof SYS_PERMISSIONMPickupViewBase
    */
    public serviceStateEvent: Subscription | undefined;

321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
    /**
     * 门户部件状态对象
     *
     * @type {*}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    @Prop() public portletState?: any;

   /**
   * 门户部件状态事件
   *
   * @public
   * @type {(Subscription | undefined)}
   * @memberof SYS_PERMISSIONMPickupViewBase
   */
    public portletStateEvent: Subscription | undefined;

338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
    /**
     * 应用上下文
     *
     * @type {*}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public context:any = {};

    /**
     * 视图参数
     *
     * @type {*}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public viewparams:any = {};

354 355 356 357 358 359 360 361
    /**
     * 视图缓存数据
     *
     * @type {*}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public viewCacheData:any;

362 363 364 365 366 367 368 369 370

    /**
     * 计数器服务对象集合
     *
     * @type {Array<*>}
     * @memberof SYS_PERMISSIONMPickupViewBase
     */    
    public counterServiceArray:Array<any> = [];

371 372 373 374 375 376
    /**
     * 解析视图参数
     *
     * @public
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
377
    public parseViewParam(inputvalue:any = null): void {
378 379 380
        for(let key in this.context){
            delete this.context[key];
        }
381 382 383
        if(this.$store.getters.getAppData() && this.$store.getters.getAppData().context){
            Object.assign(this.context,this.$store.getters.getAppData().context);
        }
384
        if (!this.viewDefaultUsage && this.viewdata && !Object.is(this.viewdata, '')) {
385 386 387
            if(typeof this.viewdata == 'string') {
                Object.assign(this.context, JSON.parse(this.viewdata));
            }
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
            if(this.context && this.context.srfparentdename){
                Object.assign(this.viewparams,{srfparentdename:this.context.srfparentdename});
            }
            if(this.context && this.context.srfparentkey){
                Object.assign(this.viewparams,{srfparentkey:this.context.srfparentkey});
            }
            this.handleCustomViewData();
            return;
        }
        const path = (this.$route.matched[this.$route.matched.length - 1]).path;
        const keys: Array<any> = [];
        const curReg = this.$pathToRegExp.pathToRegexp(path, keys);
        const matchArray = curReg.exec(this.$route.path);
        let tempValue: Object = {};
        keys.forEach((item: any, index: number) => {
            Object.defineProperty(tempValue, item.name, {
                enumerable: true,
                value: matchArray[index + 1]
            });
        });
        this.$viewTool.formatRouteParams(tempValue,this.$route,this.context,this.viewparams);
409 410 411
        if(inputvalue){
            Object.assign(this.context,{'syspermission':inputvalue});
        }
412 413 414
        //初始化视图唯一标识
        Object.assign(this.context,{srfsessionid:this.$util.createUUID()});
        this.handleCustomViewData();
415
        //初始化导航数据
416
        this.initNavDataWithRoute();
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
    }

    /**
     * 处理自定义视图数据
     *
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
	public handleCustomViewData(){
		if(Object.keys(this.customViewNavContexts).length > 0){
			Object.keys(this.customViewNavContexts).forEach((item:any) =>{
				let tempContext:any = {};
				let curNavContext:any = this.customViewNavContexts[item];
				this.handleCustomDataLogic(curNavContext,tempContext,item);
				Object.assign(this.context,tempContext);
			})
		}
		if(Object.keys(this.customViewParams).length > 0){
			Object.keys(this.customViewParams).forEach((item:any) =>{
				let tempParam:any = {};
				let curNavParam:any = this.customViewParams[item];
				this.handleCustomDataLogic(curNavParam,tempParam,item);
				Object.assign(this.viewparams,tempParam);
			})
		}
	}

    /**
     * 处理自定义视图数据逻辑
     *
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
	public handleCustomDataLogic(curNavData:any,tempData:any,item:string){
		// 直接值直接赋值
		if(curNavData.isRawValue){
			if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
                Object.defineProperty(tempData, item.toLowerCase(), {
                    value: null,
                    writable : true,
                    enumerable : true,
                    configurable : true
                });
            }else{
                Object.defineProperty(tempData, item.toLowerCase(), {
                    value: curNavData.value,
                    writable : true,
                    enumerable : true,
                    configurable : true
                });
            }
		}else{
			// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
468
			if(this.context[(curNavData.value).toLowerCase()] != null){
469 470 471 472 473 474 475
				Object.defineProperty(tempData, item.toLowerCase(), {
					value: this.context[(curNavData.value).toLowerCase()],
					writable : true,
					enumerable : true,
					configurable : true
				});
			}else{
476
				if(this.viewparams[(curNavData.value).toLowerCase()] != null){
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
					Object.defineProperty(tempData, item.toLowerCase(), {
						value: this.viewparams[(curNavData.value).toLowerCase()],
						writable : true,
						enumerable : true,
						configurable : true
					});
				}else{
					Object.defineProperty(tempData, item.toLowerCase(), {
						value: null,
						writable : true,
						enumerable : true,
						configurable : true
					});
				}
			}
		}
	}
494 495

    /**
496
     * 初始化导航数据(路由模式)
497 498 499
     *
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
500 501
    public initNavDataWithRoute(data:any = null, isNew:boolean = false,  isAlways:boolean = false){
        if( isAlways || (this.viewDefaultUsage && Object.is(this.navModel,"route")) ){
502
            this.navDataService.addNavData({id:'sys-permissionmpickup-view',tag:this.viewtag,srfkey:isNew ? null : this.context.syspermission,title:this.$t(this.model.srfCaption),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath});
503 504 505 506 507 508 509 510
        }
    }

    /**
     * 初始化导航数据(分页模式)
     *
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
511 512
    public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true, isAlways:boolean = false){
        if( isAlways || (this.viewDefaultUsage && !Object.is(this.navModel,"route")) ){
513
            this.navDataService.addNavDataByOnly({id:'sys-permissionmpickup-view',tag:this.viewtag,srfkey:this.context.syspermission,title:this.$t(this.model.srfCaption),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath},isOnlyAdd);
514 515
        }
    }
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
	

    /**
     * Vue声明周期
     *
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public created() {
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
     * @memberof SYS_PERMISSIONMPickupViewBase
     */    
    public afterCreated(){
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
        let _this:any = this;
        const secondtag = _this.$util.createUUID();
        _this.$store.commit('viewaction/createdView', { viewtag: _this.viewtag, secondtag: secondtag });
        _this.viewtag = secondtag;
        _this.parseViewParam();
        _this.serviceStateEvent = _this.navDataService.serviceState.subscribe(({ action,name, data }:{ action:string,name:any,data:any }) => {
            if(!Object.is(name,'sys-permissionmpickup-view')){
                return;
            }
            if (Object.is(action, 'viewrefresh')) {
                _this.$nextTick(()=>{
                    _this.parseViewParam(data);
                    if(_this.engine){
                        _this.engine.load();
                    }
                }); 
            }
        });
551 552
        if(_this.portletState){
            _this.portletStateEvent = _this.portletState.subscribe((res:any) =>{
553
                if(!Object.is(res.name,'SYS_PERMISSIONMPickupView')){
554 555 556 557 558 559 560
                    return;
                }
                if(Object.is(res.action,'refresh') && _this.refresh && _this.refresh instanceof Function){
                    _this.refresh();
                }
            })
        }
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 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
        
    }

    /**
     * 销毁之前
     *
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public beforeDestroy() {
        this.$store.commit('viewaction/removeView', this.viewtag);
    }

    /**
     * Vue声明周期(组件初始化完毕)
     *
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public mounted() {
        this.afterMounted();
    }

    /**
     * 执行mounted后的逻辑
     * 
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public afterMounted(){
        const _this: any = this;
        _this.engineInit();
        if (_this.loadModel && _this.loadModel instanceof Function) {
            _this.loadModel();
        }
        if(this.viewparams.selectedData){
            this.engine.onCtrlEvent('pickupviewpanel', 'selectionchange', this.viewparams.selectedData);
            this.onCLickRight();
        }

    }


    /**
     * pickupviewpanel 部件 selectionchange 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public pickupviewpanel_selectionchange($event: any, $event2?: any) {
        this.engine.onCtrlEvent('pickupviewpanel', 'selectionchange', $event);
    }


    /**
     * pickupviewpanel 部件 activated 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public pickupviewpanel_activated($event: any, $event2?: any) {
        this.engine.onCtrlEvent('pickupviewpanel', 'activated', $event);
    }


    /**
     * pickupviewpanel 部件 load 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public pickupviewpanel_load($event: any, $event2?: any) {
        this.engine.onCtrlEvent('pickupviewpanel', 'load', $event);
    }




    /**
     * 关闭视图
     *
     * @param {any[]} args
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public closeView(args: any[]): void {
        let _view: any = this;
        if (_view.viewdata) {
648 649
            _view.$emit('viewdataschange', Array.isArray(args)?args:[args]);
            _view.$emit('close', Array.isArray(args)?args:[args]);
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
        } else if (_view.$tabPageExp) {
            _view.$tabPageExp.onClose(_view.$route.fullPath);
        }
    }

    /**
     * 销毁视图回调
     *
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public destroyed(){
        this.afterDestroyed();
    }

    /**
     * 执行destroyed后的逻辑
     * 
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public afterDestroyed(){
        if(this.viewDefaultUsage){
            let localStoreLength = Object.keys(localStorage);
            if(localStoreLength.length > 0){
                localStoreLength.forEach((item:string) =>{
                if(item.startsWith(this.context.srfsessionid)){
                    localStorage.removeItem(item);
                }
                })
            }
679 680 681
            if(Object.is(this.navModel,"tab")){
                this.navDataService.removeNavDataByTag(this.viewtag);
            }
682 683 684
            if (this.serviceStateEvent) {
                this.serviceStateEvent.unsubscribe();
            }
685
        }
686 687 688 689 690 691 692 693
        // 销毁计数器定时器
        if(this.counterServiceArray && this.counterServiceArray.length >0){
            this.counterServiceArray.forEach((item:any) =>{
                if(item.destroyCounter && item.destroyCounter instanceof Function){
                    item.destroyCounter();
                }
            })
        }
694 695 696
        if(this.portletStateEvent){
            this.portletStateEvent.unsubscribe();
        }
697 698 699 700 701
    }
    /**
     * 是否显示按钮
     *
     * @type {boolean}
702
     * @memberof SYS_PERMISSIONMPickupViewBase
703 704 705 706 707 708 709
     */
    @Prop({default: true}) public isShowButton!: boolean;
    
    /**
     * 选中数据的字符串
     *
     * @type {string}
710
     * @memberof SYS_PERMISSIONMPickupViewBase
711 712 713 714 715 716 717
     */
    public selectedData: string = "";

    /**
     * 是否初始化已选中项
     *
     * @type {any[]}
718
     * @memberof SYS_PERMISSIONMPickupViewBase
719 720 721 722 723 724 725
     */
    public isInitSelected:boolean = false;
    
    /**
     * 视图选中数据
     *
     * @type {any[]}
726
     * @memberof SYS_PERMISSIONMPickupViewBase
727 728 729 730 731 732 733
     */
    public viewSelections:any[] = [];
    
    /**
     * 是否单选
     *
     * @type {boolean}
734
     * @memberof SYS_PERMISSIONMPickupViewBase
735 736 737 738 739 740 741
     */
    public isSingleSelect: boolean = false;

    /**
     * 选中数据单击
     *
     * @param {*} item
742
     * @memberof SYS_PERMISSIONMPickupViewBase
743 744 745 746 747 748 749 750 751 752 753
     */
    public selectionsClick(item:any):void {
        item._select = !item._select;
        const removeSelect: boolean = this.viewSelections.some((selection: any) => selection._select);
        this.containerModel.view_leftbtn.disabled = !removeSelect;
    }

    /**
     * 选中树双击
     *
     * @param {*} item
754
     * @memberof SYS_PERMISSIONMPickupViewBase
755 756 757 758 759 760 761 762 763 764 765 766 767 768
     */
    public selectionsDBLClick(item:any):void {
        const index: number = this.viewSelections.findIndex((selection: any) => Object.is(selection.srfkey, item.srfkey));
        if (index !== -1) {
            this.viewSelections.splice(index, 1);
        }
        const removeSelect: boolean = this.viewSelections.some((selection: any) => selection._select);
        this.containerModel.view_leftbtn.disabled = !removeSelect;
        this.selectedData = JSON.stringify(this.viewSelections);
    }

    /**
     * 删除右侧全部选中数据
     *
769
     * @memberof SYS_PERMISSIONMPickupViewBase
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789
     */
    public onCLickLeft():void {
        const _selectiions = [...JSON.parse(JSON.stringify(this.viewSelections))];
        _selectiions.forEach((item: any) => {
            if (!item._select) {
                return;
            }
            const index = this.viewSelections.findIndex((selection: any) => Object.is(item.srfkey, selection.srfkey));
            if (index !== -1) {
                this.viewSelections.splice(index, 1);
            }
        });
        const removeSelect: boolean = this.viewSelections.some((selection: any) => selection._select);
        this.containerModel.view_leftbtn.disabled = !removeSelect;
        this.selectedData = JSON.stringify(this.viewSelections);
    }

    /**
     * 添加左侧选中数据
     *
790
     * @memberof SYS_PERMISSIONMPickupViewBase
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807
     */
    public onCLickRight():void {
        Object.values(this.containerModel).forEach((model: any) => {
            if (!Object.is(model.type, 'PICKUPVIEWPANEL')) {
                return;
            }
            let newSelections:any[] = [];
            model.selections.forEach((item: any) => {
                const index: number = this.viewSelections.findIndex((selection: any) => Object.is(item.srfkey, selection.srfkey));
                if (index === -1) {
                    let _item: any = { ...JSON.parse(JSON.stringify(item)) };
                    Object.assign(_item, { _select: false })
                    newSelections.push(_item);
                }else{
                    newSelections.push(this.viewSelections[index]);
                }
            });
808
            this.viewSelections = this.removeDuplicates([...newSelections,...this.viewSelections]);
809
        });
810 811 812 813 814 815 816 817 818 819
    }

    /**
     * 去重
     *
     * @memberof SYS_PERMISSIONMPickupViewBase
     */
    public removeDuplicates(data:any):Array<any> {
        const uniqueSet = new Set(data);
        return [...uniqueSet];
820 821 822 823 824
    }

    /**
     * 选中数据全部删除
     *
825
     * @memberof SYS_PERMISSIONMPickupViewBase
826 827 828 829
     */
    public onCLickAllLeft():void {
        this.viewSelections = [];
        this.containerModel.view_leftbtn.disabled = true;
830
        this.engine.onCtrlEvent('pickupviewpanel', 'selectionchange', []);
831 832 833 834 835 836
        this.selectedData = JSON.stringify(this.viewSelections);
    }

    /**
     * 添加左侧面板所有数据到右侧
     *
837
     * @memberof SYS_PERMISSIONMPickupViewBase
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857
     */
    public onCLickAllRight():void {
        Object.values(this.containerModel).forEach((model: any) => {
            if (!Object.is(model.type, 'PICKUPVIEWPANEL')) {
                return;
            }
            if(model.datas.length>0){
                model.datas.forEach((data:any,index:any)=>{
                    Object.assign(data,{srfmajortext: data['permissionname']});
                })
            }
            model.datas.forEach((item: any) => {
                const index: number = this.viewSelections.findIndex((selection: any) => Object.is(item.srfkey, selection.srfkey));
                if (index === -1) {
                    let _item: any = { ...JSON.parse(JSON.stringify(item)) };
                    Object.assign(_item, { _select: false })
                    this.viewSelections.push(_item);
                }
            });
        });
858
        this.selectedData = JSON.stringify(this.viewSelections);
859 860 861 862 863
    }

    /**
     * 确定
     *
864
     * @memberof SYS_PERMISSIONMPickupViewBase
865 866 867 868 869 870 871 872 873
     */
    public onClickOk(): void {
        this.$emit('viewdataschange', this.viewSelections);
        this.$emit('close', null);
    }

    /**
     * 取消
     *
874
     * @memberof SYS_PERMISSIONMPickupViewBase
875 876
     */
    public onClickCancel(): void {
877
        this.$emit('viewdataschange', null);
878 879 880 881 882 883 884 885 886
        this.$emit('close', null);
    }

}
</script>

<style lang='less'>
@import './sys-permissionmpickup-view.less';
</style>