提交 752f3075 编写于 作者: ibizdev's avatar ibizdev

chitanda 发布系统代码

上级 3d57cefb
......@@ -116,7 +116,7 @@ export default {
},
matches(pattern, name) {
if (Array.isArray(pattern)) {
return pattern.findIndex(item => item.fullPath === name) !== -1;
return pattern.findIndex(item => item.to.fullPath === name) !== -1;
} else if (typeof pattern === 'string') {
return pattern.split(',').indexOf(name) > -1;
} else if (this.isRegExp(pattern)) {
......
<template>
<div class="ibiz-page-tag" v-if="appService.navHistory.metaList.length > 0">
<div class="ibiz-page-tag" v-if="appService.navHistory.historyList.length > 0">
<div class="move-btn move-left" @click="leftMove">
<icon type="ios-arrow-back" />
</div>
<div ref="scrollBody" class="tags-body">
<div ref="scrollChild" class="tags-container" :style="{left: styleLeft + 'px'}">
<transition-group name="tags-transition">
<template v-for="(meta, index) of appService.navHistory.metaList">
<Tag ref="tagElement" :key="index" :class="isActive(appService.navHistory.historyList[index]) ? 'tag-is-active' : ''" :name="index" closable @click.native="changePage(appService.navHistory.historyList[index])" @on-close="onClose(appService.navHistory.historyList[index])">
<template v-for="(item, index) of appService.navHistory.historyList">
<Tag ref="tagElement" :key="index" :class="isActive(item) ? 'tag-is-active' : ''" :name="index" closable @click.native="changePage(item)" @on-close="onClose(item)">
<div class="tag-text">
<div :title="getCaption(meta.caption, meta.info)" style="max-width: 300px;">
<i v-if="meta.iconCls && !Object.is(meta.iconCls, '')" :class="meta.iconCls"></i>
<img v-else :src="meta.imgPath" class="text-icon" />
&nbsp;{{getCaption(meta.caption, meta.info)}}
<div :title="getCaption(item.meta.caption, item.meta.info)" style="max-width: 300px;">
<i v-if="item.meta.iconCls && !Object.is(item.meta.iconCls, '')" :class="item.meta.iconCls"></i>
<img v-else :src="item.meta.imgPath" class="text-icon" />
&nbsp;{{getCaption(item.meta.caption, item.meta.info)}}
</div>
</div>
</Tag>
......@@ -40,6 +40,7 @@
import { Vue, Component, Provide, Prop, Watch } from 'vue-property-decorator';
import { Environment } from '../../environments/environment';
import { AppService } from '../../studio-core/service/app-service/AppService';
import { HistoryItem } from '../../studio-core/service/app-nav-history/AppNavHistoryBase';
@Component({})
export default class TabPageExp extends Vue {
......@@ -101,12 +102,12 @@ export default class TabPageExp extends Vue {
/**
* 是否选中
*
* @param {*} page
* @param {HistoryItem} item
* @returns {boolean}
* @memberof TabPageExp
*/
public isActive(page: any): boolean {
if (Object.is(page.fullPath, this.$route.fullPath)) {
public isActive(item: HistoryItem): boolean {
if (Object.is(item.to.fullPath, this.$route.fullPath)) {
return true;
}
return false;
......@@ -115,11 +116,11 @@ export default class TabPageExp extends Vue {
/**
* 关闭
*
* @param {*} page
* @param {HistoryItem} item
* @memberof TabPageExp
*/
public onClose(page: any) {
const appview = this.$store.getters['viewaction/getAppView'](this.appService.navHistory.viewTagMap.get(page.fullPath));
public onClose(item: HistoryItem) {
const appview = this.$store.getters['viewaction/getAppView'](item.tag);
if (appview && appview.viewdatachange) {
const title: any = this.$t('app.tabpage.sureclosetip.title');
const content: any = this.$t('app.tabpage.sureclosetip.content');
......@@ -127,15 +128,15 @@ export default class TabPageExp extends Vue {
title: title,
content: content,
onOk: () => {
this.appService.navHistory.remove(page);
this.gotoPage(page);
this.appService.navHistory.remove(item);
this.gotoPage(item.to);
},
onCancel: () => {
}
});
} else {
this.appService.navHistory.remove(page);
this.gotoPage(page);
this.appService.navHistory.remove(item);
this.gotoPage(item.to);
}
}
......@@ -155,11 +156,11 @@ export default class TabPageExp extends Vue {
/**
* 切换分页
*
* @param {*} page
* @param {*} item
* @memberof TabPageExp
*/
public changePage(page: any) {
this.gotoPage(page);
public changePage(item: HistoryItem) {
this.gotoPage(item.to);
}
/**
......@@ -254,7 +255,7 @@ export default class TabPageExp extends Vue {
this.appService.navHistory.reset();
this.gotoPage();
} else if (Object.is(name, 'closeOther')) {
this.appService.navHistory.removeOther(this.$route);
this.appService.navHistory.removeOther({ to: this.$route });
this.moveToView(this.$route);
}
}
......
......@@ -62,21 +62,6 @@ export default class CampaignServiceBase extends EntityService {
*/
public async Create(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let masterData:any = {};
let leadsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_leads'),'undefined')){
leadsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_leads') as any);
if(leadsData && leadsData.length && leadsData.length > 0){
leadsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.leadid = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.leads = leadsData;
let campaigncampaignsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_campaigncampaigns'),'undefined')){
campaigncampaignsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_campaigncampaigns') as any);
......@@ -107,6 +92,21 @@ export default class CampaignServiceBase extends EntityService {
}
}
masterData.campaignlists = campaignlistsData;
let leadsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_leads'),'undefined')){
leadsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_leads') as any);
if(leadsData && leadsData.length && leadsData.length > 0){
leadsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.leadid = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.leads = leadsData;
Object.assign(data,masterData);
if(!data.srffrontuf || data.srffrontuf !== "1"){
data[this.APPDEKEY] = null;
......@@ -116,9 +116,9 @@ export default class CampaignServiceBase extends EntityService {
}
let tempContext:any = JSON.parse(JSON.stringify(context));
let res:any = await Http.getInstance().post(`/campaigns`,data,isloading);
this.tempStorage.setItem(tempContext.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
this.tempStorage.setItem(tempContext.srfsessionkey+'_campaigncampaigns',JSON.stringify(res.data.campaigncampaigns));
this.tempStorage.setItem(tempContext.srfsessionkey+'_campaignlists',JSON.stringify(res.data.campaignlists));
this.tempStorage.setItem(tempContext.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
return res;
}
......@@ -133,21 +133,6 @@ export default class CampaignServiceBase extends EntityService {
*/
public async Update(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let masterData:any = {};
let leadsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_leads'),'undefined')){
leadsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_leads') as any);
if(leadsData && leadsData.length && leadsData.length > 0){
leadsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.leadid = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.leads = leadsData;
let campaigncampaignsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_campaigncampaigns'),'undefined')){
campaigncampaignsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_campaigncampaigns') as any);
......@@ -178,11 +163,26 @@ export default class CampaignServiceBase extends EntityService {
}
}
masterData.campaignlists = campaignlistsData;
let leadsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_leads'),'undefined')){
leadsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_leads') as any);
if(leadsData && leadsData.length && leadsData.length > 0){
leadsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.leadid = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.leads = leadsData;
Object.assign(data,masterData);
let res:any = await Http.getInstance().put(`/campaigns/${context.campaign}`,data,isloading);
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
this.tempStorage.setItem(context.srfsessionkey+'_campaigncampaigns',JSON.stringify(res.data.campaigncampaigns));
this.tempStorage.setItem(context.srfsessionkey+'_campaignlists',JSON.stringify(res.data.campaignlists));
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
return res;
}
......@@ -210,9 +210,9 @@ export default class CampaignServiceBase extends EntityService {
*/
public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().get(`/campaigns/${context.campaign}`,isloading);
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
this.tempStorage.setItem(context.srfsessionkey+'_campaigncampaigns',JSON.stringify(res.data.campaigncampaigns));
this.tempStorage.setItem(context.srfsessionkey+'_campaignlists',JSON.stringify(res.data.campaignlists));
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
return res;
}
......@@ -228,9 +228,9 @@ export default class CampaignServiceBase extends EntityService {
public async GetDraft(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().get(`/campaigns/getdraft`,isloading);
res.data.campaign = data.campaign;
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
this.tempStorage.setItem(context.srfsessionkey+'_campaigncampaigns',JSON.stringify(res.data.campaigncampaigns));
this.tempStorage.setItem(context.srfsessionkey+'_campaignlists',JSON.stringify(res.data.campaignlists));
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
return res;
}
......@@ -258,21 +258,6 @@ export default class CampaignServiceBase extends EntityService {
*/
public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let masterData:any = {};
let leadsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_leads'),'undefined')){
leadsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_leads') as any);
if(leadsData && leadsData.length && leadsData.length > 0){
leadsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.leadid = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.leads = leadsData;
let campaigncampaignsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_campaigncampaigns'),'undefined')){
campaigncampaignsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_campaigncampaigns') as any);
......@@ -303,11 +288,26 @@ export default class CampaignServiceBase extends EntityService {
}
}
masterData.campaignlists = campaignlistsData;
let leadsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_leads'),'undefined')){
leadsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_leads') as any);
if(leadsData && leadsData.length && leadsData.length > 0){
leadsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.leadid = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.leads = leadsData;
Object.assign(data,masterData);
let res:any = await Http.getInstance().post(`/campaigns/${context.campaign}/save`,data,isloading);
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
this.tempStorage.setItem(context.srfsessionkey+'_campaigncampaigns',JSON.stringify(res.data.campaigncampaigns));
this.tempStorage.setItem(context.srfsessionkey+'_campaignlists',JSON.stringify(res.data.campaignlists));
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
return res;
}
......
......@@ -2,6 +2,43 @@ import { Util } from '@/utils';
import { AppContextStore } from '../app-context-store/AppContextStore';
import { UIStateService } from '../UIStateService';
/**
* 历史记录项
*
* @export
* @interface HistoryItem
*/
export interface HistoryItem {
/**
* 路由信息
*
* @type {*}
* @memberof HistoryItem
*/
to?: any;
/**
* 参数信息
*
* @type {*}
* @memberof HistoryItem
*/
meta?: any;
/**
* 视图标识
*
* @type {string}
* @memberof HistoryItem
*/
tag?: string;
/**
* 上下文
*
* @type {*}
* @memberof HistoryItem
*/
context?: any;
}
/**
* 应用导航记录基类
*
......@@ -29,26 +66,10 @@ export class AppNavHistoryBase {
/**
* 路由记录缓存
*
* @type {any[]}
* @type {HistoryItem[]}
* @memberof AppNavHistoryBase
*/
public readonly historyList: any[] = [];
/**
* 参数列表
*
* @type {string[]}
* @memberof AppNavHistoryBase
*/
public readonly metaList: string[] = [];
/**
* 视图标识
*
* @type {Map<string, string>}
* @memberof AppNavHistoryBase
*/
public readonly viewTagMap: Map<string, string> = new Map();
public readonly historyList: HistoryItem[] = [];
/**
* 导航缓存,忽略判断的导航参数正则
......@@ -72,10 +93,11 @@ export class AppNavHistoryBase {
return -1;
}
return list.findIndex((item: any) => {
const to = item.to;
// 基本路径是否一致
if (Object.is(item.path, page.path)) {
if (Object.is(to.path, page.path)) {
// 历史路径是否存在参数
if (this.uiStateService.layoutState.styleMode === 'STYLE2' && item.query) {
if (this.uiStateService.layoutState.styleMode === 'STYLE2' && to.query) {
let judge: boolean = true;
// 新路径是否存在参数
if (page.query) {
......@@ -84,7 +106,7 @@ export class AppNavHistoryBase {
if (this.navIgnoreParameters.test(`|${key}|`)) {
continue;
}
if (item.query[key] === undefined || item.query[key] === null) {
if (to.query[key] === undefined || to.query[key] === null) {
judge = false;
}
}
......@@ -102,30 +124,31 @@ export class AppNavHistoryBase {
/**
* 添加视图缓存
*
* @param {*} page 当前路由信息
* @param {*} to 当前路由信息
* @memberof AppNavHistoryBase
*/
public add(page: any): void {
if (this.findHistoryIndex(page) === -1) {
if (this.uiStateService.layoutState.styleMode === 'DEFAULT' && page?.matched?.length === 1) {
public add(to: any): void {
if (this.findHistoryIndex(to) === -1) {
if (this.uiStateService.layoutState.styleMode === 'DEFAULT' && to?.matched?.length === 1) {
return;
}
this.historyList.push(page);
this.metaList.push(Util.deepCopy(page.meta));
this.historyList.push({
to,
meta: Util.deepCopy(to.meta)
});
}
}
/**
* 删除视图缓存
*
* @param {*} page
* @param {HistoryItem} item
* @memberof AppNavHistoryBase
*/
public remove(page: any): void {
const i = this.findHistoryIndex(page);
public remove(item: HistoryItem): void {
const i = this.findHistoryIndex(item.to);
if (i !== -1) {
this.historyList.splice(i, 1);
this.metaList.splice(i, 1);
}
}
......@@ -137,7 +160,6 @@ export class AppNavHistoryBase {
*/
public reset(num: number = 0): void {
this.historyList.splice(num, this.historyList.length);
this.metaList.splice(num, this.metaList.length);
}
/**
......@@ -152,8 +174,8 @@ export class AppNavHistoryBase {
if (i === -1) {
return false;
}
const meta = this.metaList[i];
Object.assign(meta, { caption, info });
const item = this.historyList[i];
Object.assign(item.meta, { caption, info });
return true;
}
......@@ -170,26 +192,23 @@ export class AppNavHistoryBase {
if (i === -1) {
return false;
}
const page = this.historyList[i];
this.viewTagMap.set(page.fullPath, tag);
const item = this.historyList[i];
item.tag = tag;
return true;
}
/**
* 删除其他缓存
*
* @param {*} page
* @param {HistoryItem} item
* @memberof AppNavHistoryBase
*/
public removeOther(page: any): void {
const i = this.findHistoryIndex(page);
public removeOther(item: HistoryItem): void {
const i = this.findHistoryIndex(item.to);
if (i !== -1) {
const page = this.historyList[i];
const meta = this.metaList[i];
this.historyList.splice(0, this.historyList.length);
this.metaList.splice(0, this.metaList.length);
this.historyList.push(page);
this.metaList.push(meta);
}
}
......@@ -200,7 +219,6 @@ export class AppNavHistoryBase {
*/
public pop(): void {
this.historyList.pop();
this.metaList.pop();
}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册