|
@ -7,10 +7,12 @@
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
/* *************************** 模块初始化 ***************************** */
|
|
|
var editorParam = {
|
|
|
var editorFlow = {
|
|
|
//form
|
|
|
actionUrl:"${contextRoot}/flow/addFlow",
|
|
|
|
|
|
index:1,
|
|
|
$mun:0,//保存节点数量
|
|
|
flowClassData:[],//节点数据
|
|
|
init: function () {
|
|
|
this.bindEvents();
|
|
|
this.initForm();
|
|
@ -21,8 +23,6 @@
|
|
|
var modelString = "${model.id}";
|
|
|
if(modelString!=undefined && modelString!=null && modelString.length>0)
|
|
|
{
|
|
|
var type = "${flowClass.type}";
|
|
|
liger.get("type").selectValue(type);
|
|
|
var valid = "${model.valid}";
|
|
|
liger.get("valid").selectValue(valid);
|
|
|
data={
|
|
@ -32,10 +32,9 @@
|
|
|
path: "${model.path}",
|
|
|
chart:"${model.chart}",
|
|
|
valid:"${model.valid}",
|
|
|
type: type,
|
|
|
classPath: "${flowClass.classPath}",
|
|
|
packageName: "${flowClass.packageName}",
|
|
|
className: "${flowClass.className}",
|
|
|
flowClassList: '${flowClass}',
|
|
|
flowClassArray:'${model.flowClassArray}',
|
|
|
createDate:'${model.createDate}'
|
|
|
};
|
|
|
|
|
|
me.actionUrl = "${contextRoot}/flow/updateFlow";
|
|
@ -51,19 +50,56 @@
|
|
|
},
|
|
|
|
|
|
});
|
|
|
me.resolveFlow();
|
|
|
},
|
|
|
bindFlowClass:function(index){
|
|
|
var me = this;
|
|
|
|
|
|
$("#type"+index).ligerComboBox({data : [{"value":"route","code":"route"},{"value":"processor","code":"processor"}],
|
|
|
cancelable:false,
|
|
|
onSuccess:function(data){
|
|
|
}});
|
|
|
|
|
|
var type = $("#type"+index).val();
|
|
|
if(!type || type==''){
|
|
|
type = "route";
|
|
|
}
|
|
|
|
|
|
liger.get("type"+index).selectValue(type);
|
|
|
me.flowClassData[me.$mun]= {
|
|
|
"packageName": $("#packageName"+index).val(),
|
|
|
"className": $("#className"+index).val(),
|
|
|
"classPath": $("#classPath"+index).val(),
|
|
|
"flowId": $("#flowId").val(),//流程id
|
|
|
"type":$("#type"+index).val(),
|
|
|
"id":$("#classId"+index).val(),
|
|
|
"isUpdate":$("#isUpdate"+index).val()
|
|
|
}
|
|
|
me.$mun+=1;
|
|
|
},
|
|
|
bindEvents: function () {
|
|
|
var me = this;
|
|
|
|
|
|
$(".m-form-bottom").on("click","#btnSave",function () {
|
|
|
if(!$("#div_info_form").ligerAutoForm("validate")){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
var index =newMaxFormIndex();
|
|
|
for (var i = index; i > 0; i--) {
|
|
|
me.bindFlowClass(i);
|
|
|
}
|
|
|
|
|
|
|
|
|
var data = $("#div_info_form").ligerAutoForm("getData");
|
|
|
delete data.file;
|
|
|
data.flowClassArray=me.flowClassData;
|
|
|
var dataStr = JSON.stringify(data);
|
|
|
$.ajax({ //ajax处理
|
|
|
type: "POST",
|
|
|
url : me.actionUrl,
|
|
|
dataType : "json",
|
|
|
data:data,
|
|
|
data:{"flowClass":dataStr},
|
|
|
cache:false,
|
|
|
success :function(data){
|
|
|
if(data.successFlg) {
|
|
@ -92,23 +128,55 @@
|
|
|
onSuccess:function(data){
|
|
|
}});
|
|
|
|
|
|
$("#form1").on("click",".btnGrayUp",function(){
|
|
|
var inputVal=$(this).closest("div").find("input[type=text]");
|
|
|
var obj=$(this).closest("div").find("input[type=file]")
|
|
|
obj.change(function(){
|
|
|
inputVal.val(obj.val());
|
|
|
})
|
|
|
obj.click();
|
|
|
});
|
|
|
$("#form2").on("click",".btnGrayUp",function(){
|
|
|
var inputVal=$(this).closest("div").find("input[type=text]");
|
|
|
var obj=$(this).closest("div").find("input[type=file]")
|
|
|
obj.change(function(){
|
|
|
inputVal.val(obj.val());
|
|
|
})
|
|
|
obj.click();
|
|
|
/* =====================添加新节点========================= */
|
|
|
$(".m-form-group").on("click","#btnAddClass",function () {
|
|
|
var index =newMaxFormIndex();
|
|
|
if( index>1){
|
|
|
index++
|
|
|
}
|
|
|
var html = '<div class="flows" dataIndex="'+index+'" id="paramGroup'+index+'">';
|
|
|
|
|
|
html += '<div class="m-form-group" dataIndex="'+index+'" ><label>类别 : </label><div class="m-form-control ">' +
|
|
|
'<div class="l-text"><input type="text" id="type'+index+'" class="l-text-field required" name="type"></div>'+
|
|
|
'</div></div>';
|
|
|
|
|
|
html += '<div class="m-form-group" style="border:1px solid #e1e1e1"><label>包名'+index+' : </label><div class="m-form-control" controlType="textbox" id="packName'+index+'_div" style="margin-left:0px;">' +
|
|
|
'<input type="text" id="packageName'+index+'" class="l-textbox"/></div></div>';
|
|
|
|
|
|
html += '<div class="m-form-group" dataIndex="'+index+'" id="paramGroup'+index+'"><label>类名'+index+' :</label>'+
|
|
|
'<div class="m-form-control" controlType="textbox" id="className'+index+'_div" style="margin-left:0px;"> ' +
|
|
|
'<input type="text" id="className'+index+'" class="l-textbox"/></div></div>';
|
|
|
|
|
|
|
|
|
html += ' <div class="m-form-group"><label>源代码'+index+' : </label><div class="m-form-control">' +
|
|
|
'<form id="form'+index+'" action="${contextRoot}/flow/upload" method="post" enctype="multipart/form-data">';
|
|
|
html += ' <input name="isUpdate" type="text" id="isUpdate'+index+'" class="isUpdate" hidden="hidden"/>';
|
|
|
html += ' <input type="text" id="classPath'+index+'" name="classPath" class="l-textbox btnGrayUp" style="width: 144px;" placeholder="点击选择源代码文件" readonly="readonly" data-id="">'+
|
|
|
' <div style="float: right;">'+
|
|
|
' <div class="l-button l-button-no btnGrayDo'+index+'" data-id="'+index+'">'+
|
|
|
' <span style="background-color: rgb(240, 240, 240);">导入</span> </div>'+
|
|
|
'<label class="say'+index+'" style="display: inline-block;width: 70px;"></label>'+
|
|
|
'</div><input type="file" name="file" style="display: none" id="file'+index+'" /></form>'+
|
|
|
'</div></div>';
|
|
|
html += '<div class="m-form-group"><div class="m-form-control"><a class="m-btn-cancle" href="javascrip:void()" style="display:block;" onclick="$(\'#paramGroup'+index+'\').remove()"></a></div></div>';
|
|
|
|
|
|
$("#classDiv").append(html);
|
|
|
$("#type"+index).ligerComboBox({data : [{"value":"route","code":"route"},{"value":"processor","code":"processor"}],
|
|
|
cancelable:false,
|
|
|
onSuccess:function(data){
|
|
|
}});
|
|
|
|
|
|
var type = $("#type"+index).val();
|
|
|
if(!type || type==''){
|
|
|
type = "route";
|
|
|
}
|
|
|
|
|
|
liger.get("type"+index).selectValue(type);
|
|
|
bindForm(index);
|
|
|
bindUpload(index);
|
|
|
});
|
|
|
$("#form3").on("click",".btnGrayUp",function(){
|
|
|
|
|
|
$("#formIcon").on("click",".btnIconGrayUp",function(){
|
|
|
var inputVal=$(this).closest("div").find("input[type=text]");
|
|
|
var obj=$(this).closest("div").find("input[type=file]")
|
|
|
obj.change(function(){
|
|
@ -117,13 +185,12 @@
|
|
|
obj.click();
|
|
|
});
|
|
|
|
|
|
$(".btnGrayDo").bind("click",function(){
|
|
|
var id = $(this).attr("data-id");
|
|
|
var formId = '#form'+id;
|
|
|
$(".formIcon").bind("click",function(){
|
|
|
var formId = '#formIcon';
|
|
|
var formObj=$(formId);//要提交的表单
|
|
|
var Obj=$(".btnGrayDo");
|
|
|
var upObj=formObj.closest("input").find(".btnGrayUp");//浏览的按钮
|
|
|
var formsay=formObj.find(".say"+id);//提示文字
|
|
|
var Obj=$(".formIcon");
|
|
|
var upObj=formObj.closest("input").find(".btnIconGrayUp");//浏览的按钮
|
|
|
var formsay=formObj.find(".sayformIcon");//提示文字
|
|
|
if(formObj.closest("div").find("input[type=text]").val().length!=0){//判断是否选择了文件
|
|
|
formsay.attr("class","say true").html("上传中");
|
|
|
formObj.ajaxForm({
|
|
@ -132,8 +199,8 @@
|
|
|
if(data.successFlg){
|
|
|
formsay.attr("class","say true").html("上传成功");
|
|
|
formObj.find("input[type=text]").attr("data-id",data.message)//设置已上传的文件的ID
|
|
|
formObj.find(".btnDel").css("display","inline-block")
|
|
|
formObj.closest("div").find("span").html("重新导入<i></i>");
|
|
|
|
|
|
}else{
|
|
|
$.ligerDialog.error("上传格式有问题");
|
|
|
Obj.css("background","#ebebeb").html("导入");
|
|
@ -152,9 +219,160 @@
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/* ===================== 文件预览 动态绑定事件========================== */
|
|
|
|
|
|
/* =====================上传文件 原数据绑定=========================== */
|
|
|
var index =newMaxFormIndex();
|
|
|
for (var i = index; i > 0; i--) {
|
|
|
bindForm(i);
|
|
|
// bindUpload(i);
|
|
|
}
|
|
|
|
|
|
|
|
|
// $("#form"+index).on("click",".btnGrayDo",function(){
|
|
|
// $(".btnGrayDo").bind("click",function(){
|
|
|
// var id = $(this).attr("data-id");
|
|
|
// alert(id);
|
|
|
// var formId = '#form'+id;
|
|
|
// var formObj=$(formId);//要提交的表单
|
|
|
// var Obj=$(".btnGrayDo");
|
|
|
// var upObj=formObj.closest("input").find(".btnGrayUp");//浏览的按钮
|
|
|
// var formsay=formObj.find(".say"+id);//提示文字
|
|
|
// if(formObj.closest("div").find("input[type=text]").val().length!=0){//判断是否选择了文件
|
|
|
// formsay.attr("class","say true").html("上传中");
|
|
|
// formObj.ajaxForm({
|
|
|
// dataType: 'json',
|
|
|
// success: function processJson(data){
|
|
|
// if(data.successFlg){
|
|
|
// formsay.attr("class","say true").html("上传成功");
|
|
|
// formObj.find("input[type=text]").attr("data-id",data.message)//设置已上传的文件的ID
|
|
|
// formObj.find(".btnDel").css("display","inline-block")
|
|
|
// formObj.closest("div").find("span").html("重新导入<i></i>");
|
|
|
// }else{
|
|
|
// $.ligerDialog.error("上传格式有问题");
|
|
|
// Obj.css("background","#ebebeb").html("导入");
|
|
|
//
|
|
|
// }
|
|
|
// //console.log(eval('('+data.data+')'));
|
|
|
// },
|
|
|
// error: function processJson(data){
|
|
|
// formsay.attr("class","say false").html("上传失败");
|
|
|
// }
|
|
|
// });
|
|
|
// formObj.submit();
|
|
|
// }else{
|
|
|
// $.ligerDialog.error("请选择要上传的文件");
|
|
|
// }
|
|
|
// });
|
|
|
|
|
|
|
|
|
},
|
|
|
resolveFlow:function(){
|
|
|
var index = 1;
|
|
|
var flowStr = '${flowClass}';
|
|
|
if (flowStr != "") {
|
|
|
var flowJson = $.parseJSON(flowStr);
|
|
|
$.each(flowJson, function(i, data){
|
|
|
var html = '<div class="flows" dataIndex="'+index+'" id="paramGroup'+index+'">';
|
|
|
|
|
|
html += '<div class="m-form-group" dataIndex="'+index+'" ><label>类别 :</label><div class="m-form-control "> ' +
|
|
|
'<div class="l-text"><input type="text" id="type'+index+'" value="'+data.type+'" class="l-text-field required" name="type"></div>'+
|
|
|
'</div></div>';
|
|
|
|
|
|
html += '<div class="m-form-group" style="border:1px solid #e1e1e1"><label>包名'+index+' : </label><div class="m-form-control" controlType="textbox" id="packName'+index+'_div" style="margin-left:0px;">' +
|
|
|
'<input type="text" id="packageName'+index+'" value="'+data.packageName+'" class="l-textbox"/></div></div>';
|
|
|
|
|
|
html += '<div class="m-form-group" dataIndex="'+index+'" id="paramGroup'+index+'"><label>'+
|
|
|
'类名'+index+' : </label><div class="m-form-control" controlType="textbox" id="className'+index+'_div" style="margin-left:0px;">' +
|
|
|
'<input type="text" id="className'+index+'" value="'+data.className+'" class="l-textbox"/></div></div>';
|
|
|
|
|
|
|
|
|
html += ' <div class="m-form-group"><label>源代码'+index+' : </label><div class="m-form-control">' +
|
|
|
'<form id="form'+index+'" action="${contextRoot}/flow/upload" method="post" enctype="multipart/form-data">';
|
|
|
html += ' <input type="text" name="isUpdate" id="isUpdate'+index+'" class="isUpdate" hidden="hidden"/>';
|
|
|
|
|
|
html += ' <input type="text" id="classPath'+index+'" value="'+data.classPath+'" name="classPath" class="l-textbox btnGrayUp" style="width: 144px;" placeholder="点击选择源代码文件" readonly="readonly" data-id="">'+
|
|
|
' <div style="float: right;">'+
|
|
|
' <div class="l-button l-button-no btnGrayDo'+index+'" data-id="'+index+'">'+
|
|
|
' <span style="background-color: rgb(240, 240, 240);">导入</span> </div>'+
|
|
|
'<label class="say'+index+'" style="display: inline-block;width: 70px;"></label>'+
|
|
|
'</div><input type="file" name="file" style="display: none" id="file'+index+'" /></form>'+
|
|
|
'</div></div>';
|
|
|
html += ' <input name="id" value="'+data.id+'" id="classId'+index+'" hidden="hidden"/>';
|
|
|
html += '<div class="m-form-group"><div class="m-form-control"><a class="m-btn-cancle" href="javascrip:void()" style="display:block;" onclick="$(\'#paramGroup'+index+'\').remove()"></a></div></div>';
|
|
|
|
|
|
$("#classDiv").append(html);
|
|
|
$("#type"+index).ligerComboBox({data : [{"value":"route","code":"route"},{"value":"processor","code":"processor"}],
|
|
|
cancelable:false,
|
|
|
onSuccess:function(data){
|
|
|
}});
|
|
|
|
|
|
var type = data.type;
|
|
|
if(!type || type==''){
|
|
|
type = "route";
|
|
|
}
|
|
|
|
|
|
liger.get("type"+index).selectValue(type);
|
|
|
bindForm(index);
|
|
|
bindUpload(index);
|
|
|
index++;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
};
|
|
|
|
|
|
function bindForm(index){
|
|
|
$("#form"+index).on("click",".btnGrayUp",function(){
|
|
|
var inputVal=$(this).closest("div").find("input[type=text]");
|
|
|
var obj=$(this).closest("div").find("input[type=file]");
|
|
|
obj.change(function(){
|
|
|
inputVal.val(obj.val());
|
|
|
})
|
|
|
obj.click();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function bindUpload(index){
|
|
|
$(".btnGrayDo"+index).bind("click",function(){
|
|
|
var formId = '#form'+index;
|
|
|
var formObj=$(formId);//要提交的表单
|
|
|
var Obj=$(".btnGrayDo"+index);
|
|
|
var upObj=formObj.closest("input").find(".btnGrayUp");//浏览的按钮
|
|
|
var formsay=formObj.find(".say"+index);//提示文字
|
|
|
if(formObj.closest("div").find("input[type=text]").val().length!=0){//判断是否选择了文件
|
|
|
formsay.attr("class","say true").html("上传中");
|
|
|
formObj.ajaxForm({
|
|
|
dataType: 'json',
|
|
|
success: function processJson(data){
|
|
|
if(data.successFlg){
|
|
|
formsay.attr("class","say true").html("上传成功");
|
|
|
formObj.find("input[type=text]").attr("data-id",data.message)//设置已上传的文件的ID
|
|
|
var inputVal=formObj.closest("div").find("input[type=text]");
|
|
|
inputVal.val(data.message);
|
|
|
formObj.closest("div").find("span").html("重新导入<i></i>");
|
|
|
var isUpdate=formObj.find(".isUpdate");//是否有上传过
|
|
|
isUpdate.val("1");//上传过
|
|
|
|
|
|
}else{
|
|
|
$.ligerDialog.error("上传格式有问题");
|
|
|
Obj.css("background","#ebebeb").html("导入");
|
|
|
|
|
|
}
|
|
|
//console.log(eval('('+data.data+')'));
|
|
|
},
|
|
|
error: function processJson(data){
|
|
|
formsay.attr("class","say false").html("上传失败");
|
|
|
}
|
|
|
});
|
|
|
formObj.submit();
|
|
|
}else{
|
|
|
$.ligerDialog.error("请选择要上传的文件");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function getFilePath(input){
|
|
|
if(input){//input是<input type="file">Dom对象
|
|
|
if(window.navigator.userAgent.indexOf("MSIE")>=1){ //如果是IE
|
|
@ -171,11 +389,20 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//获取动态添加的form的最大值。
|
|
|
function newMaxFormIndex(){
|
|
|
var index;
|
|
|
var size = $(".flows").length;
|
|
|
if(size!="" && size>0){
|
|
|
index=$("#"+$(".flows")[size-1].id).attr("dataIndex");//获取参数的个数
|
|
|
}else{
|
|
|
index=1;
|
|
|
}
|
|
|
return index;
|
|
|
}
|
|
|
|
|
|
|
|
|
$(function () {
|
|
|
editorParam.init();
|
|
|
getFilePath($("#file1"));
|
|
|
getFilePath($("#file2"));
|
|
|
getFilePath($("#file3"));
|
|
|
editorFlow.init();
|
|
|
});
|
|
|
</script>
|