9f5e2c7e
梁灏
update Form
|
1
|
<template>
|
afd3509a
梁灏
update Transfer
|
2
|
<div style="width: 600px">
|
c3a9f389
梁灏
update Input
|
3
4
5
6
7
8
9
10
|
<i-form v-ref:form-custom :model="formCustom" :rules="ruleCustom" :label-width="80">
<Form-item label="密码" prop="passwd">
<i-input type="password" :value.sync="formCustom.passwd"></i-input>
</Form-item>
<Form-item label="确认密码" prop="passwdCheck">
<i-input type="password" :value.sync="formCustom.passwdCheck"></i-input>
</Form-item>
<Form-item label="年龄" prop="age">
|
20766f28
梁灏
update Input
|
11
|
<i-input type="text" :value.sync="formCustom.age" number></i-input>
|
c3a9f389
梁灏
update Input
|
12
13
14
15
16
17
18
19
20
|
</Form-item>
<Form-item>
<i-button type="primary" @click="handleSubmit('formCustom')">提交</i-button>
<i-button type="ghost" @click="handleReset('formCustom')" style="margin-left: 8px">重置</i-button>
</Form-item>
</i-form>
|
578ca325
梁灏
fixed Radio bug
|
21
|
<i-form v-ref:form :model="form" :rules="rules" :label-width="100" label-position="right">
|
184dba1c
梁灏
update Form
|
22
23
24
25
26
27
|
<form-item label="邮箱" prop="mail">
<i-input :value.sync="form.mail" placeholder="请输入邮箱">
<Icon type="ios-email-outline" slot="prepend"></Icon>
</i-input>
</form-item>
<form-item label="密码" prop="passwd">
|
e93f1e9a
梁灏
update some styles
|
28
29
30
31
32
33
34
35
36
37
|
<i-input :value.sync="form.passwd">
<i-select slot="prepend" style="width: 80px">
<i-option value="http">http://</i-option>
<i-option value="https">https://</i-option>
</i-select>
<i-select slot="append" style="width: 70px">
<i-option value="com">.com</i-option>
<i-option value="org">.org</i-option>
<i-option value="io">.io</i-option>
</i-select>
|
184dba1c
梁灏
update Form
|
38
39
|
</i-input>
</form-item>
|
e93f1e9a
梁灏
update some styles
|
40
41
42
|
<form-item label="textarea" prop="textarea">
<i-input :value.sync="form.textarea" type="textarea" :autosize="{minRows: 2,maxRows: 5}" placeholder="请输入..."></i-input>
</form-item>
|
578ca325
梁灏
fixed Radio bug
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<form-item label="radio" prop="single">
<radio :checked.sync="form.single">Single</radio>
</form-item>
<form-item label="radioGroup" prop="group">
<Radio-group :model.sync="form.group">
<Radio value="apple">
<Icon type="social-apple"></Icon>
<span>Apple</span>
</Radio>
<Radio value="android">
<Icon type="social-android"></Icon>
<span>Android</span>
</Radio>
<Radio value="windows">
<Icon type="social-windows"></Icon>
<span>Windows</span>
</Radio>
</Radio-group>
</form-item>
|
f65e9be5
梁灏
update checkboxGroup
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<form-item label="checkbox-g" prop="checkboxgroup">
<Checkbox-group :model.sync="form.checkboxgroup">
<Checkbox value="twitter">
<Icon type="social-twitter"></Icon>
<span>Twitter</span>
</Checkbox>
<Checkbox value="facebook">
<Icon type="social-facebook"></Icon>
<span>Facebook</span>
</Checkbox>
<Checkbox value="github">
<Icon type="social-github"></Icon>
<span>Github</span>
</Checkbox>
<Checkbox value="snapchat">
<Icon type="social-snapchat"></Icon>
<span>Snapchat</span>
</Checkbox>
|
ba3e34e0
梁灏
update some styles
|
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
|
<Checkbox value="twitter">
<Icon type="social-twitter"></Icon>
<span>Twitter</span>
</Checkbox>
<Checkbox value="facebook">
<Icon type="social-facebook"></Icon>
<span>Facebook</span>
</Checkbox>
<Checkbox value="github">
<Icon type="social-github"></Icon>
<span>Github</span>
</Checkbox>
<Checkbox value="snapchat">
<Icon type="social-snapchat"></Icon>
<span>Snapchat</span>
</Checkbox>
<Checkbox value="twitter">
<Icon type="social-twitter"></Icon>
<span>Twitter</span>
</Checkbox>
<Checkbox value="facebook">
<Icon type="social-facebook"></Icon>
<span>Facebook</span>
</Checkbox>
<Checkbox value="github">
<Icon type="social-github"></Icon>
<span>Github</span>
</Checkbox>
<Checkbox value="snapchat">
<Icon type="social-snapchat"></Icon>
<span>Snapchat</span>
</Checkbox>
<Checkbox value="twitter">
<Icon type="social-twitter"></Icon>
<span>Twitter</span>
</Checkbox>
<Checkbox value="facebook">
<Icon type="social-facebook"></Icon>
<span>Facebook</span>
</Checkbox>
<Checkbox value="github">
<Icon type="social-github"></Icon>
<span>Github</span>
</Checkbox>
<Checkbox value="snapchat">
<Icon type="social-snapchat"></Icon>
<span>Snapchat</span>
</Checkbox>
<Checkbox value="twitter">
<Icon type="social-twitter"></Icon>
<span>Twitter</span>
</Checkbox>
<Checkbox value="facebook">
<Icon type="social-facebook"></Icon>
<span>Facebook</span>
</Checkbox>
<Checkbox value="github">
<Icon type="social-github"></Icon>
<span>Github</span>
</Checkbox>
<Checkbox value="snapchat">
<Icon type="social-snapchat"></Icon>
<span>Snapchat</span>
</Checkbox>
<Checkbox value="twitter">
<Icon type="social-twitter"></Icon>
<span>Twitter</span>
</Checkbox>
<Checkbox value="facebook">
<Icon type="social-facebook"></Icon>
<span>Facebook</span>
</Checkbox>
<Checkbox value="github">
<Icon type="social-github"></Icon>
<span>Github</span>
</Checkbox>
<Checkbox value="snapchat">
<Icon type="social-snapchat"></Icon>
<span>Snapchat</span>
</Checkbox>
|
f65e9be5
梁灏
update checkboxGroup
|
160
161
|
</Checkbox-group>
</form-item>
|
3ad47566
梁灏
update Select
|
162
163
164
165
|
<form-item label="select" prop="select">
<i-select :model.sync="form.select" style="width:200px" clearable>
<i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option>
</i-select>
|
ba3e34e0
梁灏
update some styles
|
166
167
168
169
170
171
|
<i-select :model.sync="model11" filterable>
<i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option>
</i-select>
<i-select :model.sync="model12" filterable multiple>
<i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option>
</i-select>
|
3ad47566
梁灏
update Select
|
172
173
174
175
176
177
|
</form-item>
<form-item label="select多选" prop="selectm">
<i-select :model.sync="form.selectm" multiple style="width:260px">
<i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option>
</i-select>
</form-item>
|
d1703993
梁灏
update Slider
|
178
179
180
|
<form-item label="多选滑块" prop="slider">
<Slider :value.sync="form.slider" range></Slider>
</form-item>
|
73d10c28
梁灏
update DatePicker
|
181
|
<form-item label="日期" prop="date">
|
73d10c28
梁灏
update DatePicker
|
182
183
184
|
<Time-picker :value.sync="form.date" type="time" placeholder="选择时间" style="width: 168px"></Time-picker>
</form-item>
<form-item label="两个日期" prop="date2">
|
ba3e34e0
梁灏
update some styles
|
185
|
<Date-picker :value.sync="form.date2" type="daterange" placement="bottom-start" placeholder="选择日期" @on-change="c"></Date-picker>
|
73d10c28
梁灏
update DatePicker
|
186
|
</form-item>
|
3b005863
梁灏
update Cascader
|
187
188
189
|
<form-item label="级联" prop="cascader">
<Cascader :data="data" :value.sync="form.cascader"></Cascader>
</form-item>
|
afd3509a
梁灏
update Transfer
|
190
191
192
193
194
195
196
|
<form-item label="穿梭框" prop="targetKeys1">
<Transfer
:data="form.transfer"
:target-keys="form.targetKeys1"
:render-format="render1"
@on-change="handleChange1"></Transfer>
</form-item>
|
4a260ed5
梁灏
update InputNumber
|
197
198
199
|
<form-item label="数字输入框" prop="input">
<Input-number :max="10" :min="1" :value.sync="form.input"></Input-number>
</form-item>
|
184dba1c
梁灏
update Form
|
200
201
|
<form-item>
<i-button type="primary" @click="onSubmit('form')">提交</i-button>
|
ba3a2f1e
梁灏
publish 0.9.13-rc-1
|
202
|
<i-button type="ghost" @click="resetForm('form')">重置</i-button>
|
184dba1c
梁灏
update Form
|
203
|
</form-item>
|
9f5e2c7e
梁灏
update Form
|
204
205
206
207
208
209
210
|
</i-form>
</div>
</template>
<script>
export default {
props: {},
data () {
|
c3a9f389
梁灏
update Input
|
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
const validatePass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入密码'));
} else {
if (this.formCustom.passwdCheck !== '') {
this.$refs.formCustom.validateField('passwdCheck');
}
callback();
}
};
const validatePassCheck = (rule, value, callback) => {
if (value === '') {
callback(new Error('请再次输入密码'));
} else if (value !== this.formCustom.passwd) {
callback(new Error('两次输入密码不一致!'));
} else {
callback();
}
};
const validateAge = (rule, value, callback) => {
if (!value) {
return callback(new Error('年龄不能为空'));
}
setTimeout(() => {
if (!Number.isInteger(value)) {
callback(new Error('请输入数字值'));
} else {
if (value < 18) {
callback(new Error('必须年满18岁'));
} else {
callback();
}
}
}, 1000);
};
|
184dba1c
梁灏
update Form
|
247
|
return {
|
3b005863
梁灏
update Cascader
|
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
data: [{
value: 'beijing',
label: '北京',
children: [
{
value: 'gugong',
label: '故宫'
},
{
value: 'tiantan',
label: '天坛'
},
{
value: 'wangfujing',
label: '王府井'
}
]
}, {
value: 'jiangsu',
label: '江苏',
children: [
{
value: 'nanjing',
label: '南京',
children: [
{
value: 'fuzimiao',
label: '夫子庙',
}
]
},
{
value: 'suzhou',
label: '苏州',
children: [
{
value: 'zhuozhengyuan',
label: '拙政园',
},
{
value: 'shizilin',
label: '狮子林',
}
]
}
],
}],
|
3ad47566
梁灏
update Select
|
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
cityList: [
{
value: 'beijing',
label: '北京市'
},
{
value: 'shanghai',
label: '上海市'
},
{
value: 'shenzhen',
label: '深圳市'
},
{
value: 'hangzhou',
label: '杭州市'
},
{
value: 'nanjing',
label: '南京市'
},
{
value: 'chongqing',
label: '重庆市'
}
],
|
184dba1c
梁灏
update Form
|
321
322
|
form: {
mail: '',
|
578ca325
梁灏
fixed Radio bug
|
323
324
|
passwd: '',
single: false,
|
f65e9be5
梁灏
update checkboxGroup
|
325
|
group: '',
|
3ad47566
梁灏
update Select
|
326
327
|
checkboxgroup: [],
select: '',
|
d1703993
梁灏
update Slider
|
328
|
selectm: [],
|
73d10c28
梁灏
update DatePicker
|
329
330
|
slider: [40, 50],
date: '',
|
3b005863
梁灏
update Cascader
|
331
|
date2: '',
|
afd3509a
梁灏
update Transfer
|
332
333
|
cascader: [],
transfer: this.getMockData(),
|
4a260ed5
梁灏
update InputNumber
|
334
|
targetKeys1: this.getTargetKeys(),
|
e93f1e9a
梁灏
update some styles
|
335
336
|
input: 1,
textarea: ''
|
184dba1c
梁灏
update Form
|
337
338
339
340
|
},
rules: {
mail: [
{
|
578ca325
梁灏
fixed Radio bug
|
341
342
343
344
|
required: true, message: '请输入正确的邮箱', trigger: 'blur', type: 'email'
},
{
min: 3, max: 50, message: '长度在 3 到 50 个字符', trigger: 'blur'
|
184dba1c
梁灏
update Form
|
345
346
|
},
{
|
578ca325
梁灏
fixed Radio bug
|
347
|
min: 3, max: 50, message: '长度在 3 到 5 个字符', trigger: 'change'
|
184dba1c
梁灏
update Form
|
348
349
350
351
352
353
|
}
],
passwd: [
{
required: true, message: '请输入密码', trigger: 'blur'
}
|
578ca325
梁灏
fixed Radio bug
|
354
355
356
357
358
|
],
group: [
{
required: true, message: '请单选组'
}
|
f65e9be5
梁灏
update checkboxGroup
|
359
360
361
362
363
364
365
366
|
],
checkboxgroup: [
{
required: true, message: '至少选择2个', min: 2, type: 'array',
},
{
required: true, message: '至多选择3个', max: 3, type: 'array'
}
|
3ad47566
梁灏
update Select
|
367
368
369
370
371
372
|
],
select: [
{
required: true
}
],
|
d1703993
梁灏
update Slider
|
373
|
slider: [
|
3ad47566
梁灏
update Select
|
374
|
{
|
d1703993
梁灏
update Slider
|
375
376
377
378
379
380
381
382
383
|
type: 'array', len: 2,
fields: {
0: {
type: 'number', min: 30, 'message': '不能小于30'
},
1: {
type: 'number', max: 90, 'message': '不能大于90'
}
}
|
3ad47566
梁灏
update Select
|
384
|
}
|
73d10c28
梁灏
update DatePicker
|
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
|
],
date: [
{
required: true
},
{
type: 'date'
}
],
date2: [
{
type: 'array', len: 2,
fields: {
0: {
type: 'date', required: true
},
1: {
type: 'date', required: true
}
}
}
|
3b005863
梁灏
update Cascader
|
406
407
408
409
410
|
],
cascader: [
{
type: 'array', required: true
}
|
afd3509a
梁灏
update Transfer
|
411
412
413
414
415
|
],
targetKeys1: [
{
type: 'array', min: 8, max: 10
}
|
4a260ed5
梁灏
update InputNumber
|
416
417
418
419
420
|
],
input: [
{
type: 'number', min: 1, max: 4
}
|
e93f1e9a
梁灏
update some styles
|
421
422
423
424
425
426
427
428
|
],
textarea: [
{
required: true, trigger: 'blur'
},
{
type: 'string', min: 10
}
|
184dba1c
梁灏
update Form
|
429
|
]
|
c3a9f389
梁灏
update Input
|
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
|
},
formCustom: {
passwd: '',
passwdCheck: '',
age: ''
},
ruleCustom: {
passwd: [
{ validator: validatePass, trigger: 'blur' }
],
passwdCheck: [
{ validator: validatePassCheck, trigger: 'blur' }
],
age: [
{ validator: validateAge, trigger: 'blur' }
]
|
184dba1c
梁灏
update Form
|
446
447
|
}
}
|
9f5e2c7e
梁灏
update Form
|
448
449
|
},
computed: {},
|
184dba1c
梁灏
update Form
|
450
451
452
453
454
455
456
457
458
459
|
methods: {
onSubmit (formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.$Message.success('submit!');
} else {
this.$Message.error('error submit!');
return false;
}
});
|
73d10c28
梁灏
update DatePicker
|
460
|
},
|
ba3a2f1e
梁灏
publish 0.9.13-rc-1
|
461
462
463
|
resetForm (formName) {
this.$refs[formName].resetFields();
},
|
73d10c28
梁灏
update DatePicker
|
464
465
|
c (s) {
console.log(this.form.date)
|
afd3509a
梁灏
update Transfer
|
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
},
getMockData () {
let mockData = [];
for (let i = 1; i <= 20; i++) {
mockData.push({
key: i.toString(),
label: '内容' + i,
description: '内容' + i + '的描述信息',
disabled: Math.random() * 3 < 1
});
}
return mockData;
},
getTargetKeys () {
return this.getMockData()
.filter(() => Math.random() * 2 > 1)
.map(item => item.key);
},
render1 (item) {
return item.label;
},
handleChange1 (newTargetKeys, direction, moveKeys) {
console.log(newTargetKeys);
console.log(direction);
console.log(moveKeys);
this.form.targetKeys1 = newTargetKeys;
|
c3a9f389
梁灏
update Input
|
492
493
494
495
496
497
498
499
500
501
502
503
|
},
handleSubmit (name) {
this.$refs[name].validate((valid) => {
if (valid) {
this.$Message.success('提交成功!');
} else {
this.$Message.error('表单验证失败!');
}
})
},
handleReset (name) {
this.$refs[name].resetFields();
|
184dba1c
梁灏
update Form
|
504
505
|
}
}
|
9f5e2c7e
梁灏
update Form
|
506
507
|
};
</script>
|