Zhenfei.Li
2 years ago
9 changed files with 442 additions and 395 deletions
@ -0,0 +1,3 @@
|
||||
export { DateInterval } from "./dateinterval"; |
||||
export { TimeInterval } from "./timeinterval"; |
||||
export { TimePeriods } from "./timeperiods"; |
@ -1,92 +1,90 @@
|
||||
/** |
||||
* 时间区间 |
||||
* qcc |
||||
* 2019/2/28 |
||||
*/ |
||||
import { shortcut, extend } from "@/core"; |
||||
import { Single, Label } from "@/base"; |
||||
import { TimeCombo } from "../time"; |
||||
|
||||
@shortcut() |
||||
export class TimePeriods extends Single { |
||||
static xtype = "bi.time_periods" |
||||
|
||||
props = { |
||||
extraCls: "bi-time-interval", |
||||
value: {}, |
||||
}; |
||||
|
||||
static EVENT_CONFIRM = "EVENT_CONFIRM" |
||||
static EVENT_CHANGE = "EVENT_CHANGE" |
||||
|
||||
!(function () { |
||||
BI.TimePeriods = BI.inherit(BI.Single, { |
||||
constants: { |
||||
height: 24, |
||||
width: 24, |
||||
hgap: 15, |
||||
offset: -15 |
||||
}, |
||||
props: { |
||||
extraCls: "bi-time-interval", |
||||
value: {} |
||||
}, |
||||
|
||||
render: function () { |
||||
var self = this, o = this.options; |
||||
|
||||
return { |
||||
type: "bi.horizontal_fill", |
||||
columnSize: ["fill", "", "fill"], |
||||
items: [{ |
||||
el: BI.extend({ |
||||
ref: function (_ref) { |
||||
self.left = _ref; |
||||
} |
||||
}, this._createCombo(o.value.start, o.watermark?.start)) |
||||
}, { |
||||
el: { |
||||
type: "bi.label", |
||||
height: o.height, |
||||
hgap: 5, |
||||
text: "-", |
||||
ref: function (_ref) { |
||||
self.label = _ref; |
||||
} |
||||
} |
||||
}, { |
||||
el: BI.extend({ |
||||
ref: function (_ref) { |
||||
self.right = _ref; |
||||
} |
||||
}, this._createCombo(o.value.end, o.watermark?.end)) |
||||
}] |
||||
}; |
||||
}, |
||||
render() { |
||||
const o = this.options; |
||||
|
||||
return { |
||||
type: "bi.horizontal_fill", |
||||
columnSize: ["fill", "", "fill"], |
||||
items: [{ |
||||
el: extend({ |
||||
ref: _ref => { |
||||
this.left = _ref; |
||||
}, |
||||
}, this._createCombo(o.value.start, o.watermark?.start)), |
||||
}, { |
||||
el: { |
||||
type: Label.xtype, |
||||
height: o.height, |
||||
hgap: 5, |
||||
text: "-", |
||||
ref: _ref => { |
||||
this.label = _ref; |
||||
}, |
||||
}, |
||||
}, { |
||||
el: extend({ |
||||
ref: _ref => { |
||||
this.right = _ref; |
||||
}, |
||||
}, this._createCombo(o.value.end, o.watermark?.end)), |
||||
}], |
||||
}; |
||||
} |
||||
|
||||
_createCombo(v, watermark) { |
||||
const o = this.options; |
||||
|
||||
return { |
||||
type: TimeCombo.xtype, |
||||
value: v, |
||||
height: o.height, |
||||
watermark, |
||||
listeners: [{ |
||||
eventName: TimeCombo.EVENT_BEFORE_POPUPVIEW, |
||||
action: () => { |
||||
this.left.hidePopupView(); |
||||
this.right.hidePopupView(); |
||||
}, |
||||
}, { |
||||
eventName: TimeCombo.EVENT_CHANGE, |
||||
action: () => { |
||||
this.fireEvent(TimePeriods.EVENT_CHANGE); |
||||
}, |
||||
}, { |
||||
eventName: TimeCombo.EVENT_CONFIRM, |
||||
action: () => { |
||||
this.fireEvent(TimePeriods.EVENT_CONFIRM); |
||||
}, |
||||
}], |
||||
}; |
||||
} |
||||
|
||||
_createCombo: function (v, watermark) { |
||||
var self = this; |
||||
var o = this.options; |
||||
return { |
||||
type: "bi.time_combo", |
||||
value: v, |
||||
height: o.height, |
||||
watermark: watermark, |
||||
listeners: [{ |
||||
eventName: BI.TimeCombo.EVENT_BEFORE_POPUPVIEW, |
||||
action: function () { |
||||
self.left.hidePopupView(); |
||||
self.right.hidePopupView(); |
||||
} |
||||
}, { |
||||
eventName: BI.TimeCombo.EVENT_CHANGE, |
||||
action: function () { |
||||
self.fireEvent(BI.TimePeriods.EVENT_CHANGE); |
||||
} |
||||
}, { |
||||
eventName: BI.TimeCombo.EVENT_CONFIRM, |
||||
action: function () { |
||||
self.fireEvent(BI.TimePeriods.EVENT_CONFIRM); |
||||
} |
||||
}] |
||||
}; |
||||
}, |
||||
setValue(date) { |
||||
date = date || {}; |
||||
this.left.setValue(date.start); |
||||
this.right.setValue(date.end); |
||||
} |
||||
|
||||
setValue: function (date) { |
||||
date = date || {}; |
||||
this.left.setValue(date.start); |
||||
this.right.setValue(date.end); |
||||
}, |
||||
getValue: function () { |
||||
return {start: this.left.getValue(), end: this.right.getValue()}; |
||||
} |
||||
}); |
||||
BI.TimePeriods.EVENT_CONFIRM = "EVENT_CONFIRM"; |
||||
BI.TimePeriods.EVENT_CHANGE = "EVENT_CHANGE"; |
||||
BI.shortcut("bi.time_periods", BI.TimePeriods); |
||||
})(); |
||||
getValue() { |
||||
return { |
||||
start: this.left.getValue(), |
||||
end: this.right.getValue(), |
||||
}; |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue