Добрый день!
Столкнулся с проблемой публикации данных из секции в модуль.
В секции обьявил данный метод который публикует фильтры в другой модуль.
....
afterFiltersUpdated: function() {
this.callParent(arguments);
debugger;
var previousDate = new Date();
previousDate.setDate(previousDate.getDate() - 1);
var StartDate = "";
var StopDate = "";
var fixedFilters = this.get("SectionFiltersValue").collection.get("FixedFilters");
var customFilters = this.get("SectionFiltersValue").collection.get("CustomFilters");
StartDate = fixedFilters.PeriodFilter.startDate === null ?
Ext.Date.format(previousDate, "Y-m-d") :
typeof (fixedFilters.PeriodFilter.startDate) === "string" ?
Ext.Date.format(new Date((new Date(fixedFilters.PeriodFilter.startDate.substr(0, 10))))) :
Ext.Date.format(new Date(), "Y-m-d");
StopDate = fixedFilters.PeriodFilter.dueDate === null ?
Ext.Date.format(previousDate, "Y-m-d") :
typeof (fixedFilters.PeriodFilter.dueDate) === "string" ?
Ext.Date.format(new Date((new Date(fixedFilters.PeriodFilter.dueDate.substr(0, 10))))) :
Ext.Date.format(new Date(), "Y-m-d");
var dataSend = {
StartDate: StartDate,
StopDate: StopDate
};
this.sandbox.publish("UpdateInsurerAnalyticWidget", dataSend, ["AbInsurerAnalyticWidgetUpdated"]);
},
....
define("AbInsurerAnalyticByZoneModule", ["ext-base", "terrasoft", "sandbox", "BaseFiltersGenerateModule", "AbInsurerAnalyticByZoneModuleResources", "ChartModuleHelper", "css!AbInsurerAnalyticByZoneModuleCSS", "ServiceHelper"],
function(Ext, Terrasoft, sandbox, BaseFiltersGenerateModule, resources, ChartModuleHelper, css, ServiceHelper, ConfigurationConstants) {
function getViewModel() {
return Ext.create("Terrasoft.BaseViewModel", {
entitySchema: "AbInsurance",
methods: {
init: function() {},
getChart: function(key) {
sandbox.publish("GenerateChart", key);
},
load: function() {}
}
});
}
var result = "";
function generateMainView(renderTo) {
var resultConfig = Ext.create("Terrasoft.Container", {
id: "tableInsurerAnalyticByZoneParamContainer",
selectors: {
wrapEl: "#tableInsurerAnalyticByZoneParamContainer"
},
renderTo: renderTo
});
return resultConfig;
};
function getAnalyticByZone(parameters) {
var serviceData = {
startDate: parameters[0].toString(),
stopDate: parameters[1].toString()
};
ServiceHelper.callService("AnalyticsProcessingService", "GetAnalyticDashboardData",
function (response) {
debugger;
var htmlAdded = resources.localizableStrings.HeaderTable;
if (response.status === 404 || response.status === 500 || response.status === 400) {
Terrasoft.showErrorMessage("\t Error: \n" + response.message);
}
else if(response.GetAnalyticDashboardDataResult.length > 0){
result = response.GetAnalyticDashboardDataResult;
for(var i = 0; i < result.length; i++){
var segment = result[i].Segment;
var avgRevenue = result[i].AvgRevenue;
var salesCount = result[i].SalesCount;
var cpa = result[i].Cpa;
var sumCtr = result[i].SumCtr;
var cr = result[i].Cr;
var roas = result[i].Roas;
var tableBody = resources.localizableStrings.TableBody;
htmlAdded += Ext.String.format(tableBody,segment,avgRevenue,salesCount,cpa,sumCtr,cr,roas);
}
} else {
result = null;
}
htmlAdded += "</table>";
Ext.get("tableInsurerAnalyticByZoneParamContainer").setHTML(htmlAdded);
}, serviceData, this);
}
function getReplaceString(str, separator){
var arSt = str.split(separator);
var res = arSt[2] + separator + arSt[1] + separator + arSt[0];
while(res.indexOf(separator) > 0){
res = res.replace(separator,"-");
}
return res;
}
var render = function(renderTo) {
var viewConfig = generateMainView(renderTo);
var viewModel = getViewModel();
var getStartD = Ext.get("fixedFilterCreatedAtView-wrap").dom.innerText;
var getEndD = Ext.get("fixedFilterCreatedAtDueView-wrap").dom.innerText;
var date = new Date();
var startD = getStartD.indexOf("Начало") > 0 ? Ext.Date.format(date, "Y-m-d") : getReplaceString(getStartD, ".");
var endD = getEndD.indexOf("Завершение") > 0 ? Ext.Date.format(date, "Y-m-d") : getReplaceString(getEndD, ".");
var ar = [];
ar.push(startD);
ar.push(endD);
getAnalyticByZone(ar);
viewConfig.bind(viewModel);
};
return {
schema: "AbInsurance",
mesages: {
"UpdateInsurerAnalyticWidget": {
mode: Terrasoft.MessageMode.PTP,
direction: Terrasoft.MessageDirectionType.SUBSCRIBE
},
},
methods: {
},
userCode: function() {},
init: function() {
debugger;
sandbox.subscribe("UpdateInsurerAnalyticWidget", function(arg) {
var arArg = [];
arArg.push(arg.StartDate);
arArg.push(arg.StopDate);
getAnalyticByZone(arArg);
}, this, ["AbInsurerAnalyticWidgetUpdated"]);
},
render: render
};
}
);
в данном модуле в init сделал подписку, но она не отрабатывает при изменении фильтров.
Кто нибудь сталкивался с такой проблемой?