| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 | //#region//pc时间控件U.Date = (function (that) {  //初始化    var _UDE, _ = function (UDOD, UTI, UDE) {        if (UDE && (UDE.id || UDOD.id) && _UDE.et[UDE.id || (UDOD.id + "time")]) { return _UDE.et[UDOD.id + "time"].dis(true); }        else { return new _UDE.init(UDOD, UTI, UDE); }    }    _.prototype = _UDE = {        et: {},        get: function () { },        set: function () { },        init: function (UDOD, UTI, UDE) { //初始化时间控件            var i, _UDE = ["FullYear", "Month", "Date", "Hours", "Minutes", "Seconds", "Day"]; UDE = UDE || {};            this.ti = UTI || new Date(); this.el = UDOD || this.el;            this.id = UDE.id || (UDOD.id ? UDOD.id + "time" : "U_TI" + Guid.guidNoDash());            for (i = 0; i < _UDE.length; i++) { this[_UDE[i]] = this.ti["get" + _UDE[i]]() + (i == 1 ? 1 : 0); }            this.Day = this.Day || 7;            this.ex = {};            this.startM = new Date(this.FullYear + "/" + this.Month + "/01").getDay() || 7; U.Ut.AddObj(this.ex, UDE || {});            this.et[this.id] = this; this.create();        },        create: function () { //创建一个控件            var i, _UCE, _UKE, _UDOD, _UDTD, _UDKD, _UE = U.M.GetElementInfo(this.el);            this.be = _UDOD = $$("div", { "class": "U_TI", id: this.id, style: { top: _UE.BCRT + _UE.OH + "px", left: (_UE.BCRL - 120 < 0 ? 0 : _UE.BCRL - 120) + "px"} });            this.title = _UDTD = $$("div", { "class": "U_TIH" }, _UDOD); _UCE = ["FullYear", "Month"];            for (i = 0; i < _UCE.length; i++) { _UDKD = $$("div", { "class": "U_TIHL" }, _UDTD); $$("div", { "title": "前一" + (i ? "月" : "年"), "class": "U_TIHLL", innerHTML: "<".replaceHtmlSign(), onclick: U.M.apply(this, [[this["set" + _UCE[i]], [_UDKD, -1]]]) }, _UDKD); $$("div", { "class": "U_TIHLC", innerHTML: this.ti["get" + _UCE[i]]() + i }, _UDKD); $$("div", { "title": "下一" + (i ? "月" : "年"), "class": "U_TIHLL U_TIHLR", innerHTML: ">", onclick: U.M.apply(this, [[this["set" + _UCE[i]], [_UDKD, 1]]]) }, _UDKD); } //初始化当前时间            _UDTD = $$("div", { "class": "U_TIM" }, _UDOD); for (i = 1; i < 8; i++) { $$("div", { style: { "marginLeft": i - 1 ? "" : "5px" }, innerHTML: U.MT.LowerToUpper(i + "", "day") }, _UDTD); } //星期            this.content = _UDTD = $$("div", { "class": "U_TIN" }, _UDOD); this.setDay(_UDTD);            _UDTD = $$("div", { "class": "U_TID" }, _UDOD); _UCE = ["取消", "确认", "当前"]; for (i = 0; i < _UCE.length; i++) { $$("div", { "class": "U_TIDO", innerHTML: _UCE[i], onclick: U.M.apply(this, [[this.button, [i]]]) }, _UDTD); };            U.D.SetDTop(_UDOD); $("body").append(_UDOD);        },        mp: function () { //手机端时间控件             U.Date.Phone();        },        getTime: function (UDE) { //选择当前选择的信息            var i, _UTF, _UDTD, _UDAD = $(this.title).Child(); UDE = UDE || [this.FullYear, this.Month, this.Date];            for (i = 0; i < 2; i++) { if ((_UDTD = $(_UDAD[i]).Child()[1]).innerText != UDE[i]) { _UDTD.innerText = UDE[i]; _UTF = true; } };            _UDAD = $(this.content).childg(); _UDAD.addAttrArray({ "class": "" }); _UDAD[UDE[2] + this.startM - 2].className = "U_TINO";        },        setFullYear: function (UDOD, UTF) { //设置年            $(UDOD).Child()[1].innerText = (this.FullYear += UTF); this.startM = new Date(this.FullYear + "/" + this.Month + "/01").getDay() || 7; this.setDay();        },        setMonth: function (UDOD, UTF) { //设置月            $(UDOD).Child()[1].innerText = (this.Month += UTF); this.startM = new Date(this.FullYear + "/" + this.Month + "/01").getDay() || 7; this.setDay();        },        setDay: function (UDOD) {            UDOD = UDOD || this.content; var i, _UTF, _UDE = U.MT.getYearMonthDay(); _UKE = this.startM, _UCE = this.getDay() + _UKE - 2; UDOD.innerText = "";            for (i = 0; i <= _UCE; i++) {                _UTF = i - this.startM + 2;                $$("div", { "class": (_UTF == this.Date) ? ((_UDE[0] == this.FullYear && _UDE[1] == this.Month && _UDE[2] == this.Date) ? "U_TINO" : "U_TINT") : "", "style": { "marginLeft": i % 7 ? "" : "5px" }, innerHTML: _UTF > 0 ? _UTF : "", onclick: this.startM - 2 < i ? U.M.apply(this, [[this.setTime, [_UTF]], [this.click, ["day", _UTF]]]) : null }, UDOD);            }        },        setTime: function (UIE) { //选择当前日期            this.Date = UIE; this.setDay();        },        time: function () { //时间选择            setInterval(function () { }, 1000);        },        getDay: function (UDE) { //获取指定年月的天数            UDE = UDE || [this.FullYear, this.Month]; return U.MT.getDayOfMonth(UDE);        },        click: function (UTF, UIE) { // 点击处理            var _UDE = [this.FullYear, this.Month, this.Date].join(this.ex.sy || "/"); (this.el) && (this.el[this.el.value != null ? "value" : "innerText"] = _UDE); try { (this.ex[UTF + "cb"]) && (this.ex[UTF + "cb"](_UDE)); } catch (e) { } this.dis();        },        button: function (UIE) { //按钮时间            switch (UIE) { case 0: this.dis(); break; case 1: this.click("day", this.Date); break; case 2: this.init(); break; }        },        dis: function (UTF) { //显示隐藏            $(this.be)[UTF ? "show" : "hide"](); return this;        },        TimeDif: function () { //时间差        }    };    _UDE.init.prototype = _UDE; return _;})();//手机时间控件U.Date.Phone = function (UDOD, UDE) {    var i, j, _UJE = [], _UDAD, _UDTD, _UDSD, _UDFD, _UDMD, _UDND, _UDKD, _UAE = ["FullYear", "Month", "Date", "Hours", "Minutes", "Seconds", "Day"]; UDE = UDE || {}; UDE.Date = UDE.Date || new Date(); UDOD = UDOD || event.srcElement || this;    if ((_UDTD = $("#U_Time"))[0]) { _UDTD.css("display", "block"); _UDTD.Child()[1].className = "U_TimeG U_TimeS"; }    else {        for (i = 0; i < _UAE.length; i++) { _UAE[i] = UDE.Date["get" + _UAE[i]]() + (i == 1 ? 1 : 0); }        _UDAD = $$("div", { className: "U_Time", "id": "U_Time" });        $$("div", { className: "U_TimeM" }, _UDAD);        _UDTD = $$("div", { className: "U_TimeG" }, _UDAD);        $$("div", { className: "U_TimeON" }, _UDTD);        $$("div", { className: "U_TimeT", innerHTML: "请选择时间" }, _UDTD);        _UDSD = $$("div", { className: "U_TimeO" }, _UDTD);        _UDFD = $$("div", { className: "U_TimeOA", "onscroll": [[U.Date.PhoneSc, ["this", "scroll"]]] }, _UDSD);        for (i = -1; i < 203; i++) { _UDKD = $$("div", { innerHTML: i > -1 ? (i < 1 || i > 199) ? "" : _UAE[0] + i - 99 + "年" : "选择年份", "onclick": [[U.Date.PhoneC, ["this", i]]] }, _UDFD); if (i == 99) { _UDKD.className = ""; } }        _UDMD = $$("div", { className: "U_TimeOA", "onscroll": [[U.Date.PhoneSc, ["this", "scroll"]]] }, _UDSD);        for (i = -1; i < 16; i++) { _UDKD = $$("div", { innerHTML: i > -1 ? (i < 1 || i > 12) ? "" : i + "月" : "选择月份", "onclick": [[U.Date.PhoneC, ["this", i]]] }, _UDMD); }        _UDND = $$("div", { className: "U_TimeOA", "onscroll": [[U.Date.PhoneSc, ["this", "scroll"]]] }, _UDSD); j = U.MT.getDayOfMonth[_UAE[0], _UAE[1]];        for (i = -1; i < j + 4; i++) { _UDKD = $$("div", { innerHTML: i > -1 ? (i < 1 || i > j) ? "" : i + "日" : "选择日期", "onclick": [[U.Date.PhoneC, ["this", i]]] }, _UDND); }        _UDKD = $$("div", { className: "U_TimeD" }, _UDTD);        $$("div", { innerHTML: "确定", "onclick": [[U.Date.PhoneSet, [UDOD, _UDSD, "assigin", UDE]], [U.Date.PhoneSet, [_UDAD, _UDTD, "remove", UDE]]] }, _UDKD); $$("div", { innerHTML: "当前", "onclick": [[U.Date.PhoneSet, [UDOD, _UDSD, "current", UDE]], [U.Date.PhoneSet, [_UDAD, _UDTD, "remove", UDE]]] }, _UDKD); $$("div", { innerHTML: "取消", "onclick": [[U.Date.PhoneSet, [_UDAD, _UDTD, "remove", UDE]]] }, _UDKD);        document.body.appendChild(_UDAD); _UDTD.className = "U_TimeG U_TimeS";        _UJE = [_UDFD, _UDMD, _UDND]; for (i = 0; i < _UJE.length; i++) { _UJE[i].scrollTop = ((i ? _UAE[i] : 99) - 1) * 35; }    }}//编辑变化U.Date.PhoneC = function (UDOD, UIE) {    $(UDOD).Parent().scrollTop = (UIE - 1) * 35;}//滚动变化U.Date.PhoneSc = function (UDOD, UTF) {    clearTimeout(UDOD._Time_);    UDOD._Time_ = setTimeout(function () {        UDOD.scrollTop = (Math.floor(UDOD.scrollTop / 35) + (UDOD.scrollTop % 35 > 15 ? 1 : 0)) * 35; (UDOD._Child_) && (UDOD._Child_.className = "");        (UDOD._Child_ = $(UDOD).Child()[UDOD.scrollTop / 35 + 2]).className = "U_TimeOAS"; U.Date.Phone.T = null;    }, 100);}//设置时间U.Date.PhoneSet = function (UDOD, UDTD, UTF, UDE) {    var i, _UDAD, _UTH = "", _UTM = UDE["ps"] || "-";    switch (UTF) {        case "assigin":            _UDAD = $(UDTD).Child(); for (i = 0; i < _UDAD.length; i++) { _UTH += _UDAD[i]._Child_.innerHTML.substr(0, _UDAD[i]._Child_.innerHTML.length - 1) + (i == _UDAD.length - 1 ? "" : _UTM); }            UDOD.value = UDOD.innerHTML = _UTH;            break;        case "current":            UDOD.value = UDOD.innerHTML = U.MT.getYearMonthDay("String");            break;        case "remove": UDTD.className = "U_TimeG"; $(UDOD).css("display", "none"); break;    }}//#endregion
 |