pickup-viewpickupviewpanel-pickupviewpanel-base.vue 8.8 KB
Newer Older
ibizdev's avatar
ibizdev committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<template>
    <div class='pickupviewpanel'>
        <component 
          v-if="inited && view.viewname && !Object.is(view.viewname, '')" 
          :is="view.viewname"
          class="viewcontainer3"
          :viewdata="viewdata"
          :viewparam="viewparam"
          :viewDefaultUsage="false"
          :isSingleSelect="isSingleSelect"
          :selectedData="selectedData"
          :isShowButton="isShowButton"
          @viewdataschange="onViewDatasChange"
          @viewdatasactivated="viewDatasActivated"
          @viewload="onViewLoad">
        </component>
    </div>
</template>

<script lang='tsx'>
21
import { Vue, Component, Prop, Provide, Emit, Watch, Model,Inject } from 'vue-property-decorator';
ibizdev's avatar
ibizdev committed
22 23 24
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
25
import { UIActionTool,Util,ViewTool } from '@/utils';
26
import NavDataService from '@/service/app/navdata-service';
27
import AppCenterService from "@service/app/app-center-service";
ibizdev's avatar
ibizdev committed
28 29
import IBZDepartmentService from '@/service/ibzdepartment/ibzdepartment-service';
import PickupViewpickupviewpanelService from './pickup-viewpickupviewpanel-pickupviewpanel-service';
30
import IBZDepartmentUIService from '@/uiservice/ibzdepartment/ibzdepartment-ui-service';
ibizdev's avatar
ibizdev committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44
import PickupViewpickupviewpanelModel from './pickup-viewpickupviewpanel-pickupviewpanel-model';


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

    /**
     * 名称
     *
     * @type {string}
45
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
46
     */
ibizdev's avatar
ibizdev committed
47
    @Prop() public name?: string;
ibizdev's avatar
ibizdev committed
48 49 50 51 52

    /**
     * 视图通讯对象
     *
     * @type {Subject<ViewState>}
53
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
54
     */
ibizdev's avatar
ibizdev committed
55
    @Prop() public viewState!: Subject<ViewState>;
ibizdev's avatar
ibizdev committed
56 57 58 59 60

    /**
     * 应用上下文
     *
     * @type {*}
61
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
62
     */
ibizdev's avatar
ibizdev committed
63
    @Prop() public context: any;
ibizdev's avatar
ibizdev committed
64 65 66 67 68

    /**
     * 视图参数
     *
     * @type {*}
69
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
70
     */
ibizdev's avatar
ibizdev committed
71
    @Prop() public viewparams: any;
ibizdev's avatar
ibizdev committed
72 73 74 75

    /**
     * 视图状态事件
     *
ibizdev's avatar
ibizdev committed
76
     * @public
ibizdev's avatar
ibizdev committed
77
     * @type {(Subscription | undefined)}
78
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
79
     */
ibizdev's avatar
ibizdev committed
80
    public viewStateEvent: Subscription | undefined;
ibizdev's avatar
ibizdev committed
81 82 83 84 85

    /**
     * 获取部件类型
     *
     * @returns {string}
86
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
87
     */
ibizdev's avatar
ibizdev committed
88
    public getControlType(): string {
ibizdev's avatar
ibizdev committed
89 90 91 92 93 94 95 96 97
        return 'PICKUPVIEWPANEL'
    }



    /**
     * 建构部件服务对象
     *
     * @type {PickupViewpickupviewpanelService}
98
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
99
     */
ibizdev's avatar
ibizdev committed
100
    public service: PickupViewpickupviewpanelService = new PickupViewpickupviewpanelService({ $store: this.$store });
ibizdev's avatar
ibizdev committed
101 102 103 104 105

    /**
     * 实体服务对象
     *
     * @type {IBZDepartmentService}
106
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
107
     */
ibizdev's avatar
ibizdev committed
108
    public appEntityService: IBZDepartmentService = new IBZDepartmentService({ $store: this.$store });
ibizdev's avatar
ibizdev committed
109 110 111
    


112 113 114 115 116 117 118 119 120 121 122 123 124
    /**
     * 转化数据
     *
     * @param {any} args
     * @memberof  PickupViewpickupviewpanelBase
     */
    public transformData(args: any) {
        let _this: any = this;
        if(_this.service && _this.service.handleRequestData instanceof Function && _this.service.handleRequestData('transform',_this.context,args)){
            return _this.service.handleRequestData('transform',_this.context,args)['data'];
        }
    }

ibizdev's avatar
ibizdev committed
125 126 127 128
    /**
     * 关闭视图
     *
     * @param {any} args
129
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
130
     */
ibizdev's avatar
ibizdev committed
131
    public closeView(args: any): void {
ibizdev's avatar
ibizdev committed
132 133 134 135 136 137 138
        let _this: any = this;
        _this.$emit('closeview', [args]);
    }

    /**
     *  计数器刷新
     *
139
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
140 141 142 143 144 145 146 147 148 149 150 151
     */
    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();
                }
            })
        }
    }

152 153


ibizdev's avatar
ibizdev committed
154 155 156 157
    /**
     * 选中数据字符串
     *
     * @type {string}
158
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
159
     */
ibizdev's avatar
ibizdev committed
160
    @Prop() public selectedData?: string;
ibizdev's avatar
ibizdev committed
161 162 163 164 165

    /**
     * 获取多项数据
     *
     * @returns {any[]}
166
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
167 168 169 170 171 172 173 174 175
     */
    public getDatas(): any[] {
        return [];
    }

    /**
     * 获取单项树
     *
     * @returns {*}
176
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
177 178 179 180 181 182 183 184 185
     */
    public getData(): any {
        return {};
    }

    /**
     * 视图名称
     *
     * @type {*}
186
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
187
     */
