icarys-fc-vant 1.0.14 → 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 +87 -278
- package/dist/components/common/subform/package.json +48 -0
- package/dist/components/common/subform/src/component.jsx +75 -0
- package/dist/components/common/subform/src/index.js +3 -0
- package/dist/components/common/wangeditor/package-lock.json +114 -0
- package/dist/components/common/wangeditor/package.json +52 -0
- package/dist/components/common/wangeditor/src/component.jsx +74 -0
- package/dist/components/common/wangeditor/src/index.js +3 -0
- package/dist/core/babel.config.js +13 -0
- package/dist/core/bili.config.js +34 -0
- package/dist/core/package-lock.json +13 -0
- package/dist/core/package.json +61 -0
- package/dist/core/src/components/formCreate.js +287 -0
- package/dist/core/src/components/fragment.js +12 -0
- package/dist/core/src/factory/context.js +264 -0
- package/dist/core/src/factory/creator.js +63 -0
- package/dist/core/src/factory/maker.js +17 -0
- package/dist/core/src/factory/manager.js +87 -0
- package/dist/core/src/factory/node.js +89 -0
- package/dist/core/src/factory/parser.js +28 -0
- package/dist/core/src/frame/api.js +691 -0
- package/dist/core/src/frame/attrs.js +12 -0
- package/dist/core/src/frame/dataDriver.js +76 -0
- package/dist/core/src/frame/fetch.js +128 -0
- package/dist/core/src/frame/index.js +792 -0
- package/dist/core/src/frame/language.js +50 -0
- package/dist/core/src/frame/provider.js +297 -0
- package/dist/core/src/frame/util.js +311 -0
- package/dist/core/src/handler/context.js +573 -0
- package/dist/core/src/handler/effect.js +122 -0
- package/dist/core/src/handler/index.js +143 -0
- package/dist/core/src/handler/inject.js +199 -0
- package/dist/core/src/handler/input.js +199 -0
- package/dist/core/src/handler/lifecycle.js +55 -0
- package/dist/core/src/handler/loader.js +375 -0
- package/dist/core/src/handler/page.js +46 -0
- package/dist/core/src/handler/render.js +29 -0
- package/dist/core/src/index.js +12 -0
- package/dist/core/src/parser/html.js +17 -0
- package/dist/core/src/render/cache.js +47 -0
- package/dist/core/src/render/index.js +33 -0
- package/dist/core/src/render/render.js +418 -0
- package/dist/core/types/index.d.ts +842 -0
- package/dist/icarys-fc-vant.umd.js +17 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.esm.js +39 -0
- package/dist/index.js +46 -0
- package/dist/utils/lib/console.js +16 -0
- package/dist/utils/lib/debounce.js +9 -0
- package/dist/utils/lib/deepextend.js +51 -0
- package/dist/utils/lib/deepset.js +14 -0
- package/dist/utils/lib/extend.js +20 -0
- package/dist/utils/lib/index.js +14 -0
- package/dist/utils/lib/json.js +90 -0
- package/dist/utils/lib/mergeprops.js +62 -0
- package/dist/utils/lib/mitt.js +43 -0
- package/dist/utils/lib/modify.js +8 -0
- package/dist/utils/lib/slot.js +8 -0
- package/dist/utils/lib/toarray.js +5 -0
- package/dist/utils/lib/tocase.js +11 -0
- package/dist/utils/lib/todate.js +10 -0
- package/dist/utils/lib/toline.js +10 -0
- package/dist/utils/lib/topromise.js +10 -0
- package/dist/utils/lib/tostring.js +7 -0
- package/dist/utils/lib/type.js +45 -0
- package/dist/utils/lib/unique.js +6 -0
- package/dist/utils/package.json +32 -0
- package/dist/vant/auto-import.d.ts +5 -0
- package/dist/vant/auto-import.js +50 -0
- package/dist/vant/babel.config.js +10 -0
- package/dist/vant/bili.config.js +40 -0
- package/dist/vant/examples/main.js +13 -0
- package/dist/vant/examples/rule.js +366 -0
- package/dist/vant/package.json +83 -0
- package/dist/vant/src/components/calendar.jsx +128 -0
- package/dist/vant/src/components/cascader.jsx +120 -0
- package/dist/vant/src/components/checkbox.jsx +38 -0
- package/dist/vant/src/components/datePicker.jsx +87 -0
- package/dist/vant/src/components/group.jsx +384 -0
- package/dist/vant/src/components/index.js +26 -0
- package/dist/vant/src/components/radio.jsx +38 -0
- package/dist/vant/src/components/select.jsx +81 -0
- package/dist/vant/src/components/timePicker.jsx +76 -0
- package/dist/vant/src/components/uploader.jsx +99 -0
- package/dist/vant/src/core/alias.js +31 -0
- package/dist/vant/src/core/api.js +135 -0
- package/dist/vant/src/core/config.js +35 -0
- package/dist/vant/src/core/index.js +45 -0
- package/dist/vant/src/core/manager.js +282 -0
- package/dist/vant/src/core/provider.js +63 -0
- package/dist/vant/src/core/utils.js +15 -0
- package/dist/vant/src/index.js +13 -0
- package/dist/vant/src/parsers/hidden.js +12 -0
- package/dist/vant/src/parsers/index.js +59 -0
- package/dist/vant/src/parsers/row.js +10 -0
- package/dist/vant/src/style/index.css +495 -0
- package/dist/vant/types/config.d.ts +99 -0
- package/dist/vant/types/index.d.ts +27 -0
- package/dist/vant/vue.config.js +21 -0
- package/package.json +29 -52
- package/dist/index.min.js +0 -7411
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {computed, defineComponent, ref, toRef} from 'vue';
|
|
2
|
+
import {normalizeOptions} from '../core/utils';
|
|
3
|
+
|
|
4
|
+
const NAME = 'fcSelect';
|
|
5
|
+
|
|
6
|
+
export default defineComponent({
|
|
7
|
+
name: NAME,
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
props: {
|
|
10
|
+
disabled: Boolean,
|
|
11
|
+
placeholder: String,
|
|
12
|
+
columnsFieldNames: Object,
|
|
13
|
+
modelValue: [String, Number, Boolean],
|
|
14
|
+
options: Array,
|
|
15
|
+
},
|
|
16
|
+
emits: ['update:modelValue', 'fc.el', 'change'],
|
|
17
|
+
setup(props, _) {
|
|
18
|
+
const show = ref(false);
|
|
19
|
+
const modelValue = toRef(props, 'modelValue');
|
|
20
|
+
const fieldNames = toRef(props, 'columnsFieldNames', {});
|
|
21
|
+
const options = computed(() => {
|
|
22
|
+
if (fieldNames?.value?.text) {
|
|
23
|
+
return props.options || [];
|
|
24
|
+
} else {
|
|
25
|
+
return normalizeOptions(props.options || []);
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const inputValue = computed(() => {
|
|
30
|
+
if (modelValue.value == null || modelValue.value === '') {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
for (let i = 0; i < (options.value || []).length; i++) {
|
|
34
|
+
if (options.value[i][fieldNames.value.value || 'value'] === modelValue.value) {
|
|
35
|
+
return options.value[i][fieldNames.value.text || 'text'];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return modelValue.value;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const onInput = (val) => {
|
|
42
|
+
_.emit('update:modelValue', val);
|
|
43
|
+
_.emit('change', val);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
show,
|
|
48
|
+
inputValue,
|
|
49
|
+
options,
|
|
50
|
+
open() {
|
|
51
|
+
if (props.disabled) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
show.value = true;
|
|
55
|
+
},
|
|
56
|
+
confirm({selectedValues}) {
|
|
57
|
+
onInput(selectedValues[0]);
|
|
58
|
+
show.value = false;
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
render() {
|
|
63
|
+
return <div class="_fc-select">
|
|
64
|
+
<van-field ref="el" placeholder={this.placeholder} readonly disabled={this.$props.disabled} onClick={this.open}
|
|
65
|
+
model-value={this.inputValue} isLink/>
|
|
66
|
+
<van-popup show={this.show} onUpdate:show={(v) => this.show = v} round position="bottom">
|
|
67
|
+
<van-picker
|
|
68
|
+
{...this.$attrs}
|
|
69
|
+
modelValue={[this.modelValue]}
|
|
70
|
+
columnsFieldNames={this.columnsFieldNames}
|
|
71
|
+
columns={this.options}
|
|
72
|
+
onCancel={() => this.show = false}
|
|
73
|
+
onConfirm={this.confirm}
|
|
74
|
+
/>
|
|
75
|
+
</van-popup>
|
|
76
|
+
</div>
|
|
77
|
+
},
|
|
78
|
+
mounted() {
|
|
79
|
+
this.$emit('fc.el', this.$refs.el);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {computed, defineComponent, ref, toRef} from 'vue';
|
|
2
|
+
|
|
3
|
+
const NAME = 'fcTimePicker';
|
|
4
|
+
|
|
5
|
+
export default defineComponent({
|
|
6
|
+
name: NAME,
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
props: {
|
|
9
|
+
disabled: Boolean,
|
|
10
|
+
clearable: Boolean,
|
|
11
|
+
placeholder: String,
|
|
12
|
+
modelValue: [String, Number],
|
|
13
|
+
},
|
|
14
|
+
emits: ['update:modelValue', 'fc.el', 'change'],
|
|
15
|
+
setup(props, _) {
|
|
16
|
+
const show = ref(false);
|
|
17
|
+
const modelValue = toRef(props, 'modelValue');
|
|
18
|
+
|
|
19
|
+
const formValue = computed(() => {
|
|
20
|
+
if (modelValue.value == null || modelValue.value === '') {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return modelValue.value.split(':');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const onInput = (val) => {
|
|
27
|
+
_.emit('update:modelValue', val);
|
|
28
|
+
_.emit('change', val);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
show,
|
|
33
|
+
formValue,
|
|
34
|
+
open() {
|
|
35
|
+
if (props.disabled) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
show.value = true;
|
|
39
|
+
},
|
|
40
|
+
confirm({selectedValues}) {
|
|
41
|
+
onInput(selectedValues.join(':'));
|
|
42
|
+
show.value = false;
|
|
43
|
+
},
|
|
44
|
+
clear(e) {
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
onInput('');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
render() {
|
|
51
|
+
const clearIcon = () => {
|
|
52
|
+
return this.$props.clearable && this.modelValue ?
|
|
53
|
+
<i class="van-badge__wrapper van-icon van-icon-clear van-field__clear"
|
|
54
|
+
onClick={this.clear}></i> : undefined;
|
|
55
|
+
}
|
|
56
|
+
return <div class="_fc-time-picker">
|
|
57
|
+
<van-field ref="el" placeholder={this.placeholder} readonly disabled={this.$props.disabled}
|
|
58
|
+
onClick={this.open}
|
|
59
|
+
model-value={this.modelValue} border={false} isLink v-slots={{
|
|
60
|
+
'right-icon': clearIcon
|
|
61
|
+
}}/>
|
|
62
|
+
<van-popup show={this.show} onUpdate:show={(v) => this.show = v} round position="bottom">
|
|
63
|
+
<van-time-picker
|
|
64
|
+
columnsType={['hour', 'minute']}
|
|
65
|
+
{...this.$attrs}
|
|
66
|
+
modelValue={this.formValue}
|
|
67
|
+
onConfirm={this.confirm}
|
|
68
|
+
onCancel={() => this.show = false}
|
|
69
|
+
/>
|
|
70
|
+
</van-popup>
|
|
71
|
+
</div>
|
|
72
|
+
},
|
|
73
|
+
mounted() {
|
|
74
|
+
this.$emit('fc.el', this.$refs.el);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {defineComponent, ref, toRef, watch} from 'vue';
|
|
2
|
+
import toArray from '@form-create/utils/lib/toarray';
|
|
3
|
+
|
|
4
|
+
const NAME = 'fcUploader';
|
|
5
|
+
|
|
6
|
+
function parseFile(file, i) {
|
|
7
|
+
if (typeof file === 'object') {
|
|
8
|
+
return file;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
url: file,
|
|
12
|
+
is_string: true,
|
|
13
|
+
name: getFileName(file),
|
|
14
|
+
uid: i
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function parseUpload(file) {
|
|
19
|
+
return {...file, file, value: file};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getFileName(file) {
|
|
23
|
+
return ('' + file).split('/').pop()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default defineComponent({
|
|
27
|
+
name: NAME,
|
|
28
|
+
inheritAttrs: false,
|
|
29
|
+
props: {
|
|
30
|
+
formCreateInject: Object,
|
|
31
|
+
modelValue: [Array, String, Object],
|
|
32
|
+
afterRead: Function,
|
|
33
|
+
action: String,
|
|
34
|
+
headers: Object,
|
|
35
|
+
method: String,
|
|
36
|
+
data: Object,
|
|
37
|
+
uploadName: String,
|
|
38
|
+
onSuccess: Function,
|
|
39
|
+
onError: Function,
|
|
40
|
+
maxCount: Number,
|
|
41
|
+
},
|
|
42
|
+
emits: ['update:modelValue', 'delete'],
|
|
43
|
+
setup(props, _) {
|
|
44
|
+
|
|
45
|
+
const afterRead = toRef(props, 'afterRead');
|
|
46
|
+
const modelValue = toRef(props, 'modelValue', []);
|
|
47
|
+
|
|
48
|
+
const fileList = ref(toArray(modelValue.value).map(parseFile).map(parseUpload));
|
|
49
|
+
|
|
50
|
+
watch(() => modelValue.value, (n) => {
|
|
51
|
+
fileList.value = toArray(n).map(parseFile).map(parseUpload);
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const uploadValue = () => {
|
|
55
|
+
let files = fileList.value.map((v) => v.is_string ? v.url : (v.value || v.url)).filter((url) => url !== undefined);
|
|
56
|
+
_.emit('update:modelValue', props.maxCount === 1 ? (files[0] || '') : files);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
fileList,
|
|
61
|
+
modelValue,
|
|
62
|
+
onDelete(file) {
|
|
63
|
+
uploadValue();
|
|
64
|
+
_.emit('delete', file);
|
|
65
|
+
},
|
|
66
|
+
uploadFile(file) {
|
|
67
|
+
file.status = 'uploading';
|
|
68
|
+
if (afterRead.value) {
|
|
69
|
+
return afterRead.value(file);
|
|
70
|
+
} else {
|
|
71
|
+
const data = props.data || {};
|
|
72
|
+
data[props.uploadName || 'file'] = file.file;
|
|
73
|
+
props.formCreateInject.api.fetch({
|
|
74
|
+
action: props.action,
|
|
75
|
+
dataType: 'formData',
|
|
76
|
+
source: 'upload',
|
|
77
|
+
headers: props.headers || {},
|
|
78
|
+
method: props.method || 'post',
|
|
79
|
+
data
|
|
80
|
+
}).then(res => {
|
|
81
|
+
file.status = 'success';
|
|
82
|
+
props.onSuccess && props.onSuccess(res, file);
|
|
83
|
+
uploadValue();
|
|
84
|
+
}).catch(e => {
|
|
85
|
+
file.status = 'failed';
|
|
86
|
+
file.message = this.formCreateInject.t('uploadFail') || '上传失败';
|
|
87
|
+
props.onError && props.onError(e, file);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
render() {
|
|
94
|
+
return <van-uploader {...this.$attrs} model-value={this.fileList} maxCount={this.maxCount}
|
|
95
|
+
onUpdate:model-value={(v) => this.fileList = v}
|
|
96
|
+
afterRead={this.uploadFile} onDelete={this.onDelete} v-slots={this.$slots}/>
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const PRE = 'van';
|
|
2
|
+
export default {
|
|
3
|
+
button: PRE + '-button',
|
|
4
|
+
icon: PRE + '-icon',
|
|
5
|
+
slider: PRE + '-slider',
|
|
6
|
+
stepper: PRE + '-stepper',
|
|
7
|
+
inputNumber: PRE + '-stepper',
|
|
8
|
+
rate: PRE + '-rate',
|
|
9
|
+
uploader: 'fc-uploader',
|
|
10
|
+
upload: 'fc-uploader',
|
|
11
|
+
cell: PRE + '-cell',
|
|
12
|
+
timePicker: 'fc-time-picker',
|
|
13
|
+
datePicker: 'fc-date-picker',
|
|
14
|
+
'switch': PRE + '-switch',
|
|
15
|
+
select: 'fc-select',
|
|
16
|
+
cascader: 'fc-cascader',
|
|
17
|
+
calendar: 'fc-calendar',
|
|
18
|
+
checkbox: 'fc-checkbox',
|
|
19
|
+
radio: 'fc-radio',
|
|
20
|
+
input: PRE + '-field',
|
|
21
|
+
textarea: PRE + '-field',
|
|
22
|
+
field: PRE + '-field',
|
|
23
|
+
formItem: PRE + '-field',
|
|
24
|
+
form: PRE + '-form',
|
|
25
|
+
col: PRE + '-col',
|
|
26
|
+
row: PRE + '-row',
|
|
27
|
+
group: 'fc-group',
|
|
28
|
+
array: 'fc-group',
|
|
29
|
+
object: 'fc-sub-form',
|
|
30
|
+
subForm: 'fc-sub-form',
|
|
31
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import extend from '../../../utils/lib/extend';
|
|
2
|
+
import is from '../../../utils/lib/type';
|
|
3
|
+
import {invoke} from '@form-create/core/src/frame/util';
|
|
4
|
+
import toArray from '../../../utils/lib/toarray';
|
|
5
|
+
|
|
6
|
+
function tidyBtnProp(btn, def) {
|
|
7
|
+
if (is.Boolean(btn))
|
|
8
|
+
btn = {show: btn};
|
|
9
|
+
else if (!is.Undef(btn) && !is.Object(btn)) btn = {show: def};
|
|
10
|
+
return btn;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default function extendApi(api, h) {
|
|
14
|
+
return {
|
|
15
|
+
formEl() {
|
|
16
|
+
return h.$manager.form();
|
|
17
|
+
},
|
|
18
|
+
wrapEl(id) {
|
|
19
|
+
const ctx = h.getFieldCtx(id);
|
|
20
|
+
if (!ctx) return;
|
|
21
|
+
return h.vm.refs[ctx.wrapRef];
|
|
22
|
+
},
|
|
23
|
+
validate(callback) {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
const forms = api.children;
|
|
26
|
+
const all = [h.$manager.validate()];
|
|
27
|
+
forms.filter(v=>!v.isScope).forEach(v => {
|
|
28
|
+
all.push(v.validate());
|
|
29
|
+
})
|
|
30
|
+
Promise.all(all).then(() => {
|
|
31
|
+
resolve(true);
|
|
32
|
+
callback && callback(true);
|
|
33
|
+
}).catch((e) => {
|
|
34
|
+
reject(e);
|
|
35
|
+
callback && callback(e);
|
|
36
|
+
h.vm.emit('validate-fail', e, {api});
|
|
37
|
+
h.emitEvent('validate-fail', e, {api});
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
validateField(field, callback) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const ctx = h.getFieldCtx(field);
|
|
44
|
+
if (!ctx) return;
|
|
45
|
+
const sub = h.subForm[ctx.id];
|
|
46
|
+
const all = [h.$manager.validateField(ctx.id)];
|
|
47
|
+
toArray(sub).filter(v=>!v.isScope).forEach(v => {
|
|
48
|
+
all.push(v.validate());
|
|
49
|
+
})
|
|
50
|
+
Promise.all(all).then(() => {
|
|
51
|
+
resolve(null);
|
|
52
|
+
callback && callback(null);
|
|
53
|
+
}).catch((e) => {
|
|
54
|
+
reject(e);
|
|
55
|
+
callback && callback(e);
|
|
56
|
+
h.vm.emit('validate-field-fail', e, {field, api});
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
clearValidateState(fields, clearSub = true) {
|
|
61
|
+
api.helper.tidyFields(fields).forEach(field => {
|
|
62
|
+
if (clearSub) this.clearSubValidateState(field);
|
|
63
|
+
h.getCtxs(field).forEach(ctx => {
|
|
64
|
+
h.$manager.clearValidateState(ctx);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
clearSubValidateState(fields) {
|
|
69
|
+
api.helper.tidyFields(fields).forEach(field => {
|
|
70
|
+
h.getCtxs(field).forEach(ctx => {
|
|
71
|
+
const subForm = h.subForm[ctx.id];
|
|
72
|
+
if (!subForm) return;
|
|
73
|
+
if (Array.isArray(subForm)) {
|
|
74
|
+
subForm.forEach(form => {
|
|
75
|
+
form.clearValidateState();
|
|
76
|
+
})
|
|
77
|
+
} else if (subForm) {
|
|
78
|
+
subForm.clearValidateState();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
})
|
|
82
|
+
},
|
|
83
|
+
btn: {
|
|
84
|
+
loading: (loading = true) => {
|
|
85
|
+
api.submitBtnProps({loading: !!loading});
|
|
86
|
+
},
|
|
87
|
+
disabled: (disabled = true) => {
|
|
88
|
+
api.submitBtnProps({disabled: !!disabled});
|
|
89
|
+
},
|
|
90
|
+
show: (isShow = true) => {
|
|
91
|
+
api.submitBtnProps({show: !!isShow});
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
resetBtn: {
|
|
95
|
+
loading: (loading = true) => {
|
|
96
|
+
api.resetBtnProps({loading: !!loading});
|
|
97
|
+
},
|
|
98
|
+
disabled: (disabled = true) => {
|
|
99
|
+
api.resetBtnProps({disabled: !!disabled});
|
|
100
|
+
},
|
|
101
|
+
show: (isShow = true) => {
|
|
102
|
+
api.resetBtnProps({show: !!isShow});
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
submitBtnProps: (props = {}) => {
|
|
106
|
+
let btn = tidyBtnProp(h.options.submitBtn, true);
|
|
107
|
+
extend(btn, props);
|
|
108
|
+
h.options.submitBtn = btn;
|
|
109
|
+
api.refreshOptions();
|
|
110
|
+
},
|
|
111
|
+
resetBtnProps: (props = {}) => {
|
|
112
|
+
let btn = tidyBtnProp(h.options.resetBtn, false);
|
|
113
|
+
extend(btn, props);
|
|
114
|
+
h.options.resetBtn = btn;
|
|
115
|
+
api.refreshOptions();
|
|
116
|
+
},
|
|
117
|
+
submit(successFn, failFn) {
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
const promise = h.options.validateOnSubmit === false ? Promise.resolve() : api.validate();
|
|
120
|
+
promise.then(() => {
|
|
121
|
+
let formData = api.formData();
|
|
122
|
+
h.beforeSubmit(formData).then(() => {
|
|
123
|
+
is.Function(successFn) && invoke(() => successFn(formData, api));
|
|
124
|
+
is.Function(h.options.onSubmit) && invoke(() => h.options.onSubmit(formData, api));
|
|
125
|
+
h.vm.emit('submit', formData, api);
|
|
126
|
+
resolve(formData);
|
|
127
|
+
}).catch((e) => {})
|
|
128
|
+
}).catch((...args) => {
|
|
129
|
+
is.Function(failFn) && invoke(() => failFn(api, ...args));
|
|
130
|
+
reject(...args)
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export default function getConfig() {
|
|
2
|
+
return {
|
|
3
|
+
form: {
|
|
4
|
+
required: 'auto',
|
|
5
|
+
labelAlign: 'right',
|
|
6
|
+
inputAlign: 'right',
|
|
7
|
+
},
|
|
8
|
+
row: {
|
|
9
|
+
show: true,
|
|
10
|
+
gutter: 0,
|
|
11
|
+
},
|
|
12
|
+
submitBtn: {
|
|
13
|
+
type: 'primary',
|
|
14
|
+
loading: false,
|
|
15
|
+
disabled: false,
|
|
16
|
+
block: true,
|
|
17
|
+
innerText: '',
|
|
18
|
+
size: 'small',
|
|
19
|
+
show: true,
|
|
20
|
+
col: undefined,
|
|
21
|
+
click: undefined,
|
|
22
|
+
},
|
|
23
|
+
resetBtn: {
|
|
24
|
+
type: 'default',
|
|
25
|
+
loading: false,
|
|
26
|
+
disabled: false,
|
|
27
|
+
block: true,
|
|
28
|
+
innerText: '',
|
|
29
|
+
size: 'small',
|
|
30
|
+
show: false,
|
|
31
|
+
col: undefined,
|
|
32
|
+
click: undefined,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import components from '../components';
|
|
2
|
+
import parsers from '../parsers';
|
|
3
|
+
import alias from './alias';
|
|
4
|
+
import manager from './manager';
|
|
5
|
+
import FormCreateFactory from '../../../core/src/index';
|
|
6
|
+
import '../style/index.css';
|
|
7
|
+
import extendApi from './api';
|
|
8
|
+
import required from './provider';
|
|
9
|
+
import {Field} from 'vant';
|
|
10
|
+
|
|
11
|
+
function install(FormCreate) {
|
|
12
|
+
FormCreate.componentAlias(alias);
|
|
13
|
+
|
|
14
|
+
components.forEach(component => {
|
|
15
|
+
FormCreate.component(component.name, component);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
FormCreate.register(required);
|
|
19
|
+
|
|
20
|
+
parsers.forEach((parser) => {
|
|
21
|
+
FormCreate.parser(parser);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (Field.props) {
|
|
25
|
+
Field.props.modelValue = {
|
|
26
|
+
type: [String, Number, Array, Object, Boolean, Function],
|
|
27
|
+
default: '',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default function VantFormCreate() {
|
|
33
|
+
return FormCreateFactory({
|
|
34
|
+
ui: 'process.env.UI',
|
|
35
|
+
version: 'process.env.VERSION',
|
|
36
|
+
manager,
|
|
37
|
+
extendApi,
|
|
38
|
+
install,
|
|
39
|
+
isMobile: true,
|
|
40
|
+
attrs: {
|
|
41
|
+
normal: ['col', 'wrap'],
|
|
42
|
+
key: ['title', 'info'],
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|