using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.Core.SqlBuilder; using Kingdee.BOS.JSON; using Kingdee.BOS.Mobile.PlugIn; using Kingdee.BOS.Mobile.Report.ChartDataModel; using Kingdee.BOS.Orm.DataEntity; //using Kingdee.BOS.ServiceHelper; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using Kingdee.BOS.Core.Bill.PlugIn.Args; using Kingdee.BOS.App.Data; namespace YDL.CRM.App.Report { [Description("移动报表测试")] public class TestReportEdit : AbstractMobilePlugin { private DynamicObjectCollection _data; private List<int> _ids; public override void AfterCreateNewData(EventArgs e) { } public override void TableFieldRowClick(TableFieldRowClickEventArgs e) { } private void SetChartData(int row) { int id = this._ids[row]; List<decimal> data = (from t in this._data where Convert.ToInt32(t["FID"]) == id select Convert.ToDecimal(t["F_AH_Amount2"])).ToList<decimal>(); HistogramChartData histogramChartData = new HistogramChartData(); histogramChartData.title = new Title { show = true, text = "销售额", textAlign = "left", subtext = "", x = "left", y = "top" }; histogramChartData.legend = new Legend { show = false }; histogramChartData.xAxis.data = new List<string> { "一季度", "二季度", "三季度", "四季度" }; histogramChartData.xAxis.axisLabel.textStyle.color = "#6d7073"; histogramChartData.yAxis.axisLabel.textStyle.color = "#6d7073"; HistogramChartSeries histogramChartSeries = new HistogramChartSeries { name = "金额" }; histogramChartSeries.data = data; histogramChartSeries.itemStyle.normal.color = new List<string> { "#9f93f9", "#ffd16f", "#5acde0", "#fc7b5d" }; histogramChartData.series.Add(histogramChartSeries); this.Model.SetValue("F_AH_HistogramChartField", histogramChartData); } public override void ButtonClick(ButtonClickEventArgs e) { if (e.Key == "F_VTR_Refresh".ToUpper()) { base.View.ReLoadReportData("F_VTR_TableField"); SetMultiLine(); object F_VTR_TableField = this.Model.GetValue("F_VTR_TableField"); if (F_VTR_TableField != null) { string json = F_VTR_TableField.ToString(); JSONObject jobj = JSONObject.Parse(json); int count = ((JSONArray)jobj.Get("rows")).Count; SetBackColor(count); } this.View.UpdateView(); } } public override void BeforeLoadReportData(BeforeLoadReportDataEventArgs e) { base.BeforeLoadReportData(e); //增加排序条件 e.SQL += string.Format(" AND F_VTR_USEORGNAME <> '' ORDER BY F_VTR_USEORGNAME,c.FNAME"); //设置表格不同行显示不同颜色 DynamicObjectCollection datas = DBUtils.ExecuteDynamicObject(this.Context, e.SQL); SetBackColor(datas.Count); } /// <summary> /// 设置背景色 /// </summary> /// <param name="count"></param> private void SetBackColor(int count) { JSONArray array = new JSONArray(); for (int i = 0; i < count; i++) { JSONObject obj = new JSONObject(); obj.Put("row", i); if (i % 2 == 0) obj.Put("style", "background-color: yellow;"); else //obj.Put("style", "font-family: Blod;"); obj.Put("style", "background-color: red;"); array.Add(obj); } this.View.GetControl("F_VTR_TableField").SetCustomPropertyValue("TableRowStyle", array); } public override void BeforeControlSetValue(BeforeControlSetValueEventArgs e) { base.BeforeControlSetValue(e); } public override void AfterGetDevices(JSONArray e) { base.AfterGetDevices(e); } public override void AfterBindData(EventArgs e) { base.AfterBindData(e); SetMultiLine(); } /// <summary> /// 设置自动换行 /// </summary> private void SetMultiLine() { object F_VTR_TableField = this.Model.GetValue("F_VTR_TableField"); if (F_VTR_TableField != null) { string json = F_VTR_TableField.ToString(); JSONObject jobj = JSONObject.Parse(json); jobj.Put("multiLine", true);//开启自动换行 this.Model.SetValue("F_VTR_TableField", jobj.ToString()); this.View.UpdateView("F_VTR_TableField"); } } public override void LoadData(LoadDataEventArgs e) { base.LoadData(e); } public override void AfterLoadData(EventArgs e) { base.AfterLoadData(e); } } }