index.jsp
11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<%@page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="weaver.formmode.service.CubeChartsService" %>
<%@ page import="weaver.common.util.string.StringUtil" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="com.alibaba.fastjson.JSONArray" %>
<%@ include file="/page/maint/common/initNoCache.jsp"%>
<%
List<JSONObject> xList = null;//x轴字段集合
List<JSONObject> yList = null;//Y轴字段集合
String customid = Util.null2o(request.getParameter("customid"));
String type = Util.null2o(request.getParameter("type"));
request.setAttribute("customid",customid);
CubeChartsService chartsService = new CubeChartsService(request, response);
Map formFieldMap = chartsService.getFormField(request, response);
xList = (ArrayList<JSONObject>) formFieldMap.get("x");
yList = (ArrayList<JSONObject>) formFieldMap.get("y");
//查询图表数据
//基本信息
JSONObject initData = (JSONObject) chartsService.loadCharts(request,response).get("datas");
String title = Util.null2String(initData.getString("title"));
String description = Util.null2String(initData.getString("description"));
String width = Util.null2s(initData.getString("width"),"500");
String isEnable = Util.null2String(initData.getString("isenable"));
String chartId = "";
String name = "";
String chartsType = "";
String dataFrom = "";
String xAxis = "";
String yAxis = "";
String customSql = "";
String calculateType = "";
JSONArray detail = (JSONArray)initData.get("detailArray");
if(detail.size() > 0){
JSONObject detailData = (JSONObject)detail.get(0);
chartId = Util.null2String(detailData.getString("yaxis"));
name = Util.null2String(detailData.getString("name"));
chartsType = Util.null2String(detailData.getString("chartsType"));
dataFrom = Util.null2String(detailData.getString("dataFrom"));
xAxis = Util.null2String(detailData.getString("xAxis"));
yAxis = Util.null2String(detailData.getString("yAxis"));
customSql = Util.null2String(detailData.getString("customSql"));
calculateType = Util.null2String(detailData.getString("calculateType"));
}
List<Map<String, Object>> chartViewList = new ArrayList<Map<String, Object>>();//图表明细options
chartViewList = chartsService.getChartsViewData(request, response);
%>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./css/index.css">
<!--导入百度ECharts支持-->
<script type="text/javascript" src="/formmode/charts/js/echarts.min.js"></script>
<script type="text/javascript" src="/formmode/js/jquery/jquery-1.8.3.min_wev8.js"></script>
<title>charts center</title>
</head>
<body>
<%
if(!"0".equals(customid)){
%>
<%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp" %>
<%
RCMenu += "{" + SystemEnv.getHtmlLabelName(86, user.getLanguage()) + ",javascript:doSave(),_top} ";
RCMenuHeight += RCMenuHeightStep;
%>
<%@ include file="/systeminfo/RightClickMenu_wev8.jsp" %>
<input type="hidden" id="customid" value="<%=customid%>"/>
<section class="f-content">
<section class="f-config">
<div>
<div class="f-com-wrapper">
<ul>
<li class="f-plugin" data-type="LineChart">
<a>折线图</a>
</li>
<li class="f-plugin" data-type="BarChart">
<a>柱状图</a>
</li>
<li class="f-plugin" data-type="PieChart">
<a>饼图</a>
</li>
<li class="f-plugin" data-type="RoundChart">
<a>环形图</a>
</li>
</ul>
</div>
<form class="f-base-info" action="index.jsp" id="base">
<h4>基本信息</h4>
<div class="f-row">
<label>标题</label>
<div class="col">
<input type="text" id="title" data-change="Title" value="<%=title%>" class="required"/>
</div>
</div>
<div class="f-row">
<label>描述</label>
<div class="col">
<input type="text" id="description" data-change="Desc" value="<%=description%>" class="required"/>
</div>
</div>
<div class="f-row">
<label>宽度</label>
<div class="col">
<input type="range" id="width" data-change="Width" min="300" max="500" value="<%=width%>"/>
</div>
</div>
<%--<div class="f-row">
<label>样式</label>
<div class="col">
<input type="text" />
</div>
</div>--%>
<div class="f-row">
<label>默认显示</label>
<div class="col">
<select id="isEnable">
<option value="1" selected="selected">是</option>
<option value="0">否</option>
</select>
</div>
<script>
$("#isEnable").find("option[value = '<%=isEnable%>']").attr("selected","selected");
</script>
</div>
</form>
<form class="f-com-props" action="" id="detail">
<input type="hidden" id="chartId" value="<%=chartId%>">
<input type="hidden" id="chartType" value="<%=chartsType%>">
<h4>组件属性(PieChart)</h4>
<div class="f-row">
<label>标题</label>
<div class="col">
<input id="name" type="text" value="<%=name%>"/>
</div>
</div>
<%
if(!"0".equals(customid) && "1".equals(type)){
%>
<div class="f-row">
<label>数据来源</label>
<div class="col">
<select id="dataFrom" data-value="<%=dataFrom%>">
<option value="1">查询列表</option>
<option value="0">自定义SQL</option>
</select>
</div>
</div>
<div class="f-row">
<label>X轴</label>
<div class="col">
<select id="xAxis">
<option value=""></option>
<%
for (JSONObject jsonObject : xList) {
%>
<option value="<%=jsonObject.getString("id")%>"><%=jsonObject.getString("showname")%>
</option>
<%
}
%>
</select>
</div>
<script>
$("#xAxis").find("option[value = '<%=xAxis%>']").attr("selected","selected");
</script>
</div>
<div class="f-row">
<label>Y轴</label>
<div class="col">
<select id="yAxis">
<option value=""></option>
<%
for (JSONObject jsonObject : yList) {
%>
<option value="<%=jsonObject.getString("id")%>"><%=jsonObject.getString("showname")%>
</option>
<%
}
%>
</select>
</div>
<script>
$("#yAxis").find("option[value = '<%=yAxis%>']").attr("selected","selected");
</script>
</div>
<%
}
%>
<div class="f-row">
<label>自定义SQL</label>
<div class="col">
<textarea id="customSql" data-value="" value="">
<%=customSql%>
</textarea>
<div id="eg" style="text-decoration: underline;cursor:pointer;" title="">
SQL示例
</div>
<div id="variable">
</div>
</div>
</div>
<%
if(!"0".equals(customid) && "1".equals(type)){
%>
<div class="f-row">
<label>统计方式</label>
<div class="col">
<select id="calculateType" data-value="<%=calculateType%>">
<option value="1">求和</option>
<option value="2">平均数</option>
<option value="3">统计</option>
<option value="4">最大值</option>
<option value="5">最小值</option>
</select>
</div>
</div>
<%
}
%>
</form>
</div>
</section>
<div class="saveChart">保存</div>
<section class="f-viewport">
<header class="f-base-info">
<h4 class="f-title"><%=title%></h4>
<p class="f-desc"><%=description%></p>
</header>
<div class="f-com-wrapper">
<%
for (int i = 0; i < chartViewList.size(); i++) {
String op = Util.null2String(chartViewList.get(i).get("option"));
String chartsId = Util.null2String(chartViewList.get(i).get("chartsId").toString());
JSONObject opJSON = (JSONObject)(chartViewList.get(i).get("option"));
String chartName = Util.null2String(opJSON.get("name"));
%>
<div class="f-plugin<%-- selected--%>" data-type="PieChart">
<div class="f-actions">
<a>删除</a>
</div>
<div class="f-plugin-view">
<div class="chartTop">
<div class="topText"><%=chartName%></div>
</div>
<div id="<%=chartsId%>" class="chartDiv" >
</div>
</div>
</div>
<script>
var myChart = echarts.init(document.getElementById("<%=chartsId%>"));
//2.创建Oprion
var option = <%=op%>;
//3.设置Echarts的Option
myChart.setOption(option);
</script>
<%
}
%>
</div>
</section>
</section>
<script type="text/javascript" src="./js/lib/require/require.min.js"></script>
<script type="text/javascript" src="./js/config.js"></script>
<script type="text/javascript">
require(["main"]);
var width = $("#width").val();
$(".f-viewport .f-com-wrapper > .f-plugin").css('margin-right',width-500);
$(".f-content .f-viewport").css('width', width);
$(".f-content .f-viewport").css('margin-left', 0-width);
</script>
<%
}
%>
</body>
</html>