|
|
|
function PostAjax(url, data, callback) {
|
$.ajax({
|
url: url,
|
type: "POST",
|
data: data,
|
dataType: "JSON",
|
contentType: "application/json;charset=UTF-8",
|
success: function (data) {
|
callback && callback(data)
|
},
|
})
|
}
|
|
var myChart = echarts.init(document.getElementById('chartLeft'));
|
var myChart2 = echarts.init(document.getElementById('chartRight'));
|
// var myChart3 = echarts.init(document.getElementById('echatrs3'));
|
// 使用刚指定的配置项和数据显示图表。
|
|
// 指定图表的配置项和数据
|
var option = {
|
title: {
|
text: '要素类型数量',
|
textStyle: {
|
color: '#fff',
|
|
}
|
},
|
tooltip: {},
|
legend: {
|
// data: ['图斑类型'],
|
textStyle: { //图例文字大小 颜色
|
color: "#fff",
|
fontSize: 10
|
},
|
x: '200'
|
},
|
// grid: {
|
// top: 6,
|
// bottom: 19
|
// },
|
|
xAxis: {
|
data: [],
|
axisLabel: { // x轴文本标签字体 颜色
|
color: "#fff" //30eee9
|
},
|
axisLine: {
|
show: true, //x轴线颜色
|
lineStyle: {
|
color: "#7CDCFF"
|
},
|
},
|
axisTick: { show: false, }//x轴分割点
|
|
},
|
yAxis: {
|
axisLabel: { // x轴文本标签字体 颜色
|
color: "#fff" //30eee9
|
},
|
axisLine: {
|
show: true, //x轴线颜色
|
lineStyle: {
|
color: "#7CDCFF"
|
},
|
},
|
//设置网格线颜色
|
splitLine: {
|
show: false,
|
lineStyle: {
|
color: ['#315070'],
|
width: 1,
|
type: 'solid'
|
}
|
}
|
},
|
color: ["#90EE90", "#8A2BE2", "#7FFF00", "#FF00FF", "#FF4500", "#DC143C", "#FFD700", "#FF69B4"],
|
series: [{
|
name: '图斑类型',
|
type: 'bar',
|
data: [],
|
barWidth: 30,//柱图宽度
|
itemStyle: {
|
//通常情况下:
|
normal: {
|
barBorderRadius: 8,
|
// //每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组
|
// color: function (params) {
|
// var colorList = [
|
// ['#91D4FF', '#008AFF'],
|
// // ['#F5cF0D', '#fa9203'],
|
// // ['#61dbe8', '#0785de'],
|
// // ['#ff9717', '#ff4518'],
|
// ];
|
// // var index = params.dataIndex;
|
// // if (params.dataIndex >= colorList.length) {
|
// // index = params.dataIndex - colorList.length;
|
// // }
|
// return new echarts.graphic.LinearGradient(0, 0, 0, 1,
|
// [{
|
// offset: 0,
|
// color: colorList[0][0]
|
// },
|
// {
|
// offset: 1,
|
// color: colorList[0][1]
|
// }
|
// ]);
|
// }
|
},
|
}
|
}]
|
};
|
|
var lineoption = {
|
color: ["#8A2BE2", "#7FFF00", "#DC143C", "#FF00FF", "#FFD700", "#FF69B4", "#90EE90", "#FF4500"],
|
title: {
|
text: '来源数量统计',
|
textStyle: {
|
color: '#fff',
|
},
|
x: 90
|
},
|
tooltip: {
|
trigger: 'item'
|
},
|
// legend: {
|
// // top: '5%',
|
// // left: 'center',
|
// y: 'center',
|
// x: 90,
|
// textStyle: {
|
// color: '#fff',
|
// },
|
// orient: 'vertical',
|
// type: "scroll"
|
// },
|
// color: ['#49AAFD', '#ED9F34'],
|
series: [
|
{
|
name: '数据来源',
|
type: 'pie',
|
radius: ['40%', '60%'],
|
avoidLabelOverlap: false,
|
center: ['390', 'center'],
|
// label: {
|
// show: false,
|
// position: 'center'
|
// },
|
// label: {
|
// edgeDistance: 20,
|
// position: 'outer',
|
// alignTo: 'labelLine',
|
// normal: {
|
// show: true,
|
// position: 'outter',
|
// formatter: function (parms) {
|
// return parms.data.legendname
|
// }
|
// }
|
// },
|
emphasis: {
|
label: {
|
show: true,
|
fontSize: '12',
|
fontWeight: 'bold',
|
color: 'white'
|
}
|
},
|
labelLine: {
|
show: true,
|
},
|
label: {
|
normal:{
|
textStyle:{
|
fontSize: '12',
|
fontWeight: 'bold',
|
color: 'white'
|
}
|
}
|
},
|
data: [
|
// { value: 1048, name: '内部' },
|
// { value: 735, name: '外部' },
|
|
]
|
}
|
]
|
};
|
|
|
var pieoption = {
|
title: {
|
// text: '来源统计长度与面积',
|
// subtext: '纯属虚构',
|
left: 'center',
|
textStyle: {
|
color: '#fff',
|
}
|
},
|
tooltip: {
|
trigger: 'item'
|
},
|
legend: {
|
orient: 'vertical',
|
left: 'left',
|
textStyle: { //图例文字大小 颜色
|
color: "#fff",
|
fontSize: 10
|
}
|
},
|
|
color: ['#F76B7E', '#FFA63D'],
|
series: [
|
{
|
name: '访问来源',
|
type: 'pie',
|
radius: '50%',
|
data: [
|
|
],
|
emphasis: {
|
itemStyle: {
|
shadowBlur: 10,
|
shadowOffsetX: 0,
|
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
}
|
}
|
|
}
|
]
|
};
|
|
// 请求数据,渲染图表
|
PostAjax(IPurl + '/spcData/statistics?strName=图斑类型&type=1', '', function (params) {
|
if (params.code == 500) {
|
console.log(params.msg);
|
return
|
}
|
// debugger
|
// let arr = [params.data['点状'], params.data['线状'], params.data['面状']]
|
// option.series[0].data = arr;
|
var data = [];
|
var legendData = [];
|
for (var k in params.data) {
|
if (k == "总数据") continue;
|
if (k == "") continue;
|
legendData.push(k);
|
// console.log(k, eval(`params.data['${k}']`));
|
data.push({ name: k, value: eval(`params.data['${k}']`) });
|
}
|
option.xAxis.data = legendData;
|
option.series[0].data = data;
|
myChart.setOption(option);
|
})
|
// 请求数据,渲染图表
|
PostAjax(IPurl + '/spcData/statistics?strName=专题分类&type=1', '', function (params) {
|
|
if (params.code == 500) {
|
console.log(params.msg);
|
return
|
}
|
// let arr = [{ value: params.data['内部'], name: '内部' }, { value: params.data['外部'], name: '外部' }]
|
// lineoption.series[0].data = arr;
|
var data = [];
|
for (var k in params.data) {
|
if (k == "总数据") continue;
|
if (k == "") continue;
|
// console.log(k, eval(`params.data['${k}']`));
|
data.push({ name: k, value: eval(`params.data['${k}']`) });
|
}
|
lineoption.series[0].data = data;
|
myChart2.setOption(lineoption);
|
|
})
|
|
// 请求数据,渲染图表
|
PostAjax(IPurl + '/spcData/statistics', '', function (params) {
|
if (params.code == 500) {
|
console.log(params.msg);
|
|
return
|
}
|
let arr = [{ value: params.data['长度'], name: '长度' }, { value: params.data['面积'], name: '面积' }]
|
pieoption.series[0].data = arr;
|
//myChart3.setOption(pieoption);
|
})
|
|
window.onresize = function () {
|
// for (var i = 0; i < MyCharts.length; i++) {
|
// MyCharts[i].resize();
|
// }
|
for (var i = 0; i < myChart2.length; i++) {
|
MyCharts2[i].resize();
|
}
|
// for (var i = 0; i < myChart3.length; i++) {
|
// //myChart3[i].resize();
|
// }
|
}
|
|
|
|
|
|
// 请求数据,渲染图表
|
/**
|
* 根据数据来源统计一下
|
*/
|
PostAjax(IPurl + '/spcData/statistics?strName=图斑个数&type=0', '', function (params) {
|
|
if (params.code == 500) {
|
console.log(params.msg);
|
return
|
}
|
//专题数据库共收录XX条数据,其中点状数据XX个,线状数据XX个,面状数据XX个,未知类型数据XX个,各类要素XX个 。
|
//let tem = `<p>专题数据共收录${data.data['总数据']}条数据,其中内部数据${data.data['总数据']}条,`
|
|
// let tem = `<p>专题数据库共收录328条数据,其中`
|
let tem = `<p style=" font-size: 17px;
|
padding-left: 40px;
|
letter-spacing: 9px;
|
margin-top: -27px;">海洋专题数据库共存储<strong>${params.data.总数据}</strong>个图层(<strong>${params.data.图斑个数}</strong>个要素)<br/><br/>`
|
|
// for (var k in params.data) {
|
// if (k == "总数据") continue;
|
// if (k == "") continue;
|
// // console.log(k, eval(`params.data['${k}']`));
|
// // tem += k + '包含' + eval(`params.data['${k}']`) + '个记录,'
|
// }
|
params = {}
|
dataparams = {}
|
objp=[]
|
objm={}
|
setTimeout(function(){
|
PostAjax(IPurl + '/spcData/getTbNums?strType=图斑类型&strCount=图斑个数', '', function (params) {
|
for (var k in params.data) {
|
if(k==="点状"){
|
objp.push({key:k,value:params.data[k],id:1})
|
}else if(k==="线状"){
|
objp.push({key:k,value:params.data[k],id:2})
|
}else if(k==="面状"){
|
objp.push({key:k,value:params.data[k],id:3})
|
}else if(k==="未知"){
|
objp.push({key:k,value:params.data[k],id:4})
|
}else{
|
objp.push({key:k,value:params.data[k],id:5})
|
}
|
}
|
objp.sort((a,b)=>a.id-b.id);
|
params.data = objp;
|
if (params.code == 500) {
|
console.log(params.msg);
|
return
|
}
|
var data = [];
|
for (var k in params.data) {
|
for(var m in dataparams){
|
|
if(params.data[k].key==m){
|
if (params.data[k].key == "总数据") continue;
|
if (params.data[k].key == "") continue;
|
// console.log(k, eval(`params.data['${k}']`));
|
tem += params.data[k].key + "图层<strong>" + eval(`dataparams['${m}']`) + '</strong>个(<strong>'+eval(`params.data['${k}'].value`)+'</strong>个要素)<br/><br/>'
|
}
|
}
|
|
}
|
tem = tem.substring(0,tem.length-1);
|
// $('.ztsjInfo').append(tem)
|
$('.ztsjms-content').html(tem)
|
|
})
|
},1000)
|
|
|
|
|
/**
|
* 根据图斑类型统计一下
|
*/
|
PostAjax(IPurl + '/spcData/statistics?strName=图斑类型&type=1', '', function (params) {
|
//PostAjax(IPurl + '/spcData/getTbNums?strType=图斑类型&strCount=图斑个数', '', function (params) {
|
if (params.code == 500) {
|
console.log(params.msg);
|
return
|
}
|
// var data = [];
|
// for (var k in params.data) {
|
// debugger
|
// if (k == "总数据") continue;
|
// if (k == "") continue;
|
// // console.log(k, eval(`params.data['${k}']`));
|
// tem += k + "数据 <strong>" + eval(`params.data['${k}']`) + '</strong>条,'
|
// }
|
// // $('.ztsjInfo').append(tem)
|
// $('.ztsjms-content').html(tem)
|
dataparams = params.data;
|
})
|
|
})
|
|
|
window.onload = function () {
|
$(".close").click(function () {
|
$(".tab").removeClass('fadeOutLeft').removeClass('fadeInLeft').removeClass('animated').addClass('fadeOutLeft animated ');
|
})
|
}
|
function ClickEvent(event, treeid, treeNode) {
|
$(".close").click();
|
|
if (treeNode.isParent) return;
|
if (treeNode.pId == null) {
|
$('.tab').hide()
|
return
|
}
|
$(".tab").removeClass('fadeOutLeft').removeClass('fadeInLeft').removeClass('animated').addClass('fadeInLeft animated ');
|
$('.tab').show()
|
//查询元数据
|
querymetadata(treeNode.id, treeNode.name)
|
$('.tab table').attr('data-treeid', treeNode.id)
|
}
|
|
var template = `
|
<tr><td><input type="text" value="名称" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none" ><input type="text" placeholder="请输入元数据值"/></td><td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="空间覆盖范围" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input value="-" type="text" placeholder="请输入元数据值"/></td><td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="水深覆盖范围" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input value="-" type="text" placeholder="请输入元数据值"/></td><td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="时间覆盖范围" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input value="-" type="text" placeholder="请输入元数据值"/></td><td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="时空分辨率" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input value="-" type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="摘要说明" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="访问限制" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input value="-" type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="使用限制" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input value="-" type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="坐标系" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input value="WGS84" type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="要素类型" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="要素个数" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="数据来源" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="专题分类" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="更新频率" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="更新时间" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input value="2021/06/24" type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="维护人" style="width:90% !important"/><span style="color:red;font-weight:800;font-size:22px">*</span></td><td contenteditable="true" style="border: none"><input value="郭雪" type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="服务地址" style="width:90% !important"/></td><td contenteditable="true" style="border: none"><input type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
<tr><td><input type="text" value="数据表名" style="width:90% !important"/></td><td contenteditable="true" style="border: none"><input type="text" placeholder="请输入元数据值"/></td> <td class="DelTr"><button>-</button></td></tr>
|
`;
|
|
// var template = `
|
// <tr><td>数据名称</td><td contenteditable="true" style="border: none" ></td><td class="DelTr">删除</td></tr>
|
// <tr><td>制作人</td><td contenteditable="true" style="border: none"></td><td class="DelTr">删除</td></tr>
|
// <tr><td>录入时间</td><td contenteditable="true" style="border: none"></td><td class="DelTr">删除</td></tr>
|
// <tr><td>数据类型</td><td contenteditable="true" style="border: none"></td><td class="DelTr">删除</td></tr>
|
// <tr><td>数据来源</td><td contenteditable="true" style="border: none"></td><td class="DelTr">删除</td></tr>
|
// <tr><td>面积</td><td contenteditable="true" style="border: none"></td><td class="DelTr">删除</td></tr>
|
// <tr><td>长度</td><td contenteditable="true" style="border: none"></td><td class="DelTr">删除</td></tr>
|
// <tr><td>数据服务地址</td><td contenteditable="true" style="border: none"></td> <td class="DelTr">删除</td></tr>
|
// `
|
|
/**
|
* 获取元数据的某个
|
* @param {*} params
|
* @param {*} name
|
*/
|
function queryMetaDataSome(params, name, fun) {
|
let tabdata = {
|
"menuId": params,
|
"metadata": ''
|
}
|
|
PostAjax(IPurl + '/spcData/queryMetaData', JSON.stringify(tabdata), function (params) {
|
|
if (params.data == null) {
|
$('#metadata>tbody').empty()
|
}
|
fun(params.data)
|
})
|
}
|
/**
|
* 获取元数据填充到列表
|
* @param {*} params
|
* @param {*} name
|
*/
|
var currentid = null;
|
function querymetadata(params, name) {
|
let tabdata = {
|
"menuId": params,
|
"metadata": ''
|
}
|
|
|
|
if ((window.parent.permissions == "list" || window.parent.permissions == null)) {
|
|
$('#metadata>thead').empty().append(` <tr>
|
<th>元数据名称</th>
|
<th>元数据值</th>
|
</tr>`)
|
}
|
else {
|
|
$('#metadata>thead').empty().append(` <tr>
|
<th>元数据名称</th>
|
<th>元数据值</th>
|
<th>操作</th>
|
</tr>`)
|
}
|
|
PostAjax(IPurl + '/spcData/queryMetaData', JSON.stringify(tabdata), function (params) {
|
if (params.data == null) {
|
$('#metadata>tbody').empty()
|
}
|
|
|
|
/**
|
* 必填标记
|
*/
|
var requirePro = ["名称", "空间覆盖范围", "水深覆盖范围", "时间覆盖范围", "时空分辨率", "摘要说明", "访问限制", "使用限制", "坐标系", "要素类型", "要素个数", "数据来源", "专题分类", "更新频率", "更新时间", "维护人", "服务地址", "数据表名"];
|
var requirePro = ["名称", "要素类型", "要素个数", "数据来源", "专题分类", "维护人"];
|
|
/**
|
* 权限字段
|
*/
|
var permissionsPro = ["服务地址", "数据表名"];
|
|
if (params.code == 0 && params.data && params.data.metadata) {
|
$('#metadata>tbody').empty()
|
let object = JSON.parse(params.data.metadata);
|
|
currentMetaData = object;
|
|
for (const key in object) {
|
if (object.hasOwnProperty(key)) {
|
const element = object[key];
|
let temp = ``;
|
|
if ((window.parent.permissions == "list" || window.parent.permissions == null) && permissionsPro.indexOf(key) > -1) {
|
continue;
|
}
|
|
|
|
if(window.parent.permissions==="edit"){
|
if (requirePro.indexOf(key) > -1) {
|
temp = ` <tr>
|
<td contenteditable="true"><input type="text" value="${key}" placeholder="请输入元数据名称" style="width:90% !important;"/><span style="color:red;font-weight:800;font-size:22px">*</span></td>
|
<td contenteditable="true" style="border: none"><input type="text" value="${element}" placeholder="请输入元数据值"/></td>
|
<td class="DelTr"><button style="display: `+ ((window.parent.permissions == "list" || window.parent.permissions == null) ? "none" : "block") + ` !important">-</button></td>
|
</tr>`
|
}
|
else {
|
temp = ` <tr>
|
<td contenteditable="true"><input type="text" value="${key}" placeholder="请输入元数据名称"/></td>
|
<td contenteditable="true" style="border: none"><input type="text" value="${element}" placeholder="请输入元数据值"/></td>
|
<td class="DelTr"><button style="display: `+ ((window.parent.permissions == "list" || window.parent.permissions == null) ? "none" : "block") + ` !important">-</button></td>
|
</tr>`
|
}
|
}else{
|
if (requirePro.indexOf(key) > -1) {
|
temp = ` <tr>
|
<td contenteditable="true"><input type="text" value="${key}" placeholder="请输入元数据名称" style="width:90% !important;"/><span style="color:red;font-weight:800;font-size:22px">*</span></td>
|
<td contenteditable="true" style="border: none"><input type="text" disabled="disabled" value="${element}" placeholder="请输入元数据值"/></td>
|
<td class="DelTr"><button style="display: `+ ((window.parent.permissions == "list" || window.parent.permissions == null) ? "none" : "block") + ` !important">-</button></td>
|
</tr>`
|
}
|
else {
|
temp = ` <tr>
|
<td contenteditable="true"><input type="text" value="${key}" placeholder="请输入元数据名称"/></td>
|
<td contenteditable="true" style="border: none"><input type="text" disabled="disabled" value="${element}" placeholder="请输入元数据值"/></td>
|
<td class="DelTr"><button style="display: `+ ((window.parent.permissions == "list" || window.parent.permissions == null) ? "none" : "block") + ` !important">-</button></td>
|
</tr>`
|
}
|
}
|
$('#metadata>tbody').append(temp)
|
}
|
}
|
} else {
|
|
$('#metadata>tbody').append(template);
|
$('#metadata>tbody>tr:eq(0)>td:eq(1)>input').val(name);
|
console.warn("请求元数据服务出错!");
|
}
|
if (params && params.data)
|
currentid = params.data.id;
|
})
|
|
if (window.parent.permissions == "list" || window.parent.permissions == null) {
|
$(".subbox").hide();
|
}
|
}
|
// 添加表格数据
|
function addtabtr() {
|
$('#metadata>tbody').append(`<tr>
|
<td contenteditable="true" style="border: none"><input type="text" placeholder="请输入元数据名称"/></td>
|
<td contenteditable="true" style="border: none"><input type="text" placeholder="请输入元数据值"/></td>
|
<td class="DelTr"><button>-</button></td>
|
</tr>`);
|
$('#metadata>tbody')[0].scrollTop = $('#metadata>tbody')[0].scrollHeight;
|
}
|
|
// 左键取消menu显示
|
document.addEventListener("click", function () {
|
$('.rkeymenu').css("display", 'none');
|
});
|
|
|
// 获取鼠标当前位置的函数
|
function getMousePos(event) {
|
var event = event || window.event;
|
let obj = $('#leftwindow')[0];
|
let x = event.clientX - obj.offsetLeft
|
let y = event.clientY;
|
return {
|
'x': x,
|
'y': y
|
};
|
}
|
|
// 获取元数据表格内容
|
function submitmetadata(params) {
|
arr = [], obj = {}
|
var mytable = document.getElementById('metadata')
|
for (let i = 1, rows = mytable.rows.length; i < rows; i++) {
|
for (let j = 0, cells = mytable.rows[i].cells.length; j < cells; j++) {
|
if (j > 1) {
|
break
|
} else {
|
arr.push(mytable.rows[i].cells[j].children[0].value)
|
// arr.push(mytable.rows[i].cells[j].innerHTML)
|
}
|
}
|
}
|
for (let i = 0; i < arr.length; i = i + 2) {
|
obj[arr[i]] = arr[i + 1]
|
}
|
return JSON.stringify(obj)
|
}
|
// 提交元数据
|
function submitfunc() {
|
let treeid = $('.tab table').attr('data-treeid')
|
console.log(submitmetadata());
|
let tabdata = {
|
"menuId": treeid,
|
"metadata": submitmetadata(),
|
"id": currentid
|
}
|
PostAjax(IPurl + '/spcData/addMetaData', JSON.stringify(tabdata), function (data) {
|
if (data.code == 0) {
|
// initTreeDom()
|
//$('.tab').hide();
|
$(".tab").removeClass('fadeOutLeft').removeClass('fadeInLeft').removeClass('animated').addClass('fadeOutLeft animated ');
|
layer.msg('添加成功')
|
currentid = null;
|
} else {
|
console.log('提交失败!')
|
currentid = null;
|
}
|
})
|
}
|
|
|
// 删除表格tr(当前点击行)
|
$(document).on('click', '.DelTr button', function () {
|
debugger
|
$(this).parent().parent().remove()
|
})
|
|
|
|
var layerID = [];
|
// var layer = [];
|
|
function addLayer_tc(option) {
|
|
if (option.id) {
|
var index = layerID.indexOf(option.id);
|
var imageLayer = null;
|
if (index < 0) {
|
var urlStr = option.url;
|
var layerId = "";
|
// var legendDiv = createLegendDiv(option.id);
|
// requestLegend(urlStr, legendDiv);
|
}
|
}
|
};
|
|
function createLegendDiv(id) {
|
var divObject = $('<div id="legendDiv_' + id + '_TC" class="esriLegendService" style="display: block;"></div>');
|
$("#legendDiv").append(divObject);
|
return divObject;
|
}
|
function requestLegend(url, lDiv) {
|
|
var htmlStr = "";
|
var layerIndex = url.split("MapServer")[1];
|
if (layerIndex) {
|
layerIndex = Number(layerIndex.substring(1));
|
}
|
var requestUrl = url.split("MapServer")[0] + "MapServer/legend?f=pjson";
|
$.ajax({
|
url: requestUrl,
|
type: "post",
|
dataType: "json",
|
success: function (data) {
|
if (layerIndex != "" || layerIndex == 0) {
|
var layer = data.layers[layerIndex];
|
var html = createArcgisULHtml(layer);
|
lDiv.append($(html));
|
}
|
}
|
});
|
}
|
function createArcgisULHtml(layer) {
|
var s_html = '';
|
try {
|
var legends = layer.legend;
|
s_html += '<table width="95%" style="height:45px !important;width:100%;color:#000" class="esriLegendLayerLabel"><tbody ><tr><td style="text-align: left !important;color: black !important;">';
|
s_html += layer.layerName;
|
s_html += '</td></tr></tbody></table>';
|
for (var i = 0; i < legends.length; i++) {
|
var legend = legends[i];
|
// s_html += '<table width="95%" style="height:30px !important;width:100%;color:#000" class="esriLegendLayerLabel"><tbody style="height:30px !important;width:100%;color:#000"><tr><td align="left">';
|
// s_html += layer.layerName;
|
s_html += '<table cellpadding="0" cellspacing="0" width="95%" class="esriLegendLayer" style="height:45px !important;width:100%;color:#000"><tbody style="height:38px !important;width:100%;color:#000"><tr><td width="35" align="center">';
|
s_html += '<img src="data:image/png;base64,' + legend.imageData + '" border="0" style="opacity:1"></td><td style="color:black">' + legend.label + '</td></tr></tbody></table>';
|
}
|
} catch (e) { }
|
return s_html;
|
}
|
|
|
function removeLayer_tc(option) {
|
|
var index = layerID.indexOf(option.id);
|
if (index < 0) {
|
try {
|
$("#legendDiv_" + option.id + "_TC").remove();
|
} catch (e) { }
|
// viewer.imageryLayers.remove(layerManage.layer[index]);
|
// layerManage.layer.splice(index, 1);
|
// layerManage.layerID.splice(index, 1);
|
}
|
}
|