dashboard.js
4.1 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
define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme', 'template', 'form'], function ($, undefined, Backend, Datatable, Table, Echarts, undefined, Template, Form) {
var Controller = {
index: function () {
// 基于准备好的dom,初始化echarts实例
var myChart = Echarts.init(document.getElementById('echart'), 'walden');
option = {
tooltip: {
formatter: '{a} <br/>{b} : {c}%'
},
series: [{
name: Config.achievement.name,
type: 'gauge',
detail: {
formatter: '{value}'
},
data: [{
value: Config.achievement.complete_percent,
name: '完成率(%)'
}]
}]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
;
var team_echart = Echarts.init(document.getElementById('team_echart'), 'walden');
option.series[0].data[0].value=Config.team_achievement.complete_percent;
team_echart.setOption(option);
$(".row_config").on("change",function () {
var obj=$(this);
var idstr =obj.parent().find(".achievement_type").val();
if (idstr){
Controller.api.eventachievement(team_echart,obj);
}else{
Controller.api.eventachievement(myChart,obj);
}
});
$(".row_year,.row_month").on("blur",function () {
var obj=$(this);
var idstr =obj.parent().find(".achievement_type").val();
if (idstr){
Controller.api.eventachievement(team_echart,obj);
}else{
Controller.api.eventachievement(myChart,obj);
}
});
require.config({
paths: {
'Gzyechart': '../addons/facrm/js/gzyechart',
}
}
);
require(['Gzyechart'], function () {
Form.api.bindevent($("form[role=form]"));
// 基于准备好的dom,初始化健康表格数据
Gzyechart.echart.loadEchart("achievement", Echartdata.achievement.date, Echartdata.achievement.data);
Gzyechart.echart.loadEchart("record", Echartdata.record.date, Echartdata.record.data);
Gzyechart.echart.loadEchart("team_achievement", TeamEchartdata.team_achievement.date, TeamEchartdata.team_achievement.data);
Gzyechart.echart.loadEchart("team_record", TeamEchartdata.team_record.date, TeamEchartdata.team_record.data);
Gzyechart.echart.initButton();
$("#two").removeClass('active');
});
},
api: {
eventachievement: function (myChart,obj) {
var data={};
data["row_config"] =obj.parent().find(".row_config").val();
var idstr =obj.parent().find(".achievement_type").val();
if (idstr)idstr=idstr+"_";
//获取年份
data["row_year"] =obj.parent().find(".row_year").val();
data["row_month"] =obj.parent().find(".row_month").val();
data["ajax_type"] =idstr+'achievement';
Fast.api.ajax({
url: 'facrm/dashboard/index',
data: data
},function (data) {
option.series[0].data[0].value=data.complete_percent;
option.series[0].name=data.name;
myChart.setOption(option);
$("#"+idstr+"yeartarget").html(data.yeartarget);
$("#"+idstr+"contract_money").html(data.contract_money);
$("#"+idstr+"receivables_money").html(data.receivables_money);
return false;
});
},
}
};
return Controller;
});