| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- /**
- * 个人工作量柱状图
- * */
- var myChart = null;
- var labelOption = {
- normal: {
- show: true,
- position: 'top',
- distance: 5,
- align: 'center',
- verticalAlign: 'middle',
- rotate: 0,
- formatter: '{c}',
- fontSize: 16,
- }
- };
- $(function() {
- $('.tool_bars').authorizeButton();
- //项目下拉
- helper.getDropList.getProlistDrop($('#sc_pro'));
- laydate.render({
- elem: '#sc_times',
- range: '~',
- theme: '#249fea',
- });
- //初始化图形
- initBars();
- //获取数据
- getBardatas();
- //搜索
- $("#sc_btns").click(function() {
- getBardatas();
- })
- });
- //初始化图形
- function initBars() {
- myChart = echarts.init(document.getElementById('workBar'));
- myChart.clear();
- myChart.showLoading();
- var option = {
- tooltip: {
- trigger: 'axis',
- },
- legend: {
- data: ['报修接单量', '巡检接单量', '保养接单量','超时工单量','汇总'],
- top: 10,
- padding: 5,
- },
- grid: {
- bottom: 200
- },
- dataZoom: [{ // 这个dataZoom组件,默认控制x轴。
- type: 'slider', // 这个 dataZoom 组件是 slider 型 dataZoom 组件
- xAxisIndex: 0,
- start: 0, // 左边在 0% 的位置。
- end: 100, // 右边在 100% 的位置。
- bottom: 100,
- }, ],
- xAxis: [{
- type: 'category',
- data: [],
- axisPointer: {
- type: 'shadow'
- },
- axisLabel: {
- interval: 0,
- rotate: 0
- }
- }],
- yAxis: [{
- type: 'value',
- name: '接单量',
- nameLocation: 'end',
- axisLabel: {
- formatter: '{value} '
- }
- }],
- series: [],
- color: ['#a1ef9f', '#66d1e8', '#32a1e8', '#f8a6ad']
- };
- myChart.setOption(option);
- }
- //获取数据
- function getBardatas() {
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "equipmentapi/api/RunningRepair/getuserworkcount",
- async: true,
- dataType: 'json',
- data: {
- projectid: $('#sc_pro').val(), // 否 string 项目id
- start: $('#sc_times').val() && $('#sc_times').val().split('~')[0], // 否 string 开始日期2018-12-13
- end: $('#sc_times').val() && $('#sc_times').val().split('~')[1] // 否 string 结束日期2018-12-13
- },
- success: function(data) {
- myChart.hideLoading();
- if (data.state.toLowerCase() == "success") {
- data = data.data;
- var xData = [];
- var repaircount = [];
- var equipmentrunningcount = [];
- var maintaincount = [];
- var timeoutcount = [];
- var totalcount = [];
- if (data && data.length > 0) {
- $('#warnTip').hide();
- $('#workBar').show();
- for (var i = 0; i < data.length; i++) {
- var res = data[i];
- // xData.push(res.username + '(' + res.usercode + ')');
- xData.push(res.username);
- repaircount.push(res.repaircount);
- equipmentrunningcount.push(res.equipmentrunningcount);
- maintaincount.push(res.maintaincount);
- timeoutcount.push(res.timeoutcount);
- totalcount.push(res.totalcount);
- }
- }else{
- $('#workBar').hide();
- $('#warnTip').show();
- }
- myChart.setOption({
- xAxis: [{
- data: xData
- }],
- series: [{
- type: 'bar',
- name: '报修接单量',
- label: labelOption,
- data: repaircount
- }, {
- type: 'bar',
- name: '巡检接单量',
- label: labelOption,
- data: equipmentrunningcount
- }, {
- type: 'bar',
- name: '保养接单量',
- label: labelOption,
- data: maintaincount
- }, {
- type: 'bar',
- name: '超时工单量',
- label: labelOption,
- data: timeoutcount
- }, {
- type: 'bar',
- name: '汇总',
- label: labelOption,
- data: totalcount
- }]
- });
- }
- }
- });
- }
|