<template> <div class="view-container deindexpickupdataview ibizuniproduct-index-pickup-data-view"> <card class='view-card view-no-caption view-no-toolbar' :disHover="true" :padding="0" :bordered="false"> <div class="content-container"> <view_dataview :viewState="viewState" :viewparams="viewparams" :context="context" :pViewCtx="viewCtx" :isSingleSelect="isSingleSelect" createAction="Create" removeAction="Remove" updateAction="Update" fetchAction="FetchIndexDER" :showBusyIndicator="true" @selectionchange = "dataviewDataSeletionchange" name="dataview" ref='dataview' @closeview="closeView($event)"> </view_dataview> </div> </card> </div> </template> // 基于 @VIEW/实体索引关系选择数据视图(部件视图)/VIEW-BASE.vue.ftl 生成 <script lang='tsx'> import { Vue, Component, Prop, Provide, Emit, Watch,Inject } from 'vue-property-decorator'; import { UIActionTool, Util } from '@/utils'; import axios from 'axios'; import { AppMessageBox } from '@/utils/app-message-box/app-message-box'; import NavDataService from '@/service/app/navdata-service'; import { Subject,Subscription } from 'rxjs'; import IBIZUNIProductService from '@/service/ibizuniproduct/ibizuniproduct-service'; import IBIZUNIProductAuthService from '@/authservice/ibizuniproduct/ibizuniproduct-auth-service'; import IBIZUNIProductUIService from '@/uiservice/ibizuniproduct/ibizuniproduct-ui-service'; @Component({ components: { }, }) export default class IBIZUNIProductIndexPickupDataViewBase extends Vue { /** * 实体服务对象 * * @type {IBIZUNIProductService} * @memberof IBIZUNIProductIndexPickupDataViewBase */ public appEntityService: IBIZUNIProductService = new IBIZUNIProductService(); /** * 实体UI服务对象 * * @type IBIZUNIProductUIService * @memberof IBIZUNIProductIndexPickupDataViewBase */ public appUIService: IBIZUNIProductUIService = new IBIZUNIProductUIService(); /** * 数据变化 * * @param {*} val * @returns {*} * @memberof IBIZUNIProductIndexPickupDataViewBase */ @Emit() public viewDatasChange(val: any):any { return val; } /** * 传入视图上下文 * * @type {string} * @memberof IBIZUNIProductIndexPickupDataViewBase */ @Prop() public viewdata!: string; /** * 传入视图参数 * * @type {string} * @memberof IBIZUNIProductIndexPickupDataViewBase */ @Prop() public viewparam!: string; /** * 视图默认使用 * * @type {boolean} * @memberof IBIZUNIProductIndexPickupDataViewBase */ @Prop({ default: true }) public viewDefaultUsage!: boolean; /** * 视图默认使用 * * @type {string} * @memberof IBIZUNIProductIndexPickupDataViewBase */ @Inject({from:'navModel',default: 'tab'}) public navModel!:string; /** * 视图标识 * * @type {string} * @memberof IBIZUNIProductIndexPickupDataViewBase */ public viewtag: string = '187cd0060ae45193183239145996d682'; /** * 视图类型 * * @type {string} * @memberof IBIZUNIProductIndexPickupDataViewBase */ public viewType: string = 'DEINDEXPICKUPDATAVIEW'; /** * 自定义视图导航上下文集合 * * @type {*} * @memberof IBIZUNIProductIndexPickupDataViewBase */ public customViewNavContexts:any ={ }; /** * 自定义视图导航参数集合 * * @type {*} * @memberof IBIZUNIProductIndexPickupDataViewBase */ public customViewParams:any ={ }; /** * 视图模型数据 * * @type {*} * @memberof IBIZUNIProductIndexPickupDataViewBase */ public model: any = { srfCaption: 'entities.ibizuniproduct.views.indexpickupdataview.caption', srfTitle: 'entities.ibizuniproduct.views.indexpickupdataview.title', srfSubTitle: 'entities.ibizuniproduct.views.indexpickupdataview.subtitle', dataInfo: '' } /** * 视图参数变化 * * @param {*} newVal * @param {*} oldVal * @memberof IBIZUNIProductIndexPickupDataViewBase */ @Watch('viewparam',{immediate: true, deep: true}) onParamData(newVal: any, oldVal: any) { if(newVal){ this.viewparams = {}; if(typeof newVal == 'string') { Object.assign(this.viewparams, JSON.parse(this.viewparam)); }else{ this.viewparams = Util.deepCopy(this.viewparam); } } } /** * 处理应用上下文变化 * * @param {*} newVal * @param {*} oldVal * @memberof IBIZUNIProductIndexPickupDataViewBase */ @Watch('viewdata') onViewData(newVal: any, oldVal: any) { const _this: any = this; if (!Object.is(newVal, oldVal) && _this.engine) { this.$nextTick(()=>{ _this.parseViewParam(); _this.engine.load(); }); } else if(!Object.is(newVal, oldVal) && _this.refresh && _this.refresh instanceof Function) { _this.refresh(); } } /** * 容器模型 * * @type {*} * @memberof IBIZUNIProductIndexPickupDataViewBase */ public containerModel: any = { view_dataview: { name: 'dataview', type: 'DATAVIEW' }, }; /** * 视图操作参数 * * @type {*} * @readonly * @memberof IBIZUNIProductIndexPickupDataViewBase */ public viewCtx: any = {}; /** * 视图刷新 * * @param {*} args * @memberof IBIZUNIProductIndexPickupDataViewBase */ public refresh(args?: any): void { const refs: any = this.$refs; if (refs && refs.dataview) { refs.dataview.refresh(); } } /** * 计数器刷新 * * @memberof IBIZUNIProductIndexPickupDataViewBase */ 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 IBIZUNIProductIndexPickupDataViewBase */ public viewState: Subject<ViewState> = new Subject(); /** * 引擎初始化 * * @public * @memberof IBIZUNIProductIndexPickupDataViewBase */ public engineInit(): void { } /** * 应用上下文 * * @type {*} * @memberof IBIZUNIProductIndexPickupDataViewBase */ public context:any = {}; /** * 视图参数 * * @type {*} * @memberof IBIZUNIProductIndexPickupDataViewBase */ public viewparams:any = {}; /** * 解析视图参数 * * @public * @memberof IBIZUNIProductIndexPickupDataViewBase */ public parseViewParam(): void { if (!this.viewDefaultUsage && this.viewdata && !Object.is(this.viewdata, '')) { Object.assign(this.context, JSON.parse(this.viewdata)); 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) => { if(matchArray[index + 1]){ Object.defineProperty(tempValue, item.name, { enumerable: true, value: decodeURIComponent(matchArray[index + 1]) }); } }); this.$viewTool.formatRouteParams(tempValue,this.$route,this.context,this.viewparams); //初始化视图唯一标识 Object.assign(this.context,{srfsessionid:this.$util.createUUID()}); } /** * Vue声明周期 * * @memberof IBIZUNIProductIndexPickupDataViewBase */ public created() { this.afterCreated(); } /** * 执行created后的逻辑 * * @memberof IBIZUNIProductIndexPickupDataViewBase */ public afterCreated(){ const secondtag = this.$util.createUUID(); this.$store.commit('viewaction/createdView', { viewtag: this.viewtag, secondtag: secondtag }); this.viewtag = secondtag; this.parseViewParam(); } /** * 销毁之前 * * @memberof IBIZUNIProductIndexPickupDataViewBase */ public beforeDestroy() { this.$store.commit('viewaction/removeView', this.viewtag); let _this: any = this if (_this.serviceStateEvent) { _this.serviceStateEvent.unsubscribe(); } if (_this.portletStateEvent) { _this.portletStateEvent.unsubscribe(); } if (_this.engine) { _this.engine.destroy(); } } /** * Vue声明周期(组件初始化完毕) * * @memberof IBIZUNIProductIndexPickupDataViewBase */ public mounted() { this.afterMounted(); } /** * 执行mounted后的逻辑 * * @memberof IBIZUNIProductIndexPickupDataViewBase */ public afterMounted(){ this.viewState.next({tag: 'dataview', action: 'load', data: {}}); } /** * 关闭视图 * * @param {any[]} args * @memberof IBIZUNIProductIndexPickupDataViewBase */ public closeView(args: any[]): void { let _view: any = this; if (_view.viewdata) { _view.$emit('viewdataschange', Array.isArray(args)?args:[args]); _view.$emit('close', Array.isArray(args)?args:[args]); } else if (_view.$tabPageExp) { _view.$tabPageExp.onClose(_view.$route.fullPath); } } /** * 销毁视图回调 * * @memberof IBIZUNIProductIndexPickupDataViewBase */ public destroyed(){ this.afterDestroyed(); } /** * 执行destroyed后的逻辑 * * @memberof IBIZUNIProductIndexPickupDataViewBase */ 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); } }) } } } /** * 是否单选 * * @type {boolean} * @memberof IBIZUNIProductIndexPickupDataViewBase */ public isSingleSelect: boolean = true; /** * 数据选中抛值 * * @memberof IBIZUNIProductIndexPickupDataViewBase */ public dataviewDataSeletionchange(args:any){ this.$emit('viewdataschange', [...args]); } } </script>