|
@@ -0,0 +1,64 @@
|
|
|
+import _ from 'lodash'
|
|
|
+import {baseConfig} from "../base";
|
|
|
+import {date} from "../../Defaults";
|
|
|
+import {dataSourceReload} from "../../DataSourceHelper";
|
|
|
+
|
|
|
+export default function () {
|
|
|
+
|
|
|
+ const cc = Ext.form.field.Date.prototype.constructor
|
|
|
+ const {initComponent, getValue} = Ext.form.field.Date.prototype
|
|
|
+ Ext.form.field.Date.override({
|
|
|
+ constructor(config) {
|
|
|
+ const newConfig = _.defaultsDeep({
|
|
|
+ // 强制属性
|
|
|
+ format: 'Y-m-d',
|
|
|
+ altFormats: 'Y-m-d',
|
|
|
+
|
|
|
+ }, baseConfig(config, 'col-item'), config, date)
|
|
|
+
|
|
|
+ cc.call(this, newConfig)
|
|
|
+ },
|
|
|
+
|
|
|
+ getValue() {
|
|
|
+ const ov = getValue.call(this)
|
|
|
+ const nv = Ext.util.Format.date(ov, 'Y-m-d')
|
|
|
+ // console.log('cc:', nv, ov)
|
|
|
+ return nv
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ initComponent() {
|
|
|
+ const that = this
|
|
|
+ const toggle = (e) => {
|
|
|
+ if ($(e.target).is('.x-form-trigger')) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (that.isExpanded) {
|
|
|
+ that.collapse()
|
|
|
+
|
|
|
+ } else {
|
|
|
+ that.expand();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.on({
|
|
|
+ afterrender() {
|
|
|
+ const {config} = this
|
|
|
+ $(this.el.dom).on('click', toggle)
|
|
|
+ },
|
|
|
+ destory() {
|
|
|
+ $(this.el.dom).off('click', toggle)
|
|
|
+ },
|
|
|
+ // focus: {
|
|
|
+ // // 获得焦点后自动下拉
|
|
|
+ // fn(sender) {
|
|
|
+ // sender.expand();
|
|
|
+ // this.doQuery(this.allQuery, true);
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ })
|
|
|
+
|
|
|
+ initComponent.call(this)
|
|
|
+ },
|
|
|
+ });
|
|
|
+}
|