common_util.js 63.6 KB
Newer Older
罗绍泽 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302
var upload_page1 = gaowj.WEB_APP_NAME+"/system/pages/frameEasyui/upload.jsp";
var up_maxsize = "10M";
var up_image_type = "gif,jpg,jpeg,bmp,png,tif,tiff";
var up_doc_type = "txt,doc,docx,xls,xlsx,ppt,pptx,pdf,cab";
var up_imagedoc_type = up_image_type+","+up_doc_type;
var up_act1 = "reportact_upload";
// 判断字符串是否只含中文
function isAllChinese(str) {
	return new RegExp(/^[\u4e00-\u9fa5]+$/).test(str);
}

// 空值处理
function nvl(info, showValue) {
	if (info == null) {// 若值为空则显示""
		if (showValue == null) {
			return "";
		} else {
			return showValue;
		}
	} else {
		return info;
	}
}
// 截取字符串
function CutString(str, length) {
	if (length == null) {
		length = 30;
	}
	if (str == null) {
		return "";
	} else if (str.length > length) {
		return str.substring(0, length) + "...";
	} else {
		return str;
	}
}
//去除HTML标签
function removeHtml(str){
	str = str || "";//防止空指针
	str = str.replace(/<(?!\/?p\b)[^>]+>|(<p)\b[^>]*(>)/ig, "$1$2");
	str = str.replace(/\s+/g,"");
	str = str.replace(new RegExp("&nbsp;","gm"),"");
	return str;
}
// 日期转换 如2011年06月22日 17:18
function formatDtoStr(currentDate) {
	currentDate = new Date(currentDate);
	var currentYear = (currentDate.getYear() < 1900) ? (1900 + currentDate
			.getYear()) : currentDate.getYear();
	var currentDateStr = currentYear + '年'
			+ pasTwo((currentDate.getMonth() + 1)) + '月'
			+ pasTwo(currentDate.getDate()) + "日 "
			+ pasTwo(currentDate.getHours()) + ":"
			+ pasTwo(currentDate.getMinutes());
	return currentDateStr;
}
// 日期转换 如2011-06-22 17:18
function formatDtoStr1(currentDate) {
	currentDate = new Date(currentDate);
	var currentYear = (currentDate.getYear() < 1900) ? (1900 + currentDate
			.getYear()) : currentDate.getYear();
	var currentDateStr = currentYear + '-'
			+ pasTwo((currentDate.getMonth() + 1)) + '-'
			+ pasTwo(currentDate.getDate()) + " "
			+ pasTwo(currentDate.getHours()) + ":"
			+ pasTwo(currentDate.getMinutes());
	return currentDateStr;
}
// 日期转换 如2011-06-22 17:18:58
function formatDtoStrSec(currentDate) {
	currentDate = new Date(currentDate);
	var currentYear = (currentDate.getYear() < 1900) ? (1900 + currentDate
			.getYear()) : currentDate.getYear();
	var currentDateStr = currentYear + '-'
			+ pasTwo((currentDate.getMonth() + 1)) + '-'
			+ pasTwo(currentDate.getDate()) + " "
			+ pasTwo(currentDate.getHours()) + ":"
			+ pasTwo(currentDate.getMinutes())  + ":"
			+ pasTwo(currentDate.getSeconds());
	return currentDateStr;
}
// 日期转换 如2011-06-22
function formatDtoStrDay(currentDate) {
	currentDate = new Date(currentDate);
	var currentYear = (currentDate.getYear() < 1900) ? (1900 + currentDate
			.getYear()) : currentDate.getYear();
	var currentDateStr = currentYear + '-'
			+ pasTwo((currentDate.getMonth() + 1)) + '-'
			+ pasTwo(currentDate.getDate());
	return currentDateStr;
}
//日期转换 如22:22:22
function formatDtoStrTime(currentDate){
	currentDate = new Date(currentDate);
	var currentDateStr = pasTwo(currentDate.getHours()) + ":" +
	pasTwo(currentDate.getMinutes()) + ":" +
	pasTwo(currentDate.getSeconds());
	return currentDateStr;
}
//日期转换 如22:22
function formatDtoStrTime_by_hhmi(currentDate){
	currentDate = new Date(currentDate);
	var currentDateStr = pasTwo(currentDate.getHours()) + ":" +
	pasTwo(currentDate.getMinutes()) ;
	return currentDateStr;
}
function pasTwo(str){
	if(parseFloat(str)<10){
		return "0"+str;
	}else{
		return str;
	}
}

function getNowDateCN(){
	var myDate = new Date();
	return myDate.toLocaleDateString();
}


function getNowDateEN(is_date) {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = "";
    if(is_date=='date'){
    	currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
    }else if(is_date=='datetime'){
    	currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
        + " " + date.getHours() + seperator2 + date.getMinutes()
        + seperator2 + date.getSeconds();
    }
    return currentdate;
} 

var BASE64={ 
    /** 
     * 此变量为编码的key,每个字符的下标相对应于它所代表的编码。 
     */ 
    enKey: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', 
    /** 
     * 此变量为解码的key,是一个数组,BASE64的字符的ASCII值做下标,所对应的就是该字符所代表的编码值。 
     */ 
    deKey: new Array( 
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 
        52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, 
        -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 
        15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, 
        -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 
        41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 
    ), 
    /** 
     * 编码 
     */ 
    encode: function(src){ 
    	// 为null时转为空串;
    	src = src || "";
        //用一个数组来存放编码后的字符,效率比用字符串相加高很多。 
        var str=new Array(); 
        var ch1, ch2, ch3; 
        var pos=0; 
       //每三个字符进行编码。 
        while(pos+3<=src.length){ 
            ch1=src.charCodeAt(pos++); 
            ch2=src.charCodeAt(pos++); 
            ch3=src.charCodeAt(pos++); 
            str.push(this.enKey.charAt(ch1>>2), this.enKey.charAt(((ch1<<4)+(ch2>>4))&0x3f));
            str.push(this.enKey.charAt(((ch2<<2)+(ch3>>6))&0x3f), this.enKey.charAt(ch3&0x3f));
         } 
        //给剩下的字符进行编码。 
        if(pos<src.length){ 
            ch1=src.charCodeAt(pos++); 
            str.push(this.enKey.charAt(ch1>>2)); 
            if(pos<src.length){ 
                ch2=src.charCodeAt(pos); 
                str.push(this.enKey.charAt(((ch1<<4)+(ch2>>4))&0x3f)); 
                str.push(this.enKey.charAt(ch2<<2&0x3f), '='); 
            }else{ 
                str.push(this.enKey.charAt(ch1<<4&0x3f), '=='); 
            } 
        } 
       //组合各编码后的字符,连成一个字符串。 
        return str.join(''); 
    }, 
    /** 
     * 解码。 
     */ 
    decode: function(src){ 
        //用一个数组来存放解码后的字符。 
        var str=new Array(); 
        var ch1, ch2, ch3, ch4; 
        var pos=0; 
       //过滤非法字符,并去掉'='。 
        src=src.replace(/[^A-Za-z0-9\+\/]/g, ''); 
        //decode the source string in partition of per four characters. 
        while(pos+4<=src.length){ 
            ch1=this.deKey[src.charCodeAt(pos++)]; 
            ch2=this.deKey[src.charCodeAt(pos++)]; 
            ch3=this.deKey[src.charCodeAt(pos++)]; 
            ch4=this.deKey[src.charCodeAt(pos++)]; 
            str.push(String.fromCharCode( 
                (ch1<<2&0xff)+(ch2>>4), (ch2<<4&0xff)+(ch3>>2), (ch3<<6&0xff)+ch4));
         } 
        //给剩下的字符进行解码。 
        if(pos+1<src.length){ 
            ch1=this.deKey[src.charCodeAt(pos++)]; 
            ch2=this.deKey[src.charCodeAt(pos++)]; 
            if(pos<src.length){ 
                ch3=this.deKey[src.charCodeAt(pos)]; 
                str.push(String.fromCharCode((ch1<<2&0xff)+(ch2>>4), (ch2<<4&0xff)+(ch3>>2)));
             }else{ 
                str.push(String.fromCharCode((ch1<<2&0xff)+(ch2>>4))); 
            } 
        } 
       //组合各解码后的字符,连成一个字符串。 
        return str.join(''); 
    } 
}; 


