提交 b614cc4d 编写于 作者: Skyeye云's avatar Skyeye云

feat: 数据源修改

上级 92e15aba
// 表格的序号
var rowNum = 1;
layui.config({
base: basePath,
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'codemirror', 'xml', 'sql'], function (exports) {
winui.renderColor();
layui.use(['form'], function (form) {
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$;
var radioTemplate = '{{#each rows}}<input type="radio" name="dataFromType" value="{{id}}" title="{{name}}" lay-filter="dataFromType" {{checked}} />{{/each}}';
var selOption = getFileContent('tpl/template/select-option.tpl');
var dataFromTypeList = [];
var xmlContent, jsonContent, sqlContent, restRequestBodyContent;
// 数据源类型列表
showGrid({
id: "dataFromTypeBox",
url: reportBasePath + "reportcommon008",
params: {},
pagination: false,
template: radioTemplate,
method: "GET",
ajaxSendLoadBefore: function(hdb) {
},
ajaxSendAfter:function (json) {
dataFromTypeList = [].concat(json.rows);
$.each(dataFromTypeList, function (i, item) {
if(item.checked){
initDataFromBoxContent(item.id);
form.render('radio');
}
});
}
});
matchingLanguage();
form.render();
form.on('submit(formAddBean)', function (data) {
if (winui.verifyForm(data.elem)) {
var params = {
name: $("#name").val(),
remark: $("#remark").val(),
type: $("input[name='dataFromType']:checked").val(),
analysisData: getAnalysisData()
};
if(JSON.parse(params.analysisData).length == 0){
winui.window.msg('请进行字段解析操作。', {icon: 2, time: 2000});
return false;
}
var otherData = getDataByType();
if((isNull(otherData.xmlContent) && params.type == 1)
|| (isNull(otherData.jsonContent) && params.type == 2)
|| (isNull(otherData.sqlContent) && params.type == 4)){
winui.window.msg('必填项不能为空', {icon: 2, time: 2000});
return false;
}
params = $.extend(true, params, otherData);
AjaxPostUtil.request({url: reportBasePath + "reportdatafrom002", params: params, type: 'json', method: "POST", callback: function(json) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
}
return false;
});
function getDataByType(){
var dataFromType = $("input[name='dataFromType']:checked").val();
if (dataFromType == 1){
// XML数据源
return getXMLData();
} else if (dataFromType == 2){
// JSON数据源
return getJSONData();
} else if (dataFromType == 3){
// Rest接口数据源
return getRESTData();
} else if (dataFromType == 4){
// SQL数据源
return getSQLData();
}
return {};
}
function getXMLData(){
return {
xmlContent: xmlContent.getValue()
};
}
function getJSONData(){
return {
jsonContent: jsonContent.getValue()
};
}
function getRESTData(){
return {
restUrl: $("#restUrl").val(),
method: $("#restMethod").val(),
header: getRestRequestHeaderData(),
requestBody: restRequestBodyContent.getValue()
};
}
function getSQLData(){
return {
sqlDataBaseId: $("#sqlDataBase").val(),
sqlContent: sqlContent.getValue()
};
}
function getAnalysisData(){
var tableData = new Array();
var rowTr = $("#analysisTable tr");
$.each(rowTr, function(i, item) {
//获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", "");
var row = {
key: $("#key" + rowNum).val(),
title: $("#title" + rowNum).val(),
dataType: $("#dataType" + rowNum).val(),
dataLength: $("#dataLength" + rowNum).val(),
dataPrecision: $("#dataPrecision" + rowNum).val(),
remark: $("#remark" + rowNum).val()
};
tableData.push(row);
});
return JSON.stringify(tableData);
}
function getRestRequestHeaderData(){
var tableData = new Array();
var rowTr = $("#restHeaderTable tr");
$.each(rowTr, function(i, item) {
//获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", "");
var row = {
headerKey: $("#headerKey" + rowNum).val(),
headerValue: $("#headerValue" + rowNum).val(),
headerDescription: $("#headerDescription" + rowNum).val()
};
tableData.push(row);
});
return JSON.stringify(tableData);
}
form.on('radio(dataFromType)', function (data) {
var val = data.value;
initDataFromBoxContent(val);
});
function initDataFromBoxContent(val){
var staticTplPath = getInPoingArr(dataFromTypeList, "id", val, "staticTplPath");
var html = getFileContent(staticTplPath);
$("#dataBox").html(html);
// 加载字段解析信息
$("#analysisHeader").html($("#analysisHeaderTemplate").html());
$("#analysisTable").html("");
initEvent(val);
form.render();
}
function initEvent(dataFromType){
// 获取公共的配置信息
var commonOptions = getCommonCodeMirrorOptions();
if (dataFromType == 1){
// XML数据源
xmlContent = CodeMirror.fromTextArea(document.getElementById("xmlData"), $.extend(true, commonOptions, {
mode: "xml",
theme: "default"
}));
} else if (dataFromType == 2){
// JSON数据源
jsonContent = CodeMirror.fromTextArea(document.getElementById("jsonData"), $.extend(true, commonOptions, {
mode: "xml",
theme: "default"
}));
} else if (dataFromType == 3){
// Rest接口数据源
restRequestBodyContent = CodeMirror.fromTextArea(document.getElementById("requestBody"), $.extend(true, commonOptions, {
mode: "xml",
theme: "default"
}));
} else if (dataFromType == 4){
// SQL数据源
showGrid({
id: "sqlDataBase",
url: reportBasePath + "reportdatabase006",
params: {},
pagination: false,
template: selOption,
method: "GET",
ajaxSendLoadBefore: function(hdb) {
},
ajaxSendAfter:function (json) {
}
});
sqlContent = CodeMirror.fromTextArea(document.getElementById("sqlData"), $.extend(true, commonOptions, {
mode: "text/x-sql",
theme: "default"
}));
}
}
function getCommonCodeMirrorOptions(){
return {
mode: "xml", // 模式
theme: "eclipse", // CSS样式选择
indentUnit: 4, // 缩进单位,默认2
smartIndent: true, // 是否智能缩进
tabSize: 4, // Tab缩进,默认4
readOnly: false, // 是否只读,默认false
showCursorWhenSelecting: true,
lineNumbers: true, // 是否显示行号
styleActiveLine: true, //line选择是是否加亮
matchBrackets: true,
extraKeys:{
"F7": function autoFormat(editor) {
// 代码格式化
var totalLines = editor.lineCount();
editor.autoFormatRange({line:0, ch:0}, {line:totalLines});
}
}
};
}
/**
* 字段解析
*/
$("body").on("click", "#fieldResolution", function(e) {
var dataFromType = $("input[name='dataFromType']:checked").val();
var url = "";
var params = getResolutionInputParams(dataFromType, e);
if(params == null){
return false;
}
if (dataFromType == 1){
// XML数据源
url = "reportcommon002";
} else if (dataFromType == 2){
// JSON数据源
url = "reportcommon003";
} else if (dataFromType == 3){
// Rest接口数据源
url = "reportcommon005";
} else if (dataFromType == 4){
// SQL数据源
url = "reportcommon004";
}
AjaxPostUtil.request({url: reportBasePath + url, params: params, type: 'json', method: "POST", callback: function(json) {
var data = getDataByDataFromType(dataFromType, json);
loadFieldResolution(dataFromType, data);
}});
});
/**
* 字段解析时根据不同的数据源类型获取入参
*
* @param dataFromType 数据源类型
* @returns {boolean}
*/
function getResolutionInputParams(dataFromType, e){
var params = {};
if (dataFromType == 1){
// XML数据源
params = {
xmlText: xmlContent.getValue()
};
} else if (dataFromType == 2){
// JSON数据源
params = {
jsonText: jsonContent.getValue()
};
} else if (dataFromType == 3){
// Rest接口数据源
if(isNull($("#restUrl").val())) {
winui.window.msg('请填写url', {icon: 2, time: 2000});
return null;
}
params = {
requestUrl: $("#restUrl").val(),
requestMethod: $("#restMethod").val(),
requestHeader: getRestRequestHeaderDataToResolution(),
requestBody: restRequestBodyContent.getValue()
};
} else if (dataFromType == 4){
// SQL数据源
if(isNull($("#sqlDataBase").val())) {
winui.window.msg('请选择数据库', {icon: 2, time: 2000});
return null;
}
if(isNull(sqlContent.getValue())){
winui.window.msg('请填写sql语句', {icon: 2, time: 2000});
return null;
}
params = {
sqlText: sqlContent.getValue(),
dataBaseId: $("#sqlDataBase").val()
};
}
return params;
}
function getRestRequestHeaderDataToResolution(){
var tableData = new Array();
var rowTr = $("#restHeaderTable tr");
$.each(rowTr, function(i, item) {
//获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", "");
tableData[$("#headerKey" + rowNum).val()] = $("#headerValue" + rowNum).val();
});
return JSON.stringify(tableData);
}
function getDataByDataFromType(dataFromType, json){
if (dataFromType == 1){
// XML数据源
return json.bean.nodeArray;
} else if (dataFromType == 2){
// JSON数据源
return json.bean.nodeArray;
} else if (dataFromType == 3){
// Rest接口数据源
return json.bean.nodeArray;
} else if (dataFromType == 4){
// SQL数据源
return json.rows;
}
}
/**
* 加载解析的字段
*
* @param dataFromType 数据源类型
* @param data 数据
*/
function loadFieldResolution(dataFromType, data){
$("#analysisTable").html("");
$.each(data, function (i, item) {
addAnalysisRow();
$("#key" + (rowNum - 1)).val(item);
if (dataFromType == 1){
// XML数据源
} else if (dataFromType == 2){
// JSON数据源
} else if (dataFromType == 3){
// Rest接口数据源
} else if (dataFromType == 4){
// SQL数据源
$("#key" + (rowNum - 1)).val(item.name);
$("#dataType" + (rowNum - 1)).val(item.dataType);
$("#dataLength" + (rowNum - 1)).val(item.width);
$("#dataPrecision" + (rowNum - 1)).val(item.decimals);
}
});
}
/**********************************rest数据源header--start**************************************/
//新增行
$("body").on("click", "#addRow", function() {
addRow();
});
//删除行
$("body").on("click", "#deleteRow", function() {
deleteRow();
});
//新增行
function addRow() {
var par = {
id: "row" + rowNum.toString(), //checkbox的id
trId: "tr" + rowNum.toString(), //行的id
headerKey: "headerKey" + rowNum.toString(), // 配置项id
headerValue: "headerValue" + rowNum.toString(), // 配置值id
headerDescription: "headerDescription" + rowNum.toString() // 备注id
};
$("#restHeaderTable").append(getDataUseHandlebars($("#headerTemplate").html(), par));
form.render();
rowNum++;
}
//删除行
function deleteRow() {
var checkRow = $("#restHeaderTable input[type='checkbox'][name='tableCheckRow']:checked");
if(checkRow.length > 0) {
$.each(checkRow, function(i, item) {
//移除界面上的信息
$(item).parent().parent().remove();
});
} else {
winui.window.msg('请选择要删除的行', {icon: 2, time: 2000});
}
}
/**********************************rest数据源header--end**************************************/
/**********************************字段解析--start**************************************/
//新增行
$("body").on("click", "#addAnalysisRow", function() {
addAnalysisRow();
});
//删除行
$("body").on("click", "#deleteAnalysisRow", function() {
deleteAnalysisRow();
});
//新增行
function addAnalysisRow() {
var par = {
id: "row" + rowNum.toString(), //checkbox的id
trId: "tr" + rowNum.toString(), //行的id
key: "key" + rowNum.toString(), // 字段id
title: "title" + rowNum.toString(), // 含义id
dataType: "dataType" + rowNum.toString(), // 字段类型id
dataLength: "dataLength" + rowNum.toString(), // 字段长度id
dataPrecision: "dataPrecision" + rowNum.toString(), // 字段精度id
remark: "remark" + rowNum.toString() // 备注id
};
$("#analysisTable").append(getDataUseHandlebars($("#analysisTemplate").html(), par));
form.render();
rowNum++;
}
//删除行
function deleteAnalysisRow() {
var checkRow = $("#analysisTable input[type='checkbox'][name='tableCheckRow']:checked");
if(checkRow.length > 0) {
$.each(checkRow, function(i, item) {
//移除界面上的信息
$(item).parent().parent().remove();
});
} else {
winui.window.msg('请选择要删除的行', {icon: 2, time: 2000});
}
}
/**********************************字段解析--end**************************************/
$("body").on("click", "#cancle", function() {
parent.layer.close(index);
});
});
});
\ No newline at end of file
......@@ -11,97 +11,67 @@ layui.config({
form = layui.form,
table = layui.table;
// 数据源类型列表
showGrid({
id: "dataFromType",
url: reportBasePath + "reportcommon008",
params: {},
pagination: false,
template: getFileContent('tpl/template/select-option.tpl'),
method: "GET",
ajaxSendLoadBefore: function(hdb) {
},
ajaxSendAfter:function (json) {
initTable();
}
});
// 数据源选择列表
function initTable(){
table.render({
id: 'messageTable',
elem: '#messageTable',
method: 'post',
url: reportBasePath + 'reportdatafrom006',
where: getTableParams(),
even: true,
page: true,
limits: getLimits(),
limit: getLimit(),
cols: [[
{ type: 'radio'},
{ title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' },
{ field: 'name', title: '名称', align: 'left', width: 150 },
{ field: 'typeName', title: '来源', align: 'left', width: 100 },
{ field: 'remark', title: '备注', align: 'left', width: 150 },
{ field: 'createName', title: '创建人', align: 'left', width: 120 },
{ field: 'createTime', title: '创建时间', align: 'center', width: 140 },
{ field: 'lastUpdateName', title: '最后修改人', align: 'left', width: 120 },
{ field: 'lastUpdateTime', title: '最后修改时间', align: 'center', width: 140}
]],
done: function(res){
matchingLanguage();
$('#messageTable').next().find('.layui-table-body').find("table" ).find("tbody").children("tr").on('dblclick',function(){
var dubClick = $('#messageTable').next().find('.layui-table-body').find("table").find("tbody").find(".layui-table-hover");
dubClick.find("input[type='radio']").prop("checked", true);
form.render();
var id = JSON.stringify(dubClick.data('index'));
var obj = res.rows[id];
parent.dataBaseMation = obj;
parent.layer.close(index);
parent.refreshCode = '0';
});
$('#messageTable').next().find('.layui-table-body').find("table" ).find("tbody").children("tr").on('click',function(){
var click = $('#messageTable').next().find('.layui-table-body').find("table").find("tbody").find(".layui-table-hover");
click.find("input[type='radio']").prop("checked", true);
form.render();
})
}
});
table.render({
id: 'messageTable',
elem: '#messageTable',
method: 'post',
url: sysMainMation.reportBasePath + 'queryReportDataFromList',
where: getTableParams(),
even: true,
page: true,
limits: getLimits(),
limit: getLimit(),
cols: [[
{ type: 'radio'},
{ title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' },
{ field: 'name', title: '名称', align: 'left', width: 150 },
{ field: 'typeName', title: '来源', align: 'left', width: 100 },
{ field: 'remark', title: '备注', align: 'left', width: 150 },
{ field: 'createName', title: '创建人', align: 'left', width: 120 },
{ field: 'createTime', title: '创建时间', align: 'center', width: 140 },
{ field: 'lastUpdateName', title: '最后修改人', align: 'left', width: 120 },
{ field: 'lastUpdateTime', title: '最后修改时间', align: 'center', width: 140}
]],
done: function(res){
matchingLanguage();
initTableSearchUtil.initAdvancedSearch(this, json.searchFilter, form, "请输入名称", function () {
table.reloadData("messageTable", {page: {curr: 1}, where: getTableParams()});
});
$('#messageTable').next().find('.layui-table-body').find("table" ).find("tbody").children("tr").on('dblclick',function(){
var dubClick = $('#messageTable').next().find('.layui-table-body').find("table").find("tbody").find(".layui-table-hover");
dubClick.find("input[type='radio']").prop("checked", true);
form.render();
var id = JSON.stringify(dubClick.data('index'));
var obj = res.rows[id];
parent.dataBaseMation = obj;
parent.layer.close(index);
parent.refreshCode = '0';
});
table.on('tool(messageTable)', function (obj) {
var data = obj.data;
var layEvent = obj.event;
});
}
form.render();
form.on('submit(formSearch)', function (data) {
if (winui.verifyForm(data.elem)) {
refreshloadTable();
$('#messageTable').next().find('.layui-table-body').find("table" ).find("tbody").children("tr").on('click',function(){
var click = $('#messageTable').next().find('.layui-table-body').find("table").find("tbody").find(".layui-table-hover");
click.find("input[type='radio']").prop("checked", true);
form.render();
})
}
return false;
});
// 刷新数据
table.on('tool(messageTable)', function (obj) {
var data = obj.data;
var layEvent = obj.event;
});
form.render();
$("body").on("click", "#reloadTable", function() {
loadTable();
});
function loadTable() {
table.reloadData("messageTable", {where: getTableParams()});
}
function refreshloadTable() {
table.reloadData("messageTable", {page: {curr: 1}, where: getTableParams()});
}
function getTableParams() {
return {
name: $("#name").val(),
type: $("#dataFromType").val()
};
return $.extend(true, {}, initTableSearchUtil.getSearchValue("messageTable"));
}
exports('reportDataFromChooseList', {});
......
// 表格的序号
var rowNum = 1;
layui.config({
base: basePath,
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'codemirror', 'xml', 'sql'], function (exports) {
winui.renderColor();
layui.use(['form'], function (form) {
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$;
var selOption = getFileContent('tpl/template/select-option.tpl');
var xmlContent, jsonContent, sqlContent, restRequestBodyContent;
// 数据来源类型
var dataFromType;
showGrid({
id: "showForm",
url: reportBasePath + "reportdatafrom005",
params: {id: parent.rowId},
pagination: false,
method: "GET",
template: $("#showBaseTemplate").html(),
ajaxSendLoadBefore: function(hdb) {
},
ajaxSendAfter:function(j){
$("#dataBox").html(getFileContent(j.bean.staticTplPath));
dataFromType = j.bean.type;
initEvent(j.bean);
$("#analysisHeader").html($("#analysisHeaderTemplate").html());
$.each(j.bean.analysisData, function (i, item) {
addAnalysisRow();
$("#key" + (rowNum - 1)).val(item.key);
$("#title" + (rowNum - 1)).val(item.name);
$("#remark" + (rowNum - 1)).val(item.remark);
if (dataFromType == 4){
$("#dataType" + (rowNum - 1)).val(item.dataType);
$("#dataLength" + (rowNum - 1)).val(item.dataLength);
$("#dataPrecision" + (rowNum - 1)).val(item.dataPrecision);
}
});
matchingLanguage();
form.render();
form.on('submit(formEditBean)', function (data) {
if (winui.verifyForm(data.elem)) {
var params = {
name: $("#name").val(),
remark: $("#remark").val(),
analysisData: getAnalysisData(),
type: dataFromType,
id: parent.rowId
};
if(JSON.parse(params.analysisData).length == 0){
winui.window.msg('请进行字段解析操作。', {icon: 2, time: 2000});
return false;
}
var otherData = getDataByType();
if((isNull(otherData.xmlContent) && dataFromType == 1)
|| (isNull(otherData.jsonContent) && dataFromType == 2)
|| (isNull(otherData.sqlContent) && dataFromType == 4)){
winui.window.msg('必填项不能为空', {icon: 2, time: 2000});
return false;
}
params = $.extend(true, params, otherData);
AjaxPostUtil.request({url: reportBasePath + "reportdatafrom004", params: params, type: 'json', method: "PUT", callback: function(json) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
}
return false;
});
}
});
function getDataByType(){
if (dataFromType == 1){
// XML数据源
return getXMLData();
} else if (dataFromType == 2){
// JSON数据源
return getJSONData();
} else if (dataFromType == 3){
// Rest接口数据源
return getRESTData();
} else if (dataFromType == 4){
// SQL数据源
return getSQLData();
}
return {};
}
function getXMLData(){
return {
xmlContent: xmlContent.getValue()
};
}
function getJSONData(){
return {
jsonContent: jsonContent.getValue()
};
}
function getRESTData(){
return {
restUrl: $("#restUrl").val(),
method: $("#restMethod").val(),
header: getRestRequestHeaderData(),
requestBody: restRequestBodyContent.getValue()
};
}
function getSQLData(){
return {
sqlDataBaseId: $("#sqlDataBase").val(),
sqlContent: sqlContent.getValue()
};
}
function getAnalysisData(){
var tableData = new Array();
var rowTr = $("#analysisTable tr");
$.each(rowTr, function(i, item) {
//获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", "");
var row = {
key: $("#key" + rowNum).val(),
title: $("#title" + rowNum).val(),
dataType: $("#dataType" + rowNum).val(),
dataLength: $("#dataLength" + rowNum).val(),
dataPrecision: $("#dataPrecision" + rowNum).val(),
remark: $("#remark" + rowNum).val()
};
tableData.push(row);
});
return JSON.stringify(tableData);
}
function getRestRequestHeaderData(){
var tableData = new Array();
var rowTr = $("#restHeaderTable tr");
$.each(rowTr, function(i, item) {
//获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", "");
var row = {
headerKey: $("#headerKey" + rowNum).val(),
headerValue: $("#headerValue" + rowNum).val(),
headerDescription: $("#headerDescription" + rowNum).val()
};
tableData.push(row);
});
return JSON.stringify(tableData);
}
function initEvent(bean){
// 获取公共的配置信息
var commonOptions = getCommonCodeMirrorOptions();
if (dataFromType == 1){
// XML数据源
xmlContent = CodeMirror.fromTextArea(document.getElementById("xmlData"), $.extend(true, commonOptions, {
mode: "xml",
theme: "default"
}));
xmlContent.setValue(bean.xmlContent);
} else if (dataFromType == 2){
// JSON数据源
jsonContent = CodeMirror.fromTextArea(document.getElementById("jsonData"), $.extend(true, commonOptions, {
mode: "xml",
theme: "default"
}));
jsonContent.setValue(bean.jsonContent);
} else if (dataFromType == 3){
// Rest接口数据源
$("#restUrl").val(bean.restUrl);
$("#restMethod").val(bean.restMethod);
if (!isNull(bean.restHeader)) {
$.each(JSON.parse(bean.restHeader), function (i, item) {
addRow();
$("#headerKey" + (rowNum - 1)).val(item.headerKey);
$("#headerValue" + (rowNum - 1)).val(item.headerValue);
$("#headerDescription" + (rowNum - 1)).val(item.headerDescription);
});
}
restRequestBodyContent = CodeMirror.fromTextArea(document.getElementById("requestBody"), $.extend(true, commonOptions, {
mode: "xml",
theme: "default"
}));
if (!isNull(bean.restContent)){
restRequestBodyContent.setValue(bean.restContent);
}
} else if (dataFromType == 4){
// SQL数据源
showGrid({
id: "sqlDataBase",
url: reportBasePath + "reportdatabase006",
params: {},
pagination: false,
template: selOption,
method: "GET",
ajaxSendLoadBefore: function(hdb) {
},
ajaxSendAfter:function (json) {
$("#sqlDataBase").val(bean.sqlDataBaseId);
}
});
sqlContent = CodeMirror.fromTextArea(document.getElementById("sqlData"), $.extend(true, commonOptions, {
mode: "text/x-sql",
theme: "default"
}));
sqlContent.setValue(bean.sqlContent);
}
}
function getCommonCodeMirrorOptions(){
return {
mode: "xml", // 模式
theme: "eclipse", // CSS样式选择
indentUnit: 4, // 缩进单位,默认2
smartIndent: true, // 是否智能缩进
tabSize: 4, // Tab缩进,默认4
readOnly: false, // 是否只读,默认false
showCursorWhenSelecting: true,
lineNumbers: true, // 是否显示行号
styleActiveLine: true, //line选择是是否加亮
matchBrackets: true,
extraKeys:{
"F7": function autoFormat(editor) {
// 代码格式化
var totalLines = editor.lineCount();
editor.autoFormatRange({line:0, ch:0}, {line:totalLines});
}
}
};
}
/**
* 字段解析
*/
$("body").on("click", "#fieldResolution", function(e) {
var url = "";
var params = getResolutionInputParams(e);
if(params == null){
return false;
}
if (dataFromType == 1){
// XML数据源
url = "reportcommon002";
} else if (dataFromType == 2){
// JSON数据源
url = "reportcommon003";
} else if (dataFromType == 3){
// Rest接口数据源
url = "reportcommon005";
} else if (dataFromType == 4){
// SQL数据源
url = "reportcommon004";
}
AjaxPostUtil.request({url: reportBasePath + url, params: params, type: 'json', method: "POST", callback: function(json) {
var data = getDataByDataFromType(json);
loadFieldResolution(data);
}});
});
/**
* 字段解析时根据不同的数据源类型获取入参
*
* @returns {boolean}
*/
function getResolutionInputParams(e){
var params = {};
if (dataFromType == 1){
// XML数据源
params = {
xmlText: xmlContent.getValue()
};
} else if (dataFromType == 2){
// JSON数据源
params = {
jsonText: jsonContent.getValue()
};
} else if (dataFromType == 3){
// Rest接口数据源
if(isNull($("#restUrl").val())) {
winui.window.msg('请填写url', {icon: 2, time: 2000});
return null;
}
params = {
requestUrl: $("#restUrl").val(),
requestMethod: $("#restMethod").val(),
requestHeader: getRestRequestHeaderDataToResolution(),
requestBody: restRequestBodyContent.getValue()
};
} else if (dataFromType == 4){
// SQL数据源
if(isNull($("#sqlDataBase").val())) {
winui.window.msg('请选择数据库', {icon: 2, time: 2000});
return null;
}
if(isNull(sqlContent.getValue())){
winui.window.msg('请填写sql语句', {icon: 2, time: 2000});
return null;
}
params = {
sqlText: sqlContent.getValue(),
dataBaseId: $("#sqlDataBase").val()
};
}
return params;
}
function getRestRequestHeaderDataToResolution(){
var tableData = new Array();
var rowTr = $("#restHeaderTable tr");
$.each(rowTr, function(i, item) {
//获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", "");
tableData[$("#headerKey" + rowNum).val()] = $("#headerValue" + rowNum).val();
});
return JSON.stringify(tableData);
}
function getDataByDataFromType(json){
if (dataFromType == 1){
// XML数据源
return json.bean.nodeArray;
} else if (dataFromType == 2){
// JSON数据源
return json.bean.nodeArray;
} else if (dataFromType == 3){
// Rest接口数据源
return json.bean.nodeArray;
} else if (dataFromType == 4){
// SQL数据源
return json.rows;
}
}
/**
* 加载解析的字段
*
* @param data 数据
*/
function loadFieldResolution(data) {
$("#analysisTable").html("");
$.each(data, function (i, item) {
addAnalysisRow();
$("#key" + (rowNum - 1)).val(item);
if (dataFromType == 1){
// XML数据源
} else if (dataFromType == 2){
// JSON数据源
} else if (dataFromType == 3){
// Rest接口数据源
} else if (dataFromType == 4){
// SQL数据源
$("#key" + (rowNum - 1)).val(item.name);
$("#dataType" + (rowNum - 1)).val(item.dataType);
$("#dataLength" + (rowNum - 1)).val(item.width);
$("#dataPrecision" + (rowNum - 1)).val(item.decimals);
}
});
}
/**********************************rest数据源header--start**************************************/
//新增行
$("body").on("click", "#addRow", function() {
addRow();
});
//删除行
$("body").on("click", "#deleteRow", function() {
deleteRow();
});
//新增行
function addRow() {
var par = {
id: "row" + rowNum.toString(), //checkbox的id
trId: "tr" + rowNum.toString(), //行的id
headerKey: "headerKey" + rowNum.toString(), // 配置项id
headerValue: "headerValue" + rowNum.toString(), // 配置值id
headerDescription: "headerDescription" + rowNum.toString() // 备注id
};
$("#restHeaderTable").append(getDataUseHandlebars($("#headerTemplate").html(), par));
form.render();
rowNum++;
}
//删除行
function deleteRow() {
var checkRow = $("#restHeaderTable input[type='checkbox'][name='tableCheckRow']:checked");
if(checkRow.length > 0) {
$.each(checkRow, function(i, item) {
//移除界面上的信息
$(item).parent().parent().remove();
});
} else {
winui.window.msg('请选择要删除的行', {icon: 2, time: 2000});
}
}
/**********************************rest数据源header--end**************************************/
/**********************************字段解析--start**************************************/
//新增行
$("body").on("click", "#addAnalysisRow", function() {
addAnalysisRow();
});
//删除行
$("body").on("click", "#deleteAnalysisRow", function() {
deleteAnalysisRow();
});
//新增行
function addAnalysisRow() {
var par = {
id: "row" + rowNum.toString(), //checkbox的id
trId: "tr" + rowNum.toString(), //行的id
key: "key" + rowNum.toString(), // 字段id
title: "title" + rowNum.toString(), // 含义id
dataType: "dataType" + rowNum.toString(), // 字段类型id
dataLength: "dataLength" + rowNum.toString(), // 字段长度id
dataPrecision: "dataPrecision" + rowNum.toString(), // 字段精度id
remark: "remark" + rowNum.toString() // 备注id
};
$("#analysisTable").append(getDataUseHandlebars($("#analysisTemplate").html(), par));
form.render();
rowNum++;
}
//删除行
function deleteAnalysisRow() {
var checkRow = $("#analysisTable input[type='checkbox'][name='tableCheckRow']:checked");
if(checkRow.length > 0) {
$.each(checkRow, function(i, item) {
//移除界面上的信息
$(item).parent().parent().remove();
});
} else {
winui.window.msg('请选择要删除的行', {icon: 2, time: 2000});
}
}
/**********************************字段解析--end**************************************/
$("body").on("click", "#cancle", function() {
parent.layer.close(index);
});
});
});
\ No newline at end of file
var rowId = "";
layui.config({
base: basePath,
version: skyeyeVersion
......@@ -14,64 +12,50 @@ layui.config({
authBtn('1622876929121');
// 数据源类型列表
showGrid({
id: "dataFromType",
url: reportBasePath + "reportcommon008",
params: {},
pagination: false,
template: getFileContent('tpl/template/select-option.tpl'),
method: "GET",
ajaxSendLoadBefore: function(hdb) {
},
ajaxSendAfter:function (json) {
initTable();
// 数据源列表
table.render({
id: 'messageTable',
elem: '#messageTable',
method: 'post',
url: sysMainMation.reportBasePath + 'queryReportDataFromList',
where: getTableParams(),
even: true,
page: true,
limits: getLimits(),
limit: getLimit(),
cols: [[
{ title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' },
{ field: 'name', title: '名称', align: 'left', width: 150 },
{ field: 'typeName', title: '来源', align: 'left', width: 150 },
{ field: 'remark', title: '备注', align: 'left', width: 150 },
{ field: 'createName', title: systemLanguage["com.skyeye.createName"][languageType], width: 120 },
{ field: 'createTime', title: systemLanguage["com.skyeye.createTime"][languageType], align: 'center', width: 150 },
{ field: 'lastUpdateName', title: systemLanguage["com.skyeye.lastUpdateName"][languageType], align: 'left', width: 120 },
{ field: 'lastUpdateTime', title: systemLanguage["com.skyeye.lastUpdateTime"][languageType], align: 'center', width: 150 },
{ title: systemLanguage["com.skyeye.operation"][languageType], fixed: 'right', align: 'center', width: 200, toolbar: '#tableBar'}
]],
done: function(json) {
matchingLanguage();
initTableSearchUtil.initAdvancedSearch(this, json.searchFilter, form, "请输入名称", function () {
table.reloadData("messageTable", {page: {curr: 1}, where: getTableParams()});
});
}
});
// 数据源列表
function initTable(){
table.render({
id: 'messageTable',
elem: '#messageTable',
method: 'post',
url: reportBasePath + 'reportdatafrom001',
where: getTableParams(),
even: true,
page: true,
limits: getLimits(),
limit: getLimit(),
cols: [[
{ title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' },
{ field: 'name', title: '名称', align: 'left', width: 150 },
{ field: 'typeName', title: '来源', align: 'left', width: 150 },
{ field: 'remark', title: '备注', align: 'left', width: 150 },
{ field: 'createName', title: '创建人', align: 'left', width: 120 },
{ field: 'createTime', title: '创建时间', align: 'center', width: 140 },
{ field: 'lastUpdateName', title: '最后修改人', align: 'left', width: 120 },
{ field: 'lastUpdateTime', title: '最后修改时间', align: 'center', width: 140},
{ title: systemLanguage["com.skyeye.operation"][languageType], fixed: 'right', align: 'center', width: 200, toolbar: '#tableBar'}
]],
done: function(json) {
matchingLanguage();
}
});
table.on('tool(messageTable)', function (obj) {
var data = obj.data;
var layEvent = obj.event;
if (layEvent === 'edit') { //编辑
edit(data);
} else if (layEvent === 'delet') { //删除
delet(data);
}
});
}
table.on('tool(messageTable)', function (obj) {
var data = obj.data;
var layEvent = obj.event;
if (layEvent === 'edit') { //编辑
edit(data);
} else if (layEvent === 'delet') { //删除
delet(data);
}
});
//添加
$("body").on("click", "#addBean", function() {
_openNewWindows({
url: "../../tpl/reportDataFrom/reportDataFromAdd.html",
url: "../../tpl/reportDataFrom/reportDataFromWrite.html",
title: systemLanguage["com.skyeye.addPageTitle"][languageType],
pageId: "reportDataFromAdd",
area: ['90vw', '90vh'],
......@@ -85,7 +69,7 @@ layui.config({
function delet(data) {
layer.confirm(systemLanguage["com.skyeye.deleteOperationMsg"][languageType], {icon: 3, title: systemLanguage["com.skyeye.deleteOperation"][languageType]}, function (index) {
layer.close(index);
AjaxPostUtil.request({url: reportBasePath + "reportdatafrom003", params: {id: data.id}, type: 'json', method: "DELETE", callback: function(json) {
AjaxPostUtil.request({url: sysMainMation.reportBasePath + "delReportDataFromById", params: {id: data.id}, type: 'json', method: "DELETE", callback: function(json) {
winui.window.msg(systemLanguage["com.skyeye.deleteOperationSuccessMsg"][languageType], {icon: 1, time: 2000});
loadTable();
}});
......@@ -94,9 +78,8 @@ layui.config({
// 编辑
function edit(data) {
rowId = data.id;
_openNewWindows({
url: "../../tpl/reportDataFrom/reportDataFromEdit.html",
url: "../../tpl/reportDataFrom/reportDataFromWrite.html?id=" + data.id,
title: systemLanguage["com.skyeye.editPageTitle"][languageType],
pageId: "reportDataFromEdit",
area: ['90vw', '90vh'],
......@@ -108,31 +91,15 @@ layui.config({
}
form.render();
form.on('submit(formSearch)', function (data) {
if (winui.verifyForm(data.elem)) {
refreshloadTable();
}
return false;
});
// 刷新数据
$("body").on("click", "#reloadTable", function() {
loadTable();
});
function loadTable() {
table.reloadData("messageTable", {where: getTableParams()});
}
function refreshloadTable() {
table.reloadData("messageTable", {page: {curr: 1}, where: getTableParams()});
}
function getTableParams() {
return {
name: $("#name").val(),
type: $("#dataFromType").val()
};
return $.extend(true, {}, initTableSearchUtil.getSearchValue("messageTable"));
}
exports('reportDataFromList', {});
......
// 表格的序号
var rowNum = 1;
layui.config({
base: basePath,
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'codemirror', 'xml', 'sql', 'form'], function (exports) {
winui.renderColor();
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
form = layui.form;
var selOption = getFileContent('tpl/template/select-option.tpl');
var xmlContent, jsonContent, sqlContent, restRequestBodyContent;
var id = GetUrlParam("id");
if (isNull(id)) {
skyeyeClassEnumUtil.showEnumDataListByClassName("reportDataFromType", 'radio', "dataFromTypeBox", '', form);
initDataFromBoxContent(dataShowType.getData('dataFromTypeBox'), null)
} else {
AjaxPostUtil.request({url: sysMainMation.reportBasePath + "queryReportDataFromById", params: {id: id}, type: 'json', method: 'GET', callback:function(data) {
$("#name").val(data.bean.name);
$("#remark").val(data.bean.remark);
skyeyeClassEnumUtil.showEnumDataListByClassName("reportDataFromType", 'radio', "dataFromTypeBox", data.bean.type, form);
initDataFromBoxContent(data.bean.type, data.bean)
var list = []
if (data.bean.type == 1) {
// XML数据源
list = data.bean.xmlEntity.analysisList
} else if (data.bean.type == 2) {
// JSON数据源
list = data.bean.jsonEntity.analysisList
} else if (data.bean.type == 3) {
// Rest接口数据源
list = data.bean.restEntity.analysisList
} else if (data.bean.type == 4) {
// SQL数据源
list = data.bean.sqlEntity.analysisList
}
$.each(list, function (i, item) {
addAnalysisRow();
$("#key" + (rowNum - 1)).val(item.key);
$("#name" + (rowNum - 1)).val(item.name);
$("#remark" + (rowNum - 1)).val(item.remark);
if (data.bean.type == 4) {
$("#dataType" + (rowNum - 1)).val(item.dataType);
$("#dataLength" + (rowNum - 1)).val(item.dataLength);
$("#dataPrecision" + (rowNum - 1)).val(item.dataPrecision);
}
});
form.render();
}});
}
matchingLanguage();
form.render();
form.on('submit(formWriteBean)', function (data) {
if (winui.verifyForm(data.elem)) {
var params = {
name: $("#name").val(),
remark: $("#remark").val(),
type: dataShowType.getData('dataFromTypeBox'),
id: isNull(id) ? '' : id
};
if (getAnalysisData().length == 0) {
winui.window.msg('请进行字段解析操作。', {icon: 2, time: 2000});
return false;
}
var otherData = getDataByType();
params = $.extend(true, params, otherData);
AjaxPostUtil.request({url: sysMainMation.reportBasePath + "saveReportDataFrom", params: params, type: 'json', method: "POST", callback: function(json) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
}
return false;
});
function getDataByType() {
var dataFromType = dataShowType.getData('dataFromTypeBox');
if (dataFromType == 1) {
// XML数据源
return getXMLData();
} else if (dataFromType == 2) {
// JSON数据源
return getJSONData();
} else if (dataFromType == 3) {
// Rest接口数据源
return getRESTData();
} else if (dataFromType == 4) {
// SQL数据源
return getSQLData();
}
return {};
}
function getXMLData() {
return {
xmlEntity: JSON.stringify({
xmlContent: xmlContent.getValue(),
analysisList: getAnalysisData()
})
};
}
function getJSONData() {
return {
jsonEntity: JSON.stringify({
jsonContent: jsonContent.getValue(),
analysisList: getAnalysisData()
})
};
}
function getRESTData() {
return {
restEntity: JSON.stringify({
restUrl: $("#restUrl").val(),
method: $("#restMethod").val(),
header: getRestRequestHeaderData(),
requestBody: restRequestBodyContent.getValue(),
analysisList: getAnalysisData()
})
};
}
function getSQLData() {
return {
sqlEntity: JSON.stringify({
dataBaseId: $("#dataBaseId").val(),
sqlContent: sqlContent.getValue(),
analysisList: getAnalysisData()
})
};
}
function getAnalysisData(){
var tableData = new Array();
var rowTr = $("#analysisTable tr");
$.each(rowTr, function(i, item) {
//获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", "");
var row = {
key: $("#key" + rowNum).val(),
name: $("#name" + rowNum).val(),
dataType: $("#dataType" + rowNum).val(),
dataLength: $("#dataLength" + rowNum).val(),
dataPrecision: $("#dataPrecision" + rowNum).val(),
remark: $("#remark" + rowNum).val()
};
tableData.push(row);
});
return tableData;
}
function getRestRequestHeaderData(){
var tableData = new Array();
var rowTr = $("#restHeaderTable tr");
$.each(rowTr, function(i, item) {
//获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", "");
var row = {
headerKey: $("#headerKey" + rowNum).val(),
headerValue: $("#headerValue" + rowNum).val(),
headerDescription: $("#headerDescription" + rowNum).val()
};
tableData.push(row);
});
return JSON.stringify(tableData);
}
form.on('radio(dataFromTypeBoxFilter)', function (data) {
var val = data.value;
initDataFromBoxContent(val, null);
});
function initDataFromBoxContent(val, bean){
$("#dataBox").html(getAnalysisHtmlByType(val));
// 加载字段解析信息
$("#analysisHeader").html($("#analysisHeaderTemplate").html());
$("#analysisTable").html("");
initEvent(val, bean);
form.render();
}
function getAnalysisHtmlByType(dataFromType) {
var tplPath = '';
if (dataFromType == 1) {
// XML数据源
tplPath = "../../tpl/reportDataFrom/dataFromTpl/xmlTemplate.tpl"
} else if (dataFromType == 2) {
// JSON数据源
tplPath = "../../tpl/reportDataFrom/dataFromTpl/jsonTemplate.tpl"
} else if (dataFromType == 3) {
// Rest接口数据源
tplPath = "../../tpl/reportDataFrom/dataFromTpl/restTemplate.tpl"
} else if (dataFromType == 4) {
// SQL数据源
tplPath = "../../tpl/reportDataFrom/dataFromTpl/sqlTemplate.tpl"
}
return getFileContent(tplPath);
}
function initEvent(dataFromType, bean) {
// 获取公共的配置信息
var commonOptions = getCommonCodeMirrorOptions();
if (dataFromType == 1) {
// XML数据源
xmlContent = CodeMirror.fromTextArea(document.getElementById("xmlData"), $.extend(true, commonOptions, {
mode: "xml",
theme: "default"
}));
if (!isNull(bean)) {
xmlContent.setValue(bean.xmlEntity.xmlContent);
}
} else if (dataFromType == 2) {
// JSON数据源
jsonContent = CodeMirror.fromTextArea(document.getElementById("jsonData"), $.extend(true, commonOptions, {
mode: "xml",
theme: "default"
}));
if (!isNull(bean)) {
jsonContent.setValue(bean.jsonEntity.jsonContent);
}
} else if (dataFromType == 3) {
// Rest接口数据源
restRequestBodyContent = CodeMirror.fromTextArea(document.getElementById("requestBody"), $.extend(true, commonOptions, {
mode: "xml",
theme: "default"
}));
if (!isNull(bean)) {
$("#restUrl").val(bean.restEntity.restUrl);
$("#restMethod").val(bean.restEntity.method);
if (!isNull(bean.restEntity.header)) {
$.each(bean.restEntity.header, function (i, item) {
addRow();
$("#headerKey" + (rowNum - 1)).val(item.headerKey);
$("#headerValue" + (rowNum - 1)).val(item.headerValue);
$("#headerDescription" + (rowNum - 1)).val(item.headerDescription);
});
}
restRequestBodyContent.setValue(bean.restEntity.requestBody);
}
} else if (dataFromType == 4) {
// SQL数据源
showGrid({
id: "dataBaseId",
url: sysMainMation.reportBasePath + "queryAllDataBaseList",
params: {},
pagination: false,
template: selOption,
method: "GET",
ajaxSendLoadBefore: function(hdb) {},
ajaxSendAfter:function (json) {
if (!isNull(bean)) {
$("#dataBaseId").val(bean.sqlEntity.dataBaseId);
}
}
});
sqlContent = CodeMirror.fromTextArea(document.getElementById("sqlData"), $.extend(true, commonOptions, {
mode: "text/x-sql",
theme: "default"
}));
if (!isNull(bean)) {
sqlContent.setValue(bean.sqlEntity.sqlContent);
}
}
}
function getCommonCodeMirrorOptions() {
return {
mode: "xml", // 模式
theme: "eclipse", // CSS样式选择
indentUnit: 4, // 缩进单位,默认2
smartIndent: true, // 是否智能缩进
tabSize: 4, // Tab缩进,默认4
readOnly: false, // 是否只读,默认false
showCursorWhenSelecting: true,
lineNumbers: true, // 是否显示行号
styleActiveLine: true, //line选择是是否加亮
matchBrackets: true,
extraKeys:{
"F7": function autoFormat(editor) {
// 代码格式化
var totalLines = editor.lineCount();
editor.autoFormatRange({line:0, ch:0}, {line:totalLines});
}
}
};
}
/**
* 字段解析
*/
$("body").on("click", "#fieldResolution", function(e) {
var dataFromType = dataShowType.getData('dataFromTypeBox');
var url = "";
var params = getResolutionInputParams(dataFromType, e);
if (params == null) {
return false;
}
if (dataFromType == 1) {
// XML数据源
url = "reportcommon002";
} else if (dataFromType == 2) {
// JSON数据源
url = "reportcommon003";
} else if (dataFromType == 3) {
// Rest接口数据源
url = "reportcommon005";
} else if (dataFromType == 4) {
// SQL数据源
url = "reportcommon004";
}
AjaxPostUtil.request({url: sysMainMation.reportBasePath + url, params: params, type: 'json', method: "POST", callback: function(json) {
var data = getDataByDataFromType(dataFromType, json);
loadFieldResolution(dataFromType, data);
}});
});
/**
* 字段解析时根据不同的数据源类型获取入参
*
* @param dataFromType 数据源类型
* @returns {boolean}
*/
function getResolutionInputParams(dataFromType, e){
var params = {};
if (dataFromType == 1){
// XML数据源
params = {
xmlText: xmlContent.getValue()
};
} else if (dataFromType == 2){
// JSON数据源
params = {
jsonText: jsonContent.getValue()
};
} else if (dataFromType == 3){
// Rest接口数据源
if(isNull($("#restUrl").val())) {
winui.window.msg('请填写url', {icon: 2, time: 2000});
return null;
}
params = {
requestUrl: $("#restUrl").val(),
requestMethod: $("#restMethod").val(),
requestHeader: getRestRequestHeaderDataToResolution(),
requestBody: restRequestBodyContent.getValue()
};
} else if (dataFromType == 4){
// SQL数据源
if (isNull($("#dataBaseId").val())) {
winui.window.msg('请选择数据库', {icon: 2, time: 2000});
return null;
}
if (isNull(sqlContent.getValue())) {
winui.window.msg('请填写sql语句', {icon: 2, time: 2000});
return null;
}
params = {
sqlText: sqlContent.getValue(),
dataBaseId: $("#dataBaseId").val()
};
}
return params;
}
function getRestRequestHeaderDataToResolution(){
var tableData = new Array();
var rowTr = $("#restHeaderTable tr");
$.each(rowTr, function(i, item) {
//获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", "");
tableData[$("#headerKey" + rowNum).val()] = $("#headerValue" + rowNum).val();
});
return JSON.stringify(tableData);
}
function getDataByDataFromType(dataFromType, json){
if (dataFromType == 1){
// XML数据源
return json.bean.nodeArray;
} else if (dataFromType == 2){
// JSON数据源
return json.bean.nodeArray;
} else if (dataFromType == 3){
// Rest接口数据源
return json.bean.nodeArray;
} else if (dataFromType == 4){
// SQL数据源
return json.rows;
}
}
/**
* 加载解析的字段
*
* @param dataFromType 数据源类型
* @param data 数据
*/
function loadFieldResolution(dataFromType, data){
$("#analysisTable").html("");
$.each(data, function (i, item) {
addAnalysisRow();
$("#key" + (rowNum - 1)).val(item);
if (dataFromType == 1){
// XML数据源
} else if (dataFromType == 2){
// JSON数据源
} else if (dataFromType == 3){
// Rest接口数据源
} else if (dataFromType == 4){
// SQL数据源
$("#key" + (rowNum - 1)).val(item.name);
$("#dataType" + (rowNum - 1)).val(item.dataType);
$("#dataLength" + (rowNum - 1)).val(item.width);
$("#dataPrecision" + (rowNum - 1)).val(item.decimals);
}
});
}
/**********************************rest数据源header--start**************************************/
//新增行
$("body").on("click", "#addRow", function() {
addRow();
});
//删除行
$("body").on("click", "#deleteRow", function() {
deleteRow();
});
//新增行
function addRow() {
var par = {
id: "row" + rowNum.toString(), //checkbox的id
trId: "tr" + rowNum.toString(), //行的id
headerKey: "headerKey" + rowNum.toString(), // 配置项id
headerValue: "headerValue" + rowNum.toString(), // 配置值id
headerDescription: "headerDescription" + rowNum.toString() // 备注id
};
$("#restHeaderTable").append(getDataUseHandlebars($("#headerTemplate").html(), par));
form.render();
rowNum++;
}
//删除行
function deleteRow() {
var checkRow = $("#restHeaderTable input[type='checkbox'][name='tableCheckRow']:checked");
if(checkRow.length > 0) {
$.each(checkRow, function(i, item) {
//移除界面上的信息
$(item).parent().parent().remove();
});
} else {
winui.window.msg('请选择要删除的行', {icon: 2, time: 2000});
}
}
/**********************************rest数据源header--end**************************************/
/**********************************字段解析--start**************************************/
//新增行
$("body").on("click", "#addAnalysisRow", function() {
addAnalysisRow();
});
//删除行
$("body").on("click", "#deleteAnalysisRow", function() {
deleteAnalysisRow();
});
//新增行
function addAnalysisRow() {
var par = {
id: "row" + rowNum.toString(), //checkbox的id
trId: "tr" + rowNum.toString(), //行的id
key: "key" + rowNum.toString(), // 字段id
name: "name" + rowNum.toString(), // 含义id
dataType: "dataType" + rowNum.toString(), // 字段类型id
dataLength: "dataLength" + rowNum.toString(), // 字段长度id
dataPrecision: "dataPrecision" + rowNum.toString(), // 字段精度id
remark: "remark" + rowNum.toString() // 备注id
};
$("#analysisTable").append(getDataUseHandlebars($("#analysisTemplate").html(), par));
form.render();
rowNum++;
}
//删除行
function deleteAnalysisRow() {
var checkRow = $("#analysisTable input[type='checkbox'][name='tableCheckRow']:checked");
if(checkRow.length > 0) {
$.each(checkRow, function(i, item) {
//移除界面上的信息
$(item).parent().parent().remove();
});
} else {
winui.window.msg('请选择要删除的行', {icon: 2, time: 2000});
}
}
/**********************************字段解析--end**************************************/
$("body").on("click", "#cancle", function() {
parent.layer.close(index);
});
});
\ No newline at end of file
......@@ -23,7 +23,7 @@ layui.config({
form.render('select');
});
} else {
AjaxPostUtil.request({url: reportBasePath + "queryPropertyById", params: {id: id}, type: 'json', method: 'GET', callback:function(data) {
AjaxPostUtil.request({url: sysMainMation.reportBasePath + "queryPropertyById", params: {id: id}, type: 'json', method: 'GET', callback:function(data) {
$("#name").val(data.bean.name);
$("#code").val(data.bean.attrCode);
skyeyeClassEnumUtil.showEnumDataListByClassName("whetherEnum", 'radio', 'optional', data.bean.optional, form);
......@@ -101,7 +101,7 @@ layui.config({
propertyValueList: JSON.stringify(tableData),
id: isNull(id) ? '' : id
};
AjaxPostUtil.request({url: reportBasePath + "writeProperty", params: params, type: 'json', method: "POST", callback: function(json) {
AjaxPostUtil.request({url: sysMainMation.reportBasePath + "writeProperty", params: params, type: 'json', method: "POST", callback: function(json) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
......
......@@ -20,7 +20,7 @@
<tr trcusid="{{trId}}">
<td><input type="checkbox" rowId="{{id}}" lay-filter="checkboxProperty" name="tableCheckRow"/></td>
<td><input type="text" class="layui-input" id="{{key}}" win-verify="required" /></td>
<td><input type="text" class="layui-input" id="{{title}}" /></td>
<td><input type="text" class="layui-input" id="{{name}}" /></td>
<td><input type="text" class="layui-input" id="{{remark}}" /></td>
</tr>
</script>
\ No newline at end of file
......@@ -82,7 +82,7 @@
<tr trcusid="{{trId}}">
<td><input type="checkbox" rowId="{{id}}" lay-filter="checkboxProperty" name="tableCheckRow"/></td>
<td><input type="text" class="layui-input" id="{{key}}" win-verify="required" /></td>
<td><input type="text" class="layui-input" id="{{title}}" /></td>
<td><input type="text" class="layui-input" id="{{name}}" /></td>
<td><input type="text" class="layui-input" id="{{remark}}" /></td>
</tr>
</script>
\ No newline at end of file
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">SQL数据库<i class="red">*</i></label>
<div class="layui-input-block">
<select id="sqlDataBase" name="sqlDataBase" lay-search win-verify="required"></select>
<select id="dataBaseId" name="dataBaseId" lay-search win-verify="required"></select>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
......@@ -30,7 +30,7 @@
<tr trcusid="{{trId}}">
<td><input type="checkbox" rowId="{{id}}" lay-filter="checkboxProperty" name="tableCheckRow"/></td>
<td><input type="text" class="layui-input" id="{{key}}" win-verify="required" /></td>
<td><input type="text" class="layui-input" id="{{title}}" /></td>
<td><input type="text" class="layui-input" id="{{name}}" /></td>
<td><input type="text" class="layui-input" id="{{dataType}}" /></td>
<td><input type="text" class="layui-input" id="{{dataLength}}" /></td>
<td><input type="text" class="layui-input" id="{{dataPrecision}}" /></td>
......
......@@ -21,7 +21,7 @@
<tr trcusid="{{trId}}">
<td><input type="checkbox" rowId="{{id}}" lay-filter="checkboxProperty" name="tableCheckRow"/></td>
<td><input type="text" class="layui-input" id="{{key}}" win-verify="required" /></td>
<td><input type="text" class="layui-input" id="{{title}}" /></td>
<td><input type="text" class="layui-input" id="{{name}}" /></td>
<td><input type="text" class="layui-input" id="{{remark}}" /></td>
</tr>
</script>
\ No newline at end of file
......@@ -7,30 +7,9 @@
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
</head>
<body>
<div class="txtcenter" style="margin:0 auto;padding-top:10px;">
<form class="layui-form layui-form-pane" action="" autocomplete="off">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">名称</label>
<div class="layui-input-inline">
<input type="text" id="name" name="name" placeholder="请输入名称" class="layui-input" />
</div>
<label class="layui-form-label">类型</label>
<div class="layui-input-inline">
<select id="dataFromType" name="dataFromType" lay-search></select>
</div>
<button type="reset" class="layui-btn layui-btn-primary list-form-search"><language showName="com.skyeye.reset"></language></button>
<button class="layui-btn list-form-search" lay-submit lay-filter="formSearch"><language showName="com.skyeye.search2"></language></button>
</div>
</div>
</form>
</div>
<div class="winui-toolbar">
<div class="winui-tool">
<button id="reloadTable" class="winui-toolbtn">
<i class="fa fa-refresh" aria-hidden="true"></i>
<language showName="com.skyeye.refreshDataBtn"></language>
</button>
<button id="reloadTable" class="winui-toolbtn search-table-btn-right"><i class="fa fa-refresh" aria-hidden="true"></i><language showName="com.skyeye.refreshDataBtn"></language></button>
</div>
</div>
<div style="margin:auto 10px;">
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="../../assets/lib/layui/css/layui.css" rel="stylesheet" />
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
<link href="../../assets/lib/layui/css/codemirror.css" rel="stylesheet" />
</head>
<body>
<div style="margin:0 auto;padding:20px;">
<form class="layui-form" action="" id="showForm" autocomplete="off">
</form>
</div>
<script type="text/x-handlebars-template" id="showBaseTemplate">
{{#bean}}
<div class="layui-form-item layui-col-xs12">
<span class="hr-title">基础信息</span><hr>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">名称<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="name" name="name" win-verify="required" placeholder="请输入名称" class="layui-input" maxlength="50" value="{{name}}"/>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">数据来源</label>
<div class="layui-input-block ver-center">
{{typeName}}
</div>
</div>
<div id="dataBox">
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">字段解析<i class="red">*</i></label>
<div class="layui-input-block">
<div class="winui-toolbar">
<div class="winui-tool" style="text-align: left;">
<button id="fieldResolution" class="winui-toolbtn" type="button"><i class="fa fa-plus" aria-hidden="true"></i>自动解析</button>
<button id="addAnalysisRow" class="winui-toolbtn" type="button"><i class="fa fa-plus" aria-hidden="true"></i>新增行</button>
<button id="deleteAnalysisRow" class="winui-toolbtn" type="button"><i class="fa fa-trash-o" aria-hidden="true"></i>删除行</button>
</div>
</div>
<table class="layui-table">
<thead id="analysisHeader">
</thead>
<tbody id="analysisTable" class="insurance-table">
</tbody>
</table>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">备注</label>
<div class="layui-input-block">
<textarea id="remark" name="remark" placeholder="请输入备注" maxlength="200" class="layui-textarea" style="height: 100px;">{{remark}}</textarea>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<div class="layui-input-block">
<button class="winui-btn" id="cancle"><language showName="com.skyeye.cancel"></language></button>
<button class="winui-btn" lay-submit lay-filter="formEditBean"><language showName="com.skyeye.save"></language></button>
</div>
</div>
{{/bean}}
</script>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/reportDataFrom/'}).use('reportDataFromEdit');
</script>
</body>
</html>
\ No newline at end of file
......@@ -7,40 +7,17 @@
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
</head>
<body>
<div class="txtcenter" style="margin:0 auto;padding-top:10px;">
<form class="layui-form layui-form-pane" action="" autocomplete="off">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">名称</label>
<div class="layui-input-inline">
<input type="text" id="name" name="name" placeholder="请输入名称" class="layui-input" />
</div>
<label class="layui-form-label">类型</label>
<div class="layui-input-inline">
<select id="dataFromType" name="dataFromType" lay-search></select>
</div>
<button type="reset" class="layui-btn layui-btn-primary list-form-search"><language showName="com.skyeye.reset"></language></button>
<button class="layui-btn list-form-search" lay-submit lay-filter="formSearch"><language showName="com.skyeye.search2"></language></button>
</div>
</div>
</form>
</div>
<div class="winui-toolbar">
<div class="winui-tool">
<button id="reloadTable" class="winui-toolbtn">
<i class="fa fa-refresh" aria-hidden="true"></i>
<language showName="com.skyeye.refreshDataBtn"></language>
</button>
<button id="addBean" class="winui-toolbtn" auth="1622876929121">
<i class="fa fa-plus" aria-hidden="true"></i>
<language showName="com.skyeye.addBtn"></language>
</button>
<button id="reloadTable" class="winui-toolbtn search-table-btn-right"><i class="fa fa-refresh" aria-hidden="true"></i><language showName="com.skyeye.refreshDataBtn"></language></button>
<button id="addBean" class="winui-toolbtn search-table-btn-right" auth="1622876929121"><i class="fa fa-plus" aria-hidden="true"></i>新增</button>
</div>
</div>
<div style="margin:auto 10px;">
<table id="messageTable" lay-filter="messageTable"></table>
<script type="text/html" id="tableBar">
{{# if(auth('1622876949321')){ }}
{{# if(auth('1622876929121')){ }}
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit"><language showName="com.skyeye.editBtn"></language></a>
{{# } }}
{{# if(auth('1622876937858')){ }}
......
......@@ -56,7 +56,7 @@
<div class="layui-form-item layui-col-xs12">
<div class="layui-input-block">
<button class="winui-btn" id="cancle"><language showName="com.skyeye.cancel"></language></button>
<button class="winui-btn" lay-submit lay-filter="formAddBean"><language showName="com.skyeye.save"></language></button>
<button class="winui-btn" lay-submit lay-filter="formWriteBean"><language showName="com.skyeye.save"></language></button>
</div>
</div>
</form>
......@@ -65,7 +65,7 @@
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/reportDataFrom/'}).use('reportDataFromAdd');
layui.config({base: '../../js/reportDataFrom/'}).use('reportDataFromWrite');
</script>
</body>
</html>
\ No newline at end of file
......@@ -150,5 +150,8 @@
"autoApiAuthEnum": {"name": "接口", "className": "skyeye-auto#com.skyeye.api.classenum.AutoApiAuthEnum", "pageUrl": ""},
"autoVariableAuthEnum": {"name": "变量", "className": "skyeye-auto#com.skyeye.variable.classenum.AutoVariableAuthEnum", "pageUrl": ""},
"autoVersionAuthEnum": {"name": "版本", "className": "skyeye-auto#com.skyeye.version.classenum.AutoVersionAuthEnum", "pageUrl": ""},
"autoVersionState": {"name": "自动化-版本状态", "className": "skyeye-auto#com.skyeye.version.classenum.AutoVersionState"}
"autoVersionState": {"name": "自动化-版本状态", "className": "skyeye-auto#com.skyeye.version.classenum.AutoVersionState"},
"reportDataFromType": {"name": "报表-数据来源类型", "className": "skyeye-report#com.skyeye.datafrom.classenum.ReportDataFromType"}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册