general-basic-form 1.0.12 → 1.0.16
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 +36 -1
- package/package.json +1 -1
- package/src/GeneralBasicForm.vue +64 -11
package/README.md
CHANGED
|
@@ -16,10 +16,33 @@
|
|
|
16
16
|
|
|
17
17
|

|
|
18
18
|
|
|
19
|
+
在单纯作为表单的时候可以这样使用:
|
|
20
|
+
|
|
21
|
+
<GeneralBasicForm
|
|
22
|
+
formOnly
|
|
23
|
+
:formItem="formItem"
|
|
24
|
+
size="small"
|
|
25
|
+
ref="generalBasicForm"
|
|
26
|
+
:labelWidth="formLabelWidth"
|
|
27
|
+
noUrlParameters
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<style lang="scss" scoped>
|
|
31
|
+
:deep {
|
|
32
|
+
.el-form-item {
|
|
33
|
+
margin-bottom: 22px;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
19
40
|
数据示例:
|
|
20
41
|
|
|
21
42
|
showSearch: true, // 显示搜索条件
|
|
22
|
-
getList();
|
|
43
|
+
getList(); // 请求数据的函数
|
|
44
|
+
formOnly:true // 只展示表单不展示按钮
|
|
45
|
+
noUrlParameters:true // 不接受和不改变url的参数
|
|
23
46
|
formItem: [
|
|
24
47
|
{ label: "款式名称",
|
|
25
48
|
prop: "bsName",
|
|
@@ -34,6 +57,11 @@
|
|
|
34
57
|
message: "请输入正确的Invoice单号"
|
|
35
58
|
}
|
|
36
59
|
],
|
|
60
|
+
template: {
|
|
61
|
+
suffix: () => {
|
|
62
|
+
return <svg-icon icon-class="baifenbi" />;
|
|
63
|
+
},
|
|
64
|
+
},
|
|
37
65
|
maxlength: "3000"},
|
|
38
66
|
{
|
|
39
67
|
label: "二次工艺",
|
|
@@ -120,8 +148,15 @@
|
|
|
120
148
|
},
|
|
121
149
|
],
|
|
122
150
|
//分别支持input输入框,select单选框,date-picker日期选择器,cascader层级选择器 四种组件
|
|
151
|
+
|
|
123
152
|
//date-picker可以传入'start-placeholder'和'end-placeholder',其他组件支持placeholder传入
|
|
153
|
+
|
|
124
154
|
//rules为表单校验规则,每个组件都可以传入
|
|
125
155
|
|
|
156
|
+
//input支持template,支持以下几个属性:
|
|
157
|
+
//prefix 输入框头部内容,只对 type="text"(默认) 有效
|
|
158
|
+
//suffix 输入框尾部内容,只对 type="text" 有效
|
|
159
|
+
//prepend 输入框前置内容,只对 type="text" 有效
|
|
160
|
+
//append 输入框后置内容,只对 type="text" 有效
|
|
126
161
|
安装:npm i general-basic-form<br/>
|
|
127
162
|
install: npm i general-basic-form
|
package/package.json
CHANGED
package/src/GeneralBasicForm.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
* @Author: 陈德立*******419287484@qq.com
|
|
3
3
|
* @Date: 2021-08-20 17:14:53
|
|
4
|
-
* @LastEditTime: 2021-
|
|
4
|
+
* @LastEditTime: 2021-10-19 19:23:15
|
|
5
5
|
* @LastEditors: 陈德立*******419287484@qq.com
|
|
6
6
|
* @Github: https://github.com/Alan1034
|
|
7
7
|
* @Description:
|
|
@@ -35,7 +35,19 @@
|
|
|
35
35
|
v-bind="inputSetting"
|
|
36
36
|
:placeholder="item.placeholder || inputSetting.placeholder"
|
|
37
37
|
:maxlength="item.maxlength"
|
|
38
|
-
|
|
38
|
+
>
|
|
39
|
+
<template
|
|
40
|
+
v-for="(templateEle, name) in item.template"
|
|
41
|
+
:key="name"
|
|
42
|
+
#[name]
|
|
43
|
+
>
|
|
44
|
+
<component
|
|
45
|
+
v-if="templateEle"
|
|
46
|
+
:is="currentInputComponent()"
|
|
47
|
+
:templateEle="templateEle"
|
|
48
|
+
/>
|
|
49
|
+
</template>
|
|
50
|
+
</el-input>
|
|
39
51
|
<el-select
|
|
40
52
|
filterable
|
|
41
53
|
v-else-if="item.type === 'select'"
|
|
@@ -74,7 +86,7 @@
|
|
|
74
86
|
:value-format="item['value-format']"
|
|
75
87
|
></el-date-picker>
|
|
76
88
|
</el-form-item>
|
|
77
|
-
<el-form-item>
|
|
89
|
+
<el-form-item v-if="!formOnly">
|
|
78
90
|
<el-button
|
|
79
91
|
type="primary"
|
|
80
92
|
icon="el-icon-search"
|
|
@@ -93,16 +105,30 @@
|
|
|
93
105
|
<script>
|
|
94
106
|
export default {
|
|
95
107
|
name: "GeneralBasicForm",
|
|
108
|
+
components: {
|
|
109
|
+
InputArchive: (props) => {
|
|
110
|
+
const { templateEle } = props;
|
|
111
|
+
return templateEle();
|
|
112
|
+
},
|
|
113
|
+
},
|
|
96
114
|
props: {
|
|
97
115
|
showSearch: {
|
|
116
|
+
// 是否展示所有元素
|
|
98
117
|
type: Boolean,
|
|
99
118
|
default: true,
|
|
100
119
|
},
|
|
120
|
+
formOnly: {
|
|
121
|
+
// 是否只展示表单不展示按钮
|
|
122
|
+
type: Boolean,
|
|
123
|
+
default: false,
|
|
124
|
+
},
|
|
101
125
|
getList: {
|
|
126
|
+
// 查找数据调用的函数
|
|
102
127
|
type: Function,
|
|
103
128
|
default: () => {},
|
|
104
129
|
},
|
|
105
130
|
formItem: {
|
|
131
|
+
// 定义表单的数据
|
|
106
132
|
type: Array,
|
|
107
133
|
default: [],
|
|
108
134
|
},
|
|
@@ -116,10 +142,22 @@ export default {
|
|
|
116
142
|
type: String,
|
|
117
143
|
default: "90px",
|
|
118
144
|
},
|
|
145
|
+
noUrlParameters: {
|
|
146
|
+
// 不接受和不改变url的参数
|
|
147
|
+
type: Boolean,
|
|
148
|
+
default: () => false,
|
|
149
|
+
},
|
|
150
|
+
formData: {
|
|
151
|
+
// 外部传入的表单数据,用于回填
|
|
152
|
+
type: Object,
|
|
153
|
+
default: {},
|
|
154
|
+
},
|
|
119
155
|
},
|
|
120
156
|
data() {
|
|
121
157
|
return {
|
|
122
|
-
queryParams: {
|
|
158
|
+
queryParams: {
|
|
159
|
+
...(this.noUrlParameters ? {} : this.$route?.query),
|
|
160
|
+
}, // form表单数据
|
|
123
161
|
selectSetting: {
|
|
124
162
|
placeholder: "请选择",
|
|
125
163
|
clearable: true,
|
|
@@ -152,6 +190,14 @@ export default {
|
|
|
152
190
|
// queryParams,
|
|
153
191
|
// };
|
|
154
192
|
// },
|
|
193
|
+
watch: {
|
|
194
|
+
formData(val) {
|
|
195
|
+
this.queryParams = {
|
|
196
|
+
...(this.noUrlParameters ? {} : this.queryParams),
|
|
197
|
+
...val,
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
},
|
|
155
201
|
methods: {
|
|
156
202
|
/** 搜索按钮操作 */
|
|
157
203
|
handleQuery() {
|
|
@@ -161,22 +207,29 @@ export default {
|
|
|
161
207
|
...this.queryParams,
|
|
162
208
|
...params,
|
|
163
209
|
};
|
|
164
|
-
this
|
|
165
|
-
|
|
166
|
-
|
|
210
|
+
if (!this.noUrlParameters) {
|
|
211
|
+
this.$router.push({
|
|
212
|
+
query: { ...searchParams },
|
|
213
|
+
});
|
|
214
|
+
}
|
|
167
215
|
this.getList({
|
|
168
216
|
...searchParams,
|
|
169
217
|
});
|
|
170
218
|
},
|
|
171
219
|
/** 重置按钮操作 */
|
|
172
|
-
resetQuery() {
|
|
220
|
+
async resetQuery() {
|
|
173
221
|
this.$refs.queryFormRef.resetFields();
|
|
174
222
|
const params = { page: 1 };
|
|
175
|
-
this
|
|
176
|
-
|
|
177
|
-
|
|
223
|
+
if (!this.noUrlParameters) {
|
|
224
|
+
await this.$router.push({
|
|
225
|
+
query: { ...params },
|
|
226
|
+
});
|
|
227
|
+
}
|
|
178
228
|
this.handleQuery();
|
|
179
229
|
},
|
|
230
|
+
currentInputComponent() {
|
|
231
|
+
return "input-archive";
|
|
232
|
+
},
|
|
180
233
|
},
|
|
181
234
|
};
|
|
182
235
|
</script>
|