Index: ssts-web/src/main/webapp/disinfectsystem/interfere/interfereSterilizationView1.jsp =================================================================== diff -u -r35223 -r35231 --- ssts-web/src/main/webapp/disinfectsystem/interfere/interfereSterilizationView1.jsp (.../interfereSterilizationView1.jsp) (revision 35223) +++ ssts-web/src/main/webapp/disinfectsystem/interfere/interfereSterilizationView1.jsp (.../interfereSterilizationView1.jsp) (revision 35231) @@ -26,6 +26,7 @@ + Index: ssts-web/src/main/webapp/disinfectsystem/interfere/interfereSterilizationTab1.js =================================================================== diff -u -r35228 -r35231 --- ssts-web/src/main/webapp/disinfectsystem/interfere/interfereSterilizationTab1.js (.../interfereSterilizationTab1.js) (revision 35228) +++ ssts-web/src/main/webapp/disinfectsystem/interfere/interfereSterilizationTab1.js (.../interfereSterilizationTab1.js) (revision 35231) @@ -187,7 +187,7 @@ items : [{ id : 'startDate1', name : 'startDate1', - xtype : 'datefieldWithServer', + xtype : 'datefieldWithServerTop', format : 'Y-m-d H:i:s', fieldLabel : '开始时间', anchor : '100%', @@ -200,7 +200,7 @@ items : [{ id : 'endDate1', name : 'endDate1', - xtype : 'datefieldWithServer', + xtype : 'datefieldWithServerTop', format : 'Y-m-d H:i:s', fieldLabel : '结束时间', anchor : '100%', Index: ssts-web/src/main/webapp/disinfectsystem/interfere/interfereWashAndDisinfectRecordView.jsp =================================================================== diff -u -r35223 -r35231 --- ssts-web/src/main/webapp/disinfectsystem/interfere/interfereWashAndDisinfectRecordView.jsp (.../interfereWashAndDisinfectRecordView.jsp) (revision 35223) +++ ssts-web/src/main/webapp/disinfectsystem/interfere/interfereWashAndDisinfectRecordView.jsp (.../interfereWashAndDisinfectRecordView.jsp) (revision 35231) @@ -48,6 +48,7 @@ + Index: ssts-web/src/main/webapp/ext/ext_datefield/DatetimeForServerTop.js =================================================================== diff -u --- ssts-web/src/main/webapp/ext/ext_datefield/DatetimeForServerTop.js (revision 0) +++ ssts-web/src/main/webapp/ext/ext_datefield/DatetimeForServerTop.js (revision 35231) @@ -0,0 +1,665 @@ + +DatetimePickerTop = function (config) { + DatetimePickerTop.superclass.constructor.call(this, config); +}; + +top.Ext.ns('top.Ext.form'); +var newDate = new Date(); + +top.Ext.extend(DatetimePickerTop, top.Ext.DatePicker, { + selectToday: function () { + this.setValue(newDate.clearTime()); + var val1 = this.value; + val1.setHours(this.theHours); + val1.setMinutes(this.theMinutes); + this.fireEvent("select", this, val1); + }, + handleDateClick: function (e, t) { + e.stopEvent(); + if (t.dateValue && !top.Ext.fly(t.parentNode).hasClass("x-date-disabled")) { + this.setValue(new Date(t.dateValue)); + var val1 = this.value; + val1.setHours(this.theHours); + val1.setMinutes(this.theMinutes); + this.fireEvent("select", this, val1); + } + }, + onRender: function (container, position) { + var m = [ + '', + '', + '
  
']; + var dn = this.dayNames; + for (var i = 0; i < 7; i++) { + var d = this.startDay + i; + if (d > 6) { + d = d - 7; + } + m.push(""); + } + m[m.length] = ""; + for (i = 0; i < 42; i++) { + if (i % 7 === 0 && i !== 0) { + m[m.length] = ""; + } + m[m.length] = ''; + } + + m[m.length] = '
", dn[d].substr(0, 1), "
'; + m[m.length] = ''; + m[m.length] = ''; + m[m.length] = '
'; + + var el = document.createElement("div"); + el.className = "x-date-picker"; + el.innerHTML = m.join(""); + + container.dom.insertBefore(el, position); + + this.el = top.Ext.get(el); + this.eventEl = top.Ext.get(el.firstChild); + + new top.Ext.util.ClickRepeater(this.el.child("td.x-date-left a"), { + handler: this.showPrevMonth, + scope: this, + preventDefault: true, + stopDefault: true + }); + + new top.Ext.util.ClickRepeater(this.el.child("td.x-date-right a"), { + handler: this.showNextMonth, + scope: this, + preventDefault: true, + stopDefault: true + }); + new top.Ext.util.ClickRepeater(this.el.child("td.y-hour-left a"), { + handler: function () { + if (this.theHours > 0) { + this.theHours--; + this.theHours = this.theHours % 24; + var txt = ''; + if (this.theHours < 10) { + txt = '0' + this.theHours; + } + else { + txt = this.theHours; + } + this.hourLabel.update(txt + '时'); + + } + }.createDelegate(this), + scope: this + }); + new top.Ext.util.ClickRepeater(this.el.child("td.y-hour-right a"), { + handler: function () { + this.theHours++; + this.theHours = this.theHours % 24; + var txt = ''; + if (this.theHours < 10) { + txt = '0' + this.theHours; + } + else { + txt = this.theHours; + } + this.hourLabel.update(txt + '时'); + }.createDelegate(this), + scope: this + }); + new top.Ext.util.ClickRepeater(this.el.child("td.y-minute-left a"), { + handler: function () { + if (this.theMinutes > 0) { + this.theMinutes--; + this.theMinutes = this.theMinutes % 60; + var txt = ''; + if (this.theMinutes < 10) { + txt = '0' + this.theMinutes; + } + else { + txt = this.theMinutes; + } + this.minuteLabel.update(txt + '分'); + + } + }.createDelegate(this), + scope: this + }); + new top.Ext.util.ClickRepeater(this.el.child("td.y-minute-right a"), { + handler: function () { + this.theMinutes++; + this.theMinutes = this.theMinutes % 60; + var txt = ''; + if (this.theMinutes < 10) { + txt = '0' + this.theMinutes; + } + else { + txt = this.theMinutes; + } + this.minuteLabel.update(txt + '分'); + }.createDelegate(this), + scope: this + }); + + this.eventEl.on("mousewheel", this.handleMouseWheel, this); + + this.monthPicker = this.el.down('div.x-date-mp'); + this.monthPicker.enableDisplayMode('block'); + + var kn = new top.Ext.KeyNav(this.eventEl, { + "left": function (e) { + e.ctrlKey ? + this.showPrevMonth() : + this.update(this.activeDate.add("d", -1)); + }, + + "right": function (e) { + e.ctrlKey ? + this.showNextMonth() : + this.update(this.activeDate.add("d", 1)); + }, + + "up": function (e) { + e.ctrlKey ? + this.showNextYear() : + this.update(this.activeDate.add("d", -7)); + }, + + "down": function (e) { + e.ctrlKey ? + this.showPrevYear() : + this.update(this.activeDate.add("d", 7)); + }, + + "pageUp": function (e) { + this.showNextMonth(); + }, + + "pageDown": function (e) { + this.showPrevMonth(); + }, + + "enter": function (e) { + e.stopPropagation(); + return true; + }, + + scope: this + }); + + this.eventEl.on("click", this.handleDateClick, this, { delegate: "a.x-date-date" }); + + this.eventEl.addKeyListener(top.Ext.EventObject.SPACE, this.selectToday, this); + + this.el.unselectable(); + + this.cells = this.el.select("table.x-date-inner tbody td"); + this.textNodes = this.el.query("table.x-date-inner tbody span"); + + this.mbtn = new top.Ext.Button({ + text: " ", + tooltip: this.monthYearText, + renderTo: this.el.child("td.x-date-middle", true) + }); + + this.mbtn.on('click', this.showMonthPicker, this); + this.mbtn.el.child(this.mbtn.menuClassTarget).addClass("x-btn-with-menu"); + + var dt1 = newDate; + var txt = ''; + + if ((this.theHours != 0 && !this.theHours) || isNaN(this.theHours)) { + this.theHours = dt1.getHours(); + } + if ((this.theMinutes != 0 && !this.theMinutes) || isNaN(this.theMinutes)) { + this.theMinutes = dt1.getMinutes(); + } + + this.hourLabel = this.el.child("td.y-hour-middle"); + if (this.theHours < 10) { + txt = '0' + this.theHours; + } + else { + txt = this.theHours; + } + this.hourLabel.update(txt + '时'); + + this.minuteLabel = this.el.child("td.y-minute-middle"); + if (this.theMinutes < 10) { + txt = '0' + this.theMinutes; + } + else { + txt = this.theMinutes; + } + this.minuteLabel.update(txt + '分'); + + var today = newDate.dateFormat(this.format); + var todayBtn = new top.Ext.Button({ + renderTo: this.el.child("td.x-date-bottom", true), + text: String.format(this.todayText, today), + tooltip: String.format(this.todayTip, today), + handler: this.selectToday, + scope: this + }); + + if (top.Ext.isIE) { + this.el.repaint(); + } + this.update(this.value); + }, + + update: function (date) { + var vd = this.activeDate; + this.activeDate = date; + if (vd && this.el) { + var t = date.getTime(); + if (vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()) { + this.cells.removeClass("x-date-selected"); + this.cells.each(function (c) { + if (c.dom.firstChild.dateValue == t) { + c.addClass("x-date-selected"); + setTimeout(function () { + try { c.dom.firstChild.focus(); } catch (e) { } + }, 50); + return false; + } + }); + return; + } + } + var days = date.getDaysInMonth(); + var firstOfMonth = date.getFirstDateOfMonth(); + var startingPos = firstOfMonth.getDay() - this.startDay; + + if (startingPos <= this.startDay) { + startingPos += 7; + } + + var pm = date.add("mo", -1); + var prevStart = pm.getDaysInMonth() - startingPos; + + var cells = this.cells.elements; + var textEls = this.textNodes; + days += startingPos; + + // convert everything to numbers so it's fast + var day = 86400000; + var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime(); + var today = newDate.clearTime().getTime(); + var sel = date.clearTime().getTime(); + var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY; + var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY; + var ddMatch = this.disabledDatesRE; + var ddText = this.disabledDatesText; + var ddays = this.disabledDays ? this.disabledDays.join("") : false; + var ddaysText = this.disabledDaysText; + var format = this.format; + + var setCellClass = function (cal, cell) { + cell.title = ""; + var t = d.getTime(); + cell.firstChild.dateValue = t; + if (t == today) { + cell.className += " x-date-today"; + cell.title = cal.todayText; + } + if (t == sel) { + cell.className += " x-date-selected"; + setTimeout(function () { + try { cell.firstChild.focus(); } catch (e) { } + }, 50); + } + // disabling + if (t < min) { + cell.className = " x-date-disabled"; + cell.title = cal.minText; + return; + } + if (t > max) { + cell.className = " x-date-disabled"; + cell.title = cal.maxText; + return; + } + if (ddays) { + if (ddays.indexOf(d.getDay()) != -1) { + cell.title = ddaysText; + cell.className = " x-date-disabled"; + } + } + if (ddMatch && format) { + var fvalue = d.dateFormat(format); + if (ddMatch.test(fvalue)) { + cell.title = ddText.replace("%0", fvalue); + cell.className = " x-date-disabled"; + } + } + }; + + var i = 0; + for (; i < startingPos; i++) { + textEls[i].innerHTML = (++prevStart); + d.setDate(d.getDate() + 1); + cells[i].className = "x-date-prevday"; + setCellClass(this, cells[i]); + } + for (; i < days; i++) { + intDay = i - startingPos + 1; + textEls[i].innerHTML = (intDay); + d.setDate(d.getDate() + 1); + cells[i].className = "x-date-active"; + setCellClass(this, cells[i]); + } + var extraDays = 0; + for (; i < 42; i++) { + textEls[i].innerHTML = (++extraDays); + d.setDate(d.getDate() + 1); + cells[i].className = "x-date-nextday"; + setCellClass(this, cells[i]); + } + + this.mbtn.setText(this.monthNames[date.getMonth()] + " " + date.getFullYear()); + + if (this.theHours < 10) { + txt = '0' + this.theHours; + } + else { + txt = this.theHours; + } + this.hourLabel.update(txt + '时'); + + if (this.theMinutes < 10) { + txt = '0' + this.theMinutes; + } + else { + txt = this.theMinutes; + } + this.minuteLabel.update(txt + '分'); + + if (!this.internalRender) { + var main = this.el.dom.firstChild; + var w = main.offsetWidth; + this.el.setWidth(w + this.el.getBorderWidth("lr")); + top.Ext.fly(main).setWidth(w); + this.internalRender = true; + // opera does not respect the auto grow header center column + // then, after it gets a width opera refuses to recalculate + // without a second pass + if (top.Ext.isOpera && !this.secondPass) { + main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth + main.rows[0].cells[2].offsetWidth)) + "px"; + this.secondPass = true; + this.update.defer(10, this, [date]); + } + } + }, + nextYearText: 'Next Year (Control+Up)', + prevYearText: 'Previous Year (Control+Down)' +}); + +DatetimeItemTop = function (config) { + DatetimeItemTop.superclass.constructor.call(this, new DatetimePickerTop(config), config); + this.picker = this.component; + this.addEvents({ select: true }); + + this.picker.on("render", function (picker) { + picker.getEl().swallowEvent("click"); + picker.container.addClass("x-menu-date-item"); + }); + + this.picker.on("select", this.onSelect, this); +}; + +top.Ext.extend(DatetimeItemTop, top.Ext.menu.Adapter, { + onSelect: function (picker, date) { + this.fireEvent("select", this, date, picker); + DatetimeItemTop.superclass.handleClick.call(this); + } +}); + +DatetimeMenuTop = function (config) { + DatetimeMenuTop.superclass.constructor.call(this, config); + this.plain = true; + var di = new DatetimeItemTop(config); + this.add(di); + this.picker = di.picker; + this.relayEvents(di, ["select"]); +}; +top.Ext.extend(DatetimeMenuTop, top.Ext.menu.Menu); + +/******** 支持时分的日期选择控件 ********/ +top.Ext.form.DateFieldWithMin = Ext.extend(top.Ext.form.TriggerField, { + + format: "m/d/y", + + altFormats: "m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d", + + disabledDays: null, + + disabledDaysText: "Disabled", + + disabledDates: null, + + disabledDatesText: "Disabled", + + minValue: null, + + maxValue: null, + + minText: "The date in this field must be equal to or after {0}", + + maxText: "The date in this field must be equal to or before {0}", + + invalidText: "{0} is not a valid date - it must be in the format {1}", + + triggerClass: 'x-form-date-trigger', + + //扩展(theHours、theMinutes)两个属性,可以让调用者指定初始化时间控件的时分,如果不指定默认为当前的时分(cjr) + theHours: null, + + theMinutes: null, + + defaultAutoCreate: { tag: "input", type: "text", size: "10", autocomplete: "off" }, + + initComponent: function () { + top.Ext.form.DateField.superclass.initComponent.call(this); + + this.addEvents('select'); //扩展了'select'事件(cjr) + + if (typeof this.minValue == "string") { + this.minValue = this.parseDate(this.minValue); + } + if (typeof this.maxValue == "string") { + this.maxValue = this.parseDate(this.maxValue); + } + this.ddMatch = null; + if (this.disabledDates) { + var dd = this.disabledDates; + var re = "(?:"; + for (var i = 0; i < dd.length; i++) { + re += dd[i]; + if (i != dd.length - 1) re += "|"; + } + this.ddMatch = new RegExp(re + ")"); + } + }, + + validateValue: function (value) { + value = this.formatDate(value); + if (!top.Ext.form.DateField.superclass.validateValue.call(this, value)) { + return false; + } + if (value.length < 1) { + return true; + } + var svalue = value; + value = this.parseDate(value); + if (!value) { + this.markInvalid(String.format(this.invalidText, svalue, this.format)); + return false; + } + var time = value.getTime(); + if (this.minValue && time < this.minValue.getTime()) { + this.markInvalid(String.format(this.minText, this.formatDate(this.minValue))); + return false; + } + if (this.maxValue && time > this.maxValue.getTime()) { + this.markInvalid(String.format(this.maxText, this.formatDate(this.maxValue))); + return false; + } + if (this.disabledDays) { + var day = value.getDay(); + for (var i = 0; i < this.disabledDays.length; i++) { + if (day === this.disabledDays[i]) { + this.markInvalid(this.disabledDaysText); + return false; + } + } + } + var fvalue = this.formatDate(value); + if (this.ddMatch && this.ddMatch.test(fvalue)) { + this.markInvalid(String.format(this.disabledDatesText, fvalue)); + return false; + } + return true; + }, + + validateBlur: function () { + return !this.menu || !this.menu.isVisible(); + }, + + + getValue: function () { + return this.parseDate(top.Ext.form.DateField.superclass.getValue.call(this)) || ""; + }, + + + setValue: function (date) { + top.Ext.form.DateField.superclass.setValue.call(this, this.formatDate(this.parseDate(date))); + }, + + parseDate: function (value) { + if (!value || top.Ext.isDate(value)) { + return value; + } + var v = Date.parseDate(value, this.format); + if (!v && this.altFormats) { + if (!this.altFormatsArray) { + this.altFormatsArray = this.altFormats.split("|"); + } + for (var i = 0, len = this.altFormatsArray.length; i < len && !v; i++) { + v = Date.parseDate(value, this.altFormatsArray[i]); + } + } + return v; + }, + + onDestroy: function () { + if (this.menu) { + this.menu.destroy(); + } + if (this.wrap) { + this.wrap.remove(); + } + top.Ext.form.DateField.superclass.onDestroy.call(this); + }, + + formatDate: function (date) { + return top.Ext.isDate(date) ? date.dateFormat(this.format) : date; + }, + + menuListeners: { + select: function (m, d) { + this.setValue(d); + }, + show: function () { + this.onFocus(); + }, + hide: function () { + this.focus.defer(10, this); + var ml = this.menuListeners; + this.menu.un("select", ml.select, this); + this.menu.un("show", ml.show, this); + this.menu.un("hide", ml.hide, this); + } + }, + + initEvents: function () { + top.Ext.form.DateField.superclass.initEvents.call(this); + this.keyNav = new top.Ext.KeyNav(this.el, { + "down": function (e) { + this.onTriggerClick(); + }, + scope: this, + forceKeyDown: true + }); + }, + + onTriggerClick: function () { + if (this.disabled) { + return; + } + if (this.menu == null) { + this.menu = new DatetimeMenuTop({ + minWidth: 194 + }); + Ext.apply(this.menu.picker, { + theHours: this.theHours, + theMinutes: this.theMinutes + }); + } + Ext.apply(this.menu.picker, { + minDate: this.minValue, + maxDate: this.maxValue, + disabledDatesRE: this.ddMatch, + disabledDatesText: this.disabledDatesText, + disabledDays: this.disabledDays, + disabledDaysText: this.disabledDaysText, + format: this.format, + minText: String.format(this.minText, this.formatDate(this.minValue)), + maxText: String.format(this.maxText, this.formatDate(this.maxValue)) + }); + this.menu.on(Ext.apply({}, this.menuListeners, { + scope: this + })); + var that = this; + Ext.Ajax.request({ + url: WWWROOT + '/system/serverTimeAction!getServerDateTime2.do', + async: false, + params: { dateformat: this.format }, + success: function (response, options) { + var result = Ext.decode(response.responseText); + if (result.success) { + var timeInMillis = result.timeInMillis; + var date = new Date(0); + date.setUTCMilliseconds(timeInMillis); + newDate = date; + that.menu.picker.setValue(that.getValue() || date); + that.menu.show(that.el, "tl-bl?"); + that.menuEvents('on'); + } + }, + failure: function (response, options) { + alert('获取服务器时间失败'); + } + }); + }, + menuEvents: function (method) { + this.menu[method]('select', this.onSelect, this); + this.menu[method]('hide', this.onMenuHide, this); + this.menu[method]('show', this.onFocus, this); + }, + onSelect: function (m, d) { + this.setValue(d); + this.fireEvent('select', this, d); + this.menu.hide(); + }, + onMenuHide: function () { + this.focus(false, 60); + this.menuEvents('un'); + }, + + beforeBlur: function () { + var v = this.parseDate(this.getRawValue()); + if (v) { + this.setValue(v); + } + } +}); +top.Ext.reg('datefieldWithServerTop', top.Ext.form.DateFieldWithMin); \ No newline at end of file Index: ssts-web/src/main/webapp/disinfectsystem/interfere/interferewashAndDisinfectForm.js =================================================================== diff -u -r35228 -r35231 --- ssts-web/src/main/webapp/disinfectsystem/interfere/interferewashAndDisinfectForm.js (.../interferewashAndDisinfectForm.js) (revision 35228) +++ ssts-web/src/main/webapp/disinfectsystem/interfere/interferewashAndDisinfectForm.js (.../interferewashAndDisinfectForm.js) (revision 35231) @@ -1145,7 +1145,7 @@ columnWidth : .5, layout : 'form', items : [{ - xtype : 'datefieldWithServer', + xtype : 'datefieldWithServerTop', fieldLabel : '开始时间', id : 'startDateStr', name : 'startDateStr', @@ -1207,7 +1207,7 @@ columnWidth : .5, layout : 'form', items : [{ - xtype : 'datefieldWithServer', + xtype : 'datefieldWithServerTop', fieldLabel : '结束时间', id : 'endDateStr', name : 'endDateStr',