$(function () {
let time = "all"
let c1_xueduan = "0"
let l1_xueduan = "0"
let l1_type = 1
// c1 学校主题活动开展情况监测
//学段切换
$('#l1_xueduan').on('change', function () {
l1_xueduan = $(this).val() + ""
l1(l1_xueduan, time, l1_type);
})
// 时间切换
$('body').on('click', '#switch_month', function (e) {
time = "day";
$('.switch-time a').removeClass('act')
$('#switch_month').addClass("act")
l1(l1_xueduan, time, l1_type);
})
// 人数、次数切换
$('body').on('click', '#switch_year', function (e) {
time = "month"
$('.switch-time a').removeClass('act')
$('#switch_year').addClass("act")
l1(l1_xueduan, time, l1_type);
})
$('body').on('click', '#switch_all', function (e) {
time = "all"
$('.switch-time a').removeClass('act')
$('#switch_all').addClass("act")
l1(l1_xueduan, time, l1_type);
})
$('body').on('click', '#switch_l1type1', function (e) {
l1_type = 1
$('#switch_l1type2').removeClass('subact')
$('#switch_l1type1').addClass("subact")
l1(l1_xueduan, time, l1_type);
})
$('body').on('click', '#switch_l1type2', function (e) {
l1_type = 2
$('#switch_l1type1').removeClass('subact')
$('#switch_l1type2').addClass("subact")
l1(l1_xueduan, time, l1_type);
})
l1(l1_xueduan, time, l1_type);
function l1(xueduan, time, type) {
$("#x-table").html("
loading...
")
query_count = ["total"]
if (time === "all") {
if (type == 1) {
query_id1 = "stage_school_res_const_type_num_all"
query_id2 = "stage_school_res_const_num_all"
} else if (type == 2) {
query_id1 = "stage_school_res_use_type_num_all"
query_id2 = "stage_school_res_use_num_all"
query_count = ["total_upload", "total_down", "total_share", "total_recommend"]
}
xueduan1 = [xueduan, xueduan, xueduan, xueduan]
xueduan2 = [xueduan, xueduan]
} else if (time === "month") {
if (type == 1) {
query_id1 = "stage_school_res_const_type_num_month"
query_id2 = "stage_school_res_const_num_month"
} else if (type == 2) {
query_id1 = "stage_school_res_use_type_num_month"
query_id2 = "stage_school_res_use_num_month"
query_count = ["total_upload", "total_down", "total_share", "total_recommend"]
}
xueduan1 = [xueduan, xueduan, nowYear, xueduan, xueduan, nowYear]
xueduan2 = [xueduan, xueduan, nowYear]
} else if (time === "day") {
if (type == 1) {
query_id1 = "stage_school_res_const_type_num_day"
query_id2 = "stage_school_res_const_num_day"
} else if (type == 2) {
query_id1 = "stage_school_res_use_type_num_day"
query_id2 = "stage_school_res_use_num_day"
query_count = ["total_upload", "total_down", "total_share", "total_recommend"]
}
xueduan1 = [xueduan, xueduan, nowYear, nowMonth, xueduan, xueduan, nowYear, nowMonth]
xueduan2 = [xueduan, xueduan, nowYear, nowMonth]
}
axios.all([
axios({
...axiosConf,
data: {
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": query_id1,
"query_param": xueduan1
},
"query_cache": 0,
"query_count": query_count,
"query_format": "json",
"query_group": [
"org_name", "topic_name"
]
}
}),
axios({
...axiosConf,
data: {
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": query_id2,
"query_param": xueduan2
},
"query_cache": 0,
"query_count": [
"total"
],
"query_format": "json",
"query_group": [
"org_name"
]
}
})
]).then(axios.spread(function (schoolStageTypeRes, schoolStageRes) {
let html = ""
if (schoolStageTypeRes.data.result == "") {
html = "暂无数据
"
} else {
const schoolStageTypeData = JSON.parse(schoolStageTypeRes.data.result)
const schoolStageData = JSON.parse(schoolStageRes.data.result)
let orgNameCatch = []
let orgName = []
// 提取学校名称
schoolStageTypeData.map((item) => {
orgNameCatch.push({ id: item.org_id, name: item.org_name });
})
// 去重获取学校列表
orgName = orgNameCatch.filter((item, index) => {
return orgNameCatch.findIndex(_item => _item.id == item.id) == index;
})
if (type == 1) {
orgName.map((e, i) => {
let arr = []
schoolStageTypeData.map((item) => {
if (item.org_id === e.id) {
switch (item.res_type) {
case "1":
orgName[i].jxzy = item.total
break;
case "5":
orgName[i].wkzy = item.total
break;
case "4":
orgName[i].sjzy = item.total
break;
case "5":
orgName[i].meiyu = item.total
break;
defalut:
break;
}
}
})
orgName[i].children = arr
schoolStageData.map((item) => {
if (item.org_name === e.name) {
orgName[i].total = item.total
}
})
})
html = `
序号
学校名称
教学资源
微课资源
试卷资源
试题资源
资源总计
`
orgName.map((item, index) => {
html += `
${index + 1}
${item.name}
${item.jxzy ? item.jxzy : 0}
${item.wkzy ? item.wkzy : 0}
${item.sjzy ? item.sjzy : 0}
${item.meiyu ? item.meiyu : 0}
${item.total}
`
})
} else if (type == 2) {
orgName.map((e, i) => {
let arr = []
schoolStageTypeData.map((item) => {
if (item.org_id === e.id) {
orgName[i].zysc = item.total_upload
orgName[i].zyxz = item.total_share
orgName[i].zygx = item.total_down
orgName[i].zytj = item.total_recommend
}
})
orgName[i].children = arr
schoolStageData.map((item) => {
if (item.org_name === e.name) {
orgName[i].total = item.total
}
})
})
html = `
序号
学校名称
资源上传
资源下载
资源共享
资源推荐
资源总计
`
orgName.map((item, index) => {
html += `
${index + 1}
${item.name}
${item.zysc ? item.zysc : 0}
${item.zyxz ? item.zyxz : 0}
${item.zygx ? item.zygx : 0}
${item.zytj ? item.zytj : 0}
${item.total}
`
})
}
}
$("#x-table").html(html)
})).catch(() => {
$("#x-table").html("链接失败")
})
}
r1();
function r1() {
var myChart = echarts.init(document.getElementById('r1')); // 各阶段学校数量
myChart.showLoading(chartsLoadindStyle);
axios({
...axiosConf,
data: {
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": "stage_res_use_num_all",
"query_param": [
]
},
"query_cache": 0,
"query_count": [
"total_upload", "total_down", "total_share", "total_recommend"
],
"query_format": "echarts",
"query_group": [
"school_typename"
]
}
})
.then((response) => {
const resData = JSON.parse(response.data.result)
let legendData = []
let xAxisName = []
let series = [{
type: 'bar',
data: [],
}]
if (!resData.datas) {
myChart.showLoading(chartsLoadindNodataStyle);
myChart.clear()
} else {
legendName = ["资源上传", "资源下载", "资源共享", "资源推荐"]
xAxisName = resData.groups[0]
series = [{
name: "资源上传",
type: 'bar',
barMaxWidth: 20,
data: resData.datas[0]
}, {
name: "资源下载",
type: 'bar',
barMaxWidth: 20,
data: resData.datas2[0]
}, {
name: "资源共享",
type: 'bar',
barMaxWidth: 20,
data: resData.datas3[0]
}, {
name: "资源推荐",
type: 'bar',
barMaxWidth: 20,
data: resData.datas4[0]
}]
myChart.hideLoading();
}
// ===========================================
option = {
// height: "100px",
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
}
}
},
textStyle: {
color: '#01DFF4'
},
grid: {
top: 50,
right: 10,
bottom: 40,
},
color: ["#0BCAEA", "#FE8E3A", "#3FDB94"],
legend: {
data: legendData,
itemWidth: 8,
itemHeight: 8,
right: 10,
top: 10,
textStyle: {
color: '#01DFF4'
},
},
xAxis: [
{
type: 'category',
data: xAxisName,
axisLine: {
lineStyle: {
color: '#01DFF4' //更改坐标轴颜色
}
},
axisLabel: {
fontSize: 10,
color: "white",
}
},
],
yAxis: [
{
type: 'value',
axisLine: {
lineStyle: {
color: '#01DFF4' //更改坐标轴颜色
}
}
}
],
series: series
};
myChart.setOption(option);
}).catch(() => {
myChart.showLoading(chartsLoadindNodataStyle);
myChart.clear()
})
// 使用刚指定的配置项和数据显示图表。
window.addEventListener("resize", function () {
myChart.resize();
});
}
r3();
function r3() {
var myChart = echarts.init(document.getElementById('r3')); // 各阶段学校数量
myChart.showLoading(chartsLoadindStyle);
axios({
...axiosConf,
data: {
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": "stage_res_use_num_month_all",
"query_param": [
"2021"
]
},
"query_cache": 0,
"query_count": [
"total_upload", "total_down", "total_share", "total_recommend"
],
"query_format": "echarts",
"query_group": [
"month_name"
]
}
}).then((response) => {
const resData = JSON.parse(response.data.result)
let xAxisName = []
let series = []
let legendName = []
if (!resData.datas) {
myChart.showLoading(chartsLoadindNodataStyle);
myChart.clear()
} else {
legendName = ["资源上传", "资源下载", "资源共享", "资源推荐"]
xAxisName = resData.groups[0]
series = [{
name: "资源上传",
type: 'line',
data: resData.datas[0]
}, {
name: "资源下载",
type: 'line',
data: resData.datas2[0]
}, {
name: "资源共享",
type: 'line',
data: resData.datas3[0]
}, {
name: "资源推荐",
type: 'line',
data: resData.datas4[0]
}]
myChart.hideLoading();
}
option = {
// height: "100px",
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
}
}
},
textStyle: {
color: '#01DFF4'
},
grid: {
right: 10,
top: 50,
bottom: 35,
},
color: ["#0BCAEA", "#FE8E3A", "#3FDB94"],
legend: {
data: legendName,
itemWidth: 8,
itemHeight: 8,
right: 10,
top: 15,
textStyle: {
color: '#01DFF4'
},
},
xAxis: [
{
type: 'category',
data: xAxisName,
axisLine: {
lineStyle: {
color: '#01DFF4' //更改坐标轴颜色
}
},
axisLabel: {
fontSize: 10,
color: "white",
}
},
],
yAxis: [
{
type: 'value',
axisLine: {
lineStyle: {
color: '#01DFF4' //更改坐标轴颜色
}
}
}
],
series: series
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}).catch(() => {
myChart.showLoading(chartsLoadindNodataStyle);
myChart.clear()
})
}
let r2_time = "2021"
let optionHtml = ""
for (i = nowYear; i > nowYear - 10; i--) {
optionHtml += ``
}
$("#r2_time").html(optionHtml)
$('#r2_time').on('change', function () {
r2_time = $(this).val() + ""
r2(r2_time);
})
r2(r2_time);
function r2(time) {
var myChart = echarts.init(document.getElementById('r2')); // 各阶段学校数量
myChart.showLoading(chartsLoadindStyle);
axios({
...axiosConf,
data: {
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": "stage_res_const_num_month_all",
"query_param": [
time
]
},
"query_cache": 0,
"query_count": [
"total"
],
"query_format": "echarts",
"query_group": [
"month_name", "type_name"
]
}
})
.then((response) => {
const resData = JSON.parse(response.data.result)
let xAxisName = []
let legendData = []
let series = []
let dataZoom = {}
if (!resData.datas) {
myChart.showLoading(chartsLoadindNodataStyle);
myChart.clear()
dataZoom = {
show: false
}
} else {
xAxisName = resData.groups[0]
legendData = resData.groups[1]
resData.groups[1].map((e, i) => {
series.push({
name: e,
type: 'bar',
stack: "all",
data: resData.datas[i],
barMaxWidth: 40,
})
})
myChart.hideLoading();
}
option = {
// height: "100px",
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
}
}
},
textStyle: {
color: '#01DFF4'
},
grid: {
top: 55,
bottom: 35,
right: 10
},
color: ["#0BCAEA", "#FE8E3A", "#3FDB94", "#4992FF", "#FF6E76"],
legend: {
data: legendData,
top: 15,
right: 10,
itemWidth: 8,
itemHeight: 8,
textStyle: {
color: '#01DFF4'
},
},
xAxis: [
{
type: 'category',
data: xAxisName,
axisLine: {
lineStyle: {
color: '#01DFF4' //更改坐标轴颜色
}
},
axisLabel: {
interval: 0,
fontSize: 10,
color: "white",
}
},
],
yAxis: [
{
type: 'value',
axisLine: {
lineStyle: {
color: '#01DFF4' //更改坐标轴颜色
}
}
},
{
type: 'value',
axisLine: {
lineStyle: {
color: '#01DFF4' //更改坐标轴颜色
}
}
}
],
series: series
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}).catch(() => {
myChart.showLoading(chartsLoadindNodataStyle);
myChart.clear()
dataZoom = {
show: false
}
})
}
})