//校验开始
;
(function($){
    $.fn.checker = function(){
        return $.checker(this);
    };
    $.checker = function(Obj){
        var oc = {
            act:function(eventType){
                var _this = this;
                for(var i=0;i<arguments.length;i++){
                    this.bind(arguments[i],function(){_this.exc()});
                }
                return _this;
            },
            reg:function(){
                var queue = (this.data("checkqueue")&&this.data("checkqueue").constructor==Array) ?this.data("checkqueue"):[];
                for(var i=0;i<arguments.length;i++){
                    queue.push(arguments[i]);
                }
                this.data("checkqueue",queue);
                return this;
            },
            exc:function(){
                var queue = this.data("checkqueue");
                for(var i=0;queue&&i<queue.length;i++){
                    if(!(queue[i].call(this))){
                        return false;
                    }
                }
                return true;
            }
        };
        $.extend(Obj?Obj:$({}),oc);
        return Obj;
    };
    $.fn.checkwrite = function(msg){
        $.checkwrite(this,msg);
    };
    $.checkwrite = function(obj,msg){
        var jobj = $(obj),
            top = jobj.position().top, 
		    left = jobj.position().left,	 
	        width = jobj.outerWidth(),
	        height = jobj.outerHeight(),
	        newleft = left,
	        newtop = top+height;
	        //alert("top:"+top+"left:"+left+"width:"+width+"height:"+height+"newleft:"+newleft+"newtop:"+newtop);
	    if(msg){
	        if(jobj.next().is("p[name='msgbox']")){
	            jobj.next().html(msg);
	        }else{
	        	if($.browser.msie){
	        		jobj.after($("<p name='msgbox'/>")
	    	                .css("clear","both")
	    	                .css("position","absolute")
	    	                .css("width","auth")
	    	                .css("text-align","left")
	    	                .css("border","2px outset white")
	    	                .css("background-color","#FFFFCC")
	    	                .css("color","red")
	    	                .html(msg));
	        	}else{
	        		jobj.after($("<p name='msgbox'/>")
	    	                .css("clear","both")
	    	                .css("position","absolute")
	    	                .css("width","auth")
	    	                .css("text-align","left")
	    	                .css("border","2px outset white")
	    	                .css("background-color","#FFFFCC")
	    	                .css("color","red")
	    	                .css("top",newtop)
	    	                .css("left",newleft)
	    	                .html(msg));
	        	}
	        }
	    }else{
	        jobj.next("p[name='msgbox']").remove();
	    }
    };
    
  //文本框只能输入数字,并屏蔽输入法和粘贴  
    $.fn.numeral = function() {     
               $(this).css("ime-mode", "disabled");     
               this.bind("keypress",function(e) {     
               var code = (e.keyCode ? e.keyCode : e.which);  //兼容火狐 IE      
                   if(!$.browser.msie&&(e.keyCode==0x8))  //火狐下不能使用退格键     
                   {     
                        return ;     
                       }     
                       return code >= 48 && code<= 57;     
               });     
               this.bind("blur", function() {     
                   if (this.value.lastIndexOf(".") == (this.value.length - 1)) {     
                       this.value = this.value.substr(0, this.value.length - 1);     
                   } else if (isNaN(this.value)) {     
                       this.value = "";     
                   }     
               });     
               this.bind("paste", function() {     
                   var s = clipboardData.getData('text');     
                   if (!/\D/.test(s));     
                   value = s.replace(/^0*/, '');     
                   return false;     
               });     
               this.bind("dragenter", function() {     
                   return false;     
               });     
               this.bind("keyup", function() {     
               if (/(^0+)/.test(this.value)) {     
                   this.value = this.value.replace(/^0*/, '');     
                   }     
               });     
    };

    //tipWrap:  提示消息的容器
    //maxNumber:  最大输入字符
    $.fn.artTxtCount = function(tipWrap,tipWrap_warn,maxNumber){
        var disabledClass = 'disabled';
        
        //统计字数
        var count = function(){
          var btn = $(this).closest('form').find(':submit'),text_this = $(this),
          //是否禁用提交按钮
          disabled = {
             on: function(){
                 btn.removeAttr('disabled').removeClass(disabledClass);
             },
             off: function(){
                 btn.attr('disabled', 'disabled').addClass(disabledClass);
                 var textarea_val = text_this.val().replace(/[\r\n]/g, "");
             	 var curLength = textarea_val.length;
             	 if (curLength > maxNumber) {
             		text_this.val(textarea_val.substr(0, maxNumber));
             		if (tipWrap_warn.css("display") == "none") {
             			tipWrap_warn.fadeIn();
             			tipWrap_warn.fadeOut(4000);
             		}
             	}
             }
          };
          if (text_this.val().length == 0) disabled.off();
          if(text_this.val().length <= maxNumber){
             if (text_this.val().length > 0) disabled.on();
             tipWrap.html('<span>\u8FD8\u80FD\u8F93\u5165 <strong>' + (maxNumber - text_this.val().length) + '/'+maxNumber+'</strong> \u4E2A\u5B57</span>');
          }else{
             disabled.off();
          };
        };
        $(this).bind('keyup change', count);
        return this;
    };
    
 // json对象比较
	$.compareJsonObj = function(o1, o2) {
		if (typeof arguments[0] != typeof arguments[1])
			return false;
		if (arguments[0] instanceof Array) {
			if (arguments[0].length != arguments[1].length)
				return false;
			var allElementsEqual = true;
			for (var i = 0; i < arguments[0].length; ++i) {
				if (typeof arguments[0][i] != typeof arguments[1][i])
					return false;
				if (typeof arguments[0][i] == 'number'
						&& typeof arguments[1][i] == 'number')
					allElementsEqual = (arguments[0][i] == arguments[1][i]);
				else
					allElementsEqual = arguments.callee(arguments[0][i],
							arguments[1][i]); // 递归判断对象是否相等
			}
			return allElementsEqual;
		}
		if (arguments[0] instanceof Object && arguments[1] instanceof Object) {
			var result = true;
			var attributeLengthA = 0, attributeLengthB = 0;
			for (var o in arguments[0]) {
				// 判断两个对象的同名属性是否相同(数字或字符串)
				if (typeof arguments[0][o] == 'number'
						|| typeof arguments[0][o] == 'string')
					result = eval("arguments[0]['" + o + "'] == arguments[1]['"
							+ o + "']");
				else {
					// 如果对象的属性也是对象,则递归判断两个对象的同名属性
					// if (!arguments.callee(arguments[0][o], arguments[1][o]))
					if (!arguments.callee(eval("arguments[0]['" + o + "']"),
							eval("arguments[1]['" + o + "']"))) {
						result = false;
						return result;
					}
				}
				++attributeLengthA;
			}
			for (var o in arguments[1]) {
				++attributeLengthB;
			}
			// 如果两个对象的属性数目不等,则两个对象也不等
			if (attributeLengthA != attributeLengthB)
				result = false;
			return result;
		}
		return arguments[0] == arguments[1];
	}
})(jQuery);

//点击到区域事件方法
function shiftMoveEnd(obj){
    if (obj.createTextRange) {//IE浏览器
       var range = obj.createTextRange();
       range.move("textedit");
       range.collapse(true);
       range.select();
    } else {//非IE浏览器
       obj.setSelectionRange(obj.value.length, obj.value.length);
       obj.focus();
    }
}
//修改名称显示
function changeNameDisplay(str,length){
    var l = str.length;
    if(l<length){
        return str;
    }else{
        return str.substring(0,length)+"..."
    }
}
//区分浏览器来判断输入框的字符长度
function fixLength_publish(obj,objtext_length,objtext_warn){
var element = document.getElementById("mytext");
if("\v"=="v") {
obj.attachEvent("onpropertychange",webChange);
}else{
obj.addEventListener("input",webChange,false);
}
function webChange(){
	if(obj.value){
	 var textarea_val=obj.value.replace(/[\r\n]/g,"") ;
     var curLength=textarea_val.length; 
     if(curLength>120){
         objtext_length.css("color","#ff0000");
         var num = textarea_val.substr(0, 120);//截取120输入内容
			obj.value = num;
			if (objtext_warn.css("display") == "none") {
				$("span[name='publishNull']").hide();
				objtext_warn.fadeIn();
				objtext_warn.fadeOut(4000);
			}
     }
     else{
         objtext_length.css("color","#999");
         objtext_length.text(curLength);
     }
         return false;
	}
	}
}

