icarys-fc-vant 1.0.15 → 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.
Files changed (101) hide show
  1. package/README.md +87 -278
  2. package/dist/components/common/subform/package.json +48 -0
  3. package/dist/components/common/subform/src/component.jsx +75 -0
  4. package/dist/components/common/subform/src/index.js +3 -0
  5. package/dist/components/common/wangeditor/package-lock.json +114 -0
  6. package/dist/components/common/wangeditor/package.json +52 -0
  7. package/dist/components/common/wangeditor/src/component.jsx +74 -0
  8. package/dist/components/common/wangeditor/src/index.js +3 -0
  9. package/dist/core/babel.config.js +13 -0
  10. package/dist/core/bili.config.js +34 -0
  11. package/dist/core/package-lock.json +13 -0
  12. package/dist/core/package.json +61 -0
  13. package/dist/core/src/components/formCreate.js +287 -0
  14. package/dist/core/src/components/fragment.js +12 -0
  15. package/dist/core/src/factory/context.js +264 -0
  16. package/dist/core/src/factory/creator.js +63 -0
  17. package/dist/core/src/factory/maker.js +17 -0
  18. package/dist/core/src/factory/manager.js +87 -0
  19. package/dist/core/src/factory/node.js +89 -0
  20. package/dist/core/src/factory/parser.js +28 -0
  21. package/dist/core/src/frame/api.js +691 -0
  22. package/dist/core/src/frame/attrs.js +12 -0
  23. package/dist/core/src/frame/dataDriver.js +76 -0
  24. package/dist/core/src/frame/fetch.js +128 -0
  25. package/dist/core/src/frame/index.js +792 -0
  26. package/dist/core/src/frame/language.js +50 -0
  27. package/dist/core/src/frame/provider.js +297 -0
  28. package/dist/core/src/frame/util.js +311 -0
  29. package/dist/core/src/handler/context.js +573 -0
  30. package/dist/core/src/handler/effect.js +122 -0
  31. package/dist/core/src/handler/index.js +143 -0
  32. package/dist/core/src/handler/inject.js +199 -0
  33. package/dist/core/src/handler/input.js +199 -0
  34. package/dist/core/src/handler/lifecycle.js +55 -0
  35. package/dist/core/src/handler/loader.js +375 -0
  36. package/dist/core/src/handler/page.js +46 -0
  37. package/dist/core/src/handler/render.js +29 -0
  38. package/dist/core/src/index.js +12 -0
  39. package/dist/core/src/parser/html.js +17 -0
  40. package/dist/core/src/render/cache.js +47 -0
  41. package/dist/core/src/render/index.js +33 -0
  42. package/dist/core/src/render/render.js +418 -0
  43. package/dist/core/types/index.d.ts +842 -0
  44. package/dist/icarys-fc-vant.umd.js +17 -0
  45. package/dist/index.d.ts +27 -0
  46. package/dist/index.esm.js +39 -0
  47. package/dist/index.js +46 -0
  48. package/dist/utils/lib/console.js +16 -0
  49. package/dist/utils/lib/debounce.js +9 -0
  50. package/dist/utils/lib/deepextend.js +51 -0
  51. package/dist/utils/lib/deepset.js +14 -0
  52. package/dist/utils/lib/extend.js +20 -0
  53. package/dist/utils/lib/index.js +14 -0
  54. package/dist/utils/lib/json.js +90 -0
  55. package/dist/utils/lib/mergeprops.js +62 -0
  56. package/dist/utils/lib/mitt.js +43 -0
  57. package/dist/utils/lib/modify.js +8 -0
  58. package/dist/utils/lib/slot.js +8 -0
  59. package/dist/utils/lib/toarray.js +5 -0
  60. package/dist/utils/lib/tocase.js +11 -0
  61. package/dist/utils/lib/todate.js +10 -0
  62. package/dist/utils/lib/toline.js +10 -0
  63. package/dist/utils/lib/topromise.js +10 -0
  64. package/dist/utils/lib/tostring.js +7 -0
  65. package/dist/utils/lib/type.js +45 -0
  66. package/dist/utils/lib/unique.js +6 -0
  67. package/dist/utils/package.json +32 -0
  68. package/dist/vant/auto-import.d.ts +5 -0
  69. package/dist/vant/auto-import.js +50 -0
  70. package/dist/vant/babel.config.js +10 -0
  71. package/dist/vant/bili.config.js +40 -0
  72. package/dist/vant/examples/main.js +13 -0
  73. package/dist/vant/examples/rule.js +366 -0
  74. package/dist/vant/package.json +83 -0
  75. package/dist/vant/src/components/calendar.jsx +128 -0
  76. package/dist/vant/src/components/cascader.jsx +120 -0
  77. package/dist/vant/src/components/checkbox.jsx +38 -0
  78. package/dist/vant/src/components/datePicker.jsx +87 -0
  79. package/dist/vant/src/components/group.jsx +384 -0
  80. package/dist/vant/src/components/index.js +26 -0
  81. package/dist/vant/src/components/radio.jsx +38 -0
  82. package/dist/vant/src/components/select.jsx +81 -0
  83. package/dist/vant/src/components/timePicker.jsx +76 -0
  84. package/dist/vant/src/components/uploader.jsx +99 -0
  85. package/dist/vant/src/core/alias.js +31 -0
  86. package/dist/vant/src/core/api.js +135 -0
  87. package/dist/vant/src/core/config.js +35 -0
  88. package/dist/vant/src/core/index.js +45 -0
  89. package/dist/vant/src/core/manager.js +282 -0
  90. package/dist/vant/src/core/provider.js +63 -0
  91. package/dist/vant/src/core/utils.js +15 -0
  92. package/dist/vant/src/index.js +13 -0
  93. package/dist/vant/src/parsers/hidden.js +12 -0
  94. package/dist/vant/src/parsers/index.js +59 -0
  95. package/dist/vant/src/parsers/row.js +10 -0
  96. package/dist/vant/src/style/index.css +495 -0
  97. package/dist/vant/types/config.d.ts +99 -0
  98. package/dist/vant/types/index.d.ts +27 -0
  99. package/dist/vant/vue.config.js +21 -0
  100. package/package.json +29 -67
  101. package/dist/index.min.js +0 -7411
