el-form-renderer-vue3 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/el-form-renderer-vue3.es.js +4036 -0
- package/el-form-renderer-vue3.umd.js +5 -0
- package/package.json +12 -34
- package/.vite/deps_temp_ce3ed5bf/package.json +0 -3
- package/.vscode/extensions.json +0 -3
- package/LICENSE +0 -661
- package/README.en.md +0 -36
- package/README.md +0 -252
- package/index.html +0 -13
- package/src/App.vue +0 -59
- package/src/ChildCom.vue +0 -24
- package/src/assets/vue.svg +0 -1
- package/src/components/femessage/components/render-form-group.vue +0 -48
- package/src/components/femessage/components/render-form-item.vue +0 -328
- package/src/components/femessage/el-form-renderer.vue +0 -284
- package/src/components/femessage/util/CustomComponent.js +0 -28
- package/src/components/femessage/util/VNode.js +0 -9
- package/src/components/femessage/util/enable-when.js +0 -26
- package/src/components/femessage/util/transform-content.js +0 -48
- package/src/components/femessage/util/utils.js +0 -127
- package/src/el-form-renderer.md +0 -220
- package/src/main.js +0 -15
- package/src/router/index.js +0 -160
- package/src/style.css +0 -89
- package/src/view/AboutView.vue +0 -40
- package/src/view/HomeView.vue +0 -134
- package/src/view/MyInput.vue +0 -46
- package/src/view/checkboxGroup.vue +0 -29
- package/src/view/content.vue +0 -176
- package/src/view/deprecated.vue +0 -37
- package/src/view/disabled.vue +0 -104
- package/src/view/el.vue +0 -24
- package/src/view/format.vue +0 -63
- package/src/view/getcomponent.vue +0 -51
- package/src/view/getform.vue +0 -50
- package/src/view/hidden.vue +0 -51
- package/src/view/label.vue +0 -25
- package/src/view/next.vue +0 -55
- package/src/view/picker.vue +0 -27
- package/src/view/radioGroup.vue +0 -38
- package/src/view/readonly.vue +0 -144
- package/src/view/remote.vue +0 -115
- package/src/view/rules.vue +0 -46
- package/src/view/rulesPlus.vue +0 -34
- package/src/view/setoptios.vue +0 -50
- package/src/view/slot.vue +0 -37
- package/src/view/testAttrs.vue +0 -17
- package/src/view/update.vue +0 -64
- package/src/view/vmodel.vue +0 -137
- package/src/your-component.vue +0 -55
- package/vite.config.js +0 -7
- /package/{public/vite.svg → vite.svg} +0 -0
package/src/view/HomeView.vue
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-form-renderer label-width="100px" :content="content" ref="ruleForm">
|
|
3
|
-
<el-form-item>
|
|
4
|
-
<el-button type="primary" @click="submitForm">submit</el-button>
|
|
5
|
-
<el-button @click="resetForm">reset</el-button>
|
|
6
|
-
</el-form-item>
|
|
7
|
-
</el-form-renderer>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
|
-
<script setup>
|
|
11
|
-
import { reactive, ref } from "vue";
|
|
12
|
-
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
13
|
-
const content = reactive([
|
|
14
|
-
{
|
|
15
|
-
type: "input",
|
|
16
|
-
id: "name",
|
|
17
|
-
label: "name",
|
|
18
|
-
attrs: { "data-name": "form1" },
|
|
19
|
-
el: {
|
|
20
|
-
size: "default",
|
|
21
|
-
placeholder: "test placeholder",
|
|
22
|
-
},
|
|
23
|
-
rules: [
|
|
24
|
-
{ required: true, message: "miss name", trigger: "blur" },
|
|
25
|
-
{ min: 3, max: 5, message: "length between 3 to 5", trigger: "blur" },
|
|
26
|
-
],
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
type: "select",
|
|
30
|
-
id: "region",
|
|
31
|
-
label: "area",
|
|
32
|
-
el: {
|
|
33
|
-
valueKey: "id",
|
|
34
|
-
},
|
|
35
|
-
options: [
|
|
36
|
-
{
|
|
37
|
-
label: "area1",
|
|
38
|
-
value: {
|
|
39
|
-
id: "shanghai",
|
|
40
|
-
name: "shanghai",
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
label: "area2",
|
|
45
|
-
value: {
|
|
46
|
-
id: "beijing",
|
|
47
|
-
name: "beijing",
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
rules: [{ required: true, message: "miss area", trigger: "change" }],
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: "date-picker",
|
|
55
|
-
id: "date",
|
|
56
|
-
label: "date",
|
|
57
|
-
el: {
|
|
58
|
-
type: "datetime",
|
|
59
|
-
placeholder: "select date",
|
|
60
|
-
teleported: false,
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
rules: [{ type: "date", required: true, message: "miss date", trigger: "change" }],
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
type: "switch",
|
|
67
|
-
id: "delivery",
|
|
68
|
-
label: "delivery",
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
type: "checkbox-group",
|
|
72
|
-
id: "type",
|
|
73
|
-
label: "type",
|
|
74
|
-
default: [],
|
|
75
|
-
options: [
|
|
76
|
-
{
|
|
77
|
-
label: "typeA",
|
|
78
|
-
value: "A",
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
label: "typeB",
|
|
82
|
-
value: "B",
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
label: "typeC",
|
|
86
|
-
value: "C",
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
rules: [{ type: "array", required: true, message: "miss type", trigger: "change" }],
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
type: "radio-group",
|
|
93
|
-
id: "resource",
|
|
94
|
-
label: "resource",
|
|
95
|
-
options: [
|
|
96
|
-
{
|
|
97
|
-
label: "resourceA",
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
label: "resourceB",
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
rules: [{ required: true, message: "miss resource", trigger: "change" }],
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
type: "input",
|
|
107
|
-
id: "desc",
|
|
108
|
-
label: "desc",
|
|
109
|
-
el: {
|
|
110
|
-
type: "textarea",
|
|
111
|
-
},
|
|
112
|
-
rules: [{ required: true, message: "miss desc", trigger: "blur" }],
|
|
113
|
-
},
|
|
114
|
-
]);
|
|
115
|
-
const ruleForm = ref();
|
|
116
|
-
|
|
117
|
-
const submitForm = () => {
|
|
118
|
-
try {
|
|
119
|
-
ruleForm.value.methods.validate((valid) => {
|
|
120
|
-
if (valid) {
|
|
121
|
-
console.log("OK");
|
|
122
|
-
} else {
|
|
123
|
-
console.log("error submit!!");
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
} catch (error) {
|
|
128
|
-
console.log(error);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
const resetForm = () => {
|
|
132
|
-
ruleForm.value.methods.resetFields();
|
|
133
|
-
};
|
|
134
|
-
</script>
|
package/src/view/MyInput.vue
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-form-renderer :content="content" />
|
|
3
|
-
</template>
|
|
4
|
-
<script setup>
|
|
5
|
-
import { reactive, markRaw } from "vue";
|
|
6
|
-
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
7
|
-
|
|
8
|
-
import MyInput from "../your-component.vue";
|
|
9
|
-
const content = reactive([
|
|
10
|
-
{
|
|
11
|
-
component: markRaw(MyInput),
|
|
12
|
-
id: "myInput",
|
|
13
|
-
label: "label",
|
|
14
|
-
// 传入组件属性
|
|
15
|
-
el: {
|
|
16
|
-
placeholder: "请输入一个 title",
|
|
17
|
-
type: "input", // submit button
|
|
18
|
-
title: "这是一个标题", // custom defined props
|
|
19
|
-
},
|
|
20
|
-
// 可以通过 overrideRules: true 来覆盖自定义组件内置的校验规则
|
|
21
|
-
overrideRules: true,
|
|
22
|
-
rules: [
|
|
23
|
-
{
|
|
24
|
-
required: true,
|
|
25
|
-
trigger: "blur",
|
|
26
|
-
message: "不能为空!",
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
// 传入组件事件
|
|
30
|
-
on: {
|
|
31
|
-
focus: ([event], updateForm) => {
|
|
32
|
-
console.log(event.target.value); // output: input value
|
|
33
|
-
},
|
|
34
|
-
customEvent: ([value, msg], updateForm) => {
|
|
35
|
-
console.log(value, msg); // output: 'message'
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
]);
|
|
40
|
-
</script>
|
|
41
|
-
<style scoped>
|
|
42
|
-
.box {
|
|
43
|
-
margin: 20px 0;
|
|
44
|
-
font-size: 20px;
|
|
45
|
-
}
|
|
46
|
-
</style>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="box">checkboxGroup</div>
|
|
3
|
-
|
|
4
|
-
<el-form-renderer label-width="100px" :content="content" ref="ruleForm">
|
|
5
|
-
</el-form-renderer>
|
|
6
|
-
</template>
|
|
7
|
-
<script setup>
|
|
8
|
-
import { reactive } from "vue";
|
|
9
|
-
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
10
|
-
const content = reactive([
|
|
11
|
-
{
|
|
12
|
-
id: "city",
|
|
13
|
-
type: "checkbox-group",
|
|
14
|
-
/**
|
|
15
|
-
* sytle 属性是为了满足 el-checkbox-button属性而设置,如果不需要使用el-radio-button这可不设置
|
|
16
|
-
*/
|
|
17
|
-
style: "button",
|
|
18
|
-
label: "city",
|
|
19
|
-
default: ["new york"],
|
|
20
|
-
options: [{ label: "new york" }, { label: "guangzhou" }, { label: "tokyo" }],
|
|
21
|
-
},
|
|
22
|
-
]);
|
|
23
|
-
</script>
|
|
24
|
-
<style scoped>
|
|
25
|
-
.box {
|
|
26
|
-
margin: 20px 0;
|
|
27
|
-
font-size: 20px;
|
|
28
|
-
}
|
|
29
|
-
</style>
|
package/src/view/content.vue
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-form-renderer
|
|
3
|
-
label-width="100px"
|
|
4
|
-
:content="content"
|
|
5
|
-
v-model:FormData="FormData"
|
|
6
|
-
ref="form"
|
|
7
|
-
>
|
|
8
|
-
<template #id:region>
|
|
9
|
-
<div>requestRemoteCount: {{ requestRemoteCount }}</div>
|
|
10
|
-
</template>
|
|
11
|
-
<el-form-item>
|
|
12
|
-
<el-button @click="resetForm">resetForm</el-button>
|
|
13
|
-
<el-button @click="disableName"
|
|
14
|
-
>{{ content[0].disabled ? "启" : "禁" }}用第一项</el-button
|
|
15
|
-
>
|
|
16
|
-
<el-button @click="setOptions">更新 region 的 options</el-button>
|
|
17
|
-
<el-button @click="addFormItem">随机插入表单项</el-button>
|
|
18
|
-
<el-button @click="removeFormItem">随机移除表单项</el-button>
|
|
19
|
-
</el-form-item>
|
|
20
|
-
<pre>{{ FormData }}</pre>
|
|
21
|
-
</el-form-renderer>
|
|
22
|
-
</template>
|
|
23
|
-
|
|
24
|
-
<script setup>
|
|
25
|
-
import { reactive, ref } from "vue";
|
|
26
|
-
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
27
|
-
let requestRemoteCount = ref(0);
|
|
28
|
-
const form = ref();
|
|
29
|
-
let id = ref(0);
|
|
30
|
-
let FormData = reactive({
|
|
31
|
-
name: "1111",
|
|
32
|
-
region: [],
|
|
33
|
-
type: [],
|
|
34
|
-
startDate: "2019-01-01",
|
|
35
|
-
endDate: "2019-01-02",
|
|
36
|
-
});
|
|
37
|
-
const content = reactive([
|
|
38
|
-
{
|
|
39
|
-
type: "input",
|
|
40
|
-
id: "name",
|
|
41
|
-
label: "name",
|
|
42
|
-
attrs: { "data-name": "form1" },
|
|
43
|
-
el: {
|
|
44
|
-
size: "default",
|
|
45
|
-
placeholder: "test placeholder",
|
|
46
|
-
},
|
|
47
|
-
rules: [
|
|
48
|
-
{ required: true, message: "miss name", trigger: "blur" },
|
|
49
|
-
{ min: 3, max: 5, message: "length between 3 to 5", trigger: "blur" },
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
type: "select",
|
|
54
|
-
id: "region",
|
|
55
|
-
label: "region",
|
|
56
|
-
remote: {
|
|
57
|
-
// url: 'https://mockapi.eolinker.com/IeZWjzy87c204a1f7030b2a17b00f3776ce0a07a5030a1b/el-form-renderer?q=remote',
|
|
58
|
-
request: () => {
|
|
59
|
-
const data = [
|
|
60
|
-
{
|
|
61
|
-
label: "shanghai",
|
|
62
|
-
value: "shanghai",
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
label: "beijing",
|
|
66
|
-
value: "beijing",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
label: "guangzhou",
|
|
70
|
-
value: "guangzhou",
|
|
71
|
-
},
|
|
72
|
-
];
|
|
73
|
-
requestRemoteCount.value++;
|
|
74
|
-
return new Promise((r) => setTimeout(() => r(data), 2000));
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
el: { filterable: true, multiple: true, multipleLimit: 2 },
|
|
78
|
-
rules: [{ required: true, message: "miss area", trigger: "change" }],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
type: "date-picker",
|
|
82
|
-
id: "date",
|
|
83
|
-
label: "date",
|
|
84
|
-
el: {
|
|
85
|
-
type: "daterange",
|
|
86
|
-
valueFormat: "yyyy-MM-dd",
|
|
87
|
-
},
|
|
88
|
-
rules: [{ required: true, message: "miss date", trigger: "change" }],
|
|
89
|
-
inputFormat: (row) => {
|
|
90
|
-
if (row.startDate && row.endDate) {
|
|
91
|
-
return [row.startDate, row.endDate];
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
outputFormat: (val) => {
|
|
95
|
-
if (!val) {
|
|
96
|
-
return { startDate: "", endDate: "" };
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
startDate: val[0],
|
|
100
|
-
endDate: val[1],
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
type: "switch",
|
|
106
|
-
id: "delivery",
|
|
107
|
-
label: "delivery",
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
type: "checkbox-group",
|
|
111
|
-
id: "type",
|
|
112
|
-
label: "type",
|
|
113
|
-
default: [],
|
|
114
|
-
options: [
|
|
115
|
-
{
|
|
116
|
-
label: "typeA",
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
label: "typeB",
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
label: "typeC",
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
rules: [{ type: "array", required: true, message: "miss type", trigger: "change" }],
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
type: "radio-group",
|
|
129
|
-
id: "resource",
|
|
130
|
-
label: "resource",
|
|
131
|
-
options: [
|
|
132
|
-
{
|
|
133
|
-
label: "resourceA",
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
label: "resourceB",
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
rules: [{ required: true, message: "miss resource", trigger: "change" }],
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
type: "input",
|
|
143
|
-
id: "desc",
|
|
144
|
-
label: "desc",
|
|
145
|
-
el: {
|
|
146
|
-
type: "textarea",
|
|
147
|
-
},
|
|
148
|
-
rules: [{ required: true, message: "miss desc", trigger: "blur" }],
|
|
149
|
-
},
|
|
150
|
-
]);
|
|
151
|
-
const resetForm = () => {
|
|
152
|
-
form.value.methods.resetFields();
|
|
153
|
-
};
|
|
154
|
-
const disableName = () => {
|
|
155
|
-
content[0].disabled = !content[0].disabled;
|
|
156
|
-
};
|
|
157
|
-
const setOptions = () => {
|
|
158
|
-
const region = content.find((item) => item.id === "region");
|
|
159
|
-
if (!region) return;
|
|
160
|
-
region.options = [{ label: "广州", value: "广州" }];
|
|
161
|
-
};
|
|
162
|
-
const addFormItem = () => {
|
|
163
|
-
const i = Math.floor(Math.random() * (content.length + 1));
|
|
164
|
-
id.value++;
|
|
165
|
-
content.splice(i, 0, {
|
|
166
|
-
id: `name${id.value}`,
|
|
167
|
-
label: `表单项${id.value}`,
|
|
168
|
-
type: "input",
|
|
169
|
-
});
|
|
170
|
-
};
|
|
171
|
-
const removeFormItem = () => {
|
|
172
|
-
if (content.length <= 1) return;
|
|
173
|
-
const i = Math.floor(Math.random() * content.length);
|
|
174
|
-
content.splice(i, 1);
|
|
175
|
-
};
|
|
176
|
-
</script>
|
package/src/view/deprecated.vue
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="box">deprecated</div>
|
|
3
|
-
<div>这里是些过时的写法,但仍要保留兼容性</div>
|
|
4
|
-
<el-form-renderer ref="form" label-width="100px" :content="content">
|
|
5
|
-
<el-button @click="getFormValue">getFormValue</el-button>
|
|
6
|
-
</el-form-renderer>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup>
|
|
10
|
-
import { reactive, ref } from "vue";
|
|
11
|
-
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
12
|
-
|
|
13
|
-
const form = ref();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const content = reactive(
|
|
17
|
-
[
|
|
18
|
-
{
|
|
19
|
-
type: 'radioGroup', // 推荐写作 radio-group
|
|
20
|
-
$id: 'resource', // 推荐不加 $
|
|
21
|
-
label: 'resource',
|
|
22
|
-
options: [{
|
|
23
|
-
label: 'resourceA'
|
|
24
|
-
}, {
|
|
25
|
-
label: 'resourceB'
|
|
26
|
-
}],
|
|
27
|
-
rules: [
|
|
28
|
-
{ required: true, message: 'miss resource', trigger: 'change' }
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
]);
|
|
32
|
-
const getFormValue = () => {
|
|
33
|
-
let v = form.value.getFormValue();
|
|
34
|
-
console.log(v);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
</script>
|
package/src/view/disabled.vue
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="box">disabled</div>
|
|
3
|
-
<ul>
|
|
4
|
-
<li>作为 el-form-renderer 的 prop 传入,禁用整个表单项,优先级最高 </li>
|
|
5
|
-
<li> 作为 el 的属性传入,作用于单个表单项组件</li>
|
|
6
|
-
<li> 与 el 平级传入,效果和 2 相同(因历史原因存在)</li>
|
|
7
|
-
</ul>
|
|
8
|
-
<el-form-renderer label-width="140px" ref="form" :content="content" :disabled="disabledAll">
|
|
9
|
-
<el-checkbox v-model="disabledAll">禁用全部</el-checkbox>
|
|
10
|
-
<el-checkbox v-model="disabledArea">禁用 area</el-checkbox>
|
|
11
|
-
</el-form-renderer>
|
|
12
|
-
<div style="margin-top: 16px;">
|
|
13
|
-
<el-button type="primary" @click="submit">提交,在控制台查看表单数据</el-button>
|
|
14
|
-
</div>
|
|
15
|
-
</template>
|
|
16
|
-
<script setup>
|
|
17
|
-
import { reactive, ref, watch } from "vue";
|
|
18
|
-
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
19
|
-
let disabledAll = ref(false)
|
|
20
|
-
let disabledArea = ref(false)
|
|
21
|
-
let form = ref()
|
|
22
|
-
const content = reactive([
|
|
23
|
-
{
|
|
24
|
-
type: 'input',
|
|
25
|
-
id: 'name',
|
|
26
|
-
label: 'name',
|
|
27
|
-
attrs: { 'data-name': 'form1' },
|
|
28
|
-
el: {
|
|
29
|
-
size: 'default',
|
|
30
|
-
placeholder: 'test placeholder'
|
|
31
|
-
},
|
|
32
|
-
rules: [
|
|
33
|
-
{ required: true, message: 'miss name', trigger: 'blur' },
|
|
34
|
-
{ min: 3, max: 5, message: 'length between 3 to 5', trigger: 'blur' }
|
|
35
|
-
]
|
|
36
|
-
}, {
|
|
37
|
-
type: 'select',
|
|
38
|
-
id: 'region',
|
|
39
|
-
label: 'area',
|
|
40
|
-
disabled: false,
|
|
41
|
-
options: [{
|
|
42
|
-
label: 'area1',
|
|
43
|
-
value: 'shanghai'
|
|
44
|
-
}, {
|
|
45
|
-
label: 'area2',
|
|
46
|
-
value: 'beijing'
|
|
47
|
-
}],
|
|
48
|
-
rules: [
|
|
49
|
-
{ required: true, message: 'miss area', trigger: 'change' }
|
|
50
|
-
]
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
type: 'switch',
|
|
54
|
-
id: 'delivery',
|
|
55
|
-
label: '禁用开关',
|
|
56
|
-
default: true,
|
|
57
|
-
}, {
|
|
58
|
-
type: 'checkbox-group',
|
|
59
|
-
id: 'type',
|
|
60
|
-
label: '根据开关值禁用',
|
|
61
|
-
disabled: form => form.delivery,
|
|
62
|
-
options: [{
|
|
63
|
-
label: 'typeA'
|
|
64
|
-
}, {
|
|
65
|
-
label: 'typeB'
|
|
66
|
-
}, {
|
|
67
|
-
label: 'typeC'
|
|
68
|
-
}],
|
|
69
|
-
rules: [
|
|
70
|
-
{ type: 'array', required: true, message: 'miss type', trigger: 'change' }
|
|
71
|
-
]
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
type: 'input',
|
|
75
|
-
id: 'desc',
|
|
76
|
-
label: 'desc',
|
|
77
|
-
default: '使用el禁用',
|
|
78
|
-
el: {
|
|
79
|
-
disabled: true,
|
|
80
|
-
type: 'textarea',
|
|
81
|
-
},
|
|
82
|
-
rules: [
|
|
83
|
-
{ required: true, message: 'miss desc', trigger: 'blur' }
|
|
84
|
-
]
|
|
85
|
-
}
|
|
86
|
-
]);
|
|
87
|
-
watch(
|
|
88
|
-
disabledArea,
|
|
89
|
-
(val) => {
|
|
90
|
-
content[1].disabled = val
|
|
91
|
-
},
|
|
92
|
-
);
|
|
93
|
-
const submit = () => {
|
|
94
|
-
form.value.methods.validate(valid => {
|
|
95
|
-
if (valid) console.log(form.value.getFormValue())
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
</script>
|
|
99
|
-
<style scoped>
|
|
100
|
-
.box {
|
|
101
|
-
margin: 20px 0;
|
|
102
|
-
font-size: 20px;
|
|
103
|
-
}
|
|
104
|
-
</style>
|
package/src/view/el.vue
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="box">el</div>
|
|
3
|
-
<div>可以对表单组件传入 props,使用 el 传入 例如配合 el-input,设置文本框</div>
|
|
4
|
-
<el-form-renderer :content="content" inline />
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup>
|
|
8
|
-
import { reactive, } from "vue";
|
|
9
|
-
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const content = reactive(
|
|
14
|
-
[
|
|
15
|
-
{
|
|
16
|
-
id: 'document',
|
|
17
|
-
type: 'input',
|
|
18
|
-
el: {
|
|
19
|
-
type: 'textarea'
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
]);
|
|
23
|
-
|
|
24
|
-
</script>
|
package/src/view/format.vue
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="box">value-format</div>
|
|
3
|
-
<div class="format">
|
|
4
|
-
<el-form-renderer :content="content" inline ref="formRender">
|
|
5
|
-
<el-form-item>
|
|
6
|
-
<el-button @click="setValue">set value</el-button>
|
|
7
|
-
<el-button type="primary" @click="getValue">log value</el-button>
|
|
8
|
-
</el-form-item>
|
|
9
|
-
</el-form-renderer>
|
|
10
|
-
<div>{{ form }}</div>
|
|
11
|
-
</div>
|
|
12
|
-
</template>
|
|
13
|
-
<script setup>
|
|
14
|
-
|
|
15
|
-
import { reactive, ref } from "vue";
|
|
16
|
-
const formRender = ref()
|
|
17
|
-
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
18
|
-
let form = ref()
|
|
19
|
-
const content = reactive([
|
|
20
|
-
{
|
|
21
|
-
el: {
|
|
22
|
-
type: 'daterange',
|
|
23
|
-
valueFormat: 'yyyy-MM-dd'
|
|
24
|
-
},
|
|
25
|
-
type: 'date-picker',
|
|
26
|
-
id: 'date',
|
|
27
|
-
label: 'date',
|
|
28
|
-
inputFormat: (row) => {
|
|
29
|
-
if (row.startDate && row.endDate) {
|
|
30
|
-
return [row.startDate, row.endDate]
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
outputFormat: (val) => {
|
|
34
|
-
if (!val) {
|
|
35
|
-
return { startDate: '', endDate: '' }
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
startDate: val[0],
|
|
39
|
-
endDate: val[1]
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
]);
|
|
44
|
-
const getValue = () => {
|
|
45
|
-
const value = formRender.value.getFormValue()
|
|
46
|
-
|
|
47
|
-
form.value = JSON.stringify(value)
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
const setValue = () => {
|
|
51
|
-
formRender.value.updateForm({
|
|
52
|
-
startDate: '2019-01-01',
|
|
53
|
-
endDate: '2019-01-02'
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
</script>
|
|
58
|
-
<style scoped>
|
|
59
|
-
.box {
|
|
60
|
-
margin: 20px 0;
|
|
61
|
-
font-size: 20px;
|
|
62
|
-
}
|
|
63
|
-
</style>
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<el-form-renderer inline :content="content" ref="form">
|
|
4
|
-
</el-form-renderer>
|
|
5
|
-
<el-button @click="getComponent('id')">获取id input</el-button>
|
|
6
|
-
<el-button @click="getComponent('first')">获取first name input</el-button>
|
|
7
|
-
</div>
|
|
8
|
-
</template>
|
|
9
|
-
<script setup>
|
|
10
|
-
import { reactive, ref, } from "vue";
|
|
11
|
-
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
12
|
-
|
|
13
|
-
const form = ref()
|
|
14
|
-
const content = reactive([
|
|
15
|
-
{
|
|
16
|
-
id: 'id',
|
|
17
|
-
type: 'input',
|
|
18
|
-
label: 'id',
|
|
19
|
-
el: {
|
|
20
|
-
placeholder: 'id'
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
type: 'group',
|
|
25
|
-
label: 'name',
|
|
26
|
-
id: 'name',
|
|
27
|
-
items: [
|
|
28
|
-
{
|
|
29
|
-
id: 'first',
|
|
30
|
-
label: 'first name',
|
|
31
|
-
type: 'input'
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
id: 'last',
|
|
35
|
-
label: 'last name',
|
|
36
|
-
type: 'input'
|
|
37
|
-
}
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
]);
|
|
41
|
-
const getComponent = (id) => {
|
|
42
|
-
console.log(form.value.getComponentById(id));
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
</script>
|
|
46
|
-
<style scoped>
|
|
47
|
-
.box {
|
|
48
|
-
margin: 20px 0;
|
|
49
|
-
font-size: 20px;
|
|
50
|
-
}
|
|
51
|
-
</style>
|