';
//清空echart容器,插入需要渲染的echart
$(".StatisticalRank .con-item").empty();
//渲染echarts dom,如果已存在,则不创建
$(str).appendTo($('.StatisticalRank').find('.con-item'));
//创建其他tab的 echart
var id = echarts.init(document.getElementById(itemId));
//渲染echart StatisticalRankOption为设置数据
//id.setOption(StatisticalRankOption);
}
var loading = layer.msg('正在提交请求,请稍候……', { icon: 16, shade: 0, time: 0 });
InitRank($(this).attr("tabid"));
if (loading && typeof (loading) != "undefined") layer.close(loading);
});
})
function FinishUserInfo() {
var loading = layer.msg('正在提交请求,请稍候……', { icon: 16, shade: 0, time: 0 });
$.ajax({
url: '/Console/Account/UserInfoCompleteOfDialog',
method: "get",
success: function (res) {
layer.open({
type: 1,
skin: 'mod-layui-layer no-scroll', //样式类名
shade: 0.6, //遮罩阴影透明度
title: '完善信息',
area: '630px',
resize: false, //是否允许拉伸,默认true
content: res,
success: function success(layero, index) {
layer.close(loading);
var $W = $('#apply-trainning-selectplan-dialog');
//取消按钮点击事件
$W.find('.cancle-btn,.close-btn').on('click', function () {
// ---- 编写回调
// ---- 编写回调 end
layer.close(index)
});
//确定按钮点击事件
$W.find('.submit-btn').on('click', function () {
// ---- 编写回调
// ---- 编写回调 end
layer.close(index)
});
}
});
}
})
}
//初始化开发仪器统计数据
function InitEquStatistics() {
var queryStr = "";
if (typeof (platformTypeXpath) != 'undefined') {
queryStr = "?typeXPath=" + platformTypeXpath + "&Xpath=" + platformOrgXpath + "&rand=000";
}
else {
queryStr = "?rand=000";
}
GetEquTotalStatistics(queryStr, function (result) {
if (result.result) {
$("#div-equStatistics dt[data-name='EquipmentCount']").text(result.data.equipmentCount)
$("#div-equStatistics dt[data-name='TotalPrice']").text(Math.round(result.data.totalPrice).toLocaleString())
$("#div-equStatistics dt[data-name='TotalUseHourLastYear']").text(Math.round(result.data.totalUseHourLastYear).toLocaleString())
}
});
}
var InitRealTimeAppointmentInfo = InitRealTimeAppointmentInfo && (typeof InitRealTimeAppointmentInfo === "function")
? InitRealTimeAppointmentInfo
: function () {
var $jObect = $('#booking');
if ($jObect.length <= 0) return;
let queryStr = "?rand=000";
GetRealTimeAppointmentData(queryStr, function (result) {
var bookinghtml = "";
$.each(result.data, function (index, value) {
bookinghtml += "
- " + htmlEscape(value.equipmentName) +
"" + value.lastAppointmentTime +
"被预约
- 该仪器已被预约" + value.appointmentTimes +
"次
"
});
$("#booking").html(bookinghtml);
//预约信息
$('#booking').carouFredSel({
auto: true,
items: 4,
direction: 'up'
});
});
}
function InitRank(type) {
var IsLogin = $("#IsLogin").val();
if (IsLogin == "false" || IsLogin == "False" || IsLogin == "FALSE") {
return false;
}
let queryStr = null;
if (typeof (platformTypeXpath) != 'undefined') {
queryStr = "?typeXPath=" + platformTypeXpath + "&Xpath=" + platformOrgXpath;
}
//渲染 统计排行
renderRankEchart({
id: "rank1",
queryStr: queryStr,
type: 1,
unit: InitData.RankEchartUnit,
days: 7,
});
}
//该为了兼容定制页面的js重写,根据js的特性按方法的加载顺序也可实现覆盖重写,目前razor页面里面太多东西了,还是简单点实现吧
var InintTrendRank = InintTrendRank && (typeof InintTrendRank === "function")
? InintTrendRank
: function () {
let queryStr = "";
if (typeof (platformTypeXpath) != 'undefined') {
queryStr = "?typeXPath=" + platformTypeXpath + "&Xpath=" + platformOrgXpath + "&rand=000";
} else {
queryStr = "?rand=000";
}
GetEquipmentUsedData(queryStr, function (result) {
var total = 0;
var dataCout = [];
var dataName = [];
$(result.data).each(function () {
var data = {};
data.value = this.value;
data.name = this.name;
dataCout.push(data);
dataName.push(this.name);
total += parseInt(this.value);
})
crateTrendRank(total, dataCout, dataName);
});
}
function CreateRank(nameArr, timesArr, rankDate, idStr) {
var positionLeft = 150; //间隔距离
var bgValue = 2500;
var subValue = bgValue - positionLeft;
var dataArray = [];
var bgValueArray = [];
var subValueArray = [];
var positionLeftArray = [];
for (var i = 1; i 0) {
var result = '{a|' + str_before + '}' + '次';
return result;
}
return val;
}
},
rich: {
a: {
color: themColorConfig.rankListText,
fontSize: 12
}
}
}
}, {
type: 'category',
axisTick: {
show: false
},
axisLine: {
show: false
},
axisLabel: {
show: true,
textStyle: {
color: 'rgba(153,153,153,.51)',
fontSize: 12
}
},
data: dataArray
}, {
type: 'category',
axisTick: {
show: false
},
axisLine: {
show: false
},
axisLabel: {
show: false
}
}, {
data: nameArr,
axisLabel: {
inside: true,
textStyle: {
color: '#666',
fontSize: 12,
lineHeight: 16,
padding: [0, 15, 0, 0]
},
align: 'center',
margin: 30,
padding: 0,
formatter: function formatter(value) {
var flag = '...';
if (value.length > 8) {
value = value.substring(0, 7);
} else {
flag = '';
}
var result = '';
for (var i = 0; i 4 && arguments[4] !== undefined ? arguments[4] : '小时';
if ($("#" + id).length \n\t\t\t\t\t\t
" + seriesTips;
});
if (params[0].axisValue.length > 1) {
return '
' + params[0].axisValue + '
' + html;
} else {
return html;
}
},
extraCssText: 'background: #fff; border-radius: 0;box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);color: #333;border-radius:6px;',
},
color: themColorConfig.useTrendColorArr,
legend: {
left: 47,
top: 24,
itemGap: 40,
itemHeight: 18,
itemWidth: 18,
icon: 'circle',
textStyle: {
color: '#666',
fontSize: '15',
lineHeight: 22,
padding: [0, 0, 0, 6]
},
data: ['使用机时', '预约机时'],
itemStyle: {
borderWidth: 5
},
// 使用回调函数
formatter: function formatter(name) {
return name + ("\uFF08" + unit + "\uFF09");
}
},
toolbox: {},
grid: {
left: '3%',
top: '20%',
right: '5%',
bottom: '10%',
containLabel: true
},
xAxis: [{
type: 'category',
boundaryGap: false,
data: TimeArr,
//设置轴线的属性
axisLine: {
lineStyle: {
color: '#E7E9EC',
width: 2 //这里是为了突出显示加上的
}
},
axisTick: {
show: false //不显示刻度
},
axisLabel: {
margin: 16,
textStyle: { //改变刻度字体样式
color: '#999',
fontSize: 16
}
}
}],
yAxis: [{
type: 'value',
axisLine: {
show: false
},
axisLabel: {
margin: 16,
textStyle: { //改变刻度字体样式
color: '#999',
fontSize: 16
}
},
axisTick: {
show: false //不显示刻度
},
splitLine: {
lineStyle: {
color: '#E7E9EC',
width: 2 //这里是为了突出显示加上的
}
}
}],
series: [{
name: '使用机时',
type: 'line',
smooth: true,
stack: '总量1',
showSymbol: false,
symbol: 'circle',
symbolSize: 12,
label: {
show: false,
position: 'top',
offset: [0, 0],
backgroundColor: 'rgba(255,255,255,1)',
padding: [5, 10],
shadowColor: 'rgba(0,0,0,.2)',
shadowBlur: 5,
borderRadius: 6,
textStyle: {
fontSize: 15,
lineHeight: 15,
// padding:[0,0,0,2],
color: themColorConfig.useTrendColorArr[0]
}
},
areaStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: themColorConfig.useTrendColorArr[0].colorRgb(0.1) }, { offset: 1, color: themColorConfig.useTrendColorArr[0].colorRgb(0.05) }]),
shadowColor: 'rgba(29,255,255, 1)',
shadowBlur: 5,
shadowOffsetY: 5
}
},
itemStyle: {
normal: {
areaStyle: { type: 'default' },
lineStyle: {
width: 3,
color: themColorConfig.useTrendColorArr[0]
},
color: '#fff',
borderColor: themColorConfig.useTrendColorArr[0],
borderWidth: 5
}
},
data: useData
}, {
name: '预约机时',
type: 'line',
smooth: true,
stack: '总量2',
showSymbol: false,
symbol: 'circle',
symbolSize: 12,
label: {
show: false,
position: 'bottom',
backgroundColor: 'rgba(255,255,255,1)',
padding: [5, 10],
shadowColor: 'rgba(0,0,0,.2)',
shadowBlur: 5,
borderRadius: 6,
textStyle: {
fontSize: 15,
lineHeight: 15,
// padding:[0,0,0,2],
color: themColorConfig.useTrendColorArr[1]
}
},
areaStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: themColorConfig.useTrendColorArr[1].colorRgb(0.5) }, { offset: 1, color: themColorConfig.useTrendColorArr[1].colorRgb(0.05) }]),
shadowColor: 'rgba(0,0,0,0.22)',
shadowBlur: 5,
shadowOffsetY: 5
}
},
itemStyle: {
normal: {
areaStyle: { type: 'default' },
lineStyle: {
width: 3,
color: themColorConfig.useTrendColorArr[1]
},
color: '#fff',
borderColor: themColorConfig.useTrendColorArr[1],
borderWidth: 5
}
},
data: bookData
}]
};
//echart 自适应配置项 20200507
window.addEventListener("resize", function () {
$('.useTrendChart').css({ "width": $('.useTrendChart').parent().width() });
echartID.resize();
});
//echart 配置项
return echartID.setOption(option);
}
var isFirstLoad = true;
function CreateChartDataByMonth(year) {
if (year == undefined || year == "") {
year = $("#year").find(".txt-1").text();
}
let queryStr = "";
if (typeof (platformTypeXpath) != 'undefined') {
queryStr = "?typeXPath=" + platformTypeXpath + "&Xpath=" + platformOrgXpath + "&rand=000";
}
else {
queryStr = "?rand=000";
}
if (!isFirstLoad)
var loading = layer.msg('正在提交请求,请稍候……', { icon: 16, shade: 0, time: 0 });
isFirstLoad = false;
GetChartDataByMonth(queryStr, year, function (result) {
if (loading && typeof (loading) != "undefined") layer.close(loading);
var YearTimeArr = []; //年份数组
var yearUseData = []; //年份使用机时模拟数据
var yearBookData = []; //年份预约机时模拟数据
$(result.data).each(function () {
var values = this.value.split(",");
yearBookData.push(values[0]);
yearUseData.push(values[1]);
YearTimeArr.push(this.name);
})
creatUseTrendEchartDefault('useTrendChart2', YearTimeArr, yearUseData, yearBookData);
});
$("#useTrendChart2").removeClass("dn");
}
function CreateChartDataByYear() {
let queryStr = "";
if (typeof (platformTypeXpath) != 'undefined') {
queryStr = "?typeXPath=" + platformTypeXpath + "&Xpath=" + platformOrgXpath + "&rand=000";
}
else {
queryStr = "?rand=000";
}
GetChartDataByYear(queryStr, function (result) {
var YearTimeArr = []; //年份数组
var yearUseData = []; //年份使用机时模拟数据
var yearBookData = []; //年份预约机时模拟数据
$("#year .year-item").html("");
$(result.data).each(function () {
var values = this.value.split(",");
yearBookData.push(values[0]);
yearUseData.push(values[1]);
YearTimeArr.push(this.name);
$("#year .year-item").prepend('
' + this.name + '
');
});
creatUseTrendEchartDefault('useTrendChart1', YearTimeArr, yearUseData, yearBookData);
});
$("#year").find(".txt-1").prop("onclick", null).off("click").click(function () {
var $yearItem = $("#year .year-item");
if ($yearItem.hasClass('dn')) {
$("#year").find(".txt-1").addClass('open');
$yearItem.removeClass('dn');
} else {
$("#year").find(".txt-1").removeClass('open');
$yearItem.addClass('dn');
}
});
$("#year .year-item").prop("onclick", null).off("click").on('click', '.txt-2', function (event) {
//取消事件冒泡
event.stopPropagation();
var txt = $(this).html();
$("#year").find(".txt-1").html(txt).removeClass('open');
$("#year .year-item").addClass('dn');
});
//点击空白处隐藏月份下拉弹出层。
$(document).click(function (event) {
var year = $("#year"); // 设置目标区域
if (!year.is(event.target) && year.has(event.target).length === 0) {
year.find(".txt-1").removeClass('open');
year.find(".year-item").addClass('dn');
}
});
}
/**
* 构造 排行echart 方法
* config.id 所需构造的echart id
* config.nameList 所需渲染对象名称数据
* config.hoursList 所需渲染对象小时数据
* config.timsList 所需渲染对象次数数据
* config.colorlist 展示柱体背景色数组,默认蓝色
* config.unit 显示单位数组
* param {Array} config.isRedirectList 所选对象是否跳转数组
* param {Array} config.unit 显示单位数组
* param {String} config.RedirectUrl 跳转拼接url
*/
function createRankEchart(config) {
if (config.id == undefined) return;
//创建echart 实例
var echartID = echarts.init(document.getElementById(config.id));
var option = createRankOption(config);
echartID.setOption(option, true);
//点击跳转代码
if (config.RedirectUrl != undefined) {
echartID.getZr().on('click', function (params) {
// 柱形图点击事件
var pointInPixel = [params.offsetX, params.offsetY];
// 判断给定的点是否在指定的坐标系
if (echartID.containPixel({ seriesIndex: [0, 1] }, pointInPixel)) {
var yIndex = echartID.convertFromPixel({ gridIndex: 0 }, [params.offsetX, params.offsetY])[1];
var clickOption = echartID.getOption();
var yAxis = clickOption.yAxis;
//排行数大于5条
if (config.idList.length > 5) {
//左
if (pointInPixel[0] 0) {
var _rankDate = [];
var _nameArr = [];
var _timesArr = [];
var idArr = []; //id数组
var isRedirectArr = []; //是否跳转数组
res.data.forEach(function (ele, index) {
//名称数组
_nameArr.push(ele.name);
//小时数组
_rankDate.push(ele.count);
//次数数组
var temp = ele.value.match(/\d+(.\d+)?/g);
_timesArr.push(temp[1]);
//id数组
idArr.push(ele.id);
//是否跳转数组
isRedirectArr.push(ele.isRedirect);
});
createRankEchart({
id: "rank" + config.type,
nameList: _nameArr, //名称数组
hoursList: _rankDate, //小时数组
timesList: _timesArr, //次数数组
unit: config.unit, //单位数组
type: config.type,
idList: idArr, //id数组
isRedirectList: isRedirectArr, //是否跳转数组
RedirectUrl: '/Portal/Equipment/Show?Id=' //跳转拼接字段
});
}
});
}
//统计排行切换操作
$('#rankNav').children().on('click', function () {
var self = this;
if ($(self).hasClass('cur') == false) {
$(self).addClass('cur').siblings('li').removeClass('cur');
// 获取tab ID
var itemId = "rank" + $(self).attr("tabid");
$(self).attr("tabid") == 3 || $(self).attr("tabid") == 4 ? $("#timeNav").hide() : $("#timeNav").show();
// 默认选中第一项
$("#timeNav .time-item").find('.txt-2:eq(0)').trigger('click');
//创建当前点击分类的echarts模板
var str = '
';
//清空echart容器,插入需要渲染的echart
$(".StatisticalRank .con-item").empty();
//渲染echarts dom,如果已存在,则不创建
$(str).appendTo($('.StatisticalRank').find('.con-item'));
let queryStr = null;
if (typeof (platformTypeXpath) != 'undefined') {
queryStr = "?typeXPath=" + platformTypeXpath + "&Xpath=" + platformOrgXpath;
}
let newdays = 7;
if ($("#timeNav").find(".txt-1").length > 0) {
newdays = parseInt($("#timeNav").find(".txt-1").html().replace('近', '').replace('天', ''));
}
renderRankEchart({
id: itemId,
queryStr: queryStr,
type: $(self).attr("tabid"),
unit: InitData.RankEchartUnit,
days: newdays,
});
}
});
如从搜索进入本页,可先确认栏目名称,再按相关阅读扩展浏览。