//判断textarea长度
function changeLen(obj, objtext_length, objtext_warn,objtext_length_number) {
	var textarea_val = obj.value.replace(/[\r\n]/g, "");
	var curLength = textarea_val.length;
	if (curLength > objtext_length_number) {
		var num = textarea_val.substr(0, objtext_length_number);
		obj.value = num;
		objtext_length.text(""+objtext_length_number);
		if (objtext_warn.css("display") == "none") {
			objtext_warn.fadeIn();
			objtext_warn.fadeOut(4000);
		}
	return false;
	} else {
		objtext_length.text(curLength);
	}
}


// 日期转换
function formatDtoStr3(currentDate){
	currentDate=new Date(currentDate);
	var today = new Array("周日","周一","周二","周三","周四","周五","周六");
	var currentYear = ( currentDate.getYear() < 1900 ) ? ( 1900 + currentDate.getYear() ) : currentDate.getYear();
	var currentDateStr = currentYear + '年' + pasTwo((currentDate.getMonth() + 1)) + '月' + pasTwo(currentDate.getDate())+"日"+" "+today[currentDate.getDay()]+" "+pasTwo(currentDate.getHours())+":"+pasTwo(currentDate.getMinutes()); 
	return currentDateStr; 
}
//剩余时间
function lastTime(currentDate){
	var endDate = new Date(currentDate);
	var ss = 1000;
	var mi = ss*60;
	var hh = mi*60;
	var dd = hh*24;
	
	
	var now = new Date();
	if(endDate <= now){
		return "00小时00分钟";
	}
	if(endDate > now){
		var ms = endDate-now;
		var day = Math.floor(ms/dd);
		var hour = Math.floor((ms-day*dd)/hh);
		var minute = Math.ceil((ms-day*dd-hour*hh)/mi);
		
		if(hour < 10){
			hour = "0" + hour;
		}
		if(minute < 10){
			minute = "0" + minute;
		}
		if(day == 0){
			return hour + "小时" + minute + "分钟";
		}else {
			return day + "天" + hour + "小时" + minute + "分钟";
		}
	}
}

//将String转义
function displayHtml(str){   
	if(str != null){
    //将字符串转换成数组   
    var strArr = str.split('');   
   //HTML页面特殊字符显示,空格本质不是,但多个空格时浏览器默认只显示一个,所以替换   
    var htmlChar="&<>";   
    for(var i = 0; i< str.length;i++){   
       //查找是否含有特殊的HTML字符   
        if(htmlChar.indexOf(str.charAt(i)) !=-1){   
            //如果存在,则将它们转换成对应的HTML实体   
           switch (str.charAt(i)) {                           
                case '<':   
                    strArr.splice(i,1,'&#60;');   
                    break;   
              case '>':   
                    strArr.splice(i,1,'&#62;');   
                    break;   
               case '&':   
                    strArr.splice(i,1,'&#38;');   
           }   
        }   
   }   
    return strArr.join('');   
    }
}

