@tmagic/form 1.4.6 → 1.4.8
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/dist/tmagic-form.js +64 -125
- package/dist/tmagic-form.umd.cjs +63 -124
- package/package.json +9 -5
- package/types/schema.d.ts +2 -2
- package/src/Form.vue +0 -201
- package/src/FormBox.vue +0 -120
- package/src/FormDialog.vue +0 -173
- package/src/FormDrawer.vue +0 -159
- package/src/containers/Col.vue +0 -52
- package/src/containers/Container.vue +0 -416
- package/src/containers/Fieldset.vue +0 -124
- package/src/containers/GroupList.vue +0 -139
- package/src/containers/GroupListItem.vue +0 -135
- package/src/containers/Panel.vue +0 -99
- package/src/containers/Row.vue +0 -54
- package/src/containers/Step.vue +0 -82
- package/src/containers/Table.vue +0 -648
- package/src/containers/Tabs.vue +0 -226
- package/src/fields/Cascader.vue +0 -127
- package/src/fields/Checkbox.vue +0 -58
- package/src/fields/CheckboxGroup.vue +0 -43
- package/src/fields/ColorPicker.vue +0 -30
- package/src/fields/Date.vue +0 -38
- package/src/fields/DateTime.vue +0 -47
- package/src/fields/Daterange.vue +0 -99
- package/src/fields/Display.vue +0 -21
- package/src/fields/DynamicField.vue +0 -90
- package/src/fields/Hidden.vue +0 -16
- package/src/fields/Link.vue +0 -86
- package/src/fields/Number.vue +0 -49
- package/src/fields/NumberRange.vue +0 -50
- package/src/fields/RadioGroup.vue +0 -28
- package/src/fields/Select.vue +0 -449
- package/src/fields/Switch.vue +0 -59
- package/src/fields/Text.vue +0 -170
- package/src/fields/Textarea.vue +0 -46
- package/src/fields/Time.vue +0 -34
- package/src/fields/Timerange.vue +0 -76
- package/src/index.ts +0 -139
- package/src/schema.ts +0 -757
- package/src/shims-vue.d.ts +0 -6
- package/src/theme/date-time.scss +0 -7
- package/src/theme/fieldset.scss +0 -28
- package/src/theme/form-box.scss +0 -13
- package/src/theme/form-dialog.scss +0 -13
- package/src/theme/form-drawer.scss +0 -11
- package/src/theme/form.scss +0 -43
- package/src/theme/group-list.scss +0 -23
- package/src/theme/index.scss +0 -14
- package/src/theme/link.scss +0 -3
- package/src/theme/number-range.scss +0 -8
- package/src/theme/panel.scss +0 -24
- package/src/theme/select.scss +0 -3
- package/src/theme/table.scss +0 -70
- package/src/theme/tabs.scss +0 -27
- package/src/theme/text.scss +0 -6
- package/src/utils/config.ts +0 -27
- package/src/utils/containerProps.ts +0 -50
- package/src/utils/form.ts +0 -268
- package/src/utils/useAddField.ts +0 -40
- package/tsconfig.build.json +0 -13
package/dist/tmagic-form.umd.cjs
CHANGED
|
@@ -152,8 +152,7 @@
|
|
|
152
152
|
});
|
|
153
153
|
};
|
|
154
154
|
const initValue = async (mForm, { initValues, config }) => {
|
|
155
|
-
if (!Array.isArray(config))
|
|
156
|
-
throw new Error("config应该为数组");
|
|
155
|
+
if (!Array.isArray(config)) throw new Error("config应该为数组");
|
|
157
156
|
let valuesTmp = createValues(mForm, config, vue.toRaw(initValues), {});
|
|
158
157
|
const [firstForm] = config;
|
|
159
158
|
if (firstForm && typeof firstForm.onInitValue === "function") {
|
|
@@ -207,8 +206,7 @@
|
|
|
207
206
|
const expand = vue.ref(false);
|
|
208
207
|
const name = vue.computed(() => props.config.name || "");
|
|
209
208
|
const showDiff = vue.computed(() => {
|
|
210
|
-
if (!props.isCompare)
|
|
211
|
-
return false;
|
|
209
|
+
if (!props.isCompare) return false;
|
|
212
210
|
const curValue = name.value ? props.model[name.value] : props.model;
|
|
213
211
|
const lastValue = name.value ? props.lastValues[name.value] : props.lastValues;
|
|
214
212
|
return !lodashEs.isEqual(curValue, lastValue);
|
|
@@ -226,12 +224,7 @@
|
|
|
226
224
|
}
|
|
227
225
|
return `${props.prop}${props.prop ? "." : ""}${n}`;
|
|
228
226
|
});
|
|
229
|
-
const tagName = vue.computed(() => {
|
|
230
|
-
const component = vue.resolveComponent(`m-${items.value ? "form" : "fields"}-${type.value}`);
|
|
231
|
-
if (typeof component !== "string")
|
|
232
|
-
return component;
|
|
233
|
-
return "m-fields-text";
|
|
234
|
-
});
|
|
227
|
+
const tagName = vue.computed(() => `m-${items.value ? "form" : "fields"}-${type.value}`);
|
|
235
228
|
const disabled = vue.computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
|
|
236
229
|
const text = vue.computed(() => filterFunction(mForm, props.config.text, props));
|
|
237
230
|
const tooltip = vue.computed(() => filterFunction(mForm, props.config.tooltip, props));
|
|
@@ -239,15 +232,9 @@
|
|
|
239
232
|
const rule = vue.computed(() => getRules(mForm, props.config.rules, props));
|
|
240
233
|
const type = vue.computed(() => {
|
|
241
234
|
let { type: type2 } = props.config;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
if (type2 === "form")
|
|
248
|
-
return "";
|
|
249
|
-
if (type2 === "container")
|
|
250
|
-
return "";
|
|
235
|
+
type2 = type2 && filterFunction(mForm, type2, props);
|
|
236
|
+
if (type2 === "form") return "";
|
|
237
|
+
if (type2 === "container") return "";
|
|
251
238
|
return type2?.replace(/([A-Z])/g, "-$1").toLowerCase() || (items.value ? "" : "text");
|
|
252
239
|
});
|
|
253
240
|
const display$1 = vue.computed(() => {
|
|
@@ -264,10 +251,8 @@
|
|
|
264
251
|
vue.watch(
|
|
265
252
|
showDiff,
|
|
266
253
|
(showDiff2) => {
|
|
267
|
-
if (type.value === "hidden")
|
|
268
|
-
|
|
269
|
-
if (items.value && !text.value && type.value && display$1.value)
|
|
270
|
-
return;
|
|
254
|
+
if (type.value === "hidden") return;
|
|
255
|
+
if (items.value && !text.value && type.value && display$1.value) return;
|
|
271
256
|
if (display$1.value && showDiff2 && type.value) {
|
|
272
257
|
emit("addDiffCount");
|
|
273
258
|
}
|
|
@@ -803,8 +788,7 @@
|
|
|
803
788
|
const changeOrder = (offset = 0) => emit("swap-item", props.index, props.index + offset);
|
|
804
789
|
const movable = () => {
|
|
805
790
|
const { movable: movable2 } = props.config;
|
|
806
|
-
if (movable2 === void 0)
|
|
807
|
-
return true;
|
|
791
|
+
if (movable2 === void 0) return true;
|
|
808
792
|
if (typeof movable2 === "function") {
|
|
809
793
|
return movable2(mForm, props.index || 0, props.model, props.groupModel);
|
|
810
794
|
}
|
|
@@ -935,8 +919,7 @@
|
|
|
935
919
|
const emit = __emit;
|
|
936
920
|
const mForm = vue.inject("mForm");
|
|
937
921
|
const addable = vue.computed(() => {
|
|
938
|
-
if (!props.name)
|
|
939
|
-
return false;
|
|
922
|
+
if (!props.name) return false;
|
|
940
923
|
if (typeof props.config.addable === "function") {
|
|
941
924
|
return props.config.addable(mForm, {
|
|
942
925
|
model: props.model[props.name],
|
|
@@ -948,13 +931,11 @@
|
|
|
948
931
|
return typeof props.config.addable === "undefined" ? true : props.config.addable;
|
|
949
932
|
});
|
|
950
933
|
const changeHandler = () => {
|
|
951
|
-
if (!props.name)
|
|
952
|
-
return false;
|
|
934
|
+
if (!props.name) return false;
|
|
953
935
|
emit("change", props.model[props.name]);
|
|
954
936
|
};
|
|
955
937
|
const addHandler = async () => {
|
|
956
|
-
if (!props.name)
|
|
957
|
-
return false;
|
|
938
|
+
if (!props.name) return false;
|
|
958
939
|
let initValues = {};
|
|
959
940
|
if (typeof props.config.defaultAdd === "function") {
|
|
960
941
|
initValues = await props.config.defaultAdd(mForm, {
|
|
@@ -973,14 +954,12 @@
|
|
|
973
954
|
props.model[props.name].push(groupValue);
|
|
974
955
|
};
|
|
975
956
|
const removeHandler = (index) => {
|
|
976
|
-
if (!props.name)
|
|
977
|
-
return false;
|
|
957
|
+
if (!props.name) return false;
|
|
978
958
|
props.model[props.name].splice(index, 1);
|
|
979
959
|
changeHandler();
|
|
980
960
|
};
|
|
981
961
|
const swapHandler = (idx1, idx2) => {
|
|
982
|
-
if (!props.name)
|
|
983
|
-
return false;
|
|
962
|
+
if (!props.name) return false;
|
|
984
963
|
const [currRow] = props.model[props.name].splice(idx1, 1);
|
|
985
964
|
props.model[props.name].splice(idx2, 0, currRow);
|
|
986
965
|
changeHandler();
|
|
@@ -1417,10 +1396,8 @@
|
|
|
1417
1396
|
if (tBodyEl) {
|
|
1418
1397
|
const sortable = Sortable.create(tBodyEl, {
|
|
1419
1398
|
onEnd: ({ newIndex, oldIndex }) => {
|
|
1420
|
-
if (typeof newIndex === "undefined")
|
|
1421
|
-
|
|
1422
|
-
if (typeof oldIndex === "undefined")
|
|
1423
|
-
return;
|
|
1399
|
+
if (typeof newIndex === "undefined") return;
|
|
1400
|
+
if (typeof oldIndex === "undefined") return;
|
|
1424
1401
|
swapArray(newIndex, oldIndex);
|
|
1425
1402
|
emit("change", props.model[modelName.value]);
|
|
1426
1403
|
foreUpdate();
|
|
@@ -1450,8 +1427,7 @@
|
|
|
1450
1427
|
formValue: mForm?.values,
|
|
1451
1428
|
prop: props.prop
|
|
1452
1429
|
});
|
|
1453
|
-
if (!beforeCheckRes)
|
|
1454
|
-
return;
|
|
1430
|
+
if (!beforeCheckRes) return;
|
|
1455
1431
|
}
|
|
1456
1432
|
const columns = props.config.items;
|
|
1457
1433
|
const enumValues = props.config.enum || [];
|
|
@@ -1556,8 +1532,7 @@
|
|
|
1556
1532
|
return fuc;
|
|
1557
1533
|
};
|
|
1558
1534
|
const removeHandler = (index) => {
|
|
1559
|
-
if (props.disabled)
|
|
1560
|
-
return;
|
|
1535
|
+
if (props.disabled) return;
|
|
1561
1536
|
props.model[modelName.value].splice(index, 1);
|
|
1562
1537
|
emit("change", props.model[modelName.value]);
|
|
1563
1538
|
};
|
|
@@ -1664,8 +1639,7 @@
|
|
|
1664
1639
|
};
|
|
1665
1640
|
const toggleMode = () => {
|
|
1666
1641
|
const calcLabelWidth = (label) => {
|
|
1667
|
-
if (!label)
|
|
1668
|
-
return "0px";
|
|
1642
|
+
if (!label) return "0px";
|
|
1669
1643
|
const zhLength = label.match(/[^\x00-\xff]/g)?.length || 0;
|
|
1670
1644
|
const chLength = label.length - zhLength;
|
|
1671
1645
|
return `${Math.max(chLength * 8 + zhLength * 20, 80)}px`;
|
|
@@ -1685,8 +1659,7 @@
|
|
|
1685
1659
|
});
|
|
1686
1660
|
};
|
|
1687
1661
|
const toggleFullscreen = () => {
|
|
1688
|
-
if (!mTable.value)
|
|
1689
|
-
return;
|
|
1662
|
+
if (!mTable.value) return;
|
|
1690
1663
|
if (isFullscreen.value) {
|
|
1691
1664
|
mTable.value.classList.remove("fixed");
|
|
1692
1665
|
isFullscreen.value = false;
|
|
@@ -2001,12 +1974,9 @@
|
|
|
2001
1974
|
const getActive = (mForm2, props2, activeTabName2) => {
|
|
2002
1975
|
const { config, model, prop } = props2;
|
|
2003
1976
|
const { active } = config;
|
|
2004
|
-
if (typeof active === "function")
|
|
2005
|
-
|
|
2006
|
-
if (
|
|
2007
|
-
return "0";
|
|
2008
|
-
if (typeof active !== "undefined")
|
|
2009
|
-
return active;
|
|
1977
|
+
if (typeof active === "function") return active(mForm2, { model, formValue: mForm2?.values, prop });
|
|
1978
|
+
if (+activeTabName2 >= props2.config.items.length) return "0";
|
|
1979
|
+
if (typeof active !== "undefined") return active;
|
|
2010
1980
|
return "0";
|
|
2011
1981
|
};
|
|
2012
1982
|
const tabClick = (mForm2, tab, props2) => {
|
|
@@ -2027,8 +1997,7 @@
|
|
|
2027
1997
|
const diffCount = vue.ref({});
|
|
2028
1998
|
const tabs = vue.computed(() => {
|
|
2029
1999
|
if (props.config.dynamic) {
|
|
2030
|
-
if (!props.config.name)
|
|
2031
|
-
throw new Error("dynamic tab 必须配置name");
|
|
2000
|
+
if (!props.config.name) throw new Error("dynamic tab 必须配置name");
|
|
2032
2001
|
return props.model[props.config.name] || [];
|
|
2033
2002
|
}
|
|
2034
2003
|
return props.config.items.filter((item) => display(mForm, item.display, props));
|
|
@@ -2045,8 +2014,7 @@
|
|
|
2045
2014
|
const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
|
|
2046
2015
|
const tabClickHandler = (tab) => tabClick(mForm, tab, props);
|
|
2047
2016
|
const onTabAdd = () => {
|
|
2048
|
-
if (!props.config.name)
|
|
2049
|
-
throw new Error("dynamic tab 必须配置name");
|
|
2017
|
+
if (!props.config.name) throw new Error("dynamic tab 必须配置name");
|
|
2050
2018
|
if (typeof props.config.onTabAdd === "function") {
|
|
2051
2019
|
props.config.onTabAdd(mForm, {
|
|
2052
2020
|
model: props.model,
|
|
@@ -2062,8 +2030,7 @@
|
|
|
2062
2030
|
mForm?.$emit("field-change", props.prop, props.model[props.config.name]);
|
|
2063
2031
|
};
|
|
2064
2032
|
const onTabRemove = (tabName) => {
|
|
2065
|
-
if (!props.config.name)
|
|
2066
|
-
throw new Error("dynamic tab 必须配置name");
|
|
2033
|
+
if (!props.config.name) throw new Error("dynamic tab 必须配置name");
|
|
2067
2034
|
if (typeof props.config.onTabRemove === "function") {
|
|
2068
2035
|
props.config.onTabRemove(mForm, tabName, {
|
|
2069
2036
|
model: props.model,
|
|
@@ -2166,8 +2133,7 @@
|
|
|
2166
2133
|
const getConfig = (key) => $MAGIC_FORM[key];
|
|
2167
2134
|
|
|
2168
2135
|
const useAddField = (prop) => {
|
|
2169
|
-
if (!prop)
|
|
2170
|
-
return;
|
|
2136
|
+
if (!prop) return;
|
|
2171
2137
|
const mForm = vue.inject("mForm");
|
|
2172
2138
|
const instance = vue.getCurrentInstance();
|
|
2173
2139
|
vue.watch(
|
|
@@ -2211,17 +2177,19 @@
|
|
|
2211
2177
|
const tMagicCascader = vue.ref();
|
|
2212
2178
|
const options = vue.ref([]);
|
|
2213
2179
|
const remoteData = vue.ref(null);
|
|
2180
|
+
const checkStrictly = vue.computed(() => filterFunction(mForm, props.config.checkStrictly, props));
|
|
2181
|
+
const valueSeparator = vue.computed(() => filterFunction(mForm, props.config.valueSeparator, props));
|
|
2214
2182
|
const value = vue.computed({
|
|
2215
2183
|
get() {
|
|
2216
|
-
if (typeof props.model[props.name] === "string" &&
|
|
2217
|
-
return props.model[props.name].split(
|
|
2184
|
+
if (typeof props.model[props.name] === "string" && valueSeparator.value) {
|
|
2185
|
+
return props.model[props.name].split(valueSeparator.value);
|
|
2218
2186
|
}
|
|
2219
2187
|
return props.model[props.name];
|
|
2220
2188
|
},
|
|
2221
2189
|
set(value2) {
|
|
2222
2190
|
let result = value2;
|
|
2223
|
-
if (
|
|
2224
|
-
result = value2.join(
|
|
2191
|
+
if (valueSeparator.value) {
|
|
2192
|
+
result = value2.join(valueSeparator.value);
|
|
2225
2193
|
}
|
|
2226
2194
|
props.model[props.name] = result;
|
|
2227
2195
|
}
|
|
@@ -2229,8 +2197,7 @@
|
|
|
2229
2197
|
const setRemoteOptions = async function() {
|
|
2230
2198
|
const { config } = props;
|
|
2231
2199
|
const { option } = config;
|
|
2232
|
-
if (!option)
|
|
2233
|
-
return;
|
|
2200
|
+
if (!option) return;
|
|
2234
2201
|
let { body } = option;
|
|
2235
2202
|
const postOptions = {
|
|
2236
2203
|
url: option.url,
|
|
@@ -2275,8 +2242,7 @@
|
|
|
2275
2242
|
});
|
|
2276
2243
|
}
|
|
2277
2244
|
const changeHandler = () => {
|
|
2278
|
-
if (!tMagicCascader.value)
|
|
2279
|
-
return;
|
|
2245
|
+
if (!tMagicCascader.value) return;
|
|
2280
2246
|
tMagicCascader.value.setQuery("");
|
|
2281
2247
|
tMagicCascader.value.setPreviousQuery(null);
|
|
2282
2248
|
emit("change", props.model[props.name]);
|
|
@@ -2298,7 +2264,7 @@
|
|
|
2298
2264
|
props: {
|
|
2299
2265
|
multiple: _ctx.config.multiple ?? false,
|
|
2300
2266
|
emitPath: _ctx.config.emitPath ?? true,
|
|
2301
|
-
checkStrictly:
|
|
2267
|
+
checkStrictly: checkStrictly.value ?? false
|
|
2302
2268
|
},
|
|
2303
2269
|
onChange: changeHandler
|
|
2304
2270
|
}, null, 8, ["modelValue", "size", "placeholder", "disabled", "options", "popper-class", "props"]);
|
|
@@ -2398,10 +2364,8 @@
|
|
|
2398
2364
|
};
|
|
2399
2365
|
const mForm = vue.inject("mForm");
|
|
2400
2366
|
const options = vue.computed(() => {
|
|
2401
|
-
if (Array.isArray(props.config.options))
|
|
2402
|
-
|
|
2403
|
-
if (typeof props.config.options === "function")
|
|
2404
|
-
return filterFunction(mForm, props.config.options, props);
|
|
2367
|
+
if (Array.isArray(props.config.options)) return props.config.options;
|
|
2368
|
+
if (typeof props.config.options === "function") return filterFunction(mForm, props.config.options, props);
|
|
2405
2369
|
return [];
|
|
2406
2370
|
});
|
|
2407
2371
|
return (_ctx, _cache) => {
|
|
@@ -2539,12 +2503,9 @@
|
|
|
2539
2503
|
if (!value.value) {
|
|
2540
2504
|
value.value = [];
|
|
2541
2505
|
}
|
|
2542
|
-
if (!start || !end)
|
|
2543
|
-
|
|
2544
|
-
if (
|
|
2545
|
-
value.value[0] = new Date(start);
|
|
2546
|
-
if (end !== preEnd)
|
|
2547
|
-
value.value[1] = new Date(end);
|
|
2506
|
+
if (!start || !end) value.value = [];
|
|
2507
|
+
if (start !== preStart) value.value[0] = new Date(start);
|
|
2508
|
+
if (end !== preEnd) value.value[1] = new Date(end);
|
|
2548
2509
|
},
|
|
2549
2510
|
{
|
|
2550
2511
|
immediate: true
|
|
@@ -2554,8 +2515,7 @@
|
|
|
2554
2515
|
vue.watch(
|
|
2555
2516
|
() => props.model[props.name],
|
|
2556
2517
|
(start, preStart) => {
|
|
2557
|
-
if (start !== preStart)
|
|
2558
|
-
value.value = start.map((item) => item ? new Date(item) : void 0);
|
|
2518
|
+
if (start !== preStart) value.value = start.map((item) => item ? new Date(item) : void 0);
|
|
2559
2519
|
},
|
|
2560
2520
|
{
|
|
2561
2521
|
immediate: true
|
|
@@ -2581,8 +2541,7 @@
|
|
|
2581
2541
|
emit(
|
|
2582
2542
|
"change",
|
|
2583
2543
|
value2.map((item) => {
|
|
2584
|
-
if (item)
|
|
2585
|
-
return utils.datetimeFormatter(item, "");
|
|
2544
|
+
if (item) return utils.datetimeFormatter(item, "");
|
|
2586
2545
|
return void 0;
|
|
2587
2546
|
})
|
|
2588
2547
|
);
|
|
@@ -2720,14 +2679,12 @@
|
|
|
2720
2679
|
value: {}
|
|
2721
2680
|
});
|
|
2722
2681
|
const changeFieldMap = async () => {
|
|
2723
|
-
if (typeof props.config.returnFields !== "function" || !props.model)
|
|
2724
|
-
return;
|
|
2682
|
+
if (typeof props.config.returnFields !== "function" || !props.model) return;
|
|
2725
2683
|
const fields = await props.config.returnFields(props.config, props.model, request);
|
|
2726
2684
|
fieldMap.value = {};
|
|
2727
2685
|
fieldLabelMap.value = {};
|
|
2728
2686
|
fields.forEach((v) => {
|
|
2729
|
-
if (typeof v !== "object" || v.name === void 0)
|
|
2730
|
-
return;
|
|
2687
|
+
if (typeof v !== "object" || v.name === void 0) return;
|
|
2731
2688
|
let oldVal = props.model?.[v.name] || "";
|
|
2732
2689
|
if (!oldVal && v.defaultValue !== void 0) {
|
|
2733
2690
|
oldVal = v.defaultValue;
|
|
@@ -2931,12 +2888,9 @@
|
|
|
2931
2888
|
const error = [];
|
|
2932
2889
|
Object.entries(invalidFields).forEach(([, ValidateError]) => {
|
|
2933
2890
|
ValidateError.forEach(({ field, message }) => {
|
|
2934
|
-
if (field && message)
|
|
2935
|
-
|
|
2936
|
-
if (field &&
|
|
2937
|
-
error.push(`${field} -> 出现错误`);
|
|
2938
|
-
if (!field && message)
|
|
2939
|
-
error.push(`${message}`);
|
|
2891
|
+
if (field && message) error.push(`${field} -> ${message}`);
|
|
2892
|
+
if (field && !message) error.push(`${field} -> 出现错误`);
|
|
2893
|
+
if (!field && message) error.push(`${message}`);
|
|
2940
2894
|
});
|
|
2941
2895
|
});
|
|
2942
2896
|
throw new Error(error.join("<br>"));
|
|
@@ -3459,8 +3413,7 @@
|
|
|
3459
3413
|
const emit = __emit;
|
|
3460
3414
|
const optionComponent = design.getConfig("components")?.option;
|
|
3461
3415
|
const optionGroupComponent = design.getConfig("components")?.optionGroup;
|
|
3462
|
-
if (!props.model)
|
|
3463
|
-
throw new Error("不能没有model");
|
|
3416
|
+
if (!props.model) throw new Error("不能没有model");
|
|
3464
3417
|
useAddField(props.prop);
|
|
3465
3418
|
const tMagicSelect = vue.ref();
|
|
3466
3419
|
const mForm = vue.inject("mForm");
|
|
@@ -3495,16 +3448,14 @@
|
|
|
3495
3448
|
}));
|
|
3496
3449
|
};
|
|
3497
3450
|
const getOptions = async () => {
|
|
3498
|
-
if (!props.model)
|
|
3499
|
-
return [];
|
|
3451
|
+
if (!props.model) return [];
|
|
3500
3452
|
if (localOptions.value.length) {
|
|
3501
3453
|
return localOptions.value;
|
|
3502
3454
|
}
|
|
3503
3455
|
loading.value = true;
|
|
3504
3456
|
let items = [];
|
|
3505
3457
|
const { option } = props.config;
|
|
3506
|
-
if (!option)
|
|
3507
|
-
return [];
|
|
3458
|
+
if (!option) return [];
|
|
3508
3459
|
const { root = "", totalKey = "total" } = option;
|
|
3509
3460
|
let { body = {}, url } = option;
|
|
3510
3461
|
if (typeof url === "function") {
|
|
@@ -3577,8 +3528,7 @@
|
|
|
3577
3528
|
return pgIndex.value === 0 ? selectedOptions.concat(items) : options.value.concat(items);
|
|
3578
3529
|
};
|
|
3579
3530
|
const getInitLocalOption = async () => {
|
|
3580
|
-
if (!props.model)
|
|
3581
|
-
return [];
|
|
3531
|
+
if (!props.model) return [];
|
|
3582
3532
|
const value = props.model[props.name];
|
|
3583
3533
|
const { config } = props;
|
|
3584
3534
|
localOptions.value = await getOptions();
|
|
@@ -3599,11 +3549,9 @@
|
|
|
3599
3549
|
return localOptions.value.filter((item) => equalValue(item.value, value));
|
|
3600
3550
|
};
|
|
3601
3551
|
const getInitOption = async () => {
|
|
3602
|
-
if (!props.model)
|
|
3603
|
-
return [];
|
|
3552
|
+
if (!props.model) return [];
|
|
3604
3553
|
const { option } = props.config;
|
|
3605
|
-
if (!option)
|
|
3606
|
-
return [];
|
|
3554
|
+
if (!option) return [];
|
|
3607
3555
|
const { root = "", initRoot = "" } = option;
|
|
3608
3556
|
let { initBody = {} } = option;
|
|
3609
3557
|
let options2 = [];
|
|
@@ -3686,8 +3634,7 @@
|
|
|
3686
3634
|
});
|
|
3687
3635
|
} else if (props.config.option) {
|
|
3688
3636
|
vue.onBeforeMount(() => {
|
|
3689
|
-
if (!props.model)
|
|
3690
|
-
return;
|
|
3637
|
+
if (!props.model) return;
|
|
3691
3638
|
const v = props.model[props.name];
|
|
3692
3639
|
if (Array.isArray(v) ? v.length : typeof v !== "undefined") {
|
|
3693
3640
|
getInitOption().then((data) => {
|
|
@@ -3731,10 +3678,8 @@
|
|
|
3731
3678
|
emit("change", value);
|
|
3732
3679
|
};
|
|
3733
3680
|
const visibleHandler = async (visible) => {
|
|
3734
|
-
if (!visible)
|
|
3735
|
-
|
|
3736
|
-
if (!props.config.remote)
|
|
3737
|
-
return;
|
|
3681
|
+
if (!visible) return;
|
|
3682
|
+
if (!props.config.remote) return;
|
|
3738
3683
|
if (query.value && tMagicSelect.value) {
|
|
3739
3684
|
tMagicSelect.value.setQuery(query.value);
|
|
3740
3685
|
tMagicSelect.value.setPreviousQuery(query.value);
|
|
@@ -3961,8 +3906,7 @@
|
|
|
3961
3906
|
mForm?.$emit("field-input", props.prop, v);
|
|
3962
3907
|
};
|
|
3963
3908
|
const buttonClickHandler = () => {
|
|
3964
|
-
if (!appendConfig.value)
|
|
3965
|
-
return;
|
|
3909
|
+
if (!appendConfig.value) return;
|
|
3966
3910
|
if (typeof appendConfig.value.handler === "function") {
|
|
3967
3911
|
appendConfig.value.handler(mForm, {
|
|
3968
3912
|
model: props.model,
|
|
@@ -3971,10 +3915,8 @@
|
|
|
3971
3915
|
}
|
|
3972
3916
|
};
|
|
3973
3917
|
const keyUpHandler = ($event) => {
|
|
3974
|
-
if (!props.model)
|
|
3975
|
-
|
|
3976
|
-
if (!props.name)
|
|
3977
|
-
return;
|
|
3918
|
+
if (!props.model) return;
|
|
3919
|
+
if (!props.name) return;
|
|
3978
3920
|
const arrowUp = $event.key === "ArrowUp";
|
|
3979
3921
|
const arrowDown = $event.key === "ArrowDown";
|
|
3980
3922
|
if (!arrowUp && !arrowDown) {
|
|
@@ -4204,12 +4146,9 @@
|
|
|
4204
4146
|
if (!value.value) {
|
|
4205
4147
|
value.value = [];
|
|
4206
4148
|
}
|
|
4207
|
-
if (!start || !end)
|
|
4208
|
-
|
|
4209
|
-
if (
|
|
4210
|
-
value.value[0] = start;
|
|
4211
|
-
if (end !== preEnd)
|
|
4212
|
-
value.value[1] = end;
|
|
4149
|
+
if (!start || !end) value.value = [];
|
|
4150
|
+
if (start !== preStart) value.value[0] = start;
|
|
4151
|
+
if (end !== preEnd) value.value[1] = end;
|
|
4213
4152
|
},
|
|
4214
4153
|
{
|
|
4215
4154
|
immediate: true
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.4.
|
|
2
|
+
"version": "1.4.8",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
},
|
|
23
23
|
"./*": "./*"
|
|
24
24
|
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"types"
|
|
28
|
+
],
|
|
25
29
|
"license": "Apache-2.0",
|
|
26
30
|
"engines": {
|
|
27
31
|
"node": ">=18"
|
|
@@ -44,14 +48,14 @@
|
|
|
44
48
|
"@vue/test-utils": "^2.4.6",
|
|
45
49
|
"rimraf": "^3.0.2",
|
|
46
50
|
"sass": "^1.77.0",
|
|
47
|
-
"vite": "^5.
|
|
48
|
-
"vue-tsc": "^2.0.
|
|
51
|
+
"vite": "^5.3.1",
|
|
52
|
+
"vue-tsc": "^2.0.19"
|
|
49
53
|
},
|
|
50
54
|
"peerDependencies": {
|
|
51
55
|
"vue": "^3.4.27",
|
|
52
56
|
"typescript": "*",
|
|
53
|
-
"@tmagic/design": "1.4.
|
|
54
|
-
"@tmagic/utils": "1.4.
|
|
57
|
+
"@tmagic/design": "1.4.8",
|
|
58
|
+
"@tmagic/utils": "1.4.8"
|
|
55
59
|
},
|
|
56
60
|
"peerDependenciesMeta": {
|
|
57
61
|
"typescript": {
|
package/types/schema.d.ts
CHANGED
|
@@ -436,11 +436,11 @@ export interface CascaderConfig extends FormItem, Input {
|
|
|
436
436
|
/** 是否多选,默认 false */
|
|
437
437
|
multiple?: boolean;
|
|
438
438
|
/** 是否严格的遵守父子节点不互相关联,默认 false */
|
|
439
|
-
checkStrictly?: boolean
|
|
439
|
+
checkStrictly?: boolean | FilterFunction<boolean>;
|
|
440
440
|
/** 弹出内容的自定义类名 */
|
|
441
441
|
popperClass?: string;
|
|
442
442
|
/** 合并成字符串时的分隔符 */
|
|
443
|
-
valueSeparator?: string
|
|
443
|
+
valueSeparator?: string | FilterFunction<string>;
|
|
444
444
|
options?: ((mForm: FormState | undefined, data: {
|
|
445
445
|
model: Record<any, any>;
|
|
446
446
|
prop: string;
|