meixioacomponent 1.1.49 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/lib/components/index.d.ts +1 -1
  2. package/lib/components/index.d.ts.map +1 -1
  3. package/lib/components/index.js +3 -3
  4. package/lib/config/use/UseImg.d.ts.map +1 -1
  5. package/lib/config/use/UseImg.js +1 -0
  6. package/lib/meixioacomponent.common.js +17531 -38668
  7. package/lib/meixioacomponent.umd.js +17584 -38721
  8. package/lib/meixioacomponent.umd.min.js +6 -159
  9. package/lib/style/font-family.less +2 -1
  10. package/lib/style/index.less +9 -2
  11. package/lib/style/meixioacomponenticonfont/TCloudNumberVF.ttf +0 -0
  12. package/lib/style/tableStyle.less +15 -13
  13. package/lib/style/tdesignStyle.less +9 -0
  14. package/lib/style/variables.less +1 -1
  15. package/package.json +3 -3
  16. package/packages/components/base/baseAppendix/baseAppendix.vue +12 -11
  17. package/packages/components/base/baseArea/baseArea.vue +49 -54
  18. package/packages/components/base/baseAvatar/baseAvatar.vue +16 -14
  19. package/packages/components/base/baseButton/baseButton.vue +80 -0
  20. package/packages/components/base/baseButton/index.js +6 -0
  21. package/packages/components/base/baseButtonHandle/baseButtonHandle.vue +36 -4
  22. package/packages/components/base/baseDialog/index.vue +131 -102
  23. package/packages/components/base/baseDialogTable/dialogTable.vue +1 -0
  24. package/packages/components/base/baseDrawer/index.vue +119 -89
  25. package/packages/components/base/baseEdito/baseEdito.vue +56 -50
  26. package/packages/components/base/baseFixedHeader/baseFixedHeader.vue +44 -37
  27. package/packages/components/base/baseImageViewer/image-viewer.vue +29 -311
  28. package/packages/components/base/baseImg/baseImg.vue +8 -7
  29. package/packages/components/base/baseInforWrap/baseInforWrap.vue +14 -7
  30. package/packages/components/base/baseLineInfoItem/baseLineInfoItem.vue +4 -4
  31. package/packages/components/base/baseList/index.vue +10 -23
  32. package/packages/components/base/baseMoverVerifiBar/baseMoverVerifiBar.vue +7 -13
  33. package/packages/components/base/baseNumberInput/index.vue +42 -158
  34. package/packages/components/base/basePagination/index.vue +24 -31
  35. package/packages/components/base/basePlainTable/basePlainTable.vue +89 -183
  36. package/packages/components/base/basePopoverButton/index.vue +45 -36
  37. package/packages/components/base/baseSection/baseSection.vue +17 -8
  38. package/packages/components/base/baseSingleImgUpload/index.vue +2 -2
  39. package/packages/components/base/baseSkeleton/baseSkeleton.vue +0 -1
  40. package/packages/components/base/baseStoreSelect/index.vue +48 -64
  41. package/packages/components/base/baseTag/index.vue +12 -96
  42. package/packages/components/base/baseText/index.vue +66 -79
  43. package/packages/components/base/baseTimeLine/baseTimeLineLeft.vue +1 -1
  44. package/packages/components/base/baseTimeLine/baseTimeLineRight.vue +1 -1
  45. package/packages/components/base/baseTimeTypeSelect/base_time_type_select.vue +73 -78
  46. package/packages/components/base/baseToggle/toggle.vue +28 -48
  47. package/packages/components/base/baseTreeSelect/index.vue +20 -147
  48. package/packages/components/base/baseUpload/baseUploadItem.vue +74 -77
  49. package/packages/components/base/baseUpload/mixins.js +0 -1
  50. package/packages/components/base/baseUpload/uploadMediaView.vue +14 -13
  51. package/packages/components/base/baseUploadImgAndName/index.vue +28 -11
  52. package/packages/components/base/baseUploadTemplate/index.vue +27 -11
  53. package/packages/components/base/baseVideo/index.vue +9 -7
  54. package/packages/components/base/upload/upload.vue +17 -14
  55. package/packages/components/base/upload/uploadItem.vue +40 -46
  56. package/packages/components/dialogCache/index.vue +30 -24
  57. package/packages/components/index.js +3 -3
  58. package/packages/components/index.ts +4 -3
  59. package/packages/components/mixins/tableSectionMixins.js +0 -12
  60. package/packages/components/proForm/dialogForm/baseDialogForm.vue +17 -14
  61. package/packages/components/proForm/proForm/proFormItem/pro_form_item.vue +95 -79
  62. package/packages/components/proForm/proForm/pro_form.vue +47 -52
  63. package/packages/components/proPageTable/oaProTableSearch/oa_pro-table-search.vue +2 -2
  64. package/packages/components/proPageTable/oaProTableSearch/oa_pro_screen.vue +19 -10
  65. package/packages/components/proPageTable/oaProTableSearch/oa_pro_screen_item.vue +28 -27
  66. package/packages/components/proPageTable/oa_pro_colum_config.vue +8 -10
  67. package/packages/components/proPageTable/oa_pro_footer.vue +15 -15
  68. package/packages/components/proPageTable/oa_pro_table-header.vue +19 -31
  69. package/packages/components/proPageTable/oa_pro_table.vue +208 -284
  70. package/packages/components/proPageTable/oa_pro_table_check_handle_bar.vue +28 -16
  71. package/packages/components/searchHeader/searchHeader.vue +16 -17
  72. package/packages/components/style/font-family.less +2 -1
  73. package/packages/components/style/index.less +9 -2
  74. package/packages/components/style/meixioacomponenticonfont/TCloudNumberVF.ttf +0 -0
  75. package/packages/components/style/tableStyle.less +15 -13
  76. package/packages/components/style/tdesignStyle.less +9 -0
  77. package/packages/components/style/variables.less +1 -1
  78. package/packages/config/use/UseImg.js +1 -0
  79. package/packages/config/use/UseImg.ts +1 -0
  80. package/packages/utils/upload.js +61 -72
  81. package/packages/utils/utils.js +316 -276
  82. package/lib/fonts/element-icons.f1a45d74.ttf +0 -0
  83. package/lib/fonts/element-icons.ff18efd1.woff +0 -0
  84. package/lib/style/element/common_class.less +0 -3
  85. package/lib/style/element/fonts/element-icons.ttf +0 -0
  86. package/lib/style/element/fonts/element-icons.woff +0 -0
  87. package/lib/style/element/index.css +0 -30219
  88. package/packages/components/base/elDatePicker/basic/date-table.vue +0 -441
  89. package/packages/components/base/elDatePicker/basic/month-table.vue +0 -269
  90. package/packages/components/base/elDatePicker/basic/time-spinner.vue +0 -304
  91. package/packages/components/base/elDatePicker/basic/year-table.vue +0 -111
  92. package/packages/components/base/elDatePicker/index.js +0 -6
  93. package/packages/components/base/elDatePicker/index.vue +0 -28
  94. package/packages/components/base/elDatePicker/panel/date-range.vue +0 -680
  95. package/packages/components/base/elDatePicker/panel/date.vue +0 -609
  96. package/packages/components/base/elDatePicker/panel/month-range.vue +0 -289
  97. package/packages/components/base/elDatePicker/panel/time-range.vue +0 -248
  98. package/packages/components/base/elDatePicker/panel/time-select.vue +0 -178
  99. package/packages/components/base/elDatePicker/panel/time.vue +0 -186
  100. package/packages/components/base/elDatePicker/picker/date-picker.js +0 -55
  101. package/packages/components/base/elDatePicker/picker/time-picker.js +0 -39
  102. package/packages/components/base/elDatePicker/picker/time-select.js +0 -21
  103. package/packages/components/base/elDatePicker/picker.vue +0 -956
  104. package/packages/components/style/element/common_class.less +0 -3
  105. package/packages/components/style/element/fonts/element-icons.ttf +0 -0
  106. package/packages/components/style/element/fonts/element-icons.woff +0 -0
  107. package/packages/components/style/element/index.css +0 -30219
