cnhis-design-vue 2.1.52 → 2.1.53

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 (40) hide show
  1. package/CHANGELOG.md +19 -11
  2. package/es/age/index.js +2 -2
  3. package/es/big-table/index.js +125 -71
  4. package/es/big-table/style.css +1 -1
  5. package/es/button/index.js +2 -2
  6. package/es/captcha/index.js +3 -3
  7. package/es/checkbox/index.js +1 -1
  8. package/es/color-picker/index.js +1 -1
  9. package/es/date-picker/index.js +911 -0
  10. package/es/drag-layout/index.js +3 -3
  11. package/es/editor/index.js +1 -1
  12. package/es/fabric-chart/index.js +9 -9
  13. package/es/form-table/index.js +17 -17
  14. package/es/index/index.js +873 -208
  15. package/es/index/style.css +1 -1
  16. package/es/input/index.js +1 -1
  17. package/es/map/index.js +1 -1
  18. package/es/multi-chat/index.js +24 -24
  19. package/es/multi-chat-client/index.js +18 -18
  20. package/es/multi-chat-history/index.js +4 -4
  21. package/es/multi-chat-record/index.js +4 -4
  22. package/es/multi-chat-setting/index.js +20 -20
  23. package/es/multi-chat-sip/index.js +1 -1
  24. package/es/radio/index.js +1 -1
  25. package/es/scale-view/index.js +24 -24
  26. package/es/select/index.js +4 -4
  27. package/es/select-label/index.js +3 -3
  28. package/es/select-person/index.js +2 -2
  29. package/es/shortcut-setter/index.js +2 -2
  30. package/es/table-filter/index.js +21 -21
  31. package/es/tag/index.js +1 -1
  32. package/es/verification-code/index.js +2 -2
  33. package/lib/cui.common.js +1337 -719
  34. package/lib/cui.umd.js +1337 -719
  35. package/lib/cui.umd.min.js +13 -13
  36. package/package.json +1 -1
  37. package/packages/big-table/src/BigTable.vue +59 -17
  38. package/packages/big-table/src/utils/bigTableProps.js +12 -8
  39. package/packages/date-picker/index.js +2 -0
  40. package/packages/date-picker/src/utils/index.js +374 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
- "version": "2.1.52",
3
+ "version": "2.1.53",
4
4
  "description": "前端业务UI库",
5
5
  "keyword": "cnhis-design-vue vue cnhis",
6
6
  "homepage": "http://dv.cnhis.com/",
@@ -98,6 +98,7 @@
98
98
  iconOpen: 'iconfont icon-a-xitongtubiaozhediejian',
99
99
  iconClose: 'iconfont icon-a-xitongtubiaotianjia'
100
100
  }"
101
+ :row-config="{ isCurrent: true }"
101
102
  v-bind="tableAttrs"
102
103
  >
103
104
  <template v-slot:empty>
