vxe-pc-ui 3.0.16 → 3.1.0
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/README.md +1 -1
- package/es/components.js +3 -0
- package/es/date-picker/src/date-picker.js +18 -4
- package/es/form/src/form-config-item.js +26 -157
- package/es/form/src/form-group.js +104 -0
- package/es/form/src/form-item.js +43 -143
- package/es/form/src/form.js +15 -2
- package/es/form/src/itemInfo.js +3 -0
- package/es/form/src/render.js +184 -19
- package/es/form/src/util.js +2 -2
- package/es/form/style.css +135 -70
- package/es/form/style.min.css +1 -1
- package/es/form-gather/index.js +2 -1
- package/es/form-group/index.js +12 -0
- package/es/form-group/style.css +0 -0
- package/es/form-group/style.min.css +0 -0
- package/es/icon/style.css +1 -1
- package/es/menu/src/menu.js +211 -62
- package/es/menu/style.css +25 -4
- package/es/menu/style.min.css +1 -1
- package/es/password-input/src/password-input.js +10 -10
- package/es/password-input/style.css +199 -199
- package/es/password-input/style.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/ui/index.js +5 -2
- package/es/ui/src/dom.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/vxe-form/style.css +135 -70
- package/es/vxe-form/style.min.css +1 -1
- package/es/vxe-form-group/index.js +3 -0
- package/es/vxe-form-group/style.css +0 -0
- package/es/vxe-form-group/style.min.css +0 -0
- package/es/vxe-menu/style.css +25 -4
- package/es/vxe-menu/style.min.css +1 -1
- package/es/vxe-password-input/style.css +199 -199
- package/es/vxe-password-input/style.min.css +1 -1
- package/lib/components.js +13 -1
- package/lib/components.min.js +1 -1
- package/lib/date-picker/src/date-picker.js +17 -4
- package/lib/date-picker/src/date-picker.min.js +1 -1
- package/lib/form/src/form-config-item.js +20 -146
- package/lib/form/src/form-config-item.min.js +1 -1
- package/lib/form/src/form-group.js +120 -0
- package/lib/form/src/form-group.min.js +1 -0
- package/lib/form/src/form-item.js +35 -130
- package/lib/form/src/form-item.min.js +1 -1
- package/lib/form/src/form.js +21 -2
- package/lib/form/src/form.min.js +1 -1
- package/lib/form/src/itemInfo.js +3 -0
- package/lib/form/src/itemInfo.min.js +1 -1
- package/lib/form/src/render.js +209 -8
- package/lib/form/src/render.min.js +1 -1
- package/lib/form/src/util.js +2 -2
- package/lib/form/style/style.css +135 -70
- package/lib/form/style/style.min.css +1 -1
- package/lib/form-gather/index.js +7 -4
- package/lib/form-gather/index.min.js +1 -1
- package/lib/form-group/index.js +19 -0
- package/lib/form-group/index.min.js +1 -0
- package/lib/form-group/style/index.js +1 -0
- package/lib/form-group/style/style.css +0 -0
- package/lib/form-group/style/style.min.css +0 -0
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.umd.js +620 -418
- package/lib/index.umd.min.js +1 -1
- package/lib/menu/src/menu.js +203 -64
- package/lib/menu/src/menu.min.js +1 -1
- package/lib/menu/style/style.css +25 -4
- package/lib/menu/style/style.min.css +1 -1
- package/lib/password-input/src/password-input.js +10 -10
- package/lib/password-input/src/password-input.min.js +1 -1
- package/lib/password-input/style/style.css +199 -199
- package/lib/password-input/style/style.min.css +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/ui/index.js +5 -2
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/dom.js +1 -1
- package/lib/ui/src/dom.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-form/style/style.css +135 -70
- package/lib/vxe-form/style/style.min.css +1 -1
- package/lib/vxe-form-group/index.js +23 -0
- package/lib/vxe-form-group/index.min.js +1 -0
- package/lib/vxe-form-group/style/index.js +1 -0
- package/lib/vxe-form-group/style/style.css +0 -0
- package/lib/vxe-form-group/style/style.min.css +0 -0
- package/lib/vxe-menu/style/style.css +25 -4
- package/lib/vxe-menu/style/style.min.css +1 -1
- package/lib/vxe-password-input/style/style.css +199 -199
- package/lib/vxe-password-input/style/style.min.css +1 -1
- package/package.json +1 -1
- package/packages/components.ts +3 -0
- package/packages/date-picker/src/date-picker.ts +18 -4
- package/packages/form/src/form-config-item.ts +28 -165
- package/packages/form/src/form-group.ts +121 -0
- package/packages/form/src/form-item.ts +48 -160
- package/packages/form/src/form.ts +15 -2
- package/packages/form/src/itemInfo.ts +3 -0
- package/packages/form/src/render.ts +199 -20
- package/packages/form/src/util.ts +4 -4
- package/packages/form-gather/index.ts +3 -1
- package/packages/form-group/index.ts +16 -0
- package/packages/menu/src/menu.ts +220 -65
- package/packages/password-input/src/password-input.ts +10 -10
- package/packages/ui/index.ts +4 -1
- package/packages/ui/src/dom.ts +1 -1
- package/styles/all.scss +1 -0
- package/styles/components/form-group.scss +0 -0
- package/styles/components/form.scss +216 -65
- package/styles/components/menu.scss +26 -8
- package/styles/components/password-input.scss +70 -70
- package/styles/theme/base.scss +4 -4
- package/styles/theme/dark.scss +6 -1
- package/styles/theme/light.scss +5 -1
- package/types/all.d.ts +3 -0
- package/types/components/date-picker.d.ts +2 -0
- package/types/components/form-group.d.ts +63 -0
- package/types/components/form-item.d.ts +12 -0
- package/types/components/form.d.ts +9 -0
- package/types/components/grid.d.ts +11 -0
- package/types/components/menu.d.ts +6 -0
- package/types/ui/global-config.d.ts +2 -0
- package/es/form/src/form-gather.js +0 -87
- package/lib/form/src/form-gather.js +0 -99
- package/lib/form/src/form-gather.min.js +0 -1
- package/packages/form/src/form-gather.ts +0 -104
- /package/es/icon/style/{iconfont.1726713527185.ttf → iconfont.1727008528682.ttf} +0 -0
- /package/es/icon/style/{iconfont.1726713527185.woff → iconfont.1727008528682.woff} +0 -0
- /package/es/icon/style/{iconfont.1726713527185.woff2 → iconfont.1727008528682.woff2} +0 -0
- /package/es/{iconfont.1726713527185.ttf → iconfont.1727008528682.ttf} +0 -0
- /package/es/{iconfont.1726713527185.woff → iconfont.1727008528682.woff} +0 -0
- /package/es/{iconfont.1726713527185.woff2 → iconfont.1727008528682.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1726713527185.ttf → iconfont.1727008528682.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1726713527185.woff → iconfont.1727008528682.woff} +0 -0
- /package/lib/icon/style/{iconfont.1726713527185.woff2 → iconfont.1727008528682.woff2} +0 -0
- /package/lib/{iconfont.1726713527185.ttf → iconfont.1727008528682.ttf} +0 -0
- /package/lib/{iconfont.1726713527185.woff → iconfont.1727008528682.woff} +0 -0
- /package/lib/{iconfont.1726713527185.woff2 → iconfont.1727008528682.woff2} +0 -0
package/README.md
CHANGED
package/es/components.js
CHANGED
|
@@ -22,6 +22,7 @@ import VxeDrawer, { DrawerController } from './drawer';
|
|
|
22
22
|
import VxeForm from './form';
|
|
23
23
|
// import VxeFormDesign from './form-design'
|
|
24
24
|
import VxeFormGather from './form-gather';
|
|
25
|
+
import VxeFormGroup from './form-group';
|
|
25
26
|
import VxeFormItem from './form-item';
|
|
26
27
|
// import VxeFormView from './form-view'
|
|
27
28
|
import VxeIcon from './icon';
|
|
@@ -91,6 +92,7 @@ const components = [
|
|
|
91
92
|
VxeForm,
|
|
92
93
|
// VxeFormDesign,
|
|
93
94
|
VxeFormGather,
|
|
95
|
+
VxeFormGroup,
|
|
94
96
|
VxeFormItem,
|
|
95
97
|
// VxeFormView,
|
|
96
98
|
VxeIcon,
|
|
@@ -176,6 +178,7 @@ export * from './drawer';
|
|
|
176
178
|
export * from './form';
|
|
177
179
|
// export * from './form-design'
|
|
178
180
|
export * from './form-gather';
|
|
181
|
+
export * from './form-group';
|
|
179
182
|
export * from './form-item';
|
|
180
183
|
// export * from './form-view'
|
|
181
184
|
export * from './icon';
|
|
@@ -666,6 +666,20 @@ export default defineVxeComponent({
|
|
|
666
666
|
reactData.isActivated = false;
|
|
667
667
|
return $xeDatePicker.$nextTick();
|
|
668
668
|
},
|
|
669
|
+
updateModelValue(modelValue) {
|
|
670
|
+
const $xeDatePicker = this;
|
|
671
|
+
const reactData = $xeDatePicker.reactData;
|
|
672
|
+
let val = '';
|
|
673
|
+
if (modelValue) {
|
|
674
|
+
if (XEUtils.isNumber(modelValue) && /^[0-9]{11,15}$/.test(`${modelValue}`)) {
|
|
675
|
+
val = new Date(modelValue);
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
val = modelValue;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
reactData.inputValue = val;
|
|
682
|
+
},
|
|
669
683
|
parseDate(value, format) {
|
|
670
684
|
const $xeDatePicker = this;
|
|
671
685
|
const props = $xeDatePicker;
|
|
@@ -824,7 +838,9 @@ export default defineVxeComponent({
|
|
|
824
838
|
*/
|
|
825
839
|
initValue() {
|
|
826
840
|
const $xeDatePicker = this;
|
|
841
|
+
const props = $xeDatePicker;
|
|
827
842
|
const isDatePickerType = $xeDatePicker.computeIsDatePickerType;
|
|
843
|
+
$xeDatePicker.updateModelValue(props.value);
|
|
828
844
|
if (isDatePickerType) {
|
|
829
845
|
$xeDatePicker.changeValue();
|
|
830
846
|
}
|
|
@@ -2361,17 +2377,15 @@ export default defineVxeComponent({
|
|
|
2361
2377
|
watch: {
|
|
2362
2378
|
value(val) {
|
|
2363
2379
|
const $xeDatePicker = this;
|
|
2364
|
-
|
|
2365
|
-
reactData.inputValue = val;
|
|
2380
|
+
$xeDatePicker.updateModelValue(val);
|
|
2366
2381
|
$xeDatePicker.changeValue();
|
|
2367
2382
|
},
|
|
2368
2383
|
type() {
|
|
2369
2384
|
const $xeDatePicker = this;
|
|
2370
|
-
const props = $xeDatePicker;
|
|
2371
2385
|
const reactData = $xeDatePicker.reactData;
|
|
2372
2386
|
// 切换类型是重置内置变量
|
|
2373
2387
|
Object.assign(reactData, {
|
|
2374
|
-
inputValue:
|
|
2388
|
+
inputValue: '',
|
|
2375
2389
|
datetimePanelValue: null,
|
|
2376
2390
|
datePanelValue: null,
|
|
2377
2391
|
datePanelLabel: '',
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { defineVxeComponent } from '../../ui/src/comp';
|
|
2
2
|
import XEUtils from 'xe-utils';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { renderTitle } from './render';
|
|
7
|
-
import { isActiveItem } from './util';
|
|
3
|
+
import { renderer, globalMixins, renderEmptyElement } from '../../ui';
|
|
4
|
+
import { isEnableConf } from '../../ui/src/utils';
|
|
5
|
+
import { renderTitle, getItemClass, getItemContentClass, renderItemContent } from './render';
|
|
8
6
|
const VxeFormConfigItem = defineVxeComponent({
|
|
9
7
|
name: 'VxeFormConfigItem',
|
|
10
8
|
mixins: [
|
|
@@ -22,176 +20,47 @@ const VxeFormConfigItem = defineVxeComponent({
|
|
|
22
20
|
const xeFormItemInfo = this;
|
|
23
21
|
return {
|
|
24
22
|
xeFormItemInfo,
|
|
25
|
-
$
|
|
23
|
+
$xeFormGroup: null
|
|
26
24
|
};
|
|
27
25
|
},
|
|
28
26
|
computed: Object.assign({}, {}),
|
|
29
27
|
methods: {
|
|
30
|
-
|
|
28
|
+
renderItem(h, $xeForm, item) {
|
|
31
29
|
const $xeFormConfigItem = this;
|
|
32
|
-
const props = $xeFormConfigItem;
|
|
33
|
-
const $xeForm = $xeFormConfigItem.$xeForm;
|
|
34
30
|
const formProps = $xeForm;
|
|
35
|
-
const
|
|
36
|
-
const {
|
|
37
|
-
const item = props.itemConfig;
|
|
38
|
-
const { collapseAll } = formReactData;
|
|
39
|
-
const validOpts = $xeForm.computeValidOpts;
|
|
40
|
-
const { slots, title, visible, folding, field, collapseNode, itemRender, showError, errRule, className, titleOverflow, vertical, padding, children, showTitle, contentClassName, contentStyle, titleClassName, titleStyle } = item;
|
|
31
|
+
const { data, readonly, disabled } = formProps;
|
|
32
|
+
const { visible, field, itemRender, contentStyle, children, showContent } = item;
|
|
41
33
|
const compConf = isEnableConf(itemRender) ? renderer.get(itemRender.name) : null;
|
|
42
|
-
const itemClassName = compConf ? (compConf.formItemClassName || compConf.itemClassName) : '';
|
|
43
34
|
const itemStyle = compConf ? (compConf.formItemStyle || compConf.itemStyle) : null;
|
|
44
|
-
const itemContentClassName = compConf ? (compConf.formItemContentClassName || compConf.itemContentClassName) : '';
|
|
45
35
|
const itemContentStyle = compConf ? (compConf.formItemContentStyle || compConf.itemContentStyle) : null;
|
|
46
|
-
const itemTitleClassName = compConf ? (compConf.formItemTitleClassName || compConf.itemTitleClassName) : '';
|
|
47
|
-
const itemTitleStyle = compConf ? (compConf.formItemTitleStyle || compConf.itemTitleStyle) : null;
|
|
48
|
-
const defaultSlot = slots ? slots.default : null;
|
|
49
|
-
const titleSlot = slots ? slots.title : null;
|
|
50
|
-
const span = item.span || allSpan;
|
|
51
|
-
const align = item.align || allAlign;
|
|
52
|
-
const itemPadding = XEUtils.eqNull(padding) ? allPadding : padding;
|
|
53
|
-
const itemVertical = XEUtils.eqNull(vertical) ? allVertical : vertical;
|
|
54
|
-
const titleBold = XEUtils.eqNull(item.titleBold) ? allTitleBold : item.titleBold;
|
|
55
|
-
const titleAlign = XEUtils.eqNull(item.titleAlign) ? allTitleAlign : item.titleAlign;
|
|
56
|
-
const titleWidth = itemVertical ? null : (XEUtils.eqNull(item.titleWidth) ? allTitleWidth : item.titleWidth);
|
|
57
|
-
const titleColon = XEUtils.eqNull(item.titleColon) ? allTitleColon : item.titleColon;
|
|
58
|
-
const titleAsterisk = XEUtils.eqNull(item.titleAsterisk) ? allTitleAsterisk : item.titleAsterisk;
|
|
59
|
-
const itemOverflow = XEUtils.eqNull(titleOverflow) ? allTitleOverflow : titleOverflow;
|
|
60
|
-
const ovEllipsis = itemOverflow === 'ellipsis';
|
|
61
|
-
const ovTitle = itemOverflow === 'title';
|
|
62
|
-
const ovTooltip = itemOverflow === true || itemOverflow === 'tooltip';
|
|
63
|
-
const hasEllipsis = ovTitle || ovTooltip || ovEllipsis;
|
|
64
36
|
const params = { data, disabled, readonly, field, property: field, item, $form: $xeForm, $grid: $xeForm.xegrid };
|
|
37
|
+
const hasGroup = children && children.length > 0;
|
|
65
38
|
if (visible === false) {
|
|
66
39
|
return renderEmptyElement($xeFormConfigItem);
|
|
67
40
|
}
|
|
68
|
-
let isRequired = false;
|
|
69
|
-
let isValid = false;
|
|
70
|
-
if (!readonly && rules) {
|
|
71
|
-
const itemRules = rules[field];
|
|
72
|
-
if (itemRules && itemRules.length) {
|
|
73
|
-
isValid = true;
|
|
74
|
-
isRequired = itemRules.some((rule) => rule.required);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// 如果为项集合
|
|
78
|
-
const isGather = children && children.length > 0;
|
|
79
|
-
if (isGather) {
|
|
80
|
-
const childVNs = children.map((childItem, index) => {
|
|
81
|
-
return h(VxeFormConfigItem, {
|
|
82
|
-
key: index,
|
|
83
|
-
props: {
|
|
84
|
-
itemConfig: childItem
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
return childVNs.length
|
|
89
|
-
? h('div', {
|
|
90
|
-
class: ['vxe-form--gather vxe-form--item-row', item.id, span ? `vxe-form--item-col_${span} is--span` : '', className ? (XEUtils.isFunction(className) ? className(params) : className) : '']
|
|
91
|
-
}, childVNs)
|
|
92
|
-
: renderEmptyElement($xeFormConfigItem);
|
|
93
|
-
}
|
|
94
|
-
let contentVNs = [];
|
|
95
|
-
const rftContent = compConf ? (compConf.renderFormItemContent || compConf.renderItemContent) : null;
|
|
96
|
-
if (defaultSlot) {
|
|
97
|
-
contentVNs = $xeForm.callSlot(defaultSlot, params, h);
|
|
98
|
-
}
|
|
99
|
-
else if (rftContent) {
|
|
100
|
-
contentVNs = getSlotVNs(rftContent.call($xeForm, h, itemRender, params));
|
|
101
|
-
}
|
|
102
|
-
else if (field) {
|
|
103
|
-
contentVNs = [XEUtils.toValueString(XEUtils.get(data, field))];
|
|
104
|
-
}
|
|
105
|
-
if (collapseNode) {
|
|
106
|
-
contentVNs.push(h('div', {
|
|
107
|
-
class: 'vxe-form--item-trigger-node',
|
|
108
|
-
on: {
|
|
109
|
-
click: $xeForm.toggleCollapseEvent
|
|
110
|
-
}
|
|
111
|
-
}, [
|
|
112
|
-
h('span', {
|
|
113
|
-
class: 'vxe-form--item-trigger-text'
|
|
114
|
-
}, collapseAll ? getI18n('vxe.form.unfolding') : getI18n('vxe.form.folding')),
|
|
115
|
-
h('i', {
|
|
116
|
-
class: ['vxe-form--item-trigger-icon', collapseAll ? getIcon().FORM_FOLDING : getIcon().FORM_UNFOLDING]
|
|
117
|
-
})
|
|
118
|
-
]));
|
|
119
|
-
}
|
|
120
|
-
if (errRule && validOpts.showMessage) {
|
|
121
|
-
contentVNs.push(h('div', {
|
|
122
|
-
class: 'vxe-form--item-valid',
|
|
123
|
-
style: errRule.maxWidth
|
|
124
|
-
? {
|
|
125
|
-
width: `${errRule.maxWidth}px`
|
|
126
|
-
}
|
|
127
|
-
: {}
|
|
128
|
-
}, errRule.content));
|
|
129
|
-
}
|
|
130
|
-
const ons = ovTooltip
|
|
131
|
-
? {
|
|
132
|
-
mouseenter(evnt) {
|
|
133
|
-
$xeForm.triggerTitleTipEvent(evnt, params);
|
|
134
|
-
},
|
|
135
|
-
mouseleave: $xeForm.handleTitleTipLeaveEvent
|
|
136
|
-
}
|
|
137
|
-
: {};
|
|
138
41
|
return h('div', {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
item.id,
|
|
142
|
-
span ? `vxe-form--item-col_${span} is--span` : '',
|
|
143
|
-
className ? (XEUtils.isFunction(className) ? className(params) : className) : '',
|
|
144
|
-
itemClassName ? (XEUtils.isFunction(itemClassName) ? itemClassName(params) : itemClassName) : '',
|
|
145
|
-
{
|
|
146
|
-
'is--title': title,
|
|
147
|
-
'is--colon': titleColon,
|
|
148
|
-
'is--bold': titleBold,
|
|
149
|
-
'is--padding': itemPadding,
|
|
150
|
-
'is--vertical': itemVertical,
|
|
151
|
-
'is--asterisk': titleAsterisk,
|
|
152
|
-
'is--valid': isValid,
|
|
153
|
-
'is--required': isRequired,
|
|
154
|
-
'is--hidden': folding && collapseAll,
|
|
155
|
-
'is--active': isActiveItem($xeForm, item),
|
|
156
|
-
'is--error': showError
|
|
157
|
-
}
|
|
158
|
-
],
|
|
42
|
+
key: item.id,
|
|
43
|
+
class: getItemClass($xeForm, item),
|
|
159
44
|
style: XEUtils.isFunction(itemStyle) ? itemStyle(params) : (itemStyle || {})
|
|
160
45
|
}, [
|
|
161
|
-
h
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
class: [
|
|
167
|
-
'vxe-form--item-title',
|
|
168
|
-
titleAlign ? `align--${titleAlign}` : '',
|
|
169
|
-
hasEllipsis ? 'is--ellipsis' : '',
|
|
170
|
-
itemTitleClassName ? (XEUtils.isFunction(itemTitleClassName) ? itemTitleClassName(params) : itemTitleClassName) : '',
|
|
171
|
-
titleClassName ? (XEUtils.isFunction(titleClassName) ? titleClassName(params) : titleClassName) : ''
|
|
172
|
-
],
|
|
173
|
-
style: Object.assign({}, XEUtils.isFunction(itemTitleStyle) ? itemTitleStyle(params) : itemTitleStyle, XEUtils.isFunction(titleStyle) ? titleStyle(params) : titleStyle, titleWidth
|
|
174
|
-
? {
|
|
175
|
-
width: isNaN(titleWidth) ? titleWidth : `${titleWidth}px`
|
|
176
|
-
}
|
|
177
|
-
: null),
|
|
178
|
-
attrs: {
|
|
179
|
-
title: ovTitle ? getFuncText(title) : null
|
|
180
|
-
},
|
|
181
|
-
on: ons
|
|
182
|
-
}, renderTitle(h, $xeFormConfigItem, $xeForm, item))
|
|
183
|
-
: null,
|
|
184
|
-
h('div', {
|
|
185
|
-
class: [
|
|
186
|
-
'vxe-form--item-content',
|
|
187
|
-
align ? `align--${align}` : '',
|
|
188
|
-
itemContentClassName ? (XEUtils.isFunction(itemContentClassName) ? itemContentClassName(params) : itemContentClassName) : '',
|
|
189
|
-
contentClassName ? (XEUtils.isFunction(contentClassName) ? contentClassName(params) : contentClassName) : ''
|
|
190
|
-
],
|
|
46
|
+
renderTitle(h, $xeForm, item),
|
|
47
|
+
showContent === false
|
|
48
|
+
? renderEmptyElement($xeFormConfigItem)
|
|
49
|
+
: h('div', {
|
|
50
|
+
class: getItemContentClass($xeForm, item),
|
|
191
51
|
style: Object.assign({}, XEUtils.isFunction(itemContentStyle) ? itemContentStyle(params) : itemContentStyle, XEUtils.isFunction(contentStyle) ? contentStyle(params) : contentStyle)
|
|
192
|
-
},
|
|
193
|
-
|
|
52
|
+
}, hasGroup
|
|
53
|
+
? children.map((childItem) => $xeFormConfigItem.renderItem(h, $xeForm, childItem))
|
|
54
|
+
: [
|
|
55
|
+
renderItemContent(h, $xeForm, item)
|
|
56
|
+
])
|
|
194
57
|
]);
|
|
58
|
+
},
|
|
59
|
+
renderVN(h) {
|
|
60
|
+
const $xeFormConfigItem = this;
|
|
61
|
+
const props = $xeFormConfigItem;
|
|
62
|
+
const $xeForm = $xeFormConfigItem.$xeForm;
|
|
63
|
+
return $xeFormConfigItem.renderItem(h, $xeForm, props.itemConfig);
|
|
195
64
|
}
|
|
196
65
|
},
|
|
197
66
|
render(h) {
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { defineVxeComponent } from '../../ui/src/comp';
|
|
2
|
+
import XEUtils from 'xe-utils';
|
|
3
|
+
import { renderer, globalMixins, renderEmptyElement } from '../../ui';
|
|
4
|
+
import { isEnableConf } from '../../ui/src/utils';
|
|
5
|
+
import { createItem, watchItem, destroyItem, assembleItem } from './util';
|
|
6
|
+
import { formItemProps } from './form-item';
|
|
7
|
+
import { renderTitle, getItemClass, getItemContentClass } from './render';
|
|
8
|
+
const formItemPropKeys = Object.keys(formItemProps);
|
|
9
|
+
export default defineVxeComponent({
|
|
10
|
+
name: 'VxeFormGroup',
|
|
11
|
+
mixins: [
|
|
12
|
+
globalMixins.sizeMixin
|
|
13
|
+
],
|
|
14
|
+
props: formItemProps,
|
|
15
|
+
inject: {
|
|
16
|
+
$xeForm: {
|
|
17
|
+
default: null
|
|
18
|
+
},
|
|
19
|
+
$xeParentFormGroup: {
|
|
20
|
+
from: '$xeFormGroup',
|
|
21
|
+
default: null
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
data() {
|
|
25
|
+
const xID = XEUtils.uniqueId();
|
|
26
|
+
const formItem = {};
|
|
27
|
+
const reactData = {};
|
|
28
|
+
return {
|
|
29
|
+
xID,
|
|
30
|
+
formItem,
|
|
31
|
+
reactData
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
computed: Object.assign({}, {}),
|
|
35
|
+
methods: {
|
|
36
|
+
renderVN(h) {
|
|
37
|
+
const $xeFormGroup = this;
|
|
38
|
+
const slots = $xeFormGroup.$scopedSlots;
|
|
39
|
+
const formItem = $xeFormGroup.formItem;
|
|
40
|
+
const $xeForm = $xeFormGroup.$xeForm;
|
|
41
|
+
const formProps = $xeForm;
|
|
42
|
+
const item = formItem;
|
|
43
|
+
const { data, readonly, disabled } = formProps;
|
|
44
|
+
const { visible, field, itemRender, contentStyle } = item;
|
|
45
|
+
const compConf = isEnableConf(itemRender) ? renderer.get(itemRender.name) : null;
|
|
46
|
+
const itemStyle = compConf ? (compConf.formItemStyle || compConf.itemStyle) : null;
|
|
47
|
+
const itemContentStyle = compConf ? (compConf.formItemContentStyle || compConf.itemContentStyle) : null;
|
|
48
|
+
const defaultSlot = slots ? slots.default : null;
|
|
49
|
+
const params = { data, disabled, readonly, field, property: field, item, $form: $xeForm, $grid: $xeForm.xegrid };
|
|
50
|
+
if (visible === false) {
|
|
51
|
+
return renderEmptyElement($xeFormGroup);
|
|
52
|
+
}
|
|
53
|
+
return h('div', {
|
|
54
|
+
ref: 'refElem',
|
|
55
|
+
key: item.id,
|
|
56
|
+
class: getItemClass($xeForm, item, true),
|
|
57
|
+
style: XEUtils.isFunction(itemStyle) ? itemStyle(params) : (itemStyle || {})
|
|
58
|
+
}, [
|
|
59
|
+
renderTitle(h, $xeForm, item, true),
|
|
60
|
+
h('div', {
|
|
61
|
+
class: getItemContentClass($xeForm, item, true),
|
|
62
|
+
style: Object.assign({}, XEUtils.isFunction(itemContentStyle) ? itemContentStyle(params) : itemContentStyle, XEUtils.isFunction(contentStyle) ? contentStyle(params) : contentStyle)
|
|
63
|
+
}, defaultSlot ? defaultSlot({}) : [])
|
|
64
|
+
]);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
provide() {
|
|
68
|
+
const $xeFormGroup = this;
|
|
69
|
+
const formItem = $xeFormGroup.formItem;
|
|
70
|
+
return {
|
|
71
|
+
$xeFormGroup,
|
|
72
|
+
$xeFormItem: null,
|
|
73
|
+
xeFormItemInfo: {
|
|
74
|
+
itemConfig: formItem
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
created() {
|
|
79
|
+
const $xeFormGroup = this;
|
|
80
|
+
const props = $xeFormGroup;
|
|
81
|
+
const $xeForm = $xeFormGroup.$xeForm;
|
|
82
|
+
const formItem = createItem($xeForm, props);
|
|
83
|
+
formItem.children = [];
|
|
84
|
+
$xeFormGroup.formItem = formItem;
|
|
85
|
+
watchItem($xeFormGroup, formItemPropKeys, formItem);
|
|
86
|
+
},
|
|
87
|
+
mounted() {
|
|
88
|
+
const $xeFormGroup = this;
|
|
89
|
+
const formItem = $xeFormGroup.formItem;
|
|
90
|
+
const $xeForm = $xeFormGroup.$xeForm;
|
|
91
|
+
const $xeParentFormGroup = $xeFormGroup.$xeParentFormGroup;
|
|
92
|
+
const elem = $xeFormGroup.$refs.refElem;
|
|
93
|
+
assembleItem($xeForm, elem, formItem, $xeParentFormGroup);
|
|
94
|
+
},
|
|
95
|
+
beforeDestroy() {
|
|
96
|
+
const $xeFormGroup = this;
|
|
97
|
+
const formItem = $xeFormGroup.formItem;
|
|
98
|
+
const $xeForm = $xeFormGroup.$xeForm;
|
|
99
|
+
destroyItem($xeForm, formItem);
|
|
100
|
+
},
|
|
101
|
+
render(h) {
|
|
102
|
+
return this.renderVN(h);
|
|
103
|
+
}
|
|
104
|
+
});
|
package/es/form/src/form-item.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { defineVxeComponent } from '../../ui/src/comp';
|
|
2
2
|
import XEUtils from 'xe-utils';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { renderTitle } from './render';
|
|
3
|
+
import { renderer, renderEmptyElement, globalMixins } from '../../ui';
|
|
4
|
+
import { isEnableConf } from '../../ui/src/utils';
|
|
5
|
+
import { createItem, watchItem, destroyItem, assembleItem } from './util';
|
|
6
|
+
import { renderTitle, renderItemContent, getItemClass, getItemContentClass } from './render';
|
|
8
7
|
export const formItemProps = {
|
|
9
8
|
title: String,
|
|
10
9
|
field: String,
|
|
11
|
-
span:
|
|
12
|
-
|
|
10
|
+
span: {
|
|
11
|
+
type: [String, Number],
|
|
12
|
+
default: null
|
|
13
|
+
},
|
|
14
|
+
align: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: null
|
|
17
|
+
},
|
|
18
|
+
verticalAlign: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: null
|
|
21
|
+
},
|
|
22
|
+
titleBackground: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: null
|
|
25
|
+
},
|
|
13
26
|
titleBold: {
|
|
14
27
|
type: Boolean,
|
|
15
28
|
default: null
|
|
@@ -59,6 +72,10 @@ export const formItemProps = {
|
|
|
59
72
|
type: Boolean,
|
|
60
73
|
default: null
|
|
61
74
|
},
|
|
75
|
+
showContent: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: null
|
|
78
|
+
},
|
|
62
79
|
folding: Boolean,
|
|
63
80
|
collapseNode: Boolean,
|
|
64
81
|
itemRender: Object,
|
|
@@ -75,7 +92,7 @@ export default defineVxeComponent({
|
|
|
75
92
|
$xeForm: {
|
|
76
93
|
default: null
|
|
77
94
|
},
|
|
78
|
-
$
|
|
95
|
+
$xeFormGroup: {
|
|
79
96
|
default: null
|
|
80
97
|
}
|
|
81
98
|
},
|
|
@@ -94,157 +111,40 @@ export default defineVxeComponent({
|
|
|
94
111
|
renderItem(h, $xeForm, item) {
|
|
95
112
|
const $xeFormItem = this;
|
|
96
113
|
const formProps = $xeForm;
|
|
97
|
-
const
|
|
98
|
-
const {
|
|
99
|
-
const { collapseAll } = formReactData;
|
|
100
|
-
const validOpts = $xeForm.computeValidOpts;
|
|
101
|
-
const { slots, title, visible, folding, field, collapseNode, itemRender, showError, errRule, className, titleOverflow, vertical, padding, showTitle, contentClassName, contentStyle, titleClassName, titleStyle } = item;
|
|
114
|
+
const { data, readonly, disabled } = formProps;
|
|
115
|
+
const { visible, field, itemRender, contentStyle, showContent } = item;
|
|
102
116
|
const compConf = isEnableConf(itemRender) ? renderer.get(itemRender.name) : null;
|
|
103
|
-
const itemClassName = compConf ? (compConf.formItemClassName || compConf.itemClassName) : '';
|
|
104
117
|
const itemStyle = compConf ? (compConf.formItemStyle || compConf.itemStyle) : null;
|
|
105
|
-
const itemContentClassName = compConf ? (compConf.formItemContentClassName || compConf.itemContentClassName) : '';
|
|
106
118
|
const itemContentStyle = compConf ? (compConf.formItemContentStyle || compConf.itemContentStyle) : null;
|
|
107
|
-
const itemTitleClassName = compConf ? (compConf.formItemTitleClassName || compConf.itemTitleClassName) : '';
|
|
108
|
-
const itemTitleStyle = compConf ? (compConf.formItemTitleStyle || compConf.itemTitleStyle) : null;
|
|
109
|
-
const defaultSlot = slots ? slots.default : null;
|
|
110
|
-
const titleSlot = slots ? slots.title : null;
|
|
111
|
-
const span = item.span || formProps.span;
|
|
112
|
-
const align = item.align || formProps.align;
|
|
113
|
-
const itemPadding = XEUtils.eqNull(padding) ? allPadding : padding;
|
|
114
|
-
const itemVertical = XEUtils.eqNull(vertical) ? allVertical : vertical;
|
|
115
|
-
const titleBold = XEUtils.eqNull(item.titleBold) ? allTitleBold : item.titleBold;
|
|
116
|
-
const titleAlign = XEUtils.eqNull(item.titleAlign) ? allTitleAlign : item.titleAlign;
|
|
117
|
-
const titleWidth = itemVertical ? null : (XEUtils.eqNull(item.titleWidth) ? allTitleWidth : item.titleWidth);
|
|
118
|
-
const titleColon = XEUtils.eqNull(item.titleColon) ? allTitleColon : item.titleColon;
|
|
119
|
-
const titleAsterisk = XEUtils.eqNull(item.titleAsterisk) ? allTitleAsterisk : item.titleAsterisk;
|
|
120
|
-
const itemOverflow = XEUtils.eqNull(titleOverflow) ? allTitleOverflow : titleOverflow;
|
|
121
|
-
const ovEllipsis = itemOverflow === 'ellipsis';
|
|
122
|
-
const ovTitle = itemOverflow === 'title';
|
|
123
|
-
const ovTooltip = itemOverflow === true || itemOverflow === 'tooltip';
|
|
124
|
-
const hasEllipsis = ovTitle || ovTooltip || ovEllipsis;
|
|
125
119
|
const params = { data, disabled, readonly, field, property: field, item, $form: $xeForm, $grid: $xeForm.xegrid };
|
|
126
|
-
let isRequired = false;
|
|
127
|
-
let isValid = false;
|
|
128
120
|
if (visible === false) {
|
|
129
121
|
return renderEmptyElement($xeFormItem);
|
|
130
122
|
}
|
|
131
|
-
if (!readonly && rules) {
|
|
132
|
-
const itemRules = rules[field];
|
|
133
|
-
if (itemRules && itemRules.length) {
|
|
134
|
-
isValid = true;
|
|
135
|
-
isRequired = itemRules.some((rule) => rule.required);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
let contentVNs = [];
|
|
139
|
-
const rftContent = compConf ? (compConf.renderFormItemContent || compConf.renderItemContent) : null;
|
|
140
|
-
if (defaultSlot) {
|
|
141
|
-
contentVNs = $xeForm.callSlot(defaultSlot, params, h);
|
|
142
|
-
}
|
|
143
|
-
else if (rftContent) {
|
|
144
|
-
contentVNs = getSlotVNs(rftContent.call($xeForm, h, itemRender, params));
|
|
145
|
-
}
|
|
146
|
-
else if (field) {
|
|
147
|
-
contentVNs = [`${XEUtils.get(data, field)}`];
|
|
148
|
-
}
|
|
149
|
-
if (collapseNode) {
|
|
150
|
-
contentVNs.push(h('div', {
|
|
151
|
-
class: 'vxe-form--item-trigger-node',
|
|
152
|
-
on: {
|
|
153
|
-
click: $xeForm.toggleCollapseEvent
|
|
154
|
-
}
|
|
155
|
-
}, [
|
|
156
|
-
h('span', {
|
|
157
|
-
class: 'vxe-form--item-trigger-text'
|
|
158
|
-
}, collapseAll ? getI18n('vxe.form.unfolding') : getI18n('vxe.form.folding')),
|
|
159
|
-
h('i', {
|
|
160
|
-
class: ['vxe-form--item-trigger-icon', collapseAll ? getIcon().FORM_FOLDING : getIcon().FORM_UNFOLDING]
|
|
161
|
-
})
|
|
162
|
-
]));
|
|
163
|
-
}
|
|
164
|
-
if (errRule && validOpts.showMessage) {
|
|
165
|
-
contentVNs.push(h('div', {
|
|
166
|
-
class: 'vxe-form--item-valid',
|
|
167
|
-
style: errRule.maxWidth
|
|
168
|
-
? {
|
|
169
|
-
width: `${errRule.maxWidth}px`
|
|
170
|
-
}
|
|
171
|
-
: {}
|
|
172
|
-
}, errRule.message));
|
|
173
|
-
}
|
|
174
|
-
const ons = ovTooltip
|
|
175
|
-
? {
|
|
176
|
-
mouseenter(evnt) {
|
|
177
|
-
$xeForm.triggerTitleTipEvent(evnt, params);
|
|
178
|
-
},
|
|
179
|
-
mouseleave: $xeForm.handleTitleTipLeaveEvent
|
|
180
|
-
}
|
|
181
|
-
: {};
|
|
182
123
|
return h('div', {
|
|
183
124
|
ref: 'refElem',
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
item.id,
|
|
187
|
-
span ? `vxe-form--item-col_${span} is--span` : '',
|
|
188
|
-
className ? (XEUtils.isFunction(className) ? className(params) : className) : '',
|
|
189
|
-
itemClassName ? (XEUtils.isFunction(itemClassName) ? itemClassName(params) : itemClassName) : '',
|
|
190
|
-
{
|
|
191
|
-
'is--title': title,
|
|
192
|
-
'is--colon': titleColon,
|
|
193
|
-
'is--bold': titleBold,
|
|
194
|
-
'is--padding': itemPadding,
|
|
195
|
-
'is--vertical': itemVertical,
|
|
196
|
-
'is--asterisk': titleAsterisk,
|
|
197
|
-
'is--valid': isValid,
|
|
198
|
-
'is--required': isRequired,
|
|
199
|
-
'is--hidden': folding && collapseAll,
|
|
200
|
-
'is--active': isActiveItem($xeForm, item),
|
|
201
|
-
'is--error': showError
|
|
202
|
-
}
|
|
203
|
-
],
|
|
125
|
+
key: item.id,
|
|
126
|
+
class: getItemClass($xeForm, item),
|
|
204
127
|
style: XEUtils.isFunction(itemStyle) ? itemStyle(params) : (itemStyle || {})
|
|
205
128
|
}, [
|
|
206
|
-
h
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
class: [
|
|
212
|
-
'vxe-form--item-title',
|
|
213
|
-
titleAlign ? `align--${titleAlign}` : '',
|
|
214
|
-
hasEllipsis ? 'is--ellipsis' : '',
|
|
215
|
-
itemTitleClassName ? (XEUtils.isFunction(itemTitleClassName) ? itemTitleClassName(params) : itemTitleClassName) : '',
|
|
216
|
-
titleClassName ? (XEUtils.isFunction(titleClassName) ? titleClassName(params) : titleClassName) : ''
|
|
217
|
-
],
|
|
218
|
-
style: Object.assign({}, XEUtils.isFunction(itemTitleStyle) ? itemTitleStyle(params) : itemTitleStyle, XEUtils.isFunction(titleStyle) ? titleStyle(params) : titleStyle, titleWidth
|
|
219
|
-
? {
|
|
220
|
-
width: isNaN(titleWidth) ? titleWidth : `${titleWidth}px`
|
|
221
|
-
}
|
|
222
|
-
: null),
|
|
223
|
-
attrs: {
|
|
224
|
-
title: ovTitle ? getFuncText(title) : null
|
|
225
|
-
},
|
|
226
|
-
on: ons
|
|
227
|
-
}, renderTitle(h, $xeFormItem, $xeForm, item))
|
|
228
|
-
: null,
|
|
229
|
-
h('div', {
|
|
230
|
-
class: [
|
|
231
|
-
'vxe-form--item-content',
|
|
232
|
-
align ? `align--${align}` : '',
|
|
233
|
-
itemContentClassName ? (XEUtils.isFunction(itemContentClassName) ? itemContentClassName(params) : itemContentClassName) : '',
|
|
234
|
-
contentClassName ? (XEUtils.isFunction(contentClassName) ? contentClassName(params) : contentClassName) : ''
|
|
235
|
-
],
|
|
129
|
+
renderTitle(h, $xeForm, item),
|
|
130
|
+
showContent === false
|
|
131
|
+
? renderEmptyElement($xeFormItem)
|
|
132
|
+
: h('div', {
|
|
133
|
+
class: getItemContentClass($xeForm, item),
|
|
236
134
|
style: Object.assign({}, XEUtils.isFunction(itemContentStyle) ? itemContentStyle(params) : itemContentStyle, XEUtils.isFunction(contentStyle) ? contentStyle(params) : contentStyle)
|
|
237
|
-
},
|
|
238
|
-
|
|
135
|
+
}, [
|
|
136
|
+
renderItemContent(h, $xeForm, item)
|
|
137
|
+
])
|
|
239
138
|
]);
|
|
240
139
|
},
|
|
241
140
|
renderVN(h) {
|
|
242
141
|
const $xeFormItem = this;
|
|
243
|
-
const formItem = $xeFormItem.formItem;
|
|
244
142
|
const $xeForm = $xeFormItem.$xeForm;
|
|
143
|
+
const formItem = $xeFormItem.formItem;
|
|
245
144
|
const customLayout = $xeForm ? $xeForm.customLayout : false;
|
|
145
|
+
const item = formItem;
|
|
246
146
|
return customLayout
|
|
247
|
-
? $xeFormItem.renderItem(h, $xeForm,
|
|
147
|
+
? $xeFormItem.renderItem(h, $xeForm, item)
|
|
248
148
|
: h('div', {
|
|
249
149
|
ref: 'refElem'
|
|
250
150
|
});
|
|
@@ -254,7 +154,7 @@ export default defineVxeComponent({
|
|
|
254
154
|
const $xeFormItem = this;
|
|
255
155
|
const formItem = $xeFormItem.formItem;
|
|
256
156
|
return {
|
|
257
|
-
$
|
|
157
|
+
$xeFormGroup: null,
|
|
258
158
|
$xeFormItem,
|
|
259
159
|
xeFormItemInfo: {
|
|
260
160
|
itemConfig: formItem
|
|
@@ -274,10 +174,10 @@ export default defineVxeComponent({
|
|
|
274
174
|
const slots = $xeFormItem.$scopedSlots;
|
|
275
175
|
const formItem = $xeFormItem.formItem;
|
|
276
176
|
const $xeForm = $xeFormItem.$xeForm;
|
|
277
|
-
const $
|
|
177
|
+
const $xeFormGroup = $xeFormItem.$xeFormGroup;
|
|
278
178
|
formItem.slots = slots;
|
|
279
179
|
const elem = $xeFormItem.$refs.refElem;
|
|
280
|
-
assembleItem($xeForm, elem, formItem, $
|
|
180
|
+
assembleItem($xeForm, elem, formItem, $xeFormGroup);
|
|
281
181
|
},
|
|
282
182
|
beforeDestroy() {
|
|
283
183
|
const $xeFormItem = this;
|