import { Subject } from 'rxjs'; import { GridViewBase } from '@/studio-core'; import CampaignService from '@/service/campaign/campaign-service'; import GridViewEngine from '@engine/view/grid-view-engine'; import CampaignUIService from '@/uiservice/campaign/campaign-ui-service'; import CodeListService from "@service/app/codelist-service"; /** * 市场活动信息视图基类 * * @export * @class CampaignGridViewBase * @extends {GridViewBase} */ export class CampaignGridViewBase extends GridViewBase { /** * 视图对应应用实体名称 * * @protected * @type {string} * @memberof CampaignGridViewBase */ protected appDeName: string = 'campaign'; /** * 应用实体主键 * * @protected * @type {string} * @memberof CampaignGridViewBase */ protected appDeKey: string = 'campaignid'; /** * 应用实体主信息 * * @protected * @type {string} * @memberof CampaignGridViewBase */ protected appDeMajor: string = 'campaignname'; /** * 实体服务对象 * * @type {CampaignService} * @memberof CampaignGridViewBase */ protected appEntityService: CampaignService = new CampaignService; /** * 计数器服务对象集合 * * @protected * @type {Array<*>} * @memberof CampaignGridViewBase */ protected counterServiceArray: Array<any> = []; /** * 视图模型数据 * * @protected * @type {*} * @memberof CampaignGridViewBase */ protected model: any = { srfCaption: 'entities.campaign.views.gridview.caption', srfTitle: 'entities.campaign.views.gridview.title', srfSubTitle: 'entities.campaign.views.gridview.subtitle', dataInfo: '' } /** * 容器模型 * * @protected * @type {*} * @memberof CampaignGridViewBase */ protected containerModel: any = { view_toolbar: { name: 'toolbar', type: 'TOOLBAR' }, view_grid: { name: 'grid', type: 'GRID' }, view_searchform: { name: 'searchform', type: 'SEARCHFORM' }, }; /** * 工具栏模型 * * @type {*} * @memberof CampaignGridView */ public toolBarModels: any = { tbitem1_openquickcreateview: { name: 'tbitem1_openquickcreateview', caption: '新建','isShowCaption':true,'isShowIcon':true, tooltip: '新建', iconcls: 'fa fa-user-plus', icon: '', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'OpenQuickCreateView', target: 'NONE' }, class: '' }, tbitem2: { name: 'tbitem2', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } }, tbitem4: { name: 'tbitem4', caption: '编辑','isShowCaption':true,'isShowIcon':true, tooltip: '编辑', iconcls: 'fa fa-edit', icon: '', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'Edit', target: 'SINGLEKEY' }, class: '' }, tbitem6: { name: 'tbitem6', caption: '拷贝','isShowCaption':true,'isShowIcon':true, tooltip: '拷贝', iconcls: 'fa fa-copy', icon: '', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'Copy', target: 'SINGLEKEY' }, class: '' }, tbitem7: { name: 'tbitem7', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } }, tbitem8: { name: 'tbitem8', caption: '删除','isShowCaption':true,'isShowIcon':true, tooltip: '删除', iconcls: 'fa fa-remove', icon: '', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'Remove', target: 'MULTIKEY' }, class: '' }, tbitem9: { name: 'tbitem9', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } }, tbitem13: { name: 'tbitem13', caption: '导出','isShowCaption':true,'isShowIcon':true, tooltip: '导出', iconcls: 'fa fa-file-excel-o', icon: '', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'ExportExcel', target: '' }, MaxRowCount: 1000, class: '' }, tbitem10: { name: 'tbitem10', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { } }, tbitem19: { name: 'tbitem19', caption: '过滤','isShowCaption':true,'isShowIcon':true, tooltip: '过滤', iconcls: 'fa fa-filter', icon: '', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'ToggleFilter', target: '' }, class: '' }, }; /** * 视图唯一标识 * * @protected * @type {string} * @memberof ViewBase */ protected viewtag: string = '07c5035fbb847e889f3dbb9657723f30'; /** * 视图引擎 * * @public * @type {Engine} * @memberof CampaignGridViewBase */ public engine: GridViewEngine = new GridViewEngine(); /** * 引擎初始化 * * @public * @memberof CampaignGridViewBase */ public engineInit(): void { this.engine.init({ view: this, opendata: (args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) => { this.opendata(args,fullargs, params, $event, xData); }, newdata: (args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) => { this.newdata(args,fullargs, params, $event, xData); }, grid: this.$refs.grid, searchform: this.$refs.searchform, keyPSDEField: 'campaign', majorPSDEField: 'campaignname', isLoadDefault: true, }); } /** * toolbar 部件 click 事件 * * @param {*} [args={}] * @param {*} $event * @memberof CampaignGridViewBase */ public toolbar_click($event: any, $event2?: any): void { if (Object.is($event.tag, 'tbitem1_openquickcreateview')) { this.toolbar_tbitem1_openquickcreateview_click(null, '', $event2); } if (Object.is($event.tag, 'tbitem4')) { this.toolbar_tbitem4_click(null, '', $event2); } if (Object.is($event.tag, 'tbitem6')) { this.toolbar_tbitem6_click(null, '', $event2); } if (Object.is($event.tag, 'tbitem8')) { this.toolbar_tbitem8_click(null, '', $event2); } if (Object.is($event.tag, 'tbitem13')) { this.toolbar_tbitem13_click(null, '', $event2); } if (Object.is($event.tag, 'tbitem11')) { this.toolbar_tbitem11_click(null, '', $event2); } if (Object.is($event.tag, 'tbitem19')) { this.toolbar_tbitem19_click(null, '', $event2); } } /** * grid 部件 selectionchange 事件 * * @param {*} [args={}] * @param {*} $event * @memberof CampaignGridViewBase */ public grid_selectionchange($event: any, $event2?: any): void { this.engine.onCtrlEvent('grid', 'selectionchange', $event); } /** * grid 部件 beforeload 事件 * * @param {*} [args={}] * @param {*} $event * @memberof CampaignGridViewBase */ public grid_beforeload($event: any, $event2?: any): void { this.engine.onCtrlEvent('grid', 'beforeload', $event); } /** * grid 部件 rowdblclick 事件 * * @param {*} [args={}] * @param {*} $event * @memberof CampaignGridViewBase */ public grid_rowdblclick($event: any, $event2?: any): void { this.engine.onCtrlEvent('grid', 'rowdblclick', $event); } /** * grid 部件 remove 事件 * * @param {*} [args={}] * @param {*} $event * @memberof CampaignGridViewBase */ public grid_remove($event: any, $event2?: any): void { this.engine.onCtrlEvent('grid', 'remove', $event); } /** * grid 部件 load 事件 * * @param {*} [args={}] * @param {*} $event * @memberof CampaignGridViewBase */ public grid_load($event: any, $event2?: any): void { this.engine.onCtrlEvent('grid', 'load', $event); } /** * searchform 部件 save 事件 * * @param {*} [args={}] * @param {*} $event * @memberof CampaignGridViewBase */ public searchform_save($event: any, $event2?: any): void { this.engine.onCtrlEvent('searchform', 'save', $event); } /** * searchform 部件 search 事件 * * @param {*} [args={}] * @param {*} $event * @memberof CampaignGridViewBase */ public searchform_search($event: any, $event2?: any): void { this.engine.onCtrlEvent('searchform', 'search', $event); } /** * searchform 部件 load 事件 * * @param {*} [args={}] * @param {*} $event * @memberof CampaignGridViewBase */ public searchform_load($event: any, $event2?: any): void { this.engine.onCtrlEvent('searchform', 'load', $event); } /** * 逻辑事件 * * @param {*} [params={}] * @param {*} [tag] * @param {*} [$event] * @memberof */ public toolbar_tbitem1_openquickcreateview_click(params: any = {}, tag?: any, $event?: any) { // 参数 // 取数 let datas: any[] = []; let xData: any = null; // _this 指向容器对象 const _this: any = this; let paramJO:any = {}; let contextJO:any = {}; xData = this.$refs.grid; if (xData.getDatas && xData.getDatas instanceof Function) { datas = [...xData.getDatas()]; } if(params){ datas = [params]; } // 界面行为 const curUIService:CampaignUIService = new CampaignUIService(); curUIService.Campaign_OpenQuickCreateView(datas,contextJO, paramJO, $event, xData,this,"Campaign"); } /** * 逻辑事件 * * @param {*} [params={}] * @param {*} [tag] * @param {*} [$event] * @memberof */ public toolbar_tbitem4_click(params: any = {}, tag?: any, $event?: any) { // 参数 // 取数 let datas: any[] = []; let xData: any = null; // _this 指向容器对象 const _this: any = this; let paramJO:any = {}; let contextJO:any = {}; xData = this.$refs.grid; if (xData.getDatas && xData.getDatas instanceof Function) { datas = [...xData.getDatas()]; } if(params){ datas = [params]; } // 界面行为 this.Edit(datas, contextJO,paramJO, $event, xData,this,"Campaign"); } /** * 逻辑事件 * * @param {*} [params={}] * @param {*} [tag] * @param {*} [$event] * @memberof */ public toolbar_tbitem6_click(params: any = {}, tag?: any, $event?: any) { // 参数 // 取数 let datas: any[] = []; let xData: any = null; // _this 指向容器对象 const _this: any = this; let paramJO:any = {}; let contextJO:any = {}; xData = this.$refs.grid; if (xData.getDatas && xData.getDatas instanceof Function) { datas = [...xData.getDatas()]; } if(params){ datas = [params]; } // 界面行为 this.Copy(datas, contextJO,paramJO, $event, xData,this,"Campaign"); } /** * 逻辑事件 * * @param {*} [params={}] * @param {*} [tag] * @param {*} [$event] * @memberof */ public toolbar_tbitem8_click(params: any = {}, tag?: any, $event?: any) { // 参数 // 取数 let datas: any[] = []; let xData: any = null; // _this 指向容器对象 const _this: any = this; let paramJO:any = {}; let contextJO:any = {}; xData = this.$refs.grid; if (xData.getDatas && xData.getDatas instanceof Function) { datas = [...xData.getDatas()]; } if(params){ datas = [params]; } // 界面行为 this.Remove(datas, contextJO,paramJO, $event, xData,this,"Campaign"); } /** * 逻辑事件 * * @param {*} [params={}] * @param {*} [tag] * @param {*} [$event] * @memberof */ public toolbar_tbitem13_click(params: any = {}, tag?: any, $event?: any) { // 参数 // 取数 let datas: any[] = []; let xData: any = null; // _this 指向容器对象 const _this: any = this; let paramJO:any = {}; let contextJO:any = {}; xData = this.$refs.grid; if (xData.getDatas && xData.getDatas instanceof Function) { datas = [...xData.getDatas()]; } if(params){ datas = [params]; } // 界面行为 this.ExportExcel(datas, contextJO,paramJO, $event, xData,this,"Campaign"); } /** * 逻辑事件 * * @param {*} [params={}] * @param {*} [tag] * @param {*} [$event] * @memberof */ public toolbar_tbitem11_click(params: any = {}, tag?: any, $event?: any) { // 参数 // 取数 let datas: any[] = []; let xData: any = null; // _this 指向容器对象 const _this: any = this; let paramJO:any = {}; let contextJO:any = {}; xData = this.$refs.grid; if (xData.getDatas && xData.getDatas instanceof Function) { datas = [...xData.getDatas()]; } if(params){ datas = [params]; } // 界面行为 this.Print(datas, contextJO,paramJO, $event, xData,this,"Campaign"); } /** * 逻辑事件 * * @param {*} [params={}] * @param {*} [tag] * @param {*} [$event] * @memberof */ public toolbar_tbitem19_click(params: any = {}, tag?: any, $event?: any) { // 参数 // 取数 let datas: any[] = []; let xData: any = null; // _this 指向容器对象 const _this: any = this; let paramJO:any = {}; let contextJO:any = {}; xData = this.$refs.grid; if (xData.getDatas && xData.getDatas instanceof Function) { datas = [...xData.getDatas()]; } if(params){ datas = [params]; } // 界面行为 this.ToggleFilter(datas, contextJO,paramJO, $event, xData,this,"Campaign"); } /** * 打开新建数据视图 * * @param {any[]} args * @param {*} [params] * @param {*} [fullargs] * @param {*} [$event] * @param {*} [xData] * @memberof CampaignGridView */ public newdata(args: any[],fullargs?:any[], params?: any, $event?: any, xData?: any) { let localContext:any = null; let localViewParam:any =null; const data: any = {}; if(args[0].srfsourcekey){ data.srfsourcekey = args[0].srfsourcekey; } let tempContext = JSON.parse(JSON.stringify(this.context)); delete tempContext.campaign; if(args.length >0){ Object.assign(tempContext,args[0]); } const deResParameters: any[] = []; const parameters: any[] = [ { pathName: 'campaigns', parameterName: 'campaign' }, ]; const _this: any = this; const openDrawer = (view: any, data: any) => { let container: Subject<any> = this.$appdrawer.openDrawer(view, tempContext, data); container.subscribe((result: any) => { if (!result || !Object.is(result.ret, 'OK')) { return; } if (!xData || !(xData.refresh instanceof Function)) { return; } xData.refresh(result.datas); }); } const view: any = { viewname: 'campaign-quick-create-view', height: 0, width: 0, title: this.$t('entities.campaign.views.quickcreateview.title'), placement: 'DRAWER_RIGHT', }; openDrawer(view, data); } /** * 打开编辑数据视图 * * @param {any[]} args * @param {*} [params] * @param {*} [fullargs] * @param {*} [$event] * @param {*} [xData] * @memberof CampaignGridView */ public opendata(args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) { let localContext:any = null; let localViewParam:any =null; const data: any = {}; let tempContext = JSON.parse(JSON.stringify(this.context)); if(args.length >0){ Object.assign(tempContext,args[0]); } const deResParameters: any[] = []; const parameters: any[] = [ { pathName: 'campaigns', parameterName: 'campaign' }, { pathName: 'info', parameterName: 'info' }, ]; const _this: any = this; const openIndexViewTab = (data: any) => { const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, deResParameters, parameters, args, data); this.$router.push(routePath); } openIndexViewTab(data); } /** * 编辑 * * @param {any[]} args 当前数据 * @param {any} contextJO 行为附加上下文 * @param {*} [params] 附加参数 * @param {*} [$event] 事件源 * @param {*} [xData] 执行行为所需当前部件 * @param {*} [actionContext] 执行行为上下文 * @memberof CampaignGridViewBase */ public Edit(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) { if (args.length === 0) { return; } const _this: any = this; if (_this.opendata && _this.opendata instanceof Function) { const data: any = { }; if (args.length > 0) { Object.assign(data, { campaign: args[0].campaign }) } _this.opendata([{ ...data }], params, $event, xData); } else { _this.$Notice.error({ title: '错误', desc: 'opendata 视图处理逻辑不存在,请添加!' }); } } /** * 拷贝 * * @param {any[]} args 当前数据 * @param {any} contextJO 行为附加上下文 * @param {*} [params] 附加参数 * @param {*} [$event] 事件源 * @param {*} [xData] 执行行为所需当前部件 * @param {*} [actionContext] 执行行为上下文 * @memberof CampaignGridViewBase */ public Copy(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) { if (args.length === 0) { return; } const _this: any = this; if (_this.newdata && _this.newdata instanceof Function) { const data: any = {}; if (args.length > 0) { Object.assign(data, { srfsourcekey: args[0].srfkey }) actionContext.$store.commit('addCopyData', { srfkey: args[0].srfkey, copyData: args[0] }); } _this.newdata([{ ...data }],[{ ...data }],params, $event, xData); } else if (xData && xData.copy instanceof Function) { if (args.length > 0) { actionContext.$store.commit('addCopyData', { srfkey: args[0].srfkey, copyData: args[0] }); } xData.copy(args[0].srfkey); } else { _this.$Notice.error({ title: '错误', desc: 'opendata 视图处理逻辑不存在,请添加!' }); } } /** * 删除 * * @param {any[]} args 当前数据 * @param {any} contextJO 行为附加上下文 * @param {*} [params] 附加参数 * @param {*} [$event] 事件源 * @param {*} [xData] 执行行为所需当前部件 * @param {*} [actionContext] 执行行为上下文 * @memberof CampaignGridViewBase */ public Remove(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) { const _this: any = this; if (!xData || !(xData.remove instanceof Function)) { return ; } xData.remove(args); } /** * 导出 * * @param {any[]} args 当前数据 * @param {any} contextJO 行为附加上下文 * @param {*} [params] 附加参数 * @param {*} [$event] 事件源 * @param {*} [xData] 执行行为所需当前部件 * @param {*} [actionContext] 执行行为上下文 * @memberof CampaignGridViewBase */ public ExportExcel(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) { const _this: any = this; if (!xData || !(xData.exportExcel instanceof Function) || !$event) { return ; } xData.exportExcel($event.exportparms); } /** * 打印 * * @param {any[]} args 当前数据 * @param {any} contextJO 行为附加上下文 * @param {*} [params] 附加参数 * @param {*} [$event] 事件源 * @param {*} [xData] 执行行为所需当前部件 * @param {*} [actionContext] 执行行为上下文 * @memberof CampaignGridViewBase */ public Print(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) { let _this:any = this; if (!xData || !(xData.print instanceof Function) || !$event) { return ; } xData.print(); } /** * 过滤 * * @param {any[]} args 当前数据 * @param {any} contextJO 行为附加上下文 * @param {*} [params] 附加参数 * @param {*} [$event] 事件源 * @param {*} [xData] 执行行为所需当前部件 * @param {*} [actionContext] 执行行为上下文 * @memberof CampaignGridViewBase */ public ToggleFilter(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) { const _this: any = this; if (_this.hasOwnProperty('isExpandSearchForm')) { _this.isExpandSearchForm = !_this.isExpandSearchForm; } } }