@vxe-ui/plugin-render-antd 4.0.3 → 4.0.5
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 +6 -4
- package/dist/all.common.js +1398 -99
- package/dist/form-design/checkbox-widget.js +162 -0
- package/dist/form-design/{a-date-picker.js → date-picker-widget.js} +4 -3
- package/dist/form-design/index.js +129 -6
- package/dist/form-design/{a-input.js → input-widget.js} +4 -3
- package/dist/form-design/number-input-widget.js +143 -0
- package/dist/form-design/radio-widget.js +162 -0
- package/dist/form-design/select-widget.js +154 -0
- package/dist/form-design/switch-widget.js +139 -0
- package/dist/form-design/textarea-widget.js +147 -0
- package/dist/form-design/use.js +225 -0
- package/dist/index.umd.js +1470 -108
- package/dist/index.umd.min.js +1 -1
- package/dist/style.css +2 -1
- package/dist/style.min.css +1 -1
- package/dist/table/index.js +53 -18
- package/package.json +3 -3
- package/src/form-design/checkbox-widget.ts +164 -0
- package/src/form-design/{a-date-picker.ts → date-picker-widget.ts} +5 -4
- package/src/form-design/index.ts +71 -4
- package/src/form-design/{a-input.ts → input-widget.ts} +5 -4
- package/src/form-design/number-input-widget.ts +144 -0
- package/src/form-design/radio-widget.ts +164 -0
- package/src/form-design/select-widget.ts +156 -0
- package/src/form-design/switch-widget.ts +140 -0
- package/src/form-design/textarea-widget.ts +148 -0
- package/src/form-design/use.ts +255 -0
- package/src/table/index.ts +43 -9
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createWidgetASelect = createWidgetASelect;
|
|
7
|
+
var _vue = require("vue");
|
|
8
|
+
var _use = require("./use");
|
|
9
|
+
var _xeUtils = _interopRequireDefault(require("xe-utils"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
+
function createWidgetASelect(VxeUI) {
|
|
12
|
+
var getWidgetASelectConfig = function getWidgetASelectConfig(params) {
|
|
13
|
+
return {
|
|
14
|
+
title: '下拉框',
|
|
15
|
+
icon: 'vxe-icon-select',
|
|
16
|
+
options: {
|
|
17
|
+
placeholder: '请选择',
|
|
18
|
+
options: _xeUtils["default"].range(0, 3).map(function (v, i) {
|
|
19
|
+
return {
|
|
20
|
+
value: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.defValue', [i + 1])
|
|
21
|
+
};
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
var WidgetASelectFormComponent = (0, _vue.defineComponent)({
|
|
27
|
+
props: {
|
|
28
|
+
renderOpts: {
|
|
29
|
+
type: Object,
|
|
30
|
+
"default": function _default() {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
renderParams: {
|
|
35
|
+
type: Object,
|
|
36
|
+
"default": function _default() {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
emits: [],
|
|
42
|
+
setup: function setup(props) {
|
|
43
|
+
var VxeUIFormComponent = VxeUI.getComponent('VxeForm');
|
|
44
|
+
var VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
45
|
+
var VxeUISwitchComponent = VxeUI.getComponent('VxeSwitch');
|
|
46
|
+
var VxeUIInputComponent = VxeUI.getComponent('VxeInput');
|
|
47
|
+
var _useWidgetPropDataSou = (0, _use.useWidgetPropDataSource)(VxeUI, props, false),
|
|
48
|
+
renderDataSourceFormItem = _useWidgetPropDataSou.renderDataSourceFormItem;
|
|
49
|
+
return function () {
|
|
50
|
+
var renderParams = props.renderParams;
|
|
51
|
+
var widget = renderParams.widget;
|
|
52
|
+
return (0, _vue.h)(VxeUIFormComponent, {
|
|
53
|
+
"class": 'vxe-form-design--widget-render-form-wrapper',
|
|
54
|
+
vertical: true,
|
|
55
|
+
span: 24,
|
|
56
|
+
titleBold: true,
|
|
57
|
+
titleOverflow: true,
|
|
58
|
+
data: widget.options
|
|
59
|
+
}, {
|
|
60
|
+
"default": function _default() {
|
|
61
|
+
return [(0, _vue.h)(VxeUIFormItemComponent, {
|
|
62
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
63
|
+
}, {
|
|
64
|
+
"default": function _default() {
|
|
65
|
+
return (0, _vue.h)(VxeUIInputComponent, {
|
|
66
|
+
modelValue: widget.title,
|
|
67
|
+
'onUpdate:modelValue': function onUpdateModelValue(val) {
|
|
68
|
+
widget.title = val;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}), (0, _vue.h)(VxeUIFormItemComponent, {
|
|
73
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
74
|
+
field: 'placeholder',
|
|
75
|
+
itemRender: {
|
|
76
|
+
name: 'ElInput'
|
|
77
|
+
}
|
|
78
|
+
}), (0, _vue.h)(VxeUIFormItemComponent, {
|
|
79
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
80
|
+
}, {
|
|
81
|
+
"default": function _default() {
|
|
82
|
+
return (0, _vue.h)(VxeUISwitchComponent, {
|
|
83
|
+
modelValue: widget.required,
|
|
84
|
+
'onUpdate:modelValue': function onUpdateModelValue(val) {
|
|
85
|
+
widget.required = val;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}), renderDataSourceFormItem()];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
var WidgetASelectViewComponent = (0, _vue.defineComponent)({
|
|
96
|
+
props: {
|
|
97
|
+
renderOpts: {
|
|
98
|
+
type: Object,
|
|
99
|
+
"default": function _default() {
|
|
100
|
+
return {};
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
renderParams: {
|
|
104
|
+
type: Object,
|
|
105
|
+
"default": function _default() {
|
|
106
|
+
return {};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
emits: [],
|
|
111
|
+
setup: function setup(props) {
|
|
112
|
+
var VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
113
|
+
var changeEvent = function changeEvent() {
|
|
114
|
+
var renderParams = props.renderParams;
|
|
115
|
+
var widget = renderParams.widget,
|
|
116
|
+
$formView = renderParams.$formView;
|
|
117
|
+
if ($formView) {
|
|
118
|
+
var itemValue = $formView ? $formView.getItemValue(widget) : null;
|
|
119
|
+
$formView.updateItemStatus(widget, itemValue);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
return function () {
|
|
123
|
+
var renderParams = props.renderParams;
|
|
124
|
+
var widget = renderParams.widget,
|
|
125
|
+
$formView = renderParams.$formView;
|
|
126
|
+
var options = widget.options;
|
|
127
|
+
return (0, _vue.h)(VxeUIFormItemComponent, {
|
|
128
|
+
"class": ['vxe-form-design--widget-render-form-item'],
|
|
129
|
+
field: widget.field,
|
|
130
|
+
title: widget.title
|
|
131
|
+
}, {
|
|
132
|
+
"default": function _default() {
|
|
133
|
+
return (0, _vue.h)((0, _vue.resolveComponent)('a-select'), {
|
|
134
|
+
value: $formView ? $formView.getItemValue(widget) : null,
|
|
135
|
+
options: options.options,
|
|
136
|
+
placeholder: options.placeholder,
|
|
137
|
+
onChange: changeEvent,
|
|
138
|
+
'onUpdate:value': function onUpdateValue(val) {
|
|
139
|
+
if ($formView) {
|
|
140
|
+
$formView.setItemValue(widget, val);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return {
|
|
150
|
+
getWidgetASelectConfig: getWidgetASelectConfig,
|
|
151
|
+
WidgetASelectFormComponent: WidgetASelectFormComponent,
|
|
152
|
+
WidgetASelectViewComponent: WidgetASelectViewComponent
|
|
153
|
+
};
|
|
154
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createWidgetASwitch = createWidgetASwitch;
|
|
7
|
+
var _vue = require("vue");
|
|
8
|
+
function createWidgetASwitch(VxeUI) {
|
|
9
|
+
var getWidgetASwitchConfig = function getWidgetASwitchConfig(params) {
|
|
10
|
+
return {
|
|
11
|
+
title: '是/否',
|
|
12
|
+
icon: 'vxe-icon-switch',
|
|
13
|
+
options: {}
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
var WidgetASwitchFormComponent = (0, _vue.defineComponent)({
|
|
17
|
+
props: {
|
|
18
|
+
renderOpts: {
|
|
19
|
+
type: Object,
|
|
20
|
+
"default": function _default() {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
renderParams: {
|
|
25
|
+
type: Object,
|
|
26
|
+
"default": function _default() {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
emits: [],
|
|
32
|
+
setup: function setup(props) {
|
|
33
|
+
var VxeUIFormComponent = VxeUI.getComponent('VxeForm');
|
|
34
|
+
var VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
35
|
+
var VxeUISwitchComponent = VxeUI.getComponent('VxeSwitch');
|
|
36
|
+
var VxeUIInputComponent = VxeUI.getComponent('VxeInput');
|
|
37
|
+
return function () {
|
|
38
|
+
var renderParams = props.renderParams;
|
|
39
|
+
var widget = renderParams.widget;
|
|
40
|
+
return (0, _vue.h)(VxeUIFormComponent, {
|
|
41
|
+
"class": 'vxe-form-design--widget-render-form-wrapper',
|
|
42
|
+
vertical: true,
|
|
43
|
+
span: 24,
|
|
44
|
+
titleBold: true,
|
|
45
|
+
titleOverflow: true,
|
|
46
|
+
data: widget.options
|
|
47
|
+
}, {
|
|
48
|
+
"default": function _default() {
|
|
49
|
+
return [(0, _vue.h)(VxeUIFormItemComponent, {
|
|
50
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
51
|
+
}, {
|
|
52
|
+
"default": function _default() {
|
|
53
|
+
return (0, _vue.h)(VxeUIInputComponent, {
|
|
54
|
+
modelValue: widget.title,
|
|
55
|
+
'onUpdate:modelValue': function onUpdateModelValue(val) {
|
|
56
|
+
widget.title = val;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}), (0, _vue.h)(VxeUIFormItemComponent, {
|
|
61
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
62
|
+
field: 'placeholder',
|
|
63
|
+
itemRender: {
|
|
64
|
+
name: 'ElInput'
|
|
65
|
+
}
|
|
66
|
+
}), (0, _vue.h)(VxeUIFormItemComponent, {
|
|
67
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
68
|
+
}, {
|
|
69
|
+
"default": function _default() {
|
|
70
|
+
return (0, _vue.h)(VxeUISwitchComponent, {
|
|
71
|
+
modelValue: widget.required,
|
|
72
|
+
'onUpdate:modelValue': function onUpdateModelValue(val) {
|
|
73
|
+
widget.required = val;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
})];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
var WidgetASwitchViewComponent = (0, _vue.defineComponent)({
|
|
84
|
+
props: {
|
|
85
|
+
renderOpts: {
|
|
86
|
+
type: Object,
|
|
87
|
+
"default": function _default() {
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
renderParams: {
|
|
92
|
+
type: Object,
|
|
93
|
+
"default": function _default() {
|
|
94
|
+
return {};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
emits: [],
|
|
99
|
+
setup: function setup(props) {
|
|
100
|
+
var VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
101
|
+
var changeEvent = function changeEvent() {
|
|
102
|
+
var renderParams = props.renderParams;
|
|
103
|
+
var widget = renderParams.widget,
|
|
104
|
+
$formView = renderParams.$formView;
|
|
105
|
+
if ($formView) {
|
|
106
|
+
var itemValue = $formView ? $formView.getItemValue(widget) : null;
|
|
107
|
+
$formView.updateItemStatus(widget, itemValue);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
return function () {
|
|
111
|
+
var renderParams = props.renderParams;
|
|
112
|
+
var widget = renderParams.widget,
|
|
113
|
+
$formView = renderParams.$formView;
|
|
114
|
+
return (0, _vue.h)(VxeUIFormItemComponent, {
|
|
115
|
+
"class": ['vxe-form-design--widget-render-form-item'],
|
|
116
|
+
field: widget.field,
|
|
117
|
+
title: widget.title
|
|
118
|
+
}, {
|
|
119
|
+
"default": function _default() {
|
|
120
|
+
return (0, _vue.h)((0, _vue.resolveComponent)('a-switch'), {
|
|
121
|
+
checked: $formView ? $formView.getItemValue(widget) : null,
|
|
122
|
+
onChange: changeEvent,
|
|
123
|
+
'onUpdate:checked': function onUpdateChecked(val) {
|
|
124
|
+
if ($formView) {
|
|
125
|
+
$formView.setItemValue(widget, val);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
return {
|
|
135
|
+
getWidgetASwitchConfig: getWidgetASwitchConfig,
|
|
136
|
+
WidgetASwitchFormComponent: WidgetASwitchFormComponent,
|
|
137
|
+
WidgetASwitchViewComponent: WidgetASwitchViewComponent
|
|
138
|
+
};
|
|
139
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createWidgetATextarea = createWidgetATextarea;
|
|
7
|
+
var _vue = require("vue");
|
|
8
|
+
function createWidgetATextarea(VxeUI) {
|
|
9
|
+
var getWidgetATextareaConfig = function getWidgetATextareaConfig(params) {
|
|
10
|
+
return {
|
|
11
|
+
title: '文本域',
|
|
12
|
+
icon: 'vxe-icon-textarea',
|
|
13
|
+
options: {
|
|
14
|
+
placeholder: '请输入'
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
var WidgetATextareaFormComponent = (0, _vue.defineComponent)({
|
|
19
|
+
props: {
|
|
20
|
+
renderOpts: {
|
|
21
|
+
type: Object,
|
|
22
|
+
"default": function _default() {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
renderParams: {
|
|
27
|
+
type: Object,
|
|
28
|
+
"default": function _default() {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
emits: [],
|
|
34
|
+
setup: function setup(props) {
|
|
35
|
+
var VxeUIFormComponent = VxeUI.getComponent('VxeForm');
|
|
36
|
+
var VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
37
|
+
var VxeUISwitchComponent = VxeUI.getComponent('VxeSwitch');
|
|
38
|
+
var VxeUIInputComponent = VxeUI.getComponent('VxeInput');
|
|
39
|
+
return function () {
|
|
40
|
+
var renderParams = props.renderParams;
|
|
41
|
+
var widget = renderParams.widget;
|
|
42
|
+
return (0, _vue.h)(VxeUIFormComponent, {
|
|
43
|
+
"class": 'vxe-form-design--widget-render-form-wrapper',
|
|
44
|
+
vertical: true,
|
|
45
|
+
span: 24,
|
|
46
|
+
titleBold: true,
|
|
47
|
+
titleOverflow: true,
|
|
48
|
+
data: widget.options
|
|
49
|
+
}, {
|
|
50
|
+
"default": function _default() {
|
|
51
|
+
return [(0, _vue.h)(VxeUIFormItemComponent, {
|
|
52
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.name')
|
|
53
|
+
}, {
|
|
54
|
+
"default": function _default() {
|
|
55
|
+
return (0, _vue.h)(VxeUIInputComponent, {
|
|
56
|
+
modelValue: widget.title,
|
|
57
|
+
'onUpdate:modelValue': function onUpdateModelValue(val) {
|
|
58
|
+
widget.title = val;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}), (0, _vue.h)(VxeUIFormItemComponent, {
|
|
63
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.placeholder'),
|
|
64
|
+
field: 'placeholder',
|
|
65
|
+
itemRender: {
|
|
66
|
+
name: 'ElInput'
|
|
67
|
+
}
|
|
68
|
+
}), (0, _vue.h)(VxeUIFormItemComponent, {
|
|
69
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.required')
|
|
70
|
+
}, {
|
|
71
|
+
"default": function _default() {
|
|
72
|
+
return (0, _vue.h)(VxeUISwitchComponent, {
|
|
73
|
+
modelValue: widget.required,
|
|
74
|
+
'onUpdate:modelValue': function onUpdateModelValue(val) {
|
|
75
|
+
widget.required = val;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
})];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
var WidgetATextareaViewComponent = (0, _vue.defineComponent)({
|
|
86
|
+
props: {
|
|
87
|
+
renderOpts: {
|
|
88
|
+
type: Object,
|
|
89
|
+
"default": function _default() {
|
|
90
|
+
return {};
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
renderParams: {
|
|
94
|
+
type: Object,
|
|
95
|
+
"default": function _default() {
|
|
96
|
+
return {};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
emits: [],
|
|
101
|
+
setup: function setup(props) {
|
|
102
|
+
var VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
103
|
+
var changeEvent = function changeEvent() {
|
|
104
|
+
var renderParams = props.renderParams;
|
|
105
|
+
var widget = renderParams.widget,
|
|
106
|
+
$formView = renderParams.$formView;
|
|
107
|
+
if ($formView) {
|
|
108
|
+
var itemValue = $formView ? $formView.getItemValue(widget) : null;
|
|
109
|
+
$formView.updateItemStatus(widget, itemValue);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return function () {
|
|
113
|
+
var renderParams = props.renderParams;
|
|
114
|
+
var widget = renderParams.widget,
|
|
115
|
+
$formView = renderParams.$formView;
|
|
116
|
+
var options = widget.options;
|
|
117
|
+
return (0, _vue.h)(VxeUIFormItemComponent, {
|
|
118
|
+
"class": ['vxe-form-design--widget-render-form-item'],
|
|
119
|
+
field: widget.field,
|
|
120
|
+
title: widget.title
|
|
121
|
+
}, {
|
|
122
|
+
"default": function _default() {
|
|
123
|
+
return (0, _vue.h)((0, _vue.resolveComponent)('a-textarea'), {
|
|
124
|
+
value: $formView ? $formView.getItemValue(widget) : null,
|
|
125
|
+
placeholder: options.placeholder,
|
|
126
|
+
autoSize: {
|
|
127
|
+
minRows: 2,
|
|
128
|
+
maxRows: 4
|
|
129
|
+
},
|
|
130
|
+
onChange: changeEvent,
|
|
131
|
+
'onUpdate:value': function onUpdateValue(val) {
|
|
132
|
+
if ($formView) {
|
|
133
|
+
$formView.setItemValue(widget, val);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
getWidgetATextareaConfig: getWidgetATextareaConfig,
|
|
144
|
+
WidgetATextareaFormComponent: WidgetATextareaFormComponent,
|
|
145
|
+
WidgetATextareaViewComponent: WidgetATextareaViewComponent
|
|
146
|
+
};
|
|
147
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useWidgetPropDataSource = useWidgetPropDataSource;
|
|
7
|
+
var _vue = require("vue");
|
|
8
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
9
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
12
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
13
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
|
+
function useWidgetPropDataSource(VxeUI, props, isSubOption) {
|
|
15
|
+
var VxeUIFormItemComponent = VxeUI.getComponent('VxeFormItem');
|
|
16
|
+
var VxeUIButtonComponent = VxeUI.getComponent('VxeButton');
|
|
17
|
+
var VxeUITextareaComponent = VxeUI.getComponent('VxeTextarea');
|
|
18
|
+
var VxeUITipComponent = VxeUI.getComponent('VxeTip');
|
|
19
|
+
var optionsContent = (0, _vue.ref)('');
|
|
20
|
+
var expandIndexList = (0, _vue.ref)([]);
|
|
21
|
+
var addOptionEvent = function addOptionEvent() {
|
|
22
|
+
var renderParams = props.renderParams;
|
|
23
|
+
var widget = renderParams.widget;
|
|
24
|
+
var options = widget.options.options || [];
|
|
25
|
+
options.push({
|
|
26
|
+
value: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.defValue', [options.length + 1])
|
|
27
|
+
});
|
|
28
|
+
widget.options.options = _toConsumableArray(options);
|
|
29
|
+
};
|
|
30
|
+
var subRE = /^(\s|\t)+/;
|
|
31
|
+
var hasSubOption = function hasSubOption(str) {
|
|
32
|
+
return subRE.test(str);
|
|
33
|
+
};
|
|
34
|
+
var expandAllOption = function expandAllOption() {
|
|
35
|
+
var renderParams = props.renderParams;
|
|
36
|
+
var widget = renderParams.widget;
|
|
37
|
+
var options = widget.options.options || [];
|
|
38
|
+
var indexList = [];
|
|
39
|
+
options.forEach(function (group, gIndex) {
|
|
40
|
+
var options = group.options;
|
|
41
|
+
if (options && options.length) {
|
|
42
|
+
indexList.push(gIndex);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
expandIndexList.value = indexList;
|
|
46
|
+
};
|
|
47
|
+
var toggleExpandOption = function toggleExpandOption(item, gIndex) {
|
|
48
|
+
if (expandIndexList.value.includes(gIndex)) {
|
|
49
|
+
expandIndexList.value = expandIndexList.value.filter(function (num) {
|
|
50
|
+
return num !== gIndex;
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
expandIndexList.value.push(gIndex);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var confirmBatchAddOptionEvent = function confirmBatchAddOptionEvent() {
|
|
57
|
+
var renderParams = props.renderParams;
|
|
58
|
+
var widget = renderParams.widget;
|
|
59
|
+
var optList = [];
|
|
60
|
+
var rowList = optionsContent.value.split('\n');
|
|
61
|
+
var prevGroup = null;
|
|
62
|
+
if (isSubOption) {
|
|
63
|
+
rowList.forEach(function (str, index) {
|
|
64
|
+
var nextStr = rowList[index + 1];
|
|
65
|
+
var value = str.trim();
|
|
66
|
+
if (!value) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
var item = {
|
|
70
|
+
value: value
|
|
71
|
+
};
|
|
72
|
+
if (prevGroup) {
|
|
73
|
+
if (hasSubOption(str)) {
|
|
74
|
+
prevGroup.options.push(item);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
prevGroup = null;
|
|
78
|
+
optList.push(item);
|
|
79
|
+
} else {
|
|
80
|
+
optList.push(item);
|
|
81
|
+
}
|
|
82
|
+
if (nextStr) {
|
|
83
|
+
if (hasSubOption(nextStr)) {
|
|
84
|
+
prevGroup = Object.assign(item, {
|
|
85
|
+
options: []
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
rowList.forEach(function (str) {
|
|
92
|
+
optList.push({
|
|
93
|
+
value: str.trim()
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
widget.options.options = optList;
|
|
98
|
+
expandAllOption();
|
|
99
|
+
};
|
|
100
|
+
var openPopupEditEvent = function openPopupEditEvent() {
|
|
101
|
+
var _widget$options$optio;
|
|
102
|
+
var renderParams = props.renderParams;
|
|
103
|
+
var widget = renderParams.widget;
|
|
104
|
+
var contList = [];
|
|
105
|
+
(_widget$options$optio = widget.options.options) === null || _widget$options$optio === void 0 || _widget$options$optio.forEach(function (group) {
|
|
106
|
+
var _group$options;
|
|
107
|
+
contList.push(group.value);
|
|
108
|
+
(_group$options = group.options) === null || _group$options === void 0 || _group$options.forEach(function (item) {
|
|
109
|
+
contList.push("\t".concat(item.value));
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
optionsContent.value = contList.join('\n');
|
|
113
|
+
VxeUI.modal.open({
|
|
114
|
+
title: "".concat(widget.title, " - ").concat(VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.batchEditOption')),
|
|
115
|
+
width: 500,
|
|
116
|
+
height: '50vh ',
|
|
117
|
+
resize: true,
|
|
118
|
+
showFooter: true,
|
|
119
|
+
showCancelButton: true,
|
|
120
|
+
showConfirmButton: true,
|
|
121
|
+
confirmButtonText: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.buildOption'),
|
|
122
|
+
onConfirm: confirmBatchAddOptionEvent,
|
|
123
|
+
slots: {
|
|
124
|
+
"default": function _default() {
|
|
125
|
+
return (0, _vue.h)('div', {
|
|
126
|
+
"class": 'vxe-form-design--widget-form-item-data-source-popup'
|
|
127
|
+
}, [(0, _vue.h)(VxeUITipComponent, {
|
|
128
|
+
status: 'primary',
|
|
129
|
+
title: '',
|
|
130
|
+
content: VxeUI.getI18n("vxe.formDesign.widgetProp.dataSource.".concat(isSubOption ? 'batchEditSubTip' : 'batchEditTip'))
|
|
131
|
+
}), (0, _vue.h)(VxeUITextareaComponent, {
|
|
132
|
+
resize: 'none',
|
|
133
|
+
modelValue: optionsContent.value,
|
|
134
|
+
'onUpdate:modelValue': function onUpdateModelValue(val) {
|
|
135
|
+
optionsContent.value = val;
|
|
136
|
+
}
|
|
137
|
+
})]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
var renderOption = function renderOption(item, hasFirstLevel, isExpand, gIndex, hasSub, isFirst, isLast) {
|
|
143
|
+
return (0, _vue.h)('div', {
|
|
144
|
+
"class": ['vxe-form-design--widget-form-item-data-source-option', {
|
|
145
|
+
'is--first': isFirst,
|
|
146
|
+
'is--last': isLast
|
|
147
|
+
}]
|
|
148
|
+
}, [(0, _vue.h)('div', {
|
|
149
|
+
"class": 'vxe-form-design--widget-expand-btn'
|
|
150
|
+
}, hasFirstLevel && hasSub ? [(0, _vue.h)('i', {
|
|
151
|
+
"class": isExpand ? VxeUI.getIcon().FORM_DESIGN_WIDGET_OPTION_EXPAND_CLOSE : VxeUI.getIcon().FORM_DESIGN_WIDGET_OPTION_EXPAND_OPEN,
|
|
152
|
+
onClick: function onClick() {
|
|
153
|
+
toggleExpandOption(item, gIndex);
|
|
154
|
+
}
|
|
155
|
+
})] : []), (0, _vue.h)('input', {
|
|
156
|
+
"class": 'vxe-default-input',
|
|
157
|
+
value: item.value,
|
|
158
|
+
onInput: function onInput(evnt) {
|
|
159
|
+
item.value = evnt.target.value;
|
|
160
|
+
}
|
|
161
|
+
}), (0, _vue.h)(VxeUIButtonComponent, {
|
|
162
|
+
status: 'danger',
|
|
163
|
+
mode: 'text',
|
|
164
|
+
icon: VxeUI.getIcon().FORM_DESIGN_WIDGET_DELETE
|
|
165
|
+
})]);
|
|
166
|
+
};
|
|
167
|
+
var renderOptions = function renderOptions() {
|
|
168
|
+
var renderParams = props.renderParams;
|
|
169
|
+
var widget = renderParams.widget;
|
|
170
|
+
var options = widget.options;
|
|
171
|
+
var groups = options.options;
|
|
172
|
+
var optVNs = [];
|
|
173
|
+
if (groups) {
|
|
174
|
+
groups.forEach(function (group, gIndex) {
|
|
175
|
+
var options = group.options;
|
|
176
|
+
var isExpand = expandIndexList.value.includes(gIndex);
|
|
177
|
+
if (options && options.length) {
|
|
178
|
+
optVNs.push(renderOption(group, true, isExpand, gIndex, true, gIndex === 0, gIndex === groups.length - 1));
|
|
179
|
+
if (isExpand) {
|
|
180
|
+
optVNs.push((0, _vue.h)('div', {
|
|
181
|
+
"class": 'vxe-form-design--widget-form-item-data-source-sub-option'
|
|
182
|
+
}, options.map(function (item) {
|
|
183
|
+
return renderOption(item, false, isExpand, 0, false, false, false);
|
|
184
|
+
})));
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
optVNs.push(renderOption(group, true, isExpand, gIndex, false, gIndex === 0, gIndex === groups.length - 1));
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return optVNs;
|
|
192
|
+
};
|
|
193
|
+
(0, _vue.watch)(function () {
|
|
194
|
+
return props.renderParams.widget;
|
|
195
|
+
}, function () {
|
|
196
|
+
expandAllOption();
|
|
197
|
+
});
|
|
198
|
+
(0, _vue.onMounted)(function () {
|
|
199
|
+
expandAllOption();
|
|
200
|
+
});
|
|
201
|
+
return {
|
|
202
|
+
renderDataSourceFormItem: function renderDataSourceFormItem() {
|
|
203
|
+
return (0, _vue.h)(VxeUIFormItemComponent, {
|
|
204
|
+
title: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.name'),
|
|
205
|
+
field: 'options'
|
|
206
|
+
}, {
|
|
207
|
+
"default": function _default() {
|
|
208
|
+
return [(0, _vue.h)('div', {}, [(0, _vue.h)(VxeUIButtonComponent, {
|
|
209
|
+
status: 'primary',
|
|
210
|
+
mode: 'text',
|
|
211
|
+
content: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.addOption'),
|
|
212
|
+
onClick: addOptionEvent
|
|
213
|
+
}), (0, _vue.h)(VxeUIButtonComponent, {
|
|
214
|
+
status: 'primary',
|
|
215
|
+
mode: 'text',
|
|
216
|
+
content: VxeUI.getI18n('vxe.formDesign.widgetProp.dataSource.batchEditOption'),
|
|
217
|
+
onClick: openPopupEditEvent
|
|
218
|
+
})]), (0, _vue.h)('div', {
|
|
219
|
+
"class": 'vxe-form-design--widget-form-item-data-source'
|
|
220
|
+
}, renderOptions())];
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|