123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- $(".form-control").datepicker({
- format: 'yyyy-mm-dd',
- language: 'zh-CN',
- autoclose: true,
- todayBtn: 'linked'
- }).on('changeDate', function () {
- zTreeOnClick();
- }).on('keydown', function (e) {
- return false;
- });
- $("input[name='optionsRadios']").change(function (obj) {
- var str = $("input[name='optionsRadios']:checked").val();
- if (str === "0") {
- $("#day").attr("class", "tab-pane active")
- $("#days").attr("class", "tab-pane")
- }
- if (str === "1") {
- $("#day").attr("class", "tab-pane")
- $("#days").attr("class", "tab-pane active")
- }
- zTreeOnClick();
- });
- //$("input:radio:first").attr("checked", "checked");
- //$("input:radio:first").change();
- function shortcut(key) {
- if (key === -2) {
- var date = new Date();
- var d = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + (date.getDate() - 2);
- $("#date").val(d).datepicker('setDate', d);
- }
- if (key === -1) {
- var date = new Date();
- var d = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + (date.getDate() - 1);
- $("#date").val(d).datepicker('setDate', d);
- }
- if (key === 0) {
- var date = new Date();
- var d = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
- $("#date").val(d).datepicker('setDate', d);
- }
- }
- function getTOP10Faults(id, startTime, endTime) {
- $.ajax({
- url: '/Fault/GetTOP10Faults',
- type: 'GET',
- async: true,
- data: {
- "id": id,
- "startTime": startTime,
- "endTime": endTime,
- "filterString": "安全门,门禁,提示上料,提示卸料"
- },
- success: function (rev) {
- option.series = [];
- var x = [];
- var y1 = [];
- var y2 = [];
- for (var i = 0; i < rev.length; i++) {
- x.push(rev[i].faultInfo);
- y1.push(rev[i].shiftCount);
- y2.push(rev[i].nightShiftCount);
- }
- option.xAxis.data = x;
- var serie = {
- name: '白班',
- type: 'bar',
- stack: 'total',
- label: {
- show: true,
- formatter: (params) => '白班: ' + params.value + '次'
- },
- data: y1
- }
- option.series.push(serie);
- var serie1 = {
- name: '夜班',
- type: 'bar',
- stack: 'total',
- label: {
- show: true,
- formatter: (params) => '夜班: ' + params.value + '次'
- },
- data: y2
- }
- option.series.push(serie1);
- myChart.setOption(option, true);
- }
- });
- option2.series = [];
- myChart2.setOption(option2, true);
- }
- var dom = document.getElementById('container1');
- var myChart = echarts.init(dom, 'dark');
- var app = {};
- var option;
- option = {
- backgroundColor: '#001529',
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'cross',
- crossStyle: {
- color: '#999'
- }
- }
- },
- toolbox: {
- feature: {
- dataZoom: { yAxisIndex: 'none' },
- restore: {},
- saveAsImage: {}
- }
- },
- xAxis: {
- type: 'category',
- axisPointer: {
- type: 'shadow'
- },
- axisLabel: {
- interval: 0,
- rotate: 30,
- formatter: function (value) {
- if (value.length > 5) {
- return value.substring(5, 15) + "..";
- }
- return value;
- }
- }
- },
- yAxis: [
- {
- type: 'value',
- name: '次数'
- }
- ],
- series: [],
- code:[]
- };
- if (option && typeof option === 'object') {
- myChart.setOption(option);
- }
- window.addEventListener('resize', myChart.resize);
- var emphasisStyle = {
- itemStyle: {
- shadowBlur: 10,
- shadowColor: 'rgba(0,0,0,0.3)'
- }
- };
- function addSerie(name, type, data, yIndex, company) {
- var serie = {
- name: name,
- type: type,
- label: {
- show: true
- },
- yAxisIndex: yIndex,
- tooltip: {
- valueFormatter: function (value) {
- return value + company;
- }
- },
- data: data
- }
- option.series.push(serie);
- }
- function getFaultTrend(id, code, startTime, endTime) {
- $.ajax({
- url: '/Fault/GetFaultTrend',
- type: 'GET',
- async: true,
- data: {
- "id": id,
- "faultInfo": code,
- "startTime": startTime,
- "endTime": endTime
- },
- success: function (rev) {
- option2.series = [];
- for (var i = 0; i < rev.series.length; i++) {
- addSerie2(rev.series[i].name, "line", rev.series[i].data, 0, " 次");
- addSerie3("", "line", startTime, endTime);
- }
- myChart2.setOption(option2, true);
- }
- });
- }
- var dom2 = document.getElementById('container2');
- var myChart2 = echarts.init(dom2, 'dark');
- var app2 = {};
- var option2;
- option2 = {
- backgroundColor: '#001529',
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'cross',
- crossStyle: {
- color: '#999'
- }
- }
- },
- legend: {},
- toolbox: {
- feature: {
- dataZoom: { yAxisIndex: 'none' },
- restore: {},
- saveAsImage: {}
- }
- },
- xAxis: {
- type: 'category',
- axisPointer: {
- type: 'shadow'
- },
- axisLabel: {
- interval: 0,
- formatter: function (value) {
- return value.substring(0, 13)
- }
- }
- },
- yAxis: [
- {
- type: 'value',
- name: '次数'
- }
- ],
- series: []
- };
- if (option2 && typeof option === 'object') {
- myChart2.setOption(option2);
- }
- window.addEventListener('resize', myChart2.resize);
- function addSerie2(name, type, data, yIndex, company) {
- var serie = {
- name: name,
- type: type,
- label: {
- show: true
- },
- yAxisIndex: yIndex,
- tooltip: {
- valueFormatter: function (value) {
- return value + company;
- }
- },
- data: data
- }
- option2.series.push(serie);
- }
- function addSerie3(name, type, start, end) {
- var serie = {
- name: name,
- type: type,
- areaStyle: {},
- lineStyle: {
- width: 1
- },
- emphasis: {
- focus: 'series'
- },
- markArea: {
- silent: true,
- itemStyle: {
- opacity: 0.3
- },
- data: [
- [
- {
- xAxis: start
- },
- {
- //xAxis: '2009/9/22\n7:00'
- xAxis: end
- }
- ]
- ]
- }
- }
- option2.series.push(serie);
- }
- var zTreeObj;
- var setting = {
- callback: {
- onClick: zTreeOnClick
- },
- view: {
- showIcon: false
- }
- };
- $.ajax({
- url: "/ProductionLine/GetProductionLineMachineTree",
- type: "GET",
- async: true,
- success: function (zNodes) {
- zTreeObj = $.fn.zTree.init($("#productionLineTree"), setting, zNodes);
- }
- });
- function zTreeOnClick() {
- var treeNode = zTreeObj.getSelectedNodes()[0];
- if (treeNode.level === 1) {
- var str = $("input[name='optionsRadios']:checked").val();
- if (str === "0") {
- var startTime = $("#date").val();
- var endTime = $("#date").val();
- getTOP10Faults(treeNode.id, startTime, endTime);
- }
- if (str === "1") {
- var startTime = $("#date1").val();
- var endTime = $("#date2").val();
- getTOP10Faults(treeNode.id, startTime, endTime);
- }
- }
- }
- myChart.on('click', function (params) {
- //console.log(params);
- var treeNode = zTreeObj.getSelectedNodes()[0];
- if (treeNode.level === 1) {
- var str = $("input[name='optionsRadios']:checked").val();
- if (str === "0") {
- var startTime = $("#date").val();
- var endTime = $("#date").val();
- getFaultTrend(treeNode.id, params.name, startTime, endTime);
- }
- if (str === "1") {
- var startTime = $("#date1").val();
- var endTime = $("#date2").val();
- getFaultTrend(treeNode.id, params.name, startTime, endTime);
- }
- }
- });
- function getFaultTrendV1(id, code, day) {
- $.ajax({
- url: '/Fault/GetFaultTrendV1',
- type: 'GET',
- async: true,
- data: {
- "id": id,
- "faultInfo": code,
- "day": day
- },
- success: function (rev) {
- option2.series = [];
- for (var i = 0; i < rev.series.length; i++) {
- addSerie2(rev.series[i].name, "line", rev.series[i].data, 0, " 次");
- }
- myChart2.setOption(option2, true);
- }
- });
- }
|