Ver código fonte

yvan-ext 发版

lizw 3 anos atrás
pai
commit
2405e30357
2 arquivos alterados com 176 adições e 8 exclusões
  1. 175 7
      dist/yvan-ext.js
  2. 1 1
      dist/yvan-ext.js.map

+ 175 - 7
dist/yvan-ext.js

@@ -61246,6 +61246,15 @@ define(['exports'], function (exports) { 'use strict';
         }
         return false;
     }
+    if (!window["time_offset"]) {
+        window["time_offset"] = 0;
+    }
+    function syncDate(date) {
+        if (date && date.setTime && date.getTime) {
+            date.setTime(date.getTime() + window["time_offset"]);
+        }
+        return date;
+    }
 
     function toString$2(value) {
         if (typeof value === 'undefined' || value === null) {
@@ -61824,6 +61833,26 @@ define(['exports'], function (exports) { 'use strict';
                 ct.call(this, config);
             }
         });
+        var _initComponent = Ext.picker.Date.prototype.initComponent;
+        Ext.picker.Date.override({
+            initComponent: function () {
+                var me = this;
+                me.defaultValue = Ext.isDate(me.defaultValue) ? me.defaultValue : syncDate(new Date());
+                _initComponent.call(me);
+            },
+            selectToday: function () {
+                var me = this, btn = me.todayBtn, handler = me.handler;
+                if (btn && !btn.disabled) {
+                    me.setValue(Ext.Date.clearTime(syncDate(new Date())));
+                    me.fireEvent('select', me, me.value);
+                    if (handler) {
+                        Ext.callback(handler, me.scope, [me, me.value], null, me, me);
+                    }
+                    me.onSelect();
+                }
+                return me;
+            },
+        });
     }
 
     function initMainTab () {
@@ -62698,7 +62727,14 @@ define(['exports'], function (exports) { 'use strict';
                             win.close();
                         }
                     }
-                ]
+                ],
+                keyMapEnabled: true,
+                keyMap: {
+                    ENTER: function () {
+                        resolve();
+                        win.close();
+                    }
+                }
             };
             if (scope === null || scope === void 0 ? void 0 : scope._handle) {
                 config.constrain = true;
@@ -130916,6 +130952,127 @@ define(['exports'], function (exports) { 'use strict';
         });
     }
 
