|
|
@@ -0,0 +1,1617 @@
|
|
|
+/**
|
|
|
+ * ajax 请求
|
|
|
+ * @param url
|
|
|
+ * @param successFunc
|
|
|
+ * @param errorFunc
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+function getAjaxPage(url,successFunc,errorFunc){
|
|
|
+ clear_timeout($("body").data("sessionTimeout"));
|
|
|
+ $.ajax({
|
|
|
+ type : 'GET',
|
|
|
+ url : url,
|
|
|
+ contentType : "text/html",
|
|
|
+ dataType : "html",
|
|
|
+ async : true,
|
|
|
+ success : function(data){
|
|
|
+ successFunc(data);
|
|
|
+ },
|
|
|
+ error:errorFunc
|
|
|
+ })
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Func Ajax post 数据请求
|
|
|
+ * @param dataurl
|
|
|
+ * @param data
|
|
|
+ * @param sucessCallBack
|
|
|
+ * @param errorCallBack
|
|
|
+ */
|
|
|
+function postAjax(url, data,sucessCallBack, errorCallBack) {
|
|
|
+ clear_timeout($("body").data("sessionTimeout"));
|
|
|
+ if(typeof(ukey)=="undefined"){
|
|
|
+ ukey='';
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ type : "POST",
|
|
|
+ url : url,
|
|
|
+ contentType : "application/json",
|
|
|
+ dataType : "json",
|
|
|
+ async : true,
|
|
|
+ headers : {
|
|
|
+ 'USER-KEY-ID' :"ukey:"+ (ukey==null?"":ukey)
|
|
|
+ },
|
|
|
+ data : JSON.stringify(data),
|
|
|
+ success : function(data){
|
|
|
+ sucessCallBack(data);
|
|
|
+ },
|
|
|
+ error : errorCallBack
|
|
|
+ })
|
|
|
+};
|
|
|
+/**
|
|
|
+ * Ajax post 数据请求 同步
|
|
|
+ * @param url
|
|
|
+ * @param data
|
|
|
+ * @param sucessCallBack
|
|
|
+ * @param errorCallBack
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+function postAjaxAsync(url, data,sucessCallBack, errorCallBack) {
|
|
|
+ clear_timeout($("body").data("sessionTimeout"));
|
|
|
+ if(typeof(ukey)=="undefined"){
|
|
|
+ ukey='';
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ type : "POST",
|
|
|
+ url : url,
|
|
|
+ contentType : "application/json",
|
|
|
+ dataType : "json",
|
|
|
+ async : false,
|
|
|
+ headers : {
|
|
|
+ 'USER-KEY-ID' :"ukey:"+ (ukey==null?"":ukey)
|
|
|
+ },
|
|
|
+ data : JSON.stringify(data),
|
|
|
+ success : function(data){
|
|
|
+ sucessCallBack(data);
|
|
|
+ },
|
|
|
+ error : errorCallBack
|
|
|
+ })
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Func Ajax get 数据请求
|
|
|
+ * @param dataurl
|
|
|
+ * @param sucessCallBack
|
|
|
+ * @param errorCallBack
|
|
|
+ */
|
|
|
+function getAjax(url, sucessCallBack, errorCallBack) {
|
|
|
+ clear_timeout($("body").data("sessionTimeout"));
|
|
|
+ if(typeof(ukey)=="undefined"){
|
|
|
+ ukey='';
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ type : "GET",
|
|
|
+ url : url,
|
|
|
+ contentType : "application/json",
|
|
|
+ dataType : "json",
|
|
|
+ async : true,
|
|
|
+ headers : {
|
|
|
+ 'USER-KEY-ID' :"ukey:"+ (ukey==null?"":ukey)
|
|
|
+ },
|
|
|
+ success : function(data){
|
|
|
+ sucessCallBack(data);
|
|
|
+ },
|
|
|
+ error : errorCallBack
|
|
|
+ })
|
|
|
+};
|
|
|
+
|
|
|
+var doAjaxPostData = commonAjax;
|
|
|
+function commonAjax(method,url, data,sucessCallBack, errorCallBack) {
|
|
|
+ clear_timeout($("body").data("sessionTimeout"));
|
|
|
+ if(typeof(ukey)=="undefined"){
|
|
|
+ ukey='';
|
|
|
+ }
|
|
|
+ if(method.toUpperCase() == 'GET'){
|
|
|
+ data = "";
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ type : method ,
|
|
|
+ url : url,
|
|
|
+ contentType : "application/json",
|
|
|
+ dataType : "json",
|
|
|
+ async : true,
|
|
|
+ headers : {
|
|
|
+ 'USER-KEY-ID' :"ukey:"+ (ukey==null?"":ukey)
|
|
|
+ },
|
|
|
+ data : JSON.stringify(data),
|
|
|
+ success : function(data){
|
|
|
+ sucessCallBack(data);
|
|
|
+ },
|
|
|
+ error : errorCallBack
|
|
|
+ })
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// -----------------------------------------------
|
|
|
+//---------------------------common function ----------------------------
|
|
|
+
|
|
|
+function aimAt(obj,offset){
|
|
|
+ $("html,body").animate({scrollTop:$(obj).offset().top-gdv(offset,30)},800);
|
|
|
+ $(obj).focus();
|
|
|
+}
|
|
|
+
|
|
|
+function clear_timeout(o){
|
|
|
+ if( typeof ustos != "undefined" ){
|
|
|
+ clearTimeout(o);
|
|
|
+ o= setTimeout(function(){
|
|
|
+ location.replace(base_domain);
|
|
|
+ },ustos*1000);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @func 判断是否为undefined
|
|
|
+ * @param: value , default_value
|
|
|
+ * @return "" , 或者传入的值
|
|
|
+ */
|
|
|
+var gdv = getVal ;
|
|
|
+function getVal(value,default_val){
|
|
|
+ if(value!="" && value!=undefined && value!='undefined'){
|
|
|
+ return value ;
|
|
|
+ }else{
|
|
|
+ if(default_val != undefined)
|
|
|
+ return default_val ;
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+function log(value,type){
|
|
|
+ console.log("["+ gdv(type,"info") + "] ljc: ");
|
|
|
+ console.log(value);
|
|
|
+}
|
|
|
+
|
|
|
+var slv = selectorVal ;
|
|
|
+function selectorVal(selector){
|
|
|
+ if($(selector).val()!=undefined)
|
|
|
+ return $(selector).val();
|
|
|
+ return "" ;
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * eval
|
|
|
+ * @function leval
|
|
|
+ * @param str
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+function leval(str,type){
|
|
|
+ return eval('('+ str+ (type!=null?'':"()") +')'); ;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取随机数
|
|
|
+ */
|
|
|
+function getRandom(num){
|
|
|
+ return Math.round(Math.random()*(10000*gdv(num,6))) ;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @time
|
|
|
+ * @Func 将长整形时间 转换制定格式
|
|
|
+ * @param time 长整形数值
|
|
|
+ * @returns {String}
|
|
|
+ * @Exp timeStamp2String("1464058102000","MM/dd hh:mm")
|
|
|
+ */
|
|
|
+function timeStamp2String(time,format){
|
|
|
+ if(time == "" || time == null)
|
|
|
+ return ;
|
|
|
+ if(format==undefined || format == "")
|
|
|
+ format = "yyyy/MM/dd hh:mm:ss";
|
|
|
+ var datetime = new Date();
|
|
|
+ datetime.setTime(time);
|
|
|
+ return datetime.Format(format);
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * @time
|
|
|
+ * @Func 时间格式化
|
|
|
+ * @FuncName Format
|
|
|
+ * (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
|
|
|
+ */
|
|
|
+Date.prototype.Format = function (fmt) {
|
|
|
+ var o = {
|
|
|
+ "M+": this.getMonth() + 1,
|
|
|
+ "d+": this.getDate(),
|
|
|
+ "h+": this.getHours(),
|
|
|
+ "m+": this.getMinutes(),
|
|
|
+ "s+": this.getSeconds(),
|
|
|
+ "q+": Math.floor((this.getMonth() + 3) / 3),
|
|
|
+ "S": this.getMilliseconds()
|
|
|
+ };
|
|
|
+ if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
|
|
+ for (var k in o)
|
|
|
+ if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
|
|
+ return fmt;
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取config-option属性
|
|
|
+ */
|
|
|
+function getConfig(obj){
|
|
|
+ if(obj.attr("config-option") == undefined)
|
|
|
+ return "";
|
|
|
+ return $.parseJSON( "{"+ toJSONStr( obj.attr("config-option").replace(/[\r\n\t]/g, '').replace(/'/g,'"')) +"}" );
|
|
|
+}
|
|
|
+
|
|
|
+function toJSONStr(str) {
|
|
|
+// return str.replace(/([\$\w]+)\s*:/g, function(_, $1){return '"'+$1+'":'});
|
|
|
+ return str ;
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 设置url里面的值 #...#
|
|
|
+ */
|
|
|
+function format_property(value){
|
|
|
+ if(! validater.empty(value) ){
|
|
|
+ return value.replace(/\$([\w-#\.*]+)\$/g,function(m,i){
|
|
|
+ return selectorVal(i);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 设置 {} 里面的值
|
|
|
+ * type null , 选择器的值
|
|
|
+ */
|
|
|
+function objecter(param , char,type){
|
|
|
+ var param_temp = {} ;
|
|
|
+ for(property in param){
|
|
|
+ var property_val = param[property];
|
|
|
+ if( ( typeof property_val == 'string') && property_val.indexOf(char)==0 && property_val.endsWith(char)){
|
|
|
+ param_temp[property]= selectorVal( property_val.substring(char.length,property_val.length-char.length));
|
|
|
+ }else{
|
|
|
+ param_temp[property]=property_val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return param_temp ;
|
|
|
+}
|
|
|
+
|
|
|
+//--------------------------------------------------------------------------------------------------
|
|
|
+//------------------------------------- layer -----------------------------------------------------
|
|
|
+/**
|
|
|
+ * @弹窗显示内容
|
|
|
+ * @Param content 提示内容 , func 成功后的回调方法 ,不需要则不传
|
|
|
+ */
|
|
|
+var showTip = tip ;
|
|
|
+function tip(content,time,func){
|
|
|
+ if(content == undefined){
|
|
|
+ content = "error";
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ if( validater.empty(time) )
|
|
|
+ time = 1200 ;
|
|
|
+ if( validater.empty(func) )
|
|
|
+ layer.msg(content,{time:time});
|
|
|
+ else{
|
|
|
+ layer.msg(content,{time:time},function(){
|
|
|
+ func();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }catch(e){
|
|
|
+ log(e,level.error);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+function operate_wait(tips,timeout,shade){
|
|
|
+ layer.msg(gdv(tips,'请等待...'), {
|
|
|
+ icon: 16,
|
|
|
+ shade: gdv(shade,0.3),
|
|
|
+ time:gdv(timeout,-1)
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function closeAll(){
|
|
|
+ layer.closeAll();
|
|
|
+}
|
|
|
+
|
|
|
+//----------------------------------------------------------------------------------------------
|
|
|
+//-------------------------------------validater----------------------------------------------
|
|
|
+var validater ={
|
|
|
+ email:function(obj){
|
|
|
+ var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
|
|
|
+ if(!reg.test(obj)) {
|
|
|
+ return false ;
|
|
|
+ }
|
|
|
+ return true ;
|
|
|
+ } ,
|
|
|
+ phone:function(obj){
|
|
|
+ var phone=/^((\+?86)|(\(\+86\)))?(13[0123456789][0-9]{8}|15[012356789][0-9]{8}|18[0123456789][0-9]{8}|17[0-9]{9}|147[0-9]{8}|1349[0-9]{7})$/;
|
|
|
+ if(!phone.test(obj)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true ;
|
|
|
+ },
|
|
|
+ num:function(obj){
|
|
|
+ if(!isNaN(obj)){
|
|
|
+ return true ;
|
|
|
+ }
|
|
|
+ return false ;
|
|
|
+ },
|
|
|
+ character:function(obj){
|
|
|
+ var Regx = /^[A-Za-z]*$/;
|
|
|
+ if(Regx.test(val)){
|
|
|
+ return true ;
|
|
|
+ }
|
|
|
+ return false ;
|
|
|
+ },
|
|
|
+ chinese:function(obj){
|
|
|
+ if(/^[\u4e00-\u9fa5]+$/i.test(obj)){
|
|
|
+ return true ;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ empty:function(obj){
|
|
|
+ if(obj!="" && obj!=undefined && obj!="undefined"){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true ;
|
|
|
+ },
|
|
|
+ zero:function(obj){
|
|
|
+ if(obj==0)
|
|
|
+ return true ;
|
|
|
+ return false ;
|
|
|
+ },
|
|
|
+ illegalChar:function(obj){
|
|
|
+ var pattern=/[`~!@#\$%\^\&\*\(\)_\+<>\?:"\{\},\.\\\/;'\[\]]/im;
|
|
|
+ if(pattern.test(str)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ cardNO:function(obj){
|
|
|
+ var pattern= /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
|
|
|
+ if (pattern.test(obj)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+var validate = {
|
|
|
+ _config:{tigger:'submit',style:'color,pop'},
|
|
|
+ init:function(_config , parentobj){
|
|
|
+ if(!validater.empty(_config)){
|
|
|
+ this._config =$.extend(this._config,_config);
|
|
|
+ }
|
|
|
+ _config = this._config ;
|
|
|
+ validate._initTip();
|
|
|
+ if(!validater.empty(_config) && _config.tigger.indexOf("focusout") >-1 ){
|
|
|
+ if(_config.switch_flag) { return ; }
|
|
|
+ parentobj.find("[validate]").blur(function(){
|
|
|
+ var returnMsg = validate.judgeElement(this);
|
|
|
+ if(!validater.empty(returnMsg)){
|
|
|
+ validate.showInfo(this,returnMsg);
|
|
|
+ }else{
|
|
|
+ validate._initTip(this);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ submit:function(_config , parentobj){
|
|
|
+ if(!validater.empty(_config)){
|
|
|
+ this._config =$.extend(this._config,_config);
|
|
|
+ }
|
|
|
+ _config = this._config ;
|
|
|
+ validate._initTip();
|
|
|
+ if(!validater.empty(_config) ){
|
|
|
+ if(_config.switch_flag) { return ; }
|
|
|
+ for(var i=0; i< parentobj.find("[validate]").length;i++){
|
|
|
+ var returnMsg = validate.judgeElement(parentobj.find("[validate]")[i]);
|
|
|
+ if(!validater.empty(returnMsg)){
|
|
|
+ validate.showInfo(parentobj.find("[validate]")[i],returnMsg);
|
|
|
+ aimAt(parentobj.find("[validate]")[i]);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true ;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showInfo:function(thisObj,tip){
|
|
|
+ if(this._config.style.indexOf("color")!=-1 ){
|
|
|
+ $(thisObj).addClass("validate_input_error_color");
|
|
|
+ }
|
|
|
+ if(this._config.style.indexOf("pop")!=-1){
|
|
|
+ showTip(tip);
|
|
|
+ }
|
|
|
+ if(this._config.style.indexOf("text")!=-1){
|
|
|
+ $(this.textSelector).html(tip)
|
|
|
+ }
|
|
|
+ if(this._config.style.indexOf("next")!=-1){
|
|
|
+ layer.tips(tip, thisObj);
|
|
|
+ }
|
|
|
+ if(this._config.style.indexOf("wave")!=-1){
|
|
|
+ $(thisObj).addClass("validate_input_error_wave");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ judgeElement:function(thisObj){
|
|
|
+ var validate_types = $(thisObj).attr("validate").split(",");
|
|
|
+ if( validate_types!=null && validate_types.length <1 ){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ for(var i=0;i< validate_types.length;i++){
|
|
|
+ var validate_temp = validate_types[i].split(":");
|
|
|
+ var validate_tip = "" ;
|
|
|
+ var validate_type = validate_temp[0];
|
|
|
+ if(validate_temp.length == 2){
|
|
|
+ validate_tip = validate_temp[1] ;
|
|
|
+ }
|
|
|
+ if(validate_type == 'empty'){
|
|
|
+ if(validater.empty(selectorVal(thisObj))){
|
|
|
+ return getVal(validate_tip ,"输入不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(validate_type == 'email'){
|
|
|
+ if(!validater.email(selectorVal(thisObj))){
|
|
|
+ return getVal(validate_tip,"请输入正确的邮箱");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(validate_type == 'num'){
|
|
|
+ if(!validater.num(selectorVal(thisObj))){
|
|
|
+ return getVal(validate_tip, "请输入数字");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(validate_type == 'phone'){
|
|
|
+ if(!validater.phone(selectorVal(thisObj))){
|
|
|
+ return getVal(validate_tip,"请输入正确的手机号码");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(validate_type == "character"){
|
|
|
+ if(!validater.character(selectorVal(thisObj))){
|
|
|
+ return getVal(validate_tip, "请输入字母");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(validate_type == "chinese"){
|
|
|
+ if(!validater.chinese(selectorVal(thisObj))){
|
|
|
+ return getVal(validate_tip,"请输入中文");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(validate_type == "zero"){
|
|
|
+ if(!validater.zero(selectorVal(thisObj))){
|
|
|
+ return getVal(validate_tip ,"请输入非0数字");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(validate_type == 'cardNO'){
|
|
|
+ if(!validater.cardNO(selectorVal(thisObj))){
|
|
|
+ return getVal(validate_tip, "请输入正确的身份证号码");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "" ;
|
|
|
+ },
|
|
|
+ _initTip:function(obj){
|
|
|
+ $(this.textSelector).html("");
|
|
|
+ if(obj!=null){
|
|
|
+ $(obj).removeClass("validate_input_error_color");
|
|
|
+ $(obj).removeClass("validate_input_error_wave");
|
|
|
+ }else{
|
|
|
+ $("input[class*='validate']").removeClass("validate_input_error_color");
|
|
|
+ $("select[class*='validate']").removeClass("validate_input_error_color");
|
|
|
+ $("input[class*='validate']").removeClass("validate_input_error_wave");
|
|
|
+ $("select[class*='validate']").removeClass("validate_input_error_wave");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//--------------------------------------------------------------------------
|
|
|
+
|
|
|
+//-------------------------------table init------------------------------------------
|
|
|
+jQuery.fn.tableAdaptor = function (){
|
|
|
+ var params = getConfig(this);
|
|
|
+ if(params ==""){
|
|
|
+ log("error:未配置table 的 config-option属性");
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取表格列信息
|
|
|
+ var getContentVal = function getContent(j,obj){
|
|
|
+ var val = '<tr tag="'+j+'" value="'+ obj.id +'">' ;
|
|
|
+ for(var i=0;i<params.columns.length;i++){
|
|
|
+ var flag = params.columns[i].click_callback!=undefined;
|
|
|
+ val += '<td '+ (flag?('onclick="'+ params.columns[i].click_callback +'()"'):'') + "class='"+ gdv(params.columns[i].style_class,'') +"'" +' >'+ (getMultiValue(i,j,obj)) +'</td>';
|
|
|
+ }
|
|
|
+ val += "</tr>" ;
|
|
|
+ return val ;
|
|
|
+ }
|
|
|
+
|
|
|
+ String.prototype.lgformat = function(){
|
|
|
+ var args = arguments;
|
|
|
+ return this.replace(/\{([\w-*\.*]+)\}/g,function(m,i){
|
|
|
+ s=i.split(".");
|
|
|
+ var r = args[0][s[0]];
|
|
|
+ for(var j=1;j<s.length;j++){
|
|
|
+ r=r[s[j]];
|
|
|
+ }
|
|
|
+ return getVal(r,"");
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ var getMultiValue = function getMultiValueFunc(i,j,obj){
|
|
|
+ var val = '';
|
|
|
+ var reg = /\{([\w-*\.*]+)\}/g;
|
|
|
+ if(reg.test(params.columns[i].value)){
|
|
|
+ return params.columns[i].value.lgformat(obj);
|
|
|
+ }else{
|
|
|
+ val= getVal( eval(getTypeValue(params.columns[i].value,params.columns[i].type, j
|
|
|
+ ,params.columns[i].name,params.columns[i].timeformat,params.columns[i])),
|
|
|
+ getVal(params.columns[i].default_value,""));
|
|
|
+ }
|
|
|
+ return val;
|
|
|
+ }
|
|
|
+
|
|
|
+ var getImgValue = function getImgValueFunc(img_type){
|
|
|
+ return imgUrl+img_type;
|
|
|
+ }
|
|
|
+
|
|
|
+ var getTypeValue = function getTypeValueFunc(val,type,i,name,timeformat,obj){
|
|
|
+ if(type == 'fix'){
|
|
|
+ return "'"+val+"'";
|
|
|
+ }else if(type == 'category'){
|
|
|
+ if(aobj.data("obj_loygra")["data"] != null){
|
|
|
+ return "\""+ aobj.data("obj_loygra")["data"][val] +"\"" ;
|
|
|
+ }else{
|
|
|
+ return "\"\"";
|
|
|
+ }
|
|
|
+ }else if(type == 'seq'){
|
|
|
+ return i+1+aobj.data("obj_loygra_config") ;
|
|
|
+ }else if(type == 'img'){
|
|
|
+ return "\"<img title='"+getVal(name)+"' src='"+getImgValue(val) +"' />\"";
|
|
|
+ }else if(type == 'time'){
|
|
|
+ return 'timeStamp2String('+aobj.data("obj_loygra")[obj.value]+',\"'+getVal(timeformat,"") +'\")';
|
|
|
+ }else if(type == "self"){
|
|
|
+ if( !validater.empty(val) ){
|
|
|
+ var callBack_func = eval('('+ obj.value_callback+ ')');
|
|
|
+ return "\""+ callBack_func( aobj.data("obj_loygra")[val] ,aobj.data("obj_loygra"),i ) +"\"";
|
|
|
+ }
|
|
|
+ return "\""+ eval('('+ obj.value_callback+"()" +')') +"\"";
|
|
|
+ }else if(type == 'cb'){
|
|
|
+ return "'"+ "<input type=\"checkbox\">"+"'";
|
|
|
+ }else{
|
|
|
+ return "'"+aobj.data("obj_loygra")[val]+"'" ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var getajaxDateVal = function getAjaxData(num,paramData,fresh){
|
|
|
+ if(localUrl == null || localUrl =='' ){
|
|
|
+ console.log("请先配置 localUrl的值");
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ if(paramData.wait_flag!=null && paramData.wait_flag){
|
|
|
+ operate_wait("请稍后...",10000,0.01);
|
|
|
+ }
|
|
|
+ commonAjax("POST", localUrl+ params.url+"?paged="+num, paramData,function(data){
|
|
|
+ $("#"+obj.data("tbody-id")).empty();
|
|
|
+ if(data.status == status_code.OK){
|
|
|
+ obj.data("obj_loygra_config",data.data.pageSize *( data.data.paged - 1));
|
|
|
+ obj.data("cache",data.data.data);
|
|
|
+ for(var i=0;i<data.data.data.length;i++){
|
|
|
+ obj.data("obj_loygra",data.data.data[i]);
|
|
|
+ $("#"+obj.data("tbody-id")).append(getContentVal(i,data.data.data[i]));
|
|
|
+ }
|
|
|
+ if(fresh){
|
|
|
+ if(params.pager != null ){
|
|
|
+ init_papination('#'+params.pagerStyle,num,data.data.totalPage,function(n,m){
|
|
|
+ getajaxDateVal(n,obj.data("params"),false);
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ kkpagerInit(num,data.data.totalPage,data.data.totalCount,function(n){
|
|
|
+ getajaxDateVal(n,obj.data("params"),false)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(params.success != null){
|
|
|
+ eval('('+ params.success+'(data)' +')');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(params.error != null){
|
|
|
+ eval('('+ params.error+'(data)' +')');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(layer != null && paramData.wait_flag ){
|
|
|
+ layer.closeAll();
|
|
|
+ }
|
|
|
+ }, function(){});
|
|
|
+ }
|
|
|
+ var obj = this ;
|
|
|
+ var aobj= this ;
|
|
|
+ var dom = '<table class="lg-fession-tab '+ getVal(params.style_class) +'"><thead class="lg-fession-thead" >\
|
|
|
+ <tr>';
|
|
|
+
|
|
|
+ for(var i=0;i<params.columns.length;i++){
|
|
|
+ var className = "cb_click"+getRandom(10)+i ;
|
|
|
+ var cbflag = params.columns[i].type == 'cb' ;
|
|
|
+ if(cbflag){
|
|
|
+ params.columns[i].style_class = className; // + " " + getVal(params.columns[i].style_class)
|
|
|
+ this.undelegate("."+className+" input","click");
|
|
|
+ this.delegate("."+className+" input" ,"click",function(){
|
|
|
+ if($(this).parent()[0].tagName == 'TH' ){
|
|
|
+ if($(this).is(':checked')){
|
|
|
+ $("."+$(this).parent().attr('class')+" input").attr("checked",true);
|
|
|
+ }else{
|
|
|
+ $("."+$(this).parent().attr('class')+" input").attr("checked",false);
|
|
|
+ }
|
|
|
+ }else if($(this).parent()[0].tagName == 'TD'){
|
|
|
+ if( $("td."+$(this).parent().attr('class')+" input[type='checkbox']:checked").length ==
|
|
|
+ $("td."+$(this).parent().attr('class')+" input").length){
|
|
|
+ $("th."+$(this).parent().attr('class')+" input").attr("checked",true);
|
|
|
+ }else{
|
|
|
+ $("th."+$(this).parent().attr('class')+" input").attr("checked",false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ dom += "<th "+ (cbflag?"class='"+className +"'":"") +" style='width:"+ getVal(params.columns[i].width,"") +"' >"+ (( params.columns[i].type != 'cb')?params.columns[i].name:"<input type='checkbox' >") +"</th>";
|
|
|
+ }
|
|
|
+ var tbody_id = "container"+Math.round(Math.random()*10000000) ;
|
|
|
+ dom+='</tr>\
|
|
|
+ </thead>\
|
|
|
+ <tbody class="lg-fession-tbody" id="'+tbody_id+'">\
|
|
|
+ </tbody>\
|
|
|
+ </table>';
|
|
|
+
|
|
|
+ if(params.pager != null){
|
|
|
+ params.pagerStyle = 'pager-'+ Math.round(Math.random()*10000000);
|
|
|
+ dom += '<div style="text-align: right;padding:5px"><div id="'+ params.pagerStyle +'"></div></div>';
|
|
|
+ }else{
|
|
|
+ dom += '<div style="height: 40px;" >\
|
|
|
+ <div id="kkpager"></div>\
|
|
|
+ </div>';
|
|
|
+ }
|
|
|
+
|
|
|
+ obj.empty();
|
|
|
+ obj.append(dom);
|
|
|
+ obj.data("tbody-id",tbody_id) ;
|
|
|
+ if(!(obj.data("params") != null && obj.data("params") !='' )){
|
|
|
+ obj.data("params", objecter( gdv(params.param,{}),'$' ) );
|
|
|
+ }
|
|
|
+ getajaxDateVal(1, obj.data("params"), true);
|
|
|
+};
|
|
|
+
|
|
|
+function get_table_cb(selector,property,seq){
|
|
|
+ var array = [] ;
|
|
|
+ var td_input = $("td."+$(selector+" th").eq( gdv(seq,0) ).attr('class')) ;
|
|
|
+ for(var i=0; i< td_input.length; i++){
|
|
|
+ if( td_input.eq(i).children().eq(0).is(':checked')){
|
|
|
+ if(!validater.empty(property)){
|
|
|
+ array.push( $(selector).data("cache")[td_input.eq(i).parent().attr('tag')][property]);
|
|
|
+ }else{
|
|
|
+ array.push(td_input.eq(i).parent().attr('tag'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return array;
|
|
|
+}
|
|
|
+
|
|
|
+// 外部调用表格(带分页)
|
|
|
+function out_init_table(selector,param){
|
|
|
+ if(! validater.empty(param)){
|
|
|
+ $(selector).data("params", param);
|
|
|
+ }
|
|
|
+ $(selector).tableAdaptor();
|
|
|
+}
|
|
|
+
|
|
|
+// 外部调用表格(简单)
|
|
|
+function out_init_simple_table(selector,param){
|
|
|
+ if(! validater.empty(param)){
|
|
|
+ $(selector).data("params", param);
|
|
|
+ }
|
|
|
+ $(selector).tableSimpleAdaptor();
|
|
|
+}
|
|
|
+
|
|
|
+jQuery.fn.tableSimpleAdaptor = function (){
|
|
|
+ var params = getConfig(this);
|
|
|
+ if(params ==""){
|
|
|
+ log("error:未配置table 的 config-option属性");
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ // 获取表格列信息
|
|
|
+ var getContentVal = function getContent(j,obj){
|
|
|
+ var val = '<tr tag="'+j+'" value="'+ obj.id +'">' ;
|
|
|
+ for(var i=0;i<params.columns.length;i++){
|
|
|
+ var flag = params.columns[i].click_callback!=undefined;
|
|
|
+ val += '<td '+ (flag?('onclick="'+ params.columns[i].click_callback +'()"'):'') + "class='"+ gdv(params.columns[i].style_class,'') +"'" +' >'+ (getMultiValue(i,j,obj)) +'</td>';
|
|
|
+ }
|
|
|
+ val += "</tr>" ;
|
|
|
+ return val ;
|
|
|
+ }
|
|
|
+ String.prototype.lgformat = function(){
|
|
|
+ var args = arguments;
|
|
|
+ return this.replace(/\{([\w-*\.*]+)\}/g,function(m,i){
|
|
|
+ s=i.split(".");
|
|
|
+ var r = args[0][s[0]];
|
|
|
+ for(var j=1;j<s.length;j++){
|
|
|
+ r=r[s[j]];
|
|
|
+ }
|
|
|
+ return getVal(r,"");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ var getMultiValue = function getMultiValueFunc(i,j,obj){
|
|
|
+ var val = '';
|
|
|
+ var reg = /\{([\w-*\.*]+)\}/g;
|
|
|
+ if(reg.test(params.columns[i].value)){
|
|
|
+ return params.columns[i].value.lgformat(obj);
|
|
|
+ }else{
|
|
|
+ val= getVal( eval(getTypeValue(params.columns[i].value,params.columns[i].type, j
|
|
|
+ ,params.columns[i].name,params.columns[i].timeformat,params.columns[i])),
|
|
|
+ getVal(params.columns[i].default_value,""));
|
|
|
+ }
|
|
|
+ return val;
|
|
|
+ }
|
|
|
+ var getImgValue = function getImgValueFunc(img_type){
|
|
|
+ return imgUrl+img_type;
|
|
|
+ }
|
|
|
+ var getTypeValue = function getTypeValueFunc(val,type,i,name,timeformat,obj){
|
|
|
+ if(type == 'fix'){
|
|
|
+ return "'"+val+"'";
|
|
|
+ }else if(type == 'category'){
|
|
|
+ return "\""+ aobj.data("obj_loygra")["data"][val] +"\"" ;
|
|
|
+ }else if(type == 'seq'){
|
|
|
+ return i+1 ;
|
|
|
+ }else if(type == 'img'){
|
|
|
+ return "\"<img title='"+getVal(name)+"' src='"+getImgValue(val) +"' />\"";
|
|
|
+ }else if(type == 'time'){
|
|
|
+ return 'timeStamp2String('+aobj.data("obj_loygra")[obj.value]+',\"'+getVal(timeformat,"") +'\")';
|
|
|
+ }else if(type == "self"){
|
|
|
+ if( !validater.empty(val) ){
|
|
|
+ var callBack_func = eval('('+ obj.value_callback+ ')');
|
|
|
+ return "\""+ callBack_func( aobj.data("obj_loygra")[val] ) +"\"";
|
|
|
+ }
|
|
|
+ return "\""+ eval('('+ obj.value_callback+"()" +')') +"\"";
|
|
|
+ }else if(type == 'cb'){
|
|
|
+ return "'"+ "<input type=\"checkbox\">"+"'";
|
|
|
+ }else{
|
|
|
+ return "'"+aobj.data("obj_loygra")[val]+"'" ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var getajaxDateVal = function getAjaxData(num,paramData,fresh){
|
|
|
+ if(localUrl == null || localUrl =='' ){
|
|
|
+ console.log("请先配置 localUrl的值");
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ commonAjax("POST", localUrl+ params.url+"?paged="+num, paramData,function(data){
|
|
|
+ $("#"+obj.data("tbody-id")).empty();
|
|
|
+ if(data.status == status_code.OK){
|
|
|
+ obj.data("cache",data.data);
|
|
|
+ for(var i=0;i<data.data.length;i++){
|
|
|
+ obj.data("obj_loygra",data.data[i]);
|
|
|
+ $("#"+obj.data("tbody-id")).append(getContentVal(i,data.data[i]));
|
|
|
+ }
|
|
|
+ if(params.success != null){
|
|
|
+ eval('('+ params.success+'(data)' +')');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(params.error != null){
|
|
|
+ eval('('+ params.error+'(data)' +')');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, function(){});
|
|
|
+ }
|
|
|
+ var obj = this ;
|
|
|
+ var aobj= this ;
|
|
|
+
|
|
|
+ var dom = '<table class="lg-fession-tab '+ getVal(params.style_class) +'"><thead class="lg-fession-thead" ><tr>';
|
|
|
+
|
|
|
+ for(var i=0;i<params.columns.length;i++){
|
|
|
+ var className = "cb_click"+getRandom(10)+i ;
|
|
|
+ var cbflag = params.columns[i].type == 'cb' ;
|
|
|
+ if(cbflag){
|
|
|
+ params.columns[i].style_class = className; // + " " + getVal(params.columns[i].style_class)
|
|
|
+ this.undelegate("."+className+" input","click");
|
|
|
+ this.delegate("."+className+" input" ,"click",function(){
|
|
|
+ if($(this).parent()[0].tagName == 'TH' ){
|
|
|
+ if($(this).is(':checked')){
|
|
|
+ $("."+$(this).parent().attr('class')+" input").attr("checked",true);
|
|
|
+ }else{
|
|
|
+ $("."+$(this).parent().attr('class')+" input").attr("checked",false);
|
|
|
+ }
|
|
|
+ }else if($(this).parent()[0].tagName == 'TD'){
|
|
|
+ if( $("td."+$(this).parent().attr('class')+" input[type='checkbox']:checked").length ==
|
|
|
+ $("td."+$(this).parent().attr('class')+" input").length){
|
|
|
+ $("th."+$(this).parent().attr('class')+" input").attr("checked",true);
|
|
|
+ }else{
|
|
|
+ $("th."+$(this).parent().attr('class')+" input").attr("checked",false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ dom += "<th "+ (cbflag?"class='"+className +"'":"") +" style='width:"+ getVal(params.columns[i].width,"") +"' >"+ (( params.columns[i].type != 'cb')?params.columns[i].name:"<input type='checkbox' >") +"</th>";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ var tbody_id = "container"+Math.round(Math.random()*10000000) ;
|
|
|
+ dom+='</tr>\
|
|
|
+ </thead>\
|
|
|
+ <tbody class="lg-fession-tbody" id="'+tbody_id+'">\
|
|
|
+ </tbody>\
|
|
|
+ </table>';
|
|
|
+ obj.empty();
|
|
|
+ obj.append(dom);
|
|
|
+ obj.data("tbody-id",tbody_id) ;
|
|
|
+ if(!(obj.data("params") != null && obj.data("params") !='' )){
|
|
|
+ obj.data("params", gdv(params.param,{}));
|
|
|
+ }
|
|
|
+ getajaxDateVal(1, obj.data("params"), true);
|
|
|
+};
|
|
|
+
|
|
|
+//-----------------------------------------------------------------------------------------------------------------
|
|
|
+//--------------------------------------------pager-----------------------------------------------------------------
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param currentPage
|
|
|
+ * @param totalPage
|
|
|
+ * @param totalCounts
|
|
|
+ * @param func ,不需要回调修改页面的函数
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+function kkpagerInit(currentPage,totalPages,totalCounts,func){
|
|
|
+ var sum = totalCounts;//总数据条数后台返回数据
|
|
|
+ var totalPage = totalPages;//总页数总数据条数/每页显示数 向上取整
|
|
|
+ var current = 1;//当前页数 后台返回数据
|
|
|
+ if(current == 0 || currentPage==undefined){
|
|
|
+ current = 1;
|
|
|
+ }
|
|
|
+ //初始化函数
|
|
|
+ kkpager.generPageHtml({
|
|
|
+ pno : current, //当前页数
|
|
|
+ total : totalPage,//总页数
|
|
|
+ totalRecords : sum, //总数据条数
|
|
|
+ mode:'click', //这里设置为click模式
|
|
|
+ lang : {
|
|
|
+ prePageText : '上一页',
|
|
|
+ nextPageText : '下一页',
|
|
|
+ totalPageBeforeText : '共',
|
|
|
+ totalPageAfterText : '页 '+totalCounts+'条',
|
|
|
+ totalRecordsAfterText : '条数据',
|
|
|
+ gopageBeforeText : ' 转到',
|
|
|
+ gopageButtonOkText : '确定',
|
|
|
+ gopageAfterText : '页',
|
|
|
+ buttonTipBeforeText : '第',
|
|
|
+ buttonTipAfterText : '页'
|
|
|
+ },
|
|
|
+ click:function(n){
|
|
|
+ func(n);
|
|
|
+ this.selectPage(n); //手动条用selectPage进行页码选中切换
|
|
|
+ },
|
|
|
+ //设置href链接地址,默认#
|
|
|
+ getHref:function(n){
|
|
|
+ return "javascript:;;";
|
|
|
+ }
|
|
|
+ },true);
|
|
|
+};
|
|
|
+
|
|
|
+//------------------------------------------------------------------------------------------------------
|
|
|
+//-------------------------------------jquery pagination------------------------------------------------
|
|
|
+function init_papination(selector,current,total,func){
|
|
|
+ $(selector).whjPaging({
|
|
|
+ pageSizeOpt: [
|
|
|
+ {'value': 5, 'text': '5条/页', 'selected': true},
|
|
|
+ {'value': 10, 'text': '10条/页'},
|
|
|
+ {'value': 15, 'text': '15条/页'},
|
|
|
+ {'value': 20, 'text': '20条/页'}
|
|
|
+ ],
|
|
|
+ totalPage: 19,
|
|
|
+ showPageNum: 5,
|
|
|
+ firstPage: '首页',
|
|
|
+ previousPage: '上一页',
|
|
|
+ nextPage: '下一页',
|
|
|
+ lastPage: '尾页',
|
|
|
+ skip: '跳至',
|
|
|
+ confirm: '确认',
|
|
|
+ refresh: '刷新',
|
|
|
+ totalPageText: '共{}页',
|
|
|
+ isShowFL: true,
|
|
|
+ isShowPageSizeOpt: false,
|
|
|
+ isShowSkip: true,
|
|
|
+ isShowRefresh: false,
|
|
|
+ isShowTotalPage: true,
|
|
|
+ isResetPage: false,
|
|
|
+ callBack: function (currPage, pageSize) {
|
|
|
+ func(currPage,pageSize);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $(selector).whjPaging("setPage", current, total);
|
|
|
+}
|
|
|
+//-------------------------------------------------------------------------------
|
|
|
+//-----------------------------other detail_get_restall--------------------------------------------------
|
|
|
+function detail_get_restall(selector,_config){
|
|
|
+ var config = _config ;
|
|
|
+ var childs = $(selector).find("[type-name]");
|
|
|
+ getAjax(localUrl+config.url, function(data){
|
|
|
+ if(data.status == status_code.OK){
|
|
|
+ for(var j=0; j < childs.length;j++){
|
|
|
+ if(childs.eq(j).attr("type-value") == 'h' ){
|
|
|
+ childs.eq(j).html( data.data[childs.eq(j).attr("type-name")] ) ;
|
|
|
+ }else{
|
|
|
+ childs.eq(j).val( data.data[childs.eq(j).attr("type-name")] ) ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(config.success != null ){
|
|
|
+ eval('('+ config.success+'(data)' +')');
|
|
|
+ }
|
|
|
+ },function(){
|
|
|
+ if(config.error != null){
|
|
|
+ eval('('+ config.error+'()' +')');
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//------------------------------------------------------------------------------------------
|
|
|
+//------------------------文件上传------------------------------------
|
|
|
+/**
|
|
|
+ * @Func 文件上傳功能,目前只支持單個
|
|
|
+ * @param imgUrl domain
|
|
|
+ * @param user_id 用戶id
|
|
|
+ * @param func 成功之後的回調
|
|
|
+ * @Param id 文件选择id
|
|
|
+ */
|
|
|
+function UploadInit(imgUrl,ukey,func,id,domId,thumbnailWidth, thumbnailHeight,accept,acceptconfig,extc){
|
|
|
+ var $ = jQuery,
|
|
|
+ state = 'pending',
|
|
|
+ uploader;
|
|
|
+ // 增加类型修改,可以传入类型
|
|
|
+ if(accept == undefined){
|
|
|
+ acceptconfig = "" ;
|
|
|
+ }else{
|
|
|
+ acceptconfig = getVal( acceptconfig, { // 默认值兼容之前
|
|
|
+ title: 'Images',
|
|
|
+ extensions: 'gif,jpg,jpeg,bmp,png,pdf',
|
|
|
+ mimeTypes: 'image/jpg,image/jpeg,image/png'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ var c = {
|
|
|
+ // 自动上传
|
|
|
+ auto: true,
|
|
|
+ // 不压缩image
|
|
|
+ resize: false,
|
|
|
+ //不压缩图片
|
|
|
+ compress:false,
|
|
|
+ // swf文件路径
|
|
|
+ swf: imgUrl + '/lib/webUploader/Uploader.swf',
|
|
|
+ // 文件接收服务端。
|
|
|
+ server: imgUrl+'/service/upload.json',
|
|
|
+ // 选择文件的按钮。可选。
|
|
|
+ // 内部根据当前运行是创建,可能是input元素,也可能是flash.
|
|
|
+ pick: '#'+id ,
|
|
|
+ duplicate: true ,
|
|
|
+
|
|
|
+ // 只允许选择文件,可选。
|
|
|
+ accept:acceptconfig
|
|
|
+ };
|
|
|
+ if(extc!=undefined){
|
|
|
+ c["fileNumLimit"]=extc["fileNumLimit"];
|
|
|
+ c["fileSingleSizeLimit"]=extc["fileSingleSizeLimit"];
|
|
|
+ }else{
|
|
|
+ c["fileSingleSizeLimit"] = 5*1024*1024;
|
|
|
+ }
|
|
|
+ // debugger
|
|
|
+
|
|
|
+ uploader = WebUploader.create(c);
|
|
|
+
|
|
|
+ uploader.on("error",function (type){
|
|
|
+ if(type=="Q_EXCEED_NUM_LIMIT"){
|
|
|
+ showTip("超过限定的上传数目");
|
|
|
+ }else if (type=="Q_TYPE_DENIED"){
|
|
|
+ if(typeof(layer)!="undefined"){
|
|
|
+ showTip("请上传正确的文件格式");
|
|
|
+ }else{
|
|
|
+ alert("请上传正确的文件格式");
|
|
|
+ }
|
|
|
+ }else if(type=="F_EXCEED_SIZE"){
|
|
|
+ if(typeof(layer)!="undefined"){
|
|
|
+ if(extc!=undefined){
|
|
|
+ showTip(`文件大小不能超过${ parseInt(extc["fileSingleSizeLimit"])/(1024*1024)}M`);
|
|
|
+ }else{
|
|
|
+ showTip("文件大小不能超过5M");
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ alert("文件大小不能超过5M");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 当有文件添加进来的时候
|
|
|
+ uploader.on('fileQueued', function(file) {
|
|
|
+ $("#"+domId).css("width","0%");
|
|
|
+ $("#"+domId).attr("ids","");
|
|
|
+ $("#"+domId).css("display","inherit");
|
|
|
+ uploader.options.formData={'uki':"ukey:" + getVal(ukey,"")};
|
|
|
+ uploader.makeThumb( file, function( error, src ) {
|
|
|
+ $("#back_"+domId).css("background","url("+src+")");
|
|
|
+
|
|
|
+ }, thumbnailWidth, thumbnailHeight );
|
|
|
+ });
|
|
|
+ // 文件上传过程中创建进度条实时显示。
|
|
|
+ uploader.on('uploadProgress', function(file, percentage) {
|
|
|
+ $("#all_"+domId).text(parseInt(percentage*100)+"%");
|
|
|
+ $("#"+domId).css("width",parseInt(100-percentage*100)+"%");
|
|
|
+ });
|
|
|
+ uploader.on('uploadSuccess', func);
|
|
|
+ uploader.on('uploadError', function(file) {
|
|
|
+ console.log("文件上传出错");
|
|
|
+ });
|
|
|
+ uploader.on('uploadComplete', function(file) {
|
|
|
+ });
|
|
|
+ uploader.on('all', function(type) {
|
|
|
+ });
|
|
|
+};
|
|
|
+//------------------------------------------------------------------------------------------
|
|
|
+//------------------------弹出层------------------------------------
|
|
|
+/**
|
|
|
+ * @自定义弹窗
|
|
|
+ * @Param title 标题 , selector 选择器
|
|
|
+ * @Return layer
|
|
|
+ */
|
|
|
+function openWindow(titleName,selector,width,skinColor){
|
|
|
+ if(width==undefined || width==''){
|
|
|
+ width = 'auto';
|
|
|
+ }
|
|
|
+ if(skinColor==undefined || skinColor==''){
|
|
|
+ skinColor = 'loygra-layer-skin';
|
|
|
+ }
|
|
|
+ var index = layer.open({
|
|
|
+ title:titleName,
|
|
|
+ type: 1,
|
|
|
+ area: width,
|
|
|
+ skin: skinColor,
|
|
|
+ shadeClose:true,
|
|
|
+ content: $(selector)
|
|
|
+ });
|
|
|
+ return index ;
|
|
|
+};
|
|
|
+/**
|
|
|
+ * 将值写入到selector中
|
|
|
+ * @param selector
|
|
|
+ * @param val
|
|
|
+ * @param type '#' or '.'
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+function writeVal(selector,val,type){
|
|
|
+ if(type !=undefined){
|
|
|
+ $(type+selector).val(val);
|
|
|
+ }else{
|
|
|
+ $("#"+selector).val(val);
|
|
|
+ }
|
|
|
+};
|
|
|
+/**
|
|
|
+ * @分页功能,基于JqPage
|
|
|
+ * @id <ul id="pagination" class="pagination"></ul>
|
|
|
+ * @totalpage 总页数
|
|
|
+ * @func 回调函数
|
|
|
+ */
|
|
|
+function jqPaginatorUtil(id,totalpage,func){
|
|
|
+ if(totalpage == "0"){ // 总页数为 0 则不显示
|
|
|
+ $("#"+id).hide();
|
|
|
+ return ;
|
|
|
+ }else{
|
|
|
+ $("#"+id).show();
|
|
|
+ }
|
|
|
+ $.jqPaginator('#'+id, {
|
|
|
+ totalPages: totalpage,
|
|
|
+ visiblePages: 10,
|
|
|
+ currentPage: 1,
|
|
|
+ prev: '<li class="prev"><a href="javascript:;">上一页</a></li>',
|
|
|
+ next: '<li class="next"><a href="javascript:;">下一页</a></li>',
|
|
|
+ page: '<li class="page"><a href="javascript:;">{{page}}</a></li>',
|
|
|
+ onPageChange: func
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * @分页功能,修改参数(总页数)
|
|
|
+ * @id <ul id="pagination" class="pagination"></ul>
|
|
|
+ * totalpage 总页数
|
|
|
+ */
|
|
|
+function jqPaginatorChange(id,totalpage){
|
|
|
+ $('#'+id).jqPaginator('option', {
|
|
|
+ totalPages: totalpage
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 通过ajax请求服务器数据,生成select
|
|
|
+ */
|
|
|
+function init_select(object,selector ){
|
|
|
+ commonAjax( gdv(object.method,"POST") ,
|
|
|
+ localUrl + object.url , gdv(object.data,{}),function(data){
|
|
|
+ gdv(selector,$(object.selector)).empty();
|
|
|
+ if(data.status == 10001){
|
|
|
+ var dataTemp = data.data.data ;
|
|
|
+ if(! validater.empty(object.init_value) ){
|
|
|
+ gdv(selector,$(object.selector)).append("<option value='' >"+ object.init_value +"</option>");
|
|
|
+ }
|
|
|
+ for(var i=0;i< dataTemp.length; i++){
|
|
|
+ var tempOption = "<option "+ (dataTemp[i][gdv(object.key,"key")] == object.default_value ? "selected":"" ) +" value='" + dataTemp[i][gdv(object.key,"key")] + "'>"+ dataTemp[i][gdv(object.value,"value")] +"</option>"
|
|
|
+ gdv(selector,$(object.selector)).append(tempOption);
|
|
|
+ }
|
|
|
+ object.success();
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @分页功能,修改参数(当前页数)
|
|
|
+ * @id <ul id="pagination" class="pagination"></ul>
|
|
|
+ * totalpage 总页数
|
|
|
+ */
|
|
|
+function jqPaginatorChangeCurrent(id,currentpage){
|
|
|
+ $('#'+id).jqPaginator('option', {
|
|
|
+ currentPage: currentpage
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param object
|
|
|
+ * {
|
|
|
+ * method:'POST',
|
|
|
+ * url:'url',
|
|
|
+ * param:{},
|
|
|
+ * data:{ treeNode属性
|
|
|
+ * id:'id',
|
|
|
+ * pId:'pId',
|
|
|
+ * name:'name',
|
|
|
+ * t:'r'
|
|
|
+ * },
|
|
|
+ * onClick:回调方法
|
|
|
+ * settting:配置 可不填
|
|
|
+ * selector:selector // 容器div
|
|
|
+ * }
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+function ajaxInitTree(object){
|
|
|
+ commonAjax( gdv(object.method,"POST") ,
|
|
|
+ localUrl + object.url , gdv(object.param,{}),function(data){
|
|
|
+ $(object.selector).empty();
|
|
|
+ if(data.status == 10001){
|
|
|
+ var dataTemp = data.data ;
|
|
|
+ var treeData = [] ;
|
|
|
+ for(var i=0;i<dataTemp.length;i++){
|
|
|
+ var tmpdata = {} ;
|
|
|
+ tmpdata["id"] = dataTemp[i][object.data.id];
|
|
|
+ tmpdata["pId"] = dataTemp[i][object.data.pId];
|
|
|
+ tmpdata["name"] = dataTemp[i][object.data.name];
|
|
|
+ tmpdata["t"] = dataTemp[i][object.data.t];
|
|
|
+ tmpdata["open"] = gdv(object.isOpen,"false");
|
|
|
+ treeData[i] = tmpdata ;
|
|
|
+ }
|
|
|
+ object.nodes = treeData ;
|
|
|
+ treeInit(object);
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 树型
|
|
|
+ * @param object
|
|
|
+ * @colums selector div容器
|
|
|
+ * @colums nodes 数据
|
|
|
+ * @colums onClick func 点击回调
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+function treeInit(object){
|
|
|
+ $(object.selector).empty();
|
|
|
+ var treeSelector = gdv(object.id, "tree-" + getRandom(5));
|
|
|
+ $(object.selector).append('<ul id="'+treeSelector+'" class="ztree"></ul>');
|
|
|
+ $("#"+treeSelector).data("selector",treeSelector);
|
|
|
+ var setting = {
|
|
|
+ data: {
|
|
|
+ simpleData: {
|
|
|
+ enable: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ callback: {
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if(!validater.empty(object.onClick)){
|
|
|
+ setting.callback.onClick = object.onClick ;
|
|
|
+ }
|
|
|
+ $.fn.zTree.init($("#"+treeSelector), gdv(object.setting,setting), object.nodes);
|
|
|
+ if( object.success != null ){
|
|
|
+ object.success() ;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 返回treeObj
|
|
|
+ * 其他API:http://www.treejs.cn/v3/api.php
|
|
|
+ * @param selecor
|
|
|
+ * @returns treeObj
|
|
|
+ */
|
|
|
+function getParentTree(selecor){
|
|
|
+ return $.fn.zTree.getZTreeObj( $(selecor).children().eq(0).data("selector"));
|
|
|
+}
|
|
|
+
|
|
|
+;$.fn.extend({
|
|
|
+ selectLinkage:function(url,selector,params,init_flag,parent_code,children_code){
|
|
|
+ if(init_flag == true){
|
|
|
+ $(this).val(parent_code);
|
|
|
+ var data = {};
|
|
|
+ for(var i=0;i<params.key.length;i++){
|
|
|
+ if(params.value[i]=='self'){
|
|
|
+ data[params.key[i]] = getVal($(this).val(),"") ;
|
|
|
+ }else{
|
|
|
+ data[params.key[i]] = getVal(params.value[i],"") ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ doAjaxPostData("POST", localUrl+url,
|
|
|
+ data,function(data){
|
|
|
+ if(data.status == 10001){
|
|
|
+ $(selector).empty();
|
|
|
+ if(data.data.length >0){
|
|
|
+ for(var i=0;i<data.data.length;i++){
|
|
|
+ $(selector).append("<option value='"+data.data[i].value+"'>"+data.data[i].name +"</option>");
|
|
|
+ }
|
|
|
+ $(selector).val(children_code);
|
|
|
+ }else{
|
|
|
+ $(selector).append("<option value=''>请选择</option>");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
+ }, function(){})
|
|
|
+ }else{
|
|
|
+ $(selector).append("<option value=''>请选择</option>");
|
|
|
+ }
|
|
|
+ $(this).change(function(){
|
|
|
+ var data = {};
|
|
|
+ for(var i=0;i<params.key.length;i++){
|
|
|
+ if(params.value[i]=='self'){
|
|
|
+ data[params.key[i]] = getVal($(this).val(),"") ;
|
|
|
+ }else{
|
|
|
+ data[params.key[i]] = getVal(params.value[i],"") ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ doAjaxPostData("POST", localUrl+url,
|
|
|
+ data,function(data){
|
|
|
+ if(data.status == 10001){
|
|
|
+ $(selector).empty();
|
|
|
+ if(data.data.length >0){
|
|
|
+ for(var i=0;i<data.data.length;i++){
|
|
|
+ $(selector).append("<option value='"+data.data[i].value+"'>"+data.data[i].name +"</option>");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $(selector).append("<option value=''>请选择</option>");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $(selector).empty();
|
|
|
+ $(selector).append("<option value=''>请选择</option>");
|
|
|
+ }
|
|
|
+ }, function(){})
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ infoInit:function(params){
|
|
|
+ var thisObj = $(this);
|
|
|
+ var getTypeValue = function getTypeValueFunc(object){
|
|
|
+ if(object.type == 'category'){
|
|
|
+ return ("obj_loygra.data."+object.value);
|
|
|
+ }else if(object.type == 'time'){
|
|
|
+ return 'timeStamp2String(obj_loygra.'+ object.value+','+object.format +')';
|
|
|
+ }else{
|
|
|
+ return ("obj_loygra."+object.value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ doAjaxPostData(getVal(params.method,"GET") ,params.url, getVal(params.param,{}),function(data){
|
|
|
+ var html = '<table class="mooring-table table table-bordered"><tbody><tr><td colspan="'+getVal(params.colNums*2,"4")+'" class="table-head">'
|
|
|
+ + params.title+'</td></tr>';
|
|
|
+ obj_loygra = data.data;
|
|
|
+ if(data.status == 10001){
|
|
|
+ for(var i=0;i<params.columns.length;){
|
|
|
+ html += '<tr>';
|
|
|
+ for(var j=0;j<params.colNums;j++){
|
|
|
+ if(i < params.columns.length ){
|
|
|
+ html += '<td style="'+ getVal(params.columns[i].style_key,"") +'" class="td-head-column '+ getVal(params.classKey,"") +'">'+ getVal(params.columns[i].key,"") +'</td><td style="'+ getVal(params.columns[i].style_value,"") +'" class="td-content-length '+ getVal(params.classValue,"") +'">'+
|
|
|
+ getVal(eval(getTypeValue(params.columns[i])) ,getVal(params.columns[i].defaultValue,""))+'</td>';
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ html += '</tr>';
|
|
|
+ }
|
|
|
+ html += '</table>';
|
|
|
+ thisObj.append(html);
|
|
|
+ }else{
|
|
|
+ showTip(data.statusMsg);
|
|
|
+ }
|
|
|
+ }, function(){});
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 地图联动初始化
|
|
|
+ */
|
|
|
+var area ={
|
|
|
+ className: ["selectInput"],
|
|
|
+ areaid: 'area',
|
|
|
+ showCity: true ,
|
|
|
+ showDistrict: true ,
|
|
|
+ init:function(_config){
|
|
|
+ if(_config !=undefined){
|
|
|
+ if(!this._isUndef(_config.id)){this.areaid = _config.id}
|
|
|
+
|
|
|
+ if(typeof(_config.className)=="object"){
|
|
|
+ this.className = _config.className;
|
|
|
+ }else if(typeof(_config.className)=="string"){
|
|
|
+ this.className[0]= _config.className;
|
|
|
+ this.className[1]= _config.className;
|
|
|
+ this.className[2]= _config.className;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!this._isUndef(_config.showCity)){this.showCity = _config.showCity}
|
|
|
+ if(!this._isUndef(_config.showDistrict)){this.showDistrict = _config.showDistrict}
|
|
|
+ }
|
|
|
+
|
|
|
+ var area_id = this.areaid;
|
|
|
+ $("#"+this.areaid).append('<select name="province_code" class="'+getVal(this.className[0],"selectInput")+'" id="'+this.areaid +'-province"></select>'+
|
|
|
+ (this.showCity?'<select name="city_code" class="'+getVal(this.className[1],"selectInput")+'" id="'+this.areaid+'-city"></select>':"") +
|
|
|
+ (this.showDistrict?'<select name="district_code" class="'+getVal(this.className[2],"selectInput")+'" id="'+this.areaid+'-district"></select>':""));
|
|
|
+ /**
|
|
|
+ * 省市区初始化
|
|
|
+ */
|
|
|
+ for(var i=0;i<area_array.length;i++ ){
|
|
|
+ if(area_array[i]!=undefined && area_array[i]!=""){
|
|
|
+ $("#"+this.areaid+"-province").append('<option value="'+i+'">'+area_array[i] +'</option>');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $("#"+area_id+"-city").append("<option value='0'>请选择</option>");
|
|
|
+ $("#"+area_id+"-district").append("<option value='0'>请选择</option>");
|
|
|
+
|
|
|
+ $("#"+area_id+"-province").change(function(){
|
|
|
+ var province_code = selectorVal("#"+area_id+"-province");
|
|
|
+ if(validater.empty(l_arr[province_code*100+1])){
|
|
|
+ $("#"+area_id+"-district").hide();
|
|
|
+ if(validater.zero($(this).val()))
|
|
|
+ $("#"+area_id+"-district").show();
|
|
|
+ }else{
|
|
|
+ $("#"+area_id+"-district").show();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(province_code!=0 && province_code!=""){
|
|
|
+ $("#"+area_id+"-city").empty();
|
|
|
+ $("#"+area_id+"-district").empty();
|
|
|
+ for(var i=0;i<sub_array[province_code].length;i++){
|
|
|
+ if(sub_array[province_code][i]!=undefined &&sub_array[province_code][i]!="" ){
|
|
|
+ $("#"+area_id+"-city").append('<option value="'+(i)+'">'+sub_array[province_code][i] +'</option>');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $("#"+area_id+"-district").append("<option value='0'>请选择</option>");
|
|
|
+ }else{
|
|
|
+ $("#"+area_id+"-city").empty();
|
|
|
+ $("#"+area_id+"-district").empty();
|
|
|
+ $("#"+area_id+"-city").append("<option value='0'>请选择</option>");
|
|
|
+ $("#"+area_id+"-district").append("<option value='0'>请选择</option>");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ $("#"+area_id+"-city").change(function(){
|
|
|
+ var city_code = selectorVal("#"+area_id+"-city");
|
|
|
+ if(city_code!=0 && city_code!=""){
|
|
|
+ $("#"+area_id+"-district").empty();
|
|
|
+ if(l_arr[city_code] != undefined && l_arr[city_code] != ""){
|
|
|
+ for(var i=0;i<sub_arr[city_code].length;i++){
|
|
|
+ if(sub_arr[city_code][i]!=undefined &&sub_arr[city_code][i]!="" ){
|
|
|
+ $("#"+area_id+"-district").append('<option value="'+(i)+'">'+sub_arr[city_code][i] +'</option>');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $("#"+area_id+"-district").empty();
|
|
|
+ $("#"+area_id+"-district").append("<option value='0'>请选择</option>");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ _isUndef:function(obj){
|
|
|
+ if(obj!=undefined){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ init_value:function(province_code,city_code,district_code,area){
|
|
|
+ var area_id = getVal(area,"area");
|
|
|
+ $("#"+area_id+"-province").val(province_code);
|
|
|
+
|
|
|
+ if(validater.empty(l_arr[province_code*100+1])){
|
|
|
+ $("#"+area_id+"-district").hide();
|
|
|
+ }else{
|
|
|
+ $("#"+area_id+"-district").show();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(province_code!=0 && province_code!=""){
|
|
|
+ $("#"+area_id+"-city").empty();
|
|
|
+ $("#"+area_id+"-district").empty();
|
|
|
+ for(var i=0;i<sub_array[province_code].length;i++){
|
|
|
+ if(sub_array[province_code][i]!=undefined &&sub_array[province_code][i]!="" ){
|
|
|
+ if(i == city_code ){
|
|
|
+ $("#"+area_id+"-city").append('<option checked="checked" value="'+(i)+'">'+sub_array[province_code][i] +'</option>');
|
|
|
+ }else{
|
|
|
+ $("#"+area_id+"-city").append('<option value="'+(i)+'">'+sub_array[province_code][i] +'</option>');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $("#"+area_id+"-city").empty();
|
|
|
+ $("#"+area_id+"-district").empty();
|
|
|
+ $("#"+area_id+"-city").append("<option value='0'>请选择</option>");
|
|
|
+ $("#"+area_id+"-district").append("<option value='0'>请选择</option>");
|
|
|
+ }
|
|
|
+ $("#"+area_id+"-city").val(city_code);
|
|
|
+
|
|
|
+ if(city_code!=0 && city_code!=""){
|
|
|
+ $("#"+area_id+"-district").empty();
|
|
|
+ if(l_arr[city_code] != undefined && l_arr[city_code] != ""){
|
|
|
+ for(var i=0;i<sub_arr[city_code].length;i++){
|
|
|
+ if(sub_arr[city_code][i]!=undefined &&sub_arr[city_code][i]!="" ){
|
|
|
+ if(i ==district_code ){
|
|
|
+ $("#"+area_id+"-district").append('<option checked="checked" value="'+(i)+'">'+sub_arr[city_code][i] +'</option>');
|
|
|
+ }else{
|
|
|
+ $("#"+area_id+"-district").append('<option value="'+(i)+'">'+sub_arr[city_code][i] +'</option>');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $("#"+area_id+"-district").val(district_code);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $("#"+area_id+"-district").empty();
|
|
|
+ $("#"+area_id+"-district").append("<option value='0'>请选择</option>");
|
|
|
+ }
|
|
|
+ $("#"+area_id+"-district").val(district_code);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 浏览器类型判断
|
|
|
+ * @param osName
|
|
|
+ * @returns bool Or (osName when isName is null)
|
|
|
+ */
|
|
|
+function getOs(osName){
|
|
|
+ var os_name = '' ;
|
|
|
+ var userAgent = navigator.userAgent;
|
|
|
+ var isOpera = userAgent.indexOf("Opera") > -1;
|
|
|
+ //判断是否Opera浏览器
|
|
|
+ if (isOpera) {
|
|
|
+ os_name = "Opera" ;
|
|
|
+ };
|
|
|
+ //判断是否Firefox浏览器
|
|
|
+ if (userAgent.indexOf("Firefox") > -1) {
|
|
|
+ os_name = "FF";
|
|
|
+ }
|
|
|
+ //判断是否chorme浏览器
|
|
|
+ if (userAgent.indexOf("Chrome") > -1){
|
|
|
+ os_name = "Chrome";
|
|
|
+ }
|
|
|
+ //判断是否Safari浏览器
|
|
|
+ if (userAgent.indexOf("Safari") > -1) {
|
|
|
+ os_name = "Safari";
|
|
|
+ }
|
|
|
+ //判断是否IE浏览器
|
|
|
+ if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
|
|
|
+ os_name = "IE";
|
|
|
+ }
|
|
|
+ //判断是否Edge浏览器
|
|
|
+ if (userAgent.indexOf("Trident") > -1) {
|
|
|
+ os_name = "Edge";
|
|
|
+ };
|
|
|
+ if(osName != null){
|
|
|
+ return osName == os_name ;
|
|
|
+ }else{
|
|
|
+ return os_name ;
|
|
|
+ }
|
|
|
+}
|
|
|
+/**
|
|
|
+ * 判断响应状态是否正常,正常返回true,否则返回false
|
|
|
+ * @param data
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+function isOk(data){
|
|
|
+ if (data.hasOwnProperty("status")) {
|
|
|
+ if (data.status == "10001") {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+Array.prototype.remove = function(val) {
|
|
|
+ var index = this.indexOf(val);
|
|
|
+ if (index > -1) {
|
|
|
+ this.splice(index, 1);
|
|
|
+}
|
|
|
+};
|
|
|
+
|
|
|
+function closeLayer(){
|
|
|
+ layer.closeAll();
|
|
|
+}
|
|
|
+
|
|
|
+function tom(flg,val,val2){
|
|
|
+ return flg?val:val2 ;
|
|
|
+}
|
|
|
+
|
|
|
+function GetQueryString(name) {
|
|
|
+ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
|
|
+ var r = window.location.search.substr(1).match(reg);
|
|
|
+ if (r != null) return unescape(r[2]); return null;
|
|
|
+}
|
|
|
+
|
|
|
+function encodeUtf8(text) {
|
|
|
+ const code = encodeURIComponent(text);
|
|
|
+ const bytes = [];
|
|
|
+ for (var i = 0; i < code.length; i++) {
|
|
|
+ const c = code.charAt(i);
|
|
|
+ if (c === '%') {
|
|
|
+ const hex = code.charAt(i + 1) + code.charAt(i + 2);
|
|
|
+ const hexVal = parseInt(hex, 16);
|
|
|
+ bytes.push(hexVal);
|
|
|
+ i += 2;
|
|
|
+ } else bytes.push(c.charCodeAt(0));
|
|
|
+ }
|
|
|
+ return bytes;
|
|
|
+}
|
|
|
+
|
|
|
+function decodeUtf8(bytes) {
|
|
|
+ var encoded = "";
|
|
|
+ for (var i = 0; i < bytes.length; i++) {
|
|
|
+ encoded += '%' + bytes[i].toString(16);
|
|
|
+ }
|
|
|
+ return decodeURIComponent(encoded);
|
|
|
+}
|
|
|
+
|
|
|
+function changeIframeUrl(url , selector){
|
|
|
+ if(validater.empty(url)){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ if(! validater.empty(typeof(layer))){
|
|
|
+ layer.load(2);
|
|
|
+ setTimeout(function() {
|
|
|
+ layer.closeAll();
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
+ if(url.indexOf(localUrl) >-1){
|
|
|
+ $(gdv(selector,"#myiframe")).attr("src", url);
|
|
|
+ }else{
|
|
|
+ $(gdv(selector,"#myiframe")).attr("src",localUrl + url);
|
|
|
+ }
|
|
|
+}
|
|
|
+/**
|
|
|
+ * 获取时间
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+function getSystemTime(domId,timeformat,weekFlag){
|
|
|
+ setInterval(function() {
|
|
|
+ getTimeString(domId,timeformat,weekFlag)
|
|
|
+ }, 1000);
|
|
|
+ getTimeString(domId,timeformat,weekFlag)
|
|
|
+}
|
|
|
+function getTimeString(domId,timeformat,weekFlag){
|
|
|
+ var time = new Date();
|
|
|
+ now = parseInt(now) + 1000;
|
|
|
+ time.setTime(now);
|
|
|
+ var a = [ "日", "一", "二", "三", "四", "五", "六" ];
|
|
|
+ if(timeformat == undefined || timeformat==""){
|
|
|
+ timeformat = "yyyy/MM/dd hh:mm:ss";
|
|
|
+ }
|
|
|
+ if(weekFlag == undefined || !weekFlag){
|
|
|
+ $(domId).text(time.Format(timeformat));
|
|
|
+ }else {
|
|
|
+ $(domId).text(time.Format(timeformat) + " 星期" + a[time.getDay()]);
|
|
|
+ }
|
|
|
+}
|