提交 051c233a 编写于 作者: KK's avatar KK

优化日历视图代码

上级 47d66614
......@@ -449,41 +449,7 @@ import moment from 'moment';
this.evendata = {<#if ctrl.getPSSysCalendarItems()??><#list ctrl.getPSSysCalendarItems() as calendaritem><#if calendaritem.getItemType()??>${calendaritem.getItemType()?lower_case}</#if>:[],</#list></#if>}
<#if ctrl.getPSSysCalendarItems()??>
<#list ctrl.getPSSysCalendarItems() as calendaritem>
let ${calendaritem.getItemType()?lower_case}Item: Array<any> = [];
if(this.calendarItems.<#if calendaritem.getItemType()??>${calendaritem.getItemType()?lower_case}</#if>){
this.calendarItems.<#if calendaritem.getItemType()??>${calendaritem.getItemType()?lower_case}</#if>.forEach((item:any) => {
if(${calendaritem.getItemType()?lower_case}Item.length == 0){
${calendaritem.getItemType()?lower_case}Item.push({time:item.<#if calendaritem.getBeginTimePSAppDEField()?? && calendaritem.getBeginTimePSAppDEField().getName()??>${calendaritem.getBeginTimePSAppDEField().getName()?lower_case}<#else>start</#if>.substring(0, 10),evens:[item]});
}else{
${calendaritem.getItemType()?lower_case}Item.forEach((sig:any)=>{
if(sig.time.substring(0, 10) != item.<#if calendaritem.getBeginTimePSAppDEField()?? && calendaritem.getBeginTimePSAppDEField().getName()??>${calendaritem.getBeginTimePSAppDEField().getName()?lower_case}<#else>start</#if>.substring(0, 10)){
${calendaritem.getItemType()?lower_case}Item.push({time:item.<#if calendaritem.getBeginTimePSAppDEField()?? && calendaritem.getBeginTimePSAppDEField().getName()??>${calendaritem.getBeginTimePSAppDEField().getName()?lower_case}<#else>start</#if>.substring(0, 10),evens:[item]});
}
})}
if(item.<#if calendaritem.getBeginTimePSAppDEField()?? && calendaritem.getBeginTimePSAppDEField().getName()??>${calendaritem.getBeginTimePSAppDEField().getName()?lower_case}<#else>start</#if>){
Object.assign(this.eventsDate,{[item.<#if calendaritem.getBeginTimePSAppDEField()?? && calendaritem.getBeginTimePSAppDEField().getName()??>${calendaritem.getBeginTimePSAppDEField().getName()?lower_case}<#else>start</#if>.substring(0,10)]:"——"});
if (this.evendata.<#if calendaritem.getItemType()??>${calendaritem.getItemType()?lower_case}</#if>.length > 0) {
this.evendata.<#if calendaritem.getItemType()??>${calendaritem.getItemType()?lower_case}</#if>.forEach((i: any) => {
if (i.time === item.<#if calendaritem.getBeginTimePSAppDEField()?? && calendaritem.getBeginTimePSAppDEField().getName()??>${calendaritem.getBeginTimePSAppDEField().getName()?lower_case}<#else>start</#if>.substring(0, 10)) {
if (i.evens) {
i.evens.push(item);
}
} else {
this.evendata.<#if calendaritem.getItemType()??>${calendaritem.getItemType()?lower_case}</#if>.push({
time: item.<#if calendaritem.getBeginTimePSAppDEField()?? && calendaritem.getBeginTimePSAppDEField().getName()??>${calendaritem.getBeginTimePSAppDEField().getName()?lower_case}<#else>start</#if>.substring(0, 10),
evens: [item]
});
}
});
} else {
this.evendata.<#if calendaritem.getItemType()??>${calendaritem.getItemType()?lower_case}</#if>.push({
time: item.<#if calendaritem.getBeginTimePSAppDEField()?? && calendaritem.getBeginTimePSAppDEField().getName()??>${calendaritem.getBeginTimePSAppDEField().getName()?lower_case}<#else>start</#if>.substring(0, 10),
evens: [item]
});
}
}
});
}
let ${calendaritem.getItemType()?lower_case}Item :Array<any> = this.parsingData('<#if calendaritem.getItemType()??>${calendaritem.getItemType()?lower_case}</#if>','<#if calendaritem.getBeginTimePSAppDEField()?? && calendaritem.getBeginTimePSAppDEField().getName()??>${calendaritem.getBeginTimePSAppDEField().getName()?lower_case}<#else>start</#if>');
</#list>
</#if>
this.setSign(<#if ctrl.getPSSysCalendarItems()??><#list ctrl.getPSSysCalendarItems() as calendaritem><#if calendaritem.getItemType()??>${calendaritem.getItemType()?lower_case}Item</#if>,</#list></#if>);
......@@ -491,20 +457,15 @@ import moment from 'moment';
/**
* 格式化标志数据
* <#if ctrl.getPSSysCalendarItems()??><#list ctrl.getPSSysCalendarItems() as calendaritem><#if calendaritem.getPSSysCalendarItemRVs()??><#assign rvs =calendaritem.getPSSysCalendarItemRVs()/> <#list rvs as rvsitem> <#if rvsitem.getName()??>${rvsitem.getName()}</#if></#list></#if></#list></#if>
*
* @param any
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public setSign(<#if ctrl.getPSSysCalendarItems()??><#list ctrl.getPSSysCalendarItems() as calendaritem><#if calendaritem.getItemType()??>${calendaritem.getItemType()?lower_case}Item: any</#if>,</#list></#if>){
this.sign.push(<#if ctrl.getPSSysCalendarItems()??><#list ctrl.getPSSysCalendarItems() as calendaritem><#if calendaritem.getItemType()??>...${calendaritem.getItemType()?lower_case}Item</#if>,</#list></#if>);
let signData.push(<#if ctrl.getPSSysCalendarItems()??><#list ctrl.getPSSysCalendarItems() as calendaritem><#if calendaritem.getItemType()??>...${calendaritem.getItemType()?lower_case}Item</#if>,</#list></#if>);
let obj: any = {}
//去重
this.sign = this.sign.reduce((cur: any ,next: any) => {
obj[next.time] ? "" : obj[next.time] = true && cur.push(next);
return cur;
},[]);
// 格式化数据
this.sign.forEach((item:any,index:number) => {
signData.forEach((item:any,index:number) => {
if(item.time.length == 10){
let year = item.time.split('-')[0];
let month = item.time.split('-')[1];
......@@ -517,9 +478,60 @@ import moment from 'moment';
}
item.time = year+'-'+month+'-'+day;
}
if(!obj[item.time]){
Object.assign(obj,{[item.time]:item.evens})
}else{
Object.assign(obj,{[item.time]:[...obj[item.time],...item.evens]})
}
});
for (const key in obj) {
this.sign.push({time:key,evens:obj[key]});
}
}
/**
* 解析日历事件数据
*
* @protected
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public parsingData(tag:string,mark:string) :Array<any>{
let dataItem :any = [];
if(this.calendarItems[tag]){
this.calendarItems[tag].forEach((item:any) => {
if(dataItem.length == 0){
dataItem.push({time:item[mark].substring(0, 10),evens:[item]});
}else{
dataItem.forEach((sig:any)=>{
if(sig.time.substring(0, 10) != item[mark].substring(0, 10)){
dataItem.push({time:item[mark].substring(0, 10),evens:[item]});
}
})}
if(item[mark]){
if (this.evendata[tag].length > 0) {
this.evendata[tag].forEach((i: any) => {
if (i.time === item[mark].substring(0, 10)) {
if (i.evens) {
i.evens.push(item);
}
} else {
this.evendata[tag].push({
time: item[mark].substring(0, 10),
evens: [item]
});
}
});
} else {
this.evendata[tag].push({
time: item[mark].substring(0, 10),
evens: [item]
});
}
}
});
}
return dataItem;
}
/**
* 日历部件数据选择日期回调
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册