cnhis-design-vue 3.0.8 → 3.0.9
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.
- package/CHANGELOG.md +7 -0
- package/es/big-table/index.js +63 -4
- package/es/index.js +63 -4
- package/package.json +1 -1
- package/packages/big-table/src/BigTable.vue +5 -2
- package/packages/big-table/src/components/edit-form/edit-date.vue +36 -2
- package/packages/big-table/src/components/edit-form/edit-select.vue +1 -0
- package/packages/big-table/src/hooks/useEdit.ts +21 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [3.0.9](http://120.25.59.85:3000/cnhis-frontend/cnhis-design-vue/compare/v3.0.8...v3.0.9) (2022-05-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* 不传scrollConfig报错; ([8897413](http://120.25.59.85:3000/cnhis-frontend/cnhis-design-vue/commit/88974131e5eed48f39ebe2955830062b6976f8ec))
|
|
11
|
+
|
|
5
12
|
### [3.0.8](http://120.25.59.85:3000/cnhis-frontend/cnhis-design-vue/compare/v3.0.7...v3.0.8) (2022-05-27)
|
|
6
13
|
|
|
7
14
|
|
package/es/big-table/index.js
CHANGED
|
@@ -13346,6 +13346,7 @@ var script$5 = defineComponent({
|
|
|
13346
13346
|
index: props.index
|
|
13347
13347
|
});
|
|
13348
13348
|
};
|
|
13349
|
+
console.log(attrs);
|
|
13349
13350
|
return () => [createVNode(NSelect, mergeProps(attrs, {
|
|
13350
13351
|
"options": state.options,
|
|
13351
13352
|
"consistentMenuWidth": false,
|
|
@@ -13390,13 +13391,47 @@ var script$4 = defineComponent({
|
|
|
13390
13391
|
index: props.index
|
|
13391
13392
|
});
|
|
13392
13393
|
};
|
|
13394
|
+
const { isStartDate = false, isEndDate = false, connectField } = props.col;
|
|
13395
|
+
const setDateDisabled = (cur, date) => {
|
|
13396
|
+
if (isStartDate && connectField) {
|
|
13397
|
+
return cur > date;
|
|
13398
|
+
}
|
|
13399
|
+
if (isEndDate && connectField) {
|
|
13400
|
+
return cur < date;
|
|
13401
|
+
}
|
|
13402
|
+
return false;
|
|
13403
|
+
};
|
|
13404
|
+
const isDateDisabled = (ts) => {
|
|
13405
|
+
return setDateDisabled(ts, new Date(props.row[connectField]).getTime());
|
|
13406
|
+
};
|
|
13407
|
+
const isTimeDisabled = (ts) => {
|
|
13408
|
+
const date = new Date(props.row[connectField] || ts);
|
|
13409
|
+
const h = date.getHours();
|
|
13410
|
+
const m = date.getMinutes();
|
|
13411
|
+
const s = date.getSeconds();
|
|
13412
|
+
return {
|
|
13413
|
+
isHourDisabled: (hour) => {
|
|
13414
|
+
return setDateDisabled(hour, h);
|
|
13415
|
+
},
|
|
13416
|
+
isMinuteDisabled: (minute) => {
|
|
13417
|
+
return setDateDisabled(minute, m);
|
|
13418
|
+
},
|
|
13419
|
+
isSecondDisabled: (second) => {
|
|
13420
|
+
return setDateDisabled(second, s);
|
|
13421
|
+
}
|
|
13422
|
+
};
|
|
13423
|
+
};
|
|
13393
13424
|
const config = {
|
|
13394
13425
|
type: props.col.type || "datetime",
|
|
13395
13426
|
clearable: props.col.clearable || true,
|
|
13396
13427
|
disabled: props.col.disabled || false,
|
|
13397
13428
|
valueFormat: props.col.valueFormat || "yyyy-MM-dd HH:mm:ss",
|
|
13398
|
-
to: false
|
|
13429
|
+
to: false,
|
|
13430
|
+
isDateDisabled: props.col.isDateDisabled || isDateDisabled
|
|
13399
13431
|
};
|
|
13432
|
+
if (config.type.includes("time")) {
|
|
13433
|
+
config.isTimeDisabled = props.col.isTimeDisabled || isTimeDisabled;
|
|
13434
|
+
}
|
|
13400
13435
|
return () => createVNode(NDatePicker, mergeProps(attrs, config, {
|
|
13401
13436
|
"onUpdateFormattedValue": onConfirm
|
|
13402
13437
|
}), null);
|
|
@@ -13466,13 +13501,33 @@ const useEdit = (props, state, emit, xGrid) => {
|
|
|
13466
13501
|
await xGrid.value.insertAt(record, getInsertRecords.at(-1));
|
|
13467
13502
|
xGrid.value.clearActived();
|
|
13468
13503
|
};
|
|
13504
|
+
const getLabel = (opts, value) => {
|
|
13505
|
+
return opts.find((opt) => opt.value === value)?.label || "";
|
|
13506
|
+
};
|
|
13469
13507
|
const onFormChange = ({ value, row, column, index }) => {
|
|
13470
|
-
row[column.columnName]
|
|
13471
|
-
|
|
13508
|
+
let oldValue = row[column.columnName];
|
|
13509
|
+
if ((column?.formType === "input" || column?.formType === "number") && props.columnConfig?.formValidate) {
|
|
13510
|
+
row[column.columnName] = props.columnConfig?.formValidate({ row, column, current: value, old: row[column.columnName] });
|
|
13511
|
+
}
|
|
13512
|
+
else if (column?.formatMap) {
|
|
13513
|
+
oldValue = {
|
|
13514
|
+
label: row[column.formatMap.label],
|
|
13515
|
+
value: row[column.formatMap.value]
|
|
13516
|
+
};
|
|
13517
|
+
row[column.formatMap.label] = getLabel(row[column.columnName + "_options"] || [], value);
|
|
13518
|
+
row[column.formatMap.value] = value;
|
|
13519
|
+
}
|
|
13520
|
+
else {
|
|
13521
|
+
row[column.columnName] = value;
|
|
13522
|
+
}
|
|
13523
|
+
emit("formChange", { value, row, column, index, oldValue });
|
|
13472
13524
|
};
|
|
13473
13525
|
const getDefaultValue = (params, item) => {
|
|
13474
13526
|
const value = params.row[item.columnName];
|
|
13475
13527
|
if (item.formType === "select") {
|
|
13528
|
+
if (item.formatMap) {
|
|
13529
|
+
return params.row[item.formatMap.label];
|
|
13530
|
+
}
|
|
13476
13531
|
if (item.options) {
|
|
13477
13532
|
return item.options.find((v) => v.value == value)?.label || "";
|
|
13478
13533
|
}
|
|
@@ -39848,6 +39903,7 @@ var script = /* @__PURE__ */ defineComponent({
|
|
|
39848
39903
|
const formatterEdit = (params, col) => {
|
|
39849
39904
|
let { row, column, $rowIndex, rowIndex } = params;
|
|
39850
39905
|
let formType = column.formType || col.formType || "";
|
|
39906
|
+
let formatMap = column.formatMap || col.formatMap || null;
|
|
39851
39907
|
if (!formType)
|
|
39852
39908
|
return null;
|
|
39853
39909
|
if (formType === "custom") {
|
|
@@ -39866,6 +39922,9 @@ var script = /* @__PURE__ */ defineComponent({
|
|
|
39866
39922
|
if (formType === "date") {
|
|
39867
39923
|
propsData.defaultFormattedValue = row[col.columnName];
|
|
39868
39924
|
}
|
|
39925
|
+
else if (formatMap) {
|
|
39926
|
+
propsData.defaultValue = row[formatMap.value];
|
|
39927
|
+
}
|
|
39869
39928
|
else {
|
|
39870
39929
|
propsData.defaultValue = row[col.columnName];
|
|
39871
39930
|
}
|
|
@@ -40756,7 +40815,7 @@ var script = /* @__PURE__ */ defineComponent({
|
|
|
40756
40815
|
emit("scroll", params);
|
|
40757
40816
|
};
|
|
40758
40817
|
const initScroll = () => {
|
|
40759
|
-
const { throttle = false, throttleTime = 800, throttleOptions = {} } = props.columnConfig?.scrollConfig;
|
|
40818
|
+
const { throttle = false, throttleTime = 800, throttleOptions = {} } = props.columnConfig?.scrollConfig || {};
|
|
40760
40819
|
if (throttle) {
|
|
40761
40820
|
scrollEvent = xeUtils.throttle(scrollEvent, throttleTime, throttleOptions);
|
|
40762
40821
|
}
|
package/es/index.js
CHANGED
|
@@ -38504,6 +38504,7 @@ var script$d = defineComponent({
|
|
|
38504
38504
|
index: props.index
|
|
38505
38505
|
});
|
|
38506
38506
|
};
|
|
38507
|
+
console.log(attrs);
|
|
38507
38508
|
return () => [createVNode(NSelect, mergeProps(attrs, {
|
|
38508
38509
|
"options": state.options,
|
|
38509
38510
|
"consistentMenuWidth": false,
|
|
@@ -38548,13 +38549,47 @@ var script$c = defineComponent({
|
|
|
38548
38549
|
index: props.index
|
|
38549
38550
|
});
|
|
38550
38551
|
};
|
|
38552
|
+
const { isStartDate = false, isEndDate = false, connectField } = props.col;
|
|
38553
|
+
const setDateDisabled = (cur, date) => {
|
|
38554
|
+
if (isStartDate && connectField) {
|
|
38555
|
+
return cur > date;
|
|
38556
|
+
}
|
|
38557
|
+
if (isEndDate && connectField) {
|
|
38558
|
+
return cur < date;
|
|
38559
|
+
}
|
|
38560
|
+
return false;
|
|
38561
|
+
};
|
|
38562
|
+
const isDateDisabled = (ts) => {
|
|
38563
|
+
return setDateDisabled(ts, new Date(props.row[connectField]).getTime());
|
|
38564
|
+
};
|
|
38565
|
+
const isTimeDisabled = (ts) => {
|
|
38566
|
+
const date = new Date(props.row[connectField] || ts);
|
|
38567
|
+
const h = date.getHours();
|
|
38568
|
+
const m = date.getMinutes();
|
|
38569
|
+
const s = date.getSeconds();
|
|
38570
|
+
return {
|
|
38571
|
+
isHourDisabled: (hour) => {
|
|
38572
|
+
return setDateDisabled(hour, h);
|
|
38573
|
+
},
|
|
38574
|
+
isMinuteDisabled: (minute) => {
|
|
38575
|
+
return setDateDisabled(minute, m);
|
|
38576
|
+
},
|
|
38577
|
+
isSecondDisabled: (second) => {
|
|
38578
|
+
return setDateDisabled(second, s);
|
|
38579
|
+
}
|
|
38580
|
+
};
|
|
38581
|
+
};
|
|
38551
38582
|
const config = {
|
|
38552
38583
|
type: props.col.type || "datetime",
|
|
38553
38584
|
clearable: props.col.clearable || true,
|
|
38554
38585
|
disabled: props.col.disabled || false,
|
|
38555
38586
|
valueFormat: props.col.valueFormat || "yyyy-MM-dd HH:mm:ss",
|
|
38556
|
-
to: false
|
|
38587
|
+
to: false,
|
|
38588
|
+
isDateDisabled: props.col.isDateDisabled || isDateDisabled
|
|
38557
38589
|
};
|
|
38590
|
+
if (config.type.includes("time")) {
|
|
38591
|
+
config.isTimeDisabled = props.col.isTimeDisabled || isTimeDisabled;
|
|
38592
|
+
}
|
|
38558
38593
|
return () => createVNode(NDatePicker, mergeProps(attrs, config, {
|
|
38559
38594
|
"onUpdateFormattedValue": onConfirm
|
|
38560
38595
|
}), null);
|
|
@@ -38624,13 +38659,33 @@ const useEdit = (props, state, emit, xGrid) => {
|
|
|
38624
38659
|
await xGrid.value.insertAt(record, getInsertRecords.at(-1));
|
|
38625
38660
|
xGrid.value.clearActived();
|
|
38626
38661
|
};
|
|
38662
|
+
const getLabel = (opts, value) => {
|
|
38663
|
+
return opts.find((opt) => opt.value === value)?.label || "";
|
|
38664
|
+
};
|
|
38627
38665
|
const onFormChange = ({ value, row, column, index }) => {
|
|
38628
|
-
row[column.columnName]
|
|
38629
|
-
|
|
38666
|
+
let oldValue = row[column.columnName];
|
|
38667
|
+
if ((column?.formType === "input" || column?.formType === "number") && props.columnConfig?.formValidate) {
|
|
38668
|
+
row[column.columnName] = props.columnConfig?.formValidate({ row, column, current: value, old: row[column.columnName] });
|
|
38669
|
+
}
|
|
38670
|
+
else if (column?.formatMap) {
|
|
38671
|
+
oldValue = {
|
|
38672
|
+
label: row[column.formatMap.label],
|
|
38673
|
+
value: row[column.formatMap.value]
|
|
38674
|
+
};
|
|
38675
|
+
row[column.formatMap.label] = getLabel(row[column.columnName + "_options"] || [], value);
|
|
38676
|
+
row[column.formatMap.value] = value;
|
|
38677
|
+
}
|
|
38678
|
+
else {
|
|
38679
|
+
row[column.columnName] = value;
|
|
38680
|
+
}
|
|
38681
|
+
emit("formChange", { value, row, column, index, oldValue });
|
|
38630
38682
|
};
|
|
38631
38683
|
const getDefaultValue = (params, item) => {
|
|
38632
38684
|
const value = params.row[item.columnName];
|
|
38633
38685
|
if (item.formType === "select") {
|
|
38686
|
+
if (item.formatMap) {
|
|
38687
|
+
return params.row[item.formatMap.label];
|
|
38688
|
+
}
|
|
38634
38689
|
if (item.options) {
|
|
38635
38690
|
return item.options.find((v) => v.value == value)?.label || "";
|
|
38636
38691
|
}
|
|
@@ -39849,6 +39904,7 @@ var script$8 = /* @__PURE__ */ defineComponent({
|
|
|
39849
39904
|
const formatterEdit = (params, col) => {
|
|
39850
39905
|
let { row, column, $rowIndex, rowIndex } = params;
|
|
39851
39906
|
let formType = column.formType || col.formType || "";
|
|
39907
|
+
let formatMap = column.formatMap || col.formatMap || null;
|
|
39852
39908
|
if (!formType)
|
|
39853
39909
|
return null;
|
|
39854
39910
|
if (formType === "custom") {
|
|
@@ -39867,6 +39923,9 @@ var script$8 = /* @__PURE__ */ defineComponent({
|
|
|
39867
39923
|
if (formType === "date") {
|
|
39868
39924
|
propsData.defaultFormattedValue = row[col.columnName];
|
|
39869
39925
|
}
|
|
39926
|
+
else if (formatMap) {
|
|
39927
|
+
propsData.defaultValue = row[formatMap.value];
|
|
39928
|
+
}
|
|
39870
39929
|
else {
|
|
39871
39930
|
propsData.defaultValue = row[col.columnName];
|
|
39872
39931
|
}
|
|
@@ -40757,7 +40816,7 @@ var script$8 = /* @__PURE__ */ defineComponent({
|
|
|
40757
40816
|
emit("scroll", params);
|
|
40758
40817
|
};
|
|
40759
40818
|
const initScroll = () => {
|
|
40760
|
-
const { throttle = false, throttleTime = 800, throttleOptions = {} } = props.columnConfig?.scrollConfig;
|
|
40819
|
+
const { throttle = false, throttleTime = 800, throttleOptions = {} } = props.columnConfig?.scrollConfig || {};
|
|
40761
40820
|
if (throttle) {
|
|
40762
40821
|
scrollEvent = xeUtils.throttle(scrollEvent, throttleTime, throttleOptions);
|
|
40763
40822
|
}
|
package/package.json
CHANGED
|
@@ -704,6 +704,7 @@ const formatColumns = (map: any) => {
|
|
|
704
704
|
const formatterEdit = (params: any, col: any) => {
|
|
705
705
|
let { row, column, $rowIndex, rowIndex } = params
|
|
706
706
|
let formType = column.formType || col.formType || ''
|
|
707
|
+
let formatMap = column.formatMap || col.formatMap || null
|
|
707
708
|
if (!formType) return null
|
|
708
709
|
if (formType === 'custom') {
|
|
709
710
|
return col.slotFn(params)
|
|
@@ -717,9 +718,11 @@ const formatterEdit = (params: any, col: any) => {
|
|
|
717
718
|
// vModel: [row[col.columnName], formType === 'date' ? 'formattedValue' :'value'],
|
|
718
719
|
type: formType,
|
|
719
720
|
onFormChange
|
|
720
|
-
}
|
|
721
|
+
}
|
|
721
722
|
if (formType === 'date') {
|
|
722
723
|
propsData.defaultFormattedValue = row[col.columnName]
|
|
724
|
+
} else if(formatMap){
|
|
725
|
+
propsData.defaultValue = row[formatMap.value]
|
|
723
726
|
} else {
|
|
724
727
|
propsData.defaultValue = row[col.columnName]
|
|
725
728
|
}
|
|
@@ -1689,7 +1692,7 @@ let scrollEvent = (params: any) => {
|
|
|
1689
1692
|
emit('scroll', params)
|
|
1690
1693
|
}
|
|
1691
1694
|
const initScroll = () => {
|
|
1692
|
-
const { throttle = false, throttleTime = 800, throttleOptions = {} } = props.columnConfig?.scrollConfig
|
|
1695
|
+
const { throttle = false, throttleTime = 800, throttleOptions = {} } = props.columnConfig?.scrollConfig || {}
|
|
1693
1696
|
if (throttle) {
|
|
1694
1697
|
scrollEvent = vexutils.throttle(scrollEvent, throttleTime, throttleOptions)
|
|
1695
1698
|
}
|
|
@@ -27,12 +27,46 @@ export default defineComponent({
|
|
|
27
27
|
const onConfirm = (value: any) => {
|
|
28
28
|
emit('formChange', { value, row: props.row, column: props.col, index: props.index })
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const { isStartDate = false, isEndDate = false, connectField } = props.col
|
|
31
|
+
const setDateDisabled = (cur: number, date: number) => {
|
|
32
|
+
if (isStartDate && connectField) {
|
|
33
|
+
return cur > date
|
|
34
|
+
}
|
|
35
|
+
if(isEndDate && connectField) {
|
|
36
|
+
return cur < date
|
|
37
|
+
}
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
const isDateDisabled = (ts: number) => {
|
|
41
|
+
return setDateDisabled(ts, new Date(props.row[connectField]).getTime())
|
|
42
|
+
}
|
|
43
|
+
const isTimeDisabled = (ts: number) => {
|
|
44
|
+
const date = new Date(props.row[connectField] || ts)
|
|
45
|
+
const h = date.getHours()
|
|
46
|
+
const m = date.getMinutes()
|
|
47
|
+
const s = date.getSeconds()
|
|
48
|
+
return {
|
|
49
|
+
isHourDisabled: (hour: number) => {
|
|
50
|
+
return setDateDisabled(hour, h)
|
|
51
|
+
},
|
|
52
|
+
isMinuteDisabled: (minute: number) => {
|
|
53
|
+
return setDateDisabled(minute, m)
|
|
54
|
+
},
|
|
55
|
+
isSecondDisabled: (second: number) => {
|
|
56
|
+
return setDateDisabled(second, s)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const config: any = {
|
|
31
61
|
type: props.col.type || 'datetime',
|
|
32
62
|
clearable: props.col.clearable || true,
|
|
33
63
|
disabled: props.col.disabled || false,
|
|
34
64
|
valueFormat: props.col.valueFormat || 'yyyy-MM-dd HH:mm:ss',
|
|
35
|
-
to: false
|
|
65
|
+
to: false,
|
|
66
|
+
isDateDisabled: props.col.isDateDisabled || isDateDisabled
|
|
67
|
+
}
|
|
68
|
+
if (config.type.includes('time')) {
|
|
69
|
+
config.isTimeDisabled = props.col.isTimeDisabled || isTimeDisabled
|
|
36
70
|
}
|
|
37
71
|
return () => <NDatePicker {...attrs} {...config} onUpdateFormattedValue={onConfirm} />
|
|
38
72
|
}
|
|
@@ -82,14 +82,33 @@ export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
|
|
|
82
82
|
xGrid.value.clearActived()
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
const getLabel = (opts: any[], value: any): any => {
|
|
86
|
+
return opts.find((opt: any) => opt.value === value)?.label || '';
|
|
87
|
+
};
|
|
88
|
+
|
|
85
89
|
const onFormChange = ({ value, row, column, index }: {value: number | string | null, row: any, column: any, index: number}) => {
|
|
86
|
-
row[column.columnName]
|
|
87
|
-
|
|
90
|
+
let oldValue: any = row[column.columnName]
|
|
91
|
+
if ((column?.formType === 'input' || column?.formType === 'number') && props.columnConfig?.formValidate) {
|
|
92
|
+
row[column.columnName] = props.columnConfig?.formValidate({row, column, current: value, old: row[column.columnName]})
|
|
93
|
+
} else if (column?.formatMap) {
|
|
94
|
+
oldValue = {
|
|
95
|
+
label: row[column.formatMap.label],
|
|
96
|
+
value: row[column.formatMap.value]
|
|
97
|
+
}
|
|
98
|
+
row[column.formatMap.label] = getLabel(row[column.columnName+'_options'] || [], value)
|
|
99
|
+
row[column.formatMap.value] = value
|
|
100
|
+
} else {
|
|
101
|
+
row[column.columnName] = value
|
|
102
|
+
}
|
|
103
|
+
emit('formChange', { value, row, column, index, oldValue })
|
|
88
104
|
}
|
|
89
105
|
|
|
90
106
|
const getDefaultValue = (params: any, item: any) => {
|
|
91
107
|
const value = params.row[item.columnName]
|
|
92
108
|
if (item.formType === 'select') {
|
|
109
|
+
if( item.formatMap ) {
|
|
110
|
+
return params.row[item.formatMap.label]
|
|
111
|
+
}
|
|
93
112
|
if (item.options) {
|
|
94
113
|
return item.options.find((v: any) => v.value == value)?.label || ''
|
|
95
114
|
}
|