//绑定查询框,bindTable需要绑定的table,copy的对象,需要查询的表
function bindQueryInput(copyFromTr,queryTable,trOnly){
var trStr = "
";
var totalTr = "
";
$(copyFromTr).find("label,input,select").each(
function (){
var widthStr = $(this).attr("width");
if($(this).attr("type") && $(this).attr("type") == 'checkbox'){
trStr=trStr+" | ";
totalTr = totalTr + "合计 | ";
}else{
if($(this).attr("unUseOrder")!="Y"){
var tdStr = " | "
var totalTd = " | ";
trStr=trStr+tdStr;
totalTr = totalTr+totalTd;
}
}
}
);
trStr=trStr+"
";
totalTr=totalTr+"";
$("#"+queryTable).find("tr:first").before(trStr);
// $("#"+queryTable).find("tr:last").append(totalTr);
}
function bindQueryInput_(copyFromTr,queryTable,trOnly){
var trStr = "";
var totalTr = "
";
$(copyFromTr).find("label,input").each(
function (){
var widthStr = $(this).attr("width");
if($(this).attr("type") && $(this).attr("type") == 'checkbox'){
trStr=trStr+" | ";
totalTr = totalTr + "合计 | ";
}else{
if($(this).attr("unUseOrder")!="Y"){
var tdStr = " | "
var totalTd = " | ";
trStr=trStr+tdStr;
totalTr = totalTr+totalTd;
}
}
}
);
trStr=trStr+"
";
totalTr=totalTr+"";
$("#"+queryTable).find("tr:first").before(trStr);
}
function doBindQueryInput_(obj,evt){
var queryTable = $(obj).attr("queryTable");
var trOnly = $(obj).attr("trOnly");
evt = (evt) ? evt : ((window.event) ? window.event : "");
var keyCode = evt.keyCode ? evt.keyCode : (evt.which ? evt.which : evt.charCode);
if(keyCode==13){
$("#"+queryTable).find("tr").each(
function (){
if($(this).attr(trOnly)){
$(this).css("display","");
}
}
);
$(obj).parent().parent().find("input").each(
function (){
if($(this).val()){
var inputValue = $(this).val();
var attrName = ($(this).attr("name")).replace("tablesearch_","");
$("#"+queryTable).find("tr").each(
function (){
if($(this).css("display") != "none"){
if($(this).attr(trOnly)){
$(this).find("label[name="+attrName+"]").each(
function (){
if($(this).text().indexOf(inputValue) >= 0){
$(this).parent().parent().css("display","");
}else{
$(this).parent().parent().css("display","none");
}
}
);
}
}
}
);
}
}
);
}
}
// 公共信息变更函数
function contentChange(contentChangeList, _this) {
try {
if (!$.isArray(contentChangeList) || !_this) {
return;
}
// no change的标志
if ($(_this).attr("noChange") == "true" || $(_this).attr("noChange") == true) {
return;
}
if ( $(_this).attr("name") != undefined
&& $(_this).attr("name") != ""
&& $.inArray($(_this).attr("name"),contentChangeList) == -1 ) {
contentChangeList.push($(_this).attr("name"));
}else if( $(_this).attr("comboname") != undefined
&& $(_this).attr("comboname") != ""
&& $.inArray($(_this).attr("comboname"),contentChangeList) == -1 ){
contentChangeList.push($(_this).attr("comboname"));
} else if( $(_this).attr("numberboxname") != undefined
&& $(_this).attr("numberboxname") != ""
&& $.inArray($(_this).attr("numberboxname"),contentChangeList) == -1 ){
contentChangeList.push($(_this).attr("numberboxname"));
}
else if ($(_this).attr("nativeChangeField") != undefined && $(_this).attr("nativeChangeField") != "" && $.inArray($(_this).attr("nativeChangeField"),contentChangeList) == -1) {
contentChangeList.push($(_this).attr("nativeChangeField"));
}
} catch (e) {
// do nothing
}
}
function isObject(v) {
return typeof v == 'object' && v.constructor == Object ? true : false;
};
function isJQuery(v) {
return typeof v.jquery != 'undefined';
}
// bind jQueryDatepicker to
function initDatePicker(selector) {
if (!isJQuery(selector || {})) {
return;
}
$.loadJQueryDatepickerWidegt();
selector.each(function() {
// alert(this.outerHTML);
_this = $(this);
$(this).datepicker({
showDateFormater : true,
changeMonth : true, // 设置可选 mouth
changeYear : true, // 设置可选 year
showButtonPanel : true, // 显示 下方 今天、关闭 button
// numberOfMonths: 3, // 同时显示3列datepicker
showOn : '', // 取消 自动 show
duration : 0
// 取消动态效果
});
$(this).next(".time_img").click(function() {
try {
// alert($(this).prev(".hasDatepicker").get(0).outerHTML);
$(this).prev(".hasDatepicker").datepicker('show');
} catch (e) {
// it is not a datepicker
}
});
})
}
(function($) {
$.fn.getFormValue = function() {
var o = {};
$(this).find('input,select,textarea').each(function() {
if ($(this).attr("name") != "") {
if ($(this).val() || $(this).val() == 0) {
if ($(this).val() == "") {
if(typeof($(this).attr("editType")) != 'undefined' && $(this).attr("editType").toUpperCase() == "CKEDITOR") {
o[$(this).attr("name")] = CKEDITOR.instances[$(this).attr("name")].getData();
}else {
o[$(this).attr("name")] = null;
}
} else {
if ($(this).attr("editType") == "suggestBox") {
o[$(this).attr("name")] = $(this).attr("hiddenValue");
o[$(this).attr("name") + "_name"] = $(this).val();
} else if ($(this).attr("editType") == "simpleCheckbox") {
if ($(this).attr("checked")) {
o[$(this).attr("name")] = 1;
} else {
o[$(this).attr("name")] = 0;
}
} else if(typeof($(this).attr("editType")) != 'undefined' && $(this).attr("editType").toUpperCase() == "CKEDITOR") {
o[$(this).attr("name")] = CKEDITOR.instances[$(this).attr("name")].getData();
}else {
if( $(this).attr("class")=="easyui-numberbox numberbox-f validatebox-text" ) {//数值型
var field = $(this).attr("numberboxname");
var value = $(this).next().val();
o[field] = value;
}else if( $(this).attr("class")=="easyui-datebox datebox-f combo-f" ) {//日期型
var field = $(this).attr("comboname");
var value = $(this).next()[0].children[2].value;
o[field] = value;
}else if( $(this).hasClass("easyui-combobox")){//下拉框
var field = $(this).attr("comboname");
var value = $(".combo-value[name="+field+"]").val();
o[field] = value;
}else if( $(this).attr("type")=="checkbox" ){//复选框
var field = $(this).attr("name");
var value = $(this).val();
if( this.checked ) {
o[field] = ( value=="on" ? 1:value );
}else{
o[field] = 0;
}
}else if( $(this).attr("type")=="radio" ){//单选框
var field = $(this).attr("name");
var value = $(this).val();
if( this.checked ) {
o[field] = ( value=="on" ? 1:value );
}else{
o[field] = 0;
}
}
else{
//解决IE8下 时间控件的值为"NULL"的问题
if ("null" == $(this).val())
{
o[$(this).attr("name")] = null;
}
else
{
o[$(this).attr("name")] = $(this).attr("hiddenValue") || $.trim($(this).val());
}
}
}
}
}
}
});
return o;
};
$.fn.fillForm = function( data ) {
$(this).form("load", data);
$(this).find('input').each(function() {
if ($(this).attr("name") != "") {
var name = $(this).attr("name") ;
if( $(this).attr("type")=="checkbox" || $(this).attr("type")=="radio" ){//复选框
var value = $(this).val();
if( ( value == data[name] || data[name] ==1) && data[name] !=0 ){
this.checked = true;
}
}
}
});
$(this).find("input[myType='easyui-combobox']").each(function(i){
var a = this;
var comboname = $(a).attr("comboname");
if (comboname != "")
{
var lastSub = comboname.substring(comboname.length-2,comboname.length);
var textName = "";
if ("Id" == lastSub)
{
textName = comboname.replace("Id","Name");
}
else
{
textName = comboname + "Name";
}
if (!data[textName])
{
data[textName]=data[comboname];
}
$(a).combobox('setValue',data[comboname]);
if ($(a).combobox('getText') == $(a).combobox('getValue'))
{
$(a).combobox('setText',data[textName]);
}
}
});
$(this).find("input[myType='easyui-combogrid']").each(function(i){
var a = this;
var comboname = $(a).attr("comboname");
if (comboname != "")
{
var lastSub = comboname.substring(comboname.length-2,comboname.length);
var textName = "";
if ("Id" == lastSub)
{
textName = comboname.replace("Id","Name");
}
else
{
textName = comboname + "Name";
}
if (!data[textName])
{
data[textName]=data[comboname];
}
var opts = $(a).combogrid('options');
var ele = {};
ele[opts.idField] = data[comboname];
ele[opts.textField] = data[textName];
// $(a).combogrid('grid').datagrid({data:[ele]});
$(a).combogrid('setValue',data[comboname]);
if (!$(a).combogrid('getText'))
{
$(a).combogrid('setText',data[textName]);
}
//$(".combo-value[name="+comboname+"]").val(data[comboname]);
}
});
};
$.fn.disabledContentFeild = function(fields) {
$(this).find('input,select,textarea').each(
function() {
var isDisabled = true;
if (fields == "all") {
$(this).attr("disabled", true);
} else if (fields[0] == "all") {
$(this).attr("disabled", true);
} else if (fields.contains($(this).attr("name")) || fields.contains($(this).attr("nativeChangeField"))) {
$(this).attr("disabled", true);
} else {
isDisabled = false;
}
if (isDisabled && $(this).hasClass("hasDatepicker")) {
$(this).next(".time_img").unbind("click");
}
if (isDisabled && $(this).attr("editType") == "comment") {
//$(this).next(".commentClass").css("display", 'none');
$(this).next(".commentClass").attr("disabled", true);
}
if (isDisabled && $(this).attr("editType") == "suggestBox" && $(this).attr("hasShowTrigger") == true) {
//$(this).next(".suggestbox-trigger-img").css("display", 'none');
$(this).next(".suggestbox-trigger-img").attr("disabled", true);
}
});
}
})(jQuery);
/**
* 绑定DOM对象的事件
* @param {} _scope 绑定范围
*/
function bindEditTypeEvent(_scope) {
if (!_scope) {
_scope = $("body");
}
$(_scope).find('input,textarea,select').each(function() {
if ($(this).attr("notBlank") && ($(this).parent(0).prev().text()).indexOf("*") == -1) {
$(this).parent(0).prev().html("*"+$(this).parent(0).prev().text());
}
if(typeof($(this).attr("editType")) != 'undefined') {
if ($(this).attr("editType") == "int") {
$(this).bindIntKeyDown();
}
else if ($(this).attr("editType") == "float") {
$(this).bindDecimalKeyDown();
}
else if ($(this).attr("editType") == "combo") {
if (typeof(dictionary) != 'undefined' && dictionary) {
if (dictionary[$(this).attr("name")]) {
if (!$(this).attr("notBlank") || $(this).attr("emptyOption")) {
var op = new Option('', '');
$(this).get(0).options.add(op);
$(this).val('');
}
var dictionaryList = dictionary[$(this).attr("name")];
for (var i = 0; i < dictionaryList.length; i++) {
var op = new Option(dictionaryList[i]['dictionaryName'],dictionaryList[i]['dictionaryId']);
$(this).get(0).options.add(op);
}
// 扩展defaultValue属性
if($(this).attr("defaultValue")) {
$(this).val($(this).attr("defaultValue"));
}
}
}
}
else if ($(this).attr("editType") == "date" || $(this).attr("editType") == "dateTime") {
$(this).nextAll('.hh').attr("maxLength",2);
$(this).nextAll('.mm').attr("maxLength",2);
}
else if ($(this).attr("editType") == "comment") {
if ($(this).nextAll(".commentClass").length == 0) {
$(this).after("");
var _field = $(this).attr("id");
$(this).nextAll(".commentClass").click(function() { addCommentDetail(_field);});
$(this).attr("readonly",true);
}
}
else if ($(this).attr("editType").toLowerCase() == "signedint") {
$(this).bindSignedIntKeyDown();
}
else if ($(this).attr("editType").toLowerCase() == "signedfloat") {
$(this).bindSignedDecimalKeyDown();
}
}
if($(this).attr("maxLength") == 'undefined' && $(this).attr("tagName").toUpperCase() == "TEXTAREA") {
$(this).attr("maxLength",65534);
}
});
}
// 校验和取得日期控件的值
function generatDateTimeFromInput(object, fileds, tag) {
var isOk = true;
for (var i = 0; i < fileds.length; i++) {
var fieldName = fileds[i];
if (object[fieldName] != "" && object[fieldName] != undefined && object[fieldName] != null) {
var dateFormat = /^(\d{4})\-(\d{2})\-(\d{2}) ([01]{0,1}[0-9]|2[0-3]):([0-5]{0,1}[0-9]):(\d{2})$/;
var _this = $(tag).find("input[name='" + fieldName + "']");
$(_this).each(function() {
var hh = $(this).nextAll('.hh').val();
var mm = $(this).nextAll('.mm').val();
var ss = "00";
if (hh == null || hh == "") {
hh = "00";
}
if (mm == null || mm == "") {
mm = "00";
}
object[fieldName] = object[fieldName] + " " + hh + ":" + mm + ":" + ss;
if (!dateFormat.test(object[fieldName])) {
commonErrorPrompt($(this).attr("promptName")==undefined?"必填项":$(this).attr("promptName") + "日期格式不正确");
_this.focus();
isOk = false;
}
});
}
}
return isOk;
}
/**
* 验证表单数据
* @param {} _scope 查找域
* @return {}
*/
function validateValue(_scope) {
var result = true;
$(_scope).each(function() {
if (result) {
var _thisObject=$(this);
if($(this).attr("editType")){
var t_editType = $(this).attr("editType").toLowerCase();
if(t_editType=='int'||t_editType=='float'||t_editType=='signedint'||t_editType=='signedfloat'){
if($(this).val()){
if(isNaN($(this).val())){
result = false;
_thisObject.focus();
commonErrorPrompt($(this).attr("promptName") + "数值类型不正确");
return;
}
if (typeof($(this).attr("maxValue")) == 'undefined') {
$(this).attr("maxValue","999999999");
}
if (typeof($(this).attr("minValue")) == 'undefined') {
$(this).attr("minValue","-999999999");
}
}
}
if(t_editType=='simplecheckbox'){
if ($(this).attr("notBlank") && !$(this).attr("checked")) {
result = false;
commonErrorPrompt(($(this).attr("promptName")==undefined?"必填项":$(this).attr("promptName")) + "不能为空");
return _thisObject.focus();
}
}
}
if ($(this).attr("notBlank")) {
if (typeof($(this).val()) == 'undefined' || $(this).val() == null || $(this).val().trim() == "") {
result = false;
commonErrorPrompt(($(this).attr("promptName")==undefined?"必填项":$(this).attr("promptName")) + "不能为空");
return _thisObject.focus();
}
}
if ($(this).val() != null && $(this).val() != "null" ) {
if ($(this).attr("minValue")) {
if ($(this).val() != "") {
if (!isNaN($(this).attr("minValue")
&& !isNaN($(this).val()))) {
if (parseFloat($(this).attr("minValue")) > parseFloat($(this).val())) {
//alert($(this).val());
result = false;
_thisObject.focus();
commonErrorPrompt($(this).attr("promptName") + "不能小于" + $(this).attr("minValue"));
return;
}
}
}
}
if ($(this).attr("maxValue")) {
if ($(this).val() != "") {
if (!isNaN($(this).attr("maxValue")
&& !isNaN($(this).val()))) {
if (parseFloat($(this).attr("maxValue")) < parseFloat($(this).val())) {
result = false;
_thisObject.focus();
commonErrorPrompt($(this).attr("promptName") + "不能大于" + $(this).attr("maxValue"));
return;
}
}
}
}
if ($(this).attr("maxLength")&&$(this).attr("maxLength")<65535) {
if ($(this).val() != "") {
if ($(this).val().length > $(this).attr("maxLength")) {
result = false;
_thisObject.focus();
commonErrorPrompt($(this).attr("promptName") + "长度不能大于"+ $(this).attr("maxLength"));
return;
}
}
}else{
if ($(this).val() != "") {
if ($(this).val().length > 30 && $(this).attr("editType")!="suggestBox") {
result = false;
_thisObject.focus();
commonErrorPrompt($(this).attr("promptName") + "长度不能大于"+ 30);
return;
}
}
}
if ($(this).attr("regularExpression")) {
if ($(this).val() != "") {
var target = $(this).val();
if (!$.jquery_Utils_FormVTypes[$(this).attr("regularExpression")](target,this)) {
result = false;
commonErrorPrompt($.i18n('adageCommonAllJS',$(this).attr("regularExpression")+ "Text"));
return _thisObject.focus();
};
}
}
}
}
});
return result;
}
/**
* 勾选表格
* @param {} _this
* @param {} objStr
*/
function checkAllForTable(_this, objStr) {
var isChecked = false;
if (_this.checked) {
isChecked = true;
}
var checkboxs = document.getElementsByName(objStr);
for (var i = 0; i < checkboxs.length; i++) {
checkboxs[i].checked = isChecked;
}
}
/**
* 获取表单内的数值
* @param {} _this
* @return {}
*/
function getFormValue(_this) {
var o = {};
$(_this).each(function() {
if ($(this).attr("name") != "") {
if ($(this).val() || $(this).val() == 0) {
if ($(this).val() == "") {
if(typeof($(this).attr("editType")) != 'undefined' && $(this).attr("editType").toUpperCase() == "CKEDITOR") {
o[$(this).attr("name")] = CKEDITOR.instances[$(this).attr("name")].getData();
}else {
o[$(this).attr("name")] = null;
}
} else {
if ($(this).attr("editType") == "suggestBox") {
o[$(this).attr("name")] = $(this).attr("hiddenValue");
o[$(this).attr("name") + "_name"] = $(this).val();
} else if ($(this).attr("editType") == "simpleCheckbox") {
if ($(this).attr("checked")) {
o[$(this).attr("name")] = 1;
} else {
o[$(this).attr("name")] = 0;
}
} else if(typeof($(this).attr("editType")) != 'undefined' && $(this).attr("editType").toUpperCase() == "CKEDITOR") {
o[$(this).attr("name")] = CKEDITOR.instances[$(this).attr("name")].getData();
}else {
o[$(this).attr("name")] = $(this).attr("hiddenValue") || $(this).val().trim();
}
}
}
}
});
return o;
}
// 获得日期类型的控件
function getDateTimeFields(_this) {
var returnArray = [];
var inputArray = $(_this).find("input[editType=dateTime],input[editType=date]");
$(inputArray).each(function() {
if ($(this).attr("name")) {
returnArray.push($(this).attr("name"));
}
});
return returnArray;
}
// 处理时间填充
function fillFieldWithDateTime(_this, dateValue) {
var dateArray = dateValue.split(" ");
$(_this).val(dateArray[0]);
var hhMMArray = dateArray[1].split(":");
$(_this).nextAll('.hh').val(hhMMArray[0]);
$(_this).nextAll('.mm').val(hhMMArray[1]);
}
// 处理时间填充
function fillFieldWithDate(_this, dateValue) {
var dateArray = dateValue.split(" ");
$(_this).val(dateArray[0]);
}
// 根据组件类型来进行赋值
function fillingData(_this, information) {
$(_this).find('input,select,textarea').each(function() {
if (information[$(this).attr("name")]
|| information[$(this).attr("name")] == 0) {
if ($(this).attr("editType") == "suggestBox") {
$(this).attr("hiddenValue", information[$(this).attr("name")]);
$(this).val(information[$(this).attr("name") + "_name"]);
} else if ($(this).attr("editType") == "dateTime") {
fillFieldWithDateTime(this, information[$(this).attr("name")]);
} else if ($(this).attr("editType") == "date") {
fillFieldWithDate(this, information[$(this).attr("name")]);
} else if ($(this).attr("editType") == "simpleCheckbox") {
if (information[$(this).attr("name")] == 1 || information[$(this).attr("name")] == "1") {
$(this).attr("checked", true);
} else {
$(this).attr("checked", false);
}
}
else if ($(this).attr("editType") == "my97Date")
{
if($(this).attr("dateFmt") == "yyyy-MM-dd HH:mm:ss")
{
var strTime = information[$(this).attr("name")];
var datTime = new Date(Date.parse(strTime.replace(/-/g, "/")));
var mon = datTime.getMonth().toString().length ==1 ? "0"+(datTime.getMonth()+1).toString():(datTime.getMonth()+1).toString();
var d = datTime.getDate().toString().length ==1 ? "0"+datTime.getDate().toString():datTime.getDate().toString();
var h = datTime.getHours().toString().length ==1 ? "0"+datTime.getHours().toString():datTime.getHours().toString();
var m = datTime.getMinutes().toString().length ==1 ? "0"+datTime.getMinutes().toString():datTime.getMinutes().toString();
var s = datTime.getSeconds().toString().length ==1 ? "0"+datTime.getSeconds().toString():datTime.getSeconds().toString();
$(this).val(datTime.getFullYear()+"-"+mon+"-"+d+" "+h+":"+m+":"+s);
}
else if($(this).attr("dateFmt") == "yyyy-MM-dd HH:mm")
{
var strTime = information[$(this).attr("name")];
var datTime = new Date(Date.parse(strTime.replace(/-/g, "/")));
var mon = datTime.getMonth().toString().length ==1 ? "0"+(datTime.getMonth()+1).toString():(datTime.getMonth()+1).toString();
var d = datTime.getDate().toString().length ==1 ? "0"+datTime.getDate().toString():datTime.getDate().toString();
var h = datTime.getHours().toString().length ==1 ? "0"+datTime.getHours().toString():datTime.getHours().toString();
var m = datTime.getMinutes().toString().length ==1 ? "0"+datTime.getMinutes().toString():datTime.getMinutes().toString();
var s = datTime.getSeconds().toString().length ==1 ? "0"+datTime.getSeconds().toString():datTime.getSeconds().toString();
$(this).val(datTime.getFullYear()+"-"+mon+"-"+d+" "+h+":"+m);
}
else if($(this).attr("dateFmt") == "yyyy-MM-dd")
{
var strTime = information[$(this).attr("name")];
var datTime = new Date(Date.parse(strTime.replace(/-/g, "/")));
var mon = datTime.getMonth().toString().length ==1 ? "0"+(datTime.getMonth()+1).toString():(datTime.getMonth()+1).toString();
var d = datTime.getDate().toString().length ==1 ? "0"+datTime.getDate().toString():datTime.getDate().toString();
$(this).val(datTime.getFullYear()+"-"+mon+"-"+d);
}
}
else {
$(this).val(information[$(this).attr("name")]);
}
}
});
}
// 不可编辑操作
function disabledFeild(_scope, fields) {
$(_scope).each(function() {
if (fields == "all") {
$(this).attr("disabled", true);
} else if (fields[0] == "all") {
$(this).attr("disabled", true);
} else if (fields.contains($(this).attr("name"))
|| fields.contains($(this).attr("nativeChangeField"))) {
$(this).attr("disabled", true);
}
})
}
/**
*
* Description:[设置页面不可编辑属性]
*
* @param {} _scope
* @param {} fields
*/
function disabledAttributes(_scope, fields) {
if(fields.hasOwnProperty("unEditableFields")) {
_scope.find('input,select,textarea').each(function() {
var isDisabled = true;
if (fields["unEditableFields"] == "all") {
isDisabled = true;
//$(this).attr("disabled", true);
} else if (fields["unEditableFields"][0] == "all") {
isDisabled = true;
//$(this).attr("disabled", true);
} else if (fields["unEditableFields"].contains($(this).attr("name"))) {
isDisabled = true;
} else if (fields["unEditableFields"].contains($(this).attr("numberboxname"))
|| fields["unEditableFields"].contains($(this).attr("comboname"))) {
isDisabled = true;
}else {
isDisabled = false;
}
if(isDisabled) {
var bgFlg = true;
if($(this).hasClass("combo-value")) {
var $ele = $(this).parent().prev();
if ($ele.attr("myType") == 'easyui-combobox' || $ele.hasClass("easyui-combobox"))
{
$ele.combobox('disable');
}
else if ($ele.attr("myType") == 'easyui-combogrid' || $ele.hasClass("easyui-combogrid"))
{
$ele.combogrid('disable');
$ele.attr("disabled", "disabled");
}
else
{
$ele.attr("disabled", "disabled");
}
}
else if($(this).hasClass("easyui-numberbox")) {
$(this).numberbox('disable');
}
else if($(this).hasClass("easyui-datebox")) {
$(this).datebox('disable');
}
else if($(this).attr("myType") == 'easyui-combogrid') {
$(this).combogrid('disable');
$(this).attr("disabled", "disabled");
}
else if($(this).attr("type") == 'hidden')
{
// $(this).removeAttr("disabled");
}
else
{
$(this).attr("disabled", "disabled");
}
}
});
}
if(fields.hasOwnProperty("unEditableButtons")) {
_scope.find('a').each(function() {
if ($(this).hasClass("easyui-linkbutton"))
{
if (fields["unEditableButtons"] == "all") {
$(this).hide();
} else if (fields["unEditableButtons"][0] == "all") {
$(this).hide();
} else if (fields["unEditableButtons"].contains($(this).attr("id"))) {
$(this).hide();
}
}
});
}
}
/**
*
* Description:[设置页面可编辑属性]
*
* @param {} _scope
* @param {} fields
*/
function unDisabledAttributes(_scope, fields) {
if(fields.hasOwnProperty("editableFields")) {
_scope.find('input,select,textarea').each(function() {
var isDisabled = true;
if (fields["editableFields"] == "all") {
$(this).attr("disabled", false);
} else if (fields["editableFields"][0] == "all") {
$(this).attr("disabled", false);
} else if (fields["editableFields"].contains($(this).attr("name"))
|| fields["editableFields"].contains($(this).attr("nativeChangeField"))) {
$(this).attr("disabled", false);
} else {
isDisabled = false;
}
if(isDisabled) {
var bgFlg = true;
if($(this).attr("tagName").toUpperCase() == 'TEXTAREA') {
$(this).attr('readonly',false);
$(this).next(".commentClass").attr("disabled", false);
isDisabled = false;
}
else if ($(this).attr("editType") == "suggestBox") {
//$(this).next(".suggestbox-trigger-img").css("display", 'none');
$(this).next(".suggestbox-trigger-img").attr("disabled", false);
}
else if(isDisabled && $(this).attr("editType") == "container") {
$(this).next().attr("disabled", false);
}
else if (isDisabled && $(this).hasClass("hasDatepicker")) {
$(this).next(".time_img").unbind("click");
$(this).next(".time_img").attr("disabled",false);
}
else if($(this).attr("editType") == "simpleCheckbox") {
bgFlg = false;
}
if(isDisabled) {
$(this).attr("disabled", false);
}
if(bgFlg) {
$(this).css('background','');
}
}
});
}
if(fields.hasOwnProperty("editableButtons")) {
_scope.find('button').each(function() {
if (fields["editableButtons"] == "all") {
$(this).attr("disabled", false);
} else if (fields["editableButtons"][0] == "all") {
$(this).attr("disabled", false);
} else if (fields["editableButtons"].contains($(this).attr("name"))) {
$(this).attr("disabled", false);
}
});
_scope.find('input[type=button]').each(function() {
if (fields["editableButtons"] == "all") {
$(this).attr("disabled", false);
} else if (fields["editableButtons"][0] == "all") {
$(this).attr("disabled", false);
} else if (fields["editableButtons"].contains($(this).attr("name"))) {
$(this).attr("disabled", false);
}
});
}
}
/**
* 添加备注浮层
* @param {} _field 绑定的textarea
*/
function addCommentDetail(_field) {
$.Window.showWindow('addCommentDetailForCommentFormate', {
intervalLoad : true,
width : '310px',
height : '40%',
onRender : function(config, winId) {// set comment window's
// z-index for over other
// window
$("#" + winId).find("#__jWin_mask-msg").css("z-index",90000);
},
url : 'addCommentDetailForCommentFormate.action',
params : {
field : _field
},
waitText : 'load...'
}, function(data) {
});
}
function openCommonQueryPage(pageName, action, _params, width, height,fieldUseScope) {
$.Window.showWindow(pageName, {
intervalLoad : true,
width : width,
height : height,
onRender : function(config, winId) {// set comment window's
// z-index for over other
// window
$("#" + winId).find("#__jWin_mask-msg").css("z-index",90000);
},
url : action,
params : _params,
waitText : 'load...'
}, function(data) {
_fieldUseScope = fieldUseScope;
});
}
/**
*
* Description:[前台js浮点数-乘法]
*
* @param {} arg1
* @param {} arg2
* @return {}
*/
function accMul(arg1,arg2){
var m=0,s1=arg1.toString(),s2=arg2.toString();
try{m+=s1.split(".")[1].length;}catch(e){}
try{m+=s2.split(".")[1].length;}catch(e){}
return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m);
}
/**
*
* Description:[前台js浮点数-除法]
*
* @param {} arg1
* @param {} arg2
* @return {}
*/
function accDiv(arg1,arg2){
var t1=0,t2=0,r1,r2;
try{t1=arg1.toString().split(".")[1].length}catch(e){}
try{t2=arg2.toString().split(".")[1].length}catch(e){}
with(Math){
r1=Number(arg1.toString().replace(".",""))
r2=Number(arg2.toString().replace(".",""))
return (r1/r2)*pow(10,t2-t1);
}
}
/**
*
* Description:[前台js浮点数-加法和减法]
*
* @param {} arg1
* @param {} arg2
* @return {}
*/
function accAdd(arg1, arg2) {
var r1, r2, m;
try {r1 = arg1.toString().split(".")[1].length} catch (e) {r1 = 0}
try {r2 = arg2.toString().split(".")[1].length} catch (e) {r2 = 0}
m = Math.pow(10, Math.max(r1, r2))
return (arg1 * m + arg2 * m) / m;
}
/**
*
* Description:[suggestBox附加信息填充]
*
*
* @param {} _data 选择SuggestBox行数据
* @param {} _scope 设值范围
* @param {} _mappingExtend 映射关系
*/
function fillSuggestBoxExtraData(_data,_scope,_mappingExtend) {
var _params = _data["params"];
if(typeof(_params) != 'undefined' && _params != null) {
for(var _filed in _mappingExtend) {
// 首先先清空之前的数据
$(_scope).find("input[name='"+_filed+"'],select[name='"+_filed+"'],textarea[name='"+_filed+"']").each(
function() {
if ($(this).attr("editType") == "suggestBox") {
$(this).attr("hiddenValue", "");
$(this).val("");
} else if ($(this).attr("editType") == "dateTime") {
fillFieldWithDateTime(this, "");
} else if ($(this).attr("editType") == "date") {
fillFieldWithDate(this, "");
} else if ($(this).attr("editType") == "simpleCheckbox") {
$(this).attr("checked", false);
} else {
$(this).val("");
}
$(this).change();
}
);
$(_scope).find("input[name='"+_filed+"'],select[name='"+_filed+"'],textarea[name='"+_filed+"']").each(
function() {
var __value__ = _params[_mappingExtend[_filed]];
if(typeof(__value__) == 'undefined' || __value__ == null || __value__== 'null') {
__value__ = "";
}
if($(this).attr("tagName").toUpperCase() == "SELECT" && !(typeof($(this).attr("defaultValue")) =="undefined" || $(this).attr("defaultValue") == null) && __value__ == "") {
__value__ = $(this).attr("defaultValue");
}
if ($(this).attr("editType") == "suggestBox") {
$(this).attr("hiddenValue", __value__);
$(this).val(_params[_mappingExtend[_filed + "_name"]]);
} else if ($(this).attr("editType") == "dateTime") {
fillFieldWithDateTime(this, __value__);
} else if ($(this).attr("editType") == "date") {
fillFieldWithDate(this, __value__);
} else if ($(this).attr("editType") == "simpleCheckbox") {
if (__value__ == 1 || __value__ == "1") {
$(this).attr("checked", true);
} else {
$(this).attr("checked", false);
}
} else {
$(this).val(__value__);
}
$(this).change();
}
);
}
}
}
/**
* 比较开始时间和结束时间的大小。
* 如果有一个为空,不比较,并返回true。
* @param _scope
* @param dateFrom
* @param dateTo
* @returns {Boolean}
*/
function compareDate(_scope,dateFrom,dateTo){
var fromV;
var toV;
var from = $(_scope).find("input[name="+dateFrom+"]");
var to = $(_scope).find("input[name="+dateTo+"]");
if (from.val() == null || from.val() == undefined || from.val() == null) {
return true;
}else{
fromV = from.val();
var hh = $(from).nextAll('.hh').val();
var mm = $(from).nextAll('.mm').val();
var ss = "00";
if (hh == null || hh == "") {
hh = "00";
}
if (mm == null || mm == "") {
mm = "00";
}
fromV = fromV + " "+hh+":"+mm+":"+ss;
}
if (to.val() == "" || to.val() == undefined || to.val() == null) {
return true;
}else{
toV = to.val();
var hh = $(to).nextAll('.hh').val();
var mm = $(to).nextAll('.mm').val();
var ss = "00";
if (hh == null || hh == "") {
hh = "00";
}
if (mm == null || mm == "") {
mm = "00";
}
toV = toV + " "+hh+":"+mm+":"+ss;
}
if(fromV > toV){
commonErrorPrompt(from.attr("promptName") + "不能大于" + to.attr("promptName"));
return false;
}
return true;
}
/**
* 比较开始时间和结束时间的大小。
* 如果有一个为空,不比较,并返回true。
* @param _scope
* @param dateFrom
* @param dateTo
* @returns {Boolean}
*/
function compareNowDate(_scope,dateFrom,dateTo){
var fromV;
var toV;
var from = $(_scope).find("input[name="+dateFrom+"]");
var to = $(_scope).find("input[name="+dateTo+"]");
if (from.val() == null || from.val() == undefined || from.val() == null) {
return true;
}else{
fromV = from.val();
var hh = $(from).nextAll('.hh').val();
var mm = $(from).nextAll('.mm').val();
var ss = "00";
if (hh == null || hh == "") {
hh = "00";
}
if (mm == null || mm == "") {
mm = "00";
}
fromV = fromV + " "+hh+":"+mm+":"+ss;
}
if (to.val() == "" || to.val() == undefined || to.val() == null) {
return true;
}else{
toV = to.val();
var hh = $(to).nextAll('.hh').val();
var mm = $(to).nextAll('.mm').val();
var ss = "00";
if (hh == null || hh == "") {
hh = "00";
}
if (mm == null || mm == "") {
mm = "00";
}
toV = toV + " "+hh+":"+mm+":"+ss;
}
if(fromV > toV){
commonErrorPrompt(to.attr("promptName") + "不能小于" + from.attr("promptName"));
return false;
}
return true;
}
/**
*
* @param _scope
* @param dateFrom
* @return
*/
function compareCurrentDate(_scope,dateFrom){
var fromV;
var from = $(_scope).find("input[name="+dateFrom+"]");
if (from.val() == null || from.val() == undefined) {
return true;
}else{
fromV = from.val();
var hh = $(from).nextAll('.hh').val();
var mm = $(from).nextAll('.mm').val();
var ss = "00";
if (hh == null || hh == "") {
hh = "00";
}
if (mm == null || mm == "") {
mm = "00";
}
fromV = fromV + " "+hh+":"+mm+":"+ss;
}
var current = new Date();
//过滤统一时间,分钟格式
var month = current.getMonth()+1;
var day = current.getDate();
if(month<10){
month = "0"+month;
}
if(day<10){
day="0"+day;
}
var l = current.getFullYear()+"-"+month+"-"+day+" "+current.getHours()+":"+current.getMinutes()+":"+current.getSeconds();
if(fromV= 10 ){
CurrentDate = CurrentDate + Month + "-";
}else{
CurrentDate = CurrentDate + "0" + Month + "-";
}
if (Day >= 10 ){
CurrentDate = CurrentDate + Day ;
}else{
CurrentDate = CurrentDate + "0" + Day ;
}
return CurrentDate;
}
/**
* 自动click收放内容
*/
function autoTRClick(array){
for (i = 0; i < array.length; i++)
{
var rid = array[i];
$("#"+rid).click();
}
}
/**
* tr信息收放
* @param rid
* @return
*/
function toggerTR(obj){
var rid = $(obj).attr("id");
$("tr[name="+rid+"]").toggle();
}