//去掉html标签
function removeHtmlTab(tab) {
	if(tab==null){
		return "";
	}else{
		return tab.replace(/<[^<>]+?>/g,'');//删除所有HTML标签
	}
	
}
//普通字符转换成转意符
function html2Escape(sHtml) {
	return sHtml.replace(/[<>&"]/g,function(c){return {'<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;'}[c];});
}
// &nbsp;转成空格
function nbsp2Space(str) {
	var arrEntities = {'nbsp' : ' '};
	return str.replace(/&(nbsp);/ig, function(all, t){return arrEntities[t]})
}

//空格符转换成&nbsp;
function space2Nbsp(str) {
	return str.replace(/\s/ig, '&nbsp;');
}

//转意符换成普通字符
function escape2Html(str) {
	var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
	return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
}

//回车转为br标签
function return2Br(str) {
	return str.replace(/\r?\n/g,"<br/>");
}

//去除开头结尾换行,并将连续3次以上换行转换成2次换行
function trimBr(str) {
	str=str.replace(/((\s|&nbsp;)*\r?\n){3,}/g,"\r\n\r\n");//限制最多2次换行
	str=str.replace(/^((\s|&nbsp;)*\r?\n)+/g,'');//清除开头换行
	str=str.replace(/((\s|&nbsp;)*\r?\n)+$/g,'');//清除结尾换行
	return str;
}

// 将多个连续空格合并成一个空格
function mergeSpace(str) {
	str=str.replace(/(\s|&nbsp;)+/g,' ');
	return str;
}

// 截取长度为length个字的字符串,多于length的字会截成length-1个字和"...", 
//没有中文和全角符号会截取length*1.6(取整)个字符
var subStringForDepart = function(str, length) {
	str = str || "";
	var enReg = /^[a-z0-9\`\-\=\[\]\;\s\'\,\.\/\~\\!\@\#\$\%\^\&\*\(\)\_\+\{\}\|\:\"\<\>\?]*$/;
	if(enReg.test(str)){
		length=Math.floor(length*1.6);
	}
	var newStr = str.substring(0, length);
	if (str.length > length) {
		newStr = str.substring(0,length-1);
		newStr += "......";
	}
	return newStr;
};

//按字节截取字符串,结尾添加"..."
function subStringByByte(str, len, ifAddEtc) {
    if (!str || !len) {
        return '';
    }
    str = str || "";
    // 预期计数:中文2字节,英文1字节
    var a = 0;
    // 循环计数
    var i = 0;
    // 临时字串
    var temp = '';
    for (i = 0; i < str.length; i++) {
    	if (str.charCodeAt(i) > 255 ) {
            // 按照预期计数增加2
        	if(str.charCodeAt(i) != 65279)
            a += 2;
        } else {
        	if(str.charCodeAt(i) != 65279)
            a++;
        }
        // 如果增加计数后长度大于限定长度,就直接返回临时字符串
        if (a > len) {
        	if(ifAddEtc==true || ifAddEtc=="true")
        		return temp+"...";
        	else
        		return temp;
        }
        // 将当前内容加到临时字符串
        temp += str.charAt(i);
    }
    return str;
}

// 将用户的标题转换成可html显示的标题
function transformTitle(inStr){
	var str = inStr || "";
	// 普通字符转换成转义符
	str = html2Escape(str);
	// 合并多个空格
	str = mergeSpace(str);
	return str;
}

// 将用户输入的文本转换成可显示的文本
function transformText(inStr) {
	var str = inStr || "";
	// 普通字符转换成转义符
	str = html2Escape(str);
	//去除开头结尾换行,并将连续3次以上换行转换成2次换行
	str = trimBr(str);
	// 回车换行转换成<br />标签
	str = return2Br(str);
	// 空格符转换成&nbsp;
	str = space2Nbsp(str);
	return str;
} 
// 将毫秒数转化为日期
function formatDataStr(currentDate) {
	currentDate = new Date(currentDate);
	var currentYear = (currentDate.getYear() < 1900) ? (1900 + currentDate
			.getYear()) : currentDate.getYear();
	var currentDateStr = currentYear + '-'
			+ pasTwo((currentDate.getMonth() + 1)) + '-'
			+ pasTwo(currentDate.getDate()) + " "
			+ pasTwo(currentDate.getHours()) + ":"
			+ pasTwo(currentDate.getMinutes());
	return currentDateStr;
}

//截取参数方法,hash:截取的字符串,name:截取的参数名,nvl:该参数不存在时的返回值
function getParameter(hash,name,nvl) {
	if(!nvl){
		nvl = "";
	}
	var svalue = hash.match(new RegExp("[\?\&]?" + name + "=([^\&]*)(\&?)", "i"));
	if(svalue == null){
		return nvl;
	}else{
		return svalue ? svalue[1] : svalue;
	}
}


//获取焦点
function setFocus(obj) {
	if (obj.setSelectionRange) {
		obj.setSelectionRange(0, 0);
		obj.focus();
	} else {
		if (obj.createTextRange) {
			var range = obj.createTextRange();
			range.collapse(true);
			range.moveEnd("character", 0);
			range.moveStart("character", 0);
			range.select();
		}
		try {
			obj.focus();
		} catch (e) {
		}
	}
} 

//手机号码验证,不符合规则返回false,否则返回true
function validationOfMobilePhoneNum(mobilePhoneNum) {
	var patrn = /^\d{11}$/;
	if(mobilePhoneNum != undefined && mobilePhoneNum!="" && !patrn.exec(mobilePhoneNum))
		return false;
	else
		return true;
}

/*******************
 * 搜索框叉叉整合
 */
function clean_search_value(){
	var searchinputbox =$("div[searchbox='search_box']").find("input[searchinput='searchinput']");
	if(searchinputbox!=null){
		searchinputbox.val("");
		searchinputbox.focus();
	}
}
//页面置顶
function goTop(){
	var nScrollTop = $(window).scrollTop();
	if (nScrollTop > 0) {
	$(window).scrollTop(0,0);
	}
}



;(function($){
	$.fn.extend({
		"appendWithUrl" : function(options){
			var opt = {
					url : ""
			};
			opt = $.extend(opt, options);
			this.each(function(){
				$(this).append(function(){
					var d = "";
					 $.ajax({
					 url:opt.url,
					 async:false,
					 success:function(data, status){
					    d = data;
					 }
					 });
					 return d;
				}); 
			});
		}
	});
}(jQuery));

//加载loading图片,页面全部加载完后再显示页面内容
function loadingPicFun(){
	//隐藏显示内容
	$("#container").hide();
	//loading图标
	var insert_html = "<div id = \"loading_div\" style = \"width: 100%; margin-top: 240px;\">"+
			"<img id='loadingImg' src='"+path+"/portal/images/loading_img.gif' style=\"height:150px;width:150px;\"/>"+
		"</div>";
	//<body>标签后加代码显示Loading图标
	$("body").prepend(insert_html);
	
	loadingProccess();
}
//页面全部加载完后显示页面,loading隐藏
function loadingProccess(){
	sh = setInterval('proccess();',100); 
}
//loading状态函数
function proccess(){
	//页面元素全部加载完成
    if(document.readyState == "complete"){
    	//loading图标隐藏
    	$("#loading_div").hide();
    	//页面内容显示
    	$("#container").show();
   		clearInterval(sh); 
    }
}

/*
 * 2014-11-25
 * 高伟杰
 * 文本框、表单校验
 *
*/
;(function($){
	var validator = {
		is_legal : true,
		"required" : function(value,$this){
			if($.trim(value).length!=0){
				$this.checkwrite(null);
				return true;
			} else {
				$this.checkwrite("不能为空!");
				setFocus($this);
				return false;
			}
		},
		"maxlength" : function(value,$this){
			var v_maxlength = $this.attr("maxlengthvalue");
			if(value.length<=v_maxlength){
				$this.checkwrite(null);
				return true;
			} else {
				$this.checkwrite("超出最大值("+v_maxlength+")!");
				setFocus($this);
				return false;
			}
		},
		"minlength" : function(value,$this){
			var v_minlength = $this.attr("minlengthvalue");
			if(value.length>=v_minlength){
				$this.checkwrite(null);
				return true;
			} else {
				$this.checkwrite("未达最小值("+v_minlength+")!");
				setFocus($this);
				return false;
			}
		},
		"isdate" : function(strDate,$this){
			if(strDate==""||strDate==null){
				$this.checkwrite(null);
				return true;
			}else{
				if(CheckDate(strDate)){
					$this.checkwrite(null);
					return true;
				}else{
					$this.checkwrite("输入正确的日期(yyyy-mm-dd)!");
					setFocus($this);
					return false;
				}
			}
			return CheckDate(strDate);
		},
		"isnumber" : function(value,$this){
			var reCheck = /^[1-9]+.?[0-9]*$/ ;   //判断字符串是否为数字     //判断正整数 /^[1-9]+[0-9]*]*$/  
		    if (!reCheck.test(value)){
		    	$this.checkwrite("输入数字!");
		    	setFocus($this);
		        return false;
		    }else{
		    	$this.checkwrite(null);
		    	return true;
		    }
		},
		"validate_field" : function($this, rules){
			var value = "";
			if($this.is("input")){
				//<inupt type="radio">
				if($this.is(":radio")){
					var field_id = $this.attr("name");
					value = $("[name="+field_id+"]:checked").val();
				}
				//<inupt type="checkbox">
				else if($this.is(":checkbox")){
					//var field_id = $this.attr("name");
					value = $this.is(":checked")?"1":"0";
				}
				//<inupt type="text" t="date">
				else if($this.is("[t='date']")){
					value = $this.val();
				} 
				//<inupt type="text">
				else if ($this.is(":text")){
					value = $this.val();
				}
			}
			else if($this.is("select")){
				value = $this.find("option:selected").val();
			}
			else if($this.is("textarea")){
				value = ($this.val());
			}
			if(rules.validate == 'undefined')return true;
			for(var o=0;o<rules.validate.split(',').length;o++){
				if(!validator[rules.validate.split(',')[o]](value,$this)){
					this.is_legal = false;
					return false;
				}else{
					this.is_legal = true;
				}
			}
			return this.is_legal;
		}
	};
	$.fn.extend({
		"loadMy97DateTime" : function(fitValue){
				if($(this).is("input")){
					//<inupt type="text" t="date" class="Wdate">
					if($(this).is("[t='date']")){
						$(this).attr("onClick",function(){
							$(this).click(function() {
				        		WdatePicker({
				        			dateFmt : 'yyyy-MM-dd HH:mm:ss',
				        			isShowWeek:true
				        		});
				        	});
			        	});
					$(this).attr("class","Wdate");
					if(fitValue)$(this).val(formatDtoStrSec(new Date()));
					}
				}
		},
		"loadMy97Date" : function(fitValue){
			if($(this).is("input")){
				//<inupt type="text" t="date" class="Wdate">
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
						$(this).click(function() {
			        		WdatePicker({
			        			dateFmt : 'yyyy-MM-dd',
			        			isShowWeek:true
			        		});
			        	});
		        	});
				$(this).attr("class","Wdate");
				if(fitValue)$(this).val(formatDtoStrDay(new Date()));
				}
			}
	    },
	    "loadJqueryDateMinMax" : function(fitValue,isMin,isMax){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $("#"+isMin+", #"+isMax+"").datepicker({
								changeMonth : true,
								changeYear : true,
								onSelect : function(selectedDate) {
									var option = this.id == isMin ? "minDate" : "maxDate", 
											instance = $(this).data("datepicker"), 
											date = $.datepicker.parseDate(
											instance.settings.dateFormat
													|| $.datepicker._defaults.dateFormat, selectedDate,
											instance.settings);
									dates.not(this).datepicker("option", option, date);
								}
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrDay(new Date()));
				}
			}
	    },
	    "loadJqueryDateTimeMinMax" : function(fitValue,isMin,isMax){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $("#"+isMin+", #"+isMax+"").datetimepicker({
								changeMonth : true,
								changeYear : true,
								controlType: 'select',
								timeFormat: 'HH:mm:ss',
								onSelect : function(selectedDate) {
									var option = this.id == isMin ? "minDate" : "maxDate", 
											instance = $(this).data("datepicker"), 
											date = $.datepicker.parseDate(
											instance.settings.dateFormat
													|| $.datepicker._defaults.dateFormat, selectedDate,
											instance.settings);
									dates.not(this).datepicker("option", option, date);
								}
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrSec(new Date()));
				}
			}
	    },
	    "loadJqueryDateMinMaxLimit" : function(fitValue,isMin,isMax,WeekStart,WeekEnd){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $("#"+isMin+", #"+isMax+"").datepicker({
								changeMonth : true,
								changeYear : true,
								onSelect : function(selectedDate) {
									var option = this.id == isMin ? "minDate" : "maxDate", 
											instance = $(this).data("datepicker"), 
											date = $.datepicker.parseDate(
											instance.settings.dateFormat
													|| $.datepicker._defaults.dateFormat, selectedDate,
											instance.settings);
									dates.not(this).datepicker("option", option, date);
								},
								beforeShowDay:function(e){var t=e.getDay();return[t>WeekStart&&t<WeekEnd,""]}
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrDay(new Date()));
				}
			}
	    },
	    "loadJqueryDateTimeMinMaxLimit" : function(fitValue,isMin,isMax,WeekStart,WeekEnd){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $("#"+isMin+", #"+isMax+"").datetimepicker({
								changeMonth : true,
								changeYear : true,
								controlType: 'select',
								timeFormat: 'HH:mm:ss',
								onSelect : function(selectedDate) {
									var option = this.id == isMin ? "minDate" : "maxDate", 
											instance = $(this).data("datepicker"), 
											date = $.datepicker.parseDate(
											instance.settings.dateFormat
													|| $.datepicker._defaults.dateFormat, selectedDate,
											instance.settings);
									dates.not(this).datepicker("option", option, date);
								},
								beforeShowDay:function(e){var t=e.getDay();return[t>WeekStart&&t<WeekEnd,""]}
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrSec(new Date()));
				}
			}
	    },
	    "loadJqueryDate" : function(fitValue){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $(this).datepicker({
								changeMonth : true,
								changeYear : true
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrDay(new Date()));
				}
			}
	    },
	    "loadJqueryDateTime" : function(fitValue){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $(this).datetimepicker({
								changeMonth : true,
								changeYear : true,
								controlType: 'select',
								timeFormat: 'HH:mm:ss'
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrSec(new Date()));
				}
			}
	    },
	    "loadJqueryDateLimit" : function(fitValue,WeekStart,WeekEnd){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $(this).datepicker({
								changeMonth : true,
								changeYear : true,
								beforeShowDay:function(e){var t=e.getDay();return[t>WeekStart&&t<WeekEnd,""]}
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrDay(new Date()));
				}
			}
	    },
	    "loadJqueryDateTimeLimit" : function(fitValue,WeekStart,WeekEnd){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $(this).datetimepicker({
								changeMonth : true,
								changeYear : true,
								controlType: 'select',
								timeFormat: 'HH:mm:ss',
								beforeShowDay:function(e){var t=e.getDay();return[t>WeekStart&&t<WeekEnd,""]}
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrSec(new Date()));
				}
			}
	    },
	    "readonly" : function(){
			if($(this).is("input")){
				//<inupt type="text" readonly ="readonly">
				$(this).attr("readonly","'readonly'");
				$(this).css("background-color","#cccccc");
			}
	    },
		"validateBlur" : function(){
			this.each(function(options){
				var $this = $(this);
				var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
				$(this).blur(function(){
					setTimeout(function(){
					  return validator.validate_field($this,rules);
					}, 200);
				});
			});
		},
		"validateFormBlur" : function(){
			this.find("input, select, textarea").each(function(){
				var $this = $(this);
				var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
				if($this.is(":checkbox[single='true']")){
					var field_name = $this.attr("name");
					$(":checkbox[name="+field_name+"][single='true']").each(function(){ 
						$(this).click(function(){ 
						   $("[name="+field_name+"][single='true']").attr("checked",false);
						   $(this).attr('checked',true); 
						}); 
					});
				}else{
					$this.attr("onBlur",function(){
						$(this).blur(function(){
							setTimeout(function(){
								validator.validate_field($this,rules);
							}, 200);
						});
					});
				}
			});
		},
		"validateSubmit" : function(){
			var check=true;
			this.find("input, select, textarea").each(function(){
				//input 标签
				if($(this).is("input")){
					//<inupt type="radio">
					if($(this).is(":radio")){
						var $this = $(this);
						var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
						check = validator.validate_field($this,rules);
						if(!check) return false;
					}
					//<inupt type="checkbox">
					else if($(this).is(":checkbox")){
						var $this = $(this);
						var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
						check = validator.validate_field($this,rules);
						if(!check) return false;
					}
					//<inupt type="text" t="date">
					else if($(this).is("[t='date']")){
						var $this = $(this);
						var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
						check = validator.validate_field($this,rules);
						if(!check) return false;
					} 
					//<inupt type="text">
					else if ($(this).is(":text")){
						var $this = $(this);
						var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
						check = validator.validate_field($this,rules);
						if(!check) return false;
					}
				}
				else if($(this).is("select")){
					var $this = $(this);
					var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
					check = validator.validate_field($this,rules);
					if(!check) return false;
				}
				else if($(this).is("textarea")){
					var $this = $(this);
					var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
					check = validator.validate_field($this,rules);
					if(!check) return false;
				}
			});
			return check;
		}
	});
}(jQuery));


function CheckDate(strDate){
	//结束时间不输入时,check通过
	if (strDate == null || strDate==""){
		return true;
	}
    var r=/\d{4}(?:-\d{1,2}){0,2}/;
    //正则表达式,判断是否为yyyy-mm-dd,yyyy-mm,yyyy格式
    if(strDate.match(r)==strDate){

    }else{
	 return false;
    }
    var ss=strDate.split("-");
    if (ss.length==3){
    	
    }else{
    	return false;
    }
    
    var year=ss[0];
    var month=ss[1];
    var date=ss[2];
    if(!checkYear(year)){return false;}
    if(!checkMonth(month)){return false;}
    if(!checkDate(year,month,date)){return false;}
    return true;
}
function checkYear(year){
    if(isNaN(parseInt(year)))
    {
         return false;
    }
    return true;
}
function checkMonth(month){
	if(isNaN(parseInt(month,10))){
		 return false;
	} else if(parseInt(month,10)<1 || parseInt(month,10) >12)
	{ 
		return false;
	}  else return true;
}
function checkDate(year,month,date){
	var daysOfMonth=CalDays(parseInt(year),parseInt(month));
	if(isNaN(parseInt(date,10)))
	{
		 return false;
	}  else if(parseInt(date,10)<1||parseInt(date,10)>daysOfMonth){
		return false;
	}
	    else return true;
}
function CalDays(year,month){
	var date= new Date(year,month,0);
	return date.getDate();
}
function isLeapYear(year){
		if((year %4==0 && year %100!=0) || (year %400==0)) return true;
		else return false;
}


//
function strToDateObj(str){
	var regEx = new RegExp("\\-","gi");
	dependedVal = str.replace(regEx,"/");
	var millionseconds = Date.parse(dependedVal);
	millionseconds = "DATE_"+millionseconds;
	if(millionseconds == "DATE_NaN")millionseconds="";
	return millionseconds;
}

;(function($){
	$.fn.extend({
		getFormVal : function(){
			var data = {};
			this.find("input, select, textarea").each(function(){
				//input 标签
				if($(this).is("input")){
					//<inupt type="radio">
					if($(this).is(":radio")){
						var field_id = $(this).attr("name");
						data[field_id] = $("[name="+field_id+"]:checked").val();
					}
					//<inupt type="checkbox">
					else if($(this).is(":checkbox")){
						var field_id = $(this).attr("name");
						var str="";
陈玉兰 committed
1303
						$("[name='"+field_id+"']:checked").each(function(){ 
罗绍泽 committed
1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286
					        if($(this).attr("checked")){
					           str += $(this).val()+",";
					        }
					     });
					     if(str.length>1){
					    	 str = str.substring(0, str.length - 1);
					     }
					     data[field_id] = str;
					}
					//<inupt type="text" t="date">
					else if($(this).is("[t='date']")){
						var field_id = $(this).attr("name");
						data[field_id] = strToDateObj($(this).val());
					} 
					//<inupt type="text">
					else if ($(this).is(":text")){
						var field_id = $(this).attr("name");
						data[field_id] = $(this).val();
					}
					//<inupt type="hidden">
					else if ($(this).is(":hidden") || $(this).is(":password")){
						var field_id = $(this).attr("name");
						data[field_id] = $(this).val();
					}
				}
				else if($(this).is("select")){
					var field_id = $(this).attr("name");
					data[field_id] = $(this).find("option:selected").val();
				}
				else if($(this).is("textarea")){
					var field_id = $(this).attr("name");
					data[field_id] = ($(this).val());
				}
			});
			return data;
		}
	});
}(jQuery));

function get_FIELD(data){
	if(data == null){
		return;
	}
	var ret_data = {};
    $.each(data,function(i,n){
    	ret_data["FIELD_"+i]=n;
   });
   return ret_data;
}


/**
 * 文件上传
 * @returns {Boolean}
 */
//上传页面打开1
function openUpload_page1(up_type,up_act,uuid){
	openUpload(upload_page1,up_type,up_act,uuid);
}
//上传页面打开2
function openUpload_page2(up_act,uuid){
	openUpload(upload_page1,up_imagedoc_type,up_act,uuid);
}
//上传页面打开3
function openUpload_page3(up_act,uuid,is_width,is_height,is_left,is_top){
	openUploadWidth(upload_page1,up_imagedoc_type,up_act,uuid,is_width,is_height,is_left,is_top);
}
//上传页面打开(图片)
function openUpload_image(uuid){
	openUpload(upload_page1,up_image_type,up_act1,uuid);
}
//上传页面打开(常用公文)
function openUpload_doc(uuid){
	openUpload(upload_page1,up_doc_type,up_act1,uuid);
}
//上传页面打开(常用公文加图片)
function openUpload_imagedoc(uuid){
	openUpload(upload_page1,up_imagedoc_type,up_act1,uuid);
}
//打开上传页面
function openUpload(url,up_type,up_act,uuid){
	$('#upload').dialog( {
		title : '文件上传',
		iconCls : $.getJwWindowPic(),
		width : ls_width * 0.45,
		height :ls_height * 0.35,
		closed : false,
		cache : false,
		maximizable:false,
		left:160,
		top:0,
		href : url,
		modal : true,
		buttons : [ {
			text : '上传',
			iconCls : 'icon-ok',
			handler : function() {
				return ajaxFileUpload(up_type,up_act,uuid);
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('upload');
			}
		} ],
		onLoad:function() {
			$('#notice').html("只上传"+up_type+"类型的图片,目前最大上传支持"+up_maxsize+"!");
		}
	});
}


//打开上传页面
function openUploadWidth(url,up_type,up_act,uuid,is_width,is_height,is_left,is_top){
	$('#upload').dialog( {
		title : '文件上传',
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:false,
		left:is_left,
		top:is_top,
		href : url,
		modal : true,
		buttons : [ {
			text : '上传',
			iconCls : 'icon-ok',
			handler : function() {
				return ajaxFileUpload(up_type,up_act,uuid);
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('upload');
			}
		} ],
		onLoad:function() {
			$('#notice').html("只上传"+up_type+"类型的图片,目前最大上传支持"+up_maxsize+"!");
		}
	});
}

//单个文件上传
function ajaxFileUpload(up_type,up_act,uuid)
{ 
    $("#loading")
    .ajaxStart(function(){
        $(this).show();
    })//开始上传文件时显示一个图片
    .ajaxComplete(function(){
        $(this).hide();
    });//文件上传完成将图片隐藏起来
    if($.trim($("#userFile").val()).length==0)
    	return false;
    
    if((up_type).indexOf($("#userFile").val().substring($("#userFile").val().lastIndexOf('.')+1))==-1){
    	$.messager.alert('提示',"只上传"+up_type+"类型的文件,目前最大上传支持"+up_maxsize+"!",'info');
    	return false;
    }
    $.ajaxFileUpload({
        url:up_act,//用于文件上传的服务器端请求地址
        secureuri:false,//一般设置为false
        fileElementId:'userFile',//文件上传空间的id属性  <input type="file" id="file" name="file" />
        dataType: 'json',//返回值类型 一般设置为json
        success: function (data, status){//服务器成功响应处理函数
	        if(data.message.file!='undefined'){
	        	if(data.message.file == '-1'){
	        		$.messager.alert('提示',"文件上传失败,大小超出"+up_maxsize+"!",'error');
	        		return false;
	        	}
	        	var view_name = data.message.file.split(",")[1];
	        	var store_name = data.message.file.split(",")[0];
	        	uploadCallback(view_name,store_name,uuid);
	        	$('#upload').dialog('close');
	        }            
        },error: function(data, status, e){//服务器响应失败处理函数
           alert(e);
        }
      });
    
    return false;

}
/****/

/**
 * 文件下载
 * @returns {Boolean}
 */
function fileDownload(uploadnew,uploadpath,uploadold,uuid){
   var form=$("<form>");//定义一个form表单
   form.attr("style","display:none");
   form.attr("target","");
   form.attr("method","post");
   form.attr("action","uploadFileAct_download");
   var input1=$("<input>");
   input1.attr("type","hidden");
   input1.attr("name","uploadnew");
   input1.attr("value",uploadnew);
   var input2=$("<input>");
   input2.attr("type","hidden");
   input2.attr("name","uploadpath");
   input2.attr("value",uploadpath);
   var input3=$("<input>");
   input3.attr("type","hidden");
   input3.attr("name","uploadold");
   input3.attr("value",uploadold);
   var input4=$("<input>");
   input4.attr("type","hidden");
   input4.attr("name","uuid");
   input4.attr("value",uuid);
   $("#upload").append(form);
   form.append(input1);
   form.append(input2);
   form.append(input3);
   form.append(input4);
   form.submit();//表单提交 
}
/****/

/**
 * 文件下载
 * @returns {Boolean}
 */
function fileDownloadURL(uploadnew,uploadpath,uploadold,uuid,downloadURL){
   if(downloadURL == '' || downloadURL == null || downloadURL == 'undefined'){
	   fileDownload(uploadnew,uploadpath,uploadold,uuid);
   }else{
	   var form=$("<form>");//定义一个form表单
	   form.attr("style","display:none");
	   form.attr("target","");
	   form.attr("method","post");
	   form.attr("action",downloadURL);
	   var input1=$("<input>");
	   input1.attr("type","hidden");
	   input1.attr("name","uploadnew");
	   input1.attr("value",uploadnew);
	   var input2=$("<input>");
	   input2.attr("type","hidden");
	   input2.attr("name","uploadpath");
	   input2.attr("value",uploadpath);
	   var input3=$("<input>");
	   input3.attr("type","hidden");
	   input3.attr("name","uploadold");
	   input3.attr("value",uploadold);
	   var input4=$("<input>");
	   input4.attr("type","hidden");
	   input4.attr("name","uuid");
	   input4.attr("value",uuid);
	   $("#upload").append(form);
	   form.append(input1);
	   form.append(input2);
	   form.append(input3);
	   form.append(input4);
	   form.submit();//表单提交 
   }
}
/****/

/**
 * ztree树初始化(新版)
 * @returns {Boolean}
 */
function setInitTree(is_title,is_name,idkey,pidkey){
	//定义ztree参数
	var setting = {
		view: {
			  dblClickExpand: false,
			  showLine: true,
			  selectedMulti: false
			},
		data: {
			  key: {
			    title:is_title,
			    name:is_name
			  },
			  simpleData: {
			    enable: true,
			    idKey: idkey,
			    pIdKey: pidkey,
			    rootPId: ""
			 }
			},
		edit: {
				drag:{
					autoExpandTrigger:true,
					isCopy:false,
					isMove:true
				},
				enable:true,
				showRemoveBtn: false,
				showRenameBtn: false
			},	
		callback: {
				beforeClick: beforeClick,
				onClick: onClick,
				beforeDrag: beforeDrag,
				beforeDrop: beforeDrop,
                onDrop: onDrop
			}
		};
	return setting;
}

/**
 * ztree树初始化
 * @returns {Boolean}
 */
function setInitTreeGroup(is_title,is_name,idkey,pidkey){
	//定义ztree参数
	var setting = {
		view: {
			  dblClickExpand: false,
			  showLine: true,
			  selectedMulti: false
			},
		data: {
			  key: {
			    title:is_title,
			    name:is_name
			  },
			  simpleData: {
			    enable: true,
			    idKey: idkey,
			    pIdKey: pidkey,
			    rootPId: ""
			  }
			},
        check: {
        	autoCheckTrigger: true,
        	enable: true,
        	chkboxType: { "Y": "s", "N": "s" }
        },
		callback: {
				beforeClick: beforeClick,
				onClick: onClick,
				onCheck:onCheck
			}
		};
	return setting;
}
function beforeClick(treeId, treeNode) {
	  return (treeNode.click != false);
}
function onClick(event, treeId, treeNode) { 
	   modifyNode(treeNode);
}
function onCheck(e,treeId,treeNode){
	   var zTree = $.fn.zTree.getZTreeObj(treeId);
	   var nodes = zTree.getCheckedNodes(true); 
	   v="";
       for(var i=0;i<nodes.length;i++){
       v+=nodes[i].UUID + ",";
       }
       getTreeNode(v);
    }
function beforeDrag(treeId, treeNodes){
	for(var i=0,l=treeNodes.length; i<l; i++){
		if (treeNodes[i].drag === false) {
			return false;
		}
	}
	return true;
}
function beforeDrop(treeId, treeNodes, targetNode, moveType) {
	return targetNode ? targetNode.drop !== false : true;
}
function onDrop(event, treeId, treeNodes, targetNode, moveType, isCopy){
	isCopy = false;
	var node = treeNodes[0];
	updateParentId(node, targetNode);
}
function loadTree(dataUrl,viewNode,expandKey,expandVal){
	//展现左边机构树
	$.sendPost (dataUrl, {}, function(data){
	var zTree = $.fn.zTree.init($("#"+viewNode), setting, data.rowSet);
	var treeNode = zTree.getNodeByParam(expandKey,expandVal, null);
	zTree.expandNode(treeNode,null,null,null,null);
	defautClick(zTree,treeNode);
	}, function(data){
	alert("失败");
	}, "json");
}
function loadTreeImage(dataUrl,viewNode,expandKey,expandVal){
	//展现左边机构树
	$.sendPost (dataUrl, {}, function(data){
	var zTree = $.fn.zTree.init($("#"+viewNode), setting, getDataAddNode(data.rowSet,"icon",gaowj.WEB_APP_NAME + "/images/main/bumen.gif"));
	var treeNode = zTree.getNodeByParam(expandKey,expandVal, null);
	zTree.expandNode(treeNode,null,null,null,null);
	defautClick(zTree,treeNode);
	}, function(data){
	alert("失败");
	}, "json");
}
function loadTreeGroup(dataUrl,viewNode,expandKey,expandVal){
	//展现左边机构树根据权限选择数据是否被勾选中
	$.sendPost (dataUrl, {}, function(data){
		var zTree = $.fn.zTree.init($("#"+viewNode), setting, getDataUnitOrUser(data.rowSet, gaowj.WEB_APP_NAME));
		var treeNode = zTree.getNodeByParam(expandKey,expandVal, null);
		var treeNode2 = zTree.getNodesByParam("AUTH",1,null);
		var treeNode3 = zTree.getNodesByParam("CHK",1,null);
//		zTree.expandNode(treeNode,null,null,null,null);
		zTree.expandAll(true);
		if(treeNode3==null||treeNode3==''){
			for(var i=0, l=treeNode2.length; i < l; i++){
				zTree.checkNode(treeNode2[i],true,true,false);
			}
		}else{
			for(var i=0, l=treeNode3.length; i < l; i++){
				zTree.checkNode(treeNode3[i],true,true,false);
				if(treeNode3[i].AUTH=='0' && treeNode3[i].CHK=='1'){
				  zTree.setChkDisabled(treeNode3[i], true);
				}
			}
		}
		
		defautClick(zTree,treeNode);
	}, function(data){
	alert("失败");
	}, "json");
}
function loadTreeQuery(dataUrl,viewNode,v_query,expandKey,expandVal){
	//展现左边机构树
	$.sendPost (dataUrl, v_query, function(data){
	var zTree = $.fn.zTree.init($("#"+viewNode), setting, data.rowSet);
	var treeNode = zTree.getNodeByParam(expandKey,expandVal, null);
	zTree.expandNode(treeNode,null,null,null,null);
	defautClick(zTree,treeNode);
	}, function(data){
	alert("失败");
	}, "json");
}
/****/

/**
 * 上浮横向菜单
 * @returns {Boolean}
 */
//菜单更多上浮横向菜单集(无需更改)
function createOptionMenuTooltip(menuWidth) {
	$('#list').datagrid('getPanel').find('.easyui-tooltip').each(
		function() {
			var index = parseInt($(this).attr('data-p1'));
			$(this).tooltip({
				content : $('<div></div>'),
				onUpdate : function(cc) {
					var row = $('#list').datagrid('getRows')[index];
					var content = getOptionMenu(row,index);
					var mCount = getOptionMenuCount();
					cc.css("border","0").panel({
						width : (menuWidth * mCount),
						content : content
					});
				},
				position : 'right',
				deltaX : -20,
				onShow : function() {
					var t = $(this);
					t.tooltip('tip').css( {
						backgroundColor : '#ffffff'
							}).unbind().bind('mouseenter', function() {
						t.tooltip('show');
					}).bind('mouseleave', function() {
						t.tooltip('hide');
					});
				}
			});
	    });
}
/****/
function createOptionMenuTooltipTree(menuWidth) {
	$('#list').treegrid('getPanel').find('.easyui-tooltip').each(
		function() {
			var index = $(this).attr('data-p1');
			$(this).tooltip({
				content : $('<div></div>'),
				onUpdate : function(cc) {
					$('#list').treegrid('select',index);
					var row = $('#list').treegrid('getSelected');
					$('#list').treegrid('unselectAll');
					var content = getOptionMenu(row,index);
					var mCount = getOptionMenuCount();
					cc.css("border","0").panel({
						width : (menuWidth * mCount),
						content : content
					});
				},
				position : 'right',
				deltaX : -20,
				onShow : function() {
					var t = $(this);
					t.tooltip('tip').css( {
						backgroundColor : '#ffffff'
							}).unbind().bind('mouseenter', function() {
						t.tooltip('show');
					}).bind('mouseleave', function() {
						t.tooltip('hide');
					});
				}
			});
	    });
}
/****/
/**
 * 弹出ifram页面
 * @returns {Boolean}
 */
function openViewIframRow(opendiv,editUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#'+opendiv).dialog( {
		title : is_title,
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		content : '<iframe scrolling="yes" frameborder="0"  src="'+ editUrl+ '" style="width:100%;height:98%;"></iframe><span id="return_text"></span>',
		queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [{
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox(opendiv);
			}
		} ],
		onClose: function () {
			closeCallback(is_row);
		}
	});
}
/**
 * 弹出ifram页面(授权)
 * @returns {Boolean}
 */
function openViewIframGroup(opendiv,editUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#'+opendiv).dialog( {
		title : is_title,
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		content : '<iframe scrolling="yes" frameborder="0"  src="'+ editUrl+ '" style="width:100%;height:98%;"></iframe><span style="display:none" id="return_text"></span><span style="display:none" id="return_text1"></span>',
		queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [ {
			text : '确定',
			iconCls : 'icon-ok',
			handler : function() {
				groupBox(is_row, opendiv,'list');
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox(opendiv);
			}
		} ]
	});
}
//弹出层权限选择按扭
function groupBox(is_row,Box_id,List_id) {
	if(Box_id==null||Box_id==''||Box_id==undefined)
		Box_id= opendiv;
	if(List_id==null||List_id==''||List_id==undefined)
		List_id='list';
		var v_result;
		v_result = addToGroup(is_row.G_ID,Box_id);
		if (v_result != null && v_result != undefined) {
			$.messager.alert('提示', v_result.VALUE);
		}
}
/****/

/**
 * 弹出页面
 * @returns {Boolean}
 */
function openViewRow(editUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#detail').dialog( {
		title : is_title,
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		href : editUrl,
		queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [{
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('detail');
			}
		} ]
	});
}
/**
 * 推送页面
 * @returns {Boolean}
 */
function openEditPush(editUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#detail').dialog( {
		title : is_title,
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		href : editUrl,
		//queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [ {
			text : '推送',
			iconCls : 'icon-ok',
			handler : function() {
				pushBox(is_row,'detail','list');
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('detail');
			}
		} ],
		onLoad:function pushUrlOnload(){
			pushUrlOnloadCallback(is_row);
		}
	});
}
/**
 * 推送页面
 * @returns {Boolean}
 */
function openEditPushAdd(editUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#detail').dialog( {
		title : is_title,
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		href : editUrl,
		//queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [ {
			text : '添加',
			iconCls : 'icon-add',
			handler : function() {
				AddBox(is_row,'detail','list');
			}
		}, {
			text : '推送',
			iconCls : 'icon-ok',
			handler : function() {
				pushBox(is_row,'detail','list');
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('detail');
			}
		} ],
		onLoad:function pushUrlOnload(){
			pushUrlOnloadCallback(is_row);
		}
	});
}
//弹出层保存按扭
function pushBox(is_row,Box_id,List_id) {
	if(Box_id==null||Box_id==''||Box_id==undefined)
		Box_id='detail';
	if(List_id==null||List_id==''||List_id==undefined)
		List_id='list';
		var v_result;
		v_result = addToPush(is_row);
		if (v_result != null && v_result != undefined) {
			closeBox(Box_id);
			$.messager.alert('提示', v_result.VALUE);
		}
}
/****/
//添加要推送的人员或者部门数据
function AddBox(is_row,Box_id,List_id){
	if(Box_id==null||Box_id==''||Box_id==undefined)
		Box_id='detail';
	if(List_id==null||List_id==''||List_id==undefined)
		List_id='list';
		var v_result;
		v_result = addToTree(is_row);
		if (v_result != null && v_result != undefined) {
			closeBox(Box_id);
			$.messager.alert('提示', v_result.VALUE);
		}
}

/**
 * 编辑页面
 * @returns {Boolean}
 */
function openEditRow(editUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#detail').dialog( {
		title : is_title,
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		href : editUrl,
		queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [ {
			text : '保存',
			iconCls : 'icon-ok',
			handler : function() {
				saveBox('detail','list');
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('detail');
			}
		} ],
		onLoad:function editUrlOnload(){
			if(is_row.OPETYPE=='insert'){
				addUrlOnloadCallback(is_row);
			}else{
				updateUrlOnloadCallback(is_row);
			}
		}
	});
}
/****/

/**
 * 编辑页面的动作
 * @returns {Boolean}
 */
//弹出层返回按扭
function closeBox(Box_id) {
	if(Box_id==null||Box_id==''||Box_id==undefined)
		Box_id='detail';
	$('#'+Box_id).dialog('close');
}

//弹出层保存按扭
function saveBox(Box_id,List_id) {
	if(Box_id==null||Box_id==''||Box_id==undefined)
		Box_id='detail';
	if(List_id==null||List_id==''||List_id==undefined)
		List_id='list';
	var returnIsValid = $('#inputForm').form('validate');
	if (returnIsValid) {
		//$("#inputForm").submit();
		var query = $("#inputForm").getFormVal();
		var v_result;
		if ($('#OPETYPE').val() == null || $('#OPETYPE').val() == undefined
				|| $('#OPETYPE').val() == '' || $('#OPETYPE').val()=='insert'){
			v_result = insertData(query);
		}
		else{
			v_result = updateData(query);
		}
		if (v_result != null && v_result != undefined) {
			closeBox(Box_id);
			$.messager.alert('提示', v_result.VALUE);	
		}
	}
}
/****/

/**
 * 高级查询页面
 * @returns {Boolean}
 */
function openAdvsearchRow(advsearchUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#advsearch').dialog( {
		title : is_title,
		iconCls : $.getJwAdvsearchPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		href : advsearchUrl,
		queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [ {
			text : '查询',
			iconCls : 'icon-search',
			handler : function() {
				advsearchBox('advsearch','list');
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('advsearch');
			}
		} ],
		onLoad:function editUrlOnload(){
		    addAdvsearchCallback(is_row);	
		}
	});
}
/****/

/**
 * 编辑页面的动作
 * @returns {Boolean}
 */
//弹出层保存按扭
function advsearchBox(Box_id,List_id) {
	if(Box_id==null||Box_id==''||Box_id==undefined)
		Box_id='advsearch';
	if(List_id==null||List_id==''||List_id==undefined)
		List_id='list';
	var returnIsValid = $('#adv_inputForm').form('validate');
	if (returnIsValid) {
		//$("#inputForm").submit();
		var query = $("#adv_inputForm").getFormVal();
		advsearchData(query);
		closeBox(Box_id);
		
	}
}
/****/

/**
 * 数据窗口
 * 2016-12-01
 * 高伟杰
**/
function datagrid(is_view,is_title,is_url,is_query,is_column,is_opetipmenuwidth,optionWidth){
	if(optionWidth==null || optionWidth==''){
		optionWidth = 80;
	}
	$('#'+is_view).datagrid({
		title:is_title,
	    iconCls:$.getJwWindowPic(),
	    url:is_url,
	    queryParams : is_query,//查询参数
		rownumbers : true,//显示索引号
		singleSelect : false,//是否多选
		fitColumns : false,//是否撑满
		autoRowHeight : false,//设定高度
		rowStyler :function(index,row){return rowstyler(index,row);},
		pagination : true,//分页显示
		pageSize : rows,//显示行数
		pageList : listPageSize,//条数选择
		striped : true, //是否隔行显示
		remoteSort : false,//是否从服务器排序
		frozenColumns : [[
				{
					field : 'ck',
					checkbox : true
				},
				{
					field : 'option',
					title : '操作',
					width : optionWidth,
					align : 'center',
					formatter : formatMenu
				}
				       ]],
		columns : is_column,
		toolbar : '#tb',
		onLoadSuccess : function() {
			if(is_opetipmenuwidth==null){
				is_opetipmenuwidth = 60;
			}
			createOptionMenuTooltip(is_opetipmenuwidth);
			dataOnLoadSuccess();
		}
	});
}

/**
 * 日志窗口
 * 2016-12-01
 * 高伟杰
**/
function datagridLog(is_view,is_title,is_url,is_query,is_column){
	$('#'+is_view).datagrid({
		title:is_title,
	    iconCls:$.getJwWindowPic(),
	    url:is_url,
	    queryParams : is_query,//查询参数
		rownumbers : true,//显示索引号
		singleSelect : false,//是否多选
		fitColumns : false,//是否撑满
		autoRowHeight : false,//设定高度
		rowStyler :function(index,row){return rowstyler(index,row);},
		pagination : true,//分页显示
		pageSize : rows,//显示行数
		pageList : listPageSize,//条数选择
		striped : true, //是否隔行显示
		remoteSort : false,//是否从服务器排序
		frozenColumns : [[
				{
					field : 'ck',
					checkbox : true
				}
				       ]],
		columns : is_column,
		toolbar : '#tb',
		onLoadSuccess : function() {
			dataOnLoadSuccess();
		}
	});
}

/**
 * 报表窗口
 * 2016-12-01
 * 高伟杰
**/
function reportgrid(is_view,is_title,is_url,is_query,is_column){
	$('#'+is_view).datagrid({
		title:is_title,
	    iconCls:$.getJwWindowPic(),
	    url:is_url,
	    queryParams : is_query,//查询参数
		rownumbers : true,//显示索引号
		singleSelect : false,//是否多选
		fitColumns : false,//是否撑满
		autoRowHeight : false,//设定高度
		rowStyler :function(index,row){return rowstyler(index,row);},
//		pagination : true,//分页显示
//		pageSize : rows,//显示行数
//		pageList : listPageSize,//条数选择
		striped : true, //是否隔行显示
		remoteSort : false,//是否从服务器排序
		frozenColumns : [[
				{
					field : 'ck',
					checkbox : true
				}
				       ]],
		columns : is_column,
		toolbar : '#tb',
		onLoadSuccess : function() {
			reportrollback();
		}
	});
}

/**
 * 禁止使用右键、复制
 * 2016-12-01
 * 高伟杰
**/
function disabledRightMenu(){
	$(document).bind("contextmenu",function(){return false;});
	$(document).bind("selectstart",function(){return false;});
}