+    function initMultipleSearch () {
+        Ext.define('Yvan.MultipleSearch', {
+            extend: 'Ext.form.field.Text',
+            xtype: 'multiplesearch',
+            bindTargert: '',
+            constructor: function (config) {
+                var _a, _b, _c, _d;
+                var self = this;
+                var newConfig = lodash.defaultsDeep({
+                    // 强制性属性
+                    triggers: {
+                        clear: {
+                            weight: 0,
+                            cls: Ext.baseCSSPrefix + 'form-clear-trigger',
+                            hidden: true,
+                            handler: 'onClearClick',
+                        }
+                    },
+                    transformRawValue: function (o) {
+                        return o;
+                    },
+                    listeners: {
+                        specialkey: function (sender, e) {
+                            var me = this;
+                            if (e.getKey() === e.ENTER) {
+                                me.fireEvent('search', me, e);
+                            }
+                        },
+                        afterrender: function (sender, e) {
+                            var _a;
+                            this.replaceRawInputEvent();
+                            invokeMethod((_a = config.listeners) === null || _a === void 0 ? void 0 : _a.afterrender, sender, e);
+                        }
+                    },
+                }, baseConfig(config, 'col-item'), config, search);
+                this.superclass.constructor.call(self, newConfig);
+                this.bindTargert = ((_d = (((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.bind) === null || _b === void 0 ? void 0 : _b.value) || ((_c = this.config) === null || _c === void 0 ? void 0 : _c.bind))) === null || _d === void 0 ? void 0 : _d.replaceAll("{", "").replaceAll("}", "")) || "";
+                this.bindTargert = lodash.trim(this.bindTargert);
+            },
+            setBindValue: function (arrValue) {
+                this.lookupViewModel().yvanScope.viewModel.set(this.bindTargert, arrValue);
+            },
+            replaceRawInputEvent: function () {
+                var me = this;
+                var $dom = $(me.inputEl.dom);
+                $dom.on('input', function (e) {
+                    var _a, _b, _c, _d, _e, _f;
+                    if ((_b = (_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.endsWith(" ")) {
+                        var a = lodash.trimEnd((_c = e.currentTarget) === null || _c === void 0 ? void 0 : _c.value);
+                        if (!a.endsWith(",") && a.length > 0) {
+                            e.currentTarget.value = a + ",";
+                        }
+                        else {
+                            e.currentTarget.value = a;
+                        }
+                    }
+                    e.currentTarget.value = (_d = e.currentTarget.value) === null || _d === void 0 ? void 0 : _d.replaceAll(",,", ",");
+                    var arr = (_f = (_e = e.currentTarget) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.split(",");
+                    me.setBindValue(arr);
+                    stopEvent(e);
+                });
+                $dom.on('keyup', function (e) {
+                    me.fireEvent('keyup', me, e);
+                    // invokeMethod(me.config.listeners?.keyup, me, e)
+                    stopEvent(e);
+                });
+                $dom.on('keydown', function (e) {
+                    me.fireEvent('keydown', me, e);
+                    // invokeMethod(me.config.listeners?.keydown, me, e)
+                    //stopEvent(e)
+                });
+                $dom.on('change', function (e) {
+                    stopEvent(e);
+                });
+                $dom.on('paste', function (e) {
+                    var _a;
+                    // @ts-ignore
+                    var clipdata = e.originalEvent.clipboardData || window.clipboardData;
+                    var text = clipdata.getData("text/plain");
+                    var spliter = ',';
+                    text = text.replaceAll("\r", "");
+                    text = text.replaceAll("\n", spliter);
+                    text = ((_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value) + "," + text;
+                    var arr = text.split(spliter);
+                    if (arr && Array.isArray(arr)) {
+                        for (var i = 0; i < arr.length; i++) {
+                            arr[i] = lodash.trim(arr[i]);
+                        }
+                    }
+                    lodash.remove(arr, function (it) {
+                        return !it;
+                    });
+                    me.setBindValue(arr);
+                    stopEvent(e);
+                });
+            },
+            onChange: function (newVal, oldVal) {
+                var me = this;
+                var value = newVal;
+                if (value) {
+                    me.getTrigger('clear').show();
+                    me.updateLayout();
+                }
+                else {
+                    me.getTrigger('clear').hide();
+                    me.updateLayout();
+                }
+            },
+            /**
+             * 清空所有值
+             */
+            onClearClick: function (sender, e) {
+                var me = this;
+                var config = me.config;
+                var lookup = config.lookup;
+                me.setValue('');
+                clearViewModelByLookup(sender, lookup);
+            }
+        });
+    }
+
     function initDate () {
         var cc = Ext.form.field.Date.prototype.constructor;
         var _a = Ext.form.field.Date.prototype, initComponent = _a.initComponent, getValue = _a.getValue, valueToRaw = _a.valueToRaw;
@@ -130984,6 +131141,17 @@ define(['exports'], function (exports) { 'use strict';
                 });
                 initComponent.call(this);
             },
+            createInitialDate: function (value) {
+                var minValue = this.minValue, maxValue = this.maxValue;
+                value = value || syncDate(new Date());
+                if (minValue && minValue > value) {
+                    value = minValue;
+                }
+                else if (maxValue && maxValue < value) {
+                    value = maxValue;
+                }
+                return value;
+            },
         });
     }
 
@@ -131051,7 +131219,7 @@ define(['exports'], function (exports) { 'use strict';
                 }
             ],
             beforeRender: function () {
-                var me = this, today = Ext.Date.format(new Date(), me.format);
+                var me = this, today = Ext.Date.format(syncDate(new Date()), me.format);
                 this.superclass.beforeRender.call(this);
                 function handleInput(extHandle, $input) {
                     var $dom = $(extHandle.el.dom);
@@ -131270,7 +131438,7 @@ define(['exports'], function (exports) { 'use strict';
             selectToday: function () {
                 var me = this, btn = me.todayBtn, handler = me.handler;
                 if (btn && !btn.disabled) {
-                    me.value = new Date();
+                    me.value = syncDate(new Date());
                     me.update(me.value);
                     me.fireEvent('select', me, me.value);
                     if (handler) {
@@ -131341,7 +131509,7 @@ define(['exports'], function (exports) { 'use strict';
                     var value = this.getRawValue();
                     if (!value) {
                         // 没填内容的时候,自动设置当前时间
-                        this.setValue(Ext.util.Format.date(new Date(), this.format));
+                        this.setValue(Ext.util.Format.date(syncDate(new Date()), this.format));
                     }
                 };
                 this.on({
@@ -131389,7 +131557,7 @@ define(['exports'], function (exports) { 'use strict';
             },
             onExpand: function () {
                 var strValue = this.getValue();
-                var value = Ext.Date.clearTime(new Date());
+                var value;
                 if (/^\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d$/.test(strValue)) {
                     value = new Date(parseInt(strValue.substr(0, 4)), parseInt(strValue.substr(5, 2)) - 1, parseInt(strValue.substr(8, 2)), parseInt(strValue.substr(11, 2)), parseInt(strValue.substr(14, 2)), parseInt(strValue.substr(17, 2)));
                 }
@@ -131397,8 +131565,7 @@ define(['exports'], function (exports) { 'use strict';
                     value = new Date(parseInt(strValue.substr(0, 4)), parseInt(strValue.substr(5, 2)) - 1, parseInt(strValue.substr(8, 2)));
                 }
                 else {
-                    // value = Ext.Date.clearTime(new Date())
-                    value = new Date();
+                    value = syncDate(new Date());
                 }
                 this.picker.setValue(value);
             },
@@ -132480,6 +132647,7 @@ define(['exports'], function (exports) { 'use strict';
         initButton();
         initStores();
         initSearch();
+        initMultipleSearch();
         initDate();
         initDateTimePicker();
         initDateTime();

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/yvan-ext.js.map