layoutStrings = {
|
en: {
|
},
|
zh: {
|
title: "自定义表单设计引擎",
|
saveButton: "保存",
|
shareButton: "预览",
|
}
|
|
}
|
var customBase = customBase || {};
|
customBase.uploaderTemp = 0;
|
toastr.options = {
|
closeButton: false,
|
debug: false,
|
progressBar: false,
|
positionClass: "toast-top-center",
|
onclick: null,
|
showDuration: "300",
|
hideDuration: "1000",
|
timeOut: "2000",
|
extendedTimeOut: "1000",
|
showEasing: "swing",
|
hideEasing: "linear",
|
showMethod: "fadeIn",
|
hideMethod: "fadeOut",
|
}
|
|
//customBase.query_set_value = function(itemId,type,value,num){
|
//
|
// var itemvalue;
|
// if(num != undefined){
|
// itemvalue = customBase.getItemValue(itemId,type)[num];
|
// }else{
|
// itemvalue = customBase.getItemValue(itemId,type);
|
// }
|
// if(value == 8888){
|
// ////console.log(itemvalue)
|
// }
|
// if(itemvalue == undefined || itemvalue == '' || itemvalue == 0){
|
// customBase.setItemValue(itemId,type,value,"","",num);
|
// }
|
//}
|
|
//customBase.submitForm = function(){
|
// ////console.log(window.customBase);
|
// ////console.log(window.customShow);
|
// var submit_data = {
|
// "formId":customShow.options.formid,
|
// "dataRowNUm":customShow.options.dataRowNum
|
// };
|
//
|
// var submit_request = window.commonAjax("/datamanagement/getBudget",submit_data,"POST",true);
|
// submit_request.done(function(res){
|
//
|
// })
|
//}
|
// 2017/10/17 李元杰 点击计算费用后 msgInfo渲染
|
|
customBase.groupInfo = function (_data) {
|
var groupTitle,
|
groupData
|
var container = $('#itemId_12subform').append('<div class="container"></div>')
|
var subform = $('#itemId_12subform .container');
|
// 点击后先清空在渲染页面数据
|
subform.empty();
|
for (var i = 0; i < _data.msgInfo.length; i++) {
|
subform.append(`<li style="position: relative;float:left;"></li>`);
|
groupTitle = `<span style="color:${_data.msgInfo[i].groupColor}">${_data.msgInfo[i].groupName}</span>`
|
subform.find("li").eq(i).append(groupTitle);
|
subform.find("li").eq(i).append("<div class='ulContent'></div>");
|
for (var j = 0; j < _data.msgInfo[i].groupData.length; j++) {
|
subform.find("li").eq(i).find('.ulContent').append(`<div style="color:${_data.msgInfo[i].groupColor}" >${_data.msgInfo[i].groupData[j].data}</div>`)
|
}
|
}
|
}
|
//customBase.listen_check = function(res_data,classname){// 实时验证
|
// var customBase = window.customBase;
|
// var customShow = window.customShow;
|
// // 2017/10/17 李元杰 msgInfo渲染
|
// customBase.groupInfo(res_data)
|
//// ////console.log(window.customBase);
|
// _.each(res_data.data,function(redata){
|
// var cu_item = customBase.options.customItems[redata.fieldKey];
|
// ////console.log(cu_item)
|
// if(cu_item != undefined && cu_item.type != "dropdownlist" && cu_item.type != "subform"){
|
// customBase.query_set_value(cu_item.id,cu_item.type,redata.value);
|
// }
|
//
|
// var base_item = $("[fieldKey='" + redata.fieldKey + "']");
|
// if(base_item.length > 0){
|
// var base_item_id = base_item.attr('id');
|
// var base_item_type = base_item.attr('type');
|
// if(redata.type != "subform"){
|
// $("#"+base_item_id+"ActiveId").find("." + classname).remove();
|
// if(redata.msgInfo){
|
// var check_minfo = undefined;
|
// _.each(redata.msgInfo.header,function(minfo){
|
// if(minfo.validate){
|
// //console.log(minfo)
|
// $("#"+base_item_id+"ActiveId").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo.name + ":" + minfo.value + "</span>");
|
// check_minfo = minfo;
|
// }else{
|
// $("#"+base_item_id+"ActiveId").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo.name + ":" + minfo.value + "</span>");
|
// }
|
// });
|
// if(check_minfo != undefined){
|
// customBase.bind_check(base_item_id,base_item_type,check_minfo,classname);
|
// $("#"+base_item_id).on('change', function(){
|
// customBase.bind_check(base_item_id,base_item_type,check_minfo,classname);
|
// });
|
// }
|
// }
|
// }else{
|
// $("#"+base_item_id+"ActiveId").find("." + classname).remove();
|
// if(redata.msgInfo){
|
// _.each(redata.msgInfo.header,function(minfo){
|
// $("#"+base_item_id+"ActiveId").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo.name + ":" + minfo.value + "</span>");
|
// });
|
// }
|
// var sub_type = customShow.options.customItemShow.item[base_item_id].tag_Attribute.allcopy;
|
//// ////console.log(sub_type);
|
// _.each(redata.child,function(recd,i){
|
// _.each(recd.items,function(recd_item){
|
// ////console.log(recd_item);
|
// ////console.log(customShow.options.customItemShow);
|
// var cu_cd_item = customBase.options.customItems[recd_item.fieldKey];
|
// ////console.log(cu_cd_item);
|
// if(cu_cd_item != undefined && cu_cd_item.type != "dropdownlist"){
|
// customBase.query_set_value(cu_cd_item.id,cu_cd_item.type,recd_item.value,i);
|
// }
|
//
|
// var base_item_cd = $("[fieldKey='" + recd_item.fieldKey + "']:eq('" + i + "')");
|
// var base_item_id_cd = base_item_cd.attr('id');
|
// var base_item_type_cd = base_item_cd.attr('type');
|
//// ////console.log(base_item_cd);
|
//// ////console.log(base_item_id_cd);
|
//// ////console.log(base_item_type_cd);
|
//// ////console.log(recd_item);
|
// if(sub_type){
|
// $("[id='"+base_item_id_cd+"ActiveId']:eq('" + i + "')").find("." + classname).remove();
|
// }else{
|
// $("[id='"+base_item_id_cd+"']:eq('" + i + "')").closest("tr").find("p").remove();
|
// }
|
//
|
// if(recd_item.msgInfo){
|
// var check_minfo_cd = undefined;
|
// _.each(recd_item.msgInfo.header,function(minfo_cd){
|
//// ////console.log($("#"+base_item_id_cd+"ActiveId"));
|
//// ////console.log($("[id='"+base_item_id_cd+"ActiveId']:eq('" + i + "')"));
|
// if(minfo_cd.validate){
|
// check_minfo_cd = minfo_cd;
|
// if(sub_type){
|
// $("[id='"+base_item_id_cd+"ActiveId']:eq('" + i + "')").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo_cd.name + ":" + minfo_cd.value + "</span>");
|
// }else{
|
// customBase.set_p($("[id='"+base_item_id_cd+"']:eq('" + i + "')"));
|
// $("[id='"+base_item_id_cd+"']:eq('" + i + "')").prev("p").append("<span class='" + classname + "'>" + minfo_cd.name + ":" + minfo_cd.value + "</span>");
|
// }
|
// }else{
|
// if(sub_type){
|
// $("[id='"+base_item_id_cd+"ActiveId']:eq('" + i + "')").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo_cd.name + ":" + minfo_cd.value + "</span>");
|
// }else{
|
// customBase.set_p($("[id='"+base_item_id_cd+"']:eq('" + i + "')"));
|
// $("[id='"+base_item_id_cd+"']:eq('" + i + "')").prev("p").append("<span class='" + classname + "'>" + minfo_cd.name + ":" + minfo_cd.value + "</span>");
|
// }
|
// }
|
// });
|
// if(check_minfo_cd != undefined){
|
// customBase.bind_check(base_item_id_cd,base_item_type_cd,check_minfo_cd,classname,sub_type,i);
|
// $("[id='"+base_item_id_cd+"']:eq('" + i + "')").on('change', function(){
|
// customBase.bind_check(base_item_id_cd,base_item_type_cd,check_minfo_cd,classname,sub_type,i);
|
// });
|
// }
|
// }
|
// });
|
// });
|
// }
|
// }
|
//
|
// });
|
//
|
//
|
//
|
//
|
//// _.each(res_data,function(redata){
|
//// var base_item = $("[fieldKey='" + redata.fieldKey + "']");
|
//// if(base_item.length > 0){
|
//// var base_item_id = base_item.attr('id');
|
//// var base_item_type = base_item.attr('type');
|
//// ////console.log(base_item_id);
|
//// ////console.log($("#"+base_item_id+"ActiveId").find(".listen_check"));
|
//// if($("#"+base_item_id+"ActiveId").find(".listen_check").length == 0){
|
//// $("#"+base_item_id+"ActiveId").find("h8[name='el_title']").append("<span class='listen_check'>" + redata.amount + "</span>");
|
//// }else{
|
//// $("#"+base_item_id+"ActiveId").find(".listen_check").html(redata.amount);
|
//// }
|
//// var now_value_s = customBase.getItemValue(base_item_id,base_item_type);
|
//// $("#"+base_item_id+"ActiveId").find(".listen_check").css("color","#333");
|
//// if(now_value_s != redata.amount){
|
//// $("#"+base_item_id+"ActiveId").find(".listen_check").css("color","red");
|
//// }
|
//// $("#"+base_item_id).on('change', function(){
|
//// var now_value = customBase.getItemValue(base_item_id,base_item_type);
|
//// $("#"+base_item_id+"ActiveId").find(".listen_check").css("color","#333");
|
//// if(now_value != redata.amount){
|
//// $("#"+base_item_id+"ActiveId").find(".listen_check").css("color","red");
|
//// }
|
//// });
|
//// }
|
//// });
|
//}
|
|
//customBase.bind_check = function(base_item_id,base_item_type,minfo,classname,sub_type,i){//验证方法
|
// if( i != undefined){
|
// if(i == 0){
|
// var now_value = customBase.getItemValue(base_item_id, base_item_type);
|
// }else{
|
// var now_value = customBase.getItemValue(base_item_id, base_item_type)[i];
|
// }
|
// ////console.log(base_item_id);
|
// ////console.log($("#" + base_item_id + "ActiveId"));
|
// ////console.log($("[id='"+base_item_id+"ActiveId']:eq('" + i + "')"));
|
// if(sub_type){
|
// $("[id='"+base_item_id+"ActiveId']:eq('" + i + "')").find("." + classname).css("color", "#333");
|
// if(now_value != minfo.value) {
|
// $("[id='"+base_item_id+"ActiveId']:eq('" + i + "')").find("." + classname).css("color", "red");
|
// }
|
// }else{
|
// $("[id='"+base_item_id+"']:eq('" + i + "')").prev("p").find("." + classname).css("color", "#333");
|
// if(now_value != minfo.value) {
|
// $("[id='"+base_item_id+"']:eq('" + i + "')").prev("p").find("." + classname).css("color", "red");
|
// }
|
// }
|
//
|
// }else{
|
// var now_value = customBase.getItemValue(base_item_id, base_item_type);
|
// $("#" + base_item_id + "ActiveId").find("." + classname).css("color", "#333");
|
// if(now_value != minfo.value) {
|
// $("#" + base_item_id + "ActiveId").find("." + classname).css("color", "red");
|
// }
|
// }
|
//}
|
|
//customBase.set_p = function(item){
|
// var p_height = "19.2px";
|
// if(item.closest("tr").find("p").length == 0){
|
// var item_td = item.closest("tr").find("td");
|
// item_td.each(function(){
|
// $(this).prepend("<p style='height:" + p_height + "'></p>")
|
// });
|
// }
|
//}
|
customBase.options = {
|
customItems: {},
|
uploaderItem: {},
|
uploaderItemReady: {},
|
uploaderFile: {},
|
fileuuid: "",
|
dropdownlistText: {},
|
uploaderFileName: {},
|
formbaseInfo: "",
|
zTreeOnClickItems: {}
|
}
|
//项目编辑(设定及取得值)
|
customBase.itemEdit = {
|
//单行文本
|
text: {
|
getItem: function (itemId) {
|
itemReturn = [];
|
var items = $(itemId);
|
for (var i = 0; i < items.length; i++) {
|
itemReturn[i] = items[i].value;
|
};
|
if (itemReturn.length == 1) {
|
return itemReturn[0];
|
} else {
|
return itemReturn;
|
}
|
|
},
|
setItem: function (itemId, value, showClass) {
|
if (showClass == undefined) {
|
showClass = 'customViewUEditorCss';
|
}
|
if (value == null) {
|
value = "";
|
}
|
var itemL = $("." + showClass + " " + itemId).length;
|
if (itemL > value.length) {
|
itemL = value.length;
|
}
|
if (itemL == 1) {
|
if ('customShow' == showClass) {
|
$("." + showClass).find(itemId)[0].setAttribute("readonly", "readonly");
|
}
|
$("." + showClass).find(itemId)[0].value = value;
|
} else if (itemL == 0) {
|
for (var i = 0; i < $("." + showClass + " " + itemId).length; i++) {
|
if ('customShow' == showClass) {
|
$("." + showClass + " " + itemId)[i].setAttribute("readonly", "readonly");
|
}
|
$("." + showClass + " " + itemId)[i].value = value;
|
};
|
} else {
|
for (var i = 0; i < itemL; i++) {
|
if ('customShow' == showClass) {
|
$("." + showClass + " " + itemId)[i].setAttribute("readonly", "readonly");
|
}
|
$("." + showClass + " " + itemId)[i].value = value[i]
|
};
|
}
|
|
},
|
},
|
//单选按钮组
|
checkboxRadio: {
|
getItem: function (itemId, type) {
|
var itemList = $("." + itemId + "value");
|
var itemListReturn = [];
|
// 数组循环取得
|
for (var j = 0; j < itemList.length; j++) {
|
|
if (type == "radio") {
|
var items = $(itemList[j]).find(".custom-radio");
|
} else {
|
var items = $(itemList[j]).find(".custom-check");
|
}
|
var checkItem = [];
|
var z = 0;
|
for (var i = 0; i < items.length; i++) {
|
if (items[i].className.indexOf("cur") > 0) {
|
checkItem[z] = items[i].getAttribute("value");
|
z++;
|
} else {
|
}
|
};
|
itemListReturn[j] = checkItem;
|
z++;
|
};
|
return itemListReturn;
|
},
|
setItem: function (itemId, type, value, showClass) {
|
//被选择项目设定
|
checkboxRadioItem = function (itemList, value) {
|
console.log(itemList)
|
if (typeof value == "string") {
|
value = [value];
|
}
|
for (var i = 0; i < itemList.length; i++) {
|
for (var j = 0; j < value.length; j++) {
|
if (value[j] == itemList[i].getAttribute("value")) {
|
|
$(itemList[i]).addClass('cur');
|
}
|
}
|
}
|
}
|
var itemL = $("." + showClass + " ." + itemId + "value");
|
if (typeof value == "string") {
|
value = [value];
|
}
|
|
//数据赋值
|
for (var i = 0; i < itemL.length; i++) {
|
var valueTemp = value[i];
|
if (type == "radio") {
|
var items = $(itemL[i]).find(".custom-radio");
|
} else {
|
var items = $(itemL[i]).find(".custom-check");
|
}
|
items.removeClass('cur');
|
checkboxRadioItem(items, valueTemp)
|
}
|
},
|
},
|
//复选框组
|
checkbox: {
|
getItem: function (itemId) {
|
var checkItem = "";
|
if ($(itemId)[0] != undefined) {
|
checkItem = $(itemId)[0].className.replace("custom-check", "");
|
}
|
if (checkItem.indexOf("cur") > 0) {
|
checkItem = true;
|
} else {
|
checkItem = false;
|
}
|
return checkItem;
|
},
|
setItem: function (itemId, value) {
|
if (value) {
|
$(itemId).addClass('cur')
|
} else {
|
$(itemId).removeClass('cur');
|
}
|
},
|
},
|
// HTML内容
|
htmlediter: {
|
getItem: function (itemId) {
|
itemId = itemId + "Item";
|
return UE.getEditor(itemId).getContent();
|
},
|
setItem: function (itemId, value, showClass) {
|
itemId = itemId+"Item";
|
console.log(value)
|
var rValue = value.join(",");//html回显bug修改 李伟民 0201
|
if(showClass ==undefined){
|
showClass = 'customViewUEditorCss';
|
}
|
UE.getEditor(itemId).ready(function(){
|
UE.getEditor(itemId).setContent(rValue);
|
});
|
|
},
|
},
|
dropdownlistView: {
|
getItem: function (itemId) {
|
return $(itemId).select2("val");
|
},
|
setItem: function (itemId, value) {
|
if (value) {
|
$(itemId).select2("val", value);
|
} else {
|
$('.selectItme').attr('value', "");
|
$('.val-card').remove();
|
}
|
},
|
},
|
dropdownlist: {
|
getItem: function (itemId) {
|
return $(itemId).select2("val");
|
},
|
setItem: function (itemId, value) {
|
if (value) {
|
$(itemId).select2("val", value);
|
} else {
|
$('.selectItme').attr('value', "");
|
$('.val-card').remove();
|
}
|
},
|
},
|
// 下拉框(文本取得)
|
dropdownlistText: {
|
getItem: function (itemId) {
|
var itemList = $(".customViewUEditorCss ." + itemId + "value");
|
var itemListReturn = [];
|
var select2ItemList = customBase.options.dropdownlistText[itemId];
|
for (var i = 0; i < itemList.length; i++) {
|
var select2Item = $(itemList[i]).select2("data");
|
var items = [];
|
for (var j = 0; j < select2Item.length; j++) {
|
for (var z = 0; z < select2ItemList.length; z++) {
|
if (select2ItemList[z].text == select2Item[j].text) {
|
items[j] = select2ItemList[z].value;
|
}
|
}
|
// items[j] = select2Item[j].text;
|
};
|
itemListReturn[i] = items;
|
};
|
|
return itemListReturn;
|
},
|
setItem: function (itemId, value, showClass, dropdowntype) {
|
console.log(value)
|
// var select2Item = customBase.options.dropdownlistText[itemId];
|
// //单多选框数据设定
|
// //2017/10/27 马习同修改
|
// var customItem = customBase.options.customItems;
|
// var itemAttr = "";
|
// for(let key in customItem){
|
// if(customItem[key].id == itemId){
|
// itemAttr = customItem[key];
|
// }
|
// }
|
// console.log(_.cloneDeep(customItem))
|
// console.log(itemAttr);
|
// //2017/10/27 马习同修改
|
// setelect2Item = function (itemId,value){
|
// if(typeof value == "string"){
|
// value = [value];
|
// }
|
// var itemsTemp = [];
|
// for (var i = 0; i < value.length; i++) {
|
// for (var j = 0; j < select2Item.length; j++) {
|
// if(select2Item[j].value == value[i]){
|
// var id = select2Item[j].id;
|
// itemsTemp[i] = id;
|
// }
|
// };
|
// }
|
// $(itemId).val(itemsTemp).trigger("change");
|
// }
|
// //多个下拉菜单 马习同
|
// var itemList = $("."+showClass+" #itemId_"+itemAttr.parentsubFormNum+" ."+itemId+"value");
|
// var itemList1 = $("."+showClass+" ."+itemId+"value");
|
// console.log(itemList);
|
// console.log(itemList1);
|
// console.log(value)
|
// if(itemList.length ==1){
|
// setelect2Item(itemList[0],value);
|
// }else{
|
// for (var i = 0; i < itemList.length; i++) {
|
// console.log(value)
|
// console.log(itemList[i],value[i])
|
// setelect2Item(itemList1[i],value[i]);
|
// }
|
// }
|
//
|
//原代码
|
// var select2Item = customBase.options.dropdownlistText[itemId];
|
// //单多选框数据设定
|
// setelect2Item = function (itemId,value){
|
// if(typeof value == "string"){
|
// value = [value];
|
// }
|
// var itemsTemp = [];
|
// for (var i = 0; i < value.length; i++) {
|
// for (var j = 0; j < select2Item.length; j++) {
|
// if(select2Item[j].value == value[i]){
|
// var id = select2Item[j].id;
|
// itemsTemp[i] = id;
|
// }
|
// };
|
// }
|
// $(itemId).val(itemsTemp).trigger("change");
|
// }
|
// //多个下拉菜单
|
// var itemList = $("."+showClass+" ."+itemId+"value");
|
// if(itemList.length ==1){
|
// setelect2Item(itemList[0],value);
|
// }else{
|
//
|
// for (var i = 0; i < itemList.length; i++) {
|
// setelect2Item(itemList[i],value[i]);
|
// }
|
// }
|
},
|
},
|
dropdownlistText2: {
|
getItem: function (itemId) {
|
// var itemList = $(".customViewUEditorCss ."+itemId+"value");
|
// var itemListReturn =[];
|
// var select2ItemList = customBase.options.dropdownlistText[itemId];
|
// for (var i = 0; i < itemList.length; i++) {
|
// var select2Item = $(itemList[i]).select2("data");
|
// var items = [];
|
// for (var j = 0; j < select2Item.length; j++) {
|
// for(var z=0;z<select2ItemList.length;z++){
|
// if(select2ItemList[z].text == select2Item[j].text){
|
// items[j] = select2ItemList[z].value;
|
// }
|
// }
|
// // items[j] = select2Item[j].text;
|
// };
|
// itemListReturn[i] = items;
|
// };
|
var itemListReturn = xhSelect.getValue(itemId);
|
return itemListReturn;
|
},
|
setItem: function (itemId, value, showClass, dropdowntype) {
|
//2017/10/27 马习同修改
|
console.log(value);
|
var customItem = customBase.options.customItems;
|
var itemAttr = "";
|
for (let key in customItem) {
|
if (customItem[key].id == itemId) {
|
itemAttr = customItem[key];
|
}
|
}
|
//2017/10/27 马习同修改
|
|
var select2Item = customBase.options.dropdownlistText[itemId];
|
if (itemAttr.parentsubFormNum != 0) {//非子表单中 无需添加parentformnum 李伟民 11-14
|
var itemList = $("#itemId_" + itemAttr.parentsubFormNum + " #" + itemId);
|
} else {
|
var itemList = $("#" + itemId);
|
}
|
console.log(itemList);
|
if (itemList.length == 1) {
|
// setelect2Item(itemId,value,0);
|
xhSelect.setValue(itemId, value, 0)
|
} else {
|
|
for (var i = 0; i < itemList.length; i++) {
|
// setelect2Item(itemId,value[i],i);
|
xhSelect.setValue(itemId, value[i], i)
|
}
|
}
|
|
},
|
},
|
// 下拉框(值取得)
|
dropdownlisVal: {
|
getItem: function (itemId) {
|
var itemList = $("." + itemId + "value");
|
var itemListReturn = [];
|
for (var i = 0; i < itemList.length; i++) {
|
var select2Item = $(itemList[i]).select2("val");
|
var items = [];
|
for (var j = 0; j < select2Item.length; j++) {
|
items[j] = select2Item[j].text;
|
};
|
itemListReturn[i] = items;
|
};
|
return itemListReturn;
|
},
|
setItem: function (itemId, value) {
|
$(itemId).select2("val", value);
|
},
|
},
|
//文件上传 图片
|
fileupload: { //-------------todo------------------
|
getItem: function (itemId) {
|
var fileReturn = {};
|
for (i in customBase.options.uploaderItem[itemId]) {
|
if (customBase.options.uploaderItem[itemId].hasOwnProperty(i)) {
|
var timestamp = new Date().getTime();
|
var idt = i.replace("WU", timestamp);
|
fileReturn[idt] = customBase.options.uploaderItem[itemId][i];
|
// fileReturn.push(customBase.options.uploaderItemReady[itemId][i]);
|
}
|
};
|
//////console.log(fileReturn);
|
return fileReturn;
|
},
|
setItem: function (itemId, value) {
|
//无此情况
|
},
|
},
|
tree: { //-------------todo------------------
|
getItem: function (itemId) {
|
|
var returnItem = [];
|
var treeItem = $('div#' + itemId);
|
var dataItemJSson;
|
for (var i = 0; i < treeItem.length; i++) {
|
if (treeItem[i].getAttribute("value") == "") {
|
var treeItem = {};
|
} else {
|
////console.log(selectItme[i].getAttribute("value"));
|
dataItemJSson = $.parseJSON(treeItem[i].getAttribute("value"));
|
}
|
|
var jn = 0;
|
returnItem[i] = [];
|
for (j in dataItemJSson) {
|
returnItem[i][jn] = j;
|
jn++;
|
}
|
}
|
return returnItem;
|
},
|
setItem: function (itemId, value) {
|
var treeDiv = $('div#' + itemId);
|
console.log(value)
|
// 判断是否在子表单内
|
var isSubformTree = false;
|
_.forIn(customShow.options.customItemShow.item, function (value, key) {
|
if (value.tag_Id == itemId && value.parentsubFormNum != 0) {
|
isSubformTree = true;
|
}
|
});
|
|
// 不在子表单内的树
|
if (!isSubformTree) {
|
var dataObj = {}
|
var valueData = [];
|
// 更新数据的时候需要在div上绑定一个存储数据的value
|
// 单选
|
if(value)
|
console.log(value);
|
// if(value == ' '){
|
// if(value == ' '){
|
// value = window.localStorage.getItem('businessTypeAuto');
|
// }
|
// }else{
|
if (typeof value == "string") {
|
dataObj[value] = '1'
|
} else {
|
for (var j = 0; j < value.length; j++) {
|
valueData[j] = value[j].split(',')
|
dataObj[valueData[j]] = '1'
|
}
|
}
|
$('#' + itemId).attr('value', JSON.stringify(dataObj))
|
console.log(value)
|
console.log(itemId)
|
var b = $('#'+itemId + "tree")
|
console.log($('#'+itemId + "tree"))
|
var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree");
|
console.log(treeObj)
|
if (treeObj == null) {
|
return;
|
}
|
if (typeof value == "string") {
|
value = [value];
|
}
|
// 2017/11/6 回显的地方
|
for (var i = 0, l = value.length; i < l; i++) {
|
if (treeObj.setting.check.chkStyle == "radio") {
|
// 单选
|
console.log(value)
|
var nodes = treeObj.getNodeByParam("id", value[i], null);
|
console.log(nodes);
|
if (_.isNull(nodes)) {
|
// treeObj.checkAllNodes(false);
|
// return false;
|
} else {
|
if (value == nodes.id) {
|
value = nodes.name;
|
}
|
console.log(value)
|
if (nodes != null) {
|
// 2017 /11/6 选中
|
//选择节点设定
|
treeObj.checkNode(nodes, true, true);
|
treeObj.expandAll(true);
|
}
|
}
|
} else {
|
// 多选
|
for (var j = 0; j < value[i].length; j++) {
|
//取得设定节点
|
console.log(value[j]);
|
var nodes = treeObj.getNodeByParam("id", value[j], null);
|
console.log(nodes)
|
if (_.isNull(nodes)) {
|
// treeObj.checkAllNodes(false);
|
// return false;
|
} else {
|
if (value[j] == nodes.id) {
|
value[j] = nodes.name;
|
}
|
console.log(nodes)
|
if (nodes != null) {
|
// 2017 /11/6 选中
|
//选择节点设定
|
treeObj.checkNode(nodes, true, true);
|
treeObj.expandAll(true);
|
}
|
}
|
}
|
}
|
}
|
// 详细页面的回显
|
// var showTreeDiv = ` <div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClass edui-default customShowItemClassTemp">
|
// ${value}
|
// </div>`
|
// $('#customShow').find(`#${itemId}ActiveId`).children(':nth-child(4)').remove();
|
$('#customShow').find(`[treeitemid=${itemId}]`).html(value);//普通模式树形回显 李伟民 0130
|
// $('#customShow').find(`#${itemId}ActiveId`).append(showTreeDiv);
|
$('#' + itemId).parents('div[name="TreeWin"]').find('.citySel').val(value);
|
// }
|
} else {
|
// 子表单里只有一颗树的时候
|
if (treeDiv.length == 1) {
|
var dataObj = {}
|
var valueData = [];
|
// 更新数据的时候需要在div上绑定一个存储数据的value
|
// 单选
|
console.log(value);
|
// 不在子表单里的树更新时需要的数据
|
if(value){
|
if (typeof value[0] == "string" && value[0]!= '') {
|
dataObj[value[0]] = '1'
|
} else {
|
for (var i = 0; i < value[0].length; i++) {
|
valueData[i] = value[0][i].split(',')
|
dataObj[valueData[i]] = '1'
|
}
|
}
|
$('#' + itemId).attr('value', JSON.stringify(dataObj))
|
var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree");
|
if (treeObj == null) {
|
return;
|
}
|
if (typeof value == "string") {
|
value = [value];
|
}
|
// 2017/11/6 回显的地方
|
for (var i = 0, l = value.length; i < l; i++) {
|
if (treeObj.setting.check.chkStyle == "radio") {
|
// 12/6 因为会触发customShow.addtree()导致ul 的id 变更
|
var treeDiv = $('div#' + itemId);
|
var ultreeId = $(treeDiv).find('ul').attr('id');
|
var treeObj = $.fn.zTree.getZTreeObj(ultreeId);
|
// var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree1");
|
// 单选
|
var nodes = treeObj.getNodeByParam("id", value[i], null);
|
console.log(nodes)
|
if (_.isNull(nodes)) {
|
|
var tid = '';
|
nodes = treeObj.getCheckedNodes(true);
|
for (var i = 0; i < nodes.length; i++) {
|
tid = nodes[i].tId
|
}
|
console.log(tid)
|
// 强行制空
|
$('#'+tid+'_check').click()
|
$('#' + tid + '_check').click()
|
$(treeDiv).prev().find('.citySel').val('')
|
} else {
|
if (value[i] == nodes.id) {
|
value[i] = nodes.name;
|
}
|
if (nodes != null) {
|
// 2017 /11/6 选中
|
//选择节点设定
|
console.log(nodes)
|
treeObj.checkNode(nodes, true, true);
|
treeObj.expandAll(true);
|
console.log(treeObj)
|
var tid = '';
|
nodes11 = treeObj.getCheckedNodes(true);
|
console.log(nodes11)
|
for (var i = 0; i < nodes11.length; i++) {
|
tid = nodes11[i].tId
|
}
|
console.log(tid);
|
// console.log($('#'+tid+'_check'))
|
// $('#'+tid+'_check').click()
|
// $('#'+tid+'_check').click()
|
|
}
|
}
|
} else {
|
// 多选
|
for (var j = 0; j < value[i].length; j++) {
|
//取得设定节点
|
console.log(value[i][j]);
|
var nodes = treeObj.getNodeByParam("id", value[i][j], null);
|
console.log(nodes)
|
if (_.isNull(nodes)) {
|
// treeObj.checkAllNodes(false);
|
// return false;
|
} else {
|
if (value[i][j] == nodes.id) {
|
value[i][j] = nodes.name;
|
}
|
console.log(nodes)
|
if (nodes != null) {
|
// 2017 /11/6 选中
|
//选择节点设定
|
treeObj.checkNode(nodes, true, true);
|
treeObj.expandAll(true);
|
console.log(treeObj)
|
|
}
|
}
|
}
|
}
|
}
|
// 回显到table表格里
|
var showIdTbale = $(`#${itemId}`).parents('.subformCss').attr('id');
|
$(`#${itemId}`).parent('div[name="TreeWin"]').find('.citySel').val(value);
|
var deitSubFormsTree = $(`#${showIdTbale}`).find('tbody').find('tr:nth-child(2)').find('td');
|
for (var i = 1; i < deitSubFormsTree.length - 1; i++) {
|
// 将编辑页面的树形ipnut 里面的值 放到展示页面里
|
var value = $(deitSubFormsTree[i]).find('.citySel').val();
|
$(`#customShow #${showIdTbale}ActiveId`).find(`#${showIdTbale}`).find('.trContentClass').find(`td:nth-child(${i + 1})`).find('.customShowItemClass').html(value)
|
}
|
|
}
|
|
} else {
|
// 子表单内td里面的div更改
|
var oNode = '<div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClassTemp customShowItemClass ' + id + '_showItem edui-default">';
|
oNode += "</div>";
|
var showItem = $($(".customShow").find("#" + itemId));
|
for (var i = 0; i < showItem.length; i++) {
|
$($(showItem[i])[0]).after(oNode);
|
$($(showItem[i])[0]).remove();
|
}
|
var treeDiv = $('div#' + itemId);
|
console.log(treeDiv)
|
// 插入input里的value
|
var iptValue = [];
|
var iptValueObj = {};
|
// 更新的时候需要的数据
|
var dataObj = {}
|
var valueData = [];
|
for (var j = 0; j < treeDiv.length; j++) {
|
var ultreeId = $(treeDiv[j]).find('ul').attr('id');
|
var treeObj = $.fn.zTree.getZTreeObj(ultreeId);
|
if (treeObj == null) {
|
return;
|
}
|
if (typeof value == "string") {
|
value = [value];
|
}
|
// 2017/11/6 回显的地方
|
// 单选
|
if (treeObj.setting.check.chkStyle == "radio") {
|
console.log($(treeDiv[j]))
|
console.log(value);
|
for (var i = 0; i < value.length; i++) {
|
if (value[i] == '') {
|
console.log(1)
|
// dataObj = {}
|
} else {
|
console.log(2)
|
if (i == j) {
|
dataObj[value[i]] = '1';
|
}
|
}
|
}
|
$(treeDiv[j]).attr('value', JSON.stringify(dataObj))
|
dataObj = {}
|
console.log(j)
|
console.log(value[j])
|
var nodes = treeObj.getNodeByParam("id", value[j], null);
|
console.log(nodes)
|
console.log(treeObj)
|
if (_.isNull(nodes)) {
|
// treeObj.checkAllNodes(false);
|
var tid = '';
|
nodes = treeObj.getCheckedNodes(true);
|
for (var i = 0; i < nodes.length; i++) {
|
tid = nodes[i].tId
|
}
|
console.log(tid)
|
$('#' + tid + '_check').click()
|
$(treeDiv[j]).prev().find('.citySel').val('')
|
} else {
|
if (value[j] == nodes.id) {
|
iptValue.push(nodes.name);
|
}
|
if (nodes != null) {
|
// 2017 /11/6 选中
|
//选择节点设定
|
console.log(treeObj);
|
console.log(nodes)
|
treeObj.checkNode(nodes, true, true);
|
treeObj.expandAll(true);
|
}
|
for (var k = 0; k < iptValue.length; k++) {
|
$(treeDiv[j]).prev().find('.citySel').val(iptValue[k])
|
}
|
}
|
|
} else {
|
// 多选
|
|
console.log(value[j])
|
if (typeof value[j] == "string") {
|
var strValue = value[j].split(',');
|
// 导入excel时状态多选为字符串形式
|
if (strValue.length > 1) {
|
console.log(strValue)
|
for (var n = 0; n < strValue.length; n++) {
|
var nodes = treeObj.getNodeByParam("id", strValue[n], null);
|
console.log(nodes)
|
if (strValue[n] == '') {
|
|
} else {
|
dataObj[strValue[n]] = '1';
|
}
|
if (_.isNull(nodes)) {
|
// treeObj.checkAllNodes(false);
|
// return false;
|
$(treeDiv[j]).prev().find('.citySel').val('')
|
|
} else {
|
if (strValue[n] == nodes.id) {
|
iptValue.push(nodes.name);
|
}
|
if (nodes != null) {
|
// 2017 /11/6 选中
|
//选择节点设定
|
treeObj.checkNode(nodes, true, true);
|
treeObj.expandAll(true);
|
}
|
}
|
$(treeDiv[j]).attr('value', JSON.stringify(dataObj))
|
|
}
|
$(treeDiv[j]).prev().find('.citySel').val(iptValue.join(','))
|
iptValue = [];
|
dataObj = {};
|
} else {
|
var nodes = treeObj.getNodeByParam("id", value[j], null);
|
for (var i = 0; i < value.length; i++) {
|
if (value[i] == '') {
|
|
} else {
|
if (i == j) {
|
dataObj[value[i]] = '1';
|
}
|
}
|
}
|
$(treeDiv[j]).attr('value', JSON.stringify(dataObj))
|
dataObj = {}
|
if (_.isNull(nodes)) {
|
// treeObj.checkAllNodes(false);
|
// return false;
|
} else {
|
if (value[j] == nodes.id) {
|
iptValue.push(nodes.name);
|
}
|
if (nodes != null) {
|
// 2017 /11/6 选中
|
//选择节点设定
|
treeObj.checkNode(nodes, true, true);
|
treeObj.expandAll(true);
|
}
|
for (var k = 0; k < iptValue.length; k++) {
|
$(treeDiv[j]).prev().find('.citySel').val(iptValue[k])
|
}
|
iptValue = [];
|
}
|
}
|
} else {
|
var dataObj = {}
|
var valueData = [];
|
for (var i = 0; i < value[j].length; i++) {
|
valueData[i] = value[j][i].split(',')
|
dataObj[valueData[i]] = '1'
|
}
|
$(treeDiv[j]).attr('value', JSON.stringify(dataObj))
|
for (var k = 0; k < value[j].length; k++) {
|
// j是 有几个input框
|
// k是 value 里面的数据还会有呈现数组的形式
|
dataObj = {}
|
valueData = [];
|
var nodes = treeObj.getNodeByParam("id", value[j][k], null);
|
if (_.isNull(nodes)) {
|
|
} else {
|
if (value[j][k] == nodes.id) {
|
if (k <= value[j].length) {
|
iptValue.push(nodes.name);
|
}
|
}
|
iptValueObj[k] = iptValue;
|
// if (nodes != null) {
|
// 2017 /11/6 选中
|
//选择节点设定
|
treeObj.checkNode(nodes, true, true);
|
treeObj.expandAll(true);
|
// }
|
}
|
}
|
for (index in iptValueObj) {
|
$(treeDiv[j]).prev().find('.citySel').val(iptValueObj[index].join(','))
|
}
|
iptValue = [];
|
iptValueObj = {};
|
}
|
|
}
|
// 获取父级ID
|
var showIdTable = $(`#${itemId}`).parents('.subformCss').attr('id');
|
// 获取当前树形在整个td的下标
|
var subformDataIndex = $(`#${itemId}`).parents('td').index();
|
var subformTr = $('#customShow tr#' + showIdTable + "subformTr");
|
var subformValue = $($('.tabBox' + ' #' + showIdTable + "subformTr")[j]).find('td').eq(subformDataIndex).find('.citySel').val()
|
$(subformTr[j]).children().eq(subformDataIndex).find('.customShowItemClassTemp').html(subformValue);
|
}
|
}
|
}
|
|
},
|
},
|
//选择表单控件
|
mytext: {
|
getItem: function (itemId) {
|
// var newmytextObj = $('#'+itemId+' ul');
|
// console.log(newmytextObj);
|
// var chooseFormData = {};
|
// var str = [];
|
// _.each(newmytextObj,(opt,i)=>{
|
// var $mytextObj = $('#'+opt.id+' [class="data1 DATAROWNUM"]');
|
// var $mytextObj2 = $('#'+opt.id+' [class="data2 DATAROWNUM"]');
|
//// console.log($mytextObj);
|
//// console.log($mytextObj2);
|
//// console.log($mytextObj.html());
|
//// console.log($mytextObj2.html());
|
//// for(let i = 0;i < $mytextObj.length ;i++){
|
//// var $myText = $mytextObj.eq(i).html();
|
//// console.log($myText)
|
//// console.log($mytextObj2.eq(i).html())
|
//// chooseFormData[$myText] = $mytextObj2.eq(i).html();
|
////
|
//// }
|
//// dataArr1.push($mytextObj2.html());
|
// console.log(i);
|
// console.log(newmytextObj.length);
|
// if(i<newmytextObj.length-1){
|
// str += $mytextObj2.html()+",";
|
// }else{
|
// str += $mytextObj2.html();
|
// }
|
// })
|
// console.log(str)
|
|
var str = $('#' + itemId).attr("mxtVal");//关联数据 取值 11-07 李伟民
|
return str;
|
|
|
},
|
setItem: function (itemId, value) {
|
console.log(value);
|
if (!_.isString(value)) {
|
var new_value = [];
|
_.each(value.list, function (v) {
|
if (v.DATAROWNUM) {
|
new_value.push(v.DATAROWNUM);
|
}
|
});
|
new_value = new_value.join();
|
$('#' + itemId).attr("mxtVal", new_value);//关联数据 存值 11-07 李伟民
|
} else {
|
$('#' + itemId).attr("mxtVal", value);//关联数据 存值 11-07 李伟民
|
}
|
},
|
},
|
};
|
|
|
//画面弹出信息
|
customBase.alert = function (type, message) {
|
if (type == "E") {
|
toastr.error(message);
|
} else if (type == "I") {
|
toastr.info(message);
|
} else if (type == "W") {
|
toastr.warning(message);
|
} else if (type == "S") {
|
toastr.success(message);
|
} else {
|
toastr.error(message);
|
}
|
}
|
|
//根据别名取得字段Id
|
customBase.getfieldKeyFoItemId = function (fieldKey) {
|
return customBase.options.customItems[fieldKey].id;
|
}
|
|
//取得message信息
|
customBase.getMessage = function (messageID) {
|
// 12/11
|
var strMessage = "";
|
switch (messageID) {
|
case "mesage_ID001":
|
strMessage = "子表单中无法追加此控件!";
|
break;
|
case "mesage_ID002":
|
strMessage = "表单别名重复,请对别名进行修改!";
|
break;
|
case "mesage_ID003":
|
strMessage = "表单保存成功!";
|
break;
|
case "mesage_ID004":
|
strMessage = '项目必须输入!';
|
break;
|
case "mesage_ID005":
|
strMessage = "上传成功!";
|
break;
|
case "mesage_ID006":
|
strMessage = "操作过于频繁,请稍后再执行!";
|
break;
|
case "mesage_ID007":
|
strMessage = "画面字段数据过多,保存失败!";
|
break;
|
case "mesage_ID008":
|
strMessage = "单行文本的最大长度不能超过150!";
|
break;
|
case "mesage_ID009":
|
strMessage = "'请输入有效的手机号码!";
|
break;
|
case "mesage_ID010":
|
strMessage = "'请输入正确的网址!";
|
break;
|
case "mesage_ID011":
|
strMessage = "'请输入有效的身份证号!";
|
break;
|
case "mesage_ID012":
|
strMessage = "请输入有效的邮箱!";
|
break;
|
case "mesage_ID013":
|
strMessage = "请输入表单名!";
|
break;
|
case "mesage_ID014":
|
strMessage = "表单版本重复,请修改!";
|
break;
|
case "mesage_ID015":
|
strMessage = "保存成功!";
|
break;
|
case "mesage_ID016":
|
strMessage = "表单别名必须输入,请对别名进行修改!";
|
break;
|
case "mesage_ID017":
|
strMessage = "表单的宽高必须输入!";
|
break;
|
case "mesage_ID018":
|
strMessage = "请输入版本信息!";
|
break;
|
case "mesage_ID019":
|
strMessage = "请输入整数!";
|
break;
|
case "mesage_ID020":
|
strMessage = "整数长度超出设定范围!";
|
break;
|
case "mesage_ID021":
|
strMessage = "小数长度超出设定范围!";
|
break;
|
case "mesage_ID022":
|
strMessage = "条形码默认值不能为空!";
|
break;
|
case "mesage_ID023":
|
strMessage = "长度超出设定范围!";
|
break;
|
case "mesage_ID024":
|
strMessage = "请选择正确的部门";
|
break;
|
case "mesage_ID025":
|
strMessage = "预算余额不足,不可退回";
|
break;
|
case "mesage_ID026":
|
strMessage = "上级预算余额不足";
|
break;
|
case "mesage_ID027":
|
strMessage = "操作成功";
|
break;
|
case "mesage_ID028":
|
strMessage = "上级预算无此业务类型";
|
break;
|
case "mesage_ID029":
|
strMessage = "还款成功";
|
break;
|
case "mesage_ID030":
|
strMessage = "还款失败";
|
break;
|
case "mesage_ID031":
|
strMessage = "创建流程实例成功";
|
break;
|
case "mesage_ID032":
|
strMessage = "请创建流程定义";
|
break;
|
case "mesage_ID033":
|
strMessage = "服务器返回错误有";
|
break;
|
case "mesage_ID034":
|
strMessage = "本条数据已创建流程";
|
break;
|
case "mesage_ID035":
|
strMessage = "请先选择流程定义";
|
break;
|
default:
|
strMessage = "错误信息,请与管理员联系!";
|
}
|
return strMessage;
|
}
|
|
|
//取得表单画面项目
|
customBase.getItemValue = function (itemId, type) {
|
|
var item = "";
|
//单行文本 多行文本 数字 日历 customBase.itemEdit var prefix = JSON.parse(window.localStorage.getItem("customItem"));
|
if (type == 'text' || type == 'textarea' || type == 'number' || type == 'calendar' || type == "auto") {
|
item = customBase.itemEdit['text'].getItem("." + itemId + "value");
|
} else if (type == 'radio' || type == 'checkbox') {
|
item = customBase.itemEdit['checkboxRadio'].getItem(itemId, type);
|
} else if (type == 'image' || type == 'fileupload') {
|
item = customBase.itemEdit['fileupload'].getItem(itemId);
|
} else if (type == 'amount') {
|
item = customBase.itemEdit['text'].getItem("#" + itemId + "amount");
|
} else if (type == 'qrcode') {
|
item = customBase.itemEdit['text'].getItem("#" + itemId + "qrcode");
|
} else if (type == 'barcode') {
|
item = customBase.itemEdit['text'].getItem("#" + itemId + "barcode");
|
} else if (type == 'splitline' || type == 'button') {
|
|
} else if (type == 'dropdownlistText') {
|
// customBase.itemEdit[type].setItem(itemId,value,showClass,dropdowntype);
|
// item = customBase.itemEdit["dropdownlistText"].getItem(itemId);
|
item = customBase.itemEdit["dropdownlistText2"].getItem(itemId);
|
} else if (type == "tree") {
|
item = customBase.itemEdit["tree"].getItem(itemId);
|
} else {
|
item = customBase.itemEdit[type].getItem(itemId);
|
}
|
return item;
|
}
|
//设定表单画面项目 12/7
|
customBase.setItemValue = function (itemId, type, value, showClass, dropdowntype, num) {
|
console.log(type)
|
console.log(value)
|
console.log(itemId)
|
var item;
|
if (showClass == "") {
|
showClass = 'customViewUEditorCss';
|
}
|
if (type == 'text' || type == 'textarea' || type == 'number' || type == 'calendar' || type == 'auto') {
|
if (num != undefined) {
|
customBase.itemEdit['text'].setItem("[id=" + itemId + "]:eq('" + num + "')", value, showClass);
|
} else {
|
customBase.itemEdit['text'].setItem("#" + itemId, value, showClass);
|
}
|
} else if (type == 'htmlediter') {
|
customBase.itemEdit['htmlediter'].setItem(itemId, value, showClass);
|
} else if (type == 'radio' || type == 'checkbox') {
|
customBase.itemEdit['checkboxRadio'].setItem(itemId, type, value, showClass);
|
} else if (type == 'tree') {
|
customBase.itemEdit['tree'].setItem(itemId, value);
|
} else if (type == 'dropdownlistText') {
|
//console.log(value);
|
customBase.itemEdit[type].setItem(itemId, value, showClass, dropdowntype);
|
//console.log(1);
|
customBase.itemEdit["dropdownlistText2"].setItem(itemId, value, showClass, dropdowntype);
|
} else if (type == 'splitline' || type == 'subform' || type == 'tag' || type == 'tab') {
|
} else if (type == 'image') {
|
// customBase.itemEdit[type].setItem(itemId,value,showClass);
|
} else if (type == 'qrcode') {
|
// customBase.itemEdit[type].setItem(itemId,value,showClass);
|
} else if (type == 'barcode') {
|
// customBase.itemEdit[type].setItem(itemId,value,showClass);
|
} else if (type == 'link') {
|
// customBase.itemEdit[type].setItem(itemId,value,showClass);
|
} else if (type == 'button') {
|
// customBase.itemEdit[type].setItem(itemId,value,showClass);
|
} else {
|
customBase.itemEdit[type].setItem(itemId, value, showClass);
|
}
|
|
}
|
|
|
/**
|
* 获取项目根路径1
|
* @return {RootPath}
|
*/
|
customBase.getRootPath = function () {
|
var strFullPath = window.document.location.href;
|
var strPath = window.document.location.pathname;
|
var pos = strFullPath.indexOf(strPath);
|
var prePath = strFullPath.substring(0, pos);
|
var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1) + "/";
|
return (prePath + postPath);
|
}
|
|
|
|
//文件上传
|
customBase.uploaderFileShow = function (potion) {
|
console.log(potion);
|
var itemId = potion.id;
|
|
customBase.options.uploaderItem[itemId] = {};
|
var arrItemReady = 0;
|
if (potion.ItemReady != undefined) {
|
arrItemReady = Object.keys(potion.ItemReady).length;
|
customBase.options.uploaderItem[itemId] = potion.ItemReady;
|
}
|
var $uploaderItem = $(".customViewUEditorCss #" + potion.id);
|
$uploaderItem.empty();
|
var $uploadimg = $(
|
'<div id="' + potion.id + 'uploadimg">' +
|
'<div id="' + potion.id + 'fileList" class="uploader-list"></div>' +
|
'</div>'
|
);
|
var $list = $uploadimg.find("#" + potion.id + "fileList");
|
var $addLi = $(
|
'<div id="' + potion.id + 'imgPicker" class="file-item ">' +
|
'<button type="button" class="btn btn-info designbtn right">点击选文件</button>' +
|
'</div>'
|
);
|
$list.after($addLi);
|
|
//不可见辑情况下 附件追加按钮隐藏 李伟民 0123
|
if (!potion.visible) {
|
$addLi.addClass("cfg_contentNone");
|
}
|
if (!potion.editable) {//不可编辑 附件追加按钮样式修改 李伟民 0123
|
$addLi.find('button').addClass("disabled");
|
}
|
//默认图片追加
|
if (potion.defaultvalueUrl != "") {
|
var tmp = potion.defaultvalueUrl.split("/");//按照"/"分割
|
var pp = tmp[tmp.length - 1];//获取最后一部分,即文件名和参数
|
var $li = $(
|
'<div class="thumbnail01">' +
|
'<div class="info"><a href="' + potion.defaultvalueUrl + '" >' + pp + '</a></div>' +
|
'</div>'
|
);
|
$list.prepend($li);
|
// //单一图片的情况下 图片追加隐藏
|
// if(potion.imagetype == "single"){
|
// $addLi.addClass("cfg_contentNone");
|
// }
|
}
|
//数据编辑的情况下,数据表示
|
if (arrItemReady > 0) {
|
for (fileid in potion.ItemReady) {
|
if (potion.ItemReady.hasOwnProperty(fileid)) {
|
var fileItem = potion.ItemReady[fileid];
|
// var $list = $("#"+potion.id+"fileList"),
|
// var $list = $uploadimg,
|
$li = $(
|
'<div id="' + fileid + '" class="thumbnail01">' +
|
'<div class="frm_item_icons01">' +
|
'<div class="frm_item_icon remove" imgId="' + fileid + '">' +
|
'<img alt=" " style="width:14px;height:14px;" src="./../../formEngine/resources/css/img/icon/delete.png"></div>' +
|
'</div>' +
|
// '<img class = "fileQueuedAddItem" src = "'+fileItem.base64+'">' +
|
// '<div class="info"><a href="'+customBase.options.uploaderItem[itemId][file.id].path+'" >' + file.name + '</a></div>' +
|
'<div class="info"><a href="' + fileItem.path + '" >' + fileItem.oldName + '</a></div>' +
|
'</div>'
|
);
|
// $img = $li.find('.fileQueuedAddItem');
|
|
$li.find(".frm_item_icon").on('click', function (event) {
|
var imgId = this.getAttribute("imgId");
|
$('#' + imgId).remove();
|
if (imgId.indexOf("WU") > -1) {
|
uploader.removeFile(imgId, true);
|
}
|
delete customBase.options.uploaderItem[itemId][imgId];
|
|
event.stopPropagation();
|
return false;
|
|
});
|
// $list为容器jQuery实例
|
$list.prepend($li);
|
}
|
}
|
}
|
|
$uploaderItem.append($uploadimg);
|
customBase.uploaderTemp += 500;
|
setTimeout(function () {
|
if (!potion.editable) {//不可编辑 点击无效果 李伟民 0123
|
return false;
|
}
|
var uploader;
|
var webUploaderJson = {
|
// 选完文件后,是否自动上传。
|
auto: true,
|
// pick: '#'+potion.id+"dndArea",
|
pick: '#' + potion.id + 'imgPicker',
|
paste: potion.id,
|
swf: '../../dist/Uploader.swf',
|
// fileExt: '*.zip,*.doc,*.xls,*.mp3,*.mp4',
|
// chunked:true,
|
// chunkSize :true,
|
fileSizeLimit: 20 * 1024 * 1024, // 200 M
|
fileSingleSizeLimit: 20 * 1024 * 1024, // 50 M
|
accept: {// 只允许选择图片文件格式
|
title: 'File',
|
extensions: 'zip,rar,xls,xlsx,doc,docx,ppt,pptx,rtf',
|
mimeTypes: ''
|
},
|
|
}
|
var webUploaderJson = $.extend(webUploaderJson, window.commonWebUploaderJson(potion.formid));
|
|
|
// 初始化Web Uploader
|
uploader = WebUploader.create(webUploaderJson);
|
|
// uploader;
|
uploader.on('ready', function () {
|
debugger
|
window.uploader = uploader;
|
});
|
uploader.on('error', function (type) {
|
if (type == "Q_TYPE_DENIED") {
|
customBase.alert("myModal", "请上传zip,rar,xls,xlsx,doc,docx,ppt,pptx,rtf格式文件", "");
|
}
|
});
|
// 当有文件添加进来的时候
|
uploader.on('fileQueued', function (file) {
|
// var $list = $("#"+potion.id+"fileList"),
|
var $list = $(".customViewUEditorCss #" + potion.id + "fileList"),
|
$li = $(
|
'<div id="' + file.id + '" class="thumbnail01">' +
|
'<div class="frm_item_icons01">' +
|
'<div class="frm_item_icon remove" imgId="' + file.id + '">' +
|
'<img style="width:14px;height:14px;" src="./../../formEngine/resources/css/img/icon/delete.png"></div>' +
|
'</div>' +
|
// '<img class = "fileQueuedAddItem">' +
|
'<div class="info"><a href="" >' + file.name + '</a></div>' +
|
'</div>'
|
),
|
$img = $li.find('.fileQueuedAddItem');
|
|
$li.find(".frm_item_icon").on('click', function () {
|
var imgId = this.getAttribute("imgId");
|
$('#' + imgId).remove();
|
if (imgId.indexOf("WU") > -1) {
|
uploader.removeFile(imgId, true);
|
}
|
delete customBase.options.uploaderItem[itemId][imgId];
|
|
event.stopPropagation();
|
return false;
|
});
|
// $list为容器jQuery实例
|
$list.prepend($li);
|
});
|
// 文件上传过程中创建进度条实时显示。
|
uploader.on('uploadProgress', function (file, percentage) {
|
});
|
|
// 文件上传成功,给item添加成功class, 用样式标记上传成功。
|
uploader.on('uploadSuccess', function (file, response) {
|
//////console.log(file);
|
//////console.log(response);
|
|
$("#" + itemId + "mesageErrDiv").remove();
|
$(".customViewUEditorCss #" + itemId).popover('hide')
|
|
$('#' + file.id).addClass('upload-state-done');
|
customBase.options.uploaderItem[itemId][file.id] = response.data;
|
$('#' + file.id).find("a")[0].setAttribute("href", response.data.path);
|
});
|
|
// 文件上传失败,显示上传出错。
|
uploader.on('uploadError', function (file) {
|
var $li = $('#' + file.id),
|
$error = $li.find('div.error');
|
|
// 避免重复创建
|
if (!$error.length) {
|
$error = $('<div class="error"></div>').appendTo($li);
|
}
|
|
$error.text('上传失败');
|
});
|
|
// 完成上传完了,成功或者失败,先删除进度条。
|
uploader.on('uploadComplete', function (file) {
|
$('#' + file.id).find('.progress').remove();
|
});
|
}, customBase.uploaderTemp);
|
}
|
//图片上传
|
customBase.uploaderShow = function (potion) {
|
var customShowFlag = window.localStorage.getItem("customShowFlag")
|
console.log(customShowFlag);
|
console.log(customBase.options);
|
console.log(customShow.options.customItemShow.item);
|
var customItem = customShow.options.customItemShow.item;
|
//////console.log(potion);
|
var itemId = potion.id;
|
// var uploader;
|
customBase.options.uploaderItem[itemId] = {};
|
var arrItemReady = 0;
|
if (potion.ItemReady != undefined) {
|
arrItemReady = Object.keys(potion.ItemReady).length;
|
customBase.options.uploaderItem[itemId] = potion.ItemReady;
|
}
|
var $uploaderItem = $(".customViewUEditorCss #" + potion.id);
|
$uploaderItem.empty();
|
var $uploadimg = $(
|
'<div id="' + potion.id + 'uploadimg">' +
|
'<div id="' + potion.id + 'fileList" class="uploader-list"></div>' +
|
'</div>'
|
);
|
var $list = $uploadimg.find("#" + potion.id + "fileList");
|
console.log($('#' + itemId))
|
var $addLi = $(
|
'<div id="' + potion.id + 'imgPicker" class="file-item thumbnail">' +
|
'<div style="background:url(./../../formEngine/resources/css/image.png) no-repeat ;width: 100px;height: 100px;>" </div>' +
|
'</div>'
|
);
|
$list.prepend($addLi);
|
// //不可编辑情况下 图片追加隐藏
|
// if (!potion.editable) {
|
// $addLi.addClass("cfg_contentNone");
|
// }
|
//不可见辑情况下 图片追加按钮隐藏 李伟民 0123
|
if (!potion.visible) {
|
$addLi.addClass("cfg_contentNone");
|
}
|
if (!potion.editable) {//不可编辑 图片追加样式修改 李伟民 0123
|
$addLi.css("cursor","not-allowed")
|
}
|
//默认图片追加
|
if (potion.defaultvalueUrl != "") {
|
var $li = $(
|
'<div class="file-item thumbnail">' +
|
'<img src="' + potion.defaultvalueUrl + '"' +
|
'</div>'
|
// `<div class="file-item thumbnail">
|
// <img src="${potion.defaultvalueUrl}" data-original="${otion.defaultvalueUrl}"
|
// </div>`
|
);
|
$list.prepend($li);
|
//单一图片的情况下 图片追加隐藏
|
if (potion.imagetype == "single") {
|
$addLi.addClass("cfg_contentNone");
|
}
|
}
|
//数据编辑的情况下,数据表示
|
console.log(arrItemReady)
|
if (arrItemReady > 0) {
|
console.log(potion.ItemReady)
|
for (fileid in potion.ItemReady) {
|
if (potion.ItemReady.hasOwnProperty(fileid)) {
|
var fileItem = potion.ItemReady[fileid];
|
// var $list = $("#"+potion.id+"fileList"),
|
// var $list = $uploadimg,
|
var $li = $(
|
'<div id="' + fileid + '" class="file-item thumbnail">' +
|
'<img alt=" " class = "fileQueuedAddItem" src = "' + fileItem.base64 + '" data-original ="' + fileItem.base64 + '" >' +
|
'<div class="frm_item_icons">' +
|
'<div class="frm_item_icon remove" imgId="' + fileid + '">' +
|
// '<img style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
|
'<div style="width:14px;height:14px;background:url(./../../formEngine/resources/css/img/icon/delete.png);"> </div></div>' +
|
|
'</div>' +
|
// '<div class="info">' + file.name + '</div>' +
|
'</div>'
|
);
|
|
|
$li.find(".frm_item_icon").on('click', function () {
|
var imgId = this.getAttribute("imgId");
|
$('#' + imgId).remove();
|
if (imgId.indexOf("WU") > -1) {
|
uploader.removeFile(imgId, true);
|
}
|
delete customBase.options.uploaderItem[itemId][imgId];
|
//单一图片的情况下 图片追加隐藏
|
if (potion.imagetype == "single") {
|
$addLi.removeClass("cfg_contentNone");
|
}
|
console.log($(this))
|
event.stopPropagation();
|
});
|
// $list为容器jQuery实例
|
$list.prepend($li);
|
console.log($('#customShow').children())
|
|
}
|
}
|
}
|
//单一图片的情况下 图片追加隐藏
|
if (arrItemReady > 0 && potion.imagetype == "single") {
|
setTimeout(function () {
|
$addLi.addClass("cfg_contentNone");
|
}, 10);
|
console.log($('#customShow').children())
|
|
}
|
|
$uploaderItem.append($uploadimg);
|
customBase.uploaderTemp += 500;
|
setTimeout(function () {
|
if (!potion.editable) {//不可编辑 取消点击事件 李伟民 0123
|
return false;
|
}
|
var uploader;
|
var webUploaderJson = {
|
// 选完文件后,是否自动上传。
|
auto: true,
|
// pick: '#'+potion.id+"dndArea",
|
pick: {
|
id: '#' + potion.id + 'imgPicker',
|
multiple: false//禁止多选
|
},
|
paste: potion.id,
|
swf: '../../dist/Uploader.swf',
|
}
|
var webUploaderJson = $.extend(webUploaderJson, window.commonWebUploaderJson(potion.formid));
|
|
|
// 初始化Web Uploader
|
uploader = WebUploader.create(webUploaderJson);
|
|
// uploader;
|
uploader.on('ready', function () {
|
window.uploader = uploader;
|
});
|
// 当有文件添加进来的时候
|
uploader.on('fileQueued', function (file) {
|
// var $list = $("#"+potion.id+"fileList"),
|
var $list = $(".customViewUEditorCss #" + potion.id + "fileList"),
|
$li = $(
|
'<div id="' + file.id + '" class="file-item thumbnail">' +
|
'<div class="frm_item_icons">' +
|
'<div class="frm_item_icon remove" imgId="' + file.id + '">' +
|
'<img style="width:14px;height:14px;" src="./../../formEngine/resources/css/img/icon/delete.png"></div>' +
|
'</div>' +
|
'<img class = "fileQueuedAddItem">' +
|
// '<div class="info">' + file.name + '</div>' +
|
'</div>'
|
),
|
$img = $li.find('.fileQueuedAddItem');
|
|
$li.find(".frm_item_icon").on('click', function () {
|
var imgId = this.getAttribute("imgId");
|
$('#' + imgId).remove();
|
if (imgId.indexOf("WU") > -1) {
|
uploader.removeFile(imgId, true);
|
}
|
delete customBase.options.uploaderItem[itemId][imgId];
|
//单一图片的情况下 图片追加隐藏
|
if (potion.imagetype == "single") {
|
$addLi.removeClass("cfg_contentNone");
|
}
|
|
event.stopPropagation();
|
|
});
|
// $list为容器jQuery实例
|
$list.prepend($li);
|
|
//单一图片的情况下 图片追加隐藏
|
if (potion.imagetype == "single") {
|
$addLi.addClass("cfg_contentNone");
|
}
|
|
// 创建缩略图
|
// 如果为非图片文件,可以不用调用此方法。
|
// thumbnailWidth x thumbnailHeight 为 100 x 100
|
uploader.makeThumb(file, function (error, src) {
|
if (error) {
|
$img.replaceWith('<span>不能预览</span>');
|
return;
|
}
|
// //////console.log(customBase.options.uploaderItem[itemId][file.id]);
|
// customBase.options.uploaderItem[itemId][file.id]["base64"] = src;
|
$img.attr('src', src);
|
// 12/21
|
console.log($img)
|
$img.attr('data-original', src);
|
|
}, 100, 100);
|
});
|
// 文件上传过程中创建进度条实时显示。
|
uploader.on('uploadProgress', function (file, percentage) {
|
var $li = $('#' + file.id),
|
$percent = $li.find('.progress span');
|
|
// 避免重复创建
|
if (!$percent.length) {
|
$percent = $('<p class="progress"><span></span></p>')
|
.appendTo($li)
|
.find('span');
|
}
|
//////console.log(percentage);
|
$percent.css('width', percentage * 100 + '%');
|
});
|
|
// 文件上传成功,给item添加成功class, 用样式标记上传成功。
|
uploader.on('uploadSuccess', function (file, response) {
|
//////console.log(file);
|
//////console.log(response);
|
$('#' + file.id).addClass('upload-state-done');
|
// customBase.options.uploaderFileName[file.id] = response.data;
|
customBase.options.uploaderItem[itemId][file.id] = response.data;
|
// //////console.log(customBase.options.uploaderItem[itemId][file.id]);
|
customBase.options.uploaderItem[itemId][file.id]["base64"] = $("#" + file.id + " .fileQueuedAddItem")[0].getAttribute("src");
|
});
|
|
// 文件上传失败,显示上传出错。
|
uploader.on('uploadError', function (file) {
|
var $li = $('#' + file.id),
|
$error = $li.find('div.error');
|
|
// 避免重复创建
|
if (!$error.length) {
|
$error = $('<div class="error"></div>').appendTo($li);
|
}
|
|
$error.text('上传失败');
|
});
|
|
// 完成上传完了,成功或者失败,先删除进度条。
|
uploader.on('uploadComplete', function (file) {
|
$('#' + file.id).find('.progress').remove();
|
});
|
}, customBase.uploaderTemp);
|
// 12/19
|
console.log($uploadimg)
|
console.log($('#customViewUEditor').find('#itemId_1').children())
|
|
var $uploaderItems = $($("#customViewUEditor #" + potion.id)[0]);
|
var imgId = $uploaderItems.attr('id');
|
var srcUrl = $uploaderItems.find('img').attr('src');
|
// $uploaderItem.find('img').attr('data-original',srcUrl);
|
console.log($('#' + imgId).children().children())
|
|
console.log($('#' + imgId).find('#itemId_1fileList').find('label'))
|
$('#' + imgId).find('#itemId_1fileList').find('label').css({
|
'height': '150px',
|
'width': '150px'
|
})
|
var id = $('#' + imgId).children().children().attr('id')
|
//编辑
|
var viewer = new Viewer(document.getElementById(id), {
|
url: 'data-original',
|
movable: false
|
});
|
console.log($('#customShow').children())
|
console.log($("[style='opacity: 0; width: 100%; height: 100%; display: block; cursor: pointer; background: rgb(255, 255, 255)']"))
|
}
|
|
|
//图片上传
|
customBase.uploaderShow_Temp = function (itemId, chunkSize, imgFlag, formID) {
|
if (chunkSize.width != 0) {
|
$(itemId + 'dndArea')[0].style.width = chunkSize.width + 'px';
|
$(itemId + 'dndArea')[0].style.height = chunkSize.height + 'px';
|
}
|
|
var $wrap = $(itemId),
|
// 图片容器
|
$queue = $('<ul class="filelist"></ul>').appendTo($wrap.find('.queueList')),
|
// 状态栏,包括进度和控制按钮
|
$statusBar = $wrap.find('.statusBar'),
|
// 文件总体选择信息。
|
$info = $statusBar.find('.info'),
|
// 上传按钮
|
$upload = $wrap.find('.uploadBtn'),
|
// 没选择文件之前的内容。
|
$placeHolder = $wrap.find('.placeholder'),
|
|
$progress = $statusBar.find('.progress').hide(),
|
// 添加的文件数量
|
fileCount = 0,
|
// 添加的文件总大小
|
fileSize = 0,
|
// 优化retina, 在retina下这个值是2
|
ratio = window.devicePixelRatio || 1,
|
// 缩略图大小
|
thumbnailWidth = 110 * ratio,
|
thumbnailHeight = 110 * ratio,
|
// 可能有pedding, ready, uploading, confirm, done.
|
state = 'pedding',
|
// 所有文件的进度信息,key为file id
|
percentages = {},
|
// 判断浏览器是否支持图片的base64
|
isSupportBase64 = (function () {
|
var data = new Image();
|
var support = true;
|
data.onload = data.onerror = function () {
|
if (this.width != 1 || this.height != 1) {
|
support = false;
|
}
|
}
|
data.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
|
return support;
|
})(),
|
// 检测是否已经安装flash,检测flash的版本
|
flashVersion = (function () {
|
var version;
|
|
try {
|
version = navigator.plugins['Shockwave Flash'];
|
version = version.description;
|
} catch (ex) {
|
try {
|
version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash')
|
.GetVariable('$version');
|
} catch (ex2) {
|
version = '0.0';
|
}
|
}
|
version = version.match(/\d+/g);
|
return parseFloat(version[0] + '.' + version[1], 10);
|
})(),
|
|
supportTransition = (function () {
|
var s = document.createElement('p').style,
|
r = 'transition' in s ||
|
'WebkitTransition' in s ||
|
'MozTransition' in s ||
|
'msTransition' in s ||
|
'OTransition' in s;
|
return r;
|
})(),
|
//创建
|
uploader;
|
|
if (!WebUploader.Uploader.support('flash') && WebUploader.browser.ie) {
|
// flash 安装了但是版本过低。
|
if (flashVersion) {
|
(function (container) {
|
window['expressinstallcallback'] = function (state) {
|
switch (state) {
|
case 'Download.Cancelled':
|
customBase.alert("M", '您取消了更新!')
|
break;
|
|
case 'Download.Failed':
|
customBase.alert("M", '安装失败')
|
break;
|
|
default:
|
customBase.alert("M", '安装已成功,请刷新!');
|
break;
|
}
|
delete window['expressinstallcallback'];
|
};
|
|
var swf = './expressInstall.swf';
|
// insert flash object
|
var html = '<object type="application/' +
|
'x-shockwave-flash" data="' + swf + '" ';
|
|
if (WebUploader.browser.ie) {
|
html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
|
}
|
|
html += 'width="100%" height="100%" style="outline:0">' +
|
'<param name="movie" value="' + swf + '" />' +
|
'<param name="wmode" value="transparent" />' +
|
'<param name="allowscriptaccess" value="always" />' +
|
'</object>';
|
|
container.html(html);
|
|
})($wrap);
|
|
// 压根就没有安转。
|
} else { }
|
|
return;
|
} else if (!WebUploader.Uploader.support()) {
|
customBase.alert("M", 'Web Uploader 不支持您的浏览器!');
|
return;
|
}
|
if (imgFlag) {
|
labelTemp = '点击选择图片'
|
} else {
|
labelTemp = '点击选择文件'
|
}
|
|
|
|
;
|
var webUploaderJson = {
|
pick: {
|
id: itemId + 'filePicker',
|
label: labelTemp
|
},
|
dnd: itemId + 'dndArea',
|
paste: itemId,
|
swf: '../../dist/Uploader.swf',
|
chunked: false,
|
chunkSize: 512 * 1024,
|
// 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候,把图片打开。
|
disableGlobalDnd: true,
|
fileNumLimit: 300,
|
fileSizeLimit: 200 * 1024 * 1024, // 200 M
|
fileSingleSizeLimit: 50 * 1024 * 1024 // 50 M
|
}
|
var webUploaderJson = $.extend(webUploaderJson, window.commonWebUploaderJson(formID));
|
|
// 实例化
|
uploader = WebUploader.create(webUploaderJson);
|
|
// 拖拽时不接受 js, txt 文件。
|
uploader.on('dndAccept', function (items) {
|
var denied = false,
|
len = items.length,
|
i = 0,
|
// 修改js类型
|
unAllowed = 'text/plain;application/javascript ';
|
|
for (; i < len; i++) {
|
// 如果在列表里面
|
if (~unAllowed.indexOf(items[i].type)) {
|
denied = true;
|
break;
|
}
|
}
|
|
return !denied;
|
});
|
|
// 添加“添加文件”的按钮,
|
uploader.addButton({
|
id: itemId + 'filePicker2',
|
label: '继续添加'
|
});
|
//文件读取
|
uploader.on('ready', function () {
|
window.uploader = uploader;
|
$queue.empty();
|
var json = customBase.options.uploaderItemReady[itemId.replace("#", "")];
|
if (json == undefined) {
|
json = [];
|
}
|
var jsonLen = json.length;
|
if (jsonLen != 0) {
|
fileCount = jsonLen;
|
$placeHolder.addClass('element-invisible');
|
$statusBar.show();
|
//显示在页面上
|
$.each(json, function (i, n) {
|
fileSize += n.filelen;
|
var obj = {}, statusMap = {}
|
, file_id = 'WU_FILE_' + i;
|
obj.id = file_id;
|
obj.name = n.filebasename;
|
obj.filename = n.filename;
|
obj.getStatus = function () {
|
return '';
|
};
|
obj.statusText = '';
|
obj.size = n.filelen;
|
obj.version = WebUploader.Base.version;
|
obj.type = n.mimeType;
|
obj.filetype = n.filetype;
|
obj.source = this;
|
obj.path = n.filePath.path;
|
obj.setStatus = function (status, text) {
|
|
var prevStatus = statusMap[this.id];
|
|
typeof text !== 'undefined' && (this.statusText = text);
|
|
if (status !== prevStatus) {
|
statusMap[this.id] = status;
|
/**
|
* 文件状态变化
|
* @event statuschange
|
*/
|
uploader.trigger('statuschange', status, prevStatus);
|
}
|
};
|
editFile(obj);
|
$("#" + file_id).append(inputStr(i, n));
|
});
|
|
WebUploader.Base.idSuffix = jsonLen;
|
|
setState('ready');
|
updateTotalProgress();
|
}
|
// },'json');
|
});
|
|
function inputStr(index, json) {
|
var inputStr = '';
|
var pre = itemId;
|
//转化格式后的名称
|
inputStr += '<input name="' + pre + 'list[' + index + '].filename" value="' + json.filename + '" style="display:none"/>';
|
//保存路径
|
inputStr += '<input name="' + pre + 'list[' + index + '].filepath" value="' + json.filepath + '" style="display:none"/>';
|
//文件源名称
|
inputStr += '<input name="' + pre + 'list[' + index + '].filebasename" value="' + json.filebasename + '" style="display:none"/>';
|
|
//文件类型 doc?xls?
|
inputStr += '<input name="' + pre + 'list[' + index + '].filetype" value="' + json.filetype + '" style="display:none"/>';
|
//文件大小
|
inputStr += '<input name="' + pre + 'list[' + index + '].filelen" value="' + json.filelen + '" style="display:none"/>';
|
//doc转为html
|
inputStr += '<input name="' + pre + 'list[' + index + '].doc2htmlpath" value="' + json.doc2htmlpath + '" style="display:none"/>';
|
//mimeType
|
inputStr += '<input name="' + pre + 'list[' + index + '].mimeType" value="' + json.mimeType + '" style="display:none"/>';
|
return inputStr;
|
}
|
|
function editFile(file) {
|
if (imgFlag) {
|
var $li = $('<li id="' + file.id + '" class="imgfileLiShow">' +
|
'<p class="title">' + file.name + '</p>' +
|
'<p class="imgWrap"></p>' +
|
'<p class="progress"><span></span></p>' +
|
'</li>'),
|
|
$btns = $('<div class="file-panel">' +
|
'<span class="cancel">删除</span>' +
|
'<span class="rotateRight">向右旋转</span>' +
|
'<span class="rotateLeft">向左旋转</span></div>').appendTo($li),
|
|
$wrap = $li.find('p.imgWrap')
|
|
} else {
|
var $li = $('<li id="' + file.id + '">' +
|
'<div class="title" style="word-break:break-all;text-align:left;font-size:16px">' + file.filename + '</div>' +
|
|
'</li>'),
|
$btns = $('<div class="file-panel">' +
|
'<span class="cancel">删除</span>'
|
|
+ '</div>'
|
).appendTo($li),
|
|
$wrap = $li.find('p.imgWrap')
|
}
|
|
if (file.getStatus() === 'invalid') {
|
showError(file.statusText);
|
} else {
|
// @todo lazyload
|
$wrap.empty();
|
$wrap.text('不能预览');
|
|
var img;
|
//判断是否是图片
|
src = file.path;
|
img = $('<img src="' + src + '" style="height:100%;">');
|
$wrap.empty().append(img);
|
|
percentages[file.id] = [file.size, 0];
|
file.rotation = 0;
|
}
|
|
|
|
$li.append('<span class="success"></span>');
|
|
$li.on('mouseenter', function () {
|
$btns.stop().animate({ height: 30 });
|
});
|
|
$li.on('mouseleave', function () {
|
$btns.stop().animate({ height: 0 });
|
});
|
|
$btns.on('click', 'span', function () {
|
var index = $(this).index(),
|
deg;
|
|
switch (index) {
|
case 0:
|
// uploader.removeFile( file );
|
return;
|
|
case 1:
|
file.rotation += 90;
|
break;
|
|
case 2:
|
file.rotation -= 90;
|
break;
|
}
|
|
if (supportTransition) {
|
deg = 'rotate(' + file.rotation + 'deg)';
|
$wrap.css({
|
'-webkit-transform': deg,
|
'-mos-transform': deg,
|
'-o-transform': deg,
|
'transform': deg
|
});
|
} else {
|
$wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
|
}
|
|
|
});
|
|
$li.appendTo($queue);
|
}
|
|
|
// 当有文件添加进来时执行,负责view的创建
|
if (imgFlag) { }
|
function addFile(file) {
|
if (imgFlag) {
|
var $li = $('<li id="' + file.id + '" class="imgfileLiShow">' +
|
'<p class="title">' + file.name + '</p>' +
|
'<p class="imgWrap"></p>' +
|
'<p class="progress"><span></span></p>' +
|
'</li>'),
|
|
$btns = $('<div class="file-panel">' +
|
'<span class="cancel">删除</span>' +
|
'<span class="rotateRight">向右旋转</span>' +
|
'<span class="rotateLeft">向左旋转</span></div>').appendTo($li),
|
$prgress = $li.find('p.progress span'),
|
$wrap = $li.find('p.imgWrap'),
|
$info = $('<p class="error"></p>')
|
} else {
|
var $li = $('<li id="' + file.id + '">' +
|
'<div class="title" style="word-break:break-all;text-align:left;font-size:16px">' + file.name + '</div>' +
|
'</li>'),
|
|
$btns = $('<div class="file-panel">' +
|
'<span class="cancel">删除</span>' +
|
'</div>'
|
).appendTo($li),
|
$prgress = $li.find('p.progress span'),
|
$wrap = $li.find('p.imgWrap'),
|
$info = $('<p class="error"></p>')
|
}
|
|
|
showError = function (code) {
|
switch (code) {
|
case 'exceed_size':
|
text = '文件大小超出';
|
break;
|
|
case 'interrupt':
|
text = '上传暂停';
|
break;
|
|
default:
|
text = '上传失败,请重试';
|
break;
|
}
|
|
$info.text(text).appendTo($li);
|
};
|
|
if (file.getStatus() === 'invalid') {
|
showError(file.statusText);
|
} else {
|
// @todo lazyload
|
$wrap.text('预览中');
|
uploader.makeThumb(file, function (error, src) {
|
var img;
|
|
if (error) {
|
$wrap.text('不能预览');
|
return;
|
}
|
if (isSupportBase64) {
|
img = $('<img src="' + src + '">');
|
$wrap.empty().append(img);
|
} else {
|
|
}
|
}, thumbnailWidth, thumbnailHeight);
|
|
percentages[file.id] = [file.size, 0];
|
file.rotation = 0;
|
}
|
|
file.on('statuschange', function (cur, prev) {
|
if (prev === 'progress') {
|
$prgress.hide().width(0);
|
} else if (prev === 'queued') {
|
$li.off('mouseenter mouseleave');
|
$btns.remove();
|
}
|
|
// 成功
|
if (cur === 'error' || cur === 'invalid') {
|
//////////console.log( file.statusText );
|
showError(file.statusText);
|
percentages[file.id][1] = 1;
|
} else if (cur === 'interrupt') {
|
showError('interrupt');
|
} else if (cur === 'queued') {
|
percentages[file.id][1] = 0;
|
} else if (cur === 'progress') {
|
$info.remove();
|
$prgress.css('display', 'block');
|
} else if (cur === 'complete') {
|
$li.append('<span class="success"></span>');
|
}
|
|
$li.removeClass('state-' + prev).addClass('state-' + cur);
|
});
|
|
$li.on('mouseenter', function () {
|
$btns.stop().animate({ height: 30 });
|
});
|
|
$li.on('mouseleave', function () {
|
$btns.stop().animate({ height: 0 });
|
});
|
|
$btns.on('click', 'span', function () {
|
var index = $(this).index(),
|
deg;
|
|
switch (index) {
|
case 0:
|
uploader.removeFile(file);
|
return;
|
|
case 1:
|
file.rotation += 90;
|
break;
|
|
case 2:
|
file.rotation -= 90;
|
break;
|
}
|
|
if (supportTransition) {
|
deg = 'rotate(' + file.rotation + 'deg)';
|
$wrap.css({
|
'-webkit-transform': deg,
|
'-mos-transform': deg,
|
'-o-transform': deg,
|
'transform': deg
|
});
|
} else {
|
$wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
|
}
|
|
|
});
|
|
$li.appendTo($queue);
|
}
|
|
// 负责view的销毁
|
function removeFile(file) {
|
var $li = $('#' + file.id);
|
|
delete percentages[file.id];
|
updateTotalProgress();
|
$li.off().find('.file-panel').off().end().remove();
|
}
|
|
function updateTotalProgress() {
|
var loaded = 0,
|
total = 0,
|
spans = $progress.children(),
|
percent;
|
|
$.each(percentages, function (k, v) {
|
total += v[0];
|
loaded += v[0] * v[1];
|
});
|
|
percent = total ? loaded / total : 0;
|
|
|
spans.eq(0).text(Math.round(percent * 100) + '%');
|
spans.eq(1).css('width', Math.round(percent * 100) + '%');
|
updateStatus();
|
}
|
|
function updateStatus() {
|
var text = '', stats;
|
|
if (state === 'ready') {
|
if (imgFlag) {
|
text = '选中' + fileCount + '张图片,共' + WebUploader.formatSize(fileSize) + '。';
|
} else {
|
text = '选中' + fileCount + '个文件,共' + WebUploader.formatSize(fileSize) + '。';
|
}
|
|
} else if (state === 'confirm') {
|
stats = uploader.getStats();
|
if (stats.uploadFailNum) {
|
if (imgFlag) {
|
text = '已成功上传' + stats.successNum + '张照片至XX相册,' +
|
stats.uploadFailNum + '张照片上传失败,<a class="retry" href="#">重新上传</a>失败图片或<a class="ignore" href="#">忽略</a>'
|
} else {
|
text = '已成功上传' + stats.successNum + '个文件至XX文件夹,' +
|
stats.uploadFailNum + '个文件上传失败,<a class="retry" href="#">重新上传</a>失败文件或<a class="ignore" href="#">忽略</a>'
|
}
|
}
|
|
} else {
|
stats = uploader.getStats();
|
if (imgFlag) {
|
text = '共' + fileCount + '张(' +
|
WebUploader.formatSize(fileSize) +
|
'),已上传' + stats.successNum + '张';
|
|
if (stats.uploadFailNum) {
|
text += ',失败' + stats.uploadFailNum + '张';
|
}
|
} else {
|
text = '共' + fileCount + '个文件(' +
|
WebUploader.formatSize(fileSize) +
|
'),已上传' + stats.successNum + '个文件';
|
|
if (stats.uploadFailNum) {
|
text += ',失败' + stats.uploadFailNum + '个文件';
|
}
|
}
|
|
}
|
|
$info.html(text);
|
}
|
|
function setState(val) {
|
var file, stats;
|
|
if (val === state) {
|
return;
|
}
|
|
$upload.removeClass('state-' + state);
|
$upload.addClass('state-' + val);
|
state = val;
|
|
switch (state) {
|
case 'pedding':
|
$placeHolder.removeClass('element-invisible');
|
$queue.hide();
|
$statusBar.addClass('element-invisible');
|
uploader.refresh();
|
break;
|
|
case 'ready':
|
$placeHolder.addClass('element-invisible');
|
$('#filePicker2').removeClass('element-invisible');
|
$queue.show();
|
$statusBar.removeClass('element-invisible');
|
uploader.refresh();
|
break;
|
|
case 'uploading':
|
$('#filePicker2').addClass('element-invisible');
|
$progress.show();
|
$upload.text('暂停上传');
|
break;
|
|
case 'paused':
|
$progress.show();
|
$upload.text('继续上传');
|
break;
|
|
case 'confirm':
|
$progress.hide();
|
$('#filePicker2').removeClass('element-invisible');
|
$upload.text('开始上传');
|
|
stats = uploader.getStats();
|
if (stats.successNum && !stats.uploadFailNum) {
|
setState('finish');
|
return;
|
}
|
break;
|
case 'finish':
|
stats = uploader.getStats();
|
if (stats.successNum) {
|
var strMessage = customBase.getMessage("mesage_ID005");
|
customBase.alert("S", strMessage);
|
// alert( '上传成功' );
|
} else {
|
// 没有成功的图片,重设
|
state = 'done';
|
location.reload();
|
}
|
break;
|
}
|
|
updateStatus();
|
}
|
|
uploader.onUploadProgress = function (file, percentage) {
|
var $li = $('#' + file.id),
|
$percent = $li.find('.progress span');
|
|
$percent.css('width', percentage * 100 + '%');
|
percentages[file.id][1] = percentage;
|
updateTotalProgress();
|
customBase.options.uploaderItem[itemId] = uploader.getFiles();
|
};
|
|
uploader.onFileQueued = function (file) {
|
fileCount++;
|
fileSize += file.size;
|
|
if (fileCount === 1) {
|
$placeHolder.addClass('element-invisible');
|
$statusBar.show();
|
}
|
|
addFile(file);
|
setState('ready');
|
updateTotalProgress();
|
};
|
|
uploader.onFileDequeued = function (file) {
|
fileCount--;
|
fileSize -= file.size;
|
|
if (!fileCount) {
|
setState('pedding');
|
}
|
|
removeFile(file);
|
updateTotalProgress();
|
|
};
|
|
uploader.on('all', function (type) {
|
var stats;
|
switch (type) {
|
case 'uploadFinished':
|
setState('confirm');
|
break;
|
|
case 'startUpload':
|
setState('uploading');
|
break;
|
|
case 'stopUpload':
|
setState('paused');
|
break;
|
|
}
|
});
|
|
uploader.onError = function (code) {
|
customBase.alert("M", 'Eroor: ' + code);
|
};
|
|
$upload.on('click', function () {
|
if ($(this).hasClass('disabled')) {
|
return false;
|
}
|
if (state === 'ready') {
|
uploader.upload();
|
uploader.on('uploadSuccess', function (file, response) {
|
customBase.options.uploaderFileName[response.data.oldName] = response.data;
|
})
|
} else if (state === 'paused') {
|
uploader.upload();
|
} else if (state === 'uploading') {
|
uploader.stop();
|
}
|
});
|
|
$info.on('click', '.retry', function () {
|
uploader.retry();
|
});
|
|
$info.on('click', '.ignore', function () {
|
customBase.alert("M", 'todo');
|
});
|
|
$upload.addClass('state-' + state);
|
updateTotalProgress();
|
}
|
|
//得到金融控件的HTMLL
|
customBase.getAmountHtml = function (sizeWidthHeight, flag) {
|
var width = sizeWidthHeight.width;
|
var linewidth = (width - 10) / 11;
|
var item = sizeWidthHeight.defaultvalue;
|
var height = sizeWidthHeight.height;
|
var lineheight = parseInt(height) + 20;
|
var margin_top = '-20';
|
var itemTemp = item.split("");
|
var items = [];
|
var nbsp = '';
|
|
if (flag) {
|
nbsp = 'nbsp';
|
} else {
|
nbsp = ' ';
|
margin_top = '10';
|
}
|
for (var i = 0; i < 11; i++) {
|
items[i] = nbsp;
|
};
|
for (var i = 0; i < itemTemp.length; i++) {
|
items[11 - i - 1] = itemTemp[itemTemp.length - i - 1];
|
};
|
|
var oNode = '<div style="width:' + (width) + 'px;">';
|
oNode += '<hr style="float:left;width: 1px;height:' + lineheight + 'px;margin-top:' + margin_top + 'px;border: #fff;"/>';
|
if (items[0] == "nbsp") {
|
// items[0] = " ";
|
oNode += '<span style="width:' + (linewidth) + ';float:left;line-height:' + height + 'px;color:#fff;">' + ' ' + '</span>';
|
} else {
|
oNode += '<span style="width:' + (linewidth) + ';float:left;line-height:' + height + 'px;">' + items[0] + '</span>';
|
}
|
|
var hrcolor = "";
|
for (var i = 0; i < 10; i++) {
|
if (i == 2 || i == 5) {
|
hrcolor = '#31b0d5';
|
} else if (i == 8) {
|
hrcolor = '#D53137';
|
} else {
|
hrcolor = '#eee';
|
}
|
oNode += '<hr style="border:0px;background-color:' + hrcolor + ';color:' + hrcolor + ';float: left;width: 1px;height:' + lineheight + 'px;margin-top:' + margin_top + 'px;"/>';
|
// oNode += '<span style="width:'+linewidth+'px;float:left;line-height:'+height+'px;">'+items[i+1]+'</span>';
|
////////////console.log(items[i+1]);
|
if (items[i + 1] == "nbsp") {
|
// items[0] = "0";
|
oNode += '<span style="width:' + linewidth + 'px;float:left;line-height:' + height + 'px;color:#fff;">' + ' ' + '</span>';
|
} else {
|
oNode += '<span style="width:' + linewidth + 'px;float:left;line-height:' + height + 'px;">' + items[i + 1] + '</span>';
|
}
|
|
};
|
oNode += "</div>";
|
return oNode;
|
}
|
|
//条码设定
|
customBase.createbarcode = function (val, text, callback) {
|
|
var sizeWidthHeight = { width: 88, height: 40, styleclass: "" };
|
var barWidth = 1;
|
var barHeight = 5;
|
val = parseInt(val);
|
val = val;
|
if (val == 1) {
|
barWidth = 1;
|
barHeight = 30;
|
sizeWidthHeight = { width: 88, height: 40, styleclass: "" };
|
} else if (val == 2) {
|
barWidth = 2;
|
barHeight = 40;
|
sizeWidthHeight = { width: 176, height: 50, styleclass: "" };
|
} else if (val == 3) {
|
barWidth = 3;
|
barHeight = 50;
|
sizeWidthHeight = { width: 264, height: 60, styleclass: "" };
|
} else if (val == 4) {
|
barWidth = 4;
|
barHeight = 60;
|
sizeWidthHeight = { width: 352, height: 70, styleclass: "" };
|
} else if (val == 5) {
|
barWidth = 5;
|
barHeight = 70;
|
sizeWidthHeight = { width: 440, height: 80, styleclass: "" };
|
} else if (val == 6) {
|
barWidth = 6;
|
barHeight = 80;
|
sizeWidthHeight = { width: 528, height: 90, styleclass: "" };
|
}
|
|
//条形码数据回调
|
callback(text, barWidth, barHeight, sizeWidthHeight);
|
}
|
customBase.zTreeOnClick = function (event, treeId, treeNode) {
|
console.log(this);
|
console.log(event);
|
console.log(treeId);
|
console.log(treeNode);
|
|
if (treeNode.checked) {
|
// 单击事件 by kill
|
if ($('#span_' + treeNode.id).val() == undefined || $('#span_' + treeNode.id).val() == "") {
|
var i = $('#' + treeId).children(':first').children(':nth-child(2)').attr('class').indexOf('radio');
|
if (i != -1) {
|
////console.log(i)
|
////console.log('span_'+treeId)
|
$('.span_' + treeId).remove();
|
$('#' + treeId.replace("tree", ""))
|
.parent().parent().children(':first').children(':nth-child(4)').remove();
|
}
|
//$('#'+treeId.replace("tree","")).parent().parent().children(':first')
|
// .append('<span id="span_'+treeNode.id+'">|'+treeNode.name+' </sapn>')
|
}
|
} else {
|
$('#span_' + treeNode.id).remove();
|
}
|
var dofuncion = customBase.options.zTreeOnClickItems[treeId];
|
if (dofuncion != undefined) {
|
eval(dofuncion);
|
}
|
};
|
// 2017/11/2 李元杰 单选树选中事件
|
customBase.zTreeOncheckRadio = function (e, treeId, treeNode) {
|
//console.log($('#citySel').parents('div[name=treeWinTitle]').next().attr('id'));
|
|
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
//console.log(zTree)
|
var nodes = zTree.getCheckedNodes(true);
|
var v = "";
|
var dataObj = {}
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
v += nodes[i].name + ",";
|
console.log(nodes)
|
dataObj[nodes[i].id] = '1'
|
}
|
if (v.length > 0) v = v.substring(0, v.length - 1)
|
// 2017/11/6 李元杰 单选树
|
|
// console.log($('#'+treeId).parents('div[name="TreeWin"]').find('.citySel'))
|
// console.log( )
|
|
$(e.currentTarget).parent().attr('value', JSON.stringify(dataObj))
|
$(e.currentTarget).parents('div[name="TreeWin"]').find('.citySel').val(v);
|
// // cityObj.attr("value", v);
|
// console.log(e);
|
// console.log(treeId);
|
// console.log(treeNode);
|
// // $('#'+treeId).parents('div[type="tree"]').find('h8').children(':nth-child(4)').remove();
|
// console.log( $('#'+treeId).parents('div[type="tree"]').find('h8'));
|
// console.log( $('#'+treeId).parents('div[type="tree"]').find('h8').children(':nth-child(3)'))
|
|
// if(treeNode.checked){
|
// // 单击事件 by kill
|
// if($('#span_'+treeNode.id).val()==undefined||$('#span_'+treeNode.id).val()==""){
|
// //console.log($('#'+treeId))
|
// var i=$('#'+treeId).children(':first').children(':nth-child(2)').attr('class').indexOf('radio');
|
// if(i!=-1){
|
// //console.log(i)
|
// //console.log('span_'+treeId)
|
// $('.span_'+treeId).remove();
|
// $('#'+treeId.replace("tree",""))
|
// .parent().parent().children(':first').children(':nth-child(4)').remove();
|
// }
|
// }
|
// }else{
|
// $('#span_'+treeNode.id).remove();
|
// }
|
var pitchon = `
|
<span id="spanDiv'+${treeId}+'">
|
<span>|${v}</span>
|
</span>
|
`
|
// $('#'+treeId).parents('div[type="tree"]').find('h8').children(':nth-child(4)').remove();
|
// $('#'+treeId).parents('div[type="tree"]').find('h8').append(pitchon);
|
var dofuncion = customBase.options.zTreeOnClickItems[treeId];
|
if (dofuncion != undefined) {
|
eval(dofuncion);
|
}
|
}
|
customBase.settingChkboxType = {
|
check: {
|
autoCheckTrigger: false,
|
chkboxType: { "Y": "", "N": "" },
|
chkStyle: "checkbox",
|
enable: true,
|
nocheckInherit: false,
|
radioType: "level"
|
},
|
view: {
|
showIcon: false,
|
showLine: false,
|
txtSelectedEnable: true,
|
},
|
data: {
|
simpleData: {
|
enable: true,
|
idKey: "id",
|
pIdKey: "pId",
|
rootPId: 0
|
}
|
},
|
callback: {
|
onClick: customBase.zTreeOnClick,
|
onCheck: customBase.zTreeOncheckRadio,
|
}
|
}
|
|
customBase.settingRadioType = {
|
check: {
|
enable: true,
|
chkStyle: "radio",
|
radioType: "all",
|
},
|
view: {
|
showIcon: false,
|
showLine: false,
|
txtSelectedEnable: true,
|
},
|
data: {
|
simpleData: {
|
enable: true,
|
idKey: "id",
|
pIdKey: "pId",
|
rootPId: 0
|
}
|
},
|
callback: {
|
onClick: customBase.zTreeOnClick,
|
onCheck: customBase.zTreeOncheckRadio,
|
}
|
}
|
|
|
|
customBase.zNodes = [{ name: "树控件", isParent: true }];
|
var customShow = customShow || {};
|
|
customShow.button = {
|
//基础字段
|
printableBtn: { name: "打印", cssName: 'icon iconfont icon-dayin1 ', functionName: "customShow.onPrint" },
|
exportBtn: { name: "导出", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "" },
|
rejectBtn: { name: "驳回", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.rejectBtn" },
|
submitBtn: { name: "提交", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onclickSubmit" },
|
auditableBtn: { name: "审批", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.auditableBtn" },
|
queryBtn: { name: "查询", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "" },
|
createBtn: { name: "新建", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onclickSave1" },
|
clearBtn: { name: "清空", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onclickClear" },
|
disposableBtn: { name: "取消", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: 'customShow.onclickCancel' },
|
//fromSaveBtn: { name: "保存", cssName: 'icon iconfont icon-bianji ', functionName: "customShow.onclickSave2" },
|
editableBtn: { name: "编辑", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onEditor" },
|
//添加权限按钮 马习同 2017-12-14
|
billuploadingBtn: { name: "票据上传", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.billuploading" },
|
reuploadBtn: { name: "重新上传票据", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.reupload" },
|
checkbillBtn: { name: "查看票据", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.checkbill" },
|
}
|
console.log(Flatpickr)
|
Flatpickr.localize(Flatpickr.l10ns.zh); // 设置为中文
|
customShow.options = {
|
customItem: {},
|
customViewDiv: "",
|
customInit: {},
|
htmlediterShow: {},
|
attributeList: {}, //属性一览
|
// editorFlag:true,
|
formID: "", //表单ID
|
customShowFlag: "",//调用标识
|
dataRowNum: "", //更新行番号
|
breakFlag: false, //父画面刷新
|
datasource: {},
|
customItemShow: {},
|
initTempDatas: {}, //临时初始化数据
|
itemFormbase: "",
|
jsonLinkage: {}, //公式用
|
btnFlag: { editable: "1", printable: "1", auditable: "0", disposable: "0" }, //按钮表示
|
subformList: {}, //子表单List
|
subformDList: {},
|
dropdownlist_I: 0,
|
subformDValue: {},
|
formsetting: {},
|
showErrId: {},
|
// LinkageAnalysisSetValueFlag:false
|
}
|
|
customShow.initEvent = {
|
//--------------------保存Button事件------------------------
|
//画面check
|
fromCheck: function (items, callback) {
|
return customShow.onfromCheck(items);
|
////console.log(1)
|
},
|
//03检证执行
|
validationRuleCheck: function (items, callback) { return true },
|
//检证接口函数(第三口)
|
validationRuleCheck3rd: function (items, callback) { return customShow.interfaceCheck(items) },//保存前计算费用 李伟民 10 - 31
|
//发送数据到后台服务器,保存data
|
fromSave: function (items, callback) {
|
|
},
|
//发送数据到后台服务器,保存data
|
fromSave3rd: function (items, callback) { return true },
|
fromSaveLinkage: function (items, callback) { return true },
|
//--------------------保存Button事件------------------------
|
//--------------------初期化事件----------------------------
|
//01接口绑定:接口名 接口变量名 自定义函数
|
interfaceBind: [],
|
//02事件绑定:字段别名 字段类型 事件名 自定义事件名
|
// eventBind:[{fieldKey:"项目1",tag:"text",eventName:"click",functionName:"customShow.clickBindBase001"}],
|
eventBind: [],
|
//初期化接口
|
interfaceInit: function (customShowFlag) {
|
//表示模式
|
console.log(customShowFlag)
|
if (customShowFlag == 2) {
|
customShow.controlInit("customViewUEditorCss");
|
//控件初始化
|
customShow.controlInit("customShow");
|
} else {
|
//控件初始化
|
customShow.controlInit("customViewUEditorCss");
|
}
|
//事件初始化
|
customShow.clickBind();
|
// 12/14
|
if (customShowFlag == 1) {
|
// customShow.businessTypeAutoFun( 'businessTypeAuto','budget_itemCostType','cookie');
|
SC.autoFieldKey();
|
}
|
},
|
interfaceInit3rd: function (customShowFlag) { return true },
|
//验证初期公式
|
interfaceInitLinkage: function (customShowFlag) { return true },
|
//密码输入
|
passwordInputFlag: function (items, callback) { },
|
//--------------------初期化事件----------------------------
|
//--------------------取消事件----------------------------
|
//取消接口
|
cancelEvent: function (items, callback) { },
|
//取消接口(第三方提供)
|
cancelEvent3rd: function (items, callback) { return true },
|
//取消接口
|
cancelEventLinkage: function () { return true },
|
//--------------------取消事件----------------------------
|
//--------------------印刷事件----------------------------
|
interfaceprint: function (items, callback) { },
|
interfaceprint3rd: function (items, callback) { return true },
|
//--------------------印刷事件----------------------------
|
}
|
|
function getProcessLog() {//获得流程信息 李雁鸣 12-25
|
localStorage.setItem("processLog", null);
|
if (localStorage.getItem("customItem") != undefined && localStorage.getItem("customItem") != "undefined" && localStorage.getItem("customItem") != null && localStorage.getItem("customItem") != "" && localStorage.getItem("customItem") != null) {
|
var ss = { "formID": JSON.parse(localStorage.getItem("customForm")).newFormID, "dataRowNum": JSON.parse(localStorage.getItem("customItem")).DATAROWNUM };
|
var requestSingleForm = window.commonAjax("/ubp-api-seache/process/inst/log", ss, "POST", true, false);
|
requestSingleForm.done(function (rs) {
|
console.log(rs.data);
|
console.log("新改的");
|
if (rs.data != undefined) {
|
localStorage.setItem("processLog", JSON.stringify(rs.data.data));
|
} else {
|
|
}
|
});
|
}
|
};//获得流程信息 李雁鸣 12-25
|
|
customShow.Init = function () {
|
getProcessLog() //获得流程信息 李雁鸣 12-25
|
customShow.exCouldNumber = undefined;//初始化 云单编号 李伟民 12-22
|
customShow.orderStatus = undefined;//初始化 表单状态 李伟民 12-26
|
//数据源
|
|
//数据源信息取得
|
var datasource = $.parseJSON(window.localStorage.getItem("datasource"));
|
customShow.options.datasource = {};
|
if (datasource != null) {
|
|
for (var i = 0; i < datasource.length; i++) {
|
customShow.options.datasource[datasource[i].dataSourceName] = datasource[i];
|
};
|
}
|
|
// 0:预览 1:数据管理中新建 2:数据管理中展示(数据表示) 3:发布 4:模板中心
|
var customShowFlag = window.localStorage.getItem("customShowFlag");
|
customShow.options.customShowFlag = customShowFlag;
|
// 12/13 测试模拟用
|
|
if (customShowFlag == "0" || customShowFlag == "1") {// 新建 预览 隐藏 详情页 李伟民 11-17
|
console.log(customShowFlag);
|
// 12/4 李元杰 日历当前时间
|
// var dataObj = {
|
// "time":"yyyy-MM-dd HH:mm:ss"
|
// }
|
// var requestRight = window.commonAjax('/epc/getTime', dataObj, 'POST', true);
|
// requestRight.done(function (res) {
|
// // if (res.rspCode == "000000") {
|
// console.log(res)
|
// // }
|
// })
|
var myDate = new Date();
|
myDate.getFullYear(); //获取完整的年份(4位,1970-????)
|
myDate.getMonth(); //获取当前月份(0-11,0代表1月)
|
myDate.getDate();
|
customShow.currentDate = myDate.getFullYear() + '-' + (myDate.getMonth() + 1) + '-' + myDate.getDate();
|
console.log(new Date())
|
console.log(customShow.currentDate)
|
$("#customShow").removeClass("fui-form");
|
console.log(customBase.options.customItemShow)
|
// $(".preview-edit-pane").css("display", "none");
|
// 12/23
|
|
|
|
|
}// 新建 预览 隐藏 详情页 李伟民 11-17
|
if (customShowFlag == "2") {
|
console.log(customShowFlag);
|
//12/23
|
$(".preview-edit-pane").css("display", "block");
|
// $("#editableBtn").on("click",() => {
|
// console.log($(".preview-edit-pane"));
|
|
// })
|
}
|
if(customShowFlag == '3'){
|
$(".preview-edit-pane").css("display", "block");
|
}
|
if (customShowFlag == "0") {
|
//表单ID
|
var customlocalStorage = window.localStorage.getItem("customForm");
|
customlocalStorage = $.parseJSON(customlocalStorage);
|
customShow.options.formid = customlocalStorage.newFormID;
|
var customViewItem = window.localStorage.getItem("customViewItem");
|
|
customShow.InitShow({
|
//绑定DIV
|
showDiv: "customViewUEditor",
|
//数据来源
|
customShowFlag: customShowFlag,
|
//表示模式
|
designMode: customlocalStorage.mode,
|
//画面表示基础数据
|
customViewItem: $.parseJSON(customViewItem),
|
//画面表示数据
|
formbase: "",
|
});
|
$(".s_savebtn").hide();
|
// $(".customShow .fa-calendar").addClass();
|
} else {
|
customShow.options.formid = window.localStorage.getItem("newFormID");
|
//初期数据取得
|
customDataBound.getFormbase(customShow.options.formid, function (rs) {
|
if (rs.rspCode == "000000" && rs.data != null) {
|
//控件属性JSON对象
|
var field = JSON.parse(rs.data.fieldset);
|
//转换成数组
|
var fields = _.keysIn(field);
|
console.log(rs.data.fieldset)
|
|
//循环读取tag_Type是否含有‘auto’
|
for (var i = 0; i < fields.length; i++) {
|
var attrib = field[fields[i]];
|
if (attrib.tag_Type != null && attrib.tag_Type == 'auto') {
|
//如果有那么就发送请求
|
var dataObj = {};
|
dataObj.prefix = attrib.tag_Attribute.prefixs["0"].itemtext_1 + '$in{' + attrib.tag_Attribute.prefixs["0"].itemtext_2 + '}';
|
dataObj.FormID = formid;
|
var requestRight = window.commonAjax('/datamanagement/getGenerateRandomNumService', dataObj, 'POST', true);
|
requestRight.done(function (res) {
|
if (res.rspCode == "000000") {
|
var alisN = _.keysIn(customBase.options.customItems);
|
for (var i = 0; i < alisN.length; i++) {
|
var item = customBase.options.customItems[alisN[i]];
|
if (item.type == "auto") {
|
var itemID = item.id;
|
customBase.setItemValue(itemID, 'text', res.data, '', '');
|
}
|
}
|
}
|
})
|
|
}
|
}
|
|
var formbase = window.localStorage.getItem("customItem");
|
//console.log(formbase)
|
//////////////console.log(formbase);
|
// //console.log(formbase);
|
var customItem = {
|
formeditor: rs.data.resultForm,
|
item: $.parseJSON(rs.data.fieldset),
|
//表单宽度
|
fromwidth: rs.data.formWidth,
|
//表单高度
|
fromheigh: rs.data.formHeight,
|
//表单名
|
formName: rs.data.formName,
|
customFlag: rs.data.designMode,
|
Linkage: rs.data.linkage
|
}
|
//console.log(customItem);
|
//console.log(formbase)
|
customShow.InitShow({
|
//绑定DIV
|
showDiv: "customViewUEditor",
|
//数据来源
|
customShowFlag: customShowFlag,
|
//表示模式
|
designMode: rs.data.designMode,
|
//画面表示基础数据
|
customViewItem: customItem,
|
//画面表示数据
|
formbase: formbase,
|
});
|
} else {
|
|
}
|
});
|
}
|
//隐藏保存
|
if (publishShowflag==1){
|
$(".preview-edit-pane").hide();
|
}
|
}
|
// 12/4 李元杰 当前时间
|
customShow.currentDate = '';
|
function changeOrderStatus(orderStatus){//修改表单状态 李伟民 01-04
|
if(orderStatus == undefined){
|
return false;
|
}
|
switch(orderStatus){
|
case '10':
|
$('#stateText').html('自动审单中');
|
break
|
case '15':
|
$('#stateText').html('自动审单成功');
|
break
|
case '19':
|
$('#stateText').html('自动审单失败');
|
break
|
case '20':
|
$('#stateText').html('未上传单据');
|
break
|
case '40':
|
$('#stateText').html('记账处理中');
|
break
|
case '45':
|
$('#stateText').html('记账处理完成');
|
break
|
case '49':
|
$('#stateText').html('记账处理失败');
|
break
|
case undefined:
|
$('#stateText').html('test');
|
break
|
|
}
|
}
|
//画面初期化
|
customShow.InitShow = function (customInit) {
|
customBase.customInit = customInit;
|
//画面初期迁移源属性取得
|
// 0:预览 1:数据管理中新建 2:数据管理中展示 3:发布 4:模板中心
|
//console.log(customInit)
|
if (customInit.customViewItem != null && customInit.customViewItem != undefined) {
|
customShow.costType = customInit.customViewItem.item;
|
}
|
var customShowFlag = customInit.customShowFlag;
|
var customViewDiv = "#" + customInit.showDiv;
|
customShow.options.customInit = customInit;
|
customShow.options.customViewDiv = customInit.showDiv;
|
//画面初期化(画面表示基础数据)
|
customShow.options.customItemShow = customInit.customViewItem;
|
customShow.options.jsonLinkage = customShow.options.customItemShow.Linkage;
|
var customItem = customShow.options.customItemShow;
|
setTimeout(function () {
|
if (customShowFlag == "4") {
|
$(".customViewUEditorCss").css("height", window.innerHeight);
|
$(".customShow").css("height", window.innerHeight - 200);
|
} else {
|
$(".customViewUEditorCss").css("height", window.innerHeight - 200);
|
$(".customShow").css("height", window.innerHeight - 200);
|
}
|
}, 10);
|
var btns = [];
|
//展示数据表示
|
|
if (customShowFlag == "0" || customShowFlag == "6") {
|
//2017-12-27 马习同 专家模式打印
|
var print_btnFlag = window.localStorage.getItem("print_btnFlag");
|
if (customShowFlag == "0" && print_btnFlag == "1"){
|
var btns = [
|
"printableBtn"
|
];
|
customShow.setToolBtn(btns);
|
}
|
////console.log(window.customBase);
|
//标题头表示
|
$('#childclick').css("display", "none");
|
$(".header")[0].style.display = "block";
|
//标题设定
|
$(".modal-title")[0].innerHTML = customItem.formName;
|
|
//画面内容的初始化设定
|
customShow.setContentHtml(customItem, customViewDiv);
|
//编辑模式下表示
|
$(customViewDiv)[0].style.display = "block";
|
|
//1:数据管理中新建 3:发布 4:模板中心
|
} else if (customShowFlag == "1" || customShowFlag == "3") {
|
//标题头表示
|
console.log("显示X");
|
console.log($('#childclick'));
|
$('#childclick').css("display", "block");
|
$('#childclick').click(() => {
|
customShow.onclickCancel();
|
console.log("点击父元素关闭");
|
});
|
|
$(".header")[0].style.display = "block";
|
$("title")[0].innerHTML = customItem.formName;
|
//标题设定
|
$(".modal-title")[0].innerHTML = customItem.formName;$(".modal-title")[0].innerHTML = customItem.formName;
|
//画面内容的初始化设定
|
customShow.setContentHtml(customItem, customViewDiv);
|
|
// $(".footer")[0].style.display ="block";
|
//编辑模式下表示
|
$(customViewDiv)[0].style.display = "block";
|
//2:数据管理中展示
|
//第三方事件绑定
|
// customShow.setEventBind();
|
if (customShowFlag == "1") {
|
var btns = [
|
'rejectBtn',
|
'submitBtn',
|
'auditableBtn',
|
'queryBtn',
|
'clearBtn',
|
// 'disposableBtn',
|
// 'fromSaveBtn',
|
];
|
} else {
|
var btns = [
|
'rejectBtn',
|
'submitBtn',
|
'auditableBtn',
|
'queryBtn',
|
'createBtn',
|
// 'clearBtn',
|
// 'disposableBtn',
|
//'fromSaveBtn',
|
];
|
}
|
}
|
else if (customShowFlag == "4") {
|
//标题头表示
|
$(".header")[0].style.display = "none";
|
//标题设定
|
// $(".modal-title")[0].innerHTML=customItem.formName;
|
//画面内容的初始化设定
|
customShow.setContentHtml(customItem, customViewDiv);
|
//编辑模式下表示
|
$(customViewDiv)[0].style.display = "block";
|
// $(".footer")[0].style.display ="none";
|
//编辑模式下表示
|
// $(customViewDiv)[0].style.display ="block";
|
//第三方事件绑定
|
// customShow.setEventBind();
|
} else if (customShowFlag == "2") {
|
console.log("显示X");
|
console.log($('#childclick'));
|
$('#childclick').css("display", "block");
|
if (JSON.parse(window.localStorage.getItem('allow')) == true) {
|
$('#childclick').css("display", "none");
|
} else {
|
$('#childclick').css("display", "block");
|
}
|
$('#childclick').click(() => {
|
customShow.onclickCancel();
|
console.log("点击父元素关闭");
|
|
});
|
//按钮修改 马习同 2017-12-13
|
// var btnshowFlag = {
|
// a = true,
|
// b = flase,
|
// };
|
// if(btnshowFlag.a == true){
|
// btns.push();
|
// }
|
var btns = [
|
// 'checkbillBtn',//查看票据
|
'rejectBtn',//驳回
|
'submitBtn',//提交
|
'auditableBtn',//审批
|
'editableBtn',
|
'printableBtn',//打印
|
];
|
//画面内容的初始化设定
|
console.log(customItem);
|
console.log(customViewDiv);
|
customShow.setContentHtml(customItem, customViewDiv);
|
var items = {};
|
//数据变换
|
//console.log(customInit);
|
//console.log(customInit.formbase)
|
var formbase = $.parseJSON(customInit.formbase);
|
//console.log(formbase);
|
customShow.options.dataRowNum = formbase['DATAROWNUM'];
|
customShow.exCouldNumber = formbase['orderCode'];//获取云单编号 李伟民 12-26
|
if(customShow.exCouldNumber){
|
$('#exCloudNumberText').html('云单编号:' + customShow.exCouldNumber);
|
}
|
customShow.orderStatus = formbase['orderStatus'];// 获取表单状态 李伟民 12-26
|
changeOrderStatus(customShow.orderStatus);
|
items = formbase;
|
customShow.options.itemFormbase = formbase;
|
console.log(_.cloneDeep(items));
|
delete items['DATAROWNUM'];
|
console.log(_.cloneDeep(items));
|
//初期化后,数据赋值(编辑模式)
|
console.log(_.cloneDeep(items));
|
customShow.showCustom(items, customShow.options.customInit);
|
//初期化后,数据赋值(预览)
|
console.log(_.cloneDeep(items));
|
customShow.setShowCustomItem(items);
|
//初期化后,票据信息追加 李伟民 12-26
|
SC.billInfoInit(items);
|
|
|
//数据源再次追加
|
// var customItems = customShow.options.customItemShow.item;
|
var customItems = customBase.options.customItems;
|
console.log(customItems);
|
for (item in customItems) {
|
if (customItems.hasOwnProperty(item)) {
|
if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
|
customItems[item].type == 'checkbox' || customItems[item].type == 'tree') {
|
var datasourcetype = customShow.options.customItemShow.item[customItems[item].id].tag_Attribute.datasourcetype;
|
console.log(datasourcetype);
|
if (datasourcetype == "custom") {
|
//数据源绑定(自定义数据)
|
customShow.setDatasourceData(customItems[item]);
|
}
|
}
|
}
|
}
|
//标题头表示
|
$(".header")[0].style.display = "block";
|
//标题设定
|
$(".modal-title")[0].innerHTML = customItem.formName;
|
// 12/19
|
$("#customViewUEditor")[0].style.display = "none";
|
//2017/11/18 马习同修改 隐藏预览模式下 导入数据按钮
|
$(".sonImportFile").addClass("cfg_contentNone");
|
$(".s_savebtn").hide();
|
$(".customShow .fa-calendar").addClass("cfg_contentNone");
|
|
console.log($(".customShow .tdContentClass"))
|
// _.each($(".customShow .tdContentClass"),opt=>{
|
// // $(opt).attr("title", $(opt).children().children().html());
|
// console.log($(opt).html())
|
// if ($(opt).children().children().attr("type") == "text"){
|
// $(opt).attr("title", $(opt).children().children().val());
|
// }else{
|
// console.log(_.cloneDeep($(opt).children().children()))
|
// console.log(opt.innerHTML)
|
// console.log($(opt).children().children()[0].innerHTML)
|
// $(opt).attr("title", $(opt).children().children()[0].innerHTML);
|
// }
|
// })
|
|
}
|
//第三方事件绑定
|
var token = localStorage.getItem('token');//页面事件绑定 李伟民 12-22
|
if (token != '' && token != undefined) {
|
token = JSON.parse(token);
|
}
|
var postdata = { 'formID': customShow.options.formid };
|
_.extend(postdata, token);
|
var eventBindRquest = window.commonAjax('/formevent/getFormEventListService', postdata, 'GET', true, false);
|
eventBindRquest.done(function (res) {
|
if (res.data != undefined) {
|
// var eventBindData = [];
|
// _.each(res.data,function(data){
|
// eventBindData.push({'fieldName':data.fieldName,'tag':data.fieldType,'eventName':data.event,'functionName':data.eventmethod});
|
// });
|
customShow.initEvent.eventBind = res.data;
|
}
|
customShow.setEventBind();
|
});//页面事件绑定 李伟民 12-22
|
|
SC.showUser()//报销人根据当前登录人自动带出 李伟民 0108
|
|
customShow.setToolBtn(btns);
|
$(".select2-selection").remove();
|
customShow.hidesubform();
|
var unvisible = customBase.options.customItems;
|
for (item in unvisible) {
|
if (unvisible[item].type == "subform") {
|
var itemId = unvisible[item].id;
|
// var itemTwo = itemId;
|
// var itemSubform = $('.'+"customViewUEditorCss" +" #"+itemId+"ActiveId");
|
////////////console.log(item);
|
//子表单删除第一条可添加 2017/10/26 马习同
|
// var divIcon = $('<div id="'+itemId+'save" class="cfg_contentNone"></div>');
|
var cloneE = $('#' + itemId + 'subformTr').clone();
|
// divIcon.append(cloneE);
|
console.log(cloneE);
|
// itemSubform.append(divIcon);
|
customBase.options.customItems[item]['cloneDiv'] = cloneE;
|
}
|
}
|
//2017-12-12 马习同隐藏
|
SC.Superior_hide();
|
if (customShowFlag == "1" || customShowFlag == "0") {
|
// window.localStorage.setItem('businessTypeAuto','240');
|
$(".preview-edit-pane").find('#disposableBtn').css('display', 'none');
|
$(".preview-edit-pane").find('#clearBtn').css('display', 'none');
|
$(".preview-edit-pane").find('#queryBtn').css('display', 'none');
|
$(".preview-edit-pane").find('#auditableBtn').css('display', 'none');
|
$(".preview-edit-pane").find('#submitBtn').css('display', 'none');
|
$(".preview-edit-pane").find('#rejectBtn').css('display', 'none');
|
}
|
}
|
// 2017/10/20 李元杰 抽出了 李伟民的计算费用的方法 最后将数据return出去了
|
//计算费用
|
//customShow.queryCostAllData = function(){
|
// var post_data = [];
|
// var items = customShow.getItems();
|
// var items_key = _.keysIn(items);
|
// var all_data = {};
|
// //console.log(items);
|
// _.each(items_key,function(item){
|
// var control = {};
|
// var item_attr = customBase.options.customItems[item];
|
// if(_.isArray(items[item]) && _.isObject(items[item][0])){//判断是否为子表单
|
// _.extend(control,{'fieldKey':item,'mdCode':'','value':'','type':item_attr.type,'child':[]});
|
// _.each(items[item],function(cd){
|
// var cd_key = _.keysIn(cd);
|
// var item_cd = {
|
// "items":[],
|
// "cid":""
|
// };
|
// _.each(cd_key,function(cdk){
|
// var control_cd = {};
|
// var item_attr_cd = customBase.options.customItems[cdk];
|
// _.extend(control_cd,{'fieldKey':cdk,'mdCode':customShow.getmasterdataById(item_attr_cd.id),'value':cd[cdk],'type':item_attr_cd.type});
|
// item_cd.items.push(control_cd);
|
// if(cdk == "dataRowNum"){
|
// item_cd.cid = cd[cdk];
|
// }
|
// });
|
// control.child.push(item_cd);
|
// });
|
// //行程ID 预留
|
// }else{
|
// _.extend(control,{'fieldKey':item,'mdCode':customShow.getmasterdataById(item_attr.id),'value':items[item],'type':item_attr.type});
|
// }
|
// post_data.push(control);
|
// });
|
// var customShowFlag = window.localStorage.getItem("customShowFlag");
|
// var customForm = window.localStorage.getItem("customForm");
|
// if(customForm && customForm != ""){
|
// customForm = JSON.parse(customForm);
|
// }
|
// if(customShowFlag == 2){//详情
|
// var customItem = window.localStorage.getItem("customItem");
|
// if(customItem && customItem != ""){
|
// customItem = JSON.parse(customItem);
|
// //console.log(customItem);
|
// }
|
// _.extend(all_data,{"data":post_data,"formId":customForm.newFormID,"id":customItem.DATAROWNUM});
|
// }else{//新建或预览
|
// _.extend(all_data,{'data':post_data,"formId":customForm.newFormID,"id":""});
|
// }
|
// _.extend(all_data,{'orderCode':""});
|
// _.extend(all_data,{'ctId':"240"});// 费用类型 假
|
// return all_data;
|
//}
|
//计算费用
|
//customShow.queryCost = function(){
|
// // 2017/10/20 李元杰 queryCostAllData 抽出来存这里了
|
// // var post_data = [];
|
// // var items = customShow.getItems();
|
// // var items_key = _.keysIn(items);
|
// // var all_data = {};
|
// // //console.log(items);
|
// // //console.log(items_key)
|
// // _.each(items_key,function(item){
|
// // var control = {};
|
// // //console.log(item);
|
// // var item_attr = customBase.options.customItems[item];
|
// // //console.log(item_attr)
|
// // if(_.isArray(items[item]) && _.isObject(items[item][0])){//判断是否为子表单
|
// // _.extend(control,{'fieldKey':item,'mdCode':'','value':'','type':item_attr.type,'child':[]});
|
// // _.each(items[item],function(cd){
|
// // //console.log(cd)
|
// // var cd_key = _.keysIn(cd);
|
// // //console.log(cd_key)
|
// // var item_cd = {
|
// // "items":[],
|
// // "cid":""
|
// // };
|
// // _.each(cd_key,function(cdk){
|
// // var control_cd = {};
|
// // var item_attr_cd = customBase.options.customItems[cdk];
|
// // //console.log(item_attr_cd);
|
// // _.extend(control_cd,{'fieldKey':cdk,'mdCode':customShow.getmasterdataById(item_attr_cd.id),'value':cd[cdk],'type':item_attr_cd.type});
|
// // item_cd.items.push(control_cd);
|
// // if(cdk == "dataRowNum"){
|
// // item_cd.cid = cd[cdk];
|
// // }
|
// // });
|
// // control.child.push(item_cd);
|
// // });
|
// // //行程ID 预留
|
// // }else{
|
// // _.extend(control,{'fieldKey':item,'mdCode':customShow.getmasterdataById(item_attr.id),'value':items[item],'type':item_attr.type});
|
// // }
|
// // post_data.push(control);
|
// // });
|
// // var customShowFlag = window.localStorage.getItem("customShowFlag");
|
// // var customForm = window.localStorage.getItem("customForm");
|
// // if(customForm && customForm != ""){
|
// // customForm = JSON.parse(customForm);
|
// // }
|
// // if(customShowFlag == 2){//详情
|
// // var customItem = window.localStorage.getItem("customItem");
|
// // if(customItem && customItem != ""){
|
// // customItem = JSON.parse(customItem);
|
// // //console.log(customItem);
|
// // }
|
// // _.extend(all_data,{"data":post_data,"formId":customForm.newFormID,"id":customItem.DATAROWNUM});
|
// // }else{//新建或预览
|
// // _.extend(all_data,{'data':post_data,"formId":customForm.newFormID,"id":""});
|
// // }
|
// // _.extend(all_data,{'orderCode':""});
|
// // _.extend(all_data,{'ctId':"240"});// 费用类型 假
|
// // //console.log(all_data);
|
// // //console.log(JSON.stringify(all_data))
|
// var all_data = customShow.queryCostAllData();
|
// // 2017/10/20 李元杰 queryCostAllData 抽出来存这里了 end
|
// var query_request = window.queryAjax("epc-count/countCost",all_data,"POST",true,false);
|
// ////console.log(query_request);
|
// query_request.done(function(res){
|
// ////console.log("6531289");
|
// customBase.listen_check(res.data,"query_check");
|
// })
|
//
|
// return all_data;
|
//}
|
// 12/12 模态框
|
$('.closeBtn').on('click', () => {
|
$('.maskLayer').css('display', 'none');
|
customShow.clean();
|
})
|
//扩展费用自定义方法,yuezhw 2017-11-13
|
customShow.extended_budget = function (where) {
|
var obj = {};
|
obj.formId = localStorage.getItem("newFormID");
|
obj.dataId = JSON.parse(localStorage.getItem("customItem")).DATAROWNUM;
|
obj.tenantID = JSON.parse(localStorage.getItem("tenantID")).tenantID;
|
var query_request;
|
flatpickr("#budget_time", {
|
dateFormat: "Y-m-d"
|
})
|
|
var budgetNumber = $('#customShow').find('div[type="auto"]').find('input').val();
|
var budgetDate = $($('#customShow').find('div[type="calendar"]')[1]).find('input').val();
|
$('#budget_number').val(budgetNumber)
|
$('#budget_date').val(budgetDate)
|
$('#extended_someThing').css("display", "block");
|
$('#budget_time').css("display", "block");
|
$('.maskLayer').css('display', 'block');
|
$('#budget_todo').on('click', () => {
|
obj.department = $('#budget_department').val();
|
obj.info = $('#budget_time').val();
|
var nowTime = new Date(Date.parse(obj.info));
|
var endTime = new Date(Date.parse(JSON.parse(localStorage.getItem("customItem")).budgetEndDate));
|
console.log(obj.info);
|
console.log(nowTime);
|
console.log(endTime);
|
if (obj.info.length < 1) {
|
alert("请输入增加时间");
|
} else if (nowTime < endTime) {
|
alert("扩展时间不可小于当前结束时间!");
|
} else {
|
var query_request = window.queryAjaxQQ("epc-form/extend/budget/time", obj, "POST", true, false);
|
query_request.done(function (res) {
|
console.log(typeof res.data)
|
console.log(res.data)
|
if (res.data === true) {
|
alert("扩展时间成功!");
|
customShow.clean();
|
$('.maskLayer').css('display', 'none');
|
} else {
|
alert("服务器通信失败");
|
}
|
})
|
query_request.error(function (rs) {
|
// console.log(rs)
|
toastr.error(rs.responseJSON.rspDesc);
|
|
})
|
}
|
|
})
|
$('#budget_undo,.closeModal').on('click', () => {
|
customShow.clean();
|
})
|
}
|
//关闭页面
|
customShow.clean = function () {
|
$('#extended_someThing').css("display", "none");
|
$('#budget_whrere').val('');
|
$('#budget_money').val('');
|
$('#budget_time').val('');
|
}
|
//根据别名获取主数据
|
customShow.getmasterdataById = function (itemid) {
|
var mdata = undefined;
|
////console.log(itemid);
|
if (customShow.options.customItemShow.item[itemid] != undefined) {
|
if (customShow.options.customItemShow.item[itemid].tag_Attribute.masterData != undefined && customShow.options.customItemShow.item[itemid].tag_Attribute.masterData != '') {
|
mdata = JSON.parse(customShow.options.customItemShow.item[itemid].tag_Attribute.masterData);
|
}
|
}
|
if (mdata != undefined) {
|
return mdata.defindCode;
|
} else {
|
return "";
|
}
|
}
|
|
//数据赋值 ----编辑项目赋值
|
customShow.setShowCustomItem = function (items) {
|
// 2017/10/19 李元杰 在费用明细里插入一些信息
|
// 需要传给后端的对象
|
//console.log(items);
|
// var objData = customShow.queryCostAllData();
|
// 获取orderCode的值
|
|
// if(objData.orderCode){
|
// var orderCode = customBase.getItemValue(customBase.options.customItems.orderCode.id,customBase.options.customItems.orderCode.type)
|
// objData.orderCode = orderCode[1];
|
// var requestInsert = window.commonAjax("/datamanagement/getAssociatedFormDataService", objData, "POST", true);
|
// requestInsert.done(function (res) {
|
// for(var i = 0 ; i <res.data.data.length;i++){
|
// if(res.data.data[i].child){
|
// for(var j = 0;j<res.data.data[i].child.length;j++){
|
// // 循环子表单里拥有dataRowNum的数量
|
// $(`[id= ${customBase.options.customItems.dataRowNum.id}]`).each( (index,ipt)=>{
|
// // 获取返回值里的value和子表单里的dataRowNum的值是否相同
|
// if( res.data.data[i].child[j].msgInfo.header[0].value == $(ipt).val()){
|
// // 寻找当前子表单的父节点里的H8标签插入数据
|
// $($(`[id= ${customBase.options.customItems.dataRowNum.id}]`)[index].closest('[type=subform]')).children('h8').find('.text')
|
// .append(` <span>${res.data.data[i].child[j].msgInfo.header[0].name}</span>`)
|
// }
|
// })
|
// }
|
// }
|
// }
|
// });
|
// }
|
//delete items['DATAROWNUM']; // 子表单中 不删除datarownum 李伟民 11-16
|
var items = _.cloneDeep(items);
|
var customItems = customBase.options.customItems;
|
//console.log(customItems);
|
//数据值变换
|
for (item in items) {
|
if (items.hasOwnProperty(item)) {
|
if (customItems[item] == undefined) {
|
delete customItems[item];
|
continue;
|
}
|
if (customItems[item].type == 'subform' || customItems[item].type == 'tag' || customItems[item].type == 'tab') {
|
var subformTemp = items[item];
|
console.log(subformTemp)
|
if (subformTemp == undefined) {
|
subformTemp = [{}];
|
}
|
for (subformItem in subformTemp[0]) {
|
if (subformTemp[0].hasOwnProperty(subformItem)) {
|
items[subformItem] = [];
|
}
|
}
|
console.log(subformTemp.length);//主数据丢失
|
for (var i = 0; i < subformTemp.length; i++) {
|
if (i != 0) {
|
//子表单项目追加
|
var subformAdd = $(".customViewUEditorCss #" + customItems[item].id + "ActiveId .subformAdd")[0];
|
customShow.addsubformList(subformAdd, "customViewUEditorCss");
|
}
|
for (subformItem in subformTemp[i]) {
|
if (subformTemp[i].hasOwnProperty(subformItem)) {
|
items[subformItem][i] = subformTemp[i][subformItem];
|
}
|
}
|
};
|
}
|
}
|
}
|
|
//delete items['DATAROWNUM']; // 子表单中 不删除datarownum 李伟民 11-16
|
console.log(_.cloneDeep(items))
|
console.log(customItems);
|
//数据赋值
|
for (item in items) {
|
console.log(item);
|
if (items.hasOwnProperty(item)) {
|
if (customItems[item] == undefined) {
|
delete customItems[item];
|
continue;
|
}
|
var type = customItems[item].type;
|
var id = customItems[item].id;
|
console.log(id);
|
console.log(items[item]);
|
if (
|
// type == 'radio' || type == 'checkbox' ||
|
// type == 'dropdownlist'||
|
// type == 'tree'||
|
// type == 'amount'||
|
// type == 'barcode'||
|
// type == 'qrcode' ||
|
// type == 'image'||
|
type == 'button'
|
// || type == 'fileupload'
|
|| type == 'subform' || type == 'link'
|
|| type == 'splitline' || type == 'link' || type == 'tag' || type == 'tab'
|
) {
|
|
} else if (customItems[item].type == "image" || customItems[item].type == "fileupload") {
|
var itemId = customItems[item].id;
|
if (items[item] != "") {
|
customBase.options.uploaderItemReady[itemId] = $.parseJSON(items[item]);
|
} else {
|
customBase.options.uploaderItemReady[itemId] = [];
|
}
|
} else if (type == 'amount') {
|
var id = id + "amount";
|
customBase.setItemValue(id, 'text', items[item], 'customViewUEditorCss');
|
$("#" + id).blur();
|
} else if (type == 'qrcode') {
|
var id = id + "qrcode";
|
customBase.setItemValue(id, 'text', items[item], 'customViewUEditorCss');
|
$("#" + id).blur();
|
} else if (type == 'barcode') {
|
var id = id + "barcode";
|
customBase.setItemValue(id, 'text', items[item], 'customViewUEditorCss');
|
$("#" + id).blur();
|
} else if (type == 'dropdownlist' || type == 'radio' || type == 'checkbox' || type == 'tree') {
|
//异步加载时数据临时保存
|
customShow.options.initTempDatas[id] = items[item];
|
// var datasourcetype = $("#"+id)[0].getAttribute("datasourcetype");
|
// //主数据源
|
// if(datasourcetype == "masterdata"){
|
// customBase.setItemValue(id,type,items[item],'customViewUEditorCss');
|
// //数据源
|
// }else if(datasourcetype == "datasource"){
|
// customBase.setItemValue(id,type,items[item],'customViewUEditorCss');
|
// //自定义
|
// }else if(datasourcetype == "custom"){
|
// customBase.setItemValue(id,'dropdownlistText',items[item],'customViewUEditorCss');
|
// //API接口
|
// }else if(datasourcetype == "api"){
|
// customBase.setItemValue(id,type,items[item],'customViewUEditorCss');
|
// }
|
|
} else if (customItems[item].type == 'mytext') {
|
//选择表单预览回显
|
var itemAttribute = customShow.options.customItemShow.item[customItems[item].id];
|
var item_title = [];
|
var itemVal = [];
|
var $mytext = $("#customShow " + "#" + customItems[item].id + "ActiveId");
|
if (itemAttribute.tag_Attribute.relevancesourcetype == "fundata") {// 关联数据回显渲染 李伟民 11-30
|
var titleObj = { "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"] };
|
var dataObj = {
|
"formID": customShow.options.formid,
|
"tenantID": "001",
|
"search": [],
|
"pageSize": "1000",
|
"pageNum": "1",
|
"key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"],
|
"formData": {},
|
"dataRowNum": items[item]
|
};
|
var requesTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
|
var requesData = window.commonAjax("/datamanagement/getAssociateData", dataObj, "POST", true, false);
|
requesTitle.done(function (res) {
|
console.log(res);
|
item_title = res.data;
|
});
|
requesData.done(function (res) {
|
console.log(res);
|
if (!_.isNull(res.data) && res.data != undefined) {
|
itemVal = res.data;
|
}
|
});
|
} else {
|
var myTitle = JSON.parse(window.localStorage.getItem("title"));
|
item_title = myTitle[item];
|
itemVal = items[item];
|
}
|
console.log(myTitle);
|
console.log(itemVal)
|
console.log(item_title);
|
console.log(itemVal.list);
|
var iconID = "customShow #" + customItems[item].id + "ActiveId";// 关联数据回显渲染 李伟民 11-30
|
createMxtTable(iconID, item_title, itemVal.list);// 关联数据回显渲染 李伟民 11-30
|
// var newData = [];
|
// _.each(itemVal.list,function(opt){
|
// opt = _.mapKeys(opt,function(value,key){
|
// _.each(item_title,function(item){
|
// if(key == item.fieldKey){
|
// key = item.title;
|
// }
|
// })
|
// return key;
|
// })
|
// console.log(_.cloneDeep(opt))
|
// newData.push(opt);
|
// })
|
// console.log(itemVal.list);
|
// console.log(newData);
|
//// var $value = newData;
|
// var show = "";
|
// var divBox = $("<div></div>");
|
// divBox.attr('id',customItems[item].id+'divBox');
|
// //console.log($value)
|
// var sdata_head = "";
|
// _.each($value,(opt,j)=>{
|
// //console.log(opt);
|
// var ulBox = $("<ul></ul>");
|
// for(let i in opt){
|
// show = "";
|
// sdata_head = '<td class="data1 '+i+'">'+i+'</td>';
|
// show += '<li>'+'<span class="data1 '+i+'">'+i+'</span>'+'<span class="data2 '+i+'">'+opt[i]+'</span>'+'</li>';
|
// ulBox.attr("class","addUl ulBox"+j);
|
// ulBox.attr("id","ulBox"+j);
|
// //console.log(show)
|
// ulBox.append(show);
|
// }
|
// console.log(sdata_head);
|
// divBox.append(ulBox);
|
// });
|
// $mytext.append(divBox);
|
} else {
|
//值设定
|
customBase.setItemValue(id, type, items[item], 'customViewUEditorCss');
|
//异步加载时数据临时保存
|
customShow.options.initTempDatas[id] = items[item];
|
}
|
}
|
};
|
//赋值后绑定票据信息
|
}
|
// 定义云账房方法 10/17
|
var orderid = "";
|
function getepc() {
|
window.queryAjaxsd("epc/epc-form/getOrderCode", {}, "POST", true).done(function (res) {
|
//console.log("云账房id");
|
//console.log(res);
|
if (res.data != undefined) {
|
orderid = res.data.orderCode;
|
setepc(orderid);
|
}
|
|
})
|
}
|
function setepc(orderid) {
|
//console.log(orderid);
|
//console.log(customBase);
|
//console.log(window.customShow);
|
if (customBase.options.customItems.orderCode != undefined) {
|
var id = customBase.options.customItems.orderCode.id;
|
var type = customBase.options.customItems.orderCode.type;
|
//console.log(id);
|
//console.log(type);
|
|
customBase.setItemValue(id, type, orderid);
|
}
|
}
|
|
function getCookie(name) {
|
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
|
if (arr = document.cookie.match(reg))
|
return unescape(arr[2]);
|
else
|
return null;
|
}
|
|
customShow.uploadBill = function () {//票据上传
|
$('#upload_iframe').show();
|
var token = localStorage.getItem(token);
|
if (token != '' && token != undefined) {
|
token = JSON.parse(token).accessToken;
|
}
|
var compid = getCookie('companyId');
|
var tenantId = localStorage.getItem("tenantID");
|
// var iframe_src = "http://csza.chfcloud.com/views/order_create_visit.html?token=" + token + "&compid=" + compid +"&tenantId=" + tenantId;
|
var iframe_src = "http://csza.chfcloud.com/views/order_create_visit.html?token=" + localStorage.getItem("testToken") + "&compid=" + localStorage.getItem("testCompanyId") +"&tenantId=" + localStorage.getItem("testTenantId");
|
//var iframe_src = "http://csza.chfcloud.com/views/order_create_visit.html?token=a23efb1df2303a914b1139d4e1d1859f&compid=66&tenantId=13";
|
$("#upload_iframe").append("<iframe id='uploadBill' style='width:100%;overflow: auto;'></iframe>");
|
////console.log($("body"));
|
var thisHeight = $("body").height();
|
////console.log(thisHeight);
|
$('#upload_iframe').height(thisHeight);
|
$('#uploadBill').height(thisHeight);
|
$('#uploadBill').attr("src", iframe_src);
|
window.addEventListener("message", customShow.getExCouldNumber);
|
$("#upload_iframe .right").on("click", function () {
|
customShow.uploadBillClose();
|
});
|
|
}
|
|
customShow.getExCouldNumber = function (event) {
|
if (event && event.data && event.data.indexOf('csc_OrderCode=') != -1) {
|
var exCouldNumber = event.data.split('=')[1];
|
console.log(exCouldNumber);
|
customShow.exCouldNumber = exCouldNumber;
|
if(localStorage.getItem('customShowFlag') == 2){//详情页上传票据需将云单编号传给后台 李伟民 01-04
|
var orderData = {
|
"formId":customShow.options.formid,
|
"formDataId":localStorage.getItem("datarowNum"),
|
"orderCode":exCouldNumber
|
}
|
var orderUpdate = window.cloudAjax("epc-form/formData/updataBillInfoAndForm",orderData,"POST",true);
|
orderUpdate.done(function(res){
|
if(res.rspCode == '000000'){
|
changeOrderStatus('10');
|
customShow.uploadBillClose();
|
}
|
});
|
}else{
|
customShow.uploadBillClose();
|
}
|
}
|
}
|
|
customShow.uploadBillClose = function () {
|
$('#uploadBill').remove();
|
$('#upload_iframe').hide();
|
window.removeEventListener("message", customShow.getExCouldNumber);
|
$('.bill_upload').hide();
|
// getepc();
|
}//画面初期编辑内容设定
|
customShow.setContentHtml = function (customItem, customViewDiv) {
|
|
//按钮状态编辑 btnFlag:{editable:"1",printable:"1",auditable:"1",disposable:"1"} //按钮表示
|
var btnFlag = customShow.options.btnFlag;
|
if (btnFlag.editable != "0") {
|
$("#editableBtn").removeClass("cfg_contentNone");
|
}
|
if (btnFlag.printable != "0") {
|
$("#printableBtn").removeClass("cfg_contentNone");
|
}
|
if (btnFlag.auditable != "0") {
|
$("#auditableBtn").removeClass("cfg_contentNone");
|
}
|
if (btnFlag.disposable != "0") {
|
$("#disposableBtn").removeClass("cfg_contentNone");
|
}
|
|
var div = document.createElement("div");
|
div.innerHTML = customItem.formeditor;
|
if (customShow.options.customInit.designMode == "1") {
|
div.setAttribute("class", "divshow divshowEditor");
|
|
if (customShow.options.customShowFlag != "4") {
|
$(div).css("height", customItem.fromheigh);
|
$(div).css("width", "100%");
|
// $(customViewDiv).css("height",customItem.fromheigh);
|
// $(customViewDiv).css("width",customItem.fromwidth);
|
console.log(1);
|
}
|
|
} else {
|
div.setAttribute("class", "divshow divshowNoEditor");
|
// $(div)[0].style.height = window.innerHeight-140 + "px";
|
// if(customShow.options.customShowFlag =="0"){
|
// $(div)[0].style.width ='98%';
|
// }else{
|
// $(div)[0].style.width ='100%';
|
// }
|
|
// $(div)[0].style.overflowY ='auto';
|
$(div)[0].style.width = '100%';
|
$(div)[0].style.height = '100%';
|
|
$(div).css("display", "flex");
|
$(div).css("justify-content", "flex-start");
|
$(div).css("flex-wrap", "wrap");
|
}
|
$(customViewDiv).prepend(div);
|
|
//基本信息List取得
|
customBase.options.customItems = customShow.getItemsList();
|
console.log(customShow.getItemsList())
|
console.log(customShow.options.customItemShow.item)
|
|
//接口绑定
|
interfaceBind = customShow.initEvent.interfaceBind;
|
for (var i = 0; i < interfaceBind.length; i++) {
|
if(window[interfaceBind[i].customInterfacemethod] != undefined){
|
customShow.initEvent[interfaceBind[i].interfacemethod] = eval(interfaceBind[i].customInterfacemethod);
|
}
|
};
|
|
// //事件绑定
|
// eventBind = customShow.initEvent.eventBind;
|
// //02事件绑定:字段别名 字段类型 事件名 自定义事件名
|
// for (var i = 0; i < eventBind.length; i++) {
|
// // 自定义事件名
|
// var setfunction = eval(eventBind[i].eventmethod);
|
// // 事件名
|
// var eventName = eventBind[i].event;
|
// // 字段类型
|
// // var tag = eventBind.tag; //------------类型绑定-------------
|
// // 字段别名
|
// var fieldKey = eventBind[i].fieldName;
|
// // 取得控件ID
|
// var itemId = customBase.getfieldKeyFoItemId(fieldKey); //---------------------------
|
// //事件绑定
|
// $("#"+itemId).on(eventName, setfunction);
|
// };
|
// //-------------------------主数据取得------------------------------
|
//-------------------------数据源取得------------------------------
|
//-------------------------API取得data-----------------------------
|
|
//画面初期化
|
customShow.initEvent.interfaceInit(customShow.options.customShowFlag);
|
console.log(customShow.options.customItemShow.item);
|
//第三方初始化
|
|
customShow.initEvent.interfaceInit3rd();
|
|
//密码输入----------------
|
customShow.initEvent.passwordInputFlag();
|
//tree控件 by kill
|
// 2017/11/4 李元杰 在点击预览的时候树的按钮
|
customShow.treeWinShow();
|
|
}
|
//2017/11/2 李元杰 单选树 树的显示
|
|
$('.customViewUEditorCss').on('click', '.citySel,.menuBtn', function () {
|
debugger
|
// 树里存在数据时
|
if ($(this).parents('div[name="TreeWin"]').find('.ztree').children('li').length > 0) {
|
// 12/16 李元杰
|
$('div.drop_down_sel').remove();
|
var fieldKey = $(this).parents('div[name="TreeWin"]').find('.zTreeDemoBackground').attr('fieldkey');
|
$('.zTreeDemoBackground').css("display", "none");
|
$(".search_input").css("display", "none");
|
if (customBase.options.customItems[fieldKey].editable) {
|
if (event.target.className == 'defaultHeight citySel' || event.target.className == 'defaultHeight citySel') {
|
var ztree = $(this).parents('div[name="TreeWin"]').find('.ztree')
|
for (var i = 0; i < ztree.length; i++) {
|
var treeObj = $.fn.zTree.getZTreeObj($(ztree[i]).attr('id'));
|
if (!_.isNull(treeObj)) {
|
treeObj.expandAll(true);
|
}
|
}
|
}
|
$(this).parents('div[name="TreeWin"]').find('div[name="treeWinTitle"]').find('.search_input').css("display", "block");
|
$(this).parents('div[name="TreeWin"]').find('.zTreeDemoBackground').show();
|
// 12/16 end
|
}
|
$('.customViewUEditorCss').off('click.tree').on('click.tree', function () {
|
console.log(1);
|
console.log($('div.drop_down_sel'))
|
$('div.drop_down_sel').remove();
|
$('.zTreeDemoBackground').css("display", "none");
|
$(".search_input").css("display", "none");
|
|
});
|
|
$('div.TreeWin').off('click.tree').on('click.tree', function (event) {
|
// 展开树 12/4
|
console.log($(this))
|
$('div.drop_down_sel').remove();
|
var fieldKey = $(this).find('.zTreeDemoBackground').attr('fieldkey');
|
$('.zTreeDemoBackground').css("display", "none");
|
$(".search_input").css("display", "none");
|
if (customBase.options.customItems[fieldKey].editable) {
|
if (event.target.className == 'defaultHeight citySel' || event.target.className == 'defaultHeight citySel') {
|
var ztree = $(this).find('.ztree')
|
for (var i = 0; i < ztree.length; i++) {
|
var treeObj = $.fn.zTree.getZTreeObj($(ztree[i]).attr('id'));
|
if (!_.isNull(treeObj)) {
|
treeObj.expandAll(true);
|
}
|
}
|
}
|
|
$(this).find('div[name="treeWinTitle"]').find('.search_input').css("display", "block");
|
$(this).find('.zTreeDemoBackground').show();
|
}
|
event.stopPropagation();
|
});
|
|
}
|
})
|
//this function by kill
|
customShow.treeWinShow = function () {
|
// $('body').append('<div id="occlusion"></div>')
|
// occlusionCss={
|
// background: 'white',
|
// filter: 'alpha(opacity=100)',
|
// opacity: '1',
|
// display: 'none',
|
// position: 'absolute',
|
// top: '0px',
|
// left: '0px',
|
// width: '100%',
|
// height: '100%',
|
// display:'none',
|
// "z-index":"99998",
|
// display:"none",
|
// height:'100%',
|
// width:'100%',
|
// };
|
treeButtonDivCss = {
|
position: "absolute",
|
top: '85%',
|
left: '30%',
|
}
|
treeDutton2DivCss = {
|
position: "absolute",
|
top: '85%',
|
left: '60%',
|
}
|
winCss = {
|
position: 'relative',
|
"border-radius": "4px",
|
width: "100%",
|
'max-width':"190px",
|
height: "30px",
|
|
}
|
treeWinTitleCss = {
|
"margint-top": "3%"
|
}
|
subFormTreeCss = {
|
position: "absolute",
|
|
top: '56px',
|
left: '0px',
|
|
'background-color': '#fff',
|
'z-index': '99999',
|
// top:"15%",
|
// "margin-left":"5%",
|
width: "165px",
|
border: "1px solid #CCC",
|
overflow: "hidden",
|
'overflow-y': "auto",
|
|
}
|
wintreeCss = {
|
position: "absolute",
|
top: '56px',
|
'background-color': '#fff',
|
'z-index': '99999',
|
// top:"15%",
|
// "margin-left":"5%",
|
width: "165px",
|
border: "1px solid #CCC",
|
overflow: "hidden",
|
'overflow-y': "auto",
|
}
|
if(customShow.options.customInit.designMode == 2){//快捷模式处理 李伟民 0123
|
$(".ztree").parent().parent().attr("name", "TreeWin");
|
$(".ztree").parent().parent().attr("class", "TreeWin");
|
}else{
|
$(".ztree").parent().wrapAll('<div name="TreeWin" class="TreeWin"></div>');
|
}
|
|
|
$('.ztree').parents('div[name="TreeWin"]').show();
|
// 2017/11/4 点击预览的时候产生的树样式 李元杰
|
$('div[type="Tree"]').append('<button class="btn btn-primary" name="treeButton1" style="display:none">选择</button>');
|
//马习同 下拉树样式修改 11/13
|
// $('div[name="TreeWin"]').prepend(`
|
// <div name="treeWinTitle">
|
// <div class="content_wrap">
|
// <div>
|
// <ul class="list ulContent">
|
// <div class="input-group" >
|
// <input readonly unselectable="on" type="text" class="defaultHeight citySel" placeholder="" aria-describedby="basic-addon1">
|
// <button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
|
// </div>
|
|
// </li>
|
// </ul>
|
// </div>
|
// </div>
|
// </div>
|
// `);
|
if(customShow.options.customInit.designMode == 2){
|
$('div[name="TreeWin"]').prepend(`
|
<div name="treeWinTitle">
|
<input id="search_input" type="text" class="defaultHeight search_input" placeholder="" aria-describedby="basic-addon1">
|
<div class="content_wrap">
|
<div>
|
<ul class="list ulContent">
|
<div class="input-group" >
|
<input readonly unselectable="on" type="text" class="defaultHeight citySel" placeholder="" aria-describedby="basic-addon1">
|
<button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
|
</div>
|
|
</li>
|
</ul>
|
</div>
|
</div>
|
</div>
|
`);
|
}else{
|
_.each($('.ztree'),function(tree){
|
if($(tree).parent().attr('class').indexOf('cfg_contentNone') != -1){
|
$(tree).closest('div[name="TreeWin"]').prepend(`
|
<div name="treeWinTitle" class="cfg_contentNone">
|
<input id="search_input" type="text" class="defaultHeight search_input" placeholder="" aria-describedby="basic-addon1">
|
<div class="content_wrap">
|
<div>
|
<ul class="list ulContent">
|
<div class="input-group" >
|
<input readonly unselectable="on" type="text" class="defaultHeight citySel" placeholder="" aria-describedby="basic-addon1">
|
<button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
|
</div>
|
|
</li>
|
</ul>
|
</div>
|
</div>
|
</div>
|
`);
|
}else{
|
$(tree).closest('div[name="TreeWin"]').prepend(`
|
<div name="treeWinTitle">
|
<input id="search_input" type="text" class="defaultHeight search_input" placeholder="" aria-describedby="basic-addon1">
|
<div class="content_wrap">
|
<div>
|
<ul class="list ulContent">
|
<div class="input-group" >
|
<input readonly unselectable="on" type="text" class="defaultHeight citySel" placeholder="" aria-describedby="basic-addon1">
|
<button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
|
</div>
|
|
</li>
|
</ul>
|
</div>
|
</div>
|
</div>
|
`);
|
}
|
})
|
|
}
|
|
// $('div[name="TreeWin"]').prepend('<div name="treeWinSearch"><input id="search_input" placeholder="Type to filter"><hr /></div>');
|
// $('div[name="TreeWin"]').append('<div name="treeButtonDiv"><button class="btn btn-primary" name="treeButton2">确定</button></div>');
|
// $('div[name="TreeWin"]').append('<div name="treeButtonDiv2"><button class="btn btn-danger" name="treeButton3">取消</button></div>');
|
// $(".ztree").parent().css(subFormTreeCss);
|
// $('.ztree').parents('.fieldOrderNum').attr('typpe');
|
var ztreeParentCss = $(".ztree").parent();
|
$(".ztree").parent().css(subFormTreeCss);
|
for (var i = 0; i < ztreeParentCss.length; i++) {
|
// 11/16 李元杰 子表单内树形搜索框定位
|
console.log($(ztreeParentCss[i]).find('ul'))
|
console.log($(ztreeParentCss[i]).parents('.fieldOrderNum'))
|
var isAllCopyTreeIs = $(ztreeParentCss[i]).find('ul').attr('id').split('tree')[0];
|
if (customShow.options.customItemShow.item[isAllCopyTreeIs].parentsubFormNum != 0) {
|
$(ztreeParentCss[i]).css(subFormTreeCss);
|
$(ztreeParentCss[i]).parent('div[name="TreeWin"]').find('.search_input').addClass('search_input_subform')
|
} else {
|
|
$(ztreeParentCss[i]).css(wintreeCss);
|
}
|
// 树形是否有数据的判断
|
if ($(ztreeParentCss[i]).children('ul').children('li').length > 0) {
|
|
} else {
|
|
$(ztreeParentCss[i]).hide();
|
}
|
}
|
// $("#occlusion").css(occlusionCss);
|
$('div[name="TreeWin"]').css(winCss);
|
if(customShow.options.customInit.designMode == 1){
|
$('div[name="TreeWin"]').css('width','unset');
|
}
|
$('div[name="treeWinTitle"]').css(treeWinTitleCss);
|
$('.ztree').css("top", "%20");
|
// $(".ztree").parent().parent().hide();
|
//这个换成点击新建
|
// $('button[name="treeButton1"]').click(function(){
|
// 表明只有树组件时才提示是否绑定数据
|
if ($('button[name="treeButton1"]').length > 0) {
|
var treeId = $('button[name="treeButton1"]').prev().attr("id");
|
var treeJson = $('button[name="treeButton1"]').prev().children(':nth-child(2)').attr("masterdata");
|
//////console.log($(this).prev()[0]);
|
// console.log(treeJson);
|
//console.log(treeId);
|
if (typeof (treeJson) == "undefined" || treeJson == "") {
|
// alert("该控件没有进行数据绑定!")
|
} else {
|
// $("#occlusion").fadeTo(200);
|
console.log($('button[name="treeButton1"]'))
|
$('button[name="treeButton1"]').prev().show();
|
console.log($('div[name="treeWinTitle"]'))
|
var treeWinTitle = $('div[name="treeWinTitle"]');
|
console.log(treeWinTitle[0])
|
for (var i = 0; i < treeWinTitle.length; i++) {
|
console.log($(treeWinTitle[i]));
|
$(treeWinTitle[i]).find('input[type="text"]').attr('id', `search_input${i}`)
|
}
|
}
|
}
|
// 12/7 李元杰 树禁止背景颜色
|
var editableBgColor = $('.ztree');
|
for (var i = 0; i < editableBgColor.length; i++) {
|
var editableFlag = $(editableBgColor[i]).parent().attr('editable')
|
if (editableFlag == 'true') {
|
var a = $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel')
|
$(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel').removeClass('disableColor')
|
} else {
|
var a = $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel')
|
$(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel').addClass('disableColor')
|
}
|
}
|
// 12/7 end
|
$('.ztree').addClass('search_list');
|
// 搜索框获得焦点时 初始化
|
console.log($('.tabBox'))
|
$('.tabBox').on('focus', '.search_input', function () {
|
console.log($(this))
|
var searchListId = $(this).parents('div[name="TreeWin"]').find('.ztree').attr('id');
|
console.log($(this).parents('div[name="TreeWin"]').find('.ztree'));
|
$(this).fastLiveFilter(`#${searchListId}`, {});
|
})
|
// $('button[name="treeButton2"]').click(function(){
|
// //确定按钮 by kill
|
// var treeId=$(this).parent().parent().children(':nth-child(2)').attr("id")
|
// $('#spanDiv'+treeId).remove()
|
// $('#'+treeId+"ActiveId").children(':nth-child(1)').append('<span id="spanDiv'+treeId+'"></span>')
|
// $('#'+treeId+'tree').children('li').each(function(){
|
// var state=$(this).children(':nth-child(2)').attr('class')
|
// if(state.indexOf('true')!=-1){
|
// var text=$(this).children(':nth-child(3)').attr('title');
|
// $('#'+treeId+"ActiveId").children(':nth-child(1)').children(':nth-child(4)').append('<span>|'+text+'</span>')
|
// }
|
// })
|
// // $("#occlusion").fadeOut(200);
|
// // $(this).parent().parent().hide();
|
// }
|
// )
|
// $('button[name="treeButton3"]').click(function(){
|
// //取消按钮 by kill
|
// var treeId=$(this).parent().parent().children(':nth-child(2)').attr("id")
|
// var a = [];
|
// var tite=$('#spanDiv'+treeId).children().text();
|
// for(var i=0;i<tite.split("|").length;i++){
|
// $('#'+treeId+'tree').children('li').each(function(){
|
// if(tite.split("|")[i]==$(this).children(':nth-child(3)').attr('title')){
|
// a.push($(this).children(':nth-child(2)').attr('id'))
|
// }else{
|
// if($(this).children(':nth-child(2)').attr('class').indexOf('true')!=-1){
|
// $(this).children(':nth-child(2)').click();
|
// }
|
// }
|
// })
|
// }
|
// for(var x=0;x<a.length;x++){
|
// $('#'+a[x]).click();
|
// ////console.log(a[x])
|
// }
|
|
// // $("#occlusion").fadeOut(200);
|
// // $(this).parent().parent().hide();
|
// })
|
// end by kill
|
|
|
}
|
|
//事件绑定 接口绑定
|
customShow.setEventBind = function () {
|
// //接口绑定
|
// interfaceBind = customShow.initEvent.interfaceBind;
|
// for (var i = 0; i < interfaceBind.length; i++) {
|
// customShow.initEvent[interfaceBind[i].interfacemethod] = eval(interfaceBind[i].customInterfacemethod);
|
// };
|
|
//事件绑定
|
eventBind = customShow.initEvent.eventBind;
|
//02事件绑定:字段别名 字段类型 事件名 自定义事件名
|
console.log(eventBind);
|
for (var i = 0; i < eventBind.length; i++) {
|
// 自定义事件名
|
var funstr = eventBind[i].eventmethod + "()";//页面事件绑定 李伟民 12-22
|
//页面事件绑定 李伟民 12-22
|
// 事件名
|
var eventName = eventBind[i].event;
|
// 字段类型
|
// var tag = eventBind.tag; //------------类型绑定-------------
|
// 字段别名
|
var fieldKey = eventBind[i].fieldName;
|
// 取得控件ID
|
var itemId = customBase.getfieldKeyFoItemId(fieldKey); //---------------------------
|
$("#" + itemId).attr('funstr',funstr)
|
//事件绑定
|
$("#" + itemId).on(eventName, function () {
|
try {//页面事件 无资源文件 JS报错解决 李伟民 0131
|
eval($(this).attr('funstr'));
|
} catch (error) {
|
console.log('资源文件中无此方法')
|
}
|
});
|
};
|
//-------------------------主数据取得------------------------------
|
|
//公式初期化
|
setTimeout(function () {
|
customLinkageAnalysis.bindLinkage();
|
}, 200);
|
//行程排序初期化
|
setTimeout(function () {
|
customShow.journeySort();
|
}, 200);
|
// customShow.options.LinkageAnalysisSetValueFlag = ture;
|
|
setTimeout(function () {
|
//初期化公式接口
|
customShow.initEvent.interfaceInitLinkage();
|
}, 200);
|
//马习同 合计 2017-12-07 公式初期化后
|
customShow.oneTotle();
|
}
|
|
customShow.setEventBindItem = function (eventItem) {
|
//事件绑定
|
eventBind = eventItem;
|
//02事件绑定:字段别名 字段类型 事件名 自定义事件名
|
for (var i = 0; i < eventBind.length; i++) {
|
// 自定义事件名
|
var setfunction = eval(eventBind[i].eventmethod);
|
// 事件名
|
var eventName = eventBind[i].event;
|
// 字段类型
|
// var tag = eventBind.tag; //------------类型绑定-------------
|
// 字段别名
|
var fieldKey = eventBind[i].fieldName;
|
// 取得控件ID
|
var itemId = customBase.getfieldKeyFoItemId(fieldKey); //---------------------------
|
//事件绑定
|
$("#" + itemId).on(eventName, setfunction);
|
};
|
}
|
customShow.listData = {};
|
// 11/21 全局 itemId
|
customShow.itemId = "";
|
//数据设定值取得(主数据 API 数据源 自定义)
|
customShow.setDatasourceData = function (customItem) {
|
//马习同 获取
|
customItems = customShow.options.customItemShow.item;
|
|
var setDataItem = {
|
masterdata: function (item, callback) {
|
setMasterData(item, callback);
|
},
|
datasource: function (item, callback) {
|
setDatasource(item, callback);
|
},
|
custom: function (item, callback) {
|
setCustom(item, callback);
|
},
|
api: function (item, callback) {
|
setApiDatasource(item, callback);
|
}
|
}
|
var setCallbackItem = function (itemId, listData) {
|
var type = customShow.options.customItemShow.item[itemId].tag_Type;
|
if (type == "dropdownlist") {
|
setDropdownlist(itemId, listData);
|
} else if (type == "radio" || type == "checkbox") {
|
setCustomradio(itemId, listData);
|
} else if (type == "tree") {
|
var dropdowntype = customShow.options.customItemShow.item[itemId].tag_Attribute.dropdowntype;
|
if (dropdowntype == "multiple") {
|
// 多选的树样式
|
$('#' + itemId + "tree").parent().hide();
|
setTree(itemId, customBase.settingChkboxType, listData);
|
|
} else {
|
// 2017/11/1 李元杰 树更改成单选
|
// 单选的树样式
|
|
$('#' + itemId + "tree").parent().hide();
|
setTree(itemId, customBase.settingRadioType, listData);
|
}
|
var unvisible = customBase.options.customItems;
|
for (item in unvisible) {
|
if (unvisible[item].type == "subform") {
|
var itemId = unvisible[item].id;
|
// var itemTwo = itemId;
|
// var itemSubform = $('.'+"customViewUEditorCss" +" #"+itemId+"ActiveId");
|
////////////console.log(item);
|
//子表单删除第一条可添加 2017/10/26 马习同
|
// var divIcon = $('<div id="'+itemId+'save" class="cfg_contentNone"></div>');
|
var cloneE = $('#' + itemId + 'subformTr').clone();
|
// divIcon.append(cloneE);
|
console.log(cloneE);
|
// itemSubform.append(divIcon);
|
|
|
customBase.options.customItems[item]['cloneDiv'] = cloneE;
|
}
|
}
|
}
|
}
|
|
//下拉菜单
|
setDropdownlist = function (itemId, listData) {
|
|
|
var dropdownlistData;
|
|
var item = $('.customViewUEditorCss #' + itemId);
|
// $($('.customViewUEditorCss #'+itemId)[0]).empty();
|
// $($($('.customViewUEditorCss #'+itemId)[0]).parentNode).find(".select2").remove();
|
var dropdowntype = customShow.options.customItemShow.item[itemId].tag_Attribute.dropdowntype;
|
var editable = customShow.options.customItemShow.item[itemId].tag_Attribute.editable;
|
// ////console.log(editable);
|
var readonly = "readonly";
|
if (editable) {
|
readonly = "";
|
}
|
var width = $(item[0])[0].style.width.replace("px", "");
|
width = parseInt(width);
|
console.log(width)
|
customBase.options.dropdownlistText[itemId] = listData;
|
// $("#"+itemId).parent().empty();
|
var itemIdClass = "selectClass js-example-basic-single defaultHeight customShowItemClass dropdowntypeCss " + itemId + "value " + readonly;
|
var DropdownlistItem = $("#" + itemId).parent();
|
DropdownlistItem.empty();
|
DropdownlistItem.append($('<div id="' + itemId + '" class="selectClass ' + itemIdClass + '"></div>'));
|
if (dropdowntype == "multiple") {
|
xhSelect.setXhSelect(
|
{
|
selectId: itemId,
|
multiple: true,
|
width: width,
|
listData: listData
|
}
|
);
|
} else {
|
xhSelect.setXhSelect(
|
{
|
selectId: itemId,
|
multiple: false,
|
width: width,
|
listData: listData
|
}
|
);
|
}
|
// item.find();
|
// if(dropdowntype == "multiple"){
|
// item.select2({theme: "classic",
|
// width: width,
|
// data: listData,
|
// multiple: true});
|
// }else{
|
// item.select2({theme: "classic",
|
// width: width,
|
// data: listData,
|
// });
|
// }
|
customShow.clickBindSubform();
|
|
//数据加载
|
var initTempData = customShow.options.initTempDatas[itemId];
|
if (initTempData != undefined) {
|
var parentsubFormNum = customShow.options.customItemShow.item[itemId].parentsubFormNum;
|
initTempData = customShow.dbItemToShowItem(itemId, "dropdownlistText", initTempData, "customViewUEditorCss", dropdowntype, parentsubFormNum);
|
// customShow.options.initTempDatas[itemId] = initTempData;
|
customBase.setItemValue(itemId, "dropdownlistText", initTempData, "customViewUEditorCss", dropdowntype);
|
customShow.setShowItem(itemId, "dropdownlistText", initTempData);
|
} else {
|
if (customShow.options.customItemShow.item[itemId].tag_Attribute.datasourcetype == "custom") {
|
var customItemsTemp = customShow.options.customItemShow.item[itemId].tag_Attribute.custom;
|
////////console.log(customItemsTemp);
|
var initTempDataCustom = []
|
var j = 0;
|
|
for (var i = 0; i < customItemsTemp.length; i++) {
|
if (customItemsTemp[i].ischecked) {
|
initTempDataCustom[j] = customItemsTemp[i].itemtext;
|
j++;
|
// ////////console.log(customItems[i].itemtext);
|
// ////////console.log(customItems[i]);
|
}
|
}
|
////////console.log(initTempDataCustom);
|
if (customShow.options.customItemShow.item[itemId].tag_Attribute.dropdowntype == "single") {
|
customBase.setItemValue(itemId, "dropdownlistText", [initTempDataCustom[0]], "customViewUEditorCss", dropdowntype);
|
} else {
|
customBase.setItemValue(itemId, "dropdownlistText", initTempDataCustom, "customViewUEditorCss", dropdowntype);
|
}
|
}
|
}
|
}
|
setCustomradio = function (itemId, listData) {
|
var tag_Type = customItems[itemId].tag_Type;
|
customBase.options.dropdownlistText[itemId] = listData;
|
$('.customViewUEditorCss #' + itemId).removeClass('select2Maxheight').addClass('select2Maxheight');
|
var item = $('.customViewUEditorCss #' + itemId + " .line");
|
var oNodeclass = "custom-check";
|
if (tag_Type == "radio") {
|
oNodeclass = "custom-radio";
|
} else if (tag_Type == "checkbox") {
|
oNodeclass = "custom-check";
|
}
|
var oNode = "";
|
var customItemsData = customBase.options.customItems;
|
for (data in customItemsData) {
|
// console.log(customBase.options.customItems[data]);
|
// console.log(itemId);
|
for (var i = 0; i < listData.length; i++) {
|
if (customBase.options.customItems[data].id == itemId) {
|
// 11/9 李元杰 是否有选中
|
console.log(customBase.options.customItems[data])
|
var curFlag = '';
|
if(listData[i].ischecked){
|
curFlag = 'cur'
|
}
|
if (customBase.options.customItems[data].editable) {
|
oNode += '<li class="ui-state-default" style="height:28px"><span class="' + oNodeclass + ' ' + curFlag +' " value="' + listData[i].value + '" ><i class="label"></i>' + listData[i].text + '</span></li>';
|
} else {
|
oNode += '<li class="ui-state-default" style="height:28px"><span class="' + oNodeclass + ' ' + curFlag +' readonly" value="' + listData[i].value + '" ><i class="label"></i>' + listData[i].text + '</span></li>';
|
}
|
// }else{
|
// oNode += '<li class="ui-state-default" style="height:28px"><span class="'+oNodeclass+'" value="'+listData[i].value+'" ><i class="label"></i>'+listData[i].text+'</span></li>';
|
}
|
};
|
// if(customBase.options.customItems[data].id == itemId ){
|
// // console.log(listData);
|
|
// }
|
}
|
for (var i = 0; i < $(item).length; i++) {
|
// item.empty();
|
$($(item)[i]).empty();
|
$(item)[i].innerHTML = oNode;
|
}
|
customShow.clickBindSubform();
|
//数据加载
|
var initTempData = customShow.options.initTempDatas[itemId];
|
if (initTempData != undefined) {
|
var parentsubFormNum = customShow.options.customItemShow.item[itemId].parentsubFormNum;
|
initTempData = customShow.dbItemToShowItem(itemId, tag_Type, initTempData, "customViewUEditorCss", '', parentsubFormNum);
|
// customShow.options.initTempDatas[itemId] = initTempData;
|
customBase.setItemValue(itemId, tag_Type, initTempData, "customViewUEditorCss");
|
customShow.setShowItem(itemId, tag_Type, initTempData);
|
}
|
console.log($(item))
|
// 12/11 禁用背景
|
var spanDiv = $(item).find('li').find('span');
|
console.log($(item).parent().attr('editable'))
|
if (($(item).parent().attr('editable') == "true")) {
|
$(item).find('li').find('span').addClass("disableUrl");
|
for (var i = 0; i < spanDiv.length; i++) {
|
console.log($(spanDiv[i]))
|
if (tag_Type == "radio") {
|
$(spanDiv[i]).removeClass("disableRadUrl");
|
} else if (tag_Type == "checkbox") {
|
$(spanDiv[i]).removeClass("disableChkUrl");
|
}
|
}
|
} else {
|
for (var i = 0; i < spanDiv.length; i++) {
|
console.log($(spanDiv[i]))
|
if (tag_Type == "radio") {
|
$(spanDiv[i]).addClass("disableRadUrl");
|
} else if (tag_Type == "checkbox") {
|
$(spanDiv[i]).addClass("disableChkUrl");
|
}
|
|
}
|
}
|
}
|
setTree = function (itemId, setting, listData) {
|
$('.customViewUEditorCss #' + itemId + "tree").empty();
|
// 在这里设置 树的id 和 listData
|
customShow.listData[itemId] = listData;
|
customShow.itemId = itemId
|
var treeDiv = $('div#' + itemId);
|
if (treeDiv.length != 1) {
|
for (var i = 0; i < treeDiv.length - 1; i++) {
|
var ultreeId = $(treeDiv[i]).find('ul').attr('id');
|
ultreeId = ultreeId.split('tree')[0] + 'tree';
|
$(treeDiv[i]).find('ul').attr('id', ultreeId + i);
|
$.fn.zTree.init($($('.customViewUEditorCss #' + itemId + "tree" + i)), setting, listData);
|
// $('#'+itemId).parents('div[name="TreeWin"]').find('.citySel').addClass('disableColor')
|
console.log('#' + itemId);
|
var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree" + i);
|
// customShow.setTree.disableParentNode.set(treeObj);
|
if (treeObj) {
|
treeObj.expandAll(true);
|
}
|
}
|
} else {
|
$.fn.zTree.init($($('.customViewUEditorCss #' + itemId + "tree")), setting, listData);
|
var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree");
|
var treeDefaultSet;
|
if (treeObj) {
|
treeObj.expandAll(true);
|
}
|
var defaultValue = $('#' + itemId).attr('defaultvalue');
|
var dataObj, defaultValue;
|
var treeDefaultSet = customShow.treeDefaultSet(treeObj, defaultValue)
|
defaultValue = treeDefaultSet[0]
|
dataObj = treeDefaultSet[1];
|
$('#' + itemId).attr('value', JSON.stringify(dataObj))
|
$('#' + itemId).prev().find('.citySel').val(defaultValue);
|
// 12/8 禁止选中 李元杰'
|
console.log(itemId)
|
var treeArray = _.filter(customShow.options.customItemShow.item, ['tag_Type', 'tree'])
|
for (var i = 0; i < treeArray.length; i++) {
|
if (treeArray[i].tag_Id == itemId) {
|
if (treeArray[i].tag_Attribute.disableParentNode) {
|
customShow.setTree.disableParentNode.set(treeObj)
|
}
|
}
|
}
|
}
|
var initTempData = customShow.options.initTempDatas[itemId];
|
|
var defaultValue = $('#' + itemId).attr('defaultvalue');
|
if (initTempData == 'undefined' || initTempData == undefined) {
|
if (defaultValue != '' && defaultValue != 'undefined' && defaultValue != undefined) {
|
initTempData = defaultValue;
|
} else {
|
initTempData = ' '
|
}
|
}
|
// 010110001000010000010000001
|
if (initTempData != undefined) {
|
customBase.setItemValue(itemId, "tree", initTempData, "customViewUEditorCss");
|
}
|
customShow.clickBindSubform();
|
}
|
|
|
|
|
//API数据
|
setApiDatasource = function (item, callback) {
|
console.log(item)
|
var apiUrl = item.tag_Attribute.apiUrl;
|
var callbackId = item.tag_Id;
|
callbackApiData = function (itemData, url) {
|
|
console.log(url)
|
var ItemId = url.split("callbackId=")[1];
|
console.log(url)
|
var item = customShow.options.customItemShow.item[ItemId];
|
var apiIdKey = item.tag_Attribute.apiIdKey;// 表示项
|
var apiPIdKey = item.tag_Attribute.apiPIdKey;// 表示值
|
itemData = itemData.data;
|
|
things = [];
|
console.log(itemData);
|
// var textcolumn = itemData[apiIdKey];
|
|
// var valuecolumn = itemData[apiPIdKey];
|
// //取得数据长度不一致时数据不设定
|
// if (textcolumn.length != valuecolumn.length) {
|
// return;
|
// }
|
if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
|
for (var i = 0; i < itemData.length; i++) {
|
if (i == 0 && item.tag_Type == 'radio') {
|
things[i] = { ischecked: true, value: itemData[i][apiPIdKey], text: itemData[i][apiIdKey] };
|
} else {
|
things[i] = { ischecked: false, value: itemData[i][apiPIdKey], text: itemData[i][apiIdKey] };
|
}
|
};
|
} else if (item.tag_Type == 'tree') {
|
var apiName = item.tag_Attribute.apiName;
|
console.log(apiName)
|
// var namecolumn = itemData[apiName];
|
// if (textcolumn.length != namecolumn.length) {
|
// return;
|
// }
|
for (var i = 0; i < itemData.length; i++) {
|
things[i] = { id: itemData[i][apiIdKey], pId: itemData[i][apiPIdKey], name: itemData[i][apiName] };
|
};
|
} else {
|
console.log(itemData)
|
|
for (var i = 0; i < itemData.length; i++) {
|
console.log(itemData[i])
|
console.log(apiPIdKey)
|
console.log(apiIdKey)
|
console.log(itemData[i][apiPIdKey])
|
console.log(itemData[i][apiIdKey])
|
things[i] = { id: i, value: itemData[i][apiPIdKey], text: itemData[i][apiIdKey] };
|
|
};
|
}
|
console.log(things);
|
callback(ItemId, things);
|
}
|
|
customDataBound.getApiDatasource(apiUrl, callbackId, callbackApiData);
|
}
|
//主数据
|
setMasterData = function (item, callback) {
|
var callbackId = item.tag_Id;
|
var code = item.tag_Attribute.masterData;
|
console.log(code);
|
// 11/9
|
|
|
|
console.log(callbackId)
|
// if(code == ""){
|
// return;
|
// }
|
callbackMasterData = function (itemid, itemData) {
|
things = [];
|
console.log('√')
|
console.log(itemData);
|
console.log(itemid);
|
var customItems = customBase.options.customItems;
|
for (item in customItems) {
|
if (customBase.options.customItems[item].id == callbackId) {
|
|
}
|
}
|
item = customShow.options.customItemShow.item[itemid];
|
if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
|
for (var i = 0; i < itemData.length; i++) {
|
if (i == 0 && item.tag_Type == 'radio') {
|
things[i] = { ischecked: true, value: itemData[i].code, text: itemData[i].value };
|
} else {
|
things[i] = { ischecked: false, value: itemData[i].code, text: itemData[i].value };
|
}
|
};
|
} else if (item.tag_Type == 'tree') {
|
//-------------------------
|
console.log(itemData)
|
if (itemData != null) {
|
for (var i = 0; i < itemData.length; i++) {
|
things[i] = {
|
id: itemData[i].code,
|
pId: itemData[i].pid,
|
name: itemData[i].value
|
};
|
};
|
}
|
|
} else if (item.tag_Type == 'dropdownlist') {
|
if(itemData != undefined && !_.isNull(itemData)){
|
for (var i = 0; i < itemData.length; i++) {
|
things[i] = { id: i, value: itemData[i].code, text: itemData[i].value };
|
|
};
|
}
|
} else {
|
//其他控件主数据--
|
}
|
callback(itemid, things);
|
}
|
|
//数据源数据取得
|
customDataBound.getElement(code, callbackId, function (rs) {
|
// 修改下拉框样式统一
|
if (rs.data == null) {
|
callbackMasterData(callbackId, []);
|
}
|
for (itemid in rs.data) {
|
if (rs.data.hasOwnProperty(itemid)) {
|
callbackMasterData(itemid, rs.data[itemid]);
|
}
|
}
|
|
|
});
|
}
|
//数据源
|
setDatasource = function (item, callback) {
|
var temp = {};
|
datasourceName = item.tag_Attribute.datasource;
|
if (datasourceName == "") {
|
return;
|
}
|
if (customShow.options.datasource[datasourceName] == undefined) {
|
return;
|
}
|
temp.columnNames = item.tag_Attribute.textcolumn + "," + item.tag_Attribute.valuecolumn;
|
temp.datasource = customShow.options.datasource[datasourceName].datasource;
|
temp.databaseName = customShow.options.datasource[datasourceName].databaseName;
|
temp.callbackId = item.tag_Id;
|
if (item.tag_Type == 'tree') {
|
temp.columnNames += "," + item.tag_Attribute.namecolumn;
|
}
|
|
callbackDatasource = function (rs) {
|
console.log(this);
|
console.log(this.url);
|
var ItemId = this.url.split("callbackId=")[1];
|
|
item = customShow.options.customItemShow.item[ItemId];
|
|
datasourceName = rs.data;
|
|
things = [];
|
var textcolumn = datasourceName[item.tag_Attribute.textcolumn];
|
var valuecolumn = datasourceName[item.tag_Attribute.valuecolumn];
|
if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
|
for (var i = 0; i < textcolumn.length; i++) {
|
if (i == 0 && item.tag_Type == 'radio') {
|
things[i] = { ischecked: true, value: valuecolumn[i], text: textcolumn[i] };
|
} else {
|
things[i] = { ischecked: false, value: valuecolumn[i], text: textcolumn[i] };
|
}
|
};
|
} else if (item.tag_Type == 'tree') {
|
var namecolumn = datasourceName[item.tag_Attribute.namecolumn];
|
for (var i = 0; i < valuecolumn.length; i++) {
|
things[i] = { id: valuecolumn[i], pId: textcolumn[i], name: namecolumn[i] };
|
};
|
|
} else {
|
for (var i = 0; i < valuecolumn.length; i++) {
|
things[i] = { id: i, value: valuecolumn[i], text: textcolumn[i] };
|
|
};
|
}
|
|
callback(ItemId, things);
|
}
|
|
//数据源数据取得
|
customDataBound.getFieldDatasource(temp, callbackDatasource);
|
}
|
//自定义数据 ------1001--------
|
setCustom = function (item, callback) {
|
var custom = item.tag_Attribute.custom;
|
things = [];
|
if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
|
for (var i = 0; i < custom.length; i++) {
|
things[i] = { ischecked: custom[i].ischecked, value: custom[i].itemtext, text: custom[i].itemtext };
|
};
|
|
} else {
|
for (var i = 0; i < custom.length; i++) {
|
things[i] = { id: i, value: custom[i].itemtext, text: custom[i].itemtext };
|
};
|
}
|
var ItemId = customItem.id;
|
callback(ItemId, things);
|
}
|
|
//树 单选按钮 多选按钮 下拉菜单
|
var type = customItems[customItem.id].tag_Type;
|
if (type == 'dropdownlist' || type == 'radio' || type == 'checkbox' || type == 'tree') {
|
//数据取得顺序
|
//按照 选择的情况? 按照主数据?TODO
|
var item = customShow.options.customItemShow.item[customItem.id];
|
|
//数据清空
|
if (type == 'dropdownlist') {
|
$($('.customViewUEditorCss #' + customItem.id)[0]).empty();
|
$($($('.customViewUEditorCss #' + customItem.id)[0]).parentNode).find(".select2").remove();
|
var visibleTemp = customShow.options.customItemShow.item[customItem.id].tag_Attribute.visible;
|
if (!visibleTemp) {
|
$($($('.customViewUEditorCss #' + customItem.id)[0]).parentNode).remove();
|
return;
|
} else {
|
$('.customViewUEditorCss #' + customItem.id).select2({ theme: "classic", width: '240' });
|
}
|
} else if (type == 'radio' || type == 'checkbox') {
|
// var item = $('.customViewUEditorCss #'+customItem.id +" .line");
|
$($($('.customViewUEditorCss #' + customItem.id + " .line"))[0]).empty();
|
}
|
|
var datasourcetype = item.tag_Attribute.datasourcetype;
|
// ////console.log(datasourcetype);
|
console.log(item);
|
console.log(datasourcetype);
|
setDataItem[datasourcetype](item, setCallbackItem);
|
// _.each($(".customShow .tdContentClass"), opt => {
|
// // $(opt).attr("title", $(opt).children().children().html());
|
// console.log($(opt).html())
|
// if ($(opt).children().children().attr("type") == "text") {
|
// $(opt).attr("title", $(opt).children().children().val());
|
// } else {
|
// console.log(_.cloneDeep($(opt).children().children()))
|
// console.log(opt.innerHTML)
|
// console.log($(opt).children().children()[0].innerHTML)
|
// $(opt).attr("title", $(opt).children().children()[0].innerHTML);
|
// }
|
// })
|
}
|
// return itemData;
|
// _.each($(".customShow .tdContentClass"), opt => {
|
// // $(opt).attr("title", $(opt).children().children().html());
|
// console.log($(opt).html())
|
// if ($(opt).children().children().attr("type") == "text") {
|
// $(opt).attr("title", $(opt).children().children().val());
|
// } else {
|
// console.log(_.cloneDeep($(opt).children().children()))
|
// console.log(opt.innerHTML)
|
// console.log($(opt).children().children()[0].innerHTML)
|
// $(opt).attr("title", $(opt).children().children()[0].innerHTML);
|
// }
|
// })
|
}
|
// 12/7 设置默认值
|
customShow.treeDefaultSet = function (treeObj, defaultValue) {
|
var objValue = {};
|
var defaultValueArray = [];
|
var valueData;
|
var dataObj = {};
|
var dataObjArray = []
|
// 12/7 树的默认值
|
// 判断单选多选
|
// if(defaultValue.indexOf(',') == -1){
|
if(defaultValue){
|
// 单选
|
if (defaultValue.indexOf(',') == -1) {
|
var nodes = treeObj.getNodeByParam("id", defaultValue, null);
|
if (!_.isNull(nodes)) {
|
// 2017 /11/6 选中
|
//选择节点设定
|
treeObj.checkNode(nodes, true, true);
|
treeObj.expandAll(true);
|
dataObj[defaultValue] = '1';
|
if (defaultValue == nodes.id) {
|
defaultValue = nodes.name;
|
}
|
}
|
} else { //多选
|
defaultValueArray = defaultValue.split(',');
|
for (var i = 0; i < defaultValueArray.length; i++) {
|
valueData = defaultValueArray[i]
|
dataObj[valueData] = '1'
|
}
|
for (var i = 0; i < defaultValueArray.length; i++) {
|
var nodes = treeObj.getNodeByParam("id", defaultValueArray[i], null);
|
if (!_.isNull(nodes)) {
|
// 2017 /11/6 选中
|
//选择节点设定
|
treeObj.checkNode(nodes, true, true);
|
treeObj.expandAll(true);
|
if (defaultValueArray[i] == nodes.id) {
|
defaultValueArray[i] = nodes.name;
|
}
|
}
|
}
|
defaultValue = defaultValueArray.join(',')
|
}
|
console.log(dataObj)
|
objValue[0] = defaultValue;
|
objValue[1] = dataObj;
|
}
|
return objValue;
|
// }
|
}
|
|
//画面表示项目一览取得
|
customShow.getItemsList = function () {
|
|
var items = customShow.options.customItemShow.item;
|
var itemsList = {};
|
|
for (i in items) {
|
if (items.hasOwnProperty(i)) {
|
var item = items[i];
|
itemsList[item.tag_Attribute.alias] = {
|
fieldKey: item.tag_Attribute.alias,
|
id: item.tag_Id,
|
type: item.tag_Type,
|
parentsubFormNum: item.parentsubFormNum,
|
visible: item.tag_Attribute.visible, //可见
|
editable: item.tag_Attribute.editable, //可编辑
|
mustcheck: item.tag_Attribute.mustcheck, //必填
|
approvalmustenter: item.tag_Attribute.approvalmustenter,//审查必须
|
defaultvalue: item.tag_Attribute.defaultvalue,
|
// field:"",
|
}
|
console.log(item.tag_Attribute.defaultvalue)
|
}
|
};
|
return itemsList;
|
}
|
|
// 子表单事件调用
|
customShow.clickBindSubform = function () {
|
// 单选框
|
$('.select .custom-radio').unbind();
|
$('.select .custom-radio').on('click', function () {
|
// //////////console.log(this.className);
|
if (this.className.indexOf("readonly") > -1) {
|
return;
|
}
|
$($(this).parent().parent()).find(".cur").removeClass('cur');
|
$(this).addClass('cur').siblings().removeClass('cur');
|
});
|
customLinkageAnalysis.bindLinkageSubform("radio");
|
// 多选框
|
$('.select .custom-check').unbind();
|
$('.select .custom-check').on('click', function () {
|
if (this.className.indexOf("readonly") > -1) {
|
return;
|
}
|
$(this).toggleClass('cur');
|
// $($(this).parent().parent().parent().parent()).find(".errorItemCss").removeClass('errorItemCss');
|
// //////////console.log($($(this).parent().parent().parent())[0].id);
|
// var id = $($(this).parent().parent().parent())[0].id;
|
// $("#"+id+"mesageErrDiv").remove();
|
// $(".customViewUEditorCss #"+id).popover('hide')
|
});
|
customLinkageAnalysis.bindLinkageSubform("checkbox");
|
//删除子表单项目
|
$('.divshowEditor .iconfontcolorTH').unbind();
|
$('.divshowEditor .iconfontcolorTH').on('click', function () {
|
////////////////console.log($(this).parent().parent().parent());
|
$(this).parent().parent().parent().parent().parent().remove();
|
});
|
$('.iconfontcolor').unbind();
|
$('.iconfontcolor').on('click', function () {
|
$(this).parent().parent().parent().remove();
|
});
|
|
//-----------------日期类型------------------------
|
// $('.dateFromyyyy').unbind();
|
// $('.dateFromyyyymm').unbind();
|
// $('.dateFromyyyymmdd').unbind();
|
// $('.dateFromhhmiss').unbind();
|
// Flatpickr.localize(Flatpickr.l10ns.zh); // 设置为中文
|
flatpickr('.customViewUEditorCss .dateFromyyyy', {
|
dateFormat: "Y",
|
});
|
flatpickr('.customViewUEditorCss .dateFromyyyymm', {
|
dateFormat: "Y-m",
|
});
|
flatpickr('.customViewUEditorCss .dateFromyyyymmdd', {
|
dateFormat: "Y-m-d",
|
});
|
flatpickr('.customViewUEditorCss .dateFromhhmiss', {
|
dateFormat: "Y-m-d H:i",
|
time_24hr: true,
|
enableTime: true
|
});
|
// customLinkageAnalysis.bindLinkageSubform("calendar");
|
}
|
|
//各控件初期
|
customShow.controlInit = function (showClass) {
|
|
var customItems = customBase.options.customItems;
|
console.log(customItems)
|
if ('customShow' != showClass) {
|
//HTML内容控件初期化
|
var htmlediterShow = $(".customViewUEditorCss .htmlediterShowClass");
|
|
for (var i = 0; i < htmlediterShow.length; i++) {
|
var itemId = htmlediterShow[i].id;
|
var htmlediterShowItemId = itemId.replace("Item", "");
|
// var heightShow = htmlediterShow[i].getAttribute("heightShow");
|
// var widthShow = htmlediterShow[i].getAttribute("widthShow");
|
// ////////console.log(customShow.options.customItemShow.item[htmlediterShowItemId].tag_Attribute.alias);
|
var heightShow = customShow.options.customItemShow.item[htmlediterShowItemId].tag_Attribute.height;
|
var widthShow = customShow.options.customItemShow.item[htmlediterShowItemId].tag_Attribute.width;
|
// customShow.options.customItemShow.item[itemId].tag_Attribute.alias;
|
if (widthShow == undefined || heightShow == undefined) {
|
widthShow = 200;
|
heightShow = 200;
|
}
|
|
customShow.options.htmlediterShow[itemId] = {};
|
customShow.options.htmlediterShow[itemId].widthShow = widthShow;
|
customShow.options.htmlediterShow[itemId].heightShow = heightShow;
|
|
|
UE.getEditor(itemId, {
|
// serverUrl :url,
|
//allowDivTransToP: false,//阻止转换div 为p
|
toolleipi: true,//是否显示,设计器的 toolbars
|
textarea: 'design_content',
|
//这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
|
toolbars: [[
|
'source', '|', 'bold', 'underline', 'strikethrough', 'forecolor', 'backcolor','removeformat']],
|
//关闭字数统计
|
wordCount: false,
|
//关闭elementPath
|
elementPathEnabled: false,
|
//默认的编辑区域高度
|
initialFrameHeight: heightShow,
|
scaleEnabled: true,
|
//高度
|
// initialFrameHeight:heightShow,
|
// readonly:true,
|
//,iframeCssUrl:"css/bootstrap/css/bootstrap.css" //引入自身 css使编辑器兼容你网站css
|
//更多其他参数,请参考ueditor.config.js中的配置项
|
}).ready(function () {
|
////////////console.log(customBase.options.customItems);
|
id = this.key;
|
for (i in customBase.options.customItems) {
|
if (customBase.options.customItems.hasOwnProperty(i)) {
|
var idItem = id.replace("Item", "");
|
if (customBase.options.customItems[i].id == idItem) {
|
if (customShow.options.itemFormbase == "") {
|
UE.getEditor(id).setContent(customBase.options.customItems[i].defaultvalue);
|
} else {
|
var defaultvalue = customShow.options.itemFormbase[i];
|
// ////////console.log(defaultvalue);
|
// defaultvalue=defaultvalue+" ";
|
UE.getEditor(id).setContent(defaultvalue);
|
// setTimeout(function() {
|
// // this.body.focus();
|
// ////////console.log(UE.getEditor(id));
|
// UE.getEditor(id).options.scaleEnabled =false;
|
// }, 1000);
|
}
|
}
|
//非表示
|
// if(!customBase.options.customItems[i].visible){
|
// $(".customViewUEditorCss #"+id).addClass("cfg_contentNone");
|
// }
|
}
|
}
|
$(".edui-editor-bottomContainer").addClass("cfg_contentNone");
|
this.body.onclick = function (event, ui) {
|
//////////console.log(this);
|
//////////console.log(this.getAttribute("id"));
|
// $(this).removeClass("errorItemCss");
|
// $("#"+this.getAttribute("id")+"mesageErrDiv").remove();
|
}
|
})
|
};
|
}
|
//-----------------日期类型------------------------
|
|
flatpickr('.customViewUEditorCss .dateFromyyyy', {
|
dateFormat: "Y",
|
});
|
flatpickr('.customViewUEditorCss .dateFromyyyymm', {
|
dateFormat: "Y-m",
|
});
|
flatpickr('.customViewUEditorCss .dateFromyyyymmdd', {
|
dateFormat: "Y-m-d",
|
});
|
flatpickr('.customViewUEditorCss .dateFromhhmiss', {
|
dateFormat: "Y-m-d H:i",
|
time_24hr: true,
|
enableTime: true
|
});
|
|
if ('customShow' != showClass) {
|
//删除项目(select2项目删除)
|
$('.selection').remove();
|
$(".ztree").empty();
|
}
|
//下拉列表初期化
|
|
// $(".dropdowntypeCss").select2({theme: "classic",width: '240'});
|
// //下拉列表不可用
|
$('.' + showClass + " .editableDisabled").prop("disabled", true);
|
|
// 金融控件
|
for (item in customItems) {
|
if (customItems.hasOwnProperty(item)) {
|
//金融控件
|
if (customItems[item].type == "amount") {
|
if ("customViewUEditorCss" == showClass) {
|
var itemId = customItems[item].id;
|
// var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("defaultvalue");
|
var showCustomItem = customShow.options.customItemShow.item[itemId];
|
// var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
|
// var widthQrcode = $("#"+customItems[item].id)[0].width;
|
var itemValue = showCustomItem.tag_Attribute.defaultvalue;
|
var widthQrcode = showCustomItem.tag_Attribute.width;
|
if (widthQrcode == 0 || widthQrcode == undefined) {
|
widthQrcode = 60;
|
}
|
var divIcons = document.createElement("input");
|
divIcons.setAttribute("type", "text");
|
divIcons.setAttribute("id", customItems[item].id + "amount");
|
divIcons.setAttribute("style", "width: " + widthQrcode + "px; height:33px");
|
divIcons.setAttribute("class", "amountShowTextClass cfg_contentNone");
|
divIcons.setAttribute("value", itemValue);
|
$('.' + showClass + " #" + itemId)[0].after(divIcons);
|
$('.' + showClass + " #" + itemId).addClass("amountShowClass");
|
}
|
//申请单
|
}
|
else if (customItems[item].type == "mytext") {
|
if ("customViewUEditorCss" == showClass) {
|
var itemId = customItems[item].id;
|
////console.log(itemId);
|
var showCustomItem = customShow.options.customItemShow.item[itemId];
|
// var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
|
// var widthQrcode = $("#"+customItems[item].id)[0].width;
|
var itemValue = showCustomItem.tag_Attribute.qrcodeurl;
|
var widthQrcode = showCustomItem.tag_Attribute.width;
|
if (widthQrcode == 0 || widthQrcode == undefined) {
|
widthQrcode = 60;
|
}
|
var divIcons = document.createElement("div");
|
var div = document.createElement("div");
|
divIcons.setAttribute("id", customItems[item].id + "qrcode");
|
divIcons.setAttribute("class", "boxBtn");
|
divIcons.setAttribute("myAttr", itemId);
|
divIcons.innerHTML = '选择数据';
|
divIcons.setAttribute("maxlength", 200);
|
$('.' + showClass + " #" + itemId).eq(0).after(divIcons);
|
// $(" #"+itemId+"divid")[0].after(divIcons);
|
}
|
//二维码
|
} else if (customItems[item].type == "qrcode") {
|
if ("customViewUEditorCss" == showClass) {
|
var itemId = customItems[item].id;
|
var showCustomItem = customShow.options.customItemShow.item[itemId];
|
// var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
|
// var widthQrcode = $("#"+customItems[item].id)[0].width;
|
var itemValue = showCustomItem.tag_Attribute.qrcodeurl;
|
var widthQrcode = showCustomItem.tag_Attribute.width;
|
if (widthQrcode == 0 || widthQrcode == undefined) {
|
widthQrcode = 165;
|
}
|
var divIcons = document.createElement("input");
|
divIcons.setAttribute("type", "text");
|
divIcons.setAttribute("id", customItems[item].id + "qrcode");
|
divIcons.setAttribute("style", "width: " + widthQrcode + "px;height:33px");
|
divIcons.setAttribute("class", "qrcodeShowTextClass cfg_contentNone");
|
divIcons.setAttribute("value", itemValue);
|
divIcons.setAttribute("maxlength", 200);
|
$('.' + showClass + " #" + itemId)[0].after(divIcons);
|
$('.' + showClass + " #" + itemId).addClass("qrcodeShowClass");
|
}
|
//条形码
|
} else if (customItems[item].type == "barcode") {
|
if ("customViewUEditorCss" == showClass) {
|
var itemId = customItems[item].id;
|
// var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("text");
|
// var widthBarcode = $("#"+customItems[item].id)[0].width;
|
var showCustomItem = customShow.options.customItemShow.item[itemId];
|
// var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
|
// var widthQrcode = $("#"+customItems[item].id)[0].width;
|
var itemValue = showCustomItem.tag_Attribute.text;
|
var widthBarcode = 165;
|
// if(widthBarcode == 0){
|
// widthBarcode = 100;
|
// }
|
var divIcons = document.createElement("input");
|
divIcons.setAttribute("type", "text");
|
divIcons.setAttribute("id", customItems[item].id + "barcode");
|
divIcons.setAttribute("style", "width: " + widthBarcode + "px;height:33px");
|
divIcons.setAttribute("class", "barcodeShowTextClass cfg_contentNone");
|
divIcons.setAttribute("value", itemValue);
|
divIcons.setAttribute("maxlength", 200);
|
$('.' + showClass + " #" + itemId)[0].after(divIcons);
|
$('.' + showClass + " #" + itemId).addClass("barcodeShowClass");
|
}
|
//子表单设定
|
} else if (customItems[item].type == "subform") {
|
var itemId = customItems[item].id;
|
var itemTwo = itemId;
|
var itemSubform = $('.' + showClass + " #" + itemId + "ActiveId");
|
//lym
|
//位总div添加id
|
$("#" + itemId + "ActiveId").find(".usfile").attr("id", itemTwo + "uld");
|
//为a标签添加id
|
$("#" + itemId + "ActiveId").find(".usfile a").attr("id", itemTwo + "uis");
|
$("#" + itemId + "ActiveId").find(".usfile a").attr("itemId", itemTwo);
|
//为inputFile添加id
|
$("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form input").attr("itemId", itemTwo);
|
$("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form input").attr("id", itemTwo + "btn");
|
$("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form").attr("itemId", itemTwo);
|
|
//////////////console.log(item);
|
var ulIcon = document.createElement("ul");
|
var liIcon = "";
|
var m_customItems = customShow.options.customItemShow.item;
|
console.log(customBase.options)
|
var subItems = [];
|
var parentNum = itemId.replace("itemId_", "");
|
_.each(m_customItems, opt => {
|
if (opt.parentsubFormNum == parentNum) {
|
subItems.push(opt);
|
}
|
})
|
console.log(subItems)
|
_.remove(subItems, n => {
|
return n.tag_Attribute.alias == "DATAROWNUM" || n.tag_Attribute.visible == false;
|
});
|
//_.sortBy(orderArr, ['fieldOrderNum']);
|
subItems = _.sortBy(subItems, ['fieldOrderNum']);
|
_.each(subItems, opt => {
|
console.log(opt)
|
if (opt.tag_Type == "number") {
|
liIcon += "<li class='n_totle'><input class='" + opt.tag_Id + "totle textCssDiv defaultHeight' type='text' readonly></li>"
|
console.log(1)
|
} else {
|
liIcon += "<li class='p_totle'></li>"
|
console.log(2)
|
}
|
});
|
$(ulIcon).append(liIcon);
|
$("#" + itemId + "ActiveId").find(".h_totle").append(ulIcon);
|
console.log($("#" + itemId + "ActiveId").find(".h_totle"))
|
console.log(ulIcon)
|
// 单行文本 多行文本 数字 日历
|
} else if (customItems[item].type == "text" || customItems[item].type == "textarea" || customItems[item].type == "number" || customItems[item].type == "calendar") {
|
var itemId = customItems[item].id;
|
var defaultvalue = $("#" + itemId).attr("defaultvalue");
|
// 12/4 判断是否存在当前时间
|
var calendar = _.filter(customShow.options.customItemShow.item, ['tag_Type', 'calendar'])
|
for (var i = 0; i < calendar.length; i++) {
|
if (calendar[i].tag_Attribute.currentDate) {
|
if (itemId == calendar[i].tag_Id) {
|
defaultvalue = customShow.currentDate
|
}
|
}
|
}
|
console.log(defaultvalue)
|
// 之前表单日历默认值不存在时 12/4
|
if (defaultvalue == undefined || defaultvalue == 'undefined') {
|
defaultvalue = ''
|
}
|
customBase.setItemValue(itemId, "text", defaultvalue);
|
//数字验证事件追加
|
if (customItems[item].type == "number") {
|
//数值型控件验证
|
$("#" + itemId).unbind('blur');
|
$("#" + itemId).on('blur', function (e) {
|
var numbertype = $(this)[0].getAttribute("numbertype");
|
if (numbertype == "decimal") {
|
var decimalplace = $(this)[0].getAttribute("decimalplace");
|
decimalplace = parseInt(decimalplace);
|
if ($(this)[0].value != "") {
|
$(this)[0].value = Number($(this)[0].value).toFixed(decimalplace);
|
}
|
|
}
|
});
|
}
|
} else if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
|
customItems[item].type == 'checkbox' || customItems[item].type == 'tree') {
|
if ('customShow' != showClass) {
|
//数据源绑定
|
customShow.setDatasourceData(customItems[item]);
|
}
|
} else if (customItems[item].type == 'splitline') {
|
//分割线
|
var itemId = customItems[item].id;
|
$('.' + showClass + " #" + itemId + "ActiveId").addClass("layoutsetting8");
|
} else if (customItems[item].type == 'tree') {
|
var itemId = customItems[item].id;
|
var defaultvalue = $("#" + itemId)[0].getAttribute("defaultvalue");
|
|
// 之前表单树形默认值不存在时 12/7
|
if (defaultvalue == undefined || defaultvalue == 'undefined') {
|
defaultvalue = ''
|
}
|
customBase.setItemValue(itemId, "text", defaultvalue);
|
}
|
//初始属性设定
|
if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
|
customItems[item].type == 'checkbox' || customItems[item].type == 'tree' ||
|
customItems[item].type == "text" || customItems[item].type == "textarea" || customItems[item].type == "number"
|
|| customItems[item].type == "calendar" || customItems[item].type == "fileupload"
|
|| customItems[item].type == "qrcode" || customItems[item].type == "barcode"
|
|| customItems[item].type == "htmlediter" || customItems[item].type == "link"
|
|| customItems[item].type == "subform"
|
) {
|
console.log(customBase.options.customItems[item])
|
customShow.setShowAttribute(customBase.options.customItems[item]);
|
}
|
// 12/15
|
if (customItems[item].type == "link") {
|
var linkurl = customShow.costType[customItems[item].id].tag_Attribute.linkurl;
|
if(linkurl == ''){
|
linkurl = 'javascript:void(0)';
|
}
|
if(customShow.costType[customItems[item].id].tag_Attribute.editable){//不可编辑控制 李伟民 0124
|
$('#'+customItems[item].id).attr('href',linkurl)
|
}
|
}
|
}
|
};
|
//事件追加
|
customShow.clickBindSubform();
|
|
}
|
|
//固定事件的绑定
|
var index_i = 0;
|
customShow.clickBind = function () {
|
|
//子表单事件追加
|
customShow.clickBindSubform();
|
|
// //保存按钮按下
|
// $(".fromSaveCss").on('click', function() {
|
// customShow.onclickSave();
|
// });
|
|
// //取消按钮按下
|
// $(".cancelCss").on('click', function() {
|
// customShow.onclickCancel();
|
// });
|
|
|
// 子表单添加记录事件
|
|
$('.subformAdd').unbind();
|
function addSubFunc() {
|
//子表单项目追加
|
//console.log($(this)[0]);
|
customShow.addsubformList($(this)[0], "customViewUEditorCss");
|
// customShow.setXhSelectListAdd();
|
//子表单事件追加
|
customShow.clickBindSubform();
|
//公式初期化
|
customLinkageAnalysis.bindLinkage();
|
customShow.oneTotle();
|
//console.log($('.subformAdd'));
|
$('.subformAdd').unbind('click', addSubFunc);
|
$('.subformAdd').on('click', addSubFunc);
|
//行程排序初期化
|
customShow.journeySort();
|
SC.noBillCheckInit()//无票据行程验证
|
|
}
|
$('.subformAdd').on('click', addSubFunc);
|
|
//主数据丢失
|
// $('.subformAdd').unbind();
|
// $('.subformAdd').on('click', function(){
|
// console.log(1)
|
// //子表单项目追加
|
// customShow.addsubformList($(this)[0],"customViewUEditorCss");
|
// //子表单事件追加
|
// customShow.clickBindSubform();
|
// //公式初期化
|
// customLinkageAnalysis.bindLinkage();
|
// //行程排序初期化
|
// customShow.journeySort();
|
// });
|
|
//图片文件上传
|
var uploaderImage = $(".customViewUEditorCss .uploaderImage");
|
for (var i = 0; i < uploaderImage.length; i++) {
|
|
var imageItem = customShow.options.customItemShow.item[uploaderImage[i].id];
|
var itemList = customBase.options.uploaderItemReady[uploaderImage[i].id];
|
// 参数设定
|
var potion = {
|
id: uploaderImage[i].id,
|
width: imageItem.tag_Attribute.width,
|
height: imageItem.tag_Attribute.height,
|
formid: customShow.options.formid,
|
imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
|
editable: imageItem.tag_Attribute.editable, //是否可编辑
|
defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
|
ItemReady: itemList,
|
visible:imageItem.tag_Attribute.visible
|
}
|
customBase.uploaderShow(potion);
|
// customBase.uploaderShow("#"+uploaderImage[i].id,{width:0,height:200},true,customShow.options.formid);
|
|
};
|
|
//lym子表单上传
|
$('.sonImportFile').unbind();
|
$(".sonImportFile").click(function () {
|
console.log("进入点击事件");
|
//var checkedObj = $("#tbody input[type=checkbox]:checked");
|
console.log("fdsffddffd");
|
// //创建文件上传对象
|
var a = $(this).attr("itemId")
|
console.log(a)
|
$("#" + a + "btn").click(
|
|
);
|
$("#" + a + "btn").change(function () {
|
console.log("uqwhdoqwhdo");
|
//var objFile = $("#"+itemTwo+"btn");
|
//改变
|
|
let mthis = this;
|
var tenantId = localStorage.getItem("tenantID");
|
var formID = localStorage.getItem("newFormID");
|
var tenant = JSON.parse(tenantId);
|
var user = localStorage.getItem("userName");
|
var userName = JSON.parse(user);
|
var aba = a;
|
console.log(aba);
|
//结束
|
console.log(tenantId);
|
console.log(formID);
|
var objFile = $(this);
|
if (objFile.value == "") {
|
return;
|
} else {
|
var f_content = this.value;
|
var fileext = f_content.substring(f_content.lastIndexOf("."), f_content.length);
|
fileext = fileext.toLowerCase()
|
if (fileext != '.xls') {
|
} else {
|
//改变
|
var dataObj = { "formID": formID, "tenantID": tenant.tenantID, "userName": userName.userName, "rowNum": aba }
|
//结束
|
|
var options = {
|
url: url, //上传文件的路径
|
type: 'post',
|
dataObj: dataObj,
|
async: false,
|
success: function (data) {//异步上传成功之后的操作
|
if (data != undefined && data != null) {
|
console.log("返回参数");
|
}
|
|
}
|
};
|
|
var requestData = window.SonfiledUpload(dataObj, options, "/excel/impSonExcel", $(this).attr("itemId"), fileext);
|
var excels = JSON.parse(requestData);
|
console.log(requestData);
|
// console.log("最后");
|
//
|
// console.log($(this).attr("itemId"))
|
//改变
|
$(mthis).val("");
|
if (excels.data != undefined) {
|
customShow.addRow($(this).attr("itemId"), excels.data);
|
toastr.info("导入成功");
|
|
} else {
|
toastr.error("表格数据格式有误!");
|
}
|
//结束
|
//清除后台返回结果
|
window.localStorage.removeItem("seccData");
|
|
}
|
}
|
})
|
});
|
//文本文件上传
|
var uploaderFile = $(".customViewUEditorCss .uploaderFile");
|
console.log(uploaderFile)
|
for (var i = 0; i < uploaderFile.length; i++) {
|
|
var imageItem = customShow.options.customItemShow.item[uploaderFile[i].id];
|
debugger
|
var itemList = customBase.options.uploaderItemReady[uploaderFile[i].id];
|
// 参数设定
|
var potion = {
|
id: uploaderFile[i].id,
|
width: imageItem.tag_Attribute.width,
|
height: imageItem.tag_Attribute.height,
|
formid: customShow.options.formid,
|
imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
|
editable: imageItem.tag_Attribute.editable, //是否可编辑
|
defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
|
ItemReady: itemList,
|
visible:imageItem.tag_Attribute.visible
|
}
|
customBase.uploaderFileShow(potion);
|
// customBase.uploaderShow_Temp("#"+uploaderFile[i].id,{width:0,height:200},false,customShow.options.formid);
|
|
};
|
|
//必须入力验证
|
// var mustcheckCss = $(".mustcheckCss");//-----------todo
|
// for (var i = 0; i < mustcheckCss.length; i++) {
|
// ////////////////console.log('#'+$(mustcheckCss)[i].id);
|
// };
|
|
//子表单默认删除项目去掉
|
//子表单第一行可删除
|
// $(".iconfontcolor").addClass("cfg_contentNone");
|
// $(".iconfontcolorTH").addClass("cfg_contentNone");
|
|
//金融控件点击事件
|
$('.amountShowClass').unbind();
|
$('.amountShowClass').on('click', function () {
|
var editable = $(this)[0].getAttribute("editable");
|
//编辑设定
|
if (editable == "false") {
|
return;
|
}
|
|
|
$(this).addClass("cfg_contentNone");
|
$("#" + $(this)[0].id + "amount").removeClass("cfg_contentNone");
|
$("#" + $(this)[0].id + "amount").focus();
|
});
|
|
//金融控件点击事件
|
$('.amountShowTextClass').unbind();
|
$('.amountShowTextClass').on('blur', function () {
|
var id = $(this)[0].id;
|
//表示的控件ID取得
|
var idTemp = id.replace("amount", "");
|
|
var showCustomItem = customShow.options.customItemShow.item[idTemp];
|
// var widthqrcode = $("#"+idTemp)[0].width;
|
// var heightqrcode = $("#"+idTemp)[0].height;
|
var widthqrcode = showCustomItem.tag_Attribute.width;
|
var heightqrcode = showCustomItem.tag_Attribute.height;
|
if (heightqrcode == 0 || heightqrcode == undefined) {
|
heightqrcode = 24;
|
}
|
if (widthqrcode == 0 || widthqrcode == undefined) {
|
widthqrcode = 200;
|
}
|
|
//金额组件
|
//默认数值
|
var defaultSize = {
|
width: widthqrcode,
|
height: heightqrcode,
|
defaultvalue: "",
|
styleclass: ""
|
};
|
|
var decimalplace = $(this)[0].getAttribute("decimalplace");
|
decimalplace = parseInt(decimalplace);
|
if ($(this)[0].value != "") {
|
$(this)[0].value = Number($(this)[0].value).toFixed(decimalplace);
|
}
|
|
|
defaultSize.defaultvalue = $(this)[0].value.replace(".", "");
|
|
var showItem = customBase.getAmountHtml(defaultSize, true);
|
customBase.amount2Image(showItem, "amount", defaultSize, function (amountHtml) {
|
// ////////////////console.log(idTemp);
|
$("#" + idTemp + "amount").addClass("cfg_contentNone");
|
for (var i = 0; i < $("." + idTemp + "value").length; i++) {
|
$("." + idTemp + "value")[i].setAttribute("src", amountHtml);
|
};
|
$("#" + idTemp).removeClass("cfg_contentNone");
|
})
|
});
|
var addVal = [];
|
|
//申请单控件点击事件
|
$('.chooseMenu').unbind();
|
$(".mytext_icon").on("click", function () {
|
$(this).closest("[type='mytext']").find('.boxBtn').click();
|
console.log(customShow.options);
|
console.log(customBase.options);
|
})
|
$('.boxBtn').on('click', (obj) => {
|
console.log(customBase.options)
|
addVal = [];
|
//取得父页面变量
|
var outWindowObj = window.parent;
|
var $iconId = $(obj)[0].target.getAttribute("myAttr");
|
var iconAttr = customShow.options.customItemShow.item[$iconId];
|
console.log(iconAttr);
|
if ($("#" + $iconId).attr("formhuixian") != undefined) {
|
var formhuixian = JSON.parse($("#" + $iconId).attr("formhuixian"));
|
}
|
//console.log(formhuixian);
|
let head = "";
|
if ($(obj)[0].target.previousSibling.getAttribute("chooseForm") != "" || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
|
console.log(attrData);
|
if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {//函数分支修改 李伟民 12-05
|
var titleObj = { "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
|
var requestTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
|
requestTitle.done(function (res) {
|
var formtitle = [];
|
_.each(res.data, function (tdata) {
|
formtitle.push({ "fieldKey": tdata.fieldKey, "title": tdata.title });
|
});
|
head = formtitle;
|
});
|
var attrData = undefined;
|
} else {
|
var attrData = JSON.parse($(obj)[0].target.previousSibling.getAttribute("chooseForm"));
|
head = attrData.huixianObj.chooseData;
|
}//函数分支修改 李伟民 12-05
|
// window.localStorage.setItem("bussiness", attrData.formID.bussinessSystem) //不用了?
|
//获取id值
|
//用于验证是否已经存在div
|
var $divsLength = $('#' + $iconId + 'divIcons').length;
|
//接收table头请求
|
var formId = "";
|
if (attrData && attrData.ScreenCondition != undefined) {
|
//下拉框取值
|
let getVal = attrData.ScreenCondition.child;
|
console.log(getVal);
|
_.each(getVal, opts => {
|
_.each(customBase.options.customItems, opt => {
|
if (opt.fieldKey == opts.fieldKey && opts.side == "thi") {
|
opts.value = "";
|
if (opt.type == "dropdownlist") {
|
var getVals = customBase.getItemValue(opt.id, "dropdownlistText");
|
console.log(getVals);
|
if (getVals[0][0] != undefined) {
|
opts.value = getVals[0];
|
} else {
|
opts.value = "";
|
}
|
} else if (opt.type == "tree") {//树控件 处理 李伟民 12-5
|
var getVals = customBase.getItemValue(opt.id, opt.type);
|
console.log(getVals);
|
if (getVals[0][0] != undefined) {
|
opts.value = getVals[0];
|
} else {
|
opts.value = "";
|
}
|
} else {//树控件 处理 李伟民 12-5
|
var getVals = customBase.getItemValue(opt.id, opt.type);
|
console.log(getVals);
|
if (getVals != undefined) {
|
opts.value = getVals;
|
} else {
|
opts.value = "";
|
}
|
}
|
}
|
})
|
});
|
var sCondition = {};
|
//请求数据 筛选条件参数
|
let getValue = {};
|
getValue.child = getVal;
|
getValue.count = attrData.ScreenCondition.count;
|
sCondition = getValue;
|
let shaixuanData = attrData.ScreenCondition.child;
|
}
|
if ((attrData && attrData.huixianObj != undefined) || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
|
if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
|
formId = undefined;
|
} else {
|
formId = attrData.formID;
|
}
|
if ($divsLength == 0) {
|
//外层蒙版
|
console.log(customShow.options.customItemShow.item)
|
console.log($iconId)
|
var my_text_title = customShow.options.customItemShow.item[$iconId].tag_Attribute.title;
|
|
var menuContent = document.createElement('div');
|
//数据渲染div
|
var divIcons = document.createElement('div');
|
var pageBox = document.createElement('div');
|
var buttonDiv = document.createElement("div");
|
var closeBtn = document.createElement("span");
|
var requersTable = document.createElement("table");
|
var page = document.createElement("div");
|
var bigmodule = document.createElement("div");
|
var mymodule = document.createElement("div");
|
var mymodule2 = document.createElement("div");
|
var modal_content = document.createElement("div");
|
var mymodulebody = document.createElement("div");
|
var mymoduleheader = document.createElement("div");
|
var mymodulefooter = document.createElement("div");
|
var myinput = document.createElement("input");
|
var mybtn = document.createElement("button");
|
mybtn.innerHTML = "<i class='fa fa-search'></i>";
|
mybtn.setAttribute('class', 'btn btn-default');
|
mybtn.setAttribute('onClick', 'showbtn()');
|
mybtn.setAttribute('id', 'showserch');
|
// 添加搜索
|
var serchbox = document.createElement('div');
|
var serchpage = document.createElement('div');
|
var sersrc = document.createElement('script');
|
serchpage.setAttribute('class', 'pagination');
|
serchpage.setAttribute('style', 'display:none');
|
sersrc.setAttribute('src', './../../formEngine/resources/js/dataManagement/findmany.js');
|
var header = '<div _ngcontent-c12="" aria-label="Close" class="close"><span _ngcontent-c12="" class="closeBtn" aria-hidden="true">×</span></div><h4 class="modal-title modal-title_box" id="myModalLabel">' + my_text_title + '</h4>';
|
var footer = '<div _ngcontent-c12="" class="btn btn-primary btn-info btn-action closeBtn">确定</div>';
|
serchbox.setAttribute('class', 'fui-form hides');
|
serchbox.setAttribute('id', 'findserch');
|
serchbox.setAttribute('style', 'display:none !important;');
|
serchbox.innerHTML = '<div class="search_item">' +
|
'<div class="search_column ng-scope" id="copyTemp" style="display: none;">' +
|
'<div class="ng-binding" style="font-size:10px;font-weight:700;"></div>' +
|
'<span style="display: flex;width: 100%;"></span></div>' +
|
|
'<div class="search_column findbox ng-scope" id="copyTempNumber" style="display: none;">' +
|
'<div class="ng-binding" style="font-size:10px;font-weight:700;">预算截止时间</div>' +
|
'<span style="display: flex;position:relative;width:45%;"><input id = "numberFrom" class="" type="number"/></span>' +
|
'<span> ~ </span>' +
|
'<span style="display: flex;position:relative; width:45%;"><input id = "numberTo" class="" type="number"/></span></div>' +
|
'<div class="search_column ng-scope" id="copyTempTime" style="display: none;">' +
|
'<div class="ng-binding" style="font-size:10px;font-weight:700;"> 预算截止时间</div>' +
|
'<span style="display: flex; position: relative;width:45%;">' +
|
'<input id = "dateFrom" class="" type="text"/><i name = "clearFlatPickr" style="position:absolute;padding-left:3px;font-size:16px;top:6px;right:5px;" class="fa fa-calendar" aria-hidden="true"></i>' +
|
'</span><span> ~ </span><span style="display: flex;position:relative;width:45%;">' +
|
'<input id = "dateTo" class="" type="text"/><i name = "clearFlatPickr" style="position:absolute;padding-left:3px;font-size:16px;top:6px;right:5px;" class="fa fa-calendar" aria-hidden="true"></i>' +
|
'</span></div><div class="search_column_button search_column_button_box">' +
|
'<span><button class="btn btn-info btn-action" id="search_condition"><i class="fa fa-search" aria-hidden="true"></i> 查询</button></span>' +
|
'</div></div>' +
|
'<div class="condition_search_footer" style="display:none">' +
|
'<label class="first">' +
|
'<span><select class="ng-pristine ng-untouched ng-valid ng-not-empty" id="pageSelect">' +
|
'<option value="20" selected="selected">20条/页</option>'
|
'<option value="50"> 50条/页</option><option value="100">100条/页</option>' +
|
'</select></span><span class="ng-binding">共<span id = "showTotalPageLeft"></span>页</span></label>' +
|
'<label class="second"> <div class="pagination">' +
|
'<span class="skip first">首页</span><span class="skip pre">上一页</span>' +
|
'<div class="nums"></div><span class="skip next">下一页</span>' +
|
'<span class="skip last">尾页</span></div></label></div>';
|
mymoduleheader.innerHTML = header;
|
mymodulefooter.innerHTML = footer;
|
mymodule.setAttribute('style', 'width:750px;height: 448px;margin:0 auto;');
|
menuContent.setAttribute('id', $iconId + 'menuContent');
|
menuContent.setAttribute('class', 'menuContent');
|
bigmodule.setAttribute('class', 'bigmodule');
|
mymodule.setAttribute('class', 'mymodule');
|
mymodule2.setAttribute('class', 'mymodule2 mymodule2_box');
|
modal_content.setAttribute('class', 'modal-content modal_content_box');
|
mymodulebody.setAttribute('class', 'mymodulebody');
|
$(mymodulebody).css({ "height": "485px", "overflow-y": "auto" });
|
mymoduleheader.setAttribute('class', 'mymoduleheader');
|
mymodulefooter.setAttribute('class', 'mymodulefooter');
|
myinput.setAttribute('class', 'myipt');
|
divIcons.setAttribute('class', 'mytext');
|
divIcons.setAttribute('id', $iconId + 'divIcons');
|
page.setAttribute('id', $iconId + 'pageF');
|
page.setAttribute('class', 'pageF');
|
pageBox.setAttribute('id', $iconId + 'pageBox');
|
pageBox.setAttribute('class', 'pageBox');
|
buttonDiv.setAttribute("class", "buttonDiv");
|
requersTable.setAttribute("class", "requestMenu");
|
$('#' + $iconId + 'ActiveId').append(menuContent);
|
$('#' + $iconId + 'menuContent').append(bigmodule);
|
bigmodule.appendChild(mymodule);
|
mymodule.appendChild(mymodule2);
|
mymodule2.appendChild(modal_content);
|
modal_content.appendChild(mymodulebody);
|
mymodulebody.appendChild(mymoduleheader);
|
mymodulebody.appendChild(serchpage);
|
mymodulebody.appendChild(mybtn);
|
mymodulebody.appendChild(serchbox);
|
mymodulebody.appendChild(divIcons);
|
mymodulebody.appendChild(mymodulefooter);
|
mymodulebody.appendChild(myinput);
|
pageBox.appendChild(page);
|
// $('.mytext').append(sersrc);
|
// $('.mytext').append(buttonDiv);
|
$('#' + $iconId + 'divIcons').append(requersTable);
|
$('#' + $iconId + 'divIcons').append(pageBox);
|
var lastPage = "";
|
customBase.findmay = {
|
"formId": formId,
|
"sCondition": sCondition,
|
"formhuixian": formhuixian,
|
"head": head,
|
"iconId": $iconId,
|
"addVal": addVal
|
}
|
var count = fenye("5", "1", formId, sCondition, formhuixian, head, $iconId, addVal, []);
|
|
lastPage = Math.ceil(count / 5);
|
//console.log($(".pageF"))
|
$(".pageF").paging({
|
pageNo: 1,
|
totalPage: lastPage,
|
totalSize: count,
|
callback: function (num) {
|
console.log(num);
|
fenye("5", num, formId, sCondition, formhuixian, head, $iconId, addVal, []);
|
}
|
});
|
}
|
//如果存在就移除
|
} else {
|
$('#' + $iconId + 'menuContent').remove();
|
}
|
} else {
|
alert('未选择表单')
|
}
|
// 调用查询方法10/18
|
findserch();
|
});
|
//条形码点击事件
|
$('.barcodeShowClass').unbind();
|
$('.barcodeShowClass').on('click', function () {
|
var editable = $(this)[0].getAttribute("editable");
|
//编辑设定
|
if (editable == "false") {
|
return;
|
}
|
|
$(this).addClass("cfg_contentNone");
|
$("#" + $(this)[0].id + "barcode").removeClass("cfg_contentNone");
|
$("#" + $(this)[0].id + "barcode").focus();
|
});
|
//条形码焦点离开事件
|
$('.barcodeShowTextClass').unbind();
|
$('.barcodeShowTextClass').on('blur', function () {
|
var id = $(this)[0].id;
|
//表示的控件ID取得
|
var idTemp = id.replace("barcode", "");
|
// //默认数值
|
// var defaultSize = {
|
// width:$("#"+idTemp)[0].width,
|
// height:$("#"+idTemp)[0].height,
|
// defaultvalue:"",
|
// styleclass:""
|
// };
|
// var size = $("#"+idTemp)[0].getAttribute("size");
|
var showCustomItem = customShow.options.customItemShow.item[idTemp];
|
// var size = $("#"+idTemp)[0].getAttribute("size");
|
var size = showCustomItem.tag_Attribute.size;
|
// defaultSize.defaultvalue = $(this)[0].value;
|
customBase.createbarcode(size, $(this)[0].value, function (text, barWidth, barHeight, sizeWidthHeight) {
|
$("#canvasbarcode").remove();
|
$(document.body).append('<div id="canvasbarcode" style="display: none;"></div>');
|
// //设值 距离左侧距离 margin-left: -2px;
|
// if(barWidth == 1){
|
// $("."+idTemp+"value").addClass("barcodeMarginleft1");
|
// }else if(barWidth == 2){
|
|
// }else if(barWidth == 3){
|
|
// }else if(barWidth == 4){
|
|
// }else if(barWidth == 5){
|
|
// }else if(barWidth == 6){
|
|
// }
|
// $("."+idTemp+"value").addClass("barcodeMarginleft"+barWidth);
|
|
jQuery('#canvasbarcode').barcode(text, "code128", { barWidth: barWidth, barHeight: barHeight, showHRI: true });
|
var canvasbarcode = $("#canvasbarcode")[0].innerHTML;
|
sizeWidthHeight.width = $("#canvasbarcode")[0].style.width;
|
|
customBase.amount2Image(canvasbarcode, "barcode", sizeWidthHeight, function (amountHtml) {
|
$("#" + idTemp + "barcode").addClass("cfg_contentNone");
|
for (var i = 0; i < $("." + idTemp + "value").length; i++) {
|
$("." + idTemp + "value")[i].setAttribute("src", amountHtml);
|
};
|
$("#" + idTemp).removeClass("cfg_contentNone");
|
});
|
});
|
});
|
//二维码点击事件
|
$('.qrcodeShowClass').unbind();
|
$('.qrcodeShowClass').on('click', function () {
|
var editable = $(this)[0].getAttribute("editable");
|
//编辑设定
|
if (editable == "false") {
|
return;
|
}
|
|
$(this).addClass("cfg_contentNone");
|
$("#" + $(this)[0].id + "qrcode").removeClass("cfg_contentNone");
|
$("#" + $(this)[0].id + "qrcode").focus();
|
});
|
|
//二维码焦点离开事件
|
$('.qrcodeShowTextClass').unbind();
|
$('.qrcodeShowTextClass').on('blur', function () {
|
var id = $(this)[0].id;
|
//表示的控件ID取得
|
var idTemp = id.replace("qrcode", "");
|
var showCustomItem = customShow.options.customItemShow.item[idTemp];
|
// var widthqrcode = $("#"+idTemp)[0].width;
|
// var heightqrcode = $("#"+idTemp)[0].height;
|
var widthqrcode = showCustomItem.tag_Attribute.width;
|
var heightqrcode = showCustomItem.tag_Attribute.height;
|
if (heightqrcode == 0 || heightqrcode == undefined) {
|
heightqrcode = 60;
|
}
|
if (widthqrcode == 0 || widthqrcode == undefined) {
|
widthqrcode = 60;
|
}
|
//默认数值
|
var defaultSize = {
|
width: widthqrcode,
|
height: heightqrcode,
|
defaultvalue: "",
|
styleclass: ""
|
};
|
// var size = $("#"+idTemp)[0].getAttribute("size");
|
|
defaultSize.defaultvalue = $(this)[0].value;
|
$("#canvasqrcode").remove();
|
$(document.body).append('<div id="canvasqrcode" style="display: none;"></div>');
|
jQuery('#canvasqrcode').qrcode({ width: defaultSize.width, height: defaultSize.height, text: $(this)[0].value });
|
var mycanvas = $("#canvasqrcode").find("canvas")[0];
|
var image = mycanvas.toDataURL("image/png");
|
$("#" + idTemp + "qrcode").addClass("cfg_contentNone");
|
for (var i = 0; i < $("." + idTemp + "value").length; i++) {
|
$("." + idTemp + "value")[i].setAttribute("src", image);
|
};
|
|
$("#" + idTemp).removeClass("cfg_contentNone");
|
});
|
}
|
// 禁用树的父节点 12/9
|
customShow.setTree = {
|
disableParentNode: {
|
set: function (treeObj) {
|
if (treeObj) {
|
var nodes = treeObj.getNodes();
|
var level = 0;
|
// 获取最底层的层数
|
treeObj.getNodesByFilter(function (node) {
|
if (level < node.level) {
|
level = node.level;
|
}
|
}); // 查找不是最底层的节点集合
|
var nodesFilter = treeObj.getNodesByFilter(function (node) {
|
return (node.level != level)
|
});
|
//父节点禁止勾选
|
for (var i = 0; i < nodesFilter.length; i++) {
|
treeObj.setChkDisabled(nodesFilter[i], true);
|
}
|
}
|
}
|
}
|
}
|
|
customShow.addtree = function (itemId, item) {
|
console.log(customBase.settingRadioType)
|
//修改克隆树的实例化 马习同2017-11-21
|
console.log(customShow.options.customItemShow.item)
|
var customItem = customShow.options.customItemShow.item;
|
var ztree = {};
|
for (let key in customItem) {
|
if (customItem[key].tag_Type == "tree") {
|
ztree[key] = customItem[key];
|
}
|
}
|
$('.zTreeDemoBackground').css("display", "none");
|
$(".search_input").css("display", "none");
|
var index = 0;
|
var treeObj;
|
// var disableparentnode = false;
|
for (let key in ztree) {
|
if ($(item).find("#" + key).find('.ztree').parent().attr('disableparentnode') == "true") {
|
$(item).find("#" + key).find('.ztree').attr("id", key + "tree" + index_i);//修改克隆树的id 马习同2017-11-21
|
if (ztree[key].tag_Attribute.dropdowntype == "single") {
|
$.fn.zTree.init($($(".customViewUEditorCss #" + key + "tree" + index_i)), customBase.settingRadioType, customShow.listData[key]);
|
// 12/2 树展开
|
treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
|
customShow.setTree.disableParentNode.set(treeObj)
|
if (treeObj) {
|
treeObj.expandAll(true);
|
}
|
} else if (ztree[key].tag_Attribute.dropdowntype == "multiple") {
|
$.fn.zTree.init($($(".customViewUEditorCss #" + key + "tree" + index_i)), customBase.settingChkboxType, customShow.listData[key]);
|
treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
|
customShow.setTree.disableParentNode.set(treeObj)
|
if (treeObj) {
|
treeObj.expandAll(true);
|
}
|
}
|
} else {
|
$(item).find("#" + key).find('.ztree').attr("id", key + "tree" + index_i);//修改克隆树的id 马习同2017-11-21
|
if (ztree[key].tag_Attribute.dropdowntype == "single") {
|
$.fn.zTree.init($($(".customViewUEditorCss #" + key + "tree" + index_i)), customBase.settingRadioType, customShow.listData[key]);
|
// 12/2 树展开
|
treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
|
console.log(treeObj)
|
if (treeObj) {
|
treeObj.expandAll(true);
|
}
|
} else if (ztree[key].tag_Attribute.dropdowntype == "multiple") {
|
$.fn.zTree.init($($(".customViewUEditorCss #" + key + "tree" + index_i)), customBase.settingChkboxType, customShow.listData[key]);
|
treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
|
console.log(treeObj)
|
if (treeObj) {
|
treeObj.expandAll(true);
|
}
|
}
|
}
|
// 克隆后选中节点 12/7 李元杰
|
if (!_.isNull(treeObj)) {
|
var treeId = treeObj['setting'].treeId;
|
var defaultValue = $('#' + treeId).parent().attr('defaultvalue');
|
// // 12/7 默认值
|
if (defaultValue != '') {
|
console.log(treeObj)
|
customShow.treeDefaultSet(treeObj, defaultValue);
|
}
|
}
|
|
}
|
console.log(treeObj)
|
console.log($(item))
|
//修改克隆树的实例化End 马习同2017-11-21
|
index_i++;
|
|
}
|
|
//子表单项目追加
|
customShow.addsubformList = function (subformAdd, showClass) {
|
console.log(i)
|
var allcopy = subformAdd.getAttribute('allcopy');
|
var itemId = subformAdd.getAttribute('itemId');
|
//单行记录更新
|
if (allcopy == "false") {
|
console.log(customBase.options.customItems);
|
console.log(customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv);
|
var item = customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv;
|
// 子表单隐藏 马习同 11-13
|
// var item =$("."+showClass+" #"+itemId+"save").children()[0];
|
//子表单情况为U情况
|
if (item == undefined) {// 子表单回显 修改 李伟民 11-10
|
var tbody = $("." + showClass + " #" + itemId + "ActiveId").find("tbody");
|
tbody = tbody[0].cloneNode(true);
|
console.log(tbody)
|
// 清空input 12/7
|
console.log($(item))
|
if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') == '') {
|
$(item).find(".citySel").val('');
|
}
|
$(tbody).find(".select2").remove();
|
console.log($(tbody).html());
|
$(tbody).find(".tdTitleClass").closest("tr").addClass("table_title");
|
$(tbody).find(".dropdowntypeCss").select2({ theme: "classic" });
|
// $(tbody).find(".zTreeDemoBackground").select2({theme: "classic"});
|
if ($(tbody).find(".table_title").length > 0) {
|
//删除头行
|
$(tbody).find(".table_title").remove();
|
}
|
if ($(tbody).find(".trContentClass").length > 1) {// 去除重复的tr 李伟民 11-14
|
$($(tbody).find(".trContentClass")[0]).siblings().remove();
|
}// 去除重复的tr 李伟民 11-14
|
// $(tbody).find(".cfg_contentNone").removeClass("cfg_contentNone");
|
tbody = customShow.addsubformListInit(itemId, $(tbody).find("tr"));
|
console.log(tbody);
|
console.log(itemId);
|
console.log($(tbody).find("#" + itemId).attr("class"));
|
$(tbody).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
|
$(tbody).find("input").attr("checkfunarr", "");
|
$(tbody).find(".select_get").attr("funarr", "");
|
$(tbody).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
|
$($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(tbody);// 子表单回显 修改 李伟民 11-10
|
customShow.hidesubform();
|
customShow.setXhSelectList(false);//添加记录 重复问题 李伟民11-14
|
} else {
|
item = item[0].cloneNode(true);
|
// 12/7 清空input
|
var defaultvalue = $(item).find('.zTreeDemoBackground').attr('defaultvalue');
|
var itemIdTree = $(item).find('.ztree').attr('id');
|
var treeObj = $.fn.zTree.getZTreeObj(itemIdTree);
|
console.log(treeObj)
|
// 12/7 默认值
|
if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') == '') {
|
$(item).find(".citySel").val('');
|
}
|
$(item).find(".select2").remove();
|
$(item).find(".dropdowntypeCss").select2({ theme: "classic" });
|
$(item).find(".subformAddiconShow .cfg_contentNone").removeClass("cfg_contentNone");
|
item = customShow.addsubformListInit(itemId, item);
|
$(item).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
|
$(item).find("input").attr("checkfunarr", "");
|
$(item).find(".select_get").attr("funarr", "");
|
$(item).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
|
$($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(item);
|
customShow.setXhSelectList(true);//添加记录 重复问题 李伟民11-14
|
}
|
|
customShow.addtree(itemId, item);
|
//子表单事件追加
|
} else {
|
//全子表单复制
|
// //console.log(1);
|
|
var item = $("." + showClass + " #" + itemId + "ActiveId")[0];
|
// //console.log(item);
|
item = item.cloneNode(true);
|
//console.log(item);
|
var divIcons = document.createElement("div");
|
divIcons.setAttribute("class", "frm_item_icons allCopyCss");
|
var divIcon = document.createElement("div");
|
divIcon.setAttribute("class", "frm_item_icon remove");
|
var divIconImg = document.createElement("i");
|
divIconImg.setAttribute("class", "icon iconfont icon-iconfontcolor93 iconfontcolor");
|
divIconImg.setAttribute("style", "text-align: left;font-size: 18px;color: red;");
|
// var divIconImg = document.createElement("img");
|
// divIconImg.setAttribute("src", "./../../css/img/icon/delete.png");
|
divIcon.appendChild(divIconImg);
|
divIcons.appendChild(divIcon);
|
// $(item).find(".icon-jiahao").parent().addClass("cfg_contentNone");
|
$(item).append(divIcons);
|
// 清空 树的input
|
console.log($(item))
|
if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') != '') {
|
|
} else {
|
$(item).find(".citySel").val('');
|
}
|
$(item).find(".select2").remove();
|
$(item).find(".dropdowntypeCss").select2({ theme: "classic" });
|
//console.log(item);
|
item = customShow.addsubformListInit(itemId, item);
|
// 10/23添加子表单记录
|
var beforeitem = $("." + showClass + " #" + itemId + "ActiveId");
|
//console.log(beforeitem);
|
$(item).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
|
$(item).find("input").attr("checkfunarr", "");
|
$(item).find(".select_get").attr("funarr", "");
|
$(item).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
|
$("." + showClass + " #" + itemId + "ActiveId").eq(0).after(item);
|
// _.each(beforeitem,function(bitem){
|
if (beforeitem.length > 1) {
|
for (var i = 0; i < beforeitem.length - 1; i++) {
|
$(beforeitem[i]).find(".icon-jiahao").parent().addClass("cfg_contentNone");
|
}
|
} else {
|
$(beforeitem[0]).find(".icon-jiahao").parent().addClass("cfg_contentNone");
|
}
|
customShow.setXhSelectList();//添加记录 重复问题 李伟民11-14
|
// });
|
customShow.addtree(itemId, item);
|
}
|
}
|
//马习同修改 子表单隐藏 11/13
|
customShow.hidesubform = function () {
|
// console.log($("[tag_type='subform']"))
|
_.each($("[tag_type='subform']"), opt => {
|
console.log(opt)
|
$($(opt).find(".tdTitleClass")[0]).addClass("cfg_contentNone");
|
$($(opt).find(".tdContentClass")[0]).addClass("cfg_contentNone");
|
})
|
var unvisible = customBase.options.customItems;
|
var unvisibleArr = [];
|
_.each(unvisible, opt => {
|
if (opt.visible == false && opt.parentsubFormNum != 0) {
|
unvisibleArr.push(opt)
|
}
|
})
|
// _.remove(unvisibleArr,n => {
|
// return n.fieldKey == "DATAROWNUM";
|
// })
|
// console.log(unvisibleArr)
|
_.each(unvisibleArr, opt => {
|
$("[id='" + opt.id + "']").parent().parent().addClass("cfg_contentNone");
|
$($(".customShow #itemId_" + opt.parentsubFormNum + " .tdTitleClass")[$("[id='" + opt.id + "']").parent().parent().index()]).addClass("cfg_contentNone");
|
$($(".customViewUEditorCss #itemId_" + opt.parentsubFormNum + " .tdTitleClass")[$("[id='" + opt.id + "']").parent().parent().index()]).addClass("cfg_contentNone");
|
})
|
}
|
//子表单内数据初始化
|
customShow.addsubformListInit = function (itemId, tbodys) {
|
//console.log(tbodys);
|
var itemList = customShow.options.customItemShow.item;
|
var item = itemList[itemId];
|
var parentsubFormNum = item.columnOrderNum + "";
|
|
for (itemListId in itemList) {
|
if (itemList.hasOwnProperty(itemListId)) {
|
if (itemList[itemListId].parentsubFormNum == parentsubFormNum) {
|
//子表单内控件确认
|
var type = itemList[itemListId].tag_Type;
|
if (type == "text" || type == "textarea" || type == "number") {
|
$(tbodys).find("#" + itemListId)[0].value = itemList[itemListId].tag_Attribute.defaultvalue;
|
} else if (type == "calendar") {
|
$(tbodys).find("#" + itemListId)[0].value = "";
|
} else if (type == "radio") {
|
|
} else if (type == "checkbox") {
|
|
} else if (type == "dropdownlist") {
|
var itemListIdTemp = itemListId + "_" + customShow.options.dropdownlist_I;
|
var item = $(tbodys).find("#" + itemListId);
|
////////console.log($(tbodys));
|
// var dropdowntype = $(item.find('select'))[0].getAttribute("dropdowntype");
|
var dropdowntype = customShow.options.customItemShow.item[itemListId].tag_Attribute.dropdowntype;
|
if ($("#" + itemListId + " .select3-element")[0] == undefined) {
|
var width = $(tbodys).find("#" + itemListId)[0].style.width.replace("px", "");
|
} else {
|
var width = $("#" + itemListId + " .select3-element")[0].style.width.replace("px", "");
|
}
|
|
width = parseInt(width);
|
var listData = customBase.options.dropdownlistText[itemListId];
|
////////console.log(customBase.options.dropdownlistText);
|
// $("#"+itemId).parent().empty();
|
var itemIdClass = "selectClass js-example-basic-single defaultHeight customShowItemClass dropdowntypeCss " + itemListId + "value " + itemListIdTemp;
|
var DropdownlistItem = item.parent();
|
// DropdownlistItem.css("background-color","red");
|
// var setDiv = $('<div id="'+itemListId+'" class="selectClass '+itemIdClass+'"></div>');
|
var setDiv = $('<div id="' + itemListId + '" class="selectClass lwm' + itemIdClass + '"></div>');
|
console.log("11122211")
|
DropdownlistItem.empty();
|
setDiv.empty();
|
console.log(itemListId);
|
DropdownlistItem.append(setDiv);
|
console.log($(DropdownlistItem).html());
|
//////console.log(dropdowntype);
|
|
if (dropdowntype == "multiple") {
|
customShow.options.subformDList[itemListIdTemp] = {
|
selectId: itemListId,
|
multiple: true,
|
width: width,
|
// listData:listData,
|
}
|
} else {
|
customShow.options.subformDList[itemListIdTemp] = {
|
selectId: itemListId,
|
multiple: false,
|
width: width,
|
// listData:listData,
|
}
|
}
|
// if(dropdowntype == "multiple"){
|
// xhSelect.setXhSelect(
|
// {
|
// selectId:itemListId,
|
// multiple:true,
|
// width: width,
|
// listData:listData,
|
// setDiv:setDiv
|
// // setDiv:itemListIdTemp
|
// }
|
// );
|
// }else{
|
// xhSelect.setXhSelect(
|
// {
|
// selectId:itemListId,
|
// multiple:false,
|
// width: width,
|
// listData:listData,
|
// setDiv:setDiv
|
// // setDiv:itemListIdTemp
|
// }
|
// );
|
// }
|
|
}
|
}
|
customShow.options.dropdownlist_I++;
|
}
|
|
}
|
//console.log(customShow);
|
//console.log(customBase);
|
|
////////console.log(customShow.options.customItemShow.item);
|
////////console.log(itemId);
|
////////console.log(item);
|
////////console.log(parentsubFormNum);
|
// customShow.setXhSelectList();
|
return tbodys;
|
}
|
//驳回
|
customShow.rejectBtn = function () {
|
var flag = true;//true驳回 false不驳回
|
over(flag)
|
}
|
//提交
|
customShow.onclickSubmit = function () {
|
get();
|
}
|
//查看票据
|
customShow.checkbill = function () {
|
window.open("./../bill_img/bill.html")
|
}
|
//审批
|
customShow.auditableBtn = function () {
|
auditableBtn();
|
}
|
function auditableBtn() {
|
var processLog = JSON.parse(localStorage.getItem("processLog"));
|
if (processLog != null && processLog != undefined) {
|
} else {
|
alert("请先创建一个流程");
|
return null;
|
}
|
if (processLog[0].processState == 60) {
|
alert("流程已结束");
|
return null;
|
}
|
var inputs = "<h3 class='sp_title'>请输入审批语</h3><br/>" + "<textarea maxlength='200' onKeyUp='listenword()' class='stexta' type='test' id='datas'></textarea><span class='wordwrap'><var class='word'>0</var>/200</span><br/>"
|
+ "<div class='footerbtn' style='display:flex;justify-content:space-around;'><input class='btn btn-default choosebtn' type='button' value='取消' onclick='zhixing(false)'/><input class='btn btn-default choosebtn2' type='button' value='确定' onclick='zhixing(true)'/></div>";
|
$("#liucheng").html(inputs);
|
$("#auditableBtn")[0].setAttribute('data-toggle', "modal");
|
$("#auditableBtn")[0].setAttribute('data-target', ".bs-example-modal-sm");
|
}
|
customShow.onclickSave1 = function () {
|
// SC.sendanydata(function(flag){
|
// console.log(flag);
|
// if(!flag){
|
// console("if")
|
// customShow.onclickSave(1);
|
// }else{
|
|
// alert("错误");
|
// }
|
// });
|
SC.sendanydata(customShow.onclickSave, 1)
|
|
|
}
|
customShow.onclickSave2 = function () {
|
SC.sendanydata(customShow.onclickSave, 2)
|
}
|
|
//清空按钮按下是
|
customShow.onclickClear = function () {
|
console.log(customBase);
|
console.log(customShow);
|
var itemKey = _.keys(customShow.options.customItemShow.item);
|
var item = customShow.options.customItemShow.item;
|
console.log(itemKey);
|
_.each(itemKey, function (itemId) {
|
console.log(itemId);
|
console.log(item[itemId].tag_Type);
|
customBase.setItemValue(itemId, item[itemId].tag_Type, "", "");
|
});
|
}
|
//保存按钮按下时
|
customShow.onclickSave = function (clickFlag) {
|
console.log(clickFlag);
|
var saveReturn = customShow.initEvent.fromSaveLinkage();
|
|
//画面项目取得 --------------------------画面项目取得------
|
var items = customShow.getItems(true);
|
console.log(items)
|
// customShow.queryCost();
|
try {
|
if (typeof (eval(eachitem)) == "function") {
|
eachitem(items);
|
}
|
} catch (e) {
|
console.log("不存在的函数");
|
}
|
|
console.log("遍历数组")
|
console.log(items);
|
// 画面check
|
var returnfromCheck = customShow.initEvent.fromCheck(items); //--------------------
|
if (returnfromCheck) {
|
return;
|
}
|
// 03检证执行
|
var check = customShow.initEvent.validationRuleCheck(items); //--------------------
|
if (!check) {
|
return;
|
}
|
// 检证接口函数
|
var check = customShow.initEvent.validationRuleCheck3rd(items); //-----------需要对验证进行解析---------
|
if (!check) {
|
return;
|
}
|
// 提取数据 生成数据json 同customShow.getItems()
|
//公式保存接口
|
// var saveReturn = customShow.initEvent.fromSaveLinkage(items);
|
// if(!saveReturn){
|
// return;
|
// }
|
// 发送数据到后台服务器,保存data
|
var saveReturn = customShow.initEvent.fromSave3rd(items);//--------------------
|
console.log(customShow.options.customShowFlag)
|
if (saveReturn) {
|
console.log(1)
|
if (customShow.options.customShowFlag == "1") {
|
//保存
|
customDataBound.fromSave(customShow.options.formid, items, function (rs) {
|
if (rs.rspCode == "000000") {
|
var strMessage = customBase.getMessage("mesage_ID015");
|
customBase.alert("S", strMessage);
|
// return;
|
}
|
if (rs.rspCode == "100004") {
|
var strMessage = customBase.getMessage("mesage_ID007");
|
customBase.alert("E", strMessage);
|
return;
|
}
|
if (customShow.options.customShowFlag == "1") {
|
window.parent.$('#myModal').modal('hide');
|
window.parent.addFormData(rs);
|
$(window.parent.document.body).css({ "overflow-x": "auto", "overflow-y": "auto" });
|
}
|
// //////console.log(rs);
|
});
|
} else if (customShow.options.customShowFlag == "2") {
|
console.log(2)
|
//保存
|
customDataBound.fromEdit(customShow.options.formid, items, customShow.options.dataRowNum, function (rs) {
|
if (rs.rspCode == "100004") {
|
var strMessage = customBase.getMessage("mesage_ID007");
|
customBase.alert("E", strMessage);
|
return;
|
}
|
customShow.options.breakFlag = true;
|
//预览模式表示
|
$("#customViewUEditor")[0].style.display = "none";
|
//马习同 2018-1-2 布局修改
|
$("#customShow")[0].style.display = "flex";
|
// $(".footer")[0].style.display ="none";
|
|
var btns = [
|
'printableBtn',
|
// 'exportBtn',
|
// 'rejectBtn',
|
// 'submitBtn',
|
// 'auditableBtn',
|
// 'queryBtn',
|
// 'createBtn',
|
// 'clearBtn',
|
// 'disposableBtn',
|
// 'fromSaveBtn',
|
'editableBtn'
|
];
|
customShow.showCustom(items, customShow.options.customInit);
|
customShow.setToolBtn(btns);
|
console.log("关闭")
|
customShow.onclickCancel();
|
|
});
|
// customShow.onclickCancel();
|
}
|
else if (customShow.options.customShowFlag == "3") {
|
// 保存
|
console.log(3)
|
if (clickFlag == 2 && customShow.options.dataRowNum != "") {
|
//保存
|
customDataBound.fromEdit(customShow.options.formid, items, customShow.options.dataRowNum, function (rs) {
|
////console.log(rs);
|
if (rs.rspCode == "000000") {
|
var strMessage = customBase.getMessage("mesage_ID015");
|
customBase.alert("S", strMessage);
|
// return;
|
}
|
if (rs.rspCode == "100004") {
|
var strMessage = customBase.getMessage("mesage_ID007");
|
customBase.alert("E", strMessage);
|
return;
|
}
|
// customShow.options.breakFlag = true;
|
// //预览模式表示
|
// $("#customViewUEditor")[0].style.display ="none";
|
// $("#customShow")[0].style.display ="block";
|
// // $(".footer")[0].style.display ="none";
|
// customShow.showCustom(items,customShow.options.customInit);
|
});
|
//新建
|
} else {
|
customDataBound.fromSave(customShow.options.formid, items, function (rs) {
|
if (rs.rspCode == "000000") {
|
var strMessage = customBase.getMessage("mesage_ID015");
|
customBase.alert("S", strMessage);
|
// return;
|
}
|
if (rs.rspCode == "100004") {
|
var strMessage = customBase.getMessage("mesage_ID007");
|
customBase.alert("E", strMessage);
|
return;
|
}
|
// if(customShow.options.customShowFlag == "1" ){
|
// window.parent.$('#myModal').modal('hide');
|
// window.parent.addFormData(rs);
|
// $(window.parent.document.body).css({"overflow-x": "auto","overflow-y": "auto"});
|
// }
|
if(customShow.options.customShowFlag != "3" ){//发布差异修改 李伟民 0120
|
customShow.options.dataRowNum = rs.data.dataRowNum;
|
}
|
//////console.log(rs);
|
});
|
}
|
}
|
}
|
// customShow.onclickCancel();
|
// window.parent.$('#myModal').modal('hide');
|
// console.log($('.boxOne'))
|
// $('.boxOne').css("display","none");
|
}
|
|
//保存按钮按下时(项目预览表示)
|
customShow.showCustom = function (items, customInit) {
|
console.log(items);
|
console.log(customInit);
|
customShow.options.customItemShow = customInit.customViewItem;
|
var customItem = customShow.options.customItemShow;
|
// $(".preview-edit-pane").css("display","block");
|
// $(".footer")[0].style.display ="block";
|
// $(".footer .fromSaveCss")[0].style.display ="none";
|
|
var divHtml = customItem.formeditor;
|
|
$("#customShow").empty();
|
$("#customShow")[0].innerHTML = divHtml;
|
var height = customShow.options.customItemShow.height;
|
// height = parseInt(height)-50;
|
//////////console.log(height);
|
$("#customShow")[0].style.height = height + "px";
|
$("#customShow")[0].style.width = customShow.options.customItemShow.width;
|
$("#customShow")[0].style.display = "flex";
|
var customItems = customBase.options.customItems;
|
|
//数据值变换
|
for (item in customItems) {
|
if (customItems.hasOwnProperty(item)) {
|
if (customItems[item] == undefined) {
|
delete customItems[item];
|
continue;
|
}
|
if (customItems[item].type == 'subform') {
|
var subformTemp = items[item];
|
//////console.log(items);
|
////console.log(item);
|
console.log(subformTemp);
|
// console.log(customItems);
|
if (subformTemp == undefined) {
|
subformTemp = [{}];
|
}
|
for (subformItem in subformTemp[0]) {
|
if (subformTemp[0].hasOwnProperty(subformItem)) {
|
items[subformItem] = [];
|
}
|
}
|
for (var i = 0; i < subformTemp.length; i++) {
|
if (i != 0) {
|
//子表单项目追加
|
var subformAdd = $(".customShow #" + customItems[item].id + "ActiveId .subformAdd")[0];
|
customShow.addsubformList(subformAdd, "customShow");
|
}
|
for (subformItem in subformTemp[i]) {
|
if (subformTemp[i].hasOwnProperty(subformItem)) {
|
items[subformItem][i] = subformTemp[i][subformItem];
|
}
|
}
|
};
|
}
|
//选项卡回显
|
if (customItems[item].type == 'tag') {
|
var subformTemp = items[item];
|
////console.log(items);
|
////console.log(item);
|
////console.log(subformTemp);
|
////console.log(customItems);
|
if (subformTemp == undefined) {
|
subformTemp = [{}];
|
}
|
for (subformItem in subformTemp[0]) {
|
if (subformTemp[0].hasOwnProperty(subformItem)) {
|
items[subformItem] = [];
|
}
|
}
|
for (var i = 0; i < subformTemp.length; i++) {
|
if (i != 0) {
|
//子表单项目追加
|
var subformAdd = $(".customShow #" + customItems[item].id + "ActiveId .subformAdd")[0];
|
customShow.addsubformList(subformAdd, "customShow");
|
}
|
for (subformItem in subformTemp[i]) {
|
if (subformTemp[i].hasOwnProperty(subformItem)) {
|
items[subformItem][i] = subformTemp[i][subformItem];
|
}
|
}
|
};
|
}
|
}
|
}
|
|
customShow.options.subformDValue = items;
|
//表示项目进行变换
|
|
//画面项目初期化
|
customShow.controlInit("customShow");
|
|
//删除项目(select2项目删除)
|
$('.customShow .selection').remove();
|
//console.log(customItems);
|
//数据设定
|
for (item in customItems) {
|
console.log(items)
|
if (customItems.hasOwnProperty(item)) {
|
if (customItems[item] == undefined) {
|
delete customItems[item];
|
continue;
|
}
|
|
var type = customItems[item].type;
|
var id = customItems[item].id;
|
var value = items[item];
|
// value = [{"tId":"itemId_1tree_2"},{"name":"F066008"},{"tId":"itemId_1tree_3"},{"name":"F066003"}];
|
// value = [{"name":"F066008"},{"name":"F066003"}];
|
// value = [{"name":"F066008"},{"name":"F066003"}];
|
|
if (customItems[item].type == 'subform') {
|
$(".customShow").find("#" + id + "subform").find("td").addClass("");
|
} else if (customItems[item].type == 'htmlediter') {
|
// var htmlediterShow = $(".customShow").find("#"+id)[0];
|
var htmlediterShow = $(".customShow #" + id + "Item")[0];
|
// var heightShow = $(htmlediterShow)[0].getAttribute("heightShow");
|
// var widthShow = $(htmlediterShow)[0].getAttribute("widthShow");
|
var heightShow = customShow.options.customItemShow.item[id].tag_Attribute.height;
|
var widthShow = customShow.options.customItemShow.item[id].tag_Attribute.width;
|
if (widthShow == undefined || heightShow == undefined) {
|
widthShow = 200;
|
heightShow = 200;
|
}
|
var oNode = '<div style="word-break:break-all;width:' + widthShow + 'px;height:' +
|
heightShow + 'px;" class="customShowItemClass edui-default customShowItemClassTemp">';
|
// var oNode ='<div style="word-break:break-all;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);class="customShowItemClass edui-default">';
|
oNode += value;
|
oNode += "</div>";
|
$($(".customShow #" + id + "Item")[0]).after(oNode);
|
$($(".customShow #" + id + "Item")[0]).remove();
|
//标签数据设定
|
} else if (customItems[item].type == 'textarea') {
|
var htmlediterShow = $(".customShow #" + id)[0];
|
var heightShow = customShow.options.customItemShow.item[id].tag_Attribute.height;
|
var widthShow = customShow.options.customItemShow.item[id].tag_Attribute.width;
|
if (widthShow == undefined || heightShow == undefined) {
|
widthShow = 300;
|
heightShow = 80;
|
}
|
var oNode = '<div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:' + widthShow + 'px;height:' +
|
heightShow + 'px;" class="customShowItemClass edui-default customShowItemClassTemp">';
|
// var oNode ='<div style="word-break:break-all;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);class="customShowItemClass edui-default">';
|
oNode += value;
|
oNode += "</div>";
|
$($(".customShow #" + id)[0]).after(oNode);
|
$($(".customShow #" + id)[0]).remove();
|
//标签数据设定
|
} else if (customItems[item].type == 'number') {
|
var numberShowItems = $(".customShow #" + id);
|
for (var i = 0; i < numberShowItems.length; i++) {
|
numberShowItems[i].setAttribute("type", "text");
|
}
|
|
//标签数据设定
|
} else if (customItems[item].type == 'link') {
|
var htmlediterShow = $(".customShow").find("#" + id)[0];
|
// console.log($(htmlediterShow))
|
// $(htmlediterShow)[0].setAttribute("href","javascript:;");
|
$(htmlediterShow).css("font-size", "16px;");
|
//单选 多选按钮
|
} else if (type == 'radio' || type == 'checkbox' || type == 'dropdownlist') {
|
|
var oNode = '<div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClassTemp customShowItemClass ' + id + '_showItem edui-default">';
|
oNode += "</div>";
|
// $($(".customShow").find("#"+id)[0]).after(oNode);
|
// $($(".customShow").find("#"+id)[0]).remove();
|
var showItem = $($(".customShow").find("#" + id));
|
console.log(showItem)
|
for (var i = 0; i < showItem.length; i++) {
|
$($(showItem[i])[0]).after(oNode);
|
$($(showItem[i])[0]).remove();
|
}
|
console.log(value)
|
//单选复选回显问题
|
customShow.setShowItem(id, type, value, true);
|
}
|
else if (customItems[item].type == 'tree') {
|
//普通模式树形回显 李伟民 0130
|
var oNode = '<div treeitemid=' + id + ' style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClass edui-default customShowItemClassTemp">';
|
// 2017 /11/7 李元杰 树的回显
|
// var treeShow = $('#customShow').find('div[type=tree]');
|
|
// if(value !=undefined && value !=""){
|
// console.log(1);
|
// if(typeof value == "string"){
|
// // value = $.parseJSON(value);
|
// console.log(2);
|
// value =[value];
|
// }
|
// // 2017/11/7 李元杰回显
|
// if(value.length>0){
|
// console.log(value);
|
// for(var i =0;i<value.length;i++){
|
// value[i]
|
// }
|
|
|
// console.log(value)
|
|
// if(typeof value[0] == "string"){
|
// //console.log(value[0]);
|
// // value[0] = $.parseJSON(value[0]);
|
// }
|
|
// oNode +=value[0];
|
// }
|
// for (var i = 1; i < value.length; i++) {
|
// console.log(4);
|
// if(typeof value[i] == "string"){
|
// console.log(5);
|
// // value[i] = $.parseJSON(value[i]);
|
// }
|
// console.log(value)
|
// oNode +=" , "+value[i];
|
// console.log(oNode)
|
// };
|
// }
|
// console.log(oNode)
|
|
// oNode +="</div>";
|
"</div>";
|
$($(".customShow").find("#" + id)[0]).after(oNode);
|
$($(".customShow").find("#" + id)[0]).remove();
|
// customShow.setShowItem(id, type, value, true);
|
console.log($($(".customShow").find("#" + id)[0]))
|
}
|
else if (customItems[item].type == 'amount') {
|
var id = id + "amount";
|
customBase.setItemValue(id, 'text', items[item], 'customShow');
|
$("#" + id).blur();
|
|
} else if (customItems[item].type == 'qrcode') {
|
var id = id + "qrcode";
|
customBase.setItemValue(id, 'text', items[item], 'customShow');
|
$("#" + id).blur();
|
} else if (customItems[item].type == 'barcode') {
|
var id = id + "barcode";
|
customBase.setItemValue(id, 'text', items[item], 'customShow');
|
$("#" + id).blur()
|
} else if (customItems[item].type == 'fileupload') {
|
// var $wrap = $(".customShow #" + customItems[item].id);
|
var $uploaderItem = $($(".customShow #" + customItems[item].id)[0]);
|
$uploaderItem.empty();
|
var $uploadimg = $(
|
'<div >' +
|
'<div id="fileList" class="uploader-list"></div>' +
|
'</div>'
|
);
|
var $list = $uploadimg.find("#fileList");
|
if (typeof value != "string") {
|
if (_.isArray(value)) {
|
// airport = JSON.parse(airport)
|
value = value.join(",")
|
var value = JSON.parse(value);
|
|
}
|
for (i in value) {
|
var $li = $(
|
'<div class="">' +
|
// '<div class="info"><a href="' + value[i].path + '" >' + value[i].oldName + '</a></div>' +
|
// '<div class="info info-box"><div class="info_box">' + value[i].oldName +
|
// '<span class="x_box" style="display:none;">×</span>' +
|
// '<img class="img_box" style="display:none;" src="' + value[i].path + '">' +
|
|
'<div><a href="' + value[i].path + '" >' + value[i].oldName + '</a></div>' +
|
'</div>'
|
);
|
$li.appendTo($list);
|
};
|
}
|
$uploadimg.appendTo($uploaderItem);
|
//2017-12-17 马习同修改 图片
|
// $(".info_box").on("click", function () {
|
// $(".x_box").show();
|
// $(".img_box").show();
|
// $(".x_box").unbind();
|
// $(".x_box").on("click", function () {
|
// console.log(1);
|
// $(".x_box").hide();
|
// $(".img_box").hide();
|
// })
|
// })
|
} else if (customItems[item].type == 'image') {
|
// var $wrap = $(".customShow #" + customItems[item].id);
|
var $uploaderItem = $($(".customShow #" + customItems[item].id)[0]);
|
console.log($('#' + customItems[item].id));
|
console.log($uploaderItem)
|
$uploaderItem.empty();
|
|
var $uploadimg = $(
|
'<div >' +
|
'<div id ="fileList" class="uploader-list"></div>' +
|
'</div>'
|
);
|
// var $list = $uploadimg.find("#"+potion.id+"fileList");
|
console.log(value)
|
if(customItems[item].defaultvalue != undefined){//详细显示默认值 李伟民 0131
|
var $list = $uploadimg.find("#fileList");
|
var $addLi = $(
|
'<div class="file-item thumbnail">' +
|
'<img src="' + customItems[item].defaultvalue + '">' +
|
'</div>'
|
);
|
|
$list.prepend($addLi);
|
}
|
if (_.isArray(value)) {
|
// airport = JSON.parse(airport)
|
value = value.join(",")
|
var value = JSON.parse(value);
|
|
}
|
console.log(value)
|
if (typeof value != "string") {
|
if (typeof value == "string") {
|
// value = $.parseJSON(value);
|
}
|
for (i in value) {
|
var $list = $uploadimg.find("#fileList");
|
var $addLi = $(
|
'<div class="file-item thumbnail">' +
|
'<img style="width:100px,height:100px" src="' + value[i].path + '">' +
|
'</div>'
|
);
|
|
$list.prepend($addLi);
|
}
|
}
|
// 12/18 放大图片
|
|
$uploaderItem.append($uploadimg);
|
var particularId = $uploaderItem.attr('id') + '_1'
|
$uploaderItem.children().attr('id', particularId);
|
// var particularId = $uploaderItem.find('#uploaderItem').attr('id')
|
// 详情页
|
var viewer = new Viewer(document.getElementById(particularId), {
|
url: 'data-original',
|
|
});
|
var imgId = $uploaderItem.attr('id');
|
var srcUrl = $uploaderItem.find('img').attr('src');
|
$uploaderItem.find('img').attr('alt', ' ');
|
// itemId_32uploadimg
|
|
// 编辑页
|
// console.log($('#customViewUEditor').find('#'+imgId).children())
|
// console.log($('#'+imgId))
|
// console.log($uploaderItem)
|
// var viewer = new Viewer(document.getElementById(imgId), {
|
// url: 'data-original',
|
// show:function(){
|
// console.log('显示')
|
// }
|
// });
|
// 12/18
|
|
|
} else if (customItems[item].type == 'mytext') {
|
//选择表单编辑回显
|
console.log(customItems);
|
console.log(customShow);
|
var itemAttribute = customShow.options.customItemShow.item[customItems[item].id];
|
var $mytext = $("#" + customItems[item].id);
|
var item_title = [];
|
var itemVal = [];
|
if (itemAttribute.tag_Attribute.relevancesourcetype == "fundata") {// 关联数据回显渲染 李伟民 11-30
|
var titleObj = { "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"] };
|
var dataObj = {
|
"formID": customShow.options.formid,
|
"tenantID": "001",
|
"search": [],
|
"pageSize": "1000",
|
"pageNum": "1",
|
"key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"],
|
"formData": {},
|
"dataRowNum": items[item]
|
};
|
var requesTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
|
var requesData = window.commonAjax("/datamanagement/getAssociateData", dataObj, "POST", true, false);
|
requesTitle.done(function (res) {
|
console.log(res);
|
item_title = res.data;
|
});
|
requesData.done(function (res) {
|
console.log(res);
|
if (!_.isNull(res.data) && res.data != undefined) {
|
itemVal = res.data;
|
}
|
});
|
} else {
|
var myTitle = JSON.parse(window.localStorage.getItem("title"));
|
item_title = myTitle[item];
|
itemVal = items[item];
|
}
|
console.log(itemVal)
|
console.log(item_title);
|
console.log(itemVal.list);
|
createMxtTable(customItems[item].id, item_title, itemVal.list);// 关联数据回显渲染 李伟民 11-30
|
// var newData = [];
|
// _.each(itemVal.list,function(opt){
|
// opt = _.mapKeys(opt,function(value,key){
|
// _.each(item_title,function(item){
|
// if(key == item.fieldKey){
|
// key = item.title;
|
// }
|
// })
|
// return key;
|
// })
|
// console.log(_.cloneDeep(opt))
|
// newData.push(opt);
|
// })
|
// console.log(itemVal.list);
|
// console.log(newData);
|
var formhuixian = itemVal.list;
|
|
//console.log(formhuixian);
|
var huixianStr = "";
|
for (let i in formhuixian) {
|
//console.log($mytext.attr("fieldkey"));
|
//console.log(i);
|
//console.log(formhuixian[i]);
|
if (i = $mytext.attr("fieldkey")) {
|
huixianStr = formhuixian[i];
|
}
|
}
|
//console.log(huixianStr);
|
$mytext.attr("formhuixian", JSON.stringify(itemVal.list));
|
// if(newData){
|
// var $value = newData;
|
// console.log($value)
|
//
|
// var show = "";
|
// var divBox = $("<div></div>");
|
// divBox.attr('id',customItems[item].id+'divBox');
|
// var sdata_head = "";
|
// _.each($value,(opt,j)=>{
|
// var ulBox = $("<ul></ul>");
|
// for(let i in opt){
|
// show = "";
|
// sdata_head = '<td class="data1 '+i+'">'+i+'</td>';
|
// show += '<li>'+'<span class="data1 '+i+'">'+i+'</span>'+'<span class="data2 '+i+'">'+opt[i]+'</span>'+'</li>';
|
// ulBox.attr("class","addUl ulBox"+j);
|
// ulBox.attr("id","ulBox"+j);
|
// //console.log(show)
|
// ulBox.append(show);
|
// }
|
// divBox.append(ulBox);
|
// });
|
// console.log(sdata_head);
|
// $mytext.append(divBox);
|
// }
|
}
|
if (type == 'radio' || type == 'checkbox' || type == 'dropdownlist' || type == 'tree' ||
|
type == 'amount' || type == 'barcode' || type == 'qrcode' || type == 'image' ||
|
type == 'button' || type == 'fileupload'
|
|| type == 'subform' || type == 'link'
|
|| type == 'splitline' || type == 'link'
|
|| type == 'textarea'
|
) {
|
|
} else {
|
//值设定
|
customBase.setItemValue(id, type, value, 'customShow');
|
}
|
|
}
|
};
|
}
|
|
//画面表示项目取得 -----------------
|
customShow.getItems = function (saveflag) {
|
var items = customBase.options.customItems;
|
console.log(items);
|
var itemTempS = {};
|
for (item in items) {
|
if (items.hasOwnProperty(item)) {
|
console.log(item);
|
console.log(items[item].type);
|
if (items[item].type == "button" || items[item].type == "link") {
|
} else if (items[item].type == "dropdownlist") {
|
// var datasourcetype = $("#"+items[item].id)[0].getAttribute("datasourcetype");
|
// //主数据源
|
// if(datasourcetype == "masterdata"){
|
// itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
|
// //数据源
|
// }else if(datasourcetype == "datasource"){
|
// itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
|
// //自定义
|
// }else if(datasourcetype == "custom"){
|
// itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
|
// //API接口
|
// }else if(datasourcetype == "api"){
|
// itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
|
// }
|
itemTempS[item] = customBase.getItemValue(items[item].id, "dropdownlistText");
|
console.log(itemTempS[item])
|
if (saveflag) {//下拉框 传值 修改 李伟民 11-09
|
console.log(itemTempS[item]);
|
_.each(itemTempS[item], function (sval, i) {
|
if (_.isArray(sval)) {
|
itemTempS[item][i] = sval.join();
|
}
|
})
|
// if(_.isArray(itemTempS[item][0])){
|
// itemTempS[item][0] = itemTempS[item][0].join(",")
|
// }
|
console.log(itemTempS[item]);
|
}//下拉框 传值 修改 李伟民 11-09
|
} else if (items[item].type == "tree") {
|
itemTempS[item] = customBase.getItemValue(items[item].id, "tree");
|
console.log(itemTempS[item])
|
if (saveflag) {//树形传值 修改 李元杰 11-21
|
console.log(itemTempS[item]);
|
_.each(itemTempS[item], function (sval, i) {
|
if (_.isArray(sval)) {
|
itemTempS[item][i] = sval.join();
|
}
|
})
|
// if(_.isArray(itemTempS[item][0])){
|
// itemTempS[item][0] = itemTempS[item][0].join(",")
|
// }
|
}//树形 传值 修改 李元杰 11-21
|
} else if (items[item].type == "checkbox") {
|
itemTempS[item] = customBase.getItemValue(items[item].id, "checkbox");
|
console.log(itemTempS[item])
|
console.log(saveflag)
|
if (saveflag) {//复选框传值 修改 马习同 12-6
|
console.log(itemTempS[item]);
|
_.each(itemTempS[item], function (sval, i) {
|
if (_.isArray(sval)) {
|
itemTempS[item][i] = sval.join();
|
}
|
})
|
// if(_.isArray(itemTempS[item][0])){
|
// itemTempS[item][0] = itemTempS[item][0].join(",")
|
// }
|
}////复选框传值 修改 马习同 12-6
|
} else if (items[item].type == "radio") {
|
itemTempS[item] = customBase.getItemValue(items[item].id, "radio");
|
console.log(itemTempS[item])
|
console.log(saveflag)
|
if (saveflag) {//复选框传值 修改 马习同 12-6
|
console.log(itemTempS[item]);
|
_.each(itemTempS[item], function (sval, i) {
|
if (_.isArray(sval)) {
|
itemTempS[item][i] = sval.join();
|
}
|
})
|
// if(_.isArray(itemTempS[item][0])){
|
// itemTempS[item][0] = itemTempS[item][0].join(",")
|
// }
|
}////复选框传值 修改 马习同 12-6
|
} else if (items[item].type == "subform" || items[item].type == "tag" || items[item].type == "tab") {
|
|
} else if (items[item].type == "auto") {
|
var str = window.localStorage.getItem("customItem");
|
var prefix = (str != undefined && str != "undefined") ? JSON.parse(str) : null;
|
if (prefix != null && (prefix[item] != null || prefix[item] != undefined)) {
|
itemTempS[item] = prefix[item];
|
} else {
|
itemTempS[item] = customBase.getItemValue(items[item].id, items[item].type);
|
}
|
} else {
|
itemTempS[item] = customBase.getItemValue(items[item].id, items[item].type);
|
console.log(itemTempS[item]);
|
}
|
}
|
};
|
var itemRetuen = {};
|
|
//子表单数据变换
|
for (item in customBase.options.customItems) {
|
if (customBase.options.customItems.hasOwnProperty(item)) {
|
if (customBase.options.customItems[item].type == "subform" || customBase.options.customItems[item].type == "tag" || customBase.options.customItems[item].type == "tab") {
|
var id = customBase.options.customItems[item].id.replace("itemId_", "");
|
itemRetuen[id] = {};
|
}
|
}
|
}
|
console.log(_.cloneDeep(itemRetuen));
|
console.log(_.cloneDeep(itemTempS));
|
//子表单内数据保存
|
for (item in itemTempS) {
|
////console.log(items);
|
////console.log(itemTempS);
|
////console.log(item);
|
if (itemTempS.hasOwnProperty(item)) {
|
var parentsubFormNum = customBase.options.customItems[item].parentsubFormNum;
|
////console.log(customBase.options)
|
////console.log(customBase.options.customItems[item]);
|
////console.log(parentsubFormNum);
|
if (parentsubFormNum == "0") {
|
if (customBase.options.customItems[item].type == "radio" ||
|
customBase.options.customItems[item].type == "checkbox" ||
|
customBase.options.customItems[item].type == "dropdownlist" ||
|
customBase.options.customItems[item].type == "tree"
|
) {
|
itemRetuen[item] = itemTempS[item][0];
|
} else {
|
itemRetuen[item] = itemTempS[item];
|
}
|
} else {
|
////console.log(item);
|
////console.log(items);
|
////console.log(itemRetuen[parentsubFormNum]);
|
////console.log(itemTempS[item]);
|
////console.log(itemRetuen);
|
////console.log(parentsubFormNum);
|
itemRetuen[parentsubFormNum][item] = itemTempS[item];
|
}
|
}
|
}
|
//子表单内最终数据变换
|
console.log(_.cloneDeep(itemRetuen));
|
console.log(customBase.options.customItems);
|
for (item in customBase.options.customItems) {
|
if (customBase.options.customItems.hasOwnProperty(item)) {
|
if (customBase.options.customItems[item].type == "subform" || customBase.options.customItems[item].type == "tag" || customBase.options.customItems[item].type == "tab") {
|
var id = customBase.options.customItems[item].id.replace("itemId_", "");
|
var tepItem = itemRetuen[id];
|
var subformIten = [];
|
var i = 0;
|
console.log(tepItem);
|
for (tem in tepItem) {
|
if (tepItem.hasOwnProperty(tem)) {
|
if (typeof tepItem[tem] == "string") {
|
if (subformIten[0] == undefined) {
|
subformIten[0] = {};
|
}
|
subformIten[0][tem] = tepItem[tem];
|
} else {
|
console.log(tepItem[tem]);
|
for (var i = 0; i < tepItem[tem].length; i++) {
|
if (subformIten[i] == undefined) {
|
subformIten[i] = {};
|
}
|
subformIten[i][tem] = tepItem[tem][i];
|
}
|
}
|
}
|
}
|
delete itemRetuen[id];
|
console.log(_.cloneDeep(subformIten));
|
itemRetuen[customBase.options.customItems[item].fieldKey] = subformIten;
|
}
|
}
|
}
|
console.log(_.cloneDeep(itemRetuen));
|
return itemRetuen;
|
}
|
|
//取消事件
|
customShow.onclickCancel = function () {
|
// var items = customShow.getItems();
|
//检证执行
|
var saveReturn = customShow.initEvent.cancelEventLinkage();
|
if (!saveReturn) {
|
return;
|
}
|
|
//取消接口(第三方提供)
|
var saveReturn = customShow.initEvent.cancelEvent3rd();//--------------------
|
if (saveReturn) {
|
// 取消接口
|
customShow.initEvent.cancelEvent();//--------------------
|
}
|
if (customShow.options.customShowFlag == "3") {
|
// window.close();
|
window.location.href = "about:blank";
|
window.close();
|
} else if (customShow.options.customShowFlag == "0" || customShow.options.customShowFlag == "1" || customShow.options.customShowFlag == "2") {
|
window.parent.$('#myModal').modal('hide');
|
if (customShow.options.breakFlag) {
|
window.parent.addFormData();
|
}
|
if (customShow.options.customShowFlag == "1" || customShow.options.customShowFlag == "2") {
|
$(window.parent.document.body).css({ "overflow-x": "auto", "overflow-y": "auto" });
|
}
|
window.parent.$("#myFormDesign").css("display", "");
|
window.parent.$(".htmlediterClass").css("display", "");
|
}
|
}
|
|
//印刷事件 打印
|
customShow.onPrint = function () {
|
var items = customShow.getItems();
|
var interfacep = customShow.initEvent.interfaceprint3rd(items);
|
if (!interfacep) {
|
return;
|
}
|
var removePrintArea = function (id) {
|
$("iframe#" + id).remove();
|
};
|
var customShowFlag = window.localStorage.getItem("customShowFlag");
|
if (customShowFlag == "0") {
|
var itemOnPrint = $("#customViewUEditor")[0].cloneNode(true);
|
$(itemOnPrint).css("overflow", 'visible');
|
$(itemOnPrint).printArea();
|
}else{
|
var itemOnPrint = $("#customShow")[0].cloneNode(true);
|
$(itemOnPrint).css("overflow", 'visible');
|
$(itemOnPrint).printArea();
|
}
|
}
|
|
//编辑按钮按下时
|
customShow.onEditor = function () {
|
// $(".preview-edit-pane").css("display", "none");
|
window.localStorage.setItem("customShowFlag", 3);
|
var formIDs = customlocalStorage.newFormID;
|
|
customDataBound.formsetting(formIDs, function () { });
|
//console.log("编辑存值");
|
$("#customShow").empty();
|
if (customShow.options.customShowFlag != "3") {
|
//图片文件上传
|
var uploaderImage = $(".customViewUEditorCss .uploaderImage");
|
for (var i = 0; i < uploaderImage.length; i++) {
|
$("#" + uploaderImage[i].id).find('.imgfileLiShow').remove();
|
var imageItem = customShow.options.customItemShow.item[uploaderImage[i].id];
|
var itemList = customBase.options.uploaderItemReady[uploaderImage[i].id];
|
if (customShow.options.customShowFlag == "3") {
|
|
}
|
// 参数设定
|
var potion = {
|
id: uploaderImage[i].id,
|
width: imageItem.tag_Attribute.width,
|
height: imageItem.tag_Attribute.height,
|
formid: customShow.options.formid,
|
imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
|
editable: imageItem.tag_Attribute.editable, //是否可编辑
|
defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
|
ItemReady: itemList,
|
visible:imageItem.tag_Attribute.visible
|
}
|
// 12/18
|
customBase.uploaderShow(potion);
|
|
// customBase.uploaderShow("#"+uploaderImage[i].id,{width:0,height:200},true,customShow.options.formid);
|
|
};
|
|
//文本文件上传
|
var uploaderFile = $(".customViewUEditorCss .uploaderFile");
|
|
for (var i = 0; i < uploaderFile.length; i++) {
|
$("#" + uploaderFile[i].id + " .filelist").empty();
|
|
var imageItem = customShow.options.customItemShow.item[uploaderFile[i].id];
|
debugger
|
var itemList = customBase.options.uploaderItemReady[uploaderFile[i].id];
|
// 参数设定
|
var potion = {
|
id: uploaderFile[i].id,
|
width: imageItem.tag_Attribute.width,
|
height: imageItem.tag_Attribute.height,
|
formid: customShow.options.formid,
|
imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
|
editable: imageItem.tag_Attribute.editable, //是否可编辑
|
defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
|
ItemReady: itemList,
|
visible:imageItem.tag_Attribute.visible
|
}
|
customBase.uploaderFileShow(potion);
|
// customBase.uploaderShow_Temp("#"+uploaderFile[i].id,{width:0,height:200},false,customShow.options.formid);
|
};
|
}
|
$("#customViewUEditor")[0].style.display = "block";
|
$("#customShow")[0].style.display = "none";
|
$("#customShow").css("display", "none");
|
$("#customShow").removeClass("fui-form");
|
// $(".footer")[0].style.display ="block";
|
// $(".preview-edit-pane")[0].style.display ="none";
|
// $(".footer .fromSaveCss")[0].style.display ="block";
|
|
var btns = [
|
// 'printableBtn',
|
//12/23'exportBtn',
|
//12/23 'rejectBtn',
|
// 12/23 'submitBtn',
|
//12 /23 'auditableBtn',
|
// 12/23 'queryBtn',
|
// 'createBtn',
|
// 'clearBtn',
|
// 12/23 'disposableBtn',
|
// 'fromSaveBtn',
|
// 'editableBtn'
|
];
|
customShow.setToolBtn(btns);
|
|
customShow.setXhSelectList();
|
//子表单事件调用
|
customShow.clickBindSubform();
|
//2017/11/18 马习同修改 隐藏预览模式下 导入数据按钮
|
$(".sonImportFile").removeClass("cfg_contentNone");
|
//s_savebtn
|
$(".s_savebtn").show();
|
// $(".preview-edit-pane").css("display", "none");
|
//12/23
|
// $('#disposableBtn').css('display','none');
|
// $('#clearBtn').css('display','none');
|
// $('#queryBtn').css('display','none');
|
// $('#auditableBtn').css('display','none');
|
// $('#submitBtn').css('display','none');
|
// $('#rejectBtn').css('display','none');
|
|
}
|
|
//画面验证
|
customShow.onfromCheck = function (items) {
|
if ($(".errorCheckCss").length > 0) {
|
return true;
|
}
|
if($(".checkErr") > 0){
|
return true;
|
}
|
$(".errorItemCss").removeClass("errorItemCss");
|
$(".mesageErrDiv").remove();
|
for (var id in customShow.options.showErrId) {
|
$($(".customViewUEditorCss #" + id)[customShow.options.showErrId[id]]).popover('hide');
|
}
|
|
//必须入力验证
|
mustcheckExe = function (tag_Type, value, ItemId, N) {
|
if (tag_Type == "text" || tag_Type == "textarea" ||
|
tag_Type == "number" || tag_Type == "htmlediter" || tag_Type == "fileupload" ||
|
tag_Type == "calendar") {
|
if (tag_Type == "fileupload") {
|
var count = 0;
|
for (var key in value) {
|
count++;
|
}
|
if (count == 0) {
|
value = "";
|
}
|
|
}
|
if (value == "") {
|
customShow.showErrorItem(tag_Type, ItemId, N);
|
var message = customBase.getMessage("mesage_ID004");
|
customShow.setShowMesageErr(ItemId, message, N);
|
mustcheck = true;
|
}
|
} else if (tag_Type == "checkbox" || tag_Type == "dropdownlist") {
|
// //////////console.log(value);
|
if (value.length == 0) {
|
customShow.showErrorItem(tag_Type, ItemId, N);
|
var message = customBase.getMessage("mesage_ID004");
|
customShow.setShowMesageErr(ItemId, message, N);
|
mustcheck = true;
|
}
|
}
|
}
|
|
//数值型验证
|
numberFormatCheck = function (numbertype, value, ItemId, N) {
|
if (numbertype == "integer") {
|
if (value.indexOf(".") > -1) {
|
var message = customBase.getMessage("mesage_ID019");
|
customShow.showErrorItem("number", ItemId, N);
|
customShow.setShowMesageErr(ItemId, message, N);
|
mustcheck = true;
|
} else {
|
var numberMaxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
|
numberMaxlength = parseInt(numberMaxlength);
|
if (value.length > numberMaxlength && numberMaxlength != 0) {
|
customShow.showErrorItem("number", ItemId, N);
|
var message = customBase.getMessage("mesage_ID020");
|
customShow.setShowMesageErr(ItemId, message, N);
|
mustcheck = true;
|
}
|
}
|
} else {
|
var integerItem;
|
integerItem = value.split(".");
|
//整数长度
|
// var aa = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
|
var numberMaxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
|
numberMaxlength = parseInt(numberMaxlength);
|
var numberdecimalplace = customShow.options.customItemShow.item[ItemId].tag_Attribute.decimalplace;
|
numberdecimalplace = parseInt(numberdecimalplace);
|
if (integerItem[0].length > numberMaxlength && numberMaxlength != 0) {
|
customShow.showErrorItem("number", ItemId, N);
|
var message = customBase.getMessage("mesage_ID020");
|
customShow.setShowMesageErr(ItemId, message, N);
|
mustcheck = true;
|
}
|
if (integerItem[2] != undefined && integerItem[1].length > numberdecimalplace) {
|
customShow.showErrorItem("number", ItemId, N);
|
var message = customBase.getMessage("mesage_ID021");
|
customShow.setShowMesageErr(ItemId, message, N);
|
mustcheck = true;
|
}
|
////////console.log(customShow.options.customItemShow.item[ItemId].tag_Attribute);
|
}
|
}
|
|
//文本格式验证
|
maxlengthCheck = function (maxlength, value, ItemId, N) {
|
if (value.length > maxlength && maxlength != 0) {
|
customShow.showErrorItem("htmlediter", ItemId, N);
|
var message = customBase.getMessage("mesage_ID023");
|
customShow.setShowMesageErr(ItemId, message, N);
|
mustcheck = true;
|
}
|
}
|
//文本格式验证
|
textFormatCheck = function (format, value, ItemId, N) {
|
if (value == "") {
|
return;
|
} else if (format == "phone") {
|
//手机号
|
var p1 = /^1[3|4|5|7|8][0-9]{9}$/;
|
var me = false;
|
if (!p1.test(value)) {
|
customShow.showErrorItem("text", ItemId, N);
|
var message = customBase.getMessage("mesage_ID009");
|
customShow.setShowMesageErr(ItemId, message, N);
|
mustcheck = true;
|
}
|
} else if (format == "url") {
|
//网址 张吉男修改网址验证
|
// var strRegex = "^((https|http|ftp|rtsp|mms)?://)"
|
// + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@
|
// + "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
|
// + "|" // 允许IP和DOMAIN(域名)
|
// + "([0-9a-z_!~*'()-]+\.)*" // 域名- www.
|
// + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名
|
// + "[a-z]{2,6})" // first level domain- .com or .museum
|
// + "(:[0-9]{1,4})?" // 端口- :80
|
// + "((/?)|" // a slash isn't required if there is no file name
|
// + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
|
var strRegex="[a-zA-z]+://[^\s]*";
|
var re = new RegExp(strRegex);
|
if (!re.test(value)) {
|
customShow.showErrorItem("text", ItemId, N);
|
var message = customBase.getMessage("mesage_ID010");
|
customShow.setShowMesageErr(ItemId, message, N);
|
mustcheck = true;
|
}
|
} else if (format == "cardno") {
|
//身份证
|
// 2018.1.25 张吉男修改 身份证验证错误
|
// var p1 = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i;
|
var p1=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
|
// alert(1111);
|
if (!p1.test(value)) {
|
customShow.showErrorItem("text", ItemId, N);
|
var message = customBase.getMessage("mesage_ID011");
|
customShow.setShowMesageErr(ItemId, message, N);
|
mustcheck = true;
|
}
|
} else if (format == "email") {
|
//邮箱
|
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
|
if (!myreg.test(value)) {
|
customShow.showErrorItem("text", ItemId, N);
|
var message = customBase.getMessage("mesage_ID012");
|
customShow.setShowMesageErr(ItemId, message, N);
|
mustcheck = true;
|
}
|
}
|
}
|
var customItems = customBase.options.customItems;
|
//必须入力验证
|
var mustcheck = false;
|
for (fieldKey in customItems) {
|
|
if (customItems.hasOwnProperty(fieldKey)) {
|
////console.log(customItems);
|
var tag_Type = customItems[fieldKey].type;
|
var ItemId = customItems[fieldKey].id;
|
if (customItems[fieldKey].visible) {
|
if (customItems[fieldKey].mustcheck) {
|
var value = items[fieldKey];
|
//子表单的情况
|
if (value == undefined) {
|
|
//取得对应子表单ID
|
var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
|
if (customShow.options.customItemShow.item[subformItemId] != undefined) {
|
var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
|
var subformItem = items[subformItemAlias];
|
for (var i = 0; i < subformItem.length; i++) {
|
mustcheckExe(tag_Type, subformItem[i][fieldKey], ItemId, i);
|
}
|
}
|
} else {
|
mustcheckExe(tag_Type, value, ItemId, 0);
|
}
|
}
|
//文本格式验证
|
if (customItems[fieldKey].type == "text") {
|
var value = items[fieldKey];
|
////console.log(fieldKey);
|
////console.log(customItems);
|
////console.log(value);
|
var format = customShow.options.customItemShow.item[ItemId].tag_Attribute.format;
|
//子表单的情况
|
if (value == undefined) {
|
//取得对应子表单ID
|
var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
|
var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
|
var subformItem = items[subformItemAlias];
|
////console.log(items);
|
////console.log(subformItemAlias);
|
////console.log(subformItem);
|
for (var i = 0; i < subformItem.length; i++) {
|
textFormatCheck(format, subformItem[i][fieldKey], ItemId, i);
|
}
|
} else {
|
textFormatCheck(format, value, ItemId, 0);
|
}
|
|
}
|
//数值整数验证
|
if (customItems[fieldKey].type == "number") {
|
var value = items[fieldKey];
|
//数值格式
|
var numbertype = customShow.options.customItemShow.item[ItemId].tag_Attribute.numbertype;
|
//子表单的情况
|
if (value == undefined) {
|
//取得对应子表单ID
|
var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
|
var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
|
var subformItem = items[subformItemAlias];
|
for (var i = 0; i < subformItem.length; i++) {
|
numberFormatCheck(numbertype, subformItem[i][fieldKey], ItemId, i);
|
}
|
} else {
|
numberFormatCheck(numbertype, value, ItemId, 0);
|
}
|
|
}
|
|
//默认长度检证
|
if (customItems[fieldKey].type == "htmlediter") {
|
var value = items[fieldKey];
|
//数值格式
|
var maxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
|
// //子表单的情况
|
// if(value ==undefined){
|
// //取得对应子表单ID
|
// var subformItemId = "itemId_"+customItems[fieldKey].parentsubFormNum;
|
// var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
|
// var subformItem = items[subformItemAlias];
|
// for(var i=0;i<subformItem.length;i++){
|
// numberFormatCheck(numbertype,subformItem[i][fieldKey],ItemId,i);
|
// }
|
// }else{
|
maxlengthCheck(maxlength, value, ItemId, 0);
|
// }
|
|
}
|
}
|
}
|
}
|
//焦点事件
|
// $(".errorItemCss").unbind('focus');
|
// $(".errorItemCss").on('focus', function() {
|
// $(this).removeClass("errorItemCss");
|
// ////////////console.log($(this)[0].id);
|
// $("#"+$(this)[0].id+"mesageErrDiv").remove();
|
// $(".customViewUEditorCss #"+$(this)[0].id).popover('hide')
|
// });
|
// //下拉列表点击事件
|
// $(".select2-search__field").unbind("focus");
|
// $(".select2-search__field").bind("focus",function(){
|
// var id = this.getAttribute("errorItemId");
|
// var N = this.getAttribute("N");
|
// $($('.customViewUEditorCss #'+id)[N].parentNode).find(".select2").removeClass("errorItemCss");
|
// $("#"+id+"mesageErrDiv").remove();
|
// $($(".customViewUEditorCss #"+id)[N]).popover('hide')
|
// });
|
|
if (mustcheck) { return true; }
|
|
//单选按钮长度验证
|
|
//焦点事件
|
// $(".errorItemCss").unbind();
|
// $(".errorItemCss").on('focus', function() {
|
// $(this).removeClass("errorItemCss");
|
// });
|
return false;
|
}
|
|
//检证验证
|
customShow.interfaceCheck = function (items) {//保存前计算费用 李伟民 10 - 31
|
var flag = true;
|
_.each(customBase.interfaceData, function (intdata) {
|
var func = intdata.customInterfacemethod + "()";
|
if(intdata.interfacemethod == 'fromSave3rd'){//只执行保存接口事件
|
try {//解决不上传资源文件JS报错 导致无法保存 李伟民 0129
|
var thisChheck = eval(func);
|
console.log(thisChheck);
|
if (thisChheck == false) {
|
flag = false;
|
}
|
} catch (error) {
|
|
}
|
}
|
});
|
return flag;
|
}//保存前计算费用 李伟民 10 - 31
|
|
//错误信息
|
customShow.showErrorItem = function (errorClass, tag_Type, id, N) {
|
if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar"
|
|| tag_Type == "checkbox") {
|
$($(".customViewUEditorCss #" + id)[N]).addClass(errorClass);
|
} else if (tag_Type == "htmlediter") {
|
// $(".customViewUEditorCss #"+id+"Item").addClass(errorClass);
|
UE.getEditor(id + "Item").body.setAttribute("class", errorClass);
|
if (UE.getEditor(id + "Item").body.getAttribute("heightFlag") == "height") {
|
} else {
|
var height = UE.getEditor(id + "Item").body.style.height.replace("px", "");
|
height = parseInt(height) - 12;
|
UE.getEditor(id + "Item").body.style.height = height + "px";
|
UE.getEditor(id + "Item").body.setAttribute("id", id);
|
}
|
UE.getEditor(id + "Item").body.setAttribute("heightFlag", height);
|
|
// //////////console.log(UE.getEditor(id+"Item").body.style.height = );
|
} else if (tag_Type == "dropdownlist") {
|
// $(".customViewUEditorCss #"+id).p + ".selection").addClass(errorClass);
|
// //////////console.log($('.customViewUEditorCss #'+id)[0].parentNode);
|
$($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2").addClass(errorClass);
|
// $(".customViewUEditorCss #"+id+" .select2-search__field")
|
if ($($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field").length > 0) {
|
$($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field")[0].setAttribute("errorItemId", id);
|
$($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field")[0].setAttribute("N", N);
|
}
|
}
|
}
|
|
//画面属性设定(初始值 表示/非表示 只读 必须 审查必须)
|
customShow.setShowAttribute = function (aliasItem) {
|
console.log(aliasItem)
|
// 12/7 不可编辑 可以编辑
|
id = aliasItem.id;
|
//表示非表示
|
if (aliasItem.visible) {
|
$(".customViewUEditorCss #" + id).removeClass("cfg_contentNone");
|
$(".customViewUEditorCss #" + id + "ActiveId").removeClass("cfg_contentNone");
|
$(".customViewUEditorCss ." + id + "IconShow").removeClass("cfg_contentNone");
|
$(".customViewUEditorCss #" + id + "Item").removeClass("cfg_contentNone");
|
if (customShow.options.customItemShow.customFlag == "1" && aliasItem.type == "dropdownlist") {
|
$($(".customViewUEditorCss #" + id)[0].parentNode).removeClass("cfg_contentNone");
|
}
|
} else if (!aliasItem.visible) {
|
$(".customViewUEditorCss #" + id).addClass("cfg_contentNone");
|
$(".customViewUEditorCss #" + id + "ActiveId").addClass("cfg_contentNone");
|
$(".customViewUEditorCss ." + id + "IconShow").addClass("cfg_contentNone");
|
$(".customViewUEditorCss #" + id + "Item").addClass("cfg_contentNone");
|
if (customShow.options.customItemShow.customFlag == "1" && aliasItem.type == "dropdownlist") {
|
$($(".customViewUEditorCss #" + id)[0].parentNode).addClass("cfg_contentNone");
|
}
|
}
|
//必须
|
if (aliasItem.mustcheck) {
|
$(".customViewUEditorCss ." + id + "IconShow .iconMustcheck").removeClass("cfg_contentNone");
|
} else if (!aliasItem.mustcheck) {
|
$(".customViewUEditorCss ." + id + "IconShow .iconMustcheck").addClass("cfg_contentNone");
|
}
|
//审查必须
|
if (aliasItem.approvalmustenter) {
|
$(".customViewUEditorCss ." + id + "IconShow .iconApprovalmustenter").removeClass("cfg_contentNone");
|
} else if (!aliasItem.approvalmustenter) {
|
$(".customViewUEditorCss ." + id + "IconShow .iconApprovalmustenter").addClass("cfg_contentNone");
|
}
|
|
//编辑-非编辑
|
var itemTemp = $($(".customViewUEditorCss #" + id)[0]);
|
var tag_Type = aliasItem.type;
|
if (aliasItem.editable) {
|
if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar") {//--OK
|
itemTemp.removeAttr('readonly');
|
// 非编辑情况移除背景颜色 12/7 李元杰
|
for (var i = 0; i < itemTemp.length; i++) {
|
console.log(itemTemp[i]);
|
$(itemTemp[i]).removeClass('disableColor')
|
}
|
if (tag_Type == "calendar") {
|
var calendarItem = customShow.options.customItemShow.item[id];
|
// var editable = tag_Attribute['editable'];
|
var textformat = calendarItem.tag_Attribute.datatype;
|
if (textformat == 'Y') {
|
$(itemTemp).addClass('dateFromyyyy');
|
} else if (textformat == 'Y-m') {
|
$(itemTemp).addClass('dateFromyyyymm');
|
} else if (textformat == 'Y-m-d') {
|
$(itemTemp).addClass('dateFromyyyymmdd');
|
} else if (textformat == 'Y-m-d H:i') {
|
$(itemTemp).addClass('dateFromhhmiss');
|
}
|
customShow.clickBindSubform();
|
|
}
|
} else if (tag_Type == "radio") {//----------------------------------------------------------
|
itemTemp.find('.custom-radio').removeAttr("readonly");
|
} else if (tag_Type == "radio") {//----------------------------------------------------------
|
itemTemp.find('.custom-radio').removeAttr("readonly");
|
} else if (tag_Type == "checkbox") {//-------------------------------------------------------
|
itemTemp.find('.custom-check').removeAttr("readonly");
|
} else if (tag_Type == "dropdownlist") {//---------------------------------------------------OK
|
// $(itemTemp).removeClass('editableDisabled');
|
// $(itemTemp).prop("disabled", false); //设置下拉框不可用
|
// $(itemTemp).find(".select-container").removeAttr("readonly");
|
$(itemTemp).removeClass("disableColor");
|
|
$(itemTemp).removeClass("readonly");
|
// ////console.log($(itemTemp).find(".select-container"));
|
} else if (tag_Type == "button") {//---------------------------------------------------------OK
|
$(itemTemp).removeClass('disabled');
|
} else if (tag_Type == "link") {//-----------------------------------------------------------OK
|
itemTemp.href = "javascript:void(0);";
|
itemTemp.removeAttr('disabled', 'disabled');
|
} else if (tag_Type == "fileupload") {//----------------------------------------------------todo
|
} else if (tag_Type == "tree") {//----------------------------------------------------------todo
|
$(itemTemp).parent().find('.citySel').removeClass('disableColor')
|
|
// var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
|
itemTemp[0].setAttribute('editable', aliasItem.editable);
|
}
|
// else if (tag_Type == "tree" || tag_Type == "tree" || tag_Type == "tree") {
|
// // var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
|
// itemTemp.setAttribute('editable', aliasItem.editable);
|
// }
|
|
} else if (!aliasItem.editable) {
|
if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar") {//--OK
|
for (var i = 0; i < itemTemp.length; i++) {
|
// 12/7 李元杰 添加背景颜色
|
console.log(itemTemp[i]);
|
itemTemp[i].setAttribute('readonly', '');
|
$(itemTemp[i]).addClass('disableColor')
|
}
|
if (tag_Type == "calendar") {
|
// $('.dateFromyyyy').unbind();
|
// $('.dateFromyyyymm').unbind();
|
// $('.dateFromyyyymmdd').unbind();
|
// $('.dateFromhhmiss').unbind();
|
itemTemp.removeClass('dateFromyyyy');
|
itemTemp.removeClass('dateFromyyyymm');
|
itemTemp.removeClass('dateFromyyyymmdd');
|
itemTemp.removeClass('dateFromhhmiss');
|
////////console.log(itemTemp);
|
var itemDateFromTemp = itemTemp[0].cloneNode(true);
|
var $DateFromTemp = "<div id='itemDateFromTemp'></div>"
|
itemTemp.after($DateFromTemp);
|
itemTemp.remove();
|
var DateFromTemp = $("#itemDateFromTemp")[0];
|
DateFromTemp.after(itemDateFromTemp);
|
DateFromTemp.remove();
|
customShow.clickBindSubform();
|
}
|
} else if (tag_Type == "radio") {//----------------------------------------------------------todo
|
|
// setTimeout(function(){
|
itemTemp.find('.custom-radio').addClass("readonly");
|
// },0)
|
} else if (tag_Type == "checkbox") {//-------------------------------------------------------todo
|
itemTemp.find('.custom-check').addClass("readonly");
|
} else if (tag_Type == "dropdownlist") {//---------------------------------------------------OK
|
// $(itemTemp).addClass('editableDisabled');
|
// $(itemTemp).prop("disabled", true); //设置下拉框不可用
|
// ////console.log($(itemTemp).find(".select-container"));
|
// itemTemp = $(itemTemp).find(".select-container");
|
// for(var i = 0 ;i<itemTemp.length;i++){
|
// itemTemp[i].setAttribute('readonly','');
|
// }
|
console.log($(itemTemp))
|
$(itemTemp).find('.select-container_box').addClass('disableColor')
|
$(itemTemp).addClass("readonly");
|
////console.log( $(itemTemp));
|
} else if (tag_Type == "button") {//---------------------------------------------------------OK
|
$(itemTemp).addClass('disabled');
|
} else if (tag_Type == "link") {//-----------------------------------------------------------OK
|
itemTemp.href = "javascript:void(0);";
|
debugger
|
for (var i; i < itemTemp.length; i++) {
|
itemTemp[i].setAttribute('disabled', 'disabled');
|
}
|
} else if (tag_Type == "fileupload") {//----------------------------------------------------todo
|
console.log($(itemTemp));
|
debugger
|
} else if (tag_Type == "tree") {//----------------------------------------------------------todo
|
// 禁用背景颜色
|
console.log($(itemTemp).parents('div[name="TreeWin"]'))
|
console.log($(itemTemp))
|
|
itemTemp[0].setAttribute('editable', aliasItem.editable);
|
}
|
// else if (tag_Type == "tree" || tag_Type == "tree" || tag_Type == "tree") {
|
// // var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
|
// console.log($(itemTemp))
|
// itemTemp.setAttribute('editable', aliasItem.editable);
|
// }
|
}
|
}
|
//错误信息显示
|
customShow.setShowMesageErr = function (id, message, N, type) {
|
console.log("setShowMesageErr");
|
console.log(message);
|
////console.log(id);
|
var mesageHtml = '<div class="' + id + 'Popover"></div>';
|
if (customShow.options.customInit.designMode == "1") {
|
////console.log(id);
|
////console.log(message);
|
////console.log(N);
|
////console.log($($(".customViewUEditorCss #"+id)[N]));
|
// $($(".customViewUEditorCss #"+id)[N]).popover('hide');
|
// if($($(".customViewUEditorCss #" + id)[N]).attr('popoverFalg') != undefined){
|
// $('.' + id + 'Popover').html(message);
|
// }
|
$($(".customViewUEditorCss #" + id)[N]).attr('popoverFalg','true');
|
$($(".customViewUEditorCss #" + id)[N]).popover({
|
// title:"错误信息",
|
html: true,
|
content: mesageHtml,
|
trigger: 'manual'
|
});
|
$($(".customViewUEditorCss #" + id)[N]).hover(function(){// 普通模式 错误提示修改 李伟民 0125
|
if($($(".customViewUEditorCss #" + id)[N]).attr('popoverFalg') != 'false'){
|
$($(".customViewUEditorCss #" + id)[N]).popover('show');
|
$('.' + id + 'Popover').html(message);
|
}
|
},function(){
|
$($(".customViewUEditorCss #" + id)[N]).popover('hide');
|
})
|
$($(".customViewUEditorCss #" + id)[N]).on('focus',function(){
|
$($(".customViewUEditorCss #" + id)[N]).attr('popoverFalg','false');
|
$($(".customViewUEditorCss #" + id)[N]).popover('hide');
|
})
|
$($(".customViewUEditorCss #" + id)[N]).popover('show');
|
$('.' + id + 'Popover').html(message);
|
setTimeout(function(){
|
$($(".customViewUEditorCss #" + id)[N]).popover('hide');
|
},2000)
|
customShow.options.showErrId[id] = N;
|
//////console.log($($(".customViewUEditorCss #"+id+"Item")[N]).length);
|
|
if ($($(".customViewUEditorCss #" + id + "Item")[N]).length == 1) {
|
$($(".customViewUEditorCss #" + id + "Item")[N]).attr('popoverFalg','true');
|
$($(".customViewUEditorCss #" + id + "Item")[N]).popover({
|
// title:"错误信息",
|
html: true,
|
content: mesageHtml,
|
trigger: 'manual'
|
});
|
$($(".customViewUEditorCss #" + id + "Item")[N]).popover('show');
|
$('.' + id + 'Popover').html(message);
|
setTimeout(function(){
|
$($(".customViewUEditorCss #" + id + "Item")[N]).popover('hide');
|
},2000)
|
customShow.options.showErrId[id + "Item"] = N;
|
$($(".customViewUEditorCss #" + id + "Item")[N]).hover(function(){
|
if($($(".customViewUEditorCss #" + id + "Item")[N]).attr('popoverFalg') != 'false'){
|
$($(".customViewUEditorCss #" + id + "Item")[N]).popover('show');
|
$('.' + id + 'Popover').html(message);
|
}
|
},function(){
|
$($(".customViewUEditorCss #" + id + "Item")[N]).popover('hide');
|
})
|
$($(".customViewUEditorCss #" + id + "Item")[N]).on('focus',function(){
|
$($(".customViewUEditorCss #" + id + "Item")[N]).attr('popoverFalg','false');
|
$($(".customViewUEditorCss #" + id + "Item")[N]).popover('hide');
|
})// 普通模式 错误提示修改 李伟民 0125
|
}
|
|
} else {
|
var mesageErrDiv = document.createElement("div");
|
mesageErrDiv.setAttribute("class", "mesageErrDiv");
|
mesageErrDiv.setAttribute("id", id + "mesageErrDiv");
|
if(type){//验证消息 修改 李伟民
|
$(mesageErrDiv).addClass("checkErr");
|
}//验证消息 修改 李伟民
|
$(mesageErrDiv).append(message);
|
var tempActiveId = $($(".customViewUEditorCss #" + id + "ActiveId")[N]).find("#" + id + "mesageErrDiv");
|
$($(".customViewUEditorCss #" + id + "ActiveId")[N]).find("#" + id + "mesageErrDiv").remove();
|
// if(tempActiveId.length == 0){
|
// if($($(".customViewUEditorCss #"+id+"ActiveId")[N]).length !=0){
|
//2017/10/23 李元杰 必选的提示信息修改
|
var requiredHint = $($($(".customViewUEditorCss #" + id + "ActiveId")[N])[0]);
|
if (requiredHint.find('input').val() === '') {
|
if ($(".customViewUEditorCss #" + id + "ActiveId").length == 0) {
|
console.log($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td"));
|
$(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").append(mesageErrDiv);
|
} else {
|
$($($(".customViewUEditorCss #" + id + "ActiveId")[N])[0]).append(mesageErrDiv);
|
}
|
$(mesageErrDiv).html(requiredHint.children('h8').children('span').html() + "必须输入")
|
} else {
|
if ($(".customViewUEditorCss #" + id + "ActiveId").length == 0) {
|
console.log($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td"));
|
if ($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").find(".mesageErrDiv").length == 0) {
|
$(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").append(mesageErrDiv);
|
}
|
} else {
|
if ($($($(".customViewUEditorCss #" + id + "ActiveId")[N])[0]).find(".mesageErrDiv").length == 0) {
|
$($($(".customViewUEditorCss #" + id + "ActiveId")[N])[0]).append(mesageErrDiv);
|
}
|
}
|
}
|
// $(mesageErrDiv).html(requiredHint.children('h8').children('span').html() + "必须输入")
|
// }
|
// }
|
|
|
}
|
|
}
|
|
//DB数据to画面表示数据转化
|
customShow.dbItemToShowItem = function (itemId, type, value, showClass, dropdowntype, parentsubFormNum) {
|
if (type == "radio" || type == "checkbox") {
|
var itemL = $("." + showClass + " ." + itemId + "value");
|
//数值变换
|
//单选按钮,仅仅有一项情况(无子表单时)
|
if (type == "radio" && itemL.length == 1) {
|
if (parentsubFormNum != 0) {
|
value = value[0];
|
}
|
value = [[value]];
|
} else if (type == "checkbox" && itemL.length == 1) {
|
//复选框时,仅仅有一项情况(无子表单时)
|
//只选择一项
|
if (parentsubFormNum != 0) {
|
value = value[0];
|
}
|
if (typeof value == "string") {
|
value = [[value]];
|
} else {
|
//复数项选择
|
value = [value];
|
}
|
} else if (type == "radio" && itemL.length > 1) {
|
//
|
var valueTempRadio = [];
|
for (var i = 0; i < value.length; i++) {
|
valueTempRadio[i] = [value[i]];
|
}
|
value = valueTempRadio;
|
} else if (type == "checkbox" && itemL.length > 1) {
|
var valueTempRadio = [];
|
for (var i = 0; i < value.length; i++) {
|
if (typeof value[i] == "string") {
|
valueTempRadio[i] = [value[i]];
|
} else {
|
valueTempRadio[i] = value[i];
|
}
|
}
|
value = valueTempRadio;
|
}
|
} else if (type == "dropdownlistText") {
|
|
//多个下拉菜单
|
var itemList = $("." + showClass + " ." + itemId + "value");
|
if (itemList.length == 1) {
|
if (parentsubFormNum != 0) {
|
value = value[0];
|
}
|
if (typeof value == "string" && dropdowntype == "single") {
|
value = [value];
|
}
|
//子表单中,复选情况
|
if (dropdowntype == "multiple") {
|
if (typeof value == "string") {
|
value = [value];
|
} else {
|
// value = value[0];
|
}
|
}
|
// setelect2Item(itemList[0],value);
|
} else {
|
for (var i = 0; i < itemList.length; i++) {
|
// var valueTemp;
|
//单选时,多文件
|
if (dropdowntype == "single") {
|
value[i] = [value[i]];
|
} else {
|
// for (var i = 0; i < value[i].length; i++) {
|
if (typeof value[i] == "string") {
|
value[i] = [value[i]];
|
} else {
|
value[i] = value[i];
|
}
|
// }
|
}
|
// setelect2Item(itemList[i],valueTemp);
|
}
|
}
|
}
|
return value;
|
}
|
|
//表示模式下,数据设定(单选 复选 下拉菜单)
|
customShow.setShowItem = function (itemId, type, value, flag) {
|
//被选择项目设定
|
console.log(1)
|
// console.log(_.cloneDeep(itemId))
|
// console.log(_.cloneDeep(type))
|
console.log(_.cloneDeep(value))
|
// console.log(_.cloneDeep(flag))
|
checkboxRadioShow = function (showItem, value) {
|
console.log($(showItem), value)
|
var listData = customBase.options.dropdownlistText[itemId];
|
if (listData == undefined) {
|
return;
|
}
|
if (typeof value == "string") {
|
value = [value];
|
// value = JSON.parse(value)
|
}
|
var temp = [];
|
var tempStr = "";
|
console.log(listData);
|
console.log(value)
|
for (var i = 0; i < listData.length; i++) {
|
for (var j = 0; j < value.length; j++) {
|
if (value[j] == listData[i].value) {
|
console.log(1)
|
temp[j] = listData[i].text;
|
}
|
}
|
}
|
console.log(temp)
|
for (var i = 0; i < temp.length; i++) {
|
if (i == 0) {
|
tempStr = temp[i];
|
} else {
|
tempStr += "," + temp[i];
|
}
|
}
|
console.log(tempStr)
|
$(showItem).empty();
|
//console.log(tempStr);
|
$(showItem).append(tempStr);
|
|
}
|
var showItem = $("." + itemId + "_showItem");
|
console.log(showItem)
|
//页面返回
|
if (flag) {
|
if (type == "checkbox" || type == "radio") {
|
if (showItem.length == 1) {
|
checkboxRadioShow(showItem[0], value);
|
} else {
|
for (var i = 0; i < showItem.length; i++) {
|
checkboxRadioShow(showItem[i], value[i]);
|
}
|
}
|
} else {
|
if (showItem.length == 1) {
|
checkboxRadioShow(showItem[0], value);
|
} else {
|
for (var i = 0; i < showItem.length; i++) {
|
checkboxRadioShow(showItem[i], value[i]);
|
}
|
}
|
}
|
} else {
|
if (type == "checkbox" || type == "radio") {
|
for (var i = 0; i < showItem.length; i++) {
|
var valueTemp = value[i];
|
checkboxRadioShow(showItem[i], valueTemp);
|
}
|
} else {
|
if (showItem.length == 1) {
|
checkboxRadioShow(showItem[0], value);
|
} else {
|
for (var i = 0; i < showItem.length; i++) {
|
checkboxRadioShow(showItem[i], value[i]);
|
}
|
}
|
}
|
}
|
}
|
|
//工具栏设定button
|
customShow.setToolBtn = function (btns) {
|
console.log(btns)
|
$(".edit-pane").empty();
|
var $editPaneBtn = $($(".edit-pane")[0]);
|
|
console.log($editPaneBtn)
|
// //////console.log(btns);
|
for (var i = 0; i < btns.length; i++) {
|
if (customShow.button[btns[i]].functionName == "") {
|
$a = '<a id="' + btns[i] + '" href="javascript:void(0);">' +
|
'<i class="icon-flow-edit"></i><span style="color:#ff0000"><i class="' + customShow.button[btns[i]].cssName + '" style="text-align: left;color:#ff0000"></i>' + customShow.button[btns[i]].name + '</span></a>';
|
} else {
|
$a = '<a id="' + btns[i] + '" href="javascript:void(0);" onclick="' + customShow.button[btns[i]].functionName + '()">' +
|
'<i class="icon-flow-edit"></i><span><i class="' + customShow.button[btns[i]].cssName + '" style="text-align: left;"></i>' + customShow.button[btns[i]].name + '</span></a>';
|
}
|
if (customShow.getFormSetting(btns[i]) != 0) {
|
$editPaneBtn.prepend($a);
|
}
|
|
}
|
if (btns.length > 0) {
|
// $(".preview-edit-pane").css("display", "block");
|
}
|
}
|
|
customShow.setTextBtn = function () {
|
var item = customShow.options.customItemShow.item["itemId_1"];
|
var code = item.tag_Attribute.masterData;
|
var masterData = $.parseJSON(code);
|
var defindCode = masterData.defindCode;
|
var eleCode = masterData.eleCode;
|
customLinkageAnalysis.getElement("itemId_1", eleCode, function (re) {
|
////////console.log(re);
|
})
|
}
|
|
//主数据重复
|
customShow.setXhSelectList = function (addflag) {
|
// console.log(1)
|
var subformDList = customShow.options.subformDList;
|
//console.log(subformDList);
|
//console.log(85244445)
|
//console.log(addflag)
|
var setValueItem = {};
|
//
|
//var subArr = [];
|
//_.each(subformDList,opt=>{
|
// subArr.push(opt);
|
//})
|
//var subObj = {};
|
//for(var key in subformDList){
|
// if(subformDList[key] == _.last(subArr)){
|
// subObj[key] = subformDList[key];
|
// }
|
//}
|
//console.log(_.cloneDeep(subObj));
|
for (var id in subformDList) {
|
console.log(id);
|
if ($(".customViewUEditorCss ." + id).length == 1) {
|
var xhSelectTemp = {
|
selectId: customShow.options.subformDList[id].selectId,
|
multiple: customShow.options.subformDList[id].multiple,
|
width: customShow.options.subformDList[id].width,
|
listData: customBase.options.dropdownlistText[customShow.options.subformDList[id].selectId],
|
setDiv: id
|
};
|
console.log(xhSelectTemp);
|
console.log(1)
|
xhSelect.setXhSelect(xhSelectTemp);
|
var item = customShow.options.customItemShow.item[customShow.options.subformDList[id].selectId];
|
setValueItem[item.tag_Attribute.alias] = customShow.options.subformDList[id].selectId;
|
}
|
}
|
console.log(setValueItem);
|
console.log(customShow.options);
|
if (!addflag) {
|
for (var valueItem in setValueItem) {
|
var setList = customShow.options.subformDValue[valueItem];
|
console.log(setList);
|
if (setList != undefined) {
|
for (var i = 0; i < setList.length; i++) {
|
xhSelect.setValue(setValueItem[valueItem], setList[i], i);
|
}
|
}
|
}
|
|
}
|
}
|
//子表单添加记录 复制下拉框方法 2017/10/06
|
customShow.setXhSelectListAdd = function () {
|
// //////console.log(table);
|
var subformDList = customShow.options.subformDList;
|
var setValueItem = {};
|
//10/2/27 马习同修改 下拉框复制重复
|
var xhSelectTemp = {};
|
for (var id in subformDList) {
|
if ($(".customViewUEditorCss ." + id).length == 1) {
|
var xhSelectTemp = {
|
selectId: customShow.options.subformDList[id].selectId,
|
multiple: customShow.options.subformDList[id].multiple,
|
width: customShow.options.subformDList[id].width,
|
listData: customBase.options.dropdownlistText[customShow.options.subformDList[id].selectId],
|
setDiv: id
|
};
|
// //////console.log($(".customViewUEditorCss ."+id).find('select > option'));
|
if ($(".customViewUEditorCss ." + id).find('select > option').length == 0) {
|
// //////console.log("----------------------------------------------");
|
console.log(1)
|
xhSelect.setXhSelect(xhSelectTemp);
|
}
|
}
|
}
|
xhSelect.setXhSelect(xhSelectTemp);
|
//10/2/27 马习同修改 下拉框复制重复
|
}
|
|
|
customShow.getFormSetting = function (btnFlag) {
|
var ren = 1;
|
if (btnFlag == 'printableBtn') {
|
ren = customShow.options.formsetting['printable'];
|
} else if (btnFlag == 'exportBtn') {
|
ren = customShow.options.formsetting['exportable'];
|
} else if (btnFlag == 'rejectBtn') {
|
ren = customShow.options.formsetting['rejectable'];
|
} else if (btnFlag == 'submitBtn') {
|
ren = customShow.options.formsetting['submitable'];
|
} else if (btnFlag == 'auditableBtn') {
|
ren = customShow.options.formsetting['auditable'];
|
} else if (btnFlag == 'queryBtn') {
|
ren = customShow.options.formsetting['queryable'];
|
} else if (btnFlag == 'createBtn') {
|
ren = customShow.options.formsetting['createable'];
|
} else if (btnFlag == 'clearBtn') {
|
// ren = customShow.options.formsetting['clearable'];
|
ren = 1;
|
} else if (btnFlag == 'disposableBtn') {
|
// ren = customShow.options.formsetting['disposable'];
|
ren = 1;
|
}
|
//else if (btnFlag == 'fromSaveBtn') {
|
// if(customShow.options.customShowFlag != '3'){//发布修改 李伟民 0120
|
// ren = customShow.options.formsetting['saveable'];
|
// console.log(ren)
|
// }else{
|
// ren = 1;
|
// }
|
// ren = 1;
|
} else if (btnFlag == 'editableBtn') {
|
ren = customShow.options.formsetting['editableBtn'];//编辑按钮受权限控制 李伟民 0204
|
// ren = 1;
|
}
|
return ren;
|
|
}
|
var customLinkageAnalysis = customLinkageAnalysis || {};
|
//-----------------------------------------------------仲追加内容----------------------------------------------------------
|
customLinkageAnalysis.options = {};
|
//取得表单值
|
/**
|
* 参数:ItemId 字段ID
|
* 返回值:值
|
*/
|
customLinkageAnalysis.getValue = function (itemId) {
|
var item = customShow.options.customItemShow.item[itemId];
|
var alias = item.tag_Attribute.alias;
|
var items = customShow.getItems();
|
var result = items[alias];
|
|
if (item.parentsubFormNum != 0) {
|
for (var ItemId in customShow.options.customItemShow.item) {
|
if (customShow.options.customItemShow.item[ItemId].columnOrderNum == item.parentsubFormNum) {
|
result = items[customShow.options.customItemShow.item[ItemId].tag_Attribute.alias];
|
}
|
}
|
////console.log(result);
|
var resultTemp = "";
|
|
for (var i = 0; i < result.length; i++) {
|
if (i > 0) {
|
resultTemp += ",";
|
}
|
if (typeof result[i][alias] != "string") {
|
resultTemp += result[i][alias].join(',');
|
} else {
|
resultTemp += result[i][alias];
|
}
|
|
}
|
////console.log(resultTemp);
|
return resultTemp;
|
} else if (typeof result != "string") {
|
result = result.join(',');
|
}
|
////console.log(customShow);
|
////console.log(customLinkageAnalysis);
|
console.log(result);
|
return result;
|
}
|
|
//设定表单值--------------------
|
/**
|
* 参数:ItemId 字段ID
|
* value:设定值
|
*/
|
customLinkageAnalysis.setValue = function (itemId, value, num) {
|
console.log(itemId);
|
console.log(value);
|
var item = customShow.options.customItemShow.item[itemId];
|
//数据类型
|
var type = item.tag_Type;
|
if (type == "text" || type == "textarea" ||
|
type == "number" || type == "calendar") {
|
customBase.setItemValue(itemId, "text", value, "", "", num);
|
} else if (type == "radio" || type == "checkbox") {
|
if (value.indexOf(",") != -1) {
|
value = value.split(",");
|
value = [value];
|
}
|
customBase.setItemValue(itemId, type, value, "customViewUEditorCss");
|
} else if (type == "dropdownlist") {
|
var dropdowntype = item.tag_Attribute.dropdowntype;
|
customBase.setItemValue(itemId, "dropdownlistText", value, "customViewUEditorCss", dropdowntype);
|
} else if (type == "htmlediter") {
|
var id = itemId + "Item";
|
UE.getEditor(id).setContent(value);
|
} else if (type == "qrcode") {
|
var id = itemId + "qrcode";
|
customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
|
$("#" + id).blur();
|
} else if (type == "barcode") {
|
var id = itemId + "barcode";
|
customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
|
$("#" + id).blur();
|
} else if (type == "tree") {
|
|
} else if (type == "amount") {
|
var id = itemId + "amount";
|
customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
|
$("#" + id).blur();
|
}
|
|
}
|
|
//取得属性
|
/**
|
* 参数:ItemId 字段ID
|
* attributeName:属性名
|
* visible //可见 true:可见 false:不可见
|
editable //可编辑 true:可编辑 false:不可编辑
|
*/
|
customLinkageAnalysis.getAttribut = function (itemId, attributeName) {
|
console.log(itemId);
|
console.log(attributeName)
|
var item = customShow.options.customItemShow.item[itemId];
|
// return customLinkageAnalysis.validationEx(item.tag_Attribute.alias);
|
var alias = item.tag_Attribute.alias;
|
var ttn = customBase.options.customItems[alias][attributeName];
|
////console.log(ttn)
|
return ttn;
|
}
|
|
//设定属性---------------需要测试-----
|
/**
|
* 参数:ItemId 字段ID
|
* attributeName:属性名
|
* visible //可见 true:可见 false:不可见
|
editable //可编辑 true:可编辑 false:不可编辑
|
*/
|
customLinkageAnalysis.setAttribut = function (itemId, attributeName, attributeValue) {
|
var item = customShow.options.customItemShow.item[itemId];
|
// return customLinkageAnalysis.validationEx(item.tag_Attribute.alias);
|
var alias = item.tag_Attribute.alias;
|
console.log(alias)
|
attributeValue = attributeValue + "";
|
attributeValue = attributeValue.toLowerCase();
|
if (attributeValue == "true") {
|
attributeValue = true;
|
} else if (attributeValue == "false") {
|
attributeValue = false;
|
} else {
|
//默认值
|
attributeValue = true;
|
}
|
customBase.options.customItems[alias][attributeName] = attributeValue;
|
customShow.setShowAttribute(customBase.options.customItems[alias]);
|
}
|
|
//设定错误信息
|
/**
|
* 参数:ItemId 字段ID
|
* message:信息
|
*/
|
customLinkageAnalysis.setMessage = function (mode, ItemId, message, num) {
|
var item = customShow.options.customItemShow.item[ItemId];
|
var type = item.tag_Type;
|
if (num == undefined) {
|
num = 0;
|
}
|
var errorClass;
|
if (mode == "0") {//验证消息 修改 李伟民
|
errorClass = "errorCheckCss"
|
} else {
|
errorClass = "errorItemCss";
|
}//验证消息 修改 李伟民
|
customShow.showErrorItem(errorClass, type, ItemId, num);
|
//焦点事件
|
// $("." + errorClass).unbind('focus');
|
$("[id='" + ItemId + "']:eq(" + num + ")").unbind("focus");
|
$("[id='" + ItemId + "']:eq(" + num + ")").on('focus', function () {
|
console.log("focus");
|
$(this).removeClass(errorClass);
|
////////console.log($(this)[0].id);
|
$(this).closest("#" + $(this)[0].id + "ActiveId").find("[id='" + $(this)[0].id + "mesageErrDiv']").remove();//修改错误信息删除 李伟民 2017-10-18 14:15
|
$(this).closest(".tdContentClass").find("[id='" + $(this)[0].id + "mesageErrDiv']").remove();//列表模式
|
// $("#"+$(this)[0].id+"mesageErrDiv").remove();
|
$(".customViewUEditorCss #" + $(this)[0].id).popover('hide')
|
});
|
//下拉列表点击事件
|
$(".select2-search__field").unbind("focus");
|
$(".select2-search__field").bind("focus", function () {
|
var id = this.getAttribute("errorItemId");
|
var N = this.getAttribute("N");
|
$($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2").removeClass(errorClass);
|
$("#" + id + "mesageErrDiv").remove();
|
$($(".customViewUEditorCss #" + id)[N]).popover('hide')
|
});
|
if (mode == "0") {//验证消息 修改 李伟民
|
customShow.setShowMesageErr(ItemId, message, num, true);
|
} else {
|
customShow.setShowMesageErr(ItemId, message, num);
|
}//验证消息 修改 李伟民
|
|
}
|
|
//设定alert信息
|
//参数:type类型
|
// E:错误信息
|
// I:信息
|
// W:警告
|
// S:成功
|
// message:信息
|
customLinkageAnalysis.alert = function (type, message) {
|
customBase.alert(type, message);
|
}
|
|
|
|
// 初期调用
|
customLinkageAnalysis.bindLinkage = function () {
|
// ////console.log(window.customBase);
|
//取得公式的JSON数据
|
// ////console.log(customShow);
|
// ////console.log(customLinkageAnalysis);
|
var rules = customShow.options.jsonLinkage;
|
if (typeof rules == 'string') {
|
rules = eval(rules);
|
}
|
if (rules == null || rules.length == 0) {
|
return;
|
}
|
//初期接口 (false:不继续执行 true:继续执行)
|
// customShow.initEvent.interfaceInitLinkage;
|
|
//取消接口 (false:不继续执行 true:继续执行)
|
// customShow.initEvent.cancelEventLinkage;
|
|
//保存接口 (false:不继续执行 true:继续执行)
|
// customShow.initEvent.fromSaveLinkage;
|
for (var i = 0; i < rules.length; i++) {
|
//console.log(rules[i]);
|
var dofunction = {};
|
try {
|
dofunction = customLinkageAnalysis.makeLinkage(rules[i]);
|
} catch (e) {
|
////console.log(e.message);
|
continue;
|
}
|
var allFunction = customLinkageAnalysis.changeDoFunction(dofunction);
|
var fieldId = rules[i].event.eventFieldId;
|
if (fieldId == "_body" && rules[i].event.doEvent == "loading") {
|
customShow.initEvent.interfaceInitLinkage = customLinkageAnalysis.bindFunctionEvent(allFunction.strFunction);
|
} else if (fieldId == "_body" && rules[i].event.doEvent == "commit") {
|
customShow.initEvent.fromSaveLinkage = customLinkageAnalysis.bindFunctionEvent(allFunction.strFunction);
|
}
|
var item = customShow.options.customItemShow.item[fieldId];
|
if (item != undefined) {
|
var doEvent = rules[i].event.doEvent;
|
doEvent = doEvent.replace("selectedChange", "change");
|
if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
|
doEvent = doEvent.replace("change", "click");
|
}
|
if (item.tag_Type == "amount" || item.tag_Type == "qrcode" || item.tag_Type == "barcode") {
|
fieldId = fieldId + item.tag_Type;
|
}
|
if (item.tag_Type == "htmlediter") {
|
UE.getEditor(fieldId + "Item").onclick = function (event, ui) {
|
// eval(strFunction);
|
// ////console.log(UE.getEditor(fieldId+"Item").getContent());
|
customLinkageAnalysis.options[fieldId + "Item"] = UE.getEditor(fieldId + "Item").getContent();
|
}
|
UE.getEditor(fieldId + "Item").onblur = function (event, ui) {
|
//////console.log(UE.getEditor(fieldId+"Item").getContent());
|
var fieldIdItem = UE.getEditor(fieldId + "Item").getContent();
|
if (fieldIdItem != customLinkageAnalysis.options[fieldId + "Item"]) {
|
eval(allFunction.strFunction);
|
}
|
|
}
|
////console.log(UE.getEditor(fieldId+"Item"));
|
} else if (item.tag_Type == "tree") {
|
customBase.options.zTreeOnClickItems[fieldId + "tree"] = allFunction.strFunction;
|
} else if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
|
|
} else {
|
customLinkageAnalysis.bindEvent(fieldId, doEvent, allFunction);
|
}
|
|
}
|
_.each(rules[i].results, function (ru) {// 自定义验证 为弹出消息控件绑定验证方法 李伟民 2017-10-18 15:09
|
if ((ru.mode == "2" || ru.mode == "0") && rules[i].event.eventFieldId != ru.eventFieldId) {//判断是否为验证公式 判断触发控件与弹出消息控件是否为同一控件
|
//console.log(ru);
|
customLinkageAnalysis.bindEvent(ru.eventFieldId, "blur", allFunction);
|
}
|
});// 自定义验证 为弹出消息控件绑定验证方法 李伟民 2017-10-18 15:09 end
|
}
|
}
|
|
|
// 子控件事件调用时
|
customLinkageAnalysis.bindLinkageSubform = function (inType) {
|
//取得公式的JSON数据
|
var rules = customShow.options.jsonLinkage;
|
if (typeof rules == 'string') {
|
rules = eval(rules);
|
}
|
if (rules == null || rules.length == 0) {
|
return;
|
}
|
// if("calendar" == inType){
|
// $("#"+fieldId).unbind();
|
// }
|
for (var i = 0; i < rules.length; i++) {
|
var dofuncion = "";
|
try {
|
dofuncion = customLinkageAnalysis.makeLinkage(rules[i]);
|
} catch (e) {
|
////console.log(e.message);
|
continue;
|
}
|
var fieldId = rules[i].event.eventFieldId;
|
var item = customShow.options.customItemShow.item[fieldId];
|
var strFunction = customLinkageAnalysis.changeDoFunction(dofuncion);
|
if (item != undefined) {
|
var doEvent = rules[i].event.doEvent;
|
doEvent = doEvent.replace("selectedChange", "change");
|
// if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
|
// // doEvent = doEvent.replace("change", "click");
|
// }
|
if (inType == item.tag_Type) {
|
if (item.tag_Type == "radio") {
|
$("#" + fieldId + ' .custom-radio').on('click', function () {
|
// //////console.log(this.className);
|
if (this.className.indexOf("readonly") > -1) {
|
return;
|
}
|
eval(strFunction);
|
});
|
} else if (item.tag_Type == "checkbox") {
|
$("#" + fieldId + ' .custom-check').on('click', function () {
|
// //////console.log(this.className);
|
if (this.className.indexOf("readonly") > -1) {
|
return;
|
}
|
eval(strFunction);
|
});
|
} else {
|
customLinkageAnalysis.bindEvent(fieldId, doEvent, strFunction);
|
}
|
|
}
|
}
|
}
|
}
|
|
customLinkageAnalysis.bindFunctionEvent = function (strFunction) {
|
//console.log(strFunction);
|
return function () {
|
try {
|
eval(strFunction);
|
} catch (e) {
|
////console.log(e.message);
|
}
|
}
|
}
|
|
customLinkageAnalysis.changeDoFunction = function (doFunction) {
|
var conditionCode = doFunction.conditionCode;
|
//console.log(doFunction);
|
var code = "";
|
var strFunction = "";
|
var checkFunction = "";// 单独检查校验规则代码 李伟民 2017-10-19 14:33
|
if (conditionCode != null) {
|
code = conditionCode.code
|
var conditionListCode = conditionCode.listCode;
|
|
for (var i = 0; i < conditionListCode.length; i++) {
|
strFunction += "var code" + i + " = " + conditionListCode[i] + ";\r\n";
|
checkFunction += "var code" + i + " = " + conditionListCode[i] + ";\r\n";// 单独检查校验规则代码 李伟民 2017-10-19 14:33
|
var reg = new RegExp('\\{' + i + '\\}', "g");
|
code = code.replace(reg, "\"+customLinkageAnalysis.changeEvalType(eval('code" + i + "'))+\"");
|
}
|
for (var i = 0; i < conditionListCode.length; i++) {
|
var reg = new RegExp('\\{' + i + '\\}', "g");
|
strFunction = strFunction.replace(reg, "code" + i);
|
checkFunction = strFunction.replace(reg, "code" + i);// 单独检查校验规则代码 李伟民 2017-10-19 14:33
|
}
|
if (conditionCode.clearCode != undefined) {//添加清空错误信息 李伟民 2017-10-18 17:45
|
_.each(conditionCode.clearCode, function (_clearCode) {
|
strFunction += _clearCode;
|
checkFunction += _clearCode;// 单独检查校验规则代码 李伟民 2017-10-19 14:33
|
})
|
}//添加清空错误信息 李伟民 2017-10-18 17:45 end
|
if (code != null && code != "") {
|
if (code.indexOf('Math.floor') != -1) {
|
code = eval(code);
|
////console.log(code);
|
}
|
code = "customLinkageAnalysis.expeval(\"=" + code + "\")";
|
strFunction += "if (" + code + " == 'true') { \r\n";
|
checkFunction += "if (" + code + " == 'true') { \r\n";// 单独检查校验规则代码 李伟民 2017-10-19 14:33
|
}
|
}
|
var results = doFunction.results;
|
for (var i = 0; i < results.length; i++) {
|
var resultValue = results[i].resultValue;
|
var resultJsText = results[i].resultJsText;
|
if (resultValue != null) {
|
var listCode = resultValue.listCode;
|
var resultCode = resultValue.code;
|
for (var j = 0; j < listCode.length; j++) {
|
strFunction += "var resultCode" + j + " = " + listCode[j] + ";\r\n";
|
var reg = new RegExp('\\{' + j + '\\}', "g");
|
////console.log(resultCode);
|
resultCode = resultCode.replace(reg, "\"+customLinkageAnalysis.changeEvalType(eval('resultCode" + j + "'))+\"");
|
}
|
for (var j = 0; j < listCode.length; j++) {
|
var reg = new RegExp('\\{' + j + '\\}', "g");
|
strFunction = strFunction.replace(reg, "resultCode" + j);
|
}
|
// if(resultCode.indexOf('Math.floor') != -1){
|
////console.log(resultCode);
|
// resultCode = eval(resultCode);
|
// }
|
//console.log(resultCode);
|
resultCode = "customLinkageAnalysis.expeval(\"=" + resultCode + "\")";
|
strFunction += resultJsText.replace(/\{0\}/g, resultCode);
|
} else if (results[i].resultJsText.indexOf("setMessage")) {// 判断是否为 规则校验公式
|
strFunction += resultJsText + "; \r\n";
|
checkFunction += resultJsText + "; \r\n";// 单独检查校验规则代码 李伟民 2017-10-19 14:33
|
} else {
|
strFunction += resultJsText + "; \r\n";
|
}
|
//公式联动追加
|
if (results[i].doEvent != undefined && results[i].resultJsText.indexOf("setValue") != -1) {
|
strFunction += '$("#' + results[i].targetid + '").trigger("' + results[i].doEvent + '.value");';
|
}
|
|
//公式联动追加结束
|
|
}
|
|
if (code != null && code != "") {
|
strFunction += "}";
|
checkFunction += "}";// 单独检查校验规则代码 李伟民 2017-10-19 14:33
|
}
|
////console.log(strFunction);
|
var allFunction = { "strFunction": strFunction, "checkFunction": checkFunction };
|
return allFunction;
|
}
|
|
function funCheck(optarr, allFunction) {//判断是否重复绑定方法
|
var flag = true;
|
if (optarr != undefined && optarr != '') {
|
optarr = JSON.parse(optarr);
|
console.log(optarr);
|
console.log(allFunction);
|
_.each(optarr, function (fn) {
|
if (fn.strFunction == allFunction.strFunction && fn.checkFunction == allFunction.checkFunction) {
|
console.log("falg false");
|
flag = false;
|
}
|
})
|
}
|
return flag;
|
}
|
|
customLinkageAnalysis.bindEvent = function (fieldId, doEvent, allFunction) {//aaaaaa
|
console.log(allFunction);
|
var evalstr = "";
|
var evalchekstr = "";
|
////console.log(customShow.options.customItemShow.item[fieldId].tag_Type);
|
if (customShow.options.customItemShow.item[fieldId].tag_Type == "dropdownlist") {
|
////console.log($("[id='" + fieldId+"']"));
|
////console.log($("[id='" + fieldId+"']").find(".select_get"));
|
////console.log($(".select_get"));
|
////console.log(strFunction);
|
_.each($("[id='" + fieldId + "']").find(".select_get"),function(opt){
|
var optarr = $(opt).attr("funarr");
|
if(funCheck(optarr,allFunction)){
|
$(opt).on(doEvent + ".value", function () {
|
if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
|
// _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
|
if (allFunction.strFunction.indexOf("var i=") == -1) {
|
////console.log(i);
|
evalstr = "var i=" + $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.strFunction;
|
}
|
// })
|
}else{
|
evalstr = allFunction.strFunction;
|
}
|
try {
|
console.log(evalstr);
|
eval(evalstr);
|
} catch (e) {
|
////console.log(e.message);
|
}
|
});
|
var funarr;
|
if($(opt).attr("funarr") == undefined || $(opt).attr("funarr") == ""){
|
funarr = [allFunction];
|
}else{
|
funarr = JSON.parse($(opt).attr("funarr"));
|
funarr.push(allFunction);
|
}
|
$(opt).attr("funarr",JSON.stringify(funarr));
|
}
|
var checkarr = $(opt).attr("checkfunarr");
|
if(funCheck(checkarr,allFunction)){
|
$(opt).on(doEvent + ".check", function () {//单独检验校验规则绑定 李伟民 2017-10-19 15:18
|
if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
|
// _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
|
if (allFunction.checkFunction.indexOf("var i=") == -1) {
|
evalchekstr = "var i=" + $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.checkFunction;
|
}
|
// })
|
}else{
|
evalchekstr = allFunction.checkFunction;
|
}
|
try {
|
eval(evalchekstr);
|
} catch (e) {
|
//console.log(e.message);
|
}
|
});//单独检验校验规则绑定 李伟民 2017-10-19 15:18 end
|
var checkfunarr;
|
if($(opt).attr("checkfunarr") == undefined || $(opt).attr("checkfunarr") == ""){
|
checkfunarr = [allFunction];
|
}else{
|
checkfunarr = JSON.parse($(opt).attr("checkfunarr"));
|
checkfunarr.push(allFunction);
|
}
|
$(opt).attr("checkfunarr",JSON.stringify(checkfunarr));
|
}
|
|
});
|
// $("[id='" + fieldId + "']").find(".select_get").on(doEvent + ".value", function () {
|
// if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
|
// // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
|
// if (allFunction.strFunction.indexOf("var i=") == -1) {
|
// ////console.log(i);
|
// evalstr = "var i=" + $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.strFunction;
|
// }
|
// // })
|
// }else{
|
// evalstr = allFunction.strFunction;
|
// }
|
// try {
|
// console.log(evalstr);
|
// eval(evalstr);
|
// } catch (e) {
|
// ////console.log(e.message);
|
// }
|
// });
|
// $("[id='" + fieldId + "']").find(".select_get").unbind(doEvent + ".check");
|
// $("[id='" + fieldId + "']").find(".select_get").on(doEvent + ".check", function () {//单独检验校验规则绑定 李伟民 2017-10-19 15:18
|
// if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
|
// // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
|
// if (allFunction.checkFunction.indexOf("var i=") == -1) {
|
// evalchekstr = "var i=" + $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.checkFunction;
|
// }
|
// // })
|
// }else{
|
// evalchekstr = allFunction.checkFunction;
|
// }
|
// try {
|
// eval(evalchekstr);
|
// } catch (e) {
|
// //console.log(e.message);
|
// }
|
// });//单独检验校验规则绑定 李伟民 2017-10-19 15:18 end
|
} else {
|
// $("[id='" + fieldId + "']").unbind(doEvent + ".value");
|
_.each($("[id='" + fieldId + "']"),function(opt){
|
var optarr = $(opt).attr("funarr");
|
if(funCheck(optarr,allFunction)){
|
$(opt).on(doEvent + ".value", function () {
|
if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0 && allFunction.strFunction.indexOf("getSum") == -1) {
|
console.log($("[id='" + fieldId + "']"));
|
console.log($(this));
|
console.log($("[id='" + fieldId + "']").index(this));
|
// _.each($("[id='" + fieldId + "']"), (item, i) => {
|
// console.log($(item));
|
if (allFunction.strFunction.indexOf("var i=") == -1) {
|
////console.log(i);
|
evalstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.strFunction;
|
}
|
// })
|
}else if(allFunction.strFunction.indexOf("getSum") > 0){
|
console.log(allFunction.strFunction);
|
console.log("replace");
|
evalstr = allFunction.strFunction;
|
// allFunction.strFunction = allFunction.strFunction.replace(new RegExp(".split(',')[i]") ,"");
|
while(evalstr.indexOf(".split(',')[i]") != -1){
|
evalstr = evalstr.replace(".split(',')[i]","");
|
}
|
}else{
|
evalstr = allFunction.strFunction;
|
}
|
// try {
|
console.log(evalstr);
|
eval(evalstr);
|
// } catch (e) {
|
// ////console.log(e.message);
|
// }
|
});
|
var funarr;
|
if($(opt).attr("funarr") == undefined || $(opt).attr("funarr") == ""){
|
funarr = [allFunction];
|
}else{
|
funarr = JSON.parse($(opt).attr("funarr"));
|
funarr.push(allFunction);
|
}
|
$(opt).attr("funarr",JSON.stringify(funarr));
|
|
};
|
var checkarr = $(opt).attr("checkfunarr");
|
if(funCheck(checkarr,allFunction)){
|
$(opt).on("blur.check", function () {//单独检验校验规则绑定 李伟民 2017-10-19 15:18
|
if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
|
console.log("change.check");
|
_.each($("[id='" + fieldId + "']"), (item, i) => {
|
if (allFunction.checkFunction.indexOf("var i=") == -1) {
|
////console.log(i);
|
evalchekstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.checkFunction;
|
}
|
})
|
}else{
|
evalchekstr = allFunction.checkFunction;
|
}
|
try {
|
if(evalchekstr.indexOf('alert') == -1){
|
eval(evalchekstr);
|
}
|
} catch (e) {
|
////console.log(e.message);
|
}
|
});//单独检验校验规则绑定 李伟民 2017-10-19 15:18 end
|
var checkfunarr;
|
if($(opt).attr("checkfunarr") == undefined || $(opt).attr("checkfunarr") == ""){
|
checkfunarr = [allFunction];
|
}else{
|
checkfunarr = JSON.parse($(opt).attr("checkfunarr"));
|
checkfunarr.push(allFunction);
|
}
|
$(opt).attr("checkfunarr",JSON.stringify(checkfunarr));
|
}
|
|
});
|
// $("[id='" + fieldId + "']").unbind(doEvent + ".check");
|
// $("[id='" + fieldId + "']").on(doEvent + ".check", function () {//单独检验校验规则绑定 李伟民 2017-10-19 15:18
|
// if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
|
// console.log("change.check");
|
// _.each($("[id='" + fieldId + "']"), (item, i) => {
|
// if (allFunction.checkFunction.indexOf("var i=") == -1) {
|
// ////console.log(i);
|
// evalchekstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.checkFunction;
|
// }
|
// })
|
// }else{
|
// evalchekstr = allFunction.checkFunction;
|
// }
|
// try {
|
// eval(evalchekstr);
|
// } catch (e) {
|
// ////console.log(e.message);
|
// }
|
// });//单独检验校验规则绑定 李伟民 2017-10-19 15:18 end
|
}
|
}
|
|
customLinkageAnalysis.changeEvalType = function (str) {
|
console.log(str);
|
if (isNaN(Number(str)) && (str.substring(0, 1) != "\"" || str.substring(str.length - 1, 1) != "\"") && (str.indexOf('||') != -1) && (str.indexOf('&&') != -1)) {//|| && 修改 李伟民 公式不稳定修改 0202
|
return "'" + str + "'";
|
} else {
|
////console.log(str);
|
return str;
|
}
|
}
|
|
//事件绑定调用
|
//事件绑定:字段ID:ItemId 事件名 自定义事件名
|
//参数
|
// eventItem=[{
|
// ItemId:"Item_1", 控件id
|
// event:"click", 事件
|
// eventmethod:"XXXXXXXXXXXXXXXXXXXX" 自定义事件名
|
// }]
|
customLinkageAnalysis.setEventBind = function (eventItem) {
|
customShow.setEventBindItem(eventItem);
|
}
|
//03检证执行(接口)
|
customLinkageAnalysis.validationEx = {
|
get: function (alias) {
|
var itemTempS;
|
var item = customBase.options.customItems[alias];
|
if (item.type == "button" || item.type == "link") {
|
} else if (item.type == "dropdownlist") {
|
var datasourcetype = $("#" + item.id)[0].getAttribute("datasourcetype");
|
//////////console.log(datasourcetype);
|
//主数据源
|
if (datasourcetype == "masterdata") {
|
itemTempS = customBase.getItemValue(item.id, item.type);
|
//数据源
|
} else if (datasourcetype == "datasource") {
|
itemTempS = customBase.getItemValue(item.id, "dropdownlistText");
|
//自定义
|
} else if (datasourcetype == "custom") {
|
itemTempS = customBase.getItemValue(item.id, "dropdownlistText");
|
//API接口
|
} else if (datasourcetype == "api") {
|
itemTempS = customBase.getItemValue(item.id, item.type);
|
}
|
} else if (item.type == "subform") {
|
|
} else {
|
itemTempS = customBase.getItemValue(item.id, item.type);
|
}
|
item.value = itemTempS;
|
////////console.log(item);
|
return item;
|
}
|
}
|
//取得主数据
|
/*
|
itemId:项目ID
|
masterCode:执行CODE
|
返回值:元素的值
|
*/
|
customLinkageAnalysis.getElement = function (itemId, masterCode, num) {
|
var item = customShow.options.customItemShow.item[itemId];
|
var code = item.tag_Attribute.masterData;
|
var masterData = $.parseJSON(code);
|
var defindCode = masterData.defindCode;
|
var eleCode = masterData.eleCode;
|
var eleValue = customLinkageAnalysis.getValue(itemId);
|
if(num != undefined && eleValue != undefined && eleValue.indexOf(',') != -1){//子表单中控件处理 李伟民 0106
|
eleValue = eleValue.split(',')[num];
|
}
|
var opt = {
|
eleCode: eleCode,
|
defindCode: defindCode,
|
eleValue: eleValue,
|
masterCode: masterCode,
|
itemId: itemId
|
}
|
//主数据取得
|
var result = customDataBound.getElement1(opt);
|
console.log(result);
|
console.log(itemId)
|
if (result.rspCode == "000000") {
|
if (result.data[itemId].length > 0) {
|
console.log(result.data[itemId][0].value)
|
return result.data[itemId][0].value;
|
} else {
|
return "";
|
}
|
} else {
|
return "";
|
}
|
}
|
|
customLinkageAnalysis.clearMessage = function (itemId, num) {//清空错误信息方法 李伟民 2017-10-18 16:36
|
if (num == undefined) {
|
num = 0;
|
}
|
//console.log($("[id='"+itemId+"']:eq("+num+")"));
|
//console.log($("[id='"+itemId+"ActiveId']:eq("+num+")"));
|
$("[id='" + itemId + "']:eq(" + num + ")").removeClass("errorItemCss");
|
$("[id='" + itemId + "']:eq(" + num + ")").removeClass("errorCheckCss");
|
$("[id='" + itemId + "ActiveId']:eq(" + num + ")").find("#" + itemId + "mesageErrDiv").remove();
|
}//清空错误信息方法 李伟民 2017-10-18 16:36 end
|
|
customLinkageAnalysis.makeLinkage = function (rule) {
|
////console.log(rule);
|
var result = {};
|
var conditionCode = {};
|
conditionCode = customLinkageAnalysis.changeCodeMirror(rule.conditionCode, rule.conditionHistory._history);
|
|
if (rule.conditionCode != "" && !_.isNull(rule.conditionCode)) {//清空错误信息 李伟民 2017-10-18 16:36
|
var clearCode = [];
|
_.each(rule.results, function (ru) {
|
if (ru.mode == "2") {
|
var ruItem = customShow.options.customItemShow.item[ru.eventFieldId];
|
if (ruItem.parentsubFormNum != 0) {
|
clearCode.push("customLinkageAnalysis.clearMessage('" + ru.eventFieldId + "',i);");
|
} else {
|
clearCode.push("customLinkageAnalysis.clearMessage('" + ru.eventFieldId + "');");
|
}
|
}
|
});
|
conditionCode["clearCode"] = clearCode;
|
}//清空错误信息 李伟民 2017-10-18 16:36 end
|
|
var results = new Array();
|
for (var i = 0; i < rule.results.length; i++) {
|
var resultJs = {};
|
var textType = rule.results[i].attribute;
|
var resultJsText = "";
|
var resultTargrtItem = customShow.options.customItemShow.item[rule.results[i].eventFieldId]; if ("1" == rule.results[i].mode) {
|
var resultValue = customLinkageAnalysis.changeCodeMirror(rule.results[i].code, rule.results[i].eventHistory._history);
|
resultJs.resultValue = resultValue;
|
if (textType == 'value') {
|
if (resultTargrtItem.parentsubFormNum != 0) {
|
resultJsText += "customLinkageAnalysis.setValue('" + rule.results[i].eventFieldId + "', {0}, i);";
|
} else {
|
resultJsText += "customLinkageAnalysis.setValue('" + rule.results[i].eventFieldId + "', {0});";
|
}
|
} else if (textType == 'visible' || textType == 'editable') {
|
resultJsText += "customLinkageAnalysis.setAttribut('" + rule.results[i].eventFieldId + "','" + textType + "', {0});";
|
} else {
|
// todo
|
}
|
} else if ("2" == rule.results[i].mode || "0" == rule.results[i].mode) {
|
if (resultTargrtItem.parentsubFormNum != 0) {//自定义校验支持子表单中控件 李伟民 2017-10-18 14:34
|
// resultJsText += "customLinkageAnalysis.clearMessage('" + rule.results[i].eventFieldId + "',i);";
|
resultJsText += "customLinkageAnalysis.setMessage('" + rule.results[i].mode + "','" + rule.results[i].eventFieldId + "','" + rule.results[i].message + "',i);";
|
} else {
|
// resultJsText += "customLinkageAnalysis.clearMessage('" + rule.results[i].eventFieldId + "');";
|
resultJsText += "customLinkageAnalysis.setMessage('" + rule.results[i].mode + "','" + rule.results[i].eventFieldId + "','" + rule.results[i].message + "');";
|
}//自定义校验支持子表单中控件 李伟民 2017-10-18 14:34 end
|
|
} else if ("3" == rule.results[i].mode) {
|
resultJsText += "customLinkageAnalysis.alert('" + rule.results[i].messageType + "','" + rule.results[i].message + "');";
|
} else {
|
;
|
}
|
resultJs.resultJsText = resultJsText;
|
resultJs.targetid = rule.results[i].eventFieldId;// 公式联动追加 目标控件
|
var targetDoEvent = '';
|
// ////console.log(customShow.options.jsonLinkage);
|
var jsonLinkage_add = customShow.options.jsonLinkage;//预览公式联动修改 李伟民 0117
|
if (_.isString(jsonLinkage_add)) {
|
jsonLinkage_add = JSON.parse(jsonLinkage_add);
|
}
|
_.each(jsonLinkage_add, function (allrule) {// 公式联动追加 目标控件事件
|
if (allrule.event.eventFieldId == resultJs.targetid) {
|
resultJs.doEvent = allrule.event.doEvent;
|
}
|
});
|
results.push(resultJs);
|
}
|
result.conditionCode = conditionCode;
|
result.results = results;
|
////console.log(result);
|
return result;
|
}
|
|
customLinkageAnalysis.reachLeftSpace = function (str, length) {
|
var result = str;
|
if (str.length < length) {
|
var spaceLen = length - str.length;
|
for (var i = 0; i < spaceLen; i++) {
|
result = " " + result;
|
}
|
}
|
return result;
|
}
|
|
customLinkageAnalysis.replace = function (str, stringObj, replaceText, from, to) {
|
var resultBefore = str.substring(0, from);
|
var text = str.substring(from, to);
|
var resultAfter = str.substring(to);
|
text = text.replace(stringObj, customLinkageAnalysis.reachLeftSpace(replaceText, stringObj.length));
|
return resultBefore + text + resultAfter;
|
}
|
|
customLinkageAnalysis.changeCodeMirror = function (code, history) {
|
if (code.trim() == "") {
|
return null;
|
}
|
//console.log(code);
|
//console.log(history);
|
var result = {};
|
var conditionCode = "";
|
var listCode = new Array();
|
var arrConditionCode = code.split('\r\n');
|
////console.log(arrConditionCode);
|
var resultIndex = 0;
|
|
if (history != null && history.length > 0) {
|
for (var i = 0; i < history.length; i++) {
|
var line = history[i].from.line;
|
var fromCh = history[i].from.ch;
|
var toCh = history[i].to.ch;
|
var text = history[i].text;
|
arrConditionCode[line] = customLinkageAnalysis.replace(arrConditionCode[line], text, '{' + resultIndex + '}', fromCh, toCh);
|
var idText = history[i].idText;
|
var arrInputText = idText.split('.');
|
var replaceText = "";
|
var id = arrInputText[0];
|
var textType = arrInputText[1];
|
var idItem = customShow.options.customItemShow.item[id]; if (textType == 'value') {
|
if (idItem.parentsubFormNum != 0) {
|
replaceText = "customLinkageAnalysis.getValue('" + id + "').split(',')[i]";
|
} else {
|
replaceText = "customLinkageAnalysis.getValue('" + id + "')";
|
} // ////console.log(replaceText);
|
} else if (textType == 'visible' || textType == 'editable') {
|
replaceText = "customLinkageAnalysis.getAttribut('" + id + "','" + textType + "')";
|
} else {
|
if (idItem.parentsubFormNum != 0) {//主数据关联也需区分子表单中控件 李伟民 0106
|
replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "',i)";
|
} else {
|
replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "')";
|
}
|
// replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "')";
|
}
|
listCode.push(replaceText);
|
resultIndex++;
|
}
|
}
|
conditionCode = arrConditionCode.join('\r\n').replace(/\(/g, "###(###");
|
conditionCode = conditionCode.replace(/\)/g, "###)###");
|
arrConditionCode = conditionCode.split('\r\n');
|
conditionCode = arrConditionCode.join('\r\n');
|
conditionCode = conditionCode.replace(/AND/g, '&&');
|
conditionCode = conditionCode.replace(/OR/g, '||');
|
while (conditionCode.indexOf(' ') >= 0) {
|
conditionCode = conditionCode.replace(/ /g, ' ');
|
}
|
var conditionCodeResult = customLinkageAnalysis.changeSign(conditionCode, listCode, resultIndex);
|
conditionCode = conditionCodeResult.conditionCode;
|
resultIndex = conditionCodeResult.resultIndex;
|
conditionCode = conditionCode.replace(/###\(###/g, "(");
|
conditionCode = conditionCode.replace(/###\)###/g, ")");
|
result.code = conditionCode;
|
result.listCode = listCode;
|
//console.log(result);
|
return result;
|
}
|
|
customLinkageAnalysis.changeCodeSign = function (sign, inner) {
|
var exp = igame.Expression;
|
if (sign.indexOf('MAX') >= 0) {
|
sign = "Max";
|
} else if (sign.indexOf('MIN') >= 0) {
|
sign = "Min";
|
} else if (sign.indexOf('AVG') >= 0) {
|
sign = "Average";
|
} else if (sign.indexOf('SUM') >= 0) {
|
sign = "Sum";
|
} else if (sign.indexOf('COUNT') >= 0) {
|
sign = "Count";
|
} else if (sign.indexOf('||') >= 0) {//|| &&修改 李伟民 0202 公式不稳定修改
|
return sign + eval("[" + inner + "]").toString();
|
} else {
|
return "";
|
}
|
|
var arlInner = eval("[" + inner + "]");
|
return new exp.Formula(sign + "(" + arlInner.join(',') + ")").evaluate().toString();
|
}
|
|
customLinkageAnalysis.expeval = function (str) {
|
// console.log(str);
|
if (str.trim().replace(/=/, "") == "") {
|
console.log("str err");
|
return " ";
|
}
|
console.log("str scc");
|
var exp = igame.Expression;
|
// console.log(exp);
|
// console.log(str);
|
// console.log(new exp.Formula(str));
|
// console.log(new exp.Formula(str).evaluate());
|
// console.log(new exp.Formula(str).evaluate().toString());
|
return new exp.Formula(str).evaluate().toString();
|
}
|
|
customLinkageAnalysis.changeSign = function (conditionCode, listCode, resultIndex) {
|
////console.log(conditionCode);
|
var index = 0;
|
var indexOf = -1;
|
var result = {};
|
while ((indexOf = conditionCode.substring(index).indexOf('MAX')) >= 0
|
|| (indexOf = conditionCode.substring(index).indexOf('MIN')) >= 0
|
|| (indexOf = conditionCode.substring(index).indexOf('AVG')) >= 0
|
|| (indexOf = conditionCode.substring(index).indexOf('SUM')) >= 0
|
|| (indexOf = conditionCode.substring(index).indexOf('COUNT')) >= 0
|
|| (indexOf = conditionCode.substring(index).indexOf('parseInt')) >= 0
|
|| (indexOf = conditionCode.substring(index).indexOf('addtest')) >= 0
|
|| (indexOf = conditionCode.substring(index).indexOf('getDay')) >= 0
|
|| (indexOf = conditionCode.substring(index).indexOf('getSum')) >= 0) {//时间函数 李伟民 2017-10-17 21:49 修改公式
|
var before = conditionCode.substring(0, indexOf);
|
var beforeInner = 0;
|
var afterIndexOf = 0;
|
var sign;
|
var after;
|
if (history != null && history.length > 0) {
|
beforeInner = conditionCode.substring(indexOf).indexOf('###(###') + 7
|
// afterIndexOf = conditionCode.substring(indexOf).lastIndexOf('###)###');
|
afterIndexOf = customLinkageAnalysis.getBackBracketIndex(conditionCode.substring(indexOf), '###(###', '###)###');
|
sign = conditionCode.substring(indexOf).substring(0, beforeInner - 7);
|
after = conditionCode.substring(indexOf).substring(afterIndexOf + 7);
|
} else {
|
beforeInner = conditionCode.substring(indexOf).indexOf('(') + 1
|
// afterIndexOf = conditionCode.substring(indexOf).lastIndexOf(')');
|
afterIndexOf = customLinkageAnalysis.getBackBracketIndex(conditionCode.substring(indexOf), '(', ')');
|
sign = conditionCode.substring(indexOf).substring(0, beforeInner - 1);
|
after = conditionCode.substring(indexOf).substring(afterIndexOf + 1);
|
}
|
var inner = conditionCode.substring(indexOf).substring(beforeInner, afterIndexOf);
|
var innerResult = customLinkageAnalysis.changeSign(inner, listCode, resultIndex);
|
inner = innerResult.conditionCode;
|
resultIndex = innerResult.resultIndex;
|
inner = inner.replace(/###\(###/g, "(");
|
inner = inner.replace(/###\)###/g, ")");
|
if ((indexOf = conditionCode.substring(index).indexOf('parseInt')) >= 0
|
|| (indexOf = conditionCode.substring(index).indexOf('addtest')) >= 0
|
|| (indexOf = conditionCode.substring(index).indexOf('getDay')) >= 0
|
|| (indexOf = conditionCode.substring(index).indexOf('getSum')) >= 0) {//时间函数 李伟民 2017-10-17 21:49 修改公式
|
listCode.push(sign + "(" + inner + ")");
|
} else {
|
listCode.push("customLinkageAnalysis.changeCodeSign('" + sign + "',\[" + inner + "\])");
|
}
|
|
conditionCode = before + "{" + resultIndex + "}";
|
resultIndex++;
|
index = conditionCode.length - 1;
|
conditionCode += after;
|
}
|
result.conditionCode = conditionCode;
|
result.resultIndex = resultIndex;
|
////console.log(result);
|
return result;
|
}
|
addtest = function (arg1, arg2) {
|
return arg1 + arg2;
|
}
|
|
getDay = function (arg1, arg2) {//时间函数 李伟民 2017-10-17 21:49
|
var date1 = new Date(arg1)
|
var date2 = new Date(arg2)
|
var s1 = date1.getTime(), s2 = date2.getTime();
|
var total = (s1 - s2) / 1000;
|
var day = parseInt(total / (24 * 60 * 60));//计算整数天数
|
//console.log(day);
|
return day;
|
}//时间函数 李伟民 2017-10-17 21:49 end
|
|
getSum = function () {
|
console.log(arguments);
|
var allItem = [];
|
_.each(arguments, function (arg) {
|
allItem.push(arg.split(","));
|
});
|
console.log(allItem);
|
var sum = 0;
|
_.each(allItem, function (item) {
|
_.each(item, function (cd) {
|
sum += Number(cd);
|
})
|
})
|
return sum;
|
}
|
|
customLinkageAnalysis.getBackBracketIndex = function (str, strBracket, strBackBracket) {
|
var beforeIndex = str.indexOf(strBracket);
|
var backIndex = str.indexOf(strBackBracket);
|
var layers = 0;
|
while (beforeIndex < backIndex && beforeIndex >= 0) {
|
layers++;
|
beforeIndex = str.indexOf(strBracket, beforeIndex + strBracket.length)
|
}
|
while (layers > 1 && backIndex >= 0) {
|
layers--;
|
backIndex = str.indexOf(strBackBracket, backIndex + strBackBracket.length);
|
}
|
if (backIndex < 0) {
|
throw Error("括号未闭合");
|
}
|
return backIndex;
|
}
|
var customDataBound = customDataBound || {};
|
|
//根据表单ID取得表单基本信息
|
customDataBound.getFormbase = function (formid, callback) {
|
// if(customBase.options.formbaseInfo == ""){
|
var dataObj = {};
|
dataObj.formID = formid;
|
var requestRight = window.commonAjax("/formbase/getFormInfoService", dataObj, "GET", true);
|
requestRight.done(function (rs) {
|
callback(rs);
|
})
|
|
|
// }else{
|
// callback(customBase.options.formbaseInfo);
|
// }
|
}
|
|
//表单保存
|
customDataBound.savaFormbase = function (formbase, callback) {
|
////////////console.log(formbase);
|
var dataObj = {};
|
dataObj = formbase;
|
console.log(formbase);
|
var requestRight = window.commonAjax("/formbase/saveformService", dataObj, "POST", true);
|
requestRight.done(function (rs) {
|
|
callback(rs);
|
});
|
}
|
|
//表单数据保存
|
customDataBound.fromSave = function (formid, formbase, callback) {
|
// if(window.localStorage.getItem("bussinessSystem")){
|
// var flag = window.localStorage.getItem("bussinessSystem");
|
// }
|
var dataObj = {};
|
dataObj.formID = formid;
|
dataObj.data = formbase;
|
// dataObj.tenantID = "001";
|
// dataObj.flag = flag;
|
//dataObj.flag = "cloud"
|
//console.log(dataObj);
|
if (customShow.exCouldNumber != undefined && customShow.exCouldNumber != '') {//保存时 传云单标号 李伟民 12-22
|
_.extend(dataObj, { 'orderCode': customShow.exCouldNumber });
|
}//保存时 传云单标号 李伟民 12-22
|
//_.extend(dataObj,{'orderCode': '1012000170900005'});//临时修改
|
var requestRight = window.commonAjax("/datamanagement/addFormDataService", dataObj, "POST", true);
|
requestRight.done(function (rs) {
|
callback(rs);
|
});
|
}
|
|
//表单数据编辑
|
customDataBound.fromEdit = function (formid, formbase, dataRowNum, callback) {
|
var dataObj = {};
|
// if(window.localStorage.getItem("bussinessSystem")){
|
// var flag = window.localStorage.getItem("bussinessSystem");
|
// }
|
// dataObj.flag = flag;
|
dataObj.formID = formid;
|
dataObj.dataRowNum = dataRowNum;
|
dataObj.data = formbase;
|
if (customShow.exCouldNumber != undefined && customShow.exCouldNumber != '') {//保存时 传云单标号 李伟民 12-22
|
_.extend(dataObj, { 'orderCode': customShow.exCouldNumber });
|
}//保存时 传云单标号 李伟民 12-22
|
//_.extend(dataObj,{'orderCode': '1012000170900005'});//临时修改
|
var requestRight = window.commonAjax("/datamanagement/updateFormDataService", dataObj, "POST", true);
|
requestRight.done(function (rs) {
|
|
callback(rs);
|
});
|
}
|
|
// 获取表单设定数据源信息
|
|
// JSON:{"rspCode":"000000","rspDesc":"请求成功","data":[{"测试连接":["actor_id","first_name","last_name","last_update"]}]}
|
customDataBound.getDatasource = function (formID, callback) {
|
var dataObj = {};
|
dataObj.formID = formID;
|
// dataObj.formID = '8888';
|
// dataObj.tenantID = "001";
|
var requestRight = window.commonAjax("/datasource/getDatasourceColumnsNameService", dataObj, "GET", true);
|
|
requestRight.done(function (rs) {
|
if (rs.rspCode == "000000") {
|
callback(rs.data);
|
} else {
|
callback(rs.data);
|
}
|
});
|
}
|
|
// 获取当前表单设置字段的数据源信息 数据绑定
|
// 参数: formID,tenantID
|
// JSON: {"rspCode":"000000","rspDesc":"请求成功","data":[{"单选按钮组测试":{"datasource":"","textcolumn":"","valuecolumn":""}}]}
|
customDataBound.getFieldDatasource = function (Datasource, callback) {
|
url = "/datasource/getDatasourceColumnsValueService?tenantID={tenantID}&databaseName={databaseName}&datasource={datasource}&columnNames={columnNames}&callbackId={callbackId}";
|
url = url.replace("{databaseName}", Datasource.databaseName);
|
url = url.replace("{columnNames}", Datasource.columnNames);
|
url = url.replace("{datasource}", Datasource.datasource);
|
url = url.replace("{callbackId}", Datasource.callbackId);
|
|
window.commonGetJson(url, callback);
|
|
}
|
|
// 获得主数据
|
customDataBound.getElement = function (code, callbackId, callback) {
|
if (code != "") {
|
var dataObj = {};
|
dataObj.tenantIDForMaster = 1;
|
dataObj.code = code;
|
dataObj.callbackId = callbackId;
|
//console.log(dataObj);
|
let customlocalStorage = window.localStorage.getItem("bussinessSystem");
|
var reg = new RegExp('"', "g"); // service 修改 李元杰 11-16
|
customlocalStorage = customlocalStorage.replace(reg, ""); // service 修改 李元杰 11-16
|
console.log(customlocalStorage);
|
dataObj.flag = customlocalStorage;
|
var requestRight = window.commonAjax("/te-csc-api/search/base/elementprivate", dataObj, "GET", true);
|
|
requestRight.done(function (rs) {
|
console.log(rs)
|
if (rs.rspCode == "000000") {
|
console.log(rs)
|
callback(rs);
|
customShow.addTitle();
|
SC.money_cur();
|
// 12/13
|
|
console.log(window.localStorage.getItem('customShowFlag'))
|
if (window.localStorage.getItem('customShowFlag') == 1) {
|
// customShow.businessTypeAutoFun( 'businessTypeAuto','budget_itemCostType');
|
SC.autoFieldKey();
|
}
|
} else {
|
callback(rs);
|
console.log(rs)
|
toastr.error(rs.rspDesc.responseJSON);
|
}
|
});
|
requestRight.error(function (rs) {
|
// console.log(rs)
|
// toastr.error(rs.responseJSON.rspDesc);
|
|
})
|
} else {
|
callback([]);
|
}
|
|
}
|
|
// 获得主数据
|
customDataBound.getElement1 = function (opt) {
|
var dataObj = {};
|
// dataObj.tenantIDForMaster = 1;
|
// dataObj.code =opt;
|
// dataObj.callbackId = callbackId;
|
var result;
|
var requestRight = window.commonAjax("/te-csc-api/search/base/elementprivate1", opt, "GET", true, false);
|
requestRight.done(function (rs) {
|
if (rs.rspCode == "000000") {
|
result = rs;
|
} else {
|
result = rs;
|
}
|
});
|
return result;
|
}
|
|
// 获取当前表单设置字段的数据源信息 API数据取得
|
// 参数: formID,tenantID
|
// JSON: {"rspCode":"000000","rspDesc":"请求成功","data":[{"单选按钮组测试":{"datasource":"","textcolumn":"","valuecolumn":""}}]}
|
customDataBound.getApiDatasource = function (url, callbackId, callback) {
|
// console.log(1);
|
var urls = url;
|
var url = url + "&callbackId={callbackId}";
|
|
url = url.replace("{callbackId}", callbackId);
|
// var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
|
// xhr.open("GET", urls, true);
|
// debugger
|
// xhr.onreadystatechange = function () {
|
// var res = JSON.parse(xhr.responseText);
|
// console.log(res);
|
// }
|
$.ajax({
|
type: "get",
|
url: urls,
|
async: true,
|
success: function (rs) {
|
console.log(url);
|
console.log(rs);
|
callback(rs, url);
|
}
|
});
|
// // var url = url + "&callbackId={callbackId}";
|
// // url = url.replace("{callbackId}", callbackId);
|
// // //////////console.log(url);
|
// // window.commonGetApiJson(url, callback);
|
// //////////console.log(url);
|
// //window.commonGetApiJson(url,callback);
|
}
|
|
customDataBound.bindInterface = function (formid) {//绑定接口注册方法//保存前计算费用 李伟民 10 - 31
|
var dataObj = {};
|
dataObj.formID = formid;
|
var accessToken = JSON.parse(localStorage.getItem("token")).accessToken;
|
dataObj.access_token = accessToken;
|
var requestRight = window.commonAjax("/forminterface/getFormInterfaceListService", dataObj, "GET", true, false);
|
requestRight.done(function (rs) {
|
//console.log(rs);
|
customBase.interfaceData = rs.data;
|
|
})
|
}//保存前计算费用 李伟民 10 - 31
|
|
customDataBound.formsetting = function (formid, callback) {
|
// 工具栏自定义10/18
|
$('.edit_form').html("");
|
var type = "";
|
var flag = window.localStorage.getItem("customShowFlag");
|
switch (flag) {
|
case "1": type = "TJ"; break;
|
case "3": type = "XG"; break;
|
case "2": type = "XX"; break;
|
case "4": type = "LB"; break;
|
}
|
|
//console.log(type);
|
var dataObj = {};
|
dataObj.formID = formid;
|
dataObj.type = type;
|
console.log(dataObj)
|
var dataObjFlag = _.cloneDeep(dataObj);
|
delete dataObjFlag.type
|
var request = window.commonAjax("/formbase/getFormInfoService", dataObjFlag, "GET", true);
|
request.done(function (rs) {
|
if (rs.data != null) {
|
window.localStorage.setItem('bussinessSystem', rs.data.bussinesssystem)
|
}
|
})
|
|
|
|
var requestRight = window.commonAjax("/formsetting/getFormsettingInfoService", dataObj, "POST", true);
|
requestRight.done(function (rs) {
|
customDataBound.bindInterface(formid);
|
// ////console.log(rs);
|
//console.log(type);
|
if (rs.data.saveable == "0") {
|
$(".sure_box").hide();
|
}
|
if (!rs.data.subCustomButton) {
|
$("#doself").remove();
|
|
}
|
if (rs.data.subCustomButton) {
|
// var dd=document.createElement('span');
|
var formdata = [];
|
//console.log("查询类型");
|
//console.log(type);
|
switch (type) {
|
case "TJ": formdata = rs.data.subCustomButton.addCustomButton; break;
|
case "XG": formdata = rs.data.subCustomButton.updateCustomButton; break;
|
case "XX": formdata = rs.data.subCustomButton.detailedCustomButton; break;
|
case "LB": formdata = rs.data.subCustomButton.listCustomButton; break;
|
}
|
//console.log("渲染结果");
|
var srcd = document.createElement('script');
|
// var tabledata=rs.data.customButtons;
|
srcd.type = "text/javascript";
|
_.each(formdata, function (obt, i) {
|
var dd = document.createElement('span');
|
dd.id = obt.buttonName + i;
|
//btn btn-default
|
dd.setAttribute("class", "btn_myself");
|
dd.setAttribute("buttonId", obt.buttonId);
|
dd.innerHTML = "<i class='icon iconfont icon-kongjian_danhangwenben' style='text-align: left;'></i>" + obt.buttonName;
|
|
$(".edit_form").append(dd);
|
|
//console.log(obt.buttonName);
|
if (obt.buttonName == "驳回") {
|
//console.log("等于撤回");
|
// 定义审批流程定义的方法
|
// 撤销流程实例
|
|
$("#" + dd.id).click(function () {
|
var process = localStorage.getItem("processid");
|
|
//console.log(process);
|
var dd = JSON.parse(process);
|
var tent = JSON.parse(localStorage.getItem("tenantID")).tenantID;
|
|
//console.log(dd.data);
|
window.queryAjaxs("ubp-api-seache/process/inst/log", { "processInstId": dd.data.processInstId }, "POST", true).done(function (res) {
|
//console.log("打印回执");
|
//console.log(res);
|
if (res != undefined) {
|
//console.log("发送请求");
|
window.queryAjaxs("ubp-api-control/process/inst/drawBack", { "processInstId": res.data[0].processInstId, "activityInstId": res.data[0].activityInstId }, "POST", true).done(function (res) {
|
//console.log("打印回执");
|
//console.log(res);
|
if (res.data == 1) {
|
//console.log("撤销成功");
|
customBase.alert('S',"撤销成功");
|
// localStorage.removeItem('userinfo')
|
}
|
})
|
}
|
|
})
|
|
});
|
|
// 结束流程实例
|
} else if (obt.buttonName == "结束") {
|
$("#" + dd.id)[0].setAttribute('data-toggle', "modal");
|
$("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
|
$("#" + dd.id).click(function () {
|
var processLog = JSON.parse(localStorage.getItem("processLog"));
|
if (processLog != null && processLog != undefined) {
|
} else {
|
$("#liucheng").html("<h3 class='sp_title'>请先创建一个流程<h3>");
|
return null;
|
}
|
if (processLog[0].processState == 60) {
|
$("#liucheng").html("<h3 class='sp_title'>流程已结束<h3>");
|
return null;
|
} else {
|
var inputs = "<h3 class='sp_title'>是否确认结束?<h3><br/>"
|
+ "<div class='footerbtn' style='display:flex;justify-content:space-around;'><input class='btn btn-default choosebtn2' type='button' value='确定' onclick='over(true)'/> <input type='button' class='btn btn-default choosebtn' value='取消' onclick='over(false)'/></div>";
|
$("#liucheng").html(inputs);
|
$("#sssd").click();
|
|
}
|
});
|
|
} else if (obt.buttonName == "退回") {
|
$("#" + dd.id)[0].setAttribute('data-toggle', "modal");
|
$("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
|
$("#" + dd.id).click(function () {
|
var processLog = JSON.parse(localStorage.getItem("processLog"));
|
if (processLog[0].processState == 60) {
|
customBase.alert('E',"流程已结束");
|
return null;
|
} else {
|
if (processLog != "null" && processLog != undefined) {
|
console.log(processLog.length);
|
if (processLog.length == 1) {
|
customBase.alert('W',"无可退回活动");
|
return null;
|
}
|
} else {
|
customBase.alert('W',"请先创建一个流程");
|
return;
|
}
|
//请求可退回活动项
|
var isshow = false;
|
var ss = {
|
"processInstId": processLog[0].processInstId
|
}
|
var requestSingleForm = window.commonAjax("/ubp-api-seache/process/get/back", ss, "POST", true);
|
requestSingleForm.done(function (rs) {
|
console.log(rs);
|
var res = rs.data;
|
if (res != undefined & res != null) {
|
|
if (res.length > 0) {
|
|
var inputs = "<h3 class='sp_title'>请选择要退回的活动</h3><br/>";
|
for (var i = 0; i < res.length; i++) {
|
if (i == 0) {
|
inputs += "<input style='margin-left:-9px !important;' type='radio' onClick='choosebox(" + i + ")' class='act acts' value=" + res[i].activityDefId + " name='task' />" + res[i].activityDefName + "</br>";
|
} else {
|
inputs += "<input type='radio' onClick='choosebox(" + i + ")' class='act acts' value=" + res[i].activityDefId + " name='task' />" + res[i].activityDefName + "</br>";
|
}
|
}
|
inputs += "<div class='footerbtn' style='display:flex;justify-content:space-around;'><input class='btn btn-default choosebtn' type='button' value='取消' onclick='tui(false)'/><input type='button' class='btn btn-default choosebtn2' value='确定' onclick='tui(true," + activeitem + ")'/>";
|
inputs += "</div>";
|
console.log(inputs);
|
$("#liucheng").html(inputs);
|
|
|
// callback();
|
}
|
} else {
|
$("#liucheng").html("<h3 class='sp_title'>无可退回项<h3>");
|
|
return null;
|
}
|
});
|
|
}
|
});
|
} else if (obt.buttonName == "审批") {
|
$("#" + dd.id).click(function () {
|
|
var processLog = JSON.parse(localStorage.getItem("processLog"));
|
if (processLog != null && processLog != undefined) {
|
} else {
|
customBase.alert('W',"请先创建一个流程");
|
return null;
|
}
|
if (processLog[0].processState == 60) {
|
customBase.alert('E',"流程已结束");
|
return null;
|
}
|
var inputs = "<h3 class='sp_title'>请输入审批语</h3><br/>" + "<textarea maxlength='200' onKeyUp='listenword()' class='stexta' type='test' id='datas'></textarea><span class='wordwrap'><var class='word'>0</var>/200</span><br/>"
|
+ "<div class='footerbtn' style='display:flex;justify-content:space-around;'><input class='btn btn-default choosebtn' type='button' value='取消' onclick='zhixing(false)'/><input class='btn btn-default choosebtn2' type='button' value='确定' onclick='zhixing(true)'/></div>";
|
$("#liucheng").html(inputs);
|
$("#" + dd.id)[0].setAttribute('data-toggle', "modal");
|
$("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
|
});
|
|
} else {
|
$("#" + dd.id).click(function () {
|
|
var fuc = obt.methodName + "()";
|
eval(fuc);
|
//console.log(fuc);
|
//调用自定义js中的方法
|
//console.log("调用自定义方法");
|
fuc;
|
|
});
|
}
|
});
|
|
srcd.src = rs.data.resourceFilePath;
|
|
// $("#customShow").append(srcd);
|
if(rs.data.resourceFilePath != undefined && flag != 3 && rs.data.resourceFilePath != ''){//自定义JS加载修改 李伟民 0109
|
document.getElementsByTagName("head")[0].appendChild(srcd); // 接口注册 初期化事件 李伟民 12-18
|
srcd.onload = function () {
|
_.each(customBase.interfaceData, function (data) {
|
if (data.interfacemethod == "interfaceInit3rd") {
|
if (data.customInterfacemethod != undefined && data.customInterfacemethod != '') {
|
var funstr = data.customInterfacemethod + "()";
|
eval(funstr);
|
}
|
}
|
});
|
callback(rs);//自定义JS加载修改 李伟民 0109
|
}
|
}else{
|
callback(rs);//自定义JS加载修改 李伟民 0109
|
}
|
|
// $(".preview-edit-pane").append(dd);
|
// $("#"+dd.id).click(function(){
|
|
// var fuc=arr[1]+"()";
|
// eval(fuc);
|
// ////console.log(fuc);
|
|
// ////console.log("调用自定义方法");
|
// fuc;
|
|
// });
|
}else{
|
callback(rs);//自定义JS加载修改 李伟民 0109
|
}
|
});
|
var dataObjDo = {};
|
dataObjDo = dataObj;
|
delete dataObjDo.type
|
console.log(dataObj)
|
var requestRight = window.commonAjax("/tabConfiguration/queryTabConfiguration", dataObjDo, "POST", true);
|
requestRight.done(function (rs) {
|
//2017/10/31 李元杰 附件 流程先洗 选项卡添加
|
console.log(rs)
|
$('.boxTwo').hide();
|
$('.sTab').find('ul li').eq(1).hide();
|
$('.boxThr').hide();
|
$('.sTab').find('ul li').eq(2).hide();
|
if (rs.data != '') {
|
if (rs.data[0].appendix == "do") {
|
console.log($('.sTab').find('ul li'))
|
$('.sTab').find('ul li').eq(1).show();
|
} else {
|
$('.boxTwo').hide();
|
$('.sTab').find('ul li').eq(1).hide();
|
}
|
if (rs.data[0].processInfo == "do") {
|
$('.sTab').find('ul li').eq(2).show();
|
} else {
|
$('.boxThr').hide();
|
$('.sTab').find('ul li').eq(2).hide();
|
}
|
}
|
});
|
}
|
|
|
var xhSelect = xhSelect || {};
|
xhSelect.scope = {
|
sel_val_lst: {
|
// 'F073001':"常规出差"
|
},
|
rm_optionFlag: false
|
};
|
|
xhSelect.options = {
|
selectId: "",
|
multiple: false,
|
listData: [],
|
width: 200,
|
setDiv: ""
|
}
|
xhSelect.setValue = function (itemId, listData) {
|
xhSelect.setValue(itemId, listData, 0);
|
}
|
xhSelect.setValue = function (itemId, listData, N) {
|
var selectItme = $("#" + itemId + " .selectItme");
|
var listDataJson = {};
|
if (_.isString(listData)) {// 下拉款填值 修改 李伟民 11-14
|
listData = listData.split(",")
|
}// 下拉款填值 修改 李伟民 11-14
|
console.log(listData);
|
for (var i = 0; i < listData.length; i++) {
|
listDataJson[listData[i]] = "1";
|
}
|
|
var $options = $($("#" + itemId)[0]).find('select > option');
|
var vals_selected = [];
|
var j = 0;
|
$options.each(function () {
|
for (var jsonstr in listDataJson) {
|
if ($(this).val() == jsonstr) {
|
vals_selected[j] = {};
|
vals_selected[j].value = $(this).val();
|
vals_selected[j].label = $(this).text();
|
j++;
|
}
|
}
|
});
|
var $el = $($("." + itemId + "value")[N]);
|
var set_valueleft = function (vals_selected) {
|
var $divContainer = "";
|
var selectedItem = {};
|
for (var i = 0; i < vals_selected.length; i++) {
|
//张吉男修改 下拉框发布
|
$divContainer += '<div class="val-card ng-binding ng-scope ' + vals_selected[i].value +
|
'Class" ng-repeat="sel_val in sel_val_lst track by $index" ng-show="true" multiple="" load-data="" style="height:40px;line-height:25px;">' +
|
vals_selected[i].label + '<a onclick="xhSelect.rm_option(this,\'' + vals_selected[i].value +
|
'\')" ng-href="javascript:void(0);" href="javascript:void(0);">' + ' <i class="icon iconfont icon-guanbijiantou" val="' +
|
vals_selected[i].value + '" style="color:#20b4aa;"></i></li>' + ' </a>' + ' </div>';
|
|
selectedItem[vals_selected[i].value] = "1";
|
}
|
$divContainer += '<div class="suffix">' + '<i class="fa fa-angle-down" aria-hidden="true"></i>' + '</div>';
|
$el.find(".select-container").empty();
|
$el.find(".select-container").append($divContainer);
|
var selectedItemJson = JSON.stringify(selectedItem);
|
if ($el.find(".selectItme").length != 0) {
|
$el.find(".selectItme")[0].setAttribute("value", selectedItemJson);
|
}
|
|
};
|
set_valueleft(vals_selected);
|
}
|
xhSelect.getValue = function (itemId) {
|
var returnItem = [];
|
var selectItme = $("#" + itemId + " .selectItme");
|
console.log(selectItme)
|
for (var i = 0; i < selectItme.length; i++) {
|
if (selectItme[i].getAttribute("value") == "") {
|
var selectItmeJson = {};
|
} else {
|
////console.log(selectItme[i].getAttribute("value"));
|
var selectItmeJson = $.parseJSON(selectItme[i].getAttribute("value"));
|
}
|
|
var jn = 0;
|
returnItem[i] = [];
|
for (j in selectItmeJson) {
|
returnItem[i][jn] = j;
|
jn++;
|
}
|
}
|
return returnItem;
|
}
|
// 下拉框主数据渲染
|
xhSelect.setXhSelect = function (options) {
|
////console.log(options);
|
////console.log(_.cloneDeep(xhSelect.options));
|
//解决主数据重复
|
var options_xh = _.cloneDeep(xhSelect.options);
|
options_xh.listData = [];
|
//解决主数据重复END
|
options = $.extend(true, options_xh, options);
|
var optionArr = "";
|
console.log(options.selectId);
|
////console.log(options.listData);
|
// ////console.log(options.listData.length);
|
for (var i = 0; i < options.listData.length; i++) {
|
optionArr += '<option value="' + options.listData[i].value + '">' + options.listData[i].text + '</option>';
|
}
|
console.log(optionArr);
|
var multiple = "";
|
if (options.multiple) {
|
multiple = 'multiple';
|
}
|
|
var $xhSelectDiv = '' +
|
'<div class="selectClass">' +
|
'<div ng-transclude="" style="display:none;">' +
|
'<select class="select_get ng-scope" load-data="" ' + multiple + ' >' +
|
optionArr +
|
'</select>' +
|
'</div>' +
|
'<div class="selectItme" style="display:none;" value=""></div>' +
|
'<div class="select3-element" style="width:100%;max-width: ' + options.width + 'px">' +
|
' <div class="select-container select-container_box" gccolname="ex_c11"> ' +
|
' <div class="suffix">' +
|
' <i class="fa fa-angle-down" aria-hidden="true"></i>' +
|
' </div>' +
|
' </div>' +
|
' </div> ' +
|
'</div>';
|
console.log(options);
|
if (options.setDiv == '') {
|
var $el = $("#" + options.selectId);
|
} else {
|
var $el = $("." + options.setDiv);
|
}
|
console.log(optionArr)
|
console.log($xhSelectDiv)
|
_.each($el, function (sel) {//添加记录 重复问题 李伟民11-14 主数据丢失 11-29 再次修改
|
if ($(sel).find(".selectClass").length == 0) {
|
$(sel).append($xhSelectDiv)
|
} else {
|
$(sel).find(".selectClass").find(".select_get").html(optionArr);
|
}
|
})//添加记录 重复问题 李伟民11-14 主数据丢失 11-29 再次修改
|
|
|
//添加记录 重复问题 李伟民11-14
|
// $("#"+options.selectId).find()
|
|
xhSelect.selectContainer(options);
|
customLinkageAnalysis.bindLinkage();
|
//行程排序初期化
|
customShow.journeySort();
|
}
|
xhSelect.rm_option = function (val, vals_selected) {
|
xhSelect.scope.rm_optionFlag = true;
|
console.log(val);
|
console.log(vals_selected)
|
$('div.drop_down_sel').remove();
|
var selectItmeJson = $($(val).parent().parent().parent().parent()).find(".selectItme")[0].getAttribute("value");
|
|
var selectItme = $.parseJSON(selectItmeJson);
|
delete selectItme[vals_selected];
|
selectItmeJson = JSON.stringify(selectItme);
|
$($(val).parent().parent().parent().parent()).find(".selectItme")[0].setAttribute('value', selectItmeJson);
|
|
//张吉男修改 下拉框默认值不可以清空
|
var cla=new RegExp("disableColor");
|
//console.log(cla.test($(val).parent().parent().attr("class")));
|
//判断下拉框是否是可编辑
|
if(!(cla.test($(val).parent().parent().attr("class")))){
|
$(val).parent().remove();
|
}
|
setTimeout(function () {
|
xhSelect.scope.rm_optionFlag = false;
|
}, 500);
|
}
|
xhSelect.selectContainer = function (options) {
|
var itemId = options.selectId;
|
if (options.setDiv == '') {
|
var $el = $("#" + itemId);
|
} else {
|
var $el = $("." + options.setDiv);
|
}
|
$el.find('div.select-container').on('click', function (event) {
|
var selectedItem = $el.find(".selectItme")[0].getAttribute("value");
|
// 12/4 李元杰
|
$('.zTreeDemoBackground').css("display", "none");
|
$(".search_input").css("display", "none");
|
console.log(selectedItem);
|
console.log(event);
|
console.log($(this))
|
////console.log("-------------------this-----------------------------------");
|
if ($el[0].className.indexOf("readonly") > -1) {
|
return;
|
}
|
if (selectedItem != "") {
|
selectedItem = $.parseJSON(selectedItem);
|
}
|
|
if (xhSelect.scope.rm_optionFlag) {
|
return;
|
}
|
console.log(2)
|
$('div.drop_down_sel').remove();
|
var $select = $el.find('select');
|
var isMultiple = $select.attr('multiple');
|
var $options = $el.find('select > option');
|
////console.log($el);
|
////console.log($options);
|
var $options_str = '<ul>' + '<li class="sel_query">' + '<input type="text" name="query" >' + '</li>' + '</ul>';
|
|
$options_str += '<div class="select "><ul class="line">';
|
|
if ($select.attr('multiple')) {
|
$options_str += '<li class="ui-state-default" style="height:28px"><span class="custom-check "' +
|
' value="All" label="全选" ><i class="label"></i>全选</span></li>';
|
}
|
$options.each(function () {
|
var checked = '';
|
if (selectedItem[$(this).val()] != undefined) {
|
checked = 'cur';
|
}
|
$options_str += '<li class="ui-state-default" style="height:28px"><span class="custom-check ' + checked +
|
'" value="' + $(this).val() + '" label="' + $(this).text() + '' + '" title="' + $(this).text() + '"><i class="label"></i>' + $(this).text() + '</span></li>'
|
});
|
|
$options_str += '</ul></div>';
|
console.log($options_str)
|
console.log(3)
|
$("div.drop_down_sel").remove();
|
var $select_obj = $('<div drop-down-selector="" filterlist="searchlist" class="drop_down_sel" style="position: absolute;">' + $options_str + '</div>');
|
$el.find('div.select3-element').append($select_obj);
|
$('body').off('click.sel').on('click.sel', function () {
|
console.log(5);
|
$('div.drop_down_sel').remove();
|
$('.zTreeDemoBackground').css("display", "none");
|
$(".search_input").css("display", "none");
|
});
|
$('div.drop_down_sel').off('click.sel').on('click.sel', function (event) {
|
|
event.stopPropagation();
|
});
|
console.log(6)
|
$select_obj.find('input[name="query"]').on('keyup',
|
function () {
|
var $el = $(this);
|
var inputs = $select_obj.find('.custom-check');
|
inputs.each(function () {
|
var val = $(this).attr('label');
|
var input_val = $el.val();
|
if (val.indexOf(input_val) > -1) {
|
$(this).closest('li').show();
|
} else {
|
$(this).closest('li').hide();
|
}
|
});
|
});
|
|
$select_obj.find('.custom-check').on('click', function () {
|
if (this.className.indexOf("readonly") > -1) {
|
return;
|
}
|
$(this).toggleClass('cur');
|
if ($(this)[0].getAttribute("value") == "All") {
|
if (this.className.indexOf("cur") > -1) {
|
$($(this).parent().parent()).find(".custom-check").addClass("cur");
|
} else {
|
$($(this).parent().parent()).find(".cur").removeClass('cur');
|
}
|
}
|
|
var set_valueleft = function (vals_selected) {
|
var $divContainer = "";
|
var selectedItem = {};
|
for (var i = 0; i < vals_selected.length; i++) {
|
$divContainer += '<div class="val-card ng-binding ng-scope ' + vals_selected[i].value +
|
'Class" ng-repeat="sel_val in sel_val_lst track by $index" ng-show="true" multiple="" load-data="" style="height:40px;line-height:25px;">' +
|
vals_selected[i].label + '<a onclick="xhSelect.rm_option(this,\'' + vals_selected[i].value +
|
'\')" ng-href="javascript:void(0);" href="javascript:void(0);">' + ' <i class="icon iconfont icon-guanbijiantou" val="' +
|
vals_selected[i].value + '" style="color:#20b4aa;"></i>' + ' </a>' + ' </div>';
|
selectedItem[vals_selected[i].value] = "1";
|
}
|
$divContainer += '<div class="suffix">' + '<i class="fa fa-angle-down" aria-hidden="true"></i>' + '</div>';
|
$el.find(".select-container").empty();
|
$el.find(".select-container").append($divContainer);
|
var selectedItemJson = JSON.stringify(selectedItem);
|
$el.find(".selectItme")[0].setAttribute("value", selectedItemJson);
|
$el.find(".select_get").trigger("change.value");//下拉框 公式
|
};
|
var vals_selected = [];
|
var vals_selected_item = [];
|
var checkboxChecked = false;
|
var checkboxValue = $(this)[0].getAttribute("value");
|
var checkboxLabel = $(this)[0].getAttribute("label");
|
if ($(this)[0].className.indexOf('cur') > -1) {
|
checkboxChecked = true;
|
}
|
if (!isMultiple) {
|
vals_selected = [{
|
'value': checkboxValue,
|
'label': checkboxLabel
|
}];
|
set_valueleft(vals_selected);
|
console.log(7)
|
$('div.drop_down_sel').remove();
|
} else {
|
var vls = [];
|
var values = $($(this).parent().parent()).find('.cur');
|
var j = 0;
|
for (var i = 0; i < values.length; i++) {
|
if (values[i].getAttribute("value") != "All") {
|
vals_selected[j] = {};
|
vals_selected[j].value = values[i].getAttribute("value");
|
vals_selected[j].label = values[i].getAttribute("label");
|
j++;
|
}
|
}
|
set_valueleft(vals_selected);
|
}
|
});
|
event.stopPropagation();
|
});
|
}
|
|
//customBase.reCharge = function(){//重新记账 李伟民 2017-10-18 21:30
|
// //console.log(customBase);
|
// //console.log(customShow);
|
// var rePostData = {};
|
// rePostData['formID'] = customShow.options.formid;
|
// rePostData['dataRowNum'] = customShow.options.dataRowNum;
|
// var reCharge_request = window.cloudAjax("epc-tenant/accounting/record",rePostData,"POST",true);
|
// reCharge_request.done(function(res){
|
// //console.log(res);
|
// })
|
//}//重新记账 李伟民 2017-10-18 21:30 end
|
|
//customBase.checkItem = function(){//提交验证 李伟民2017-10-19 15:52
|
// //console.log(customBase);
|
// //console.log(customShow);
|
// //画面项目取得 --------------------------画面项目取得------
|
// var items = customShow.getItems();
|
// ////console.log(items)
|
// // 画面check
|
// var returnfromCheck = customShow.initEvent.fromCheck(items); //--------------------
|
// if(returnfromCheck){
|
//// return;
|
// }
|
//
|
//
|
// var rules = customShow.options.jsonLinkage;
|
// if(!_.isNull(rules) && rules != undefined){
|
// rules = JSON.parse(rules);
|
// //console.log(rules);
|
// var checkId = [];
|
// _.each(rules,function(ru){
|
// _.each(ru.results,function(res){
|
// if(res.mode == "2" || res.mode == "0"){
|
// checkId.push(ru.event.eventFieldId);
|
// return false;
|
// }
|
// })
|
// });
|
// checkId = _.uniq(checkId);
|
// //console.log(checkId);
|
// _.each(checkId,function(cid){
|
// $("[id='" + cid + "']").trigger("change.check");
|
// });
|
// }
|
//}//提交验证 李伟民2017-10-19 15:52 end
|
|
// function checkSameDay(day1, day2) {//判断是否为同一天 李伟民 2017-10-20 17:00
|
// var seconds;
|
// seconds = day1 - day2;
|
// //console.log(seconds);
|
// if (seconds < 24 * 60 * 60 * 1000 && seconds >= 0) {
|
// return true;
|
// } else {
|
// return false;
|
// }
|
// }//判断是否为同一天 李伟民 2017-10-20 17:00 end
|
|
// customBase.checkTimeCross = function () {//跨行程验证时间 李伟民 2017-10-20 11:35
|
// //console.log(customBase);
|
// //console.log(customShow);
|
// var items = customShow.getItems();
|
// //console.log(items);
|
// var itemKey = _.keys(customBase.options.customItems);
|
// var subItem = [];
|
// _.each(itemKey, function (keys) {
|
// if (customBase.options.customItems[keys].type == "subform") {
|
// subItem.push(customBase.options.customItems[keys].fieldKey);
|
// }
|
// });
|
// var FromDateArr = [];
|
// var LeaveDateArr = [];
|
// //console.log(subItem);
|
// _.each(subItem, function (sub) {
|
// if (items[sub] != undefined) {
|
// _.each(items[sub], function (isub, i) {
|
// if (isub.FromDate != undefined) {
|
// FromDateArr.push({ "value": new Date(isub.FromDate), "num": i, "property": customBase.options.customItems['FromDate'] });
|
// }
|
// if (isub.LeaveDate != undefined) {
|
// LeaveDateArr.push({ "value": new Date(isub.LeaveDate), "num": i, "property": customBase.options.customItems['LeaveDate'] });
|
// }
|
// });
|
// }
|
// });
|
// //console.log(FromDateArr);
|
// //console.log(LeaveDateArr);
|
// if (FromDateArr.length > 1 && LeaveDateArr.length > 1 && FromDateArr.length == LeaveDateArr.length) {
|
// _.each(FromDateArr, function (fdate, k) {
|
// if (k > 0) {
|
// //console.log(checkSameDay(fdate.value,LeaveDateArr[k-1].value));
|
// if (checkSameDay(fdate.value, LeaveDateArr[k - 1].value) == false) {
|
// var message = customShow.options.customItemShow.item[fdate.property.id].tag_Attribute.title + "与上一行程不连续";
|
// customLinkageAnalysis.setMessage(fdate.property.id, message, k);
|
// }
|
// }
|
// });
|
// }
|
// }//跨行程验证时间 李伟民 2017-10-20 11:35 end
|
// customBase.checkLandCross = function () {//跨行程验地点 李伟民 2017-10-20 11:35
|
// var items = customShow.getItems();
|
// //console.log(items);
|
// var itemKey = _.keys(customBase.options.customItems);
|
// var subItem = [];
|
// _.each(itemKey, function (keys) {
|
// if (customBase.options.customItems[keys].type == "subform") {
|
// subItem.push(customBase.options.customItems[keys].fieldKey);
|
// }
|
// });
|
// var FromLandeArr = [];
|
// var ToLandArr = [];
|
// _.each(subItem, function (sub) {
|
// if (items[sub] != undefined) {
|
// _.each(items[sub], function (isub, i) {
|
// if (isub.From_site != undefined) {
|
// FromLandeArr.push({ "value": isub.From_site[0], "num": i, "property": customBase.options.customItems['From_site'] });
|
// }
|
// if (isub.To_site != undefined) {
|
// ToLandArr.push({ "value": isub.To_site[0], "num": i, "property": customBase.options.customItems['To_site'] });
|
// }
|
// });
|
// }
|
// });
|
// if (FromLandeArr.length > 1 && ToLandArr.length > 1 && FromLandeArr.length == ToLandArr.length) {
|
// _.each(FromLandeArr, function (fland, k) {
|
// if (k > 0) {
|
// customLinkageAnalysis.clearMessage(fland.property.id, k);
|
// //console.log(fland.value != ToLandArr[k-1].value);
|
// if (fland.value != ToLandArr[k - 1].value) {
|
// var message = customShow.options.customItemShow.item[fland.property.id].tag_Attribute.title + "与上一行程不连续";
|
// customLinkageAnalysis.setMessage(fland.property.id, message, k);
|
// }
|
// }
|
// });
|
// }
|
// }//跨行程验地点 李伟民 2017-10-20 11:35 end
|
//自定义表单扩展函数 增加行 删除行
|
customShow.addRow = function (subId, data) {
|
console.log(data);
|
console.log(subId);
|
console.log($("#" + subId));
|
console.log($("#" + subId).find(".trContentClass"));
|
$("#" + subId).find(".trContentClass").remove();
|
// console.log(data[0].length - 1);
|
for (var i = 0; i < data[0].length; i++) {
|
var itemId = subId;
|
var showClass = "customViewUEditorCss";
|
var item = customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv;
|
//console.log(customShow.options)
|
console.log(itemId, item)
|
console.log(itemId, customBase.options.customItems)
|
//子表单情况为U情况
|
if (item == undefined) {// 子表单回显 修改 李伟民 11-10
|
var tbody = $("." + showClass + " #" + itemId + "ActiveId").find("tbody");
|
tbody = tbody[0].cloneNode(true);
|
$(tbody).find(".select2").remove();
|
console.log($(tbody).html());
|
$(tbody).find(".tdTitleClass").closest("tr").addClass("table_title");
|
$(tbody).find(".dropdowntypeCss").select2({ theme: "classic" });
|
// $(tbody).find(".zTreeDemoBackground").select2({theme: "classic"});
|
if ($(tbody).find(".table_title").length > 0) {
|
//删除头行
|
$(tbody).find(".table_title").remove();
|
}
|
if ($(tbody).find(".trContentClass").length > 1) {// 去除重复的tr 李伟民 11-14
|
$($(tbody).find(".trContentClass")[0]).siblings().remove();
|
}// 去除重复的tr 李伟民 11-14
|
// $(tbody).find(".cfg_contentNone").removeClass("cfg_contentNone");
|
tbody = customShow.addsubformListInit(itemId, $(tbody).find("tr"));
|
console.log(tbody);
|
console.log(itemId);
|
console.log($(tbody).find("#" + itemId).attr("class"));
|
$($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(tbody);// 子表单回显 修改 李伟民 11-10
|
customShow.hidesubform();
|
customShow.setXhSelectList(false);//添加记录 重复问题 李伟民11-14
|
} else {
|
console.log(item);
|
item = item[0].cloneNode(true);
|
console.log(item);
|
$(item).find(".select2").remove();
|
$(item).find(".dropdowntypeCss").select2({ theme: "classic" });
|
|
$(item).find(".subformAddiconShow .cfg_contentNone").removeClass("cfg_contentNone");
|
item = customShow.addsubformListInit(itemId, item);
|
$($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(item);
|
|
}
|
customShow.setXhSelectList(true);//添加记录 重复问题 李伟民11-14
|
customShow.addtree(itemId, item);
|
//子表单事件追加
|
customShow.clickBindSubform();
|
//公式初期化
|
customLinkageAnalysis.bindLinkage();
|
customShow.oneTotle();
|
$('.iconfontcolor').on('click', function () {
|
$(this).parent().parent().parent().remove();
|
});
|
console.log($(item))
|
customShow.addtree(itemId, item);
|
}
|
var customItems = customBase.options.customItems;
|
console.log(customItems)
|
var order = $($("#" + subId + "ActiveId .trContentClass")[0]).find(".tdContentClass");
|
var orderid = [];
|
var orderObj = {};
|
_.each(order, opt => {
|
if ($(opt).find("div").children().eq(0).attr("id")) {
|
orderid.push($(opt).find("div").children().eq(0).attr("id"));
|
} else {
|
orderid.push($(opt).find("div").children().eq(1).attr("id"));
|
}
|
});
|
console.log(orderid);
|
orderid.splice(0, 1);
|
console.log(orderid);
|
var subArr = [];
|
console.log(subId)
|
_.each(customItems, opt => {
|
if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
|
subArr.push(opt);
|
}
|
});
|
_.remove(subArr, n => {
|
return n.fieldKey == "DATAROWNUM";
|
})
|
console.log(subArr);
|
var endArr = [];
|
_.each(orderid, opt => {
|
var a = {};
|
_.each(subArr, o => {
|
if (opt == o.id) {
|
a = o;
|
}
|
});
|
endArr.push(a);
|
})
|
console.log(endArr);
|
console.log(data);
|
_.each(endArr, (opts, i) => {
|
console.log(opts.id, opts.type, data[i]);
|
if (opts.type == "dropdownlist") {// 不可修改 控件type 李伟民 11-17
|
customBase.setItemValue(opts.id, "dropdownlistText", data[i], "", "");
|
} else {
|
customBase.setItemValue(opts.id, opts.type, data[i], "", "");
|
}
|
});
|
console.log(subId)
|
customShow.subTotle(subId)
|
};
|
//关联表单控件 列表渲染
|
createTable = function (rs, formId, formhuixian, head, $iconId, addVal) {
|
var showVal = [];
|
var iconAttr = customShow.options.customItemShow.item[$iconId];//关联数据 函数 数据源 李伟民 11-07
|
//接收table内容请求
|
var content = "";
|
var counts = "";
|
$(".requestMenu").empty();
|
//渲染table头部变量;
|
let headtr = "";
|
//渲染table内容变量
|
let contentdata = "";
|
//表头渲染数据
|
//console.log(head);
|
_.remove(head, n => {
|
return n.fieldKey == "DATAROWNUM";
|
});
|
_.each(head, opt => {
|
headtr += '<td>' + opt.title + '</td>';
|
});
|
let head_tr = $("<tr class='headtr'></tr>");
|
head_tr.append('<td class="td1">选择</td>' + headtr);
|
$(".requestMenu").append(head_tr);
|
|
//console.log(rs)
|
if (rs.data != undefined && !_.isNull(rs.data) && rs.data.count != undefined) {
|
counts = rs.data.count;
|
}
|
if (rs.data != undefined && !_.isNull(rs.data)) {
|
content = rs.data.list;
|
} else {
|
content = [];
|
}
|
// if(iconAttr.tag_Attribute.relevancesourcetype == "fundata"){
|
// codeContent = rs.data.list;
|
// }else{
|
// codeContent = rs.data.code;
|
// }
|
console.log(content);
|
if (content.length == 0) {
|
var div_empty = $("<div><i style='width:20px;height:20px;' class='fa fa-envelope-o' aria-hidden='true'></i><p>您还没有数据显示</p></div>");
|
$(".requestMenu").append(div_empty);
|
} else {
|
_.each(content, (opt) => {
|
_.each(formhuixian, n => {
|
if (opt.DATAROWNUM == n.DATAROWNUM) {
|
opt.show = "cur";
|
}
|
});
|
var contentdata = "";
|
_.each(head, opts => {
|
contentdata += '<td>' + opt[opts.fieldKey] + '</td>';
|
});
|
var tr = $("<tr class='bodytr'></tr>");
|
tr.append('<td class="td1"><li class="checkLine"><span class="custom-check ' + opt.show + '"></span><i class="label"></i></li></td>' + contentdata);
|
console.log(tr);
|
$(".requestMenu").append(tr);
|
});
|
}
|
//console.log(formhuixian);
|
|
|
if (formhuixian != undefined) {
|
addVal = formhuixian;
|
}
|
let show = "";
|
var showObj = {};
|
//选择方法
|
head.push({ fieldKey: "DATAROWNUM", title: "DATAROWNUM" });
|
//判断单选多选
|
var selItem = customShow.options.customItemShow.item;
|
console.log(selItem);
|
var sel = "";
|
var datarow = "";
|
var tag_Id = "";
|
console.log(selItem);
|
for (let key in selItem) {
|
if (key == $iconId) {
|
sel = selItem[key].tag_Attribute.mytextSel;
|
console.log(selItem[key].tag_Attribute.singleSetValue);
|
if (selItem[key].tag_Attribute.singleSetValue != "itemId") {
|
datarow = JSON.parse(selItem[key].tag_Attribute.singleSetValue).columnOrderNum;
|
tag_Id = JSON.parse(selItem[key].tag_Attribute.singleSetValue).tag_Id;
|
}
|
}
|
}
|
console.log(sel)
|
if (sel == "single") {
|
$(".custom-check").on("click", function () {
|
var addVals = [];
|
var showVals = [];
|
$(this).parent().parent().parent().siblings().find(".custom-check").removeClass('cur');
|
$(this).toggleClass('cur');
|
console.log($(this));
|
console.log($(this).siblings());
|
// var showObj = {};
|
let $index = $(this).parent().parent().parent().index() - 1;
|
var check = $(".custom-check");
|
console.log(check);
|
_.each(check, opt => {
|
console.log(opt)
|
if ($(opt).hasClass('cur')) {
|
addVals.push(content[$(opt).parent().parent().parent().index() - 1]);
|
// showVals.push(content[$(opt).parent().parent().parent().index() - 1]);
|
// addVals.push(codeContent[$(opt).parent().parent().parent().index() - 1]);//填值时使用code 李伟民 12-05
|
// console.log(codeContent[$(opt).parent().parent().parent().index() - 1])
|
} else {
|
_.remove(addVals, n => {
|
return n.DATAROWNUM == content[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;
|
// return n.DATAROWNUM == codeContent[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;//填值时使用code 李伟民 12-05
|
});
|
// _.remove(showVals, n => {
|
// return n.DATAROWNUM == content[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;
|
// });
|
}
|
});
|
addVal = addVals;
|
// showVal = showVals;
|
console.log(addVal);
|
console.log(datarow);
|
customShow.sureonclick(addVal, $iconId, head, sel, iconAttr, datarow, formId);
|
});
|
console.log(addVal);
|
|
} else if (sel == "multiple") {
|
$(".custom-check").on("click", function () {
|
$(this).toggleClass('cur');
|
// var showObj = {};
|
let $index = $(this).parent().parent().parent().index() - 1;
|
if ($(this).hasClass('cur')) {
|
addVal.push(content[$index]);
|
// showVal.push(content[$index]);
|
// addVal.push(codeContent[$index]);//填值时使用code 李伟民 12-05
|
//console.log(content[$index])
|
} else {
|
_.remove(addVal, n => {
|
return n.DATAROWNUM == content[$index].DATAROWNUM;
|
// return n.DATAROWNUM == codeContent[$index].DATAROWNUM;//填值时使用code 李伟民 12-05
|
});
|
// _.remove(showVal, n => {
|
// return n.DATAROWNUM == content[$index].DATAROWNUM;
|
// });
|
}
|
customShow.sureonclick(addVal, $iconId, head, sel, iconAttr, datarow, formId);
|
});
|
}
|
console.log(addVal);
|
//选择方法END
|
return counts;
|
}
|
|
function createMxtTable($iconId, head, addVal) {// 关联数据渲染修改 李伟民 11-30
|
console.log(head);
|
console.log(addVal);
|
if (head == "" || addVal == "" || head == undefined || addVal == undefined) {
|
return false;
|
}
|
var tableBox = $("<table class='mxtdatatable table'></table>");
|
var tableTitle = $("<tr></tr>");
|
var tableBody = $("<tbody></tbody>");
|
var tableHead = $("<thead></thead>");
|
_.each(addVal, function (atd) {
|
var tableContent = $("<tr></tr>");
|
_.each(head, function (htd) {
|
var td = '<td class="mxtdatatabletd">' + (atd[htd.fieldKey] ? atd[htd.fieldKey] : "") + '</td>';
|
tableContent.append(td);
|
var th = '<th>' + htd.title + '</th>';
|
tableTitle.append(th);
|
});
|
tableBody.append(tableContent);
|
});
|
tableHead.append(tableTitle);
|
tableBox.append(tableHead);
|
tableBox.append(tableBody);
|
$('#' + $iconId).append(tableBox);
|
}// 关联数据渲染修改 李伟民 11-30
|
|
function setValByAnother(iconAttr, addVal, formId, head, typeflag) {//遍历对比别名相同填值 typefalg为true代表关联的是函数
|
var datarowNum = addVal[0].DATAROWNUM;
|
var postdata = {};
|
var getCodeUrl = "";
|
var ajaxtype = "";
|
if (typeflag) {
|
getCodeUrl = "/datamanagement/getAssociateData";
|
postdata = { "formID": customShow.options.formid, "search": [], "pageSize": "1000", "pageNum": "1", "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'], "dataRowNum": datarowNum, "type": "code" };
|
ajaxtype = "POST";
|
} else {
|
postdata = {
|
"datarowNum": datarowNum,
|
"formID": formId.formID
|
};
|
getCodeUrl = "/datamanagement/getSingleFormDataService";
|
ajaxtype = "GET";
|
}
|
|
console.log(postdata);
|
var rquest = window.commonAjax(getCodeUrl, postdata, ajaxtype, true);
|
rquest.done(function (res) {
|
console.log(res);
|
var rsdata = "";
|
if (res.data && res.data.main != undefined) {
|
if (typeflag) {
|
rsdata = res.data.list[0];
|
} else {
|
rsdata = res.data.main;
|
}
|
console.log(iconAttr);
|
console.log(rsdata);
|
if (rsdata == undefined) {
|
return false;
|
}
|
_.each(customBase.options.customItems, opt => {
|
_.each(head, opts => {
|
if (opts.fieldKey == opt.fieldKey) {
|
if (opt.type == "dropdownlist") {
|
// if(customBase.getItemValue(opt.id,"dropdownlistText")[0].length == 0){
|
var item = customShow.options.customItemShow.item[opt.id];
|
var dropdowntype = item.tag_Attribute.dropdowntype;
|
customBase.setItemValue(opt.id, "dropdownlistText", res.data.main[opt.fieldKey], "", "");
|
// }
|
} else {
|
// if(!customBase.getItemValue(opt.id,opt.type)){
|
customBase.setItemValue(opt.id, opt.type, res.data.main[opt.fieldKey], "", "");
|
// }
|
}
|
};
|
})
|
});
|
}
|
|
});
|
|
}
|
|
customShow.sureonclick = function (addVal, $iconId, head, sel, iconAttr, datarow, formId) {
|
console.log(datarow)
|
$(".btn-primary").on("click", function () {
|
var showObj = {};
|
console.log(addVal);
|
$('#' + $iconId).empty();
|
//回显属性
|
$("#" + $iconId).attr("formhuixian", JSON.stringify(addVal));
|
var saveval = '';//关联数据空间 存值 李伟民 11-07
|
var saveArr = [];
|
_.each(addVal, function (v) {
|
if (v.DATAROWNUM != undefined) {
|
saveArr.push(v.DATAROWNUM);
|
}
|
});
|
saveval = saveArr.join();
|
customBase.setItemValue($iconId, customShow.options.customItemShow.item[$iconId].tag_Type, saveval);//关联数据空间 存值 李伟民 11-07 end
|
if (addVal != "" && addVal != undefined) {
|
$("#" + iconAttr.tag_Id).attr("checkVal", JSON.stringify(addVal));//将选中值存储起来 用于验证
|
$("#" + iconAttr.tag_Id).attr("checkHead", JSON.stringify(head));
|
}
|
var data2 = customShow.columnToRow(head, addVal);
|
//子表单自动增加行
|
var subId = $('#' + $iconId + "ActiveId").attr("choosesubform");
|
console.log(subId);
|
if (subId == "itemId") {
|
createMxtTable($iconId, head, addVal);
|
console.log(addVal);
|
console.log(head);
|
setValByAnother(iconAttr, addVal, formId, head);
|
//遍历对比别名相同填值
|
// _.each(customBase.options.customItems, opt => {
|
// _.each(head, opts => {
|
// if (opts.fieldKey == opt.fieldKey) {
|
// if (opt.type == "dropdownlist") {
|
// // if(customBase.getItemValue(opt.id,"dropdownlistText")[0].length == 0){
|
// var item = customShow.options.customItemShow.item[opt.id];
|
// var dropdowntype = item.tag_Attribute.dropdowntype;
|
// customBase.setItemValue(opt.id, "dropdownlistText", addVal[0][opt.fieldKey], "", "");
|
// // }
|
// } else {
|
// // if(!customBase.getItemValue(opt.id,opt.type)){
|
// customBase.setItemValue(opt.id, opt.type, addVal[0][opt.fieldKey], "", "");
|
// // }
|
// }
|
// };
|
// })
|
// });
|
} else {
|
console.log(addVal)
|
if (sel == "single" && iconAttr.tag_Attribute.relevancesourcetype != "fundata") {
|
setValByAnother(iconAttr, addVal, formId, head)
|
// _.each(addVal,(opt,j)=>{
|
//// var ulBox = $("<ul></ul>");
|
// var ulBox = $("<table></table>");
|
// var sdata_head = "";
|
// var sdata_boby = "";
|
// for(var i = 0;i<head.length;i++){
|
// show = "";
|
// sdata_head += '<td class="data1 '+head[i].fieldKey+'">'+head[i].title+'</td>';
|
// sdata_boby += '<td class="data2 '+head[i].fieldKey+'">'+opt[head[i].fieldKey]+'</td>';
|
// show += '<li>'+'<span class="data1 '+head[i].fieldKey+'">'+head[i].title+'</span>'+'<span class="data2 '+head[i].fieldKey+'">'+opt[head[i].fieldKey]+'</span>'+'</li>';
|
//
|
// showObj[head[i].fieldKey] = opt[head[i].fieldKey];
|
//
|
// ulBox.attr("class","addUl ulBox"+j);
|
// ulBox.attr("id","ulBox"+j);
|
//// ulBox.append(show);
|
// }
|
// ulBox.append("<tr>"+sdata_head+"</tr><tr>"+sdata_boby+"</tr>");
|
// console.log(sdata_head);
|
// $('#'+$iconId).append(ulBox);
|
// });
|
createMxtTable($iconId, head, addVal);
|
var subdata = {};
|
console.log(datarow)
|
subdata.formdataNum = datarow;
|
subdata.datarowNum = addVal[0].DATAROWNUM;
|
subdata.formID = formId.formID;
|
var subformData = window.commonAjax("/datamanagement/getSubFormDataListService", subdata, "GET", true, false);
|
subformData.done(function (rs) {
|
console.log(rs.data);
|
var c_data = SC.cur_zero(rs.data);
|
console.log(c_data)
|
var rsArr = [];
|
_.each(c_data, opt => {
|
var opts = _.omit(opt, ['DATAROWNUM']);
|
rsArr.push(opts)
|
});
|
var rslength = _.keys(rsArr[0]).length;
|
console.log(rsArr);
|
var subId = $('#' + $iconId + "ActiveId").attr("choosesubform");
|
console.log($(".myipt"))
|
var formObj = window.localStorage.getItem("netformid");
|
var globalFormID = formObj;
|
var dataObj = {};
|
dataObj.formID = globalFormID;
|
var order_id = [];
|
// 11/25 李元杰 存flag
|
console.log(dataObj)
|
var requestRight = window.commonAjax("/datamanagement/getFormFieldListService", dataObj, "GET", true, false);
|
requestRight.done(function (rs) {
|
console.log(rs)
|
order_id = rs.data;
|
})
|
|
// var tenantID =JSON.parse(window.localStorage.getItem('tenantID'))
|
// dataObj.tenantID= tenantID.tenantID;
|
|
// var order_ids = JSON.parse($(".myipt").val());
|
console.log(order_id);
|
// console.log(order_ids)
|
|
|
if (customShow.options.customItemShow.item[$iconId].tag_Attribute.singleSetValue) {
|
var message = JSON.parse(customShow.options.customItemShow.item[$iconId].tag_Attribute.singleSetValue);
|
}
|
console.log(message.columnOrderNum)
|
|
console.log(subId);
|
var subIds = subId.replace("itemId_", "")
|
console.log(subIds);
|
var orderArr = []; //存储关联表单内子表单的数组
|
_.each(order_id, opt => {
|
console.log(opt)
|
if (opt.parentsubFormNum == message.columnOrderNum) {
|
orderArr.push(opt);
|
}
|
});
|
_.remove(orderArr, n => {
|
return n.fieldKey == "DATAROWNUM";
|
})
|
console.log(orderArr);
|
orderArr = _.sortBy(orderArr, ['fieldOrderNum']);
|
var resArr = [];
|
for (i = 0; i < rslength; i++) {
|
resArr.push([])
|
}
|
console.log(rsArr);
|
console.log(orderArr)
|
_.each(rsArr, (opt, i) => {
|
var j = 0
|
_.each(orderArr, n => {
|
resArr[j][i] = opt[n.fieldKey]
|
j++;
|
})
|
});
|
console.log(resArr);
|
if (resArr.length == 0){
|
alert("上级预算为0");
|
} else {
|
customShow.addRow(subId, resArr);
|
}
|
$(".subformAdd").hide();
|
$(".subformAddiconShow").hide();
|
|
});
|
} else if (sel == "multiple" || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
|
console.log("fundata");
|
if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {//关联函数时 别名相同填值
|
setValByAnother(iconAttr, addVal, "", head, true);
|
}
|
createMxtTable($iconId, head, addVal);
|
$("#" + subId + "subformTr").nextAll().remove();
|
customShow.addRow(subId, data2);
|
$(".subformAdd").hide();
|
$(".subformAddiconShow").hide();
|
}
|
}
|
console.log(customShow.customJs(subId))
|
SC.setSubForm(customShow.customJs(subId), subId);
|
if (addVal.length != 0) {
|
SC.Superior_show()
|
}
|
});
|
}
|
|
customShow.customJs = function (subId) {
|
var subArr = [];
|
console.log(subId)
|
var customItems = customBase.options.customItems;
|
console.log(customItems)
|
_.each(customItems, opt => {
|
if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
|
subArr.push(opt);
|
}
|
});
|
_.remove(subArr, n => {
|
return n.fieldKey == "DATAROWNUM";
|
})
|
console.log(subArr);
|
var aliasArr = [];
|
_.each(subArr, opt => {
|
aliasArr.push(opt.fieldKey)
|
})
|
console.log(aliasArr);
|
return aliasArr;
|
}
|
|
//表单引用 扩展 回显子表单功能
|
fenye = function (pageSize, pageNum, formId, sCondition, formhuixian, head, $iconId, addVal, anydata) {
|
console.log($iconId);
|
console.log("findmany");
|
console.log(anydata);
|
console.log(head);
|
var iconAttr = customShow.options.customItemShow.item[$iconId];//关联数据 函数 数据源 李伟民 11-07
|
console.log(iconAttr);
|
var dataUrl = "";
|
var dataObj;
|
if (anydata) {
|
// alert('if');
|
} else {
|
// alert("else");
|
}
|
if (iconAttr.tag_Attribute.relevancesourcetype && iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
|
dataUrl = "/datamanagement/getAssociateData";
|
dataObj = { "formID": customShow.options.formid, "tenantID": "001", "search": [], "pageSize": pageSize, "pageNum": pageNum, "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
|
_.extend(dataObj, { "formData": customShow.getItems() });
|
} else {
|
dataUrl = "/datamanagement/getAssociatedFormDataService";
|
dataObj = { "formID": formId.formID, "tenantID": "001", "screenCondition": sCondition, "pageSize": pageSize, "pageNum": pageNum, "search": anydata };
|
window.localStorage.setItem("netformid", dataObj.formID);
|
}
|
//关联数据 函数 数据源 李伟民 11-07
|
// var dataObj = {"formID":formId.formID,"tenantID":"001","screenCondition":sCondition,"pageSize":pageSize,"pageNum":pageNum};
|
//window.localStorage.setItem("netformid",dataObj.formID);
|
var requestRight = window.commonAjax(dataUrl, dataObj, "POST", true, false);
|
var counts = "";
|
requestRight.done(function (rs) {
|
if (iconAttr.tag_Attribute.relevancesourcetype && iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
|
// var titleObj = { "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
|
// var requestTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
|
// requestTitle.done(function (res) {
|
// var formtitle = [];
|
// _.each(res.data, function (tdata) {
|
// formtitle.push({ "fieldKey": tdata.fieldKey, "title": tdata.title });
|
// });
|
counts = createTable(rs, formId, formhuixian, head, $iconId, addVal);
|
// });
|
|
} else {
|
counts = createTable(rs, formId, formhuixian, head, $iconId, addVal);//关联表单 列表回显
|
}
|
|
});
|
$('.closeBtn').on('click', () => {
|
$('#' + $iconId + 'menuContent').remove();
|
console.log($('.maskLayer'))
|
$('.maskLayer').css('display', 'none');
|
})
|
return counts;
|
}
|
customShow.journeySort = function () {//行程排序 初始化 李伟民 2017-10-23 15:56
|
//console.log(customShow);
|
var itemKey = _.keys(customShow.options.customItemShow.item);
|
_.each(itemKey, function (keys) {
|
if (customShow.options.customItemShow.item[keys].tag_Type == "subform" && customShow.options.customItemShow.item[keys].tag_Attribute.sorttype != undefined && customShow.options.customItemShow.item[keys].tag_Attribute.sorttype != "") {
|
customShow.bindSort(customShow.options.customItemShow.item[keys].tag_Attribute.sorttype, keys);
|
}
|
});
|
// customShow.bindSort("itemId_6","itemId_3");
|
}//行程排序 初始化 李伟民 2017-10-23 15:56 end
|
|
customShow.bindSort = function (sorttype, sub) {//排序事件绑定
|
if (customShow.options.customItemShow.item[sorttype] == undefined) {
|
return false;
|
}
|
var tagType = customShow.options.customItemShow.item[sorttype].tag_Type;
|
if (tagType == "text" || tagType == "number" || tagType == "calendar") { //单行文本 数字 时间
|
$("[id=" + sorttype + "]").unbind("change.sort", customShow.sortEvent);
|
$("[id=" + sorttype + "]").on("change.sort", { msg: { "sorttype": sorttype, "type": tagType, "sub": sub } }, customShow.sortEvent);
|
} else if (tagType == "dropdownlist") { // 下拉框
|
|
}
|
|
}
|
|
customShow.sortEvent = function (event) {//
|
var sorttype = event.data.msg.sorttype;
|
var type = event.data.msg.type;
|
var sub = event.data.msg.sub;
|
var subType = customShow.options.customItemShow.item[sub].tag_Attribute.allcopy;
|
console.log(event);
|
var allValue;
|
var allItem = [];
|
allValue = customBase.getItemValue(sorttype, type);
|
if(_.isString(allValue)){
|
allValue = [allValue];
|
}
|
//console.log(allValue);
|
_.each(allValue, function (v, i) {
|
var optValue;
|
if(type == "calendar"){
|
optValue = new Date(v);
|
}else if(type == "number"){
|
optValue = Number(v)
|
}else{
|
optValue = v;
|
}
|
if(subType){
|
allItem.push({ "value": optValue, "index": i, "temp": $("[id='" + sub + "ActiveId']:eq(" + i + ")").clone(true) });
|
}else{
|
allItem.push({ "value": optValue, "index": i, "temp": $("[id='" + sub + "subformTr']:eq(" + i + ")").clone(true) });
|
}
|
|
});
|
//console.log(allItem);
|
var sortValue = _.sortBy(allItem, function (o) {
|
return o.value;
|
});
|
console.log(sortValue);
|
if(subType){
|
_.each($("[id='" + sub + "ActiveId']"), function (subform, k) {
|
$(subform).replaceWith(sortValue[k].temp);
|
})
|
}else{
|
_.each($("[id='" + sub + "subformTr']"), function (subform, k) {
|
$(subform).replaceWith(sortValue[k].temp);
|
})
|
}
|
|
// customShow.controlInit("customShow");
|
customLinkageAnalysis.bindLinkage();
|
customShow.journeySort();
|
}
|
//马习同 2017/10/25
|
$(".sTab ul li").on('click', function () {
|
$(this).css('border-bottom', '2px solid #23b7e5');
|
$(this).css('box-sizing', 'border-box');
|
$(this).siblings().css('border', 'none');
|
//console.log($($(".tabBox>div")[$(this).index()]));
|
$($(".tabBox>div")[$(this).index()]).show();
|
$($(".tabBox>div")[$(this).index()]).siblings().hide();
|
if($(this).index() == 0){//切换选项卡导致 保存按钮消失修改 李伟民 0201
|
$(".tabBox .sure_box").show();
|
}
|
});
|
$(".tag_two").on("click", function () {
|
// $(".boxTwo iframe").attr("src","http://122.114.176.216:8087/#/IframeExample?token=C3CDE94FE9CBDDDD37312D3331AC091EC737F5555007677E45A390EFEC7147996A49AA4E117EDC02F0D15984E725CA3B5B93DDAF0C989C35642B58B29360D998DDDAC06EB509BE1C22B19D555A1BB75A07A36FD6C4A7E87C9C9EA0070A213BFB44FF8D3B2AD5A33086EAF1F22E978B24951EA806054F94042533CA73EA7901C5E8B13D4DB7DC87308266E769258DEDFF&openId=3dc22baf5d484170&tenantId=13&companyId=17& appId=1&processInstId=1483")
|
})
|
//马习同 11/7 行转化列
|
customShow.columnToRow = function (head, addVal) {
|
var data = []
|
_.remove(head, n => {
|
return n.fieldKey == "DATAROWNUM";
|
})
|
_.each(head, opt => {
|
let data1 = [];
|
_.each(addVal, opts => {
|
data1.push(opts[opt.fieldKey]);
|
});
|
console.log(data1)
|
data.push(data1)
|
});
|
return data;
|
}
|
|
function submitErrShow(item,num){//审查必须错误提示 李伟民 0119
|
console.log(item,num);
|
var itemId = item.tag_Id;
|
if(num == undefined){
|
num = 0;
|
}
|
var mesageErrDiv = document.createElement("div");
|
mesageErrDiv.setAttribute("class", "mesageErrDiv");
|
$(mesageErrDiv).addClass('submitrErr');
|
var mesageErrStr = item.tag_Attribute.title + '不能为空(审查必须)';
|
mesageErrDiv.setAttribute("id", id + "mesageErrDiv");
|
$(mesageErrDiv).append(mesageErrStr);
|
if(customShow.options.customInit.designMode != 1){//快捷模式 李伟民 0126
|
if ($(".customShow #" + itemId + "ActiveId").length == 0) {
|
console.log($(".customViewUEditorCss [id='" + itemId + "']:eq(" + num + ")").closest("td"));
|
$(".customShow [id='" + itemId + "']:eq(" + num + ")").closest("td").append(mesageErrDiv);
|
$(".customShow ." + itemId + "_showItem:eq(" + num + ")").append(mesageErrDiv);
|
} else {
|
$($($(".customShow #" + itemId + "ActiveId")[num])[0]).append(mesageErrDiv);
|
}
|
}else{//普通模式 李伟民 0126
|
if ($(".customShow #" + itemId).length == 0) {
|
$($(".customShow ." + itemId + "_showItem")[num]).css({
|
'height':"20px",
|
'display':'inline-block'
|
})
|
$($(".customShow ." + itemId + "_showItem")[num]).popover({
|
// title:"错误信息",
|
html: true,
|
content: mesageErrStr,
|
trigger: 'hover'
|
});
|
$($(".customShow ." + itemId + "_showItem")[num]).popover('show');
|
} else {
|
$($(".customShow #" + itemId)[num]).popover({
|
// title:"错误信息",
|
html: true,
|
content: mesageErrStr,
|
trigger: 'hover'
|
});
|
$($(".customShow #" + itemId)[num]).popover('show');
|
}
|
}
|
}
|
|
function submitCheck(){//提交前验证审查必须 李伟民 0119
|
$('.submitrErr').remove();
|
var checkFlag = true;
|
var item = localStorage.getItem('customItem');
|
if(item != undefined && item != ''){
|
item = JSON.parse(item);
|
}
|
console.log(customBase);
|
console.log(customShow);
|
console.log(item);
|
var allItemKey = _.keys(customBase.options.customItems);
|
var allItemId = _.keys(customShow.options.customItemShow.item);
|
var allItem = _.cloneDeep(customShow.options.customItemShow.item);
|
var allItemValue = [];
|
var childItem = [];
|
var parentNums = [];
|
var parentItem = {};
|
_.each(allItemId,function(id){
|
if(allItem[id].parentsubFormNum == 0){
|
allItemValue.push(allItem[id]);
|
}else{
|
childItem.push(allItem[id]);
|
parentNums.push(allItem[id].parentsubFormNum);
|
}
|
});
|
_.each(parentNums,function(num){
|
_.each(allItemId,function(id){
|
if(num == allItem[id].columnOrderNum){
|
parentItem[num] = allItem[id];
|
}
|
});
|
});
|
_.each(childItem,function(cd){
|
_.extend(cd,{'parentId':parentItem[cd.parentsubFormNum].tag_Attribute.alias});
|
});
|
allItemValue = _.concat(allItemValue,childItem);
|
console.log(allItemValue);
|
console.log(item);
|
_.each(allItemValue,function(item_value){
|
if(item_value.parentsubFormNum == 0){
|
var value = item[item_value.tag_Attribute.alias]
|
// _.extend(item_value,{'value':item[item_value.tag_Attribute.alias]});
|
if(item_value.tag_Attribute.approvalmustenter){//审查必须属性
|
if(_.isArray(value)){
|
if(value.length == 0){
|
submitErrShow(item_value);
|
checkFlag = false;
|
}
|
}else if(value == '' || value == undefined){
|
submitErrShow(item_value);
|
checkFlag = false;
|
}
|
}
|
}else{
|
var cd_value = [];
|
_.each(item[item_value.parentId],function(sub){
|
cd_value.push(sub[item_value.tag_Attribute.alias]);
|
});
|
// _.extend(item_value,{'value':cd_value});
|
_.each(cd_value,function(cval,k){
|
if(_.isArray(cval)){
|
if(cval.length == 0){
|
submitErrShow(item_value,k);
|
checkFlag = false;
|
}
|
}else if(cval == '' || cval == undefined){
|
submitErrShow(item_value,k);
|
checkFlag = false;
|
}
|
})
|
}
|
});
|
return checkFlag;
|
}
|
|
//lym
|
function get() {
|
var checkFlag = submitCheck();
|
if(checkFlag != true){
|
return false;
|
}
|
console.log(localStorage.getItem("organizationId"));
|
console.log(localStorage.getItem("datarowNum"));
|
//从local取出log
|
var processLog = localStorage.getItem("processLog");
|
var tenant = JSON.parse(localStorage.getItem("tenantID"));
|
var cust = JSON.parse(localStorage.getItem("customItem"));
|
//暂时修改流程lym
|
// var org = cust.expend_department.trim();
|
//暂时修改流程lym
|
console.log(processLog);
|
console.log(processLog !== null);
|
//12/11
|
if (processLog != "null") {
|
var strMessage = customBase.getMessage("mesage_ID034");
|
customBase.alert("E", strMessage);
|
//return null;
|
} else {
|
//暂时修改流程lym
|
// if (org == "" || org == undefined || org == null) {
|
// //var strMessage = customBase.getMessage("mesage_ID035");
|
// customBase.alert("E", "请选择部门");
|
// return null;
|
// }
|
//暂时修改流程lym
|
// 画面check 提交前验证 李伟民 12-26
|
// var returnfromCheck = customShow.initEvent.fromCheck(items); //--------------------
|
// if (returnfromCheck) {
|
// return;
|
// }
|
var ss = {
|
"tenantID": tenant.tenantID,
|
//"organizationId": org,
|
"formID": localStorage.getItem("newFormID"),
|
"dataRowNum": localStorage.getItem("datarowNum")
|
}
|
var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/create", ss, "POST", true);
|
requestSingleForm.done(function (rs) {
|
console.log(rs);
|
if (rs.resCode == 00000) {
|
|
customBase.alert('S', "提交成功");
|
$("#sssd").click();
|
|
} else {
|
if (rs.data == '3') {
|
customBase.alert('E', "请先配置流程定义");
|
$("#sssd").click();
|
}else if(rs.data == '2'){
|
customBase.alert('E', "请不要重复提交");
|
$("#sssd").click();
|
} else {
|
customBase.alert('E', "提交失败");
|
$("#sssd").click();
|
}
|
}
|
});
|
}
|
|
}
|
//lym结束后操作
|
function over(data) {
|
if (data == true) {
|
//确定提交后操作
|
var processLog = JSON.parse(localStorage.getItem("processLog"));
|
console.log(processLog);
|
var ss = {
|
"processInstId": processLog[0].processInstId
|
}
|
console.log(ss);
|
var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/over", ss, "POST", true);
|
requestSingleForm.done(function (rs) {
|
console.log(rs);
|
if (rs.data == 1) {
|
customBase.alert('S',"结束成功");
|
$("#sssd").click();
|
} else {
|
customBase.alert("E","结束失败");
|
}
|
});
|
|
|
|
} else {
|
$("#sssd").click();
|
}
|
}
|
|
//lym退回确定后操作
|
function tui(data, item) {
|
|
if (data == true) {
|
console.log($('.actcur').val());
|
if ($('.actcur').val() == undefined) {
|
customBase.alert("W","请选择退回的活动");
|
return null;
|
}
|
var processLog = JSON.parse(localStorage.getItem("processLog"));
|
var ss = {
|
"activityInstId": processLog[0].activityInstId,
|
"activityDefId": $('.actcur').val(),
|
"processInstId": processLog[0].processInstId,
|
"formID": localStorage.getItem("newFormID"),
|
"dataRowNum": localStorage.getItem("datarowNum")
|
}
|
var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/bac", ss, "POST", true);
|
requestSingleForm.done(function (rs) {
|
console.log(rs);
|
|
if (rs.data == 1) {
|
customBase.alert("S","退回成功");
|
$("#sssd").click();
|
} else {
|
customBase.alert("E","退回失败");
|
}
|
});
|
|
|
} else {
|
$("#sssd").click();
|
}
|
}
|
//lym 审批确定后方法
|
function zhixing(data) {
|
console.log(data);
|
console.log($("#datas").val());
|
if (data == false) {
|
$("#sssd").click();
|
} else {
|
|
var processLog = JSON.parse(localStorage.getItem("processLog"));
|
console.log(processLog[0].processInstId);
|
var ss = {
|
"processInstId": processLog[0].processInstId,
|
"activityInstId": processLog[0].activityInstId,
|
"data": $("#datas").val(),
|
"formID": localStorage.getItem("newFormID"),
|
"dataRowNum": localStorage.getItem("datarowNum"),
|
"token": localStorage.getItem("testToken"),//差旅token 特殊处理
|
"tenantId": localStorage.getItem("testTenantId"),
|
"companyId": localStorage.getItem("testCompanyId"),
|
|
}
|
console.log("标记token");
|
var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/finish", ss, "POST", true);
|
requestSingleForm.done(function (rs) {
|
console.log(rs);
|
if (rs.resCode == "00000") {
|
customBase.alert('S',"审批成功");
|
$('#editableBtn').remove();//审批成功后不能编辑 李伟民 0129
|
$("#sssd").click();
|
} else {
|
customBase.alert('W',"审批失败");
|
}
|
});
|
}
|
}
|
//2017.11.24 qld 追加预算
|
customBase.budgetAddmoney = function () {
|
var id = JSON.parse(localStorage.getItem("tenantID"))
|
console.log(id.tenantID);
|
var sub = JSON.parse(localStorage.getItem("customItem"));
|
var submit_data = {
|
"formId": localStorage.getItem("newFormID"),
|
"netformid": localStorage.getItem("netformid"),
|
"parentDataRowNum": localStorage.getItem("datarowNum"),
|
"dataRowNum": localStorage.getItem("datarowNum"),
|
"tenantID": id.tenantID,
|
"formType": "ZJ"
|
};
|
|
var submit_request = window.commonAjax1("epc-form/extend/budget/money", submit_data, "POST", true);
|
submit_request.done(function (res) {
|
if (res.resCode == 'C0000') {
|
if (res.data == '1') {
|
var strMessage = customBase.getMessage("mesage_ID024");
|
customBase.alert("E", strMessage);
|
} else if (res.data == '2') {
|
var strMessage = customBase.getMessage("mesage_ID025");
|
customBase.alert("E", strMessage);
|
} else if (res.data == '3') {
|
var strMessage = customBase.getMessage("mesage_ID026");
|
customBase.alert("E", strMessage);
|
} else if (res.data == '9') {
|
var strMessage = customBase.getMessage("mesage_ID027");
|
customBase.alert("S", strMessage);
|
} else if (res.data == '7') {
|
var strMessage = customBase.getMessage("mesage_ID028");
|
customBase.alert("E", strMessage);
|
}
|
|
}
|
|
})
|
|
}
|
|
customBase.budgetBackmoney = function () {
|
var id = JSON.parse(localStorage.getItem("tenantID"))
|
console.log(id.tenantID);
|
var sub = JSON.parse(localStorage.getItem("customItem"));
|
var submit_data = {
|
"formId": localStorage.getItem("newFormID"),
|
"netformid": localStorage.getItem("netformid"),
|
"parentDataRowNum": localStorage.getItem("datarowNum"),
|
"dataRowNum": localStorage.getItem("datarowNum"),
|
"formType": "TH",
|
"tenantID": id.tenantID
|
};
|
|
var submit_request = window.commonAjax1("epc-form/extend/budget/money", submit_data, "POST", true);
|
submit_request.done(function (res) {
|
if (res.resCode == 'C0000') {
|
if (res.data == '1') {
|
var strMessage = customBase.getMessage("mesage_ID024");
|
customBase.alert("E", strMessage);
|
} else if (res.data == '2') {
|
var strMessage = customBase.getMessage("mesage_ID025");
|
customBase.alert("E", strMessage);
|
} else if (res.data == '3') {
|
var strMessage = customBase.getMessage("mesage_ID026");
|
customBase.alert("E", strMessage);
|
} else if (res.data == '9') {
|
var strMessage = customBase.getMessage("mesage_ID027");
|
customBase.alert("S", strMessage);
|
} else if (res.data == '7') {
|
var strMessage = customBase.getMessage("mesage_ID028");
|
customBase.alert("E", strMessage);
|
}
|
}
|
|
})
|
|
}
|
function repayment() {
|
var customBase = window.customBase;
|
customBase.repayment();
|
return true;
|
}
|
customBase.repayment = function () {
|
var id = JSON.parse(localStorage.getItem("tenantID"))
|
console.log(id.tenantID);
|
var sub = JSON.parse(localStorage.getItem("customItem"));
|
console.log(sub);
|
var subForm = sub.DATAROWNUM;
|
console.log("我是" + subForm)
|
var submit_data = {
|
"formId": localStorage.getItem("newFormID"),
|
"netformid": localStorage.getItem("netformid"),
|
"parentDataRowNum": localStorage.getItem("datarowNum"),
|
"datarowNum": localStorage.getItem("datarowNum"),
|
"tenantId": id.tenantID
|
};
|
|
var submit_request = window.commonAjax1("epc-form/repayment/money", submit_data, "POST", true);
|
submit_request.done(function (res) {
|
if (res.data == true) {
|
// 12/7 qld
|
var strMessage = customBase.getMessage("mesage_ID029");
|
customBase.alert("S", strMessage);
|
} else {
|
var strMessage = customBase.getMessage("mesage_ID030");
|
customBase.alert("E", strMessage);
|
}
|
|
})
|
|
}
|
//子表单合计方法 马习同 2017-12-06
|
customShow.subTotle = function (subId) {
|
var customItems = customBase.options.customItems;
|
var numArr = [];
|
var subArr = [];
|
var numObj = {};
|
_.each(customItems, opt => {
|
if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
|
subArr.push(opt);
|
}
|
});
|
_.remove(subArr, n => {
|
return n.fieldKey == "DATAROWNUM";
|
});
|
_.each(subArr, opt => {
|
if (opt.type == "number") {
|
console.log(opt.id);
|
numObj[opt.id] = customBase.getItemValue(opt.id, opt.type);
|
numArr.push(Number(customBase.getItemValue(opt.id, opt.type)));
|
}
|
})
|
console.log(numObj);
|
for (let key in numObj) {
|
var opts = [];
|
if (_.isArray(numObj[key])) {
|
_.each(numObj[key], n => {
|
n = Number(n);
|
console.log(n);
|
opts.push(n);
|
})
|
numObj[key] = opts;
|
}
|
console.log(numObj[key]);
|
}
|
console.log(numObj);
|
//_.sum 求和
|
for (let key in numObj) {
|
$("." + key + "totle").val(_.sum(numObj[key]));
|
}
|
|
}
|
//子表单合计方法 马习同 2017-12-07
|
customShow.oneTotle = function () {
|
var customItems = customShow.options.customItemShow.item;
|
var totleArr = [];
|
var numObj = {};
|
var numArr = [];
|
_.each(customItems, opt => {
|
console.log(opt.tag_Attribute.total)
|
if (opt.tag_Attribute.total == true) {
|
totleArr.push(opt.tag_Id);
|
console.log(opt.tag_Id)
|
}
|
})
|
console.log(totleArr);
|
_.each(totleArr, opt => {
|
$("#" + opt + " [type='number']").unbind("change.totle");
|
$("#" + opt + " [type='number']").on("change.totle", function () {
|
console.log($(this).attr("id"));
|
numObj[$(this).attr("id")] = customBase.getItemValue($(this).attr("id"), $(this).attr("type"));
|
console.log(_.cloneDeep(numObj));
|
console.log(numObj[key])
|
|
for (let key in numObj) {
|
var opts = [];
|
if (_.isArray(numObj[key])) {
|
_.each(numObj[key], n => {
|
n = Number(n);
|
console.log(n);
|
opts.push(n);
|
})
|
numObj[key] = opts;
|
}
|
console.log(numObj[key]);
|
}
|
|
console.log(numObj);
|
//_.sum 求和
|
for (let key in numObj) {
|
$("." + key + "totle").val(_.sum(numObj[key]));
|
}
|
})
|
})
|
}
|
//子表单内的控件内容超出部分显示title
|
customShow.addTitle = function () {
|
_.each($(".customShow .tdContentClass"), opt => {
|
// $(opt).attr("title", $(opt).children().children().html());
|
console.log($(opt).html())
|
if ($(opt).children().children().attr("type") == "text") {
|
$(opt).attr("title", $(opt).children().children().val());
|
} else {
|
console.log(_.cloneDeep($(opt).children().children()))
|
console.log(opt.innerHTML)
|
console.log($(opt).children().children()[0].innerHTML)
|
$(opt).attr("title", $(opt).children().children()[0].innerHTML);
|
}
|
})
|
}
|
// customShow.businessTypeAutoFun = function(key,fieldKey,cookieOrlocal){
|
// if(cookieOrlocal == 'cookie'){
|
// if(customBase.options.customItems[fieldKey].parentsubFormNum == '0'){
|
// var businessTypeAuto = getCookie(key);
|
// customBase.setItemValue(customBase.options.customItems[fieldKey].id, customBase.options.customItems[fieldKey].type, businessTypeAuto, '', '');
|
// }
|
// }else{
|
// if(customBase.options.customItems[fieldKey].parentsubFormNum == '0'){
|
// var businessTypeAuto = window.localStorage.getItem(key);
|
// customBase.setItemValue(customBase.options.customItems[fieldKey].id, customBase.options.customItems[fieldKey].type, businessTypeAuto, '', '');
|
// }
|
// }
|
// }
|
// SC.billInfoInit = function(items){//票据信息初始化 李伟民 12-26
|
// var itemKey = _.keys(items);
|
// var customItems = customBase.options.customItems;
|
// customShow.allbillInfo = [];
|
// _.each(itemKey,function(key){
|
// console.log(key);
|
// if(customItems[key] != undefined && customItems[key] != '' && customItems[key].type == "subform"){
|
// var billInfos = [];
|
// _.each(items[key], function(journey, i){
|
// if(journey.billData != undefined){
|
// billInfos.push(JSON.parse(journey.billData));
|
// $("#" + key + "ActiveId").attr('noBillCheck',JSON.parse(journey.billData));
|
// }else{
|
// billInfos.push({});
|
// }
|
// });
|
// customShow.allbillInfo.push({
|
// 'subFormId':customItems[key].id,
|
// 'subFormKey':key,
|
// 'billInfos':billInfos
|
// })
|
// }
|
// });
|
// billInfobind(customShow.allbillInfo);
|
// SC.noBillCheckInit();
|
// }
|
// SC.noBillCheckInit = function(){
|
// noBillCheck('journey','reimburseMan');
|
// }
|
// function noBillCheck(subFieldKey,reimburseManKey){//无票据行程及票据人员与报销人验证
|
// if(customBase.options.customItems[subFieldKey] == undefined){
|
// return false;
|
// }
|
// var subId = customBase.options.customItems[subFieldKey].id;
|
// var manId = customBase.options.customItems[reimburseManKey].id;
|
// var manType = customBase.options.customItems[reimburseManKey].type;
|
// var manTitle = customBase.options.customItems[reimburseManKey].title;
|
// var journeySub = $("#" + subId + "ActiveId");
|
// _.each(journeySub,function(jour){
|
// var checkData = $(jour).attr('noBillCheck');
|
// if(checkData != undefined && checkData != ''){
|
// checkData = JSON.parse(checkData);
|
// var manVal = customBase.getItemValue(manId,manType);
|
// if(manVal != undefined && manVal != checkData.PersonalVal){
|
// $(jour).children('h8').append("<span class='billCheck'>" + "票据‘" + checkData.PersonalName + "’与" + manTitle + "不同</span>");
|
// }
|
// }else{
|
// $(jour).children('h8').append("<span class='billCheck'>无票据行程</span>");
|
// }
|
// });
|
// }
|
// function billInfobind(allbillInfo){//票据信息显示 及 实时验证 李伟民 12-26
|
// _.each(allbillInfo,function(info,k){
|
// var sub_type = customShow.options.customItemShow.item[info.subFormId].tag_Attribute.allcopy;
|
|
// _.each(info.billInfos,function(binfo, i){
|
// if(binfo.billCode != undefined){
|
// var itemKey = _.keys(binfo.billHeadMeaningMvCodeMap);
|
// _.each(itemKey,function(key){
|
// if(binfo.billHeadMap[key] != undefined && binfo.billHeadMap[key] != ''){
|
// var bhName = binfo.billHeadMap[key].val;
|
// var bhVal = binfo.billHeadMap[key].code;
|
// billShow(sub_type,itemKey,bhName,bhVal,i);
|
// if(sub_type && key == 'PersonalName'){//储存票据人员信息
|
// var noBillCheckData = {
|
// "PersonalName":bhName,
|
// "PersonalVal":bhVal
|
// };
|
// $("#" + info.subFormId + "ActiveId:ep(" + k + ")").attr("noBillCheck",JSON.stringify(noBillCheckData));
|
// }
|
// }
|
// });
|
// }
|
// });
|
// })
|
// }
|
// function billShow(sub_type,itemKey,bhName,bhVal,num){//票据信息验证绑定 李伟民 12-26
|
// var itemId = customBase.options.customItems[itemKey].id;
|
// var type = customBase.options.customItems[itemKey].type;
|
// if(sub_type){
|
// $("[id='"+itemId+"ActiveId']:eq('" + num + "')").find("h8[name='el_title']").append("<span class='billCheck'>" + bhName + "</span>");
|
// }else{
|
// customBase.set_p($("[id='"+itemId+"']:eq('" + num + "')"));
|
// if(type == 'dropdownlist'){
|
// $("[id='"+itemId+"']:eq('" + num + "')").closet("p").append("<span class='billCheck'>" + bhName + "</span>");
|
// }else{
|
// $("[id='"+itemId+"']:eq('" + num + "')").prev("p").append("<span class='billCheck'>" + bhName + "</span>");
|
// }
|
|
// }
|
// if(type == 'dropdownlist'){
|
// $("[id='"+itemId+"']:eq('" + num + "')").find(".select_get").on('change.billcheck',function(){
|
// if(sub_type){
|
// $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "#333");
|
// if($(this).val() != bhVal) {
|
// $("[id='"+base_item_id+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "red");
|
// }
|
// }else{
|
// $("[id='"+itemId+"']:eq('" + i + "')").closet("p").find(".billCheck").css("color", "#333");
|
// if($(this).val() != bhVal) {
|
// $("[id='"+itemId+"']:eq('" + i + "')").closet("p").find(".billCheck").css("color", "red");
|
// }
|
// }
|
// });
|
// }else{
|
// $("[id='"+itemId+"']:eq('" + num + "')").on('change.billcheck',function(){
|
// if(sub_type){
|
// $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "#333");
|
// if($(this).val() != bhVal) {
|
// $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "red");
|
// }
|
// }else{
|
// $("[id='"+itemId+"']:eq('" + i + "')").prev("p").find(".billCheck").css("color", "#333");
|
// if($(this).val() != bhVal) {
|
// $("[id='"+itemId+"']:eq('" + i + "')").prev("p").find(".billCheck").css("color", "red");
|
// }
|
// }
|
// })
|
// }
|
// }
|