general-basic-form 1.0.26 → 1.0.28
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 +356 -203
- package/dist/index.d.ts +17 -0
- package/dist/index.js +394 -0
- package/dist/index.umd.cjs +1 -0
- package/package.json +41 -11
- package/README.assets/image-20210820173738506.png +0 -0
- package/config/webpack.common.js +0 -98
- package/config/webpack.dev.js +0 -15
- package/config/webpack.prod.js +0 -16
- package/src/GeneralBasicForm.vue +0 -258
- package/src/assets/image-20210820173037871.png +0 -0
- package/src/assets/logo.png +0 -0
- package/src/index.js +0 -12
package/README.md
CHANGED
|
@@ -1,203 +1,356 @@
|
|
|
1
|
-
# GeneralBasicForm
|
|
2
|
-
|
|
3
|
-
一个兼容 Vue2 和 Vue3
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
1
|
+
# GeneralBasicForm
|
|
2
|
+
|
|
3
|
+
一个兼容 Vue2 和 Vue3 的表单组件,支持typescript,vue2请使用@1版本,Vue3请使用@2版本 <br/>
|
|
4
|
+
|
|
5
|
+
示例:
|
|
6
|
+
|
|
7
|
+
因为兼容性问题,目前只能使用完整引入
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
import ElementPlus from 'element-plus'
|
|
11
|
+
import 'element-plus/dist/index.css'
|
|
12
|
+
app.use(ElementPlus)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
import { VGeneralBasicForm } from "general-basic-form";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
<VGeneralBasicForm
|
|
20
|
+
:showSearch="showSearch"
|
|
21
|
+
:getList="getList"
|
|
22
|
+
:formItem="formItem"
|
|
23
|
+
:size="size"
|
|
24
|
+
ref="VGeneralBasicFormRef"
|
|
25
|
+
labelWidth="90px"
|
|
26
|
+
>
|
|
27
|
+
...一些传入插槽的内容
|
|
28
|
+
</VGeneralBasicForm>
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
在单纯作为表单的时候可以这样使用:
|
|
33
|
+
|
|
34
|
+
<VGeneralBasicForm
|
|
35
|
+
formOnly
|
|
36
|
+
:formItem="formItem"
|
|
37
|
+
size="small"
|
|
38
|
+
ref="VGeneralBasicFormRef"
|
|
39
|
+
:labelWidth="formLabelWidth"
|
|
40
|
+
:formData: {
|
|
41
|
+
// 外部传入的表单数据,用于回填
|
|
42
|
+
}
|
|
43
|
+
noUrlParameters
|
|
44
|
+
:afterReset="afterReset"
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
<style lang="scss" scoped>
|
|
48
|
+
:deep {
|
|
49
|
+
.el-form-item {
|
|
50
|
+
margin-bottom: 22px;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
</style>
|
|
54
|
+
|
|
55
|
+
getList会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数1
|
|
56
|
+
|
|
57
|
+
async getList(
|
|
58
|
+
params = {
|
|
59
|
+
page: Number(this.$route.query.page) || 1,
|
|
60
|
+
limit: Number(this.$route.query.limit) || 10,
|
|
61
|
+
}
|
|
62
|
+
) {}
|
|
63
|
+
|
|
64
|
+
表单数据校验需要拿到内部表单的ref
|
|
65
|
+
|
|
66
|
+
const VGeneralBasicFormRef = this.$refs["VGeneralBasicFormRef"];
|
|
67
|
+
VGeneralBasicFormRef.$refs["queryFormRef"].validate(async (boolean, object) => {
|
|
68
|
+
if (boolean) {
|
|
69
|
+
console.log(this.$refs["VGeneralBasicFormRef"]["queryParams"]);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
校验单个字段
|
|
74
|
+
const VGeneralBasicFormRef = this.$refs["VGeneralBasicFormRef"];
|
|
75
|
+
const state = await new Promise((resolve, reject) => {
|
|
76
|
+
VGeneralBasicFormRef.$refs["queryFormRef"]?.validateField(
|
|
77
|
+
"accNum",
|
|
78
|
+
(errorMessage) => {
|
|
79
|
+
if (!errorMessage) {
|
|
80
|
+
const { accNum } = VGeneralBasicFormRef["queryParams"];
|
|
81
|
+
http
|
|
82
|
+
.getMobileByAccNum({ accNum })
|
|
83
|
+
.then((res) => {
|
|
84
|
+
if (res) {
|
|
85
|
+
if (res.data) {
|
|
86
|
+
}
|
|
87
|
+
resolve(true);
|
|
88
|
+
}else {
|
|
89
|
+
resolve(false);
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
.catch((error) => {
|
|
93
|
+
resolve(false);
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
resolve(false);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+

|
|
104
|
+
|
|
105
|
+
数据示例:
|
|
106
|
+
|
|
107
|
+
showSearch: true, // 显示搜索条件
|
|
108
|
+
getList(); // 请求数据的函数
|
|
109
|
+
afterReset(); // 在重置按钮点击完后但还没重新请求时触发的的函数
|
|
110
|
+
formOnly:true // 只展示表单不展示按钮
|
|
111
|
+
noUrlParameters:true // 不接受和不改变url的参数
|
|
112
|
+
loading:false // 加载动画
|
|
113
|
+
formData:{} // 注意,因为可能出现的性能问题在组件watch formData的变化时没有使用deep,所以有时候深度的修改会不生效,导致表单数据不完整
|
|
114
|
+
noInputBlank: true //校验input框不能仅输入空格
|
|
115
|
+
//例子:formData.value.x=y ✘ | formData.value={...formData.value,x:y} ✔
|
|
116
|
+
formItem: [
|
|
117
|
+
{ // vue2未实现
|
|
118
|
+
label: '',
|
|
119
|
+
prop: 'bsName35',
|
|
120
|
+
type: 'divider',
|
|
121
|
+
dividerSetting: {
|
|
122
|
+
},
|
|
123
|
+
template: {
|
|
124
|
+
default: () => {
|
|
125
|
+
return "123123123";
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{ label: "款式名称",
|
|
130
|
+
prop: "bsName",
|
|
131
|
+
type: "input",
|
|
132
|
+
inputSetting: {
|
|
133
|
+
placeholder: '请输入手机验证码',
|
|
134
|
+
style: 'width: 100%'
|
|
135
|
+
},
|
|
136
|
+
rules: [
|
|
137
|
+
{
|
|
138
|
+
message: "请输入信息"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
pattern: /^\w+[\,\,\-\w' '#]+$/,
|
|
142
|
+
message: "请输入正确的Invoice单号"
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
verificationSetting: {
|
|
146
|
+
defaultText: "查询",
|
|
147
|
+
restTime: 5,
|
|
148
|
+
},
|
|
149
|
+
template: {
|
|
150
|
+
suffix: () => {
|
|
151
|
+
return <svg-icon icon-class="baifenbi" />;
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
label: "二次工艺",
|
|
157
|
+
prop: "spName",
|
|
158
|
+
type: "select",
|
|
159
|
+
multiple:true, //多选
|
|
160
|
+
selectSetting:{},
|
|
161
|
+
option: [
|
|
162
|
+
{ value: "3", label: "满印" },
|
|
163
|
+
{ value: "1", label: "区域印花" },
|
|
164
|
+
{ value: "2", label: "绣花" },
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
label: "创建时间",
|
|
169
|
+
prop: "create_time",
|
|
170
|
+
type: "date-picker",
|
|
171
|
+
datePackerSetting: {
|
|
172
|
+
"range-separator": "至",
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
label: "二次工艺成本价格(人民币分)",
|
|
177
|
+
prop: "spCost",
|
|
178
|
+
type: "input-number",
|
|
179
|
+
"controls-position": "right",
|
|
180
|
+
min: 0,
|
|
181
|
+
rules: [
|
|
182
|
+
{
|
|
183
|
+
required: true,
|
|
184
|
+
message: "请输入二次工艺成本价格",
|
|
185
|
+
trigger: "blur",
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
// vue2未实现
|
|
191
|
+
label: '',
|
|
192
|
+
prop: 'bsName2',
|
|
193
|
+
type: 'input-graphic-verification',
|
|
194
|
+
inputSetting: {
|
|
195
|
+
placeholder: '请输入图形验证码',
|
|
196
|
+
style: 'width: 100%'
|
|
197
|
+
},
|
|
198
|
+
rules: [
|
|
199
|
+
{
|
|
200
|
+
message: '请输入图形验证码',
|
|
201
|
+
trigger: 'blur'
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
graphicSrc, // 请求图像的URL
|
|
205
|
+
getGraphic, // 重新请求图像的函数
|
|
206
|
+
key:Math.random(), // 必传,图像更新后必须更新。如果URL会变化也可以用URL代替
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
label: '',
|
|
210
|
+
prop: 'bsName3',
|
|
211
|
+
type: 'input-mobile-verification',
|
|
212
|
+
inputSetting: {
|
|
213
|
+
placeholder: '请输入手机验证码',
|
|
214
|
+
style: 'width: 100%'
|
|
215
|
+
},
|
|
216
|
+
rules: [
|
|
217
|
+
{
|
|
218
|
+
message: '请输入手机验证码',
|
|
219
|
+
trigger: 'blur'
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
getSmscode,// 获取验证码的回调函数,获取失败必须返回false,否则计时器不会重新计算
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
// vue2未实现
|
|
226
|
+
label: '是否必填',
|
|
227
|
+
prop: 'is_optional',
|
|
228
|
+
type: 'radio',
|
|
229
|
+
radioGroupSetting: {
|
|
230
|
+
disabled: true
|
|
231
|
+
},
|
|
232
|
+
option: [
|
|
233
|
+
{ value: '是', label: 'true',border: true },
|
|
234
|
+
{ value: '否', label: 'false' }
|
|
235
|
+
],
|
|
236
|
+
rules: [
|
|
237
|
+
{
|
|
238
|
+
required: true,
|
|
239
|
+
message: '请输入标签项名称',
|
|
240
|
+
trigger: 'blur'
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
// vue2未实现
|
|
246
|
+
label: '多选',
|
|
247
|
+
prop: 'is_multi',
|
|
248
|
+
type: 'checkbox',
|
|
249
|
+
checkboxGroupSetting: {
|
|
250
|
+
},
|
|
251
|
+
option: [
|
|
252
|
+
{ value: '是', label: 'true' },
|
|
253
|
+
{ value: '否', label: 'false' }
|
|
254
|
+
],
|
|
255
|
+
rules: []
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
// vue2未实现
|
|
259
|
+
label: '受访人',
|
|
260
|
+
prop: 'contactors',
|
|
261
|
+
type: 'form-item-slot',
|
|
262
|
+
name: "contactors"
|
|
263
|
+
// 插槽组件使用:
|
|
264
|
+
// <VGeneralBasicForm ...>
|
|
265
|
+
// <template #contactors>
|
|
266
|
+
// <div>一些组件
|
|
267
|
+
// 一些组件
|
|
268
|
+
// <el-form-item prop="contactors">...</el-form-item>
|
|
269
|
+
// </div>
|
|
270
|
+
// </template>
|
|
271
|
+
// </VGeneralBasicForm>
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
label: "分类",
|
|
275
|
+
prop: "分类",
|
|
276
|
+
type: "cascader",
|
|
277
|
+
selectSetting:{},
|
|
278
|
+
options: [
|
|
279
|
+
{
|
|
280
|
+
value: "zhinan",
|
|
281
|
+
label: "指南",
|
|
282
|
+
children: [
|
|
283
|
+
{
|
|
284
|
+
value: "shejiyuanze",
|
|
285
|
+
label: "设计原则",
|
|
286
|
+
children: [
|
|
287
|
+
{
|
|
288
|
+
value: "yizhi",
|
|
289
|
+
label: "一致",
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
value: "fankui",
|
|
293
|
+
label: "反馈",
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
value: "xiaolv",
|
|
297
|
+
label: "效率",
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
value: "kekong",
|
|
301
|
+
label: "可控",
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
value: "daohang",
|
|
307
|
+
label: "导航",
|
|
308
|
+
children: [
|
|
309
|
+
{
|
|
310
|
+
value: "cexiangdaohang",
|
|
311
|
+
label: "侧向导航",
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
value: "dingbudaohang",
|
|
315
|
+
label: "顶部导航",
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
value: "ziyuan",
|
|
323
|
+
label: "资源",
|
|
324
|
+
children: [
|
|
325
|
+
{
|
|
326
|
+
value: "axure",
|
|
327
|
+
label: "Axure Components",
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
value: "sketch",
|
|
331
|
+
label: "Sketch Templates",
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
value: "jiaohu",
|
|
335
|
+
label: "组件交互文档",
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
},
|
|
339
|
+
],
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
|
|
343
|
+
//rules为表单校验规则,每个组件都可以传入
|
|
344
|
+
|
|
345
|
+
//input支持template,支持以下几个属性:
|
|
346
|
+
//prefix 输入框头部内容,只对 type="text"(默认) 有效
|
|
347
|
+
//suffix 输入框尾部内容,只对 type="text" 有效
|
|
348
|
+
//prepend 输入框前置内容,只对 type="text" 有效
|
|
349
|
+
//append 输入框后置内容,只对 type="text" 有效
|
|
350
|
+
|
|
351
|
+
//divider支持template:
|
|
352
|
+
//default
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
安装:npm i general-basic-form<br/>
|
|
356
|
+
install: npm i general-basic-form
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: 陈德立*******419287484@qq.com
|
|
3
|
+
* @Date: 2023-11-07 17:55:59
|
|
4
|
+
* @LastEditTime: 2023-11-08 10:24:14
|
|
5
|
+
* @LastEditors: 陈德立*******419287484@qq.com
|
|
6
|
+
* @Github: https://github.com/Alan1034
|
|
7
|
+
* @Description:
|
|
8
|
+
* @FilePath: \GeneralBasicForm\public\index.d.ts
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
/// <reference types="vite/client" />
|
|
12
|
+
declare module "*.vue" {
|
|
13
|
+
import { DefineComponent } from "vue"
|
|
14
|
+
const component: DefineComponent<{}, {}, any>
|
|
15
|
+
export default component
|
|
16
|
+
}
|
|
17
|
+
declare module "general-basic-form";
|