ibizdev's avatar
ibizdev committed
188
    public view: any = {
ibizdev's avatar
ibizdev committed
189 190 191 192
        viewname: 'ibzdepartment-pickup-grid-view',
        data: {},
    }

193 194 195 196
    /**
     * 局部上下文
     *
     * @type {*}
197
     * @memberof PickupViewpickupviewpanelBase
198 199 200 201 202 203 204 205 206 207 208
     */
    public localContext: any = null;

    /**
     * 局部视图参数
     *
     * @type {*}
     * @memberof PickupViewpickupviewpanel
     */
    public localViewParam: any = null;

ibizdev's avatar
ibizdev committed
209 210 211 212
    /**
     * 视图数据
     *
     * @type {*}
213
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
214
     */
ibizdev's avatar
ibizdev committed
215
    public viewdata: string  = JSON.stringify(this.context);
ibizdev's avatar
ibizdev committed
216 217 218 219 220 221 222

    /**
     * 视图参数
     *
     * @type {*}
     * @memberof PickupViewpickupviewpanel
     */
ibizdev's avatar
ibizdev committed
223
    public viewparam: string  = JSON.stringify(this.viewparams);
ibizdev's avatar
ibizdev committed
224 225 226 227 228

    /**
     * 是否显示按钮
     *
     * @type {boolean}
229
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
230
     */
ibizdev's avatar
ibizdev committed
231
    @Prop({default: true}) public isShowButton!: boolean;
ibizdev's avatar
ibizdev committed
232 233 234 235 236

    /**
     * 是否单选
     *
     * @type {boolean}
237
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
238
     */
ibizdev's avatar
ibizdev committed
239
    @Prop() public isSingleSelect?: boolean;
ibizdev's avatar
ibizdev committed
240 241 242 243 244

    /**
     * 初始化完成
     *
     * @type {boolean}
245
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
246
     */
ibizdev's avatar
ibizdev committed
247
    public inited: boolean = false;
ibizdev's avatar
ibizdev committed
248 249 250 251 252

    /**
     * 视图数据变化
     *
     * @param {*} $event
253
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
254
     */
ibizdev's avatar
ibizdev committed
255
    public onViewDatasChange($event: any): void {
ibizdev's avatar
ibizdev committed
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
        if($event.length>0){
          $event.forEach((item:any,index:any) => {
              let srfmajortext = item['deptname'];
              if(srfmajortext){
                Object.assign($event[index],{srfmajortext: srfmajortext});
              }
          });
        }
        this.$emit('selectionchange', $event);
    }

    /**
     * 视图数据被激活
     *
     * @param {*} $event
271
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
272
     */
ibizdev's avatar
ibizdev committed
273
    public viewDatasActivated($event: any): void {
ibizdev's avatar
ibizdev committed
274 275 276 277 278 279 280
        this.$emit('activated', $event);
    }

    /**
     * 视图加载完成
     *
     * @param {*} $event
281
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
282
     */
ibizdev's avatar
ibizdev committed
283
    public onViewLoad($event: any): void {
ibizdev's avatar
ibizdev committed
284 285 286 287 288 289
        this.$emit('load', $event);
    }

    /**
     * vue 生命周期
     *
290
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
291
     */
ibizdev's avatar
ibizdev committed
292
    public created() {
ibizdev's avatar
ibizdev committed
293 294 295 296 297 298
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
299
     *  @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
300
     */    
ibizdev's avatar
ibizdev committed
301
    public afterCreated(){
302
        this.initNavParam();
ibizdev's avatar
ibizdev committed
303 304 305 306 307 308 309 310 311 312 313 314 315 316
        if (this.viewState) {
            this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
                if (!Object.is(tag, this.name)) {
                    return;
                }
                if (Object.is('load', action)) {
                    this.viewdata = JSON.stringify(this.context);
                    this.viewparam = JSON.stringify(Object.assign(data, this.viewparams));
                    this.inited = true;
                }
            });
        }
    }

317 318 319
    /**
     * 初始化导航参数
     *
320
     *  @memberof PickupViewpickupviewpanelBase
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
     */  
    public initNavParam(){
        if(this.localContext && Object.keys(this.localContext).length >0){
            let _context:any = this.$util.computedNavData({},this.context,this.viewparams,this.localContext);
            Object.assign(this.context,_context);
        }
        if(this.localViewParam && Object.keys(this.localViewParam).length >0){
            let _param:any = this.$util.computedNavData({},this.context,this.viewparams,this.localViewParam);
            Object.assign(this.viewparams,_param);
        }
        this.viewdata = JSON.stringify(this.context);
        this.viewparam = JSON.stringify(this.viewparams);
    }


ibizdev's avatar
ibizdev committed
336 337 338
    /**
     * vue 生命周期
     *
339
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
340
     */
ibizdev's avatar
ibizdev committed
341
    public destroyed() {
ibizdev's avatar
ibizdev committed
342 343 344 345 346 347
        this.afterDestroy();
    }

    /**
     * 执行destroyed后的逻辑
     *
348
     * @memberof PickupViewpickupviewpanelBase
ibizdev's avatar
ibizdev committed
349
     */
ibizdev's avatar
ibizdev committed
350
    public afterDestroy() {
ibizdev's avatar
ibizdev committed
351 352 353 354 355 356 357 358 359 360 361
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
    }

}
</script>

<style lang='less'>
@import './pickup-viewpickupviewpanel-pickupviewpanel.less';
</style>