Built files from Bizgaze WebServer
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

twovalue.js 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. var Unibase;
  2. (function (Unibase) {
  3. let Themes;
  4. (function (Themes) {
  5. let Compact;
  6. (function (Compact) {
  7. let KpiWidgets;
  8. (function (KpiWidgets) {
  9. class TwoValue extends Unibase.Platform.Core.BaseComponent {
  10. jsFiles() {
  11. return [];
  12. }
  13. cssFiles() {
  14. return [];
  15. }
  16. html(id, containerid) {
  17. let title = id[0].WidgetName;
  18. let html = '<div class="card mb-0 card-sm kpi-card" id="widget_kpis_TwoValue">' +
  19. '<a href="javascript:;" class="kpi-link-report" onclick = "Unibase.Themes.Compact.KpiWidgets.TwoValue.Instance().linkReport(' + id[0].WidgetId + ',' + id[0].PortletWidgetId + ',' + "'" + containerid + "'" + ')" style = "margin-top:-20px;" > <small id="showreport_' + id[0].PortletWidgetId + '" class="font-sm-11"><span class="nav-icon-wrap"><i class="font-14 dripicons dripicons-graph-pie text-dark"></i></span></small></a>' +
  20. '<div class="card-body p-2">' +
  21. '<span class="d-block mb-10" ><span id="hf_kpi_widgetName_' + id[0].PortletWidgetId + '" data-kpi="kpi_font">' + title + '</span>' +
  22. '<span class="d-block align-items-center card-action-wrap pull-right font-11" >' +
  23. '<a href="#" class="inline-block full-screen mr-15 hidden" id="kpi_FullScreen_' + id[0].PortletWidgetId + '">' +
  24. '<i class="ion ion-md-expand"></i>' +
  25. '</a>' +
  26. '</span>' +
  27. '<span id="config_widget_' + id[0].PortletWidgetId + '"></span>' +
  28. '</span>' +
  29. '<div class="pull-right" style="margin-top:-10px;"><div id="span_kpi_icon_' + id[0].PortletWidgetId + '" ></div></div>' +
  30. '<span class="d-block display-7" style="font-weight:400;font-size:20px;" id="kpi_Twovalue_1_' + id[0].PortletWidgetId + '">000000</span>' +
  31. '<small id="kpi_Twovalue_2_' + id[0].PortletWidgetId + '">000</small><br>' +
  32. '</div>' +
  33. '</div>';
  34. return html;
  35. }
  36. load(id, containerid, callback) {
  37. let instance = this;
  38. let inputparameters = Unibase.Themes.Providers.DashboardHelper.Instance().replaceWidgetParameterValues(id[0].WidgetParameters, id[0].InstalledAppId);
  39. let fromDate = "", toDate = "";
  40. var cf_fromDate = Unibase.Platform.Membership.Infos.Identity.currentUser.fromDate;
  41. var cf_toDate = Unibase.Platform.Membership.Infos.Identity.currentUser.toDate;
  42. if (cf_fromDate != null && cf_toDate != null) {
  43. fromDate = cf_fromDate.toString();
  44. toDate = cf_toDate.toString();
  45. }
  46. else {
  47. fromDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(new Date(Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate()), "YYYY/MM/DD");
  48. toDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(new Date(Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate()), "YYYY/MM/DD");
  49. }
  50. var parameters = {
  51. WidgetId: id[0].WidgetId,
  52. PortletWidgetId: id[0].PortletWidgetId,
  53. InstalledAppId: id[0].InstalledAppId,
  54. InputParameters: inputparameters,
  55. FromDate: fromDate,
  56. ToDate: toDate
  57. };
  58. instance.loadResponseData(id[0].PortletWidgetId, containerid, parameters);
  59. }
  60. loadResponseData(portletwidgetid, detailContainer, parameters) {
  61. let instance = this;
  62. instance.inputParameters = parameters.InputParameters;
  63. Unibase.Platform.Widgets.Managers.WidgetManager.Instance().getKpiWidgetData(parameters).then(function (response) {
  64. instance.loadData(portletwidgetid, detailContainer, parameters, false, response);
  65. });
  66. }
  67. loadData(portletwidgetid, detailcontainer, parameters, IsPreview, response) {
  68. detailcontainer = '.' + detailcontainer;
  69. var post = response.result;
  70. if (post != null) {
  71. if (post.IsMaximize == true) {
  72. $("#kpi_FullScreen_" + portletwidgetid).removeClass("hidden");
  73. }
  74. if (post.Data == null || post.Data == "" || post.Data == '[]') {
  75. $(detailcontainer).find("#kpi_Twovalue_1_" + portletwidgetid).removeClass('display-6');
  76. $(detailcontainer).find("#kpi_Twovalue_1_" + portletwidgetid).addClass('display-8');
  77. $(detailcontainer).find("#kpi_Twovalue_1_" + portletwidgetid).text("No Data");
  78. }
  79. else {
  80. var data = JSON.parse(post.Data)[0];
  81. var selected_values = post.Selected_Columns;
  82. if (selected_values != null) {
  83. var sp = selected_values.split(',');
  84. var column1 = sp[0];
  85. var column2 = sp[1];
  86. }
  87. var Value_1 = data[column1];
  88. var Value_2 = data[column2];
  89. if (isNaN(Value_1)) {
  90. }
  91. else {
  92. Value_1 = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Value_1, 2);
  93. }
  94. $(detailcontainer).find("#kpi_Twovalue_1_" + portletwidgetid).text(Value_1);
  95. $(detailcontainer).find("#kpi_Twovalue_2_" + portletwidgetid).text(Value_2);
  96. if (post.Icon != "" || post.Icon != null) {
  97. let iconhtml = '<img id="kpi_icon_' + portletwidgetid + '"src="' + post.Icon + '" style="width:50px;"/>';
  98. $("#span_kpi_icon_" + portletwidgetid).html(iconhtml);
  99. }
  100. }
  101. var color = post.Color;
  102. if (post.Color != "" && post.Color != null) {
  103. $(detailcontainer).find("#kpi_Twovalue_1_" + portletwidgetid).addClass("text-" + color);
  104. }
  105. var colors = ["primary", "success", "warning", "danger", "info", "light", "secondary", "dark"];
  106. if (response.result.AppConfigurations != null) {
  107. if (response.result.AppConfigurations.length != 0) {
  108. var designhtml = "";
  109. var appconfig = response.result.AppConfigurations;
  110. for (var i = 0; i < appconfig.length; i++) {
  111. var onlickurl = "";
  112. var sname = appconfig[i].SettingName.replace(/ /g, '');
  113. designhtml += ' <span class="mr-10"><a href="javascript:;" id="widgetconfig_' + sname + '" onclick="' + onlickurl + '">' +
  114. '<button class="btn btn-sm btn-' + colors[i] + ' pull-right btn-rounded text-white">' + appconfig[i].SettingName + '</button>' +
  115. '</a> </span>';
  116. }
  117. designhtml += "</div>";
  118. $(detailcontainer).find("#config_widget_" + portletwidgetid).html(designhtml);
  119. }
  120. }
  121. if (response.result.ReportId == 0 || response.result.ReportId == null) {
  122. $(detailcontainer).find("#showreport_" + portletwidgetid).addClass("hidden");
  123. }
  124. if (post.LinkReportId != 0 && post.LinkReportId != null) {
  125. }
  126. else {
  127. $(detailcontainer).find("#showreport_" + portletwidgetid).addClass('hidden');
  128. }
  129. }
  130. $(detailcontainer).siblings('.line-loader').remove();
  131. $(detailcontainer).removeClass('hidden');
  132. }
  133. linkReport(widgetid, portletwidgetid, containerid) {
  134. var instance = this;
  135. Unibase.Platform.Widgets.Managers.WidgetManager.Instance().getKPIWidget(widgetid).then(function (response) {
  136. var res = response.result;
  137. if (res != null) {
  138. let containerid = "div_kpireport_" + portletwidgetid;
  139. var rv_obj = Unibase.Platform.Analytics.Components.ReportViewer.Instance();
  140. instance.navigationHelper.popup(res.LinkReportId, containerid, rv_obj, null, Unibase.Platform.Helpers.Size.ExtraLarge);
  141. }
  142. });
  143. }
  144. static Instance() {
  145. if (this.instance === null || this.instance === undefined)
  146. this.instance = new TwoValue();
  147. return this.instance;
  148. }
  149. }
  150. KpiWidgets.TwoValue = TwoValue;
  151. })(KpiWidgets = Compact.KpiWidgets || (Compact.KpiWidgets = {}));
  152. })(Compact = Themes.Compact || (Themes.Compact = {}));
  153. })(Themes = Unibase.Themes || (Unibase.Themes = {}));
  154. })(Unibase || (Unibase = {}));