@@ -0,0 +1,120 @@
1
+ import {computed, defineComponent, ref, toRef, watch} from 'vue';
2
+ import {normalizeOptions} from '../core/utils';
3
+
4
+ const NAME = 'fcCascader';
5
+
6
+ export default defineComponent({
7
+ name: NAME,
8
+ inheritAttrs: false,
9
+ props: {
10
+ placeholder: String,
11
+ disabled: Boolean,
12
+ clearable: Boolean,
13
+ fieldNames: Object,
14
+ modelValue: [String, Number],
15
+ options: Array,
16
+ minDate: [String, Date],
17
+ maxDate: [String, Date],
18
+ },
19
+ emits: ['update:modelValue', 'fc.el', 'change'],
20
+ setup(props, _) {
21
+ const show = ref(false);
22
+ const modelValue = toRef(props, 'modelValue');
23
+ const fieldNames = toRef(props, 'fieldNames', {});
24
+ const options = computed(() => {
25
+ if (fieldNames?.value?.text) {
26
+ return props.options || [];
27
+ } else {
28
+ return normalizeOptions(props.options || []);
29
+ }
30
+ })
31
+
32
+ const findOptions = (options, value, path) => {
33
+ for (let i = 0; i < options.length; i++) {
34
+ if (options[i][fieldNames.value.value || 'value'] === value) {
35
+ return [...path, options[i]];
36
+ } else if (options[i][fieldNames.value.children || 'children']) {
37
+ const find = findOptions(options[i][fieldNames.value.children || 'children'], value, [...path, options[i]]);
38
+ if (find) {
39
+ return find;
40
+ }
41
+ }
42
+ }
43
+ }
44
+
45
+ const updateInputValue = (n) => {
46
+ if (n == null || n === '') {
47
+ return '';
48
+ }
49
+ const path = findOptions(options.value, n, []);
50
+ return path ? path.map((option) => option[fieldNames.value.text || 'text']).join(' / ') : n;
51
+ }
52
+
53
+ const inputValue = ref(updateInputValue(modelValue.value));
54
+
55
+ watch(() => modelValue.value, (n) => {
56
+ inputValue.value = updateInputValue(n);
57
+ });
58
+
59
+ watch(() => options.value, () => {
60
+ if (modelValue.value != null && modelValue.value !== '') {
61
+ inputValue.value = updateInputValue(modelValue.value);
62
+ }
63
+ }, {deep: true});
64
+
65
+ const onInput = (val) => {
66
+ _.emit('update:modelValue', val);
67
+ _.emit('change', val);
68
+ }
69
+
70
+ return {
71
+ show,
72
+ inputValue,
73
+ options,
74
+ open() {
75
+ if (props.disabled) {
76
+ return;
77
+ }
78
+ show.value = true;
79
+ },
80
+ confirm({selectedOptions, value}) {
81
+ inputValue.value = selectedOptions.map((option) => option[fieldNames.value.text || 'text']).join(' / ');
82
+ show.value = false;
83
+ onInput(value);
84
+ },
85
+ clear(e) {
86
+ e.stopPropagation();
87
+ inputValue.value = '';
88
+ onInput('');
89
+ }
90
+ }
91
+ },
92
+ render() {
93
+ const clearIcon = () => {
94
+ return this.$props.clearable && this.inputValue ?
95
+ <i class="van-badge__wrapper van-icon van-icon-clear van-field__clear"
96
+ onClick={this.clear}></i> : undefined;
97
+ }
98
+
99
+ return <div class="_fc-cascader">
100
+ <van-field ref="el" placeholder={this.placeholder} readonly disabled={this.$props.disabled}
101
+ onClick={this.open}
102
+ model-value={this.inputValue} border={false} isLink v-slots={{
103
+ 'right-icon': clearIcon
104
+ }}/>
105
+ <van-popup show={this.show} onUpdate:show={(v) => this.show = v} round position="bottom">
106
+ <van-cascader
107
+ {...this.$attrs}
108
+ modelValue={this.modelValue}
109
+ fieldNames={this.fieldNames}
110
+ options={this.options}
111
+ onClose={() => this.show = false}
112
+ onFinish={this.confirm}
113
+ />
114
+ </van-popup>
115
+ </div>
116
+ },
117
+ mounted() {
118
+ this.$emit('fc.el', this.$refs.el);
119
+ }
120
+ });
@@ -0,0 +1,38 @@
1
+ import {defineComponent, toRef} from 'vue';
2
+
3
+ const NAME = 'fcCheckbox';
4
+
5
+ export default defineComponent({
6
+ name: NAME,
7
+ inheritAttrs: false,
8
+ props: {
9
+ modelValue: Array,
10
+ options: Array,
11
+ },
12
+ emits: ['update:modelValue', 'change'],
13
+ setup(props, _) {
14
+ const modelValue = toRef(props, 'modelValue', []);
15
+ const options = toRef(props, 'options');
16
+
17
+ return {
18
+ options,
19
+ modelValue,
20
+ onInput(val) {
21
+ _.emit('update:modelValue', val);
22
+ _.emit('change', val);
23
+ },
24
+ }
25
+ },
26
+ render() {
27
+ return <van-checkbox-group direction="horizontal" {...this.$attrs} modelValue={Array.isArray(this.modelValue) ? this.modelValue : []}
28
+ onUpdate:modelValue={this.onInput}>
29
+ {(this.options || []).map(opt => {
30
+ const tmp = {...opt};
31
+ const {text, value} = opt;
32
+ delete tmp.text;
33
+ delete tmp.value;
34
+ return <van-checkbox name={value} shape="square" {...tmp}>{text || opt.label || value}</van-checkbox>
35
+ })}
36
+ </van-checkbox-group>
37
+ }
38
+ });
@@ -0,0 +1,87 @@
1
+ import {computed, defineComponent, ref, toRef} from 'vue';
2
+ import dayjs from 'dayjs';
3
+
4
+ const NAME = 'fcDatePicker';
5
+
6
+ export default defineComponent({
7
+ name: NAME,
8
+ inheritAttrs: false,
9
+ props: {
10
+ disabled: Boolean,
11
+ clearable: Boolean,
12
+ placeholder: String,
13
+ modelValue: [String, Number],
14
+ minDate: [String, Date],
15
+ maxDate: [String, Date],
16
+ },
17
+ emits: ['update:modelValue', 'fc.el', 'change'],
18
+ setup(props, _) {
19
+ const show = ref(false);
20
+ const modelValue = toRef(props, 'modelValue');
21
+
22
+ const formValue = computed(() => {
23
+ if (modelValue.value == null || modelValue.value === '') {
24
+ return [];
25
+ }
26
+ return modelValue.value.split('-');
27
+ });
28
+
29
+ const dateRange = computed(() => {
30
+ return {
31
+ minDate: props.minDate ? dayjs(props.minDate).toDate() : undefined,
32
+ maxDate: props.maxDate ? dayjs(props.maxDate).toDate() : undefined,
33
+ }
34
+ })
35
+
36
+ const onInput = (val) => {
37
+ _.emit('update:modelValue', val);
38
+ _.emit('change', val);
39
+ }
40
+
41
+ return {
42
+ show,
43
+ formValue,
44
+ dateRange,
45
+ open() {
46
+ if (props.disabled) {
47
+ return;
48
+ }
49
+ show.value = true;
50
+ },
51
+ confirm({selectedValues}) {
52
+ onInput(selectedValues.join('-'));
53
+ show.value = false;
54
+ },
55
+ clear(e) {
56
+ e.stopPropagation();
57
+ onInput('');
58
+ }
59
+ }
60
+ },
61
+ render() {
62
+ const clearIcon = () => {
63
+ return this.$props.clearable && this.modelValue ?
64
+ <i class="van-badge__wrapper van-icon van-icon-clear van-field__clear"
65
+ onClick={this.clear}></i> : undefined;
66
+ }
67
+ return <div class="_fc-date-picker">
68
+ <van-field ref="el" placeholder={this.placeholder} readonly disabled={this.$props.disabled}
69
+ onClick={this.open}
70
+ model-value={this.modelValue} border={false} isLink v-slots={{
71
+ 'right-icon': clearIcon
72
+ }}/>
73
+ <van-popup show={this.show} onUpdate:show={(v) => this.show = v} round position="bottom">
74
+ <van-date-picker
75
+ columnsType={['year', 'month', 'day']}
76
+ {...{...this.$attrs, ...this.dateRange}}
77
+ modelValue={this.formValue}
78
+ onConfirm={this.confirm}
79
+ onCancel={() => this.show = false}
80
+ />
81
+ </van-popup>
82
+ </div>
83
+ },
84
+ mounted() {
85
+ this.$emit('fc.el', this.$refs.el);
86
+ }
87
+ });
@@ -0,0 +1,384 @@
1
+ import {hasProperty} from '@form-create/utils/lib/type';
2
+ import {defineComponent, markRaw, nextTick, watch} from 'vue';
3
+ import deepExtend, {deepCopy} from '@form-create/utils/lib/deepextend';
4
+ import extend from '@form-create/utils/lib/extend';
5
+ import {toPromise} from '@form-create/utils';
6
+
7
+ const NAME = 'fcGroup';
8
+
9
+
10
+ export default defineComponent({
11
+ name: NAME,
12
+ props: {
13
+ field: String,
14
+ rule: Array,
15
+ expand: Number,
16
+ options: Object,
17
+ button: {
18
+ type: Boolean,
19
+ default: true
20
+ },
21
+ max: {
22
+ type: Number,
23
+ default: 0
24
+ },
25
+ min: {
26
+ type: Number,
27
+ default: 0
28
+ },
29
+ modelValue: {
30
+ type: Array,
31
+ default: () => []
32
+ },
33
+ defaultValue: Object,
34
+ sortBtn: {
35
+ type: Boolean,
36
+ default: false
37
+ },
38
+ disabled: {
39
+ type: Boolean,
40
+ default: undefined
41
+ },
42
+ title: {
43
+ type: [String, Function],
44
+ default: null
45
+ },
46
+ type: {
47
+ type: String,
48
+ default: 'default'
49
+ },
50
+ onBeforeRemove: {
51
+ type: Function,
52
+ default: () => {
53
+ }
54
+ },
55
+ onBeforeAdd: {
56
+ type: Function,
57
+ default: () => {
58
+ }
59
+ },
60
+ formCreateInject: Object,
61
+ parse: Function,
62
+ },
63
+ data() {
64
+ return {
65
+ len: 0,
66
+ cacheRule: {},
67
+ cacheValue: {},
68
+ sort: [],
69
+ form: markRaw(this.formCreateInject.form.$form())
70
+ }
71
+ },
72
+ emits: ['update:modelValue', 'change', 'itemMounted', 'remove', 'add'],
73
+ watch: {
74
+ rule: {
75
+ handler(n, o) {
76
+ Object.keys(this.cacheRule).forEach(v => {
77
+ const item = this.cacheRule[v];
78
+ if (item.$f) {
79
+ const val = item.$f.formData();
80
+ if (n === o) {
81
+ item.$f.deferSyncValue(() => {
82
+ deepExtend(item.rule, n);
83
+ item.$f.setValue(val);
84
+ }, true);
85
+ } else {
86
+ const val = item.$f.formData();
87
+ item.$f.once('reloading', () => {
88
+ item.$f.setValue(val);
89
+ })
90
+ item.rule = deepCopy(n);
91
+ }
92
+ }
93
+ })
94
+ },
95
+ deep: true
96
+ },
97
+ expand(n) {
98
+ let d = n - this.modelValue.length;
99
+ if (d > 0) {
100
+ this.expandRule(d);
101
+ }
102
+ },
103
+ modelValue: {
104
+ handler(n) {
105
+ n = n || [];
106
+ let keys = this.sort, total = keys.length, len = total - n.length;
107
+ if (len < 0) {
108
+ for (let i = len; i < 0; i++) {
109
+ this.addRule(n.length + i, true);
110
+ }
111
+ for (let i = 0; i < total; i++) {
112
+ this.setValue(keys[i], n[i]);
113
+ }
114
+ } else {
115
+ if (len > 0) {
116
+ for (let i = 0; i < len; i++) {
117
+ this.removeRule(keys[total - i - 1]);
118
+ }
119
+ }
120
+ n.forEach((val, i) => {
121
+ this.setValue(keys[i], n[i]);
122
+ });
123
+ }
124
+ },
125
+ deep: true,
126
+ }
127
+ },
128
+ methods: {
129
+ _value(v) {
130
+ return (v && hasProperty(v, this.field)) ? v[this.field] : v;
131
+ },
132
+ cache(k, val) {
133
+ this.cacheValue[k] = JSON.stringify(val);
134
+ },
135
+ input(value) {
136
+ this.$emit('update:modelValue', value);
137
+ this.$emit('change', value);
138
+ },
139
+ formData(key, formData) {
140
+ const cacheRule = this.cacheRule;
141
+ const keys = this.sort;
142
+ if (keys.filter(k => cacheRule[k] && cacheRule[k].$f).length !== keys.length) {
143
+ return;
144
+ }
145
+ const value = keys.map(k => {
146
+ const data = key === k ? formData : {...this.cacheRule[k].$f.form};
147
+ const value = this.field ? data[this.field] || null : data;
148
+ this.cache(k, value);
149
+ return value;
150
+ });
151
+ this.input(value);
152
+ },
153
+ setValue(key, value) {
154
+ const field = this.field
155
+ if (field) {
156
+ value = {[field]: this._value(value)};
157
+ }
158
+ if (this.cacheValue[key] === JSON.stringify(field ? value[field] : value)) {
159
+ return;
160
+ }
161
+ this.cacheRule[key].$f && this.cacheRule[key].$f.coverValue(value);
162
+ this.cache(key, value);
163
+ },
164
+ addRule(i, emit) {
165
+ const rule = this.formCreateInject.form.copyRules(this.rule || []);
166
+ const options = this.options ? {...this.options} : {
167
+ submitBtn: false,
168
+ resetBtn: false,
169
+ };
170
+ if (this.defaultValue) {
171
+ if (!options.formData) options.formData = {};
172
+ const defVal = deepCopy(this.defaultValue);
173
+ extend(options.formData, this.field ? {[this.field]: defVal} : defVal);
174
+ }
175
+ this.parse && this.parse({rule, options, index: this.sort.length});
176
+ this.cacheRule[++this.len] = {rule, options};
177
+ this.sort = Object.keys(this.cacheRule);
178
+ if (emit) {
179
+ nextTick(() => this.$emit('add', rule, Object.keys(this.cacheRule).length - 1));
180
+ }
181
+ },
182
+ add$f(i, key, $f) {
183
+ this.cacheRule[key].$f = $f;
184
+ nextTick(() => {
185
+ this.$emit('itemMounted', $f, Object.keys(this.cacheRule).indexOf(key));
186
+ });
187
+ },
188
+ removeRule(key, emit) {
189
+ const index = Object.keys(this.cacheRule).indexOf(key);
190
+ delete this.cacheRule[key];
191
+ delete this.cacheValue[key];
192
+ this.sort = Object.keys(this.cacheRule);
193
+ if (emit) {
194
+ nextTick(() => this.$emit('remove', index));
195
+ }
196
+ },
197
+ add(i) {
198
+ if (this.disabled || false === this.onBeforeAdd(this.modelValue)) {
199
+ return;
200
+ }
201
+ const value = [...this.modelValue];
202
+ value.push(this.defaultValue ? deepCopy(this.defaultValue) : (this.field ? null : {}));
203
+ this.input(value);
204
+ },
205
+ del(index, key) {
206
+ if (this.disabled) {
207
+ return;
208
+ }
209
+ const del = () => {
210
+ this.removeRule(key, true);
211
+ const value = [...this.modelValue];
212
+ value.splice(index, 1);
213
+ this.input(value);
214
+ }
215
+ toPromise(this.onBeforeRemove(this.modelValue, index)).then(res => {
216
+ if (false !== res) {
217
+ del();
218
+ }
219
+ })
220
+ },
221
+ addIcon(key) {
222
+ return <div class="_fc-m-group-btn _fc-m-group-plus-minus" onClick={this.add}></div>;
223
+ },
224
+ delIcon(index, key) {
225
+ return <div class="_fc-m-group-btn _fc-m-group-plus-minus _fc-m-group-minus"
226
+ onClick={() => this.del(index, key)}></div>
227
+ },
228
+ sortUpIcon(index) {
229
+ return <div class="_fc-m-group-btn _fc-m-group-arrow _fc-m-group-up"
230
+ onClick={() => this.changeSort(index, -1)}></div>
231
+ },
232
+ sortDownIcon(index) {
233
+ return <div class="_fc-m-group-btn _fc-m-group-arrow _fc-m-group-down"
234
+ onClick={() => this.changeSort(index, 1)}></div>
235
+ },
236
+ changeSort(index, sort) {
237
+ const a = this.sort[index];
238
+ this.sort[index] = this.sort[index + sort];
239
+ this.sort[index + sort] = a;
240
+ this.formCreateInject.subForm(this.sort.map(k=>{
241
+ return this.cacheRule[k].$f;
242
+ }));
243
+ this.formData(0);
244
+ },
245
+ sortIcon(index, total) {
246
+ const canMoveUp = index > 0;
247
+ const canMoveDown = index < total - 1;
248
+
249
+ if (!canMoveUp && !canMoveDown) {
250
+ return null;
251
+ }
252
+
253
+ if (canMoveUp && canMoveDown) {
254
+ // 显示合并的上下箭头按钮
255
+ return <div class="_fc-m-group-btn _fc-m-group-sort">
256
+ <div class="_fc-m-group-sort-up" onClick={() => this.changeSort(index, -1)}></div>
257
+ <div class="_fc-m-group-sort-down" onClick={() => this.changeSort(index, 1)}></div>
258
+ </div>;
259
+ }
260
+
261
+ if (canMoveUp) {
262
+ return this.sortUpIcon(index);
263
+ }
264
+
265
+ if (canMoveDown) {
266
+ return this.sortDownIcon(index);
267
+ }
268
+ },
269
+ makeIcon(total, index, key) {
270
+ if (this.$slots.button) {
271
+ return this.$slots.button({
272
+ total,
273
+ index,
274
+ vm: this,
275
+ key,
276
+ del: () => this.del(index, key),
277
+ add: this.add
278
+ });
279
+ }
280
+ const btn = [];
281
+ if ((!this.max || total < this.max) && total === index + 1) {
282
+ btn.push(this.addIcon(key));
283
+ }
284
+ if (total > this.min) {
285
+ btn.push(this.delIcon(index, key));
286
+ }
287
+ if (this.sortBtn) {
288
+ const sortBtn = this.sortIcon(index, total);
289
+ if (sortBtn) {
290
+ btn.push(sortBtn);
291
+ }
292
+ }
293
+ return btn;
294
+ },
295
+ expandRule(n) {
296
+ for (let i = 0; i < n; i++) {
297
+ this.modelValue.push(this.field ? null : {});
298
+ }
299
+ this.input([...this.modelValue]);
300
+ },
301
+ getTitle(index, key) {
302
+ if (typeof this.title === 'function') {
303
+ return this.title(index, this.modelValue[index], key);
304
+ }
305
+ if (typeof this.title === 'string') {
306
+ return this.title.replace('{index}', index + 1);
307
+ }
308
+ return false;
309
+ }
310
+ },
311
+ created() {
312
+ const d = (this.expand || 0) - this.modelValue.length;
313
+ for (let i = 0; i < this.modelValue.length; i++) {
314
+ this.addRule(i);
315
+ }
316
+ if (d > 0) {
317
+ this.expandRule(d);
318
+ }
319
+ },
320
+ render() {
321
+ const keys = this.sort;
322
+ const button = this.button;
323
+ const Type = this.form;
324
+ const disabled = this.disabled;
325
+ const isCardType = this.type === 'card';
326
+
327
+ const children = keys.length === 0 ?
328
+ (this.$slots.default ? (this.$slots.default({
329
+ vm: this,
330
+ add: this.add
331
+ })) : <div key={'a_def'} class="_fc-m-group-plus-minus _fc-m-group-add fc-clock"
332
+ onClick={this.add}/>) : keys.map((key, index) => {
333
+ const {rule, options} = this.cacheRule[key];
334
+ const btn = button && !disabled ? this.makeIcon(keys.length, index, key) : [];
335
+ const title = this.getTitle(index, key);
336
+
337
+ if (isCardType) {
338
+ return <div class="_fc-m-group-container" key={key}>
339
+ <div class="_fc-m-group-header">
340
+ {title === false ? <div class="_fc-m-group-idx">{index + 1}</div> : null}
341
+ {title !== false ? <div class="_fc-m-group-title">{title}</div> : null}
342
+ <div class="_fc-m-group-handle fc-clock">
343
+ {(btn.length) ? btn : null}
344
+ </div>
345
+ </div>
346
+ <div class="_fc-m-group-content">
347
+ <Type
348
+ key={key}
349
+ {...{
350
+ disabled,
351
+ 'onUpdate:modelValue': (formData) => this.formData(key, formData),
352
+ 'onUpdate:api': ($f) => this.add$f(index, key, $f),
353
+ inFor: true,
354
+ modelValue: this.field ? {[this.field]: this._value(this.modelValue[index])} : this.modelValue[index],
355
+ rule,
356
+ option: options,
357
+ extendOption: true
358
+ }}
359
+ />
360
+ </div>
361
+ </div>
362
+ } else {
363
+ return <div class="_fc-m-group-container" key={key}>
364
+ <Type
365
+ key={key}
366
+ {...{
367
+ disabled,
368
+ 'onUpdate:modelValue': (formData) => this.formData(key, formData),
369
+ 'onUpdate:api': ($f) => this.add$f(index, key, $f),
370
+ inFor: true,
371
+ modelValue: this.field ? {[this.field]: this._value(this.modelValue[index])} : this.modelValue[index],
372
+ rule,
373
+ option: options,
374
+ extendOption: true
375
+ }}
376
+ />
377
+ <div class="_fc-m-group-idx">{index + 1}</div>
378
+ {(btn.length) ? <div class="_fc-m-group-handle fc-clock">{btn}</div> : null}
379
+ </div>
380
+ }
381
+ });
382
+ return <div key={'con'} class={'_fc-m-group ' + (disabled ? '_fc-m-group-disabled' : '') + (isCardType ? ' _fc-m-group-card' : '')}>{children}</div>
383
+ }
384
+ });
@@ -0,0 +1,26 @@
1
+ import subForm from '@form-create/components/common/subform/src/index';
2
+ import Calendar from './calendar';
3
+ import Cascader from './cascader';
4
+ import Checkbox from './checkbox';
5
+ import Select from './select';
6
+ import Uploader from './uploader';
7
+ import Radio from './radio';
8
+ import DatePicker from './datePicker';
9
+ import TimePicker from './timePicker';
10
+ import Group from './group';
11
+ import IconWarning from './icon/IconWarning.vue';
12
+
13
+
14
+ export default [
15
+ subForm,
16
+ IconWarning,
17
+ Calendar,
18
+ Cascader,
19
+ Checkbox,
20
+ Radio,
21
+ Select,
22
+ DatePicker,
23
+ TimePicker,
24
+ Group,
25
+ Uploader,
26
+ ]
@@ -0,0 +1,38 @@
1
+ import {defineComponent, toRef} from 'vue';
2
+
3
+ const NAME = 'fcRadio';
4
+
5
+ export default defineComponent({
6
+ name: NAME,
7
+ inheritAttrs: false,
8
+ props: {
9
+ modelValue: [String, Number, Boolean],
10
+ options: Array,
11
+ },
12
+ emits: ['update:modelValue', 'change'],
13
+ setup(props, _) {
14
+ const modelValue = toRef(props, 'modelValue', []);
15
+ const options = toRef(props, 'options');
16
+
17
+ return {
18
+ options,
19
+ modelValue,
20
+ onInput(val) {
21
+ _.emit('update:modelValue', val);
22
+ _.emit('change', val);
23
+ },
24
+ }
25
+ },
26
+ render() {
27
+ return <van-radio-group direction="horizontal" {...this.$attrs} modelValue={this.modelValue}
28
+ onUpdate:modelValue={this.onInput}>
29
+ {(this.options || []).map(opt => {
30
+ const tmp = {...opt};
31
+ const {text, value} = opt;
32
+ delete tmp.text;
33
+ delete tmp.value;
34
+ return <van-radio name={value} {...tmp}>{text || opt.label || value}</van-radio>
35
+ })}
36
+ </van-radio-group>
37
+ }
38
+ });