@@ -1,956 +0,0 @@
1
- <template>
2
- <el-input
3
- class="el-date-editor"
4
- :class="'el-date-editor--' + mxType"
5
- :readonly="!editable || readonly || mxType === 'dates' || mxType === 'week' || mxType === 'years' || mxType === 'months'"
6
- :disabled="pickerDisabled"
7
- :size="pickerSize"
8
- :name="name"
9
- v-bind="firstInputId"
10
- v-if="!ranged"
11
- v-clickoutside="handleClose"
12
- :placeholder="placeholder"
13
- @focus="handleFocus"
14
- @keydown.native="handleKeydown"
15
- :value="displayValue"
16
- @input="value => userInput = value"
17
- @change="handleChange"
18
- @mouseenter.native="handleMouseEnter"
19
- @mouseleave.native="showClose = false"
20
- :validateEvent="false"
21
- ref="reference">
22
- <i slot="prefix"
23
- class="el-input__icon"
24
- :class="triggerClass"
25
- @click="handleFocus">
26
- </i>
27
- <i slot="suffix"
28
- class="el-input__icon"
29
- @click="handleClickIcon"
30
- :class="[showClose ? '' + clearIcon : '']"
31
- v-if="haveTrigger">
32
- </i>
33
- </el-input>
34
- <div
35
- class="el-date-editor el-range-editor el-input__inner"
36
- :class="[
37
- 'el-date-editor--' + mxType,
38
- pickerSize ? `el-range-editor--${ pickerSize }` : '',
39
- pickerDisabled ? 'is-disabled' : '',
40
- pickerVisible ? 'is-active' : ''
41
- ]"
42
- @click="handleRangeClick"
43
- @mouseenter="handleMouseEnter"
44
- @mouseleave="showClose = false"
45
- @keydown="handleKeydown"
46
- ref="reference"
47
- v-clickoutside="handleClose"
48
- v-else>
49
- <i :class="['el-input__icon', 'el-range__icon', triggerClass]"></i>
50
- <input
51
- autocomplete="off"
52
- :placeholder="startPlaceholder"
53
- :value="displayValue && displayValue[0]"
54
- :disabled="pickerDisabled"
55
- v-bind="firstInputId"
56
- :readonly="!editable || readonly"
57
- :name="name && name[0]"
58
- @input="handleStartInput"
59
- @change="handleStartChange"
60
- @focus="handleFocus"
61
- class="el-range-input">
62
- <slot name="range-separator">
63
- <span class="el-range-separator">{{ rangeSeparator }}</span>
64
- </slot>
65
- <input
66
- autocomplete="off"
67
- :placeholder="endPlaceholder"
68
- :value="displayValue && displayValue[1]"
69
- :disabled="pickerDisabled"
70
- v-bind="secondInputId"
71
- :readonly="!editable || readonly"
72
- :name="name && name[1]"
73
- @input="handleEndInput"
74
- @change="handleEndChange"
75
- @focus="handleFocus"
76
- class="el-range-input">
77
- <i
78
- @click="handleClickIcon"
79
- v-if="haveTrigger"
80
- :class="[showClose ? '' + clearIcon : '']"
81
- class="el-input__icon el-range__close-icon">
82
- </i>
83
- </div>
84
- </template>
85
-
86
- <script>
87
- import Vue from 'vue';
88
- import Clickoutside from 'element-ui/src/utils/clickoutside';
89
- import { formatDate, parseDate, isDateObject, getWeekNumber } from 'element-ui/src/utils/date-util';
90
- import Popper from 'element-ui/src/utils/vue-popper';
91
- import Emitter from 'element-ui/src/mixins/emitter';
92
- import ElInput from 'element-ui/packages/input';
93
- import merge from 'element-ui/src/utils/merge';
94
-
95
- const NewPopper = {
96
- props: {
97
- appendToBody: Popper.props.appendToBody,
98
- offset: Popper.props.offset,
99
- boundariesPadding: Popper.props.boundariesPadding,
100
- arrowOffset: Popper.props.arrowOffset,
101
- transformOrigin: Popper.props.transformOrigin
102
- },
103
- methods: Popper.methods,
104
- data() {
105
- return merge({ visibleArrow: true }, Popper.data);
106
- },
107
- beforeDestroy: Popper.beforeDestroy
108
- };
109
-
110
- const DEFAULT_FORMATS = {
111
- date: 'yyyy-MM-dd',
112
- month: 'yyyy-MM',
113
- months: 'yyyy-MM',
114
- datetime: 'yyyy-MM-dd HH:mm:ss',
115
- time: 'HH:mm:ss',
116
- week: 'yyyywWW',
117
- timerange: 'HH:mm:ss',
118
- daterange: 'yyyy-MM-dd',
119
- monthrange: 'yyyy-MM',
120
- datetimerange: 'yyyy-MM-dd HH:mm:ss',
121
- year: 'yyyy',
122
- years: 'yyyy'
123
- };
124
- const HAVE_TRIGGER_TYPES = [
125
- 'date',
126
- 'datetime',
127
- 'time',
128
- 'time-select',
129
- 'week',
130
- 'month',
131
- 'year',
132
- 'daterange',
133
- 'monthrange',
134
- 'timerange',
135
- 'datetimerange',
136
- 'dates',
137
- 'months',
138
- 'years'
139
- ];
140
- const DATE_FORMATTER = function(value, format) {
141
- if (format === 'timestamp') return value.getTime();
142
- return formatDate(value, format);
143
- };
144
- const DATE_PARSER = function(text, format) {
145
- if (format === 'timestamp') return new Date(Number(text));
146
- return parseDate(text, format);
147
- };
148
- const RANGE_FORMATTER = function(value, format) {
149
- if (Array.isArray(value) && value.length === 2) {
150
- const start = value[0];
151
- const end = value[1];
152
-
153
- if (start && end) {
154
- return [DATE_FORMATTER(start, format), DATE_FORMATTER(end, format)];
155
- }
156
- }
157
- return '';
158
- };
159
- const RANGE_PARSER = function(array, format, separator) {
160
- if (!Array.isArray(array)) {
161
- array = array.split(separator);
162
- }
163
- if (array.length === 2) {
164
- const range1 = array[0];
165
- const range2 = array[1];
166
-
167
- return [DATE_PARSER(range1, format), DATE_PARSER(range2, format)];
168
- }
169
- return [];
170
- };
171
- const TYPE_VALUE_RESOLVER_MAP = {
172
- default: {
173
- formatter(value) {
174
- if (!value) return '';
175
- return '' + value;
176
- },
177
- parser(text) {
178
- if (text === undefined || text === '') return null;
179
- return text;
180
- }
181
- },
182
- week: {
183
- formatter(value, format) {
184
- let week = getWeekNumber(value);
185
- let month = value.getMonth();
186
- const trueDate = new Date(value);
187
- if (week === 1 && month === 11) {
188
- trueDate.setHours(0, 0, 0, 0);
189
- trueDate.setDate(trueDate.getDate() + 3 - (trueDate.getDay() + 6) % 7);
190
- }
191
- let date = formatDate(trueDate, format);
192
-
193
- date = /WW/.test(date)
194
- ? date.replace(/WW/, week < 10 ? '0' + week : week)
195
- : date.replace(/W/, week);
196
- return date;
197
- },
198
- parser(text, format) {
199
- // parse as if a normal date
200
- return TYPE_VALUE_RESOLVER_MAP.date.parser(text, format);
201
- }
202
- },
203
- date: {
204
- formatter: DATE_FORMATTER,
205
- parser: DATE_PARSER
206
- },
207
- datetime: {
208
- formatter: DATE_FORMATTER,
209
- parser: DATE_PARSER
210
- },
211
- daterange: {
212
- formatter: RANGE_FORMATTER,
213
- parser: RANGE_PARSER
214
- },
215
- monthrange: {
216
- formatter: RANGE_FORMATTER,
217
- parser: RANGE_PARSER
218
- },
219
- datetimerange: {
220
- formatter: RANGE_FORMATTER,
221
- parser: RANGE_PARSER
222
- },
223
- timerange: {
224
- formatter: RANGE_FORMATTER,
225
- parser: RANGE_PARSER
226
- },
227
- time: {
228
- formatter: DATE_FORMATTER,
229
- parser: DATE_PARSER
230
- },
231
- month: {
232
- formatter: DATE_FORMATTER,
233
- parser: DATE_PARSER
234
- },
235
- year: {
236
- formatter: DATE_FORMATTER,
237
- parser: DATE_PARSER
238
- },
239
- number: {
240
- formatter(value) {
241
- if (!value) return '';
242
- return '' + value;
243
- },
244
- parser(text) {
245
- let result = Number(text);
246
-
247
- if (!isNaN(text)) {
248
- return result;
249
- } else {
250
- return null;
251
- }
252
- }
253
- },
254
- dates: {
255
- formatter(value, format) {
256
- return value.map(date => DATE_FORMATTER(date, format));
257
- },
258
- parser(value, format) {
259
- return (typeof value === 'string' ? value.split(', ') : value)
260
- .map(date => date instanceof Date ? date : DATE_PARSER(date, format));
261
- }
262
- },
263
- months: {
264
- formatter(value, format) {
265
- return value.map(date => DATE_FORMATTER(date, format));
266
- },
267
- parser(value, format) {
268
- return (typeof value === 'string' ? value.split(', ') : value)
269
- .map(date => date instanceof Date ? date : DATE_PARSER(date, format));
270
- }
271
- },
272
- years: {
273
- formatter(value, format) {
274
- return value.map(date => DATE_FORMATTER(date, format));
275
- },
276
- parser(value, format) {
277
- return (typeof value === 'string' ? value.split(', ') : value)
278
- .map(date => date instanceof Date ? date : DATE_PARSER(date, format));
279
- }
280
- }
281
- };
282
- const PLACEMENT_MAP = {
283
- left: 'bottom-start',
284
- center: 'bottom',
285
- right: 'bottom-end'
286
- };
287
-
288
- const parseAsFormatAndType = (value, customFormat, type, rangeSeparator = '-') => {
289
- if (!value) return null;
290
- const parser = (
291
- TYPE_VALUE_RESOLVER_MAP[type] ||
292
- TYPE_VALUE_RESOLVER_MAP['default']
293
- ).parser;
294
- const format = customFormat || DEFAULT_FORMATS[type];
295
- return parser(value, format, rangeSeparator);
296
- };
297
-
298
- const formatAsFormatAndType = (value, customFormat, type) => {
299
- if (!value) return null;
300
- const formatter = (
301
- TYPE_VALUE_RESOLVER_MAP[type] ||
302
- TYPE_VALUE_RESOLVER_MAP['default']
303
- ).formatter;
304
- const format = customFormat || DEFAULT_FORMATS[type];
305
- return formatter(value, format);
306
- };
307
-
308
- /*
309
- * Considers:
310
- * 1. Date object
311
- * 2. date string
312
- * 3. array of 1 or 2
313
- */
314
- const valueEquals = function(a, b) {
315
- // considers Date object and string
316
- const dateEquals = function(a, b) {
317
- const aIsDate = a instanceof Date;
318
- const bIsDate = b instanceof Date;
319
- if (aIsDate && bIsDate) {
320
- return a.getTime() === b.getTime();
321
- }
322
- if (!aIsDate && !bIsDate) {
323
- return a === b;
324
- }
325
- return false;
326
- };
327
-
328
- const aIsArray = a instanceof Array;
329
- const bIsArray = b instanceof Array;
330
- if (aIsArray && bIsArray) {
331
- if (a.length !== b.length) {
332
- return false;
333
- }
334
- return a.every((item, index) => dateEquals(item, b[index]));
335
- }
336
- if (!aIsArray && !bIsArray) {
337
- return dateEquals(a, b);
338
- }
339
- return false;
340
- };
341
-
342
- const isString = function(val) {
343
- return typeof val === 'string' || val instanceof String;
344
- };
345
-
346
- const validator = function(val) {
347
- // either: String, Array of String, null / undefined
348
- return (
349
- val === null ||
350
- val === undefined ||
351
- isString(val) ||
352
- (Array.isArray(val) && val.length === 2 && val.every(isString))
353
- );
354
- };
355
-
356
- export default {
357
- mixins: [Emitter, NewPopper],
358
-
359
- inject: {
360
- elForm: {
361
- default: ''
362
- },
363
- elFormItem: {
364
- default: ''
365
- }
366
- },
367
-
368
- props: {
369
- size: String,
370
- format: String,
371
- valueFormat: String,
372
- readonly: Boolean,
373
- placeholder: String,
374
- startPlaceholder: String,
375
- endPlaceholder: String,
376
- prefixIcon: String,
377
- clearIcon: {
378
- type: String,
379
- default: 'el-icon-circle-close'
380
- },
381
- name: {
382
- default: '',
383
- validator
384
- },
385
- disabled: Boolean,
386
- clearable: {
387
- type: Boolean,
388
- default: true
389
- },
390
- id: {
391
- default: '',
392
- validator
393
- },
394
- popperClass: String,
395
- editable: {
396
- type: Boolean,
397
- default: true
398
- },
399
- align: {
400
- type: String,
401
- default: 'left'
402
- },
403
- value: {},
404
- defaultValue: {},
405
- defaultTime: {},
406
- rangeSeparator: {
407
- default: '-'
408
- },
409
- pickerOptions: {},
410
- unlinkPanels: Boolean,
411
- validateEvent: {
412
- type: Boolean,
413
- default: true
414
- },
415
- },
416
-
417
- components: { ElInput },
418
-
419
- directives: { Clickoutside },
420
-
421
- data() {
422
- return {
423
- pickerVisible: false,
424
- showClose: false,
425
- userInput: null,
426
- valueOnOpen: null, // value when picker opens, used to determine whether to emit change
427
- unwatchPickerOptions: null
428
- };
429
- },
430
-
431
- watch: {
432
- pickerVisible(val) {
433
- if (this.readonly || this.pickerDisabled) return;
434
- if (val) {
435
- this.showPicker();
436
- this.valueOnOpen = Array.isArray(this.value) ? [...this.value] : this.value;
437
- } else {
438
- this.hidePicker();
439
- this.emitChange(this.value);
440
- this.userInput = null;
441
- if (this.validateEvent) {
442
- this.dispatch('ElFormItem', 'el.form.blur');
443
- }
444
- this.$emit('blur', this);
445
- this.blur();
446
- }
447
- },
448
- parsedValue: {
449
- immediate: true,
450
- handler(val) {
451
- if (this.picker) {
452
- this.picker.value = val;
453
- }
454
- }
455
- },
456
- defaultValue(val) {
457
- // NOTE: should eventually move to jsx style picker + panel ?
458
- if (this.picker) {
459
- this.picker.defaultValue = val;
460
- }
461
- },
462
- value(val, oldVal) {
463
- if (!valueEquals(val, oldVal) && !this.pickerVisible && this.validateEvent) {
464
- this.dispatch('ElFormItem', 'el.form.change', val);
465
- }
466
- }
467
- },
468
-
469
- computed: {
470
- ranged() {
471
- return this.mxType.indexOf('range') > -1;
472
- },
473
-
474
- reference() {
475
- const reference = this.$refs.reference;
476
- return reference.$el || reference;
477
- },
478
-
479
- refInput() {
480
- if (this.reference) {
481
- return [].slice.call(this.reference.querySelectorAll('input'));
482
- }
483
- return [];
484
- },
485
-
486
- valueIsEmpty() {
487
- const val = this.value;
488
- if (Array.isArray(val)) {
489
- for (let i = 0, len = val.length; i < len; i++) {
490
- if (val[i]) {
491
- return false;
492
- }
493
- }
494
- } else {
495
- if (val) {
496
- return false;
497
- }
498
- }
499
- return true;
500
- },
501
-
502
- triggerClass() {
503
- return this.prefixIcon || (this.mxType.indexOf('time') !== -1 ? 'el-icon-time' : 'el-icon-date');
504
- },
505
-
506
- selectionMode() {
507
- if (this.mxType === 'week') {
508
- return 'week';
509
- } else if (this.mxType === 'month') {
510
- return 'month';
511
- } else if (this.mxType === 'year') {
512
- return 'year';
513
- } else if (this.mxType === 'dates') {
514
- return 'dates';
515
- } else if (this.mxType === 'months') {
516
- return 'months';
517
- } else if (this.mxType === 'years') {
518
- return 'years';
519
- }
520
-
521
- return 'day';
522
- },
523
-
524
- haveTrigger() {
525
- if (typeof this.showTrigger !== 'undefined') {
526
- return this.showTrigger;
527
- }
528
- return HAVE_TRIGGER_TYPES.indexOf(this.mxType) !== -1;
529
- },
530
-
531
- displayValue() {
532
- const formattedValue = formatAsFormatAndType(this.parsedValue, this.format, this.mxType, this.rangeSeparator);
533
- if (Array.isArray(this.userInput)) {
534
- return [
535
- this.userInput[0] || (formattedValue && formattedValue[0]) || '',
536
- this.userInput[1] || (formattedValue && formattedValue[1]) || ''
537
- ];
538
- } else if (this.userInput !== null) {
539
- return this.userInput;
540
- } else if (formattedValue) {
541
- return (this.mxType === 'dates' || this.mxType === 'years' || this.mxType === 'months')
542
- ? formattedValue.join(', ')
543
- : formattedValue;
544
- } else {
545
- return '';
546
- }
547
- },
548
-
549
- parsedValue() {
550
- if (!this.value) return this.value; // component value is not set
551
- if (this.mxType === 'time-select') return this.value; // time-select does not require parsing, this might change in next major version
552
-
553
- const valueIsDateObject = isDateObject(this.value) || (Array.isArray(this.value) && this.value.every(isDateObject));
554
- if (valueIsDateObject) {
555
- return this.value;
556
- }
557
-
558
- if (this.valueFormat) {
559
- return parseAsFormatAndType(this.value, this.valueFormat, this.mxType, this.rangeSeparator) || this.value;
560
- }
561
-
562
- // NOTE: deal with common but incorrect usage, should remove in next major version
563
- // user might provide string / timestamp without value-format, coerce them into date (or array of date)
564
- return Array.isArray(this.value) ? this.value.map(val => new Date(val)) : new Date(this.value);
565
- },
566
-
567
- _elFormItemSize() {
568
- return (this.elFormItem || {}).elFormItemSize;
569
- },
570
-
571
- pickerSize() {
572
- return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
573
- },
574
-
575
- pickerDisabled() {
576
- return this.disabled || (this.elForm || {}).disabled;
577
- },
578
-
579
- firstInputId() {
580
- const obj = {};
581
- let id;
582
- if (this.ranged) {
583
- id = this.id && this.id[0];
584
- } else {
585
- id = this.id;
586
- }
587
- if (id) obj.id = id;
588
- return obj;
589
- },
590
-
591
- secondInputId() {
592
- const obj = {};
593
- let id;
594
- if (this.ranged) {
595
- id = this.id && this.id[1];
596
- }
597
- if (id) obj.id = id;
598
- return obj;
599
- }
600
- },
601
-
602
- created() {
603
- // vue-popper
604
- this.popperOptions = {
605
- boundariesPadding: 0,
606
- gpuAcceleration: false
607
- };
608
- this.placement = PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left;
609
-
610
- this.$on('fieldReset', this.handleFieldReset);
611
- },
612
-
613
- methods: {
614
- focus() {
615
- if (!this.ranged) {
616
- this.$refs.reference.focus();
617
- } else {
618
- this.handleFocus();
619
- }
620
- },
621
-
622
- blur() {
623
- this.refInput.forEach(input => input.blur());
624
- },
625
-
626
- // {parse, formatTo} Value deals maps component value with internal Date
627
- parseValue(value) {
628
- const isParsed = isDateObject(value) || (Array.isArray(value) && value.every(isDateObject));
629
- if (this.valueFormat && !isParsed) {
630
- return parseAsFormatAndType(value, this.valueFormat, this.mxType, this.rangeSeparator) || value;
631
- } else {
632
- return value;
633
- }
634
- },
635
-
636
- formatToValue(date) {
637
- const isFormattable = isDateObject(date) || (Array.isArray(date) && date.every(isDateObject));
638
- if (this.valueFormat && isFormattable) {
639
- return formatAsFormatAndType(date, this.valueFormat, this.mxType, this.rangeSeparator);
640
- } else {
641
- return date;
642
- }
643
- },
644
-
645
- // {parse, formatTo} String deals with user input
646
- parseString(value) {
647
- const type = Array.isArray(value) ? this.mxType : this.mxType.replace('range', '');
648
- return parseAsFormatAndType(value, this.format, type);
649
- },
650
-
651
- formatToString(value) {
652
- const type = Array.isArray(value) ? this.mxType : this.mxType.replace('range', '');
653
- return formatAsFormatAndType(value, this.format, type);
654
- },
655
-
656
- handleMouseEnter() {
657
- if (this.readonly || this.pickerDisabled) return;
658
- if (!this.valueIsEmpty && this.clearable) {
659
- this.showClose = true;
660
- }
661
- },
662
-
663
- handleChange() {
664
- if (this.userInput) {
665
- const value = this.parseString(this.displayValue);
666
- if (value) {
667
- this.picker.value = value;
668
- if (this.isValidValue(value)) {
669
- this.emitInput(value);
670
- this.userInput = null;
671
- }
672
- }
673
- }
674
- if (this.userInput === '') {
675
- this.emitInput(null);
676
- this.emitChange(null);
677
- this.userInput = null;
678
- }
679
- },
680
-
681
- handleStartInput(event) {
682
- if (this.userInput) {
683
- this.userInput = [event.target.value, this.userInput[1]];
684
- } else {
685
- this.userInput = [event.target.value, null];
686
- }
687
- },
688
-
689
- handleEndInput(event) {
690
- if (this.userInput) {
691
- this.userInput = [this.userInput[0], event.target.value];
692
- } else {
693
- this.userInput = [null, event.target.value];
694
- }
695
- },
696
-
697
- handleStartChange(event) {
698
- const value = this.parseString(this.userInput && this.userInput[0]);
699
- if (value) {
700
- this.userInput = [this.formatToString(value), this.displayValue[1]];
701
- const newValue = [value, this.picker.value && this.picker.value[1]];
702
- this.picker.value = newValue;
703
- if (this.isValidValue(newValue)) {
704
- this.emitInput(newValue);
705
- this.userInput = null;
706
- }
707
- }
708
- },
709
-
710
- handleEndChange(event) {
711
- const value = this.parseString(this.userInput && this.userInput[1]);
712
- if (value) {
713
- this.userInput = [this.displayValue[0], this.formatToString(value)];
714
- const newValue = [this.picker.value && this.picker.value[0], value];
715
- this.picker.value = newValue;
716
- if (this.isValidValue(newValue)) {
717
- this.emitInput(newValue);
718
- this.userInput = null;
719
- }
720
- }
721
- },
722
-
723
- handleClickIcon(event) {
724
- if (this.readonly || this.pickerDisabled) return;
725
- if (this.showClose) {
726
- this.valueOnOpen = this.value;
727
- event.stopPropagation();
728
- this.emitInput(null);
729
- this.emitChange(null);
730
- this.showClose = false;
731
- if (this.picker && typeof this.picker.handleClear === 'function') {
732
- this.picker.handleClear();
733
- }
734
- } else {
735
- this.pickerVisible = !this.pickerVisible;
736
- }
737
- },
738
-
739
- handleClose() {
740
- if (!this.pickerVisible) return;
741
- this.pickerVisible = false;
742
-
743
- if (this.mxType === 'dates' || this.mxType === 'years' || this.mxType === 'months') {
744
- // restore to former value
745
- const oldValue = parseAsFormatAndType(this.valueOnOpen, this.valueFormat, this.mxType, this.rangeSeparator) || this.valueOnOpen;
746
- this.emitInput(oldValue);
747
- }
748
- },
749
-
750
- handleFieldReset(initialValue) {
751
- this.userInput = initialValue === '' ? null : initialValue;
752
- },
753
-
754
- handleFocus() {
755
- const type = this.mxType;
756
-
757
- if (HAVE_TRIGGER_TYPES.indexOf(type) !== -1 && !this.pickerVisible) {
758
- this.pickerVisible = true;
759
- }
760
- this.$emit('focus', this);
761
- },
762
-
763
- handleKeydown(event) {
764
- const keyCode = event.keyCode;
765
-
766
- // ESC
767
- if (keyCode === 27) {
768
- this.pickerVisible = false;
769
- event.stopPropagation();
770
- return;
771
- }
772
-
773
- // Tab
774
- if (keyCode === 9) {
775
- if (!this.ranged) {
776
- this.handleChange();
777
- this.pickerVisible = this.picker.visible = false;
778
- this.blur();
779
- event.stopPropagation();
780
- } else {
781
- // user may change focus between two input
782
- setTimeout(() => {
783
- if (this.refInput.indexOf(document.activeElement) === -1) {
784
- this.pickerVisible = false;
785
- this.blur();
786
- event.stopPropagation();
787
- }
788
- }, 0);
789
- }
790
- return;
791
- }
792
-
793
- // Enter
794
- if (keyCode === 13) {
795
- if (this.userInput === '' || this.isValidValue(this.parseString(this.displayValue))) {
796
- this.handleChange();
797
- this.pickerVisible = this.picker.visible = false;
798
- this.blur();
799
- }
800
- event.stopPropagation();
801
- return;
802
- }
803
-
804
- // if user is typing, do not let picker handle key input
805
- if (this.userInput) {
806
- event.stopPropagation();
807
- return;
808
- }
809
-
810
- // delegate other keys to panel
811
- if (this.picker && this.picker.handleKeydown) {
812
- this.picker.handleKeydown(event);
813
- }
814
- },
815
-
816
- handleRangeClick() {
817
- const type = this.mxType;
818
-
819
- if (HAVE_TRIGGER_TYPES.indexOf(type) !== -1 && !this.pickerVisible) {
820
- this.pickerVisible = true;
821
- }
822
- this.$emit('focus', this);
823
- },
824
-
825
- hidePicker() {
826
- if (this.picker) {
827
- this.picker.resetView && this.picker.resetView();
828
- this.pickerVisible = this.picker.visible = false;
829
- this.destroyPopper();
830
- }
831
- },
832
-
833
- showPicker() {
834
- if (this.$isServer) return;
835
- if (!this.picker) {
836
- this.mountPicker();
837
- }
838
- this.pickerVisible = this.picker.visible = true;
839
-
840
- this.updatePopper();
841
-
842
- this.picker.value = this.parsedValue;
843
- this.picker.resetView && this.picker.resetView();
844
-
845
- this.$nextTick(() => {
846
- this.picker.adjustSpinners && this.picker.adjustSpinners();
847
- });
848
- },
849
-
850
- mountPicker() {
851
- this.picker = new Vue(this.panel).$mount();
852
- this.picker.defaultValue = this.defaultValue;
853
- this.picker.defaultTime = this.defaultTime;
854
- this.picker.popperClass = this.popperClass;
855
- this.popperElm = this.picker.$el;
856
- this.picker.width = this.reference.getBoundingClientRect().width;
857
- this.picker.showTime = this.mxType === 'datetime' || this.mxType === 'datetimerange';
858
- this.picker.selectionMode = this.selectionMode;
859
- this.picker.unlinkPanels = this.unlinkPanels;
860
- this.picker.arrowControl = this.arrowControl || this.timeArrowControl || false;
861
- this.$watch('format', (format) => {
862
- this.picker.format = format;
863
- });
864
-
865
- const updateOptions = () => {
866
- const options = this.pickerOptions;
867
-
868
- if (options && options.selectableRange) {
869
- let ranges = options.selectableRange;
870
- const parser = TYPE_VALUE_RESOLVER_MAP.datetimerange.parser;
871
- const format = DEFAULT_FORMATS.timerange;
872
-
873
- ranges = Array.isArray(ranges) ? ranges : [ranges];
874
- this.picker.selectableRange = ranges.map(range => parser(range, format, this.rangeSeparator));
875
- }
876
-
877
- for (const option in options) {
878
- if (options.hasOwnProperty(option) &&
879
- // 忽略 time-picker 的该配置项
880
- option !== 'selectableRange') {
881
- this.picker[option] = options[option];
882
- }
883
- }
884
-
885
- // main format must prevail over undocumented pickerOptions.format
886
- if (this.format) {
887
- this.picker.format = this.format;
888
- }
889
- };
890
- updateOptions();
891
- this.unwatchPickerOptions = this.$watch('pickerOptions', () => updateOptions(), { deep: true });
892
- this.$el.appendChild(this.picker.$el);
893
- this.picker.resetView && this.picker.resetView();
894
-
895
- this.picker.$on('dodestroy', this.doDestroy);
896
- this.picker.$on('pick', (date = '', visible = false) => {
897
- this.userInput = null;
898
- this.pickerVisible = this.picker.visible = visible;
899
- this.emitInput(date);
900
- this.picker.resetView && this.picker.resetView();
901
- });
902
-
903
- this.picker.$on('select-range', (start, end, pos) => {
904
- if (this.refInput.length === 0) return;
905
- if (!pos || pos === 'min') {
906
- this.refInput[0].setSelectionRange(start, end);
907
- this.refInput[0].focus();
908
- } else if (pos === 'max') {
909
- this.refInput[1].setSelectionRange(start, end);
910
- this.refInput[1].focus();
911
- }
912
- });
913
- },
914
-
915
- unmountPicker() {
916
- if (this.picker) {
917
- this.picker.$destroy();
918
- this.picker.$off();
919
- if (typeof this.unwatchPickerOptions === 'function') {
920
- this.unwatchPickerOptions();
921
- }
922
- this.picker.$el.parentNode.removeChild(this.picker.$el);
923
- }
924
- },
925
-
926
- emitChange(val) {
927
- // determine user real change only
928
- if (!valueEquals(val, this.valueOnOpen)) {
929
- this.$emit('change', val);
930
- this.valueOnOpen = val;
931
- if (this.validateEvent) {
932
- this.dispatch('ElFormItem', 'el.form.change', val);
933
- }
934
- }
935
- },
936
-
937
- emitInput(val) {
938
- const formatted = this.formatToValue(val);
939
- if (!valueEquals(this.value, formatted)) {
940
- this.$emit('input', formatted);
941
- }
942
- },
943
-
944
- isValidValue(value) {
945
- if (!this.picker) {
946
- this.mountPicker();
947
- }
948
- if (this.picker.isValidValue) {
949
- return value && this.picker.isValidValue(value);
950
- } else {
951
- return true;
952
- }
953
- }
954
- }
955
- };
956
- </script>