@@ -2278,6 +2279,10 @@ export default create({
2278
2279
  },
2279
2280
  // 行双击
2280
2281
  rowdblclick({ row, column }) {
2282
+ // 2022/12/12 方晶晶要求 列表相关项在底部展示时, 去除双击事件, 只触发单击事件
2283
+ if (this.aboutPositionBtm) {
2284
+ return false;
2285
+ }
2281
2286
  if (this.isScanMultiTable || this.isInlineOperating) return false;
2282
2287
  if (vexutils.has(row, GROUP_TITLE_KEY)) return false;
2283
2288
  this.$emit('setNestTableClick', this.isNestTable);
@@ -2292,7 +2297,7 @@ export default create({
2292
2297
  // 嵌套表与主表click切换时需要清除上次的选中
2293
2298
  this.isAboutNestTable && this.$emit('resetNestLastClickTable', table);
2294
2299
 
2295
- let { row, $event = {}, rowIndex, source } = data;
2300
+ let { row, $event = {}, rowIndex, source, column } = data;
2296
2301
  // 点击主表格展开行按钮 不需要触发选中行
2297
2302
  let { className } = $event.target || {};
2298
2303
  if (className && vexutils.isString(className) && className.includes('vxe-table--expand-btn')) return;
@@ -2319,7 +2324,7 @@ export default create({
2319
2324
  const value = this.getRowClassName({ row }) == 'single--checked' ? [] : [row];
2320
2325
  this.$set(this, 'checkedRows', value);
2321
2326
  this.pubCheckChange(value);
2322
- this.$emit('handlerClickRow', row, rowIndex, {source});
2327
+ this.$emit('handlerClickRow', row, rowIndex, {source, column});
2323
2328
  return;
2324
2329
  }
2325
2330
  this.visibleCheckAllWrap = false;
@@ -2368,7 +2373,8 @@ export default create({
2368
2373
  }
2369
2374
  this.updateAddCheckedRows(rowVal, true);
2370
2375
  // 需要选中行
2371
- this.$emit('handlerClickRow', rowVal, rowIndex, {source});
2376
+ this.$emit('handlerClickRow', rowVal, rowIndex, {source, column});
2377
+ this.setTableCurrentRow(table, row)
2372
2378
  return;
2373
2379
  }
2374
2380
  let newTheUniqueKeyArr = [];
@@ -2380,41 +2386,59 @@ export default create({
2380
2386
  rowLen = checkedRow.filter(item => !vexutils.has(item, GROUP_TITLE_KEY)).length;
2381
2387
  }
2382
2388
  }
2383
- table.setAllCheckboxRow(false);
2389
+
2390
+ // 相关项位于底部,再次点击已选中数据不取消勾选
2391
+ let btmNotClear = rowLen < 2 && checked
2392
+ !btmNotClear && table.setAllCheckboxRow(false);
2384
2393
  // 全选后/数据大于一条 单击行只剩这一行 取消其他
2385
2394
  // 只有一条选中 单击行 取消选中
2386
2395
  let setChecked = checked;
2387
2396
  if (rowLen > 1) {
2388
2397
  this.selectType != 'radio' && table.setCheckboxRow([row], true);
2389
2398
  this.isTree != 0 && this.selectType != 'radio' && this.pubCheckChange(newRow);
2390
- this.selectType != 'radio' && this.$emit('handlerClickRow', row, rowIndex, {source});
2399
+ this.selectType != 'radio' && this.$emit('handlerClickRow', row, rowIndex, {source, column});
2391
2400
  } else {
2392
2401
  setChecked = !setChecked;
2393
2402
  if (!setChecked) {
2394
- table.clearCurrentRow();
2403
+ !this.aboutPositionBtm && table.clearCurrentRow();
2395
2404
  this.selectType == 'radio' && table.clearRadioRow();
2396
2405
  this.isTree != 0 && this.selectType != 'radio' && this.pubCheckChange([]);
2397
2406
  } else {
2398
2407
  this.selectType == 'radio' && table.setRadioRow(row);
2399
2408
  this.isTree != 0 && this.selectType != 'radio' && this.pubCheckChange(newRow);
2400
2409
  }
2401
- this.selectType != 'radio' && table.setCheckboxRow([row], setChecked);
2410
+ // 相关项位于底部,再次点击已选中数据不取消勾选
2411
+ let isBtmCheck = this.aboutPositionBtm && !setChecked
2412
+ if (this.selectType != 'radio' && !isBtmCheck) {
2413
+ table.setCheckboxRow([row], setChecked);
2414
+ }
2402
2415
  }
2403
2416
  if (this.isTree != 0) {
2404
- setChecked && this.$emit('handlerClickRow', row, rowIndex, {source});
2417
+ setChecked && this.$emit('handlerClickRow', row, rowIndex, {source, column});
2418
+ this.setTableCurrentRow(table, row)
2405
2419
  return;
2406
2420
  }
2407
2421
 
2408
2422
  this.setCheckedMehod(setChecked, row);
2409
- if (setChecked || rowLen > 1 || !rowLen) {
2410
- this.$set(this, 'checkedRows', [row]);
2411
- }
2412
- if (!setChecked && rowLen === 1) {
2413
- this.$set(this, 'checkedRows', []);
2414
- }
2423
+
2424
+ // 选中row
2425
+ let curCheckedRow = table.getCheckboxRecords();
2426
+ this.$set(this, 'checkedRows', curCheckedRow);
2427
+
2415
2428
  this.setCurrentCheckedLength();
2416
2429
  this.lastPageIndex = this.pageVO.pageIndex;
2417
2430
  setChecked && this.$emit('handlerClickRow', row, rowIndex, {source});
2431
+ this.setTableCurrentRow(table, row)
2432
+ },
2433
+ setBtmDbClick(row){
2434
+ if(!row) return;
2435
+ let id = row[this.handleRowId]
2436
+ if(!id) return;
2437
+ let table = this.$refs.xGrid;
2438
+ if (!table) return;
2439
+ let curRow = table?.getRowById(id);
2440
+ if(!curRow) return
2441
+ this.handlerClickRow({row: curRow})
2418
2442
  },
2419
2443
  /**
2420
2444
  * 单选行数据 树结构 扁平化处理
@@ -2465,6 +2489,11 @@ export default create({
2465
2489
  return;
2466
2490
  }
2467
2491
  if (this.currentCheckedKeys.includes(row[this.primaryKey])) {
2492
+ // 关项位于底部,再次点击已选中数据不取消勾选,批量及行级按钮要显示 且 重新加载该数据相关项
2493
+ if(this.aboutPositionBtm) {
2494
+ this.$emit('preRowdblclick', row, {}, true, true)
2495
+ return;
2496
+ }
2468
2497
  this.removeCheckedRows([row]);
2469
2498
  return;
2470
2499
  }
@@ -2549,11 +2578,22 @@ export default create({
2549
2578
  this.pubCheckChange(records);
2550
2579
  return true;
2551
2580
  },
2581
+ setTableCurrentRow(table, row) {
2582
+ if(!this.aboutPositionBtm) return
2583
+ setTimeout(() => {
2584
+ table.setCurrentRow(row);
2585
+ }, 30)
2586
+ },
2552
2587
  selectionChange({ checked, row, records }) {
2553
2588
  // HACK: 防止点击多选框时,触发cell-click(行选中)事件
2554
2589
  // $event.stopPropagation、$event.preventDefault,点击多选框列的空白处触发多选事件,无法阻止事件冒泡触发cell-click事件
2555
2590
  let table = this.$refs.xGrid;
2556
- table.clearCurrentRow();
2591
+
2592
+ // 相关项在底部,只选中一条的情况下,复选框不让去掉
2593
+ if (this.aboutPositionBtm && this.checkedRows?.length === 1 && !checked) {
2594
+ return false;
2595
+ }
2596
+
2557
2597
  this.isTriggerSelectionChange = true;
2558
2598
  setTimeout(() => {
2559
2599
  this.isTriggerSelectionChange = false;
@@ -2562,8 +2602,10 @@ export default create({
2562
2602
  if (this.treeTableSelectionChange(records)) return;
2563
2603
 
2564
2604
  if (checked) {
2605
+ this.setTableCurrentRow(table, row)
2565
2606
  this.addCheckedRows([row]);
2566
2607
  } else {
2608
+ table.clearCurrentRow();
2567
2609
  this.removeCheckedRows([row], true);
2568
2610
  }
2569
2611
 
@@ -2614,7 +2656,7 @@ export default create({
2614
2656
  this.$emit('selectionChangeAll');
2615
2657
  },
2616
2658
  handleCancelAllCheck() {
2617
- this.$emit('selectionChangeAllCancel');
2659
+ this.$emit('selectionChangeAllCancel', {type: 'cancelAll'});
2618
2660
  },
2619
2661
  setCurrentCheckedLength() {
2620
2662
  let table = this.$refs.xGrid;
@@ -2692,7 +2734,7 @@ export default create({
2692
2734
  let isCheckedByCheckboxRow = vxeTable.isCheckedByCheckboxRow(row);
2693
2735
  // 不冒泡 手动触发方法
2694
2736
  if (!isCheckedByCheckboxRow) {
2695
- this.handlerClickRow({row, rowIndex: index, source:'linkDetail'})
2737
+ this.handlerClickRow({row, rowIndex: index, source:'linkDetail', column: col})
2696
2738
  }
2697
2739
  e.stopPropagation();
2698
2740
  vxeTable.setCurrentRow(row);
@@ -73,11 +73,13 @@ const bigTableProps = {
73
73
  isMatchComponent: { type: Boolean, default: true }, // 为了兼容低代码(组件内部)与二次开发平台(vuex)
74
74
  asyncCount: Boolean,
75
75
  showSettings: { type: Object, default: () => ({}) },
76
- filterDomPortal: { // 表头筛选挂载的地方
76
+ filterDomPortal: {
77
+ // 表头筛选挂载的地方
77
78
  type: String,
78
- default: "body"
79
+ default: 'body'
79
80
  },
80
- filterTopOffset: { // 表头 top 调节
81
+ filterTopOffset: {
82
+ // 表头 top 调节
81
83
  type: Number,
82
84
  default: 0
83
85
  },
@@ -85,15 +87,17 @@ const bigTableProps = {
85
87
  defaultEditAllRow: Boolean,
86
88
  editTableUid: [String, Number],
87
89
  curBatchBtnData: { type: Object, default: () => ({}) },
88
- rowBtnAutoLayout:{// 行内按钮自适应布局
90
+ rowBtnAutoLayout: {
91
+ // 行内按钮自适应布局
89
92
  type: Boolean,
90
93
  default: true
91
94
  },
92
- listCountParams:{ type: Object, default: () => ({}) },
93
- tableProps:{
95
+ listCountParams: { type: Object, default: () => ({}) },
96
+ tableProps: {
94
97
  type: Object,
95
- default:()=>({})
96
- }
98
+ default: () => ({})
99
+ },
100
+ aboutPositionBtm: { type: Boolean, default: true }
97
101
  };
98
102
 
99
103
  export default bigTableProps;
@@ -4,9 +4,11 @@ import DatePicker from './src/DatePicker';
4
4
  import MonthPicker from './src/MonthPicker';
5
5
  import RangePicker from './src/RangePicker';
6
6
  import WeekPicker from './src/WeekPicker';
7
+ import { rewriteAntd } from './src/utils';
7
8
 
8
9
  // 为组件提供 install 安装方法,供按需引入
9
10
  DatePicker.install = function(Vue) {
11
+ rewriteAntd();
10
12
  Vue.use(Base);
11
13
  Vue.component(DatePicker.name, DatePicker);
12
14
  Vue.component(MonthPicker.name, MonthPicker);
@@ -0,0 +1,374 @@
1
+ /**
2
+ * 重写antd的一些方法满足业务需要
3
+ */
4
+ import { message } from 'ant-design-vue/es';
5
+ import DateInput from 'ant-design-vue/es/vc-calendar/src/date/DateInput.js';
6
+ import TimePickerHeader from 'ant-design-vue/es/vc-time-picker/Header.js';
7
+ import KEYCODE from 'ant-design-vue/es/_util/KeyCode';
8
+ import moment from 'moment';
9
+
10
+ function checkDateVal(val, type) {
11
+ const regObj = {
12
+ YYYYMMDD: /\d{8}/,
13
+ YYYYMM: /\d{6}/,
14
+ YYYY: /\d{4}/,
15
+ 'YYYY-MM-DD': /\d{4}-\d\d-\d\d/,
16
+ 'YYYY-MM': /\d{4}-\d\d/
17
+ };
18
+ if (regObj[type]) {
19
+ return regObj[type].test(val);
20
+ }
21
+ return false;
22
+ }
23
+
24
+ function checkTimeVal(val, type) {
25
+ const regObj = {
26
+ 'HH:mm:ss': /\d\d:\d\d:\d\d/,
27
+ 'HH:mm': /\d\d:\d\d/,
28
+ HHmmss: /\d\d\d\d\d\d/,
29
+ HHmm: /\d\d\d\d/,
30
+ HH: /\d\d/
31
+ };
32
+ if (regObj[type]) {
33
+ return regObj[type].test(val);
34
+ }
35
+ return false;
36
+ }
37
+
38
+ /**
39
+ *
40
+ * @param {string} str
41
+ * @param {string} formatStr
42
+ * @returns
43
+ */
44
+ function getHasTimeValue(str, formatStr) {
45
+ let res = str;
46
+ let [dateType, timeType] = formatStr.split(' ');
47
+ let dateTypeStr = dateType.toUpperCase().replace(/-/g, '');
48
+ let timeTypeStr = timeType.replace(/:/g, '');
49
+ if (str.length > 8) {
50
+ let dateValue = str.slice(0, 8);
51
+ let timeValue = str.slice(8).trim();
52
+
53
+ // time 兼容两种输入 HH:mm:ss | HHmmss
54
+ if (checkDateVal(dateValue, dateTypeStr) && (checkTimeVal(timeValue, timeType) || checkTimeVal(timeValue, timeTypeStr))) {
55
+ // 使用 moment 的 iso Date 格式转换值
56
+ dateValue = moment(dateValue, dateTypeStr).format(dateType);
57
+ // 使用 moment 的 iso time 格式转换值
58
+ timeValue = timeValue ? moment(timeValue, timeTypeStr).format(timeType) : '';
59
+ res = `${dateValue} ${timeValue}`;
60
+ }
61
+ }
62
+ return res;
63
+ }
64
+
65
+ function mendTime(timeVal, timeType, defVal) {
66
+ let res = timeVal;
67
+ return res + defVal.slice(0, timeType.length).slice(timeVal.length);
68
+ }
69
+
70
+ /**
71
+ * 补全时间
72
+ * @param {*} str
73
+ * @param {*} formatStr
74
+ * @returns
75
+ */
76
+ function strFormatToDate(str, formatStr) {
77
+ let res = '';
78
+ let [dateType, timeType] = formatStr.split(' ');
79
+ let updateType = dateType.toUpperCase();
80
+ let dateTypeStr = updateType.replace(/-/g, '');
81
+ let timeTypeStr = timeType.replace(/:/g, '');
82
+ let strDateValue = '',
83
+ strTimeValue = '';
84
+ let ordinary = false;
85
+ if (str.length >= 10) {
86
+ strDateValue = str.slice(0, 10);
87
+ }
88
+ // 是否是"YYYY-MM-DD" 格式
89
+ if (checkDateVal(strDateValue, updateType)) {
90
+ strTimeValue = str.slice(10).trim();
91
+ ordinary = true;
92
+ } else {
93
+ // 处理“yyyymmdd”的格式
94
+ if (str.length >= 8) {
95
+ strDateValue = str.slice(0, 8);
96
+ strTimeValue = str.slice(8).trim();
97
+ }
98
+ }
99
+
100
+ // time 兼容两种输入 HH:mm:ss | HHmmss
101
+ let ff = !checkTimeVal(strTimeValue, timeType) || !checkTimeVal(strTimeValue, timeTypeStr);
102
+
103
+ // 日期格式
104
+ let dateFlag = ordinary || checkDateVal(strDateValue, dateTypeStr);
105
+
106
+ if (dateFlag && ff) {
107
+ if (strTimeValue && ff) {
108
+ let f = strTimeValue.includes(':') || ordinary;
109
+ if (f) {
110
+ strTimeValue = mendTime(strTimeValue, timeType, '00:00:00');
111
+ } else {
112
+ strTimeValue = mendTime(strTimeValue, timeTypeStr, '000000');
113
+ }
114
+ }
115
+ if (!strTimeValue) {
116
+ strTimeValue = '00:00:00';
117
+ }
118
+ // 使用 moment 的 iso Date 格式转换值
119
+ strDateValue = moment(strDateValue, dateTypeStr).format(dateType);
120
+ // 使用 moment 的 iso time 格式转换值
121
+ strTimeValue = strDateValue ? moment(strTimeValue, timeTypeStr).format(timeType) : '';
122
+ res = `${strDateValue} ${strTimeValue}`;
123
+ // 有解析错误的置空
124
+ if (res.includes('Invalid date')) {
125
+ res = '';
126
+ }
127
+ }
128
+
129
+ return res;
130
+ }
131
+
132
+ function getHasTimeValue2(str, formatStr) {
133
+ let res = '';
134
+ let [dateType, timeType] = formatStr.split(' ');
135
+ let updateType = dateType.toUpperCase();
136
+ let dateTypeStr = updateType.replace(/-/g, '');
137
+ let timeTypeStr = timeType.replace(/:/g, '');
138
+
139
+ if (str.length >= 8) {
140
+ let dateValue = str.slice(0, 8);
141
+ let timeValue = str.slice(8).trim();
142
+ let ff = !checkTimeVal(timeValue, timeType) || !checkTimeVal(timeValue, timeTypeStr);
143
+
144
+ // time 兼容两种输入 HH:mm:ss | HHmmss
145
+ if (checkDateVal(dateValue, dateTypeStr) && ff) {
146
+ if (timeValue && ff) {
147
+ let f = timeValue.includes(':');
148
+ if (f) {
149
+ timeValue = timeValue + '00:00:00'.slice(timeValue.length);
150
+ } else {
151
+ timeValue = timeValue + '000000'.slice(timeValue.length);
152
+ }
153
+ }
154
+ if (!timeValue) {
155
+ timeValue = '00:00:00';
156
+ }
157
+ // 使用 moment 的 iso Date 格式转换值
158
+ dateValue = moment(dateValue, dateTypeStr).format(dateType);
159
+ // 使用 moment 的 iso time 格式转换值
160
+ timeValue = timeValue ? moment(timeValue, timeTypeStr).format(timeType) : '';
161
+ res = `${dateValue} ${timeValue}`;
162
+ }
163
+ }
164
+ return res;
165
+ }
166
+ const extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
167
+
168
+ function sleep() {
169
+ return new Promise(res => {
170
+ setTimeout(() => res(), 0);
171
+ });
172
+ }
173
+
174
+ const getMomentObjectIfValid = date => {
175
+ if (moment.isMoment(date) && date.isValid()) {
176
+ return date;
177
+ }
178
+ return false;
179
+ };
180
+
181
+ function customGetValue(str, formatStr) {
182
+ let res = '';
183
+ // 如果有含有“时间”, 自定义拼值
184
+ if (formatStr && /(HH)|(hh)/.test(formatStr)) {
185
+ res = strFormatToDate(str, formatStr);
186
+ } else {
187
+ let dateTypeStr = formatStr.toUpperCase().replace(/-/g, '');
188
+ res = checkDateVal(str, dateTypeStr) ? moment(str, dateTypeStr).format(formatStr) : str;
189
+ }
190
+ // 如是含有错误解析,重置输出
191
+ if (res.includes('Invalid date')) {
192
+ res = '';
193
+ }
194
+ return res;
195
+ }
196
+
197
+ function onInputChange11(e) {
198
+ const { value: str, composing } = e.target;
199
+ const { str: oldStr = '' } = this;
200
+
201
+ const { disabledDate, format, selectedValue } = this.$props;
202
+
203
+ // 没有内容,合法并直接退出
204
+ if (!str) {
205
+ this.__emit('change', null);
206
+ this.setState({
207
+ invalid: false,
208
+ str
209
+ });
210
+ return;
211
+ }
212
+
213
+ // 不合法直接退出
214
+ const parsed = moment(str, format, true);
215
+ if (!parsed.isValid()) {
216
+ this.setState({
217
+ invalid: true,
218
+ str
219
+ });
220
+ return;
221
+ }
222
+ const value = this.value.clone();
223
+ value
224
+ .year(parsed.year())
225
+ .month(parsed.month())
226
+ .date(parsed.date())
227
+ .hour(parsed.hour())
228
+ .minute(parsed.minute())
229
+ .second(parsed.second());
230
+
231
+ if (!value || (disabledDate && disabledDate(value))) {
232
+ this.setState({
233
+ invalid: true,
234
+ str
235
+ });
236
+ return;
237
+ }
238
+
239
+ if (selectedValue !== value || (selectedValue && value && !selectedValue.isSame(value))) {
240
+ this.setState({
241
+ invalid: false,
242
+ str
243
+ });
244
+ this.__emit('change', value);
245
+ }
246
+ }
247
+
248
+ export function rewriteAntd() {
249
+ /**
250
+ * 改写日期弹窗框的 input 元素的 onInputChange 方法,满足格式化 '20221014121517' | '20221014 12:15:17'
251
+ */
252
+ /**
253
+ * TODO: 输入完整的日期格式,光标会移到最后。有可能是 antd 的bug
254
+ */
255
+ if (DateInput && DateInput.methods) {
256
+ DateInput.methods.onInputChange11 = onInputChange11;
257
+ // 缓存原有的方法
258
+ DateInput.methods.originalOnInputChange = DateInput.methods.onInputChange;
259
+ // 重新 onInputChange
260
+ DateInput.methods.onInputChange = function(e) {
261
+ // console.log(e.target.selectionStart, "e.target.selectionStart");
262
+ const { value: str, composing } = e.target;
263
+ let res = str;
264
+ const formatStr = this.format;
265
+ // 如果有含有“时间”, 自定义拼值
266
+ if (formatStr && /(HH)|(hh)/.test(formatStr)) {
267
+ res = getHasTimeValue(str, formatStr);
268
+ } else {
269
+ let dateTypeStr = this.format.toUpperCase().replace(/-/g, '');
270
+ res = checkDateVal(str, dateTypeStr) ? moment(str, dateTypeStr).format(this.format) : str;
271
+ }
272
+ // 如是含有错误解析,重置输出
273
+ if (res.includes('Invalid date')) {
274
+ res = str;
275
+ }
276
+ // 调用原来的 onInputChange 方法
277
+ // 原本是传入事件对象,目前只传入需要的参数
278
+ this.originalOnInputChange({
279
+ target: { value: res, composing }
280
+ });
281
+ // this.originalOnInputChange(e);
282
+ };
283
+
284
+ /**
285
+ * 改写 onKeyDown 事件,满足按回车键,不满足的 yyyymmdd: hhmmss 格式的自动补“时间”(hhmmss)
286
+ * @param {*} event
287
+ * @returns
288
+ */
289
+ DateInput.methods.onKeyDown = async function(event) {
290
+ const { keyCode, target } = event;
291
+
292
+ if (keyCode === KEYCODE.ENTER) {
293
+ const formatStr = this.format;
294
+ const tValue = target.value;
295
+ const pProps = this.$parent.$props;
296
+ // 回车自动补全“时间”
297
+ if (tValue && formatStr && /(HH)|(hh)/.test(formatStr) && (!extendedIsoRegex.test(tValue) || checkDateVal(tValue, 'YYYY-MM-DD'))) {
298
+ // 是否可以自动补全时间
299
+ let ress = strFormatToDate(tValue, formatStr);
300
+ if (ress) {
301
+ this.onInputChange11({
302
+ target: { value: ress }
303
+ });
304
+ await sleep();
305
+ }
306
+ }
307
+ const { disabledDate, value, selectedValue } = this.$props;
308
+
309
+ const validateDate = !disabledDate || !disabledDate(value);
310
+ // if (selectedValue !== value || (selectedValue && value && !selectedValue.isSame(value))) {
311
+
312
+ // }
313
+ let def = getMomentObjectIfValid(pProps.value) || getMomentObjectIfValid(pProps.defaultValue);
314
+ if (validateDate) {
315
+ let dateTypeStr = formatStr.toUpperCase().replace(/-/g, '');
316
+ let f = checkDateVal(tValue, formatStr) || checkDateVal(tValue, dateTypeStr);
317
+ // 有输入的值,但是格式错误,提示
318
+ if (tValue && ((!customGetValue(tValue, formatStr) && !extendedIsoRegex.test(tValue) && /(HH)|(hh)/.test(formatStr)) || (['YYYYMMDD', 'YYYYMM', 'YYYY'].includes(dateTypeStr) && !f))) {
319
+ console.log(tValue, '-----------------');
320
+ message.error('请输入有效的格式');
321
+ }
322
+ if (!selectedValue && !def) {
323
+ message.error('请输入有效的格式');
324
+ return false;
325
+ }
326
+ if (!selectedValue && def && def.isSame(value)) {
327
+ this.__emit('select', null);
328
+ return false;
329
+ }
330
+ this.__emit('select', value.clone());
331
+ }
332
+ event.preventDefault();
333
+ }
334
+ };
335
+ }
336
+
337
+ /**
338
+ * TimePickerHeader
339
+ */
340
+ if (TimePickerHeader && TimePickerHeader.methods) {
341
+ // 缓存原有的方法
342
+ TimePickerHeader.methods.originalOnKeyDown = TimePickerHeader.methods.onKeyDown;
343
+
344
+ TimePickerHeader.methods.onKeyDown = async function(event) {
345
+ const { keyCode, target } = event;
346
+
347
+ if (keyCode === KEYCODE.ENTER) {
348
+ const timeType = this.format;
349
+ const tValue = target.value;
350
+ let timeValue = tValue;
351
+ let timeTypeStr = timeType.replace(/:/g, '');
352
+ // iso time 格式
353
+ if (checkTimeVal(timeValue, timeTypeStr)) {
354
+ timeValue = timeValue ? moment(timeValue, timeTypeStr).format(timeType) : '';
355
+ if (checkTimeVal(timeValue, timeType)) {
356
+ this.onInputChange({
357
+ target: { value: timeValue }
358
+ });
359
+ await sleep();
360
+ this.__emit('esc');
361
+ return;
362
+ }
363
+ } else if (checkTimeVal(timeValue, timeType)) {
364
+ // 满足条件按回车关闭弹窗
365
+ this.__emit('esc');
366
+ } else {
367
+ message.error('请输入有效的时间格式');
368
+ }
369
+ }
370
+
371
+ this.originalOnKeyDown(event);
372
+ };
373
+ }
374
+ }