| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- define(['jquery', 'bootstrap', 'backend', 'addtabs', 'echarts', 'echarts-theme'], function ($, undefined, Backend, undefined, Echarts) {
- var Controller = {
- index: function () {
- var procChart = null;
- var chartData = Config.procuremenChart || {};
- var chartEl = document.getElementById('procuremen-echart');
- if (chartEl) {
- procChart = Echarts.init(chartEl, 'walden');
- var labels = chartData.labels || [];
- var seriesMeta = [
- {name: '待确认', key: 'confirm', color: '#f0ad4e'},
- {name: '待审批', key: 'approval', color: '#7266ba'},
- {name: '已完结', key: 'completed', color: '#27C24C'}
- ];
- var maxVal = 0;
- seriesMeta.forEach(function (meta) {
- (chartData[meta.key] || []).forEach(function (v) {
- var n = parseInt(v, 10) || 0;
- if (n > maxVal) {
- maxVal = n;
- }
- });
- });
- procChart.setOption({
- color: seriesMeta.map(function (m) {
- return m.color;
- }),
- title: {
- text: '近7天单数',
- left: 0,
- top: 0,
- textStyle: {
- fontSize: 13,
- fontWeight: 600,
- color: '#555'
- }
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {type: 'line', lineStyle: {color: '#ddd'}},
- backgroundColor: 'rgba(50,50,50,0.92)',
- borderWidth: 0,
- textStyle: {fontSize: 12}
- },
- legend: {
- data: seriesMeta.map(function (m) {
- return m.name;
- }),
- top: 0,
- right: 0,
- itemWidth: 10,
- itemHeight: 10,
- textStyle: {fontSize: 11}
- },
- grid: {
- left: 2,
- right: 14,
- top: 36,
- bottom: 10,
- containLabel: true
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- data: labels,
- axisTick: {show: false},
- axisLabel: {
- fontSize: 11,
- color: '#888',
- margin: 4,
- interval: 0,
- showMinLabel: true,
- showMaxLabel: true,
- alignMinLabel: 'left',
- alignMaxLabel: 'right'
- },
- axisLine: {lineStyle: {color: '#e8e8e8'}}
- },
- yAxis: {
- type: 'value',
- minInterval: 1,
- min: 0,
- max: maxVal <= 1 ? 2 : null,
- splitNumber: maxVal <= 2 ? 2 : 4,
- axisLabel: {fontSize: 11, color: '#888'},
- splitLine: {lineStyle: {color: '#f0f0f0', type: 'dashed'}}
- },
- series: seriesMeta.map(function (meta) {
- return {
- name: meta.name,
- type: 'line',
- smooth: true,
- showSymbol: true,
- symbol: 'circle',
- symbolSize: function (val) {
- return (parseInt(val, 10) || 0) > 0 ? 6 : 0;
- },
- lineStyle: {width: 2, color: meta.color},
- itemStyle: {color: meta.color, borderWidth: 2, borderColor: '#fff'},
- emphasis: {focus: 'series', lineStyle: {width: 3}},
- data: chartData[meta.key] || []
- };
- })
- });
- }
- $(window).resize(function () {
- if (procChart) {
- procChart.resize();
- }
- });
- setTimeout(function () {
- if (procChart) {
- procChart.resize();
- }
- }, 120);
- setTimeout(function () {
- if (procChart) {
- procChart.resize();
- }
- }, 400);
- $(document).on('click', '.btn-refresh', function () {
- setTimeout(function () {
- if (procChart) {
- procChart.resize();
- }
- }, 0);
- });
- }
- };
- return Controller;
- });
|