• js扩展


    //项目问题跟踪-状态枚举
    var arr_issue_state = ['全部', '未开始', '进行中', '开发完成', '关闭', '待验证', '拒绝'];

    //项目问题跟踪-问题分类
    var arr_issue_class = ['全部', '系统bug', '功能优化', '操作问题', '非系统问题'];

    //D项目FA-储位绑定状态
    var arr_fa_bind_states = ['全部', '绑定到储位', '分配到工程师', '已回流'];

    // 对Date的扩展,将 Date 转化为指定格式的String
    // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
    // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
    Date.prototype.format = function (fmt) { //author: meizz
    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;
    };

    //对字符串进行扩展
    //将HTML特殊符号转义
    String.prototype.escape = function () {
    debugger;
    return this.replace(/"/g, '"')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;');
    }

    //对字符串进行扩展
    //将HTML特殊符号反转义
    String.prototype.descape = function () {
    return this.replace(/&quot;/g, '"')
    .replace(/&lt;/g, '<')
    .replace(/&gt;/g, '>');
    }

    $.extend({
    request: function (name) { //获取地址栏参数
    var hash = location.href;
    hash = hash.substr(hash.indexOf('?')).replace('?', '');
    var arr = hash.split('&');
    for (var i = 0; i < arr.length; i++) {
    var ar = arr[i].split("=");
    if (ar[0] == name) {
    if (unescape(ar[1]) == 'undefined') {
    return "";
    } else {
    return unescape(ar[1]);
    }
    }
    }
    return "";
    },
    req: function (options) { //ajax请求封装
    var success = options.success,
    error = options.error,
    end = options.end,
    dof = options.dof,
    isAlert = options.isAlert;

    options.data = options.data || {};
    options.headers = options.headers || {};

    delete options.success;
    delete options.error;

    return $.ajax($.extend({
    type: 'GET',
    dataType: 'JSON',
    success: function (res) {
    if (res.code == 0) {
    typeof options.done === 'function' && options.done(res);
    }
    else if (res.code == 1001) {
    $.error(res.msg, function () {
    window.top.location.href = '/Login.aspx';
    //window.top.location.href = 'http://mes.goertek.local/#/login';
    });
    }
    else {
    if (isAlert) {
    typeof isAlert === 'function' && isAlert(res);
    }
    else {
    $.error(res.msg || "请求异常,请联系管理员!", end);
    }

    }
    typeof success === 'function' && success(res);
    },
    error: function (e, code) {
    $.error(code || "请求异常,请联系管理员!", typeof error === 'function' && error(res));
    }
    }, options));
    },
    messagebox: function (msg, options, end) {
    msg = msg || "出现异常";
    options.icon = options.icon || 0;
    options.time = options.time || 800;
    if (typeof layer == "undefined") {
    layui.use('layer', function () {
    var layer = layui.layer;
    layer.msg(msg, options, typeof end === 'function' && end);
    });
    } else {
    layer.msg(msg, options, typeof end === 'function' && end);
    }
    },
    error: function (msg, end, isAlert) {
    $.messagebox(msg, { icon: 2 }, end, isAlert);
    return false;
    },
    warning: function (msg, end) {
    $.messagebox(msg, { icon: 0 }, end);
    return false;
    },
    success: function (msg, end) {
    $.messagebox(msg, { icon: 1 }, end);
    return false;
    }
    });

  • 相关阅读:
    毕业设计进度5(2月5日)
    毕业设计进度4(2月4日)
    Intellij IDEA 安装Scala插件 + 创建Scala项目
    中国HBase技术社区第一届Meetup资料大合集
    【大会PPT+直播回顾】HBaseCon亚洲2018峰会
    Java 中的锁原理、锁优化、CAS、AQS 详解!
    Reactor 反应堆设计模式
    IO模型
    浅析Reactor设计模式
    将IDEA工程代码提交到Github
  • 原文地址:https://www.cnblogs.com/hanzonghao/p/14709130.html
Copyright © 2020-2023  润新知