@tmagic/form 1.0.0-rc.7 → 1.0.0
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.es.js +72 -60
- package/dist/tmagic-form.es.js.map +1 -1
- package/dist/tmagic-form.umd.js +72 -60
- package/dist/tmagic-form.umd.js.map +1 -1
- package/dist/types/src/schema.d.ts +10 -0
- package/package.json +2 -2
- package/src/containers/Container.vue +2 -0
- package/src/containers/Table.vue +1 -1
- package/src/containers/Tabs.vue +13 -5
- package/src/fields/DateTime.vue +12 -13
- package/src/fields/Daterange.vue +12 -13
- package/src/fields/Select.vue +3 -0
- package/src/schema.ts +10 -0
- package/src/utils/form.ts +2 -0
package/dist/tmagic-form.es.js
CHANGED
|
@@ -114,7 +114,8 @@ const filterFunction = (mForm, config, props) => {
|
|
|
114
114
|
model: props.model,
|
|
115
115
|
parent: mForm?.parentValues || {},
|
|
116
116
|
formValue: mForm?.values || props.model,
|
|
117
|
-
prop: props.prop
|
|
117
|
+
prop: props.prop,
|
|
118
|
+
config: props.config
|
|
118
119
|
});
|
|
119
120
|
};
|
|
120
121
|
const display = function(mForm, config, props) {
|
|
@@ -145,7 +146,8 @@ const getRules = function(mForm, rules = [], props) {
|
|
|
145
146
|
model: props.model,
|
|
146
147
|
parent: mForm?.parentValues || {},
|
|
147
148
|
formValue: mForm?.values || props.model,
|
|
148
|
-
prop: props.prop
|
|
149
|
+
prop: props.prop,
|
|
150
|
+
config: props.config
|
|
149
151
|
}, mForm);
|
|
150
152
|
}
|
|
151
153
|
return item;
|
|
@@ -256,7 +258,8 @@ const _sfc_main$t = defineComponent({
|
|
|
256
258
|
model: props.model,
|
|
257
259
|
values: mForm?.initValues,
|
|
258
260
|
formValue: mForm?.values,
|
|
259
|
-
prop: itemProp.value
|
|
261
|
+
prop: itemProp.value,
|
|
262
|
+
config: props.config
|
|
260
263
|
});
|
|
261
264
|
}
|
|
262
265
|
if (filter === "number") {
|
|
@@ -270,7 +273,8 @@ const _sfc_main$t = defineComponent({
|
|
|
270
273
|
model: props.model,
|
|
271
274
|
values: mForm?.initValues,
|
|
272
275
|
formValue: mForm?.values,
|
|
273
|
-
prop: itemProp.value
|
|
276
|
+
prop: itemProp.value,
|
|
277
|
+
config: props.config
|
|
274
278
|
});
|
|
275
279
|
}
|
|
276
280
|
};
|
|
@@ -316,7 +320,7 @@ const _sfc_main$t = defineComponent({
|
|
|
316
320
|
};
|
|
317
321
|
}
|
|
318
322
|
});
|
|
319
|
-
const _hoisted_1$
|
|
323
|
+
const _hoisted_1$e = ["innerHTML"];
|
|
320
324
|
const _hoisted_2$7 = ["innerHTML"];
|
|
321
325
|
const _hoisted_3$7 = ["innerHTML"];
|
|
322
326
|
const _hoisted_4$6 = ["innerHTML"];
|
|
@@ -366,7 +370,7 @@ function _sfc_render$q(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
366
370
|
label: withCtx(() => [
|
|
367
371
|
createElementVNode("span", {
|
|
368
372
|
innerHTML: _ctx.type === "checkbox" ? "" : _ctx.config.text
|
|
369
|
-
}, null, 8, _hoisted_1$
|
|
373
|
+
}, null, 8, _hoisted_1$e)
|
|
370
374
|
]),
|
|
371
375
|
default: withCtx(() => [
|
|
372
376
|
_ctx.tooltip ? (openBlock(), createBlock(_component_el_tooltip, { key: 0 }, {
|
|
@@ -505,7 +509,7 @@ const _sfc_main$s = defineComponent({
|
|
|
505
509
|
};
|
|
506
510
|
}
|
|
507
511
|
});
|
|
508
|
-
const _hoisted_1$
|
|
512
|
+
const _hoisted_1$d = ["innerHTML"];
|
|
509
513
|
const _hoisted_2$6 = ["innerHTML"];
|
|
510
514
|
const _hoisted_3$6 = { key: 1 };
|
|
511
515
|
const _hoisted_4$5 = ["innerHTML"];
|
|
@@ -539,7 +543,7 @@ function _sfc_render$p(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
539
543
|
default: withCtx(() => [
|
|
540
544
|
createElementVNode("span", {
|
|
541
545
|
innerHTML: _ctx.config.legend
|
|
542
|
-
}, null, 8, _hoisted_1$
|
|
546
|
+
}, null, 8, _hoisted_1$d),
|
|
543
547
|
_ctx.config.extra ? (openBlock(), createElementBlock("span", {
|
|
544
548
|
key: 0,
|
|
545
549
|
innerHTML: _ctx.config.extra,
|
|
@@ -697,7 +701,7 @@ const _sfc_main$r = defineComponent({
|
|
|
697
701
|
};
|
|
698
702
|
}
|
|
699
703
|
});
|
|
700
|
-
const _hoisted_1$
|
|
704
|
+
const _hoisted_1$c = { class: "m-fields-group-list-item" };
|
|
701
705
|
const _hoisted_2$5 = /* @__PURE__ */ createTextVNode("\u4E0A\u79FB");
|
|
702
706
|
const _hoisted_3$5 = /* @__PURE__ */ createTextVNode("\u4E0B\u79FB");
|
|
703
707
|
const _hoisted_4$4 = ["innerHTML"];
|
|
@@ -709,7 +713,7 @@ function _sfc_render$o(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
709
713
|
const _component_CaretRight = resolveComponent("CaretRight");
|
|
710
714
|
const _component_CaretBottom = resolveComponent("CaretBottom");
|
|
711
715
|
const _component_m_form_container = resolveComponent("m-form-container");
|
|
712
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
716
|
+
return openBlock(), createElementBlock("div", _hoisted_1$c, [
|
|
713
717
|
createElementVNode("div", null, [
|
|
714
718
|
createVNode(_component_el_icon, {
|
|
715
719
|
style: { "margin-right": "7px" },
|
|
@@ -886,7 +890,7 @@ const _sfc_main$q = defineComponent({
|
|
|
886
890
|
};
|
|
887
891
|
}
|
|
888
892
|
});
|
|
889
|
-
const _hoisted_1$
|
|
893
|
+
const _hoisted_1$b = { class: "m-fields-group-list" };
|
|
890
894
|
const _hoisted_2$4 = ["innerHTML"];
|
|
891
895
|
const _hoisted_3$4 = {
|
|
892
896
|
key: 1,
|
|
@@ -901,7 +905,7 @@ const _hoisted_7$1 = /* @__PURE__ */ createTextVNode("\u5207\u6362\u4E3A\u8868\u
|
|
|
901
905
|
function _sfc_render$n(_ctx, _cache, $props, $setup, $data, $options) {
|
|
902
906
|
const _component_m_fields_group_list_item = resolveComponent("m-fields-group-list-item");
|
|
903
907
|
const _component_el_button = resolveComponent("el-button");
|
|
904
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
908
|
+
return openBlock(), createElementBlock("div", _hoisted_1$b, [
|
|
905
909
|
_ctx.config.extra ? (openBlock(), createElementBlock("div", {
|
|
906
910
|
key: 0,
|
|
907
911
|
innerHTML: _ctx.config.extra,
|
|
@@ -980,7 +984,7 @@ const _sfc_main$p = defineComponent({
|
|
|
980
984
|
};
|
|
981
985
|
}
|
|
982
986
|
});
|
|
983
|
-
const _hoisted_1$
|
|
987
|
+
const _hoisted_1$a = { class: "clearfix" };
|
|
984
988
|
const _hoisted_2$3 = ["innerHTML"];
|
|
985
989
|
const _hoisted_3$3 = {
|
|
986
990
|
key: 0,
|
|
@@ -1000,7 +1004,7 @@ function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1000
1004
|
"body-style": { display: _ctx.expand ? "block" : "none" }
|
|
1001
1005
|
}, {
|
|
1002
1006
|
header: withCtx(() => [
|
|
1003
|
-
createElementVNode("div", _hoisted_1$
|
|
1007
|
+
createElementVNode("div", _hoisted_1$a, [
|
|
1004
1008
|
createElementVNode("a", {
|
|
1005
1009
|
href: "javascript:",
|
|
1006
1010
|
style: { "width": "100%", "display": "block" },
|
|
@@ -1486,7 +1490,7 @@ const _sfc_main$l = defineComponent({
|
|
|
1486
1490
|
}
|
|
1487
1491
|
emit("select", selection, row);
|
|
1488
1492
|
if (typeof props.config.onSelect === "function") {
|
|
1489
|
-
props.config.onSelect(mForm, { selection, row });
|
|
1493
|
+
props.config.onSelect(mForm, { selection, row, config: props.config });
|
|
1490
1494
|
}
|
|
1491
1495
|
},
|
|
1492
1496
|
toggleRowSelection(row, selected) {
|
|
@@ -1612,7 +1616,7 @@ const _sfc_main$l = defineComponent({
|
|
|
1612
1616
|
};
|
|
1613
1617
|
}
|
|
1614
1618
|
});
|
|
1615
|
-
const _hoisted_1$
|
|
1619
|
+
const _hoisted_1$9 = ["innerHTML"];
|
|
1616
1620
|
const _hoisted_2$2 = { class: "el-form-item__content" };
|
|
1617
1621
|
const _hoisted_3$2 = ["innerHTML"];
|
|
1618
1622
|
const _hoisted_4$1 = /* @__PURE__ */ createTextVNode("\u6DFB\u52A0");
|
|
@@ -1641,7 +1645,7 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1641
1645
|
key: 0,
|
|
1642
1646
|
style: { "color": "rgba(0, 0, 0, 0.45)" },
|
|
1643
1647
|
innerHTML: _ctx.config.extra
|
|
1644
|
-
}, null, 8, _hoisted_1$
|
|
1648
|
+
}, null, 8, _hoisted_1$9)) : createCommentVNode("", true),
|
|
1645
1649
|
createElementVNode("div", _hoisted_2$2, [
|
|
1646
1650
|
createVNode(_component_el_tooltip, {
|
|
1647
1651
|
content: "\u62D6\u62FD\u53EF\u6392\u5E8F",
|
|
@@ -1891,11 +1895,11 @@ const tabClickHandler = (mForm, tab, props) => {
|
|
|
1891
1895
|
const { config, model, prop } = props;
|
|
1892
1896
|
tab.name = tab.paneName;
|
|
1893
1897
|
if (typeof config.onTabClick === "function") {
|
|
1894
|
-
config.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop });
|
|
1898
|
+
config.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop, config });
|
|
1895
1899
|
}
|
|
1896
1900
|
const tabConfig = config.items.find((item) => tab.name === item.status);
|
|
1897
1901
|
if (tabConfig && typeof tabConfig.onTabClick === "function") {
|
|
1898
|
-
tabConfig.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop });
|
|
1902
|
+
tabConfig.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop, config });
|
|
1899
1903
|
}
|
|
1900
1904
|
};
|
|
1901
1905
|
const Tab = defineComponent({
|
|
@@ -1950,7 +1954,11 @@ const Tab = defineComponent({
|
|
|
1950
1954
|
if (!props.config.name)
|
|
1951
1955
|
throw new Error("dynamic tab \u5FC5\u987B\u914D\u7F6Ename");
|
|
1952
1956
|
if (typeof props.config.onTabAdd === "function") {
|
|
1953
|
-
props.config.onTabAdd(mForm, {
|
|
1957
|
+
props.config.onTabAdd(mForm, {
|
|
1958
|
+
model: props.model,
|
|
1959
|
+
prop: props.prop,
|
|
1960
|
+
config: props.config
|
|
1961
|
+
});
|
|
1954
1962
|
} else if (tabs.value.length > 0) {
|
|
1955
1963
|
const newObj = cloneDeep(tabs.value[0]);
|
|
1956
1964
|
newObj.title = `\u6807\u7B7E${tabs.value.length + 1}`;
|
|
@@ -1963,7 +1971,11 @@ const Tab = defineComponent({
|
|
|
1963
1971
|
if (!props.config.name)
|
|
1964
1972
|
throw new Error("dynamic tab \u5FC5\u987B\u914D\u7F6Ename");
|
|
1965
1973
|
if (typeof props.config.onTabRemove === "function") {
|
|
1966
|
-
props.config.onTabRemove(mForm, tabName, {
|
|
1974
|
+
props.config.onTabRemove(mForm, tabName, {
|
|
1975
|
+
model: props.model,
|
|
1976
|
+
prop: props.prop,
|
|
1977
|
+
config: props.config
|
|
1978
|
+
});
|
|
1967
1979
|
} else {
|
|
1968
1980
|
props.model[props.config.name].splice(+tabName, 1);
|
|
1969
1981
|
if (tabName < activeTabName.value || activeTabName.value >= props.model[props.config.name].length) {
|
|
@@ -1978,7 +1990,7 @@ const Tab = defineComponent({
|
|
|
1978
1990
|
changeHandler: () => {
|
|
1979
1991
|
emit("change", props.model);
|
|
1980
1992
|
if (typeof props.config.onChange === "function") {
|
|
1981
|
-
props.config.onChange(mForm, { model: props.model });
|
|
1993
|
+
props.config.onChange(mForm, { model: props.model, prop: props.prop, config: props.config });
|
|
1982
1994
|
}
|
|
1983
1995
|
}
|
|
1984
1996
|
};
|
|
@@ -2167,13 +2179,13 @@ const _sfc_main$j = defineComponent({
|
|
|
2167
2179
|
};
|
|
2168
2180
|
}
|
|
2169
2181
|
});
|
|
2170
|
-
const _hoisted_1$
|
|
2182
|
+
const _hoisted_1$8 = {
|
|
2171
2183
|
class: "m-cascader",
|
|
2172
2184
|
style: { "width": "100%" }
|
|
2173
2185
|
};
|
|
2174
2186
|
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2175
2187
|
const _component_el_cascader = resolveComponent("el-cascader");
|
|
2176
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2188
|
+
return openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
2177
2189
|
createVNode(_component_el_cascader, {
|
|
2178
2190
|
modelValue: _ctx.model[_ctx.name],
|
|
2179
2191
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
|
|
@@ -2296,7 +2308,7 @@ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2296
2308
|
}
|
|
2297
2309
|
var CheckboxGroup = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$e]]);
|
|
2298
2310
|
|
|
2299
|
-
const _hoisted_1$
|
|
2311
|
+
const _hoisted_1$7 = { key: 0 };
|
|
2300
2312
|
const __default__$2 = defineComponent({
|
|
2301
2313
|
name: "m-fields-color-picker"
|
|
2302
2314
|
});
|
|
@@ -2316,7 +2328,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
2316
2328
|
const changeHandler = (value) => emit("change", value);
|
|
2317
2329
|
return (_ctx, _cache) => {
|
|
2318
2330
|
const _component_el_color_picker = resolveComponent("el-color-picker");
|
|
2319
|
-
return _ctx.model ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
2331
|
+
return _ctx.model ? (openBlock(), createElementBlock("div", _hoisted_1$7, [
|
|
2320
2332
|
createVNode(_component_el_color_picker, {
|
|
2321
2333
|
modelValue: _ctx.model[_ctx.name],
|
|
2322
2334
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
|
|
@@ -2352,10 +2364,10 @@ const _sfc_main$f = defineComponent({
|
|
|
2352
2364
|
};
|
|
2353
2365
|
}
|
|
2354
2366
|
});
|
|
2355
|
-
const _hoisted_1$
|
|
2367
|
+
const _hoisted_1$6 = { key: 0 };
|
|
2356
2368
|
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2357
2369
|
const _component_el_date_picker = resolveComponent("el-date-picker");
|
|
2358
|
-
return _ctx.model ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
2370
|
+
return _ctx.model ? (openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
2359
2371
|
createVNode(_component_el_date_picker, {
|
|
2360
2372
|
modelValue: _ctx.model[_ctx.modelName],
|
|
2361
2373
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.modelName] = $event),
|
|
@@ -2422,20 +2434,19 @@ const _sfc_main$e = defineComponent({
|
|
|
2422
2434
|
});
|
|
2423
2435
|
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2424
2436
|
const _component_el_date_picker = resolveComponent("el-date-picker");
|
|
2425
|
-
return openBlock(),
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
]);
|
|
2437
|
+
return openBlock(), createBlock(_component_el_date_picker, {
|
|
2438
|
+
modelValue: _ctx.value,
|
|
2439
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.value = $event),
|
|
2440
|
+
type: "datetimerange",
|
|
2441
|
+
"range-separator": "-",
|
|
2442
|
+
"start-placeholder": "\u5F00\u59CB\u65E5\u671F",
|
|
2443
|
+
"end-placeholder": "\u7ED3\u675F\u65E5\u671F",
|
|
2444
|
+
size: _ctx.size,
|
|
2445
|
+
"unlink-panels": true,
|
|
2446
|
+
disabled: _ctx.disabled,
|
|
2447
|
+
"default-time": _ctx.config.defaultTime || [new Date(2e3, 1, 1, 23, 59, 59)],
|
|
2448
|
+
onChange: _ctx.changeHandler
|
|
2449
|
+
}, null, 8, ["modelValue", "size", "disabled", "default-time", "onChange"]);
|
|
2439
2450
|
}
|
|
2440
2451
|
var Daterange = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$c]]);
|
|
2441
2452
|
|
|
@@ -2467,23 +2478,21 @@ const _sfc_main$d = defineComponent({
|
|
|
2467
2478
|
};
|
|
2468
2479
|
}
|
|
2469
2480
|
});
|
|
2470
|
-
const _hoisted_1$6 = { key: 0 };
|
|
2471
2481
|
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2472
2482
|
const _component_el_date_picker = resolveComponent("el-date-picker");
|
|
2473
|
-
return
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
])) : createCommentVNode("", true);
|
|
2483
|
+
return openBlock(), createBlock(_component_el_date_picker, {
|
|
2484
|
+
modelValue: _ctx.model[_ctx.name],
|
|
2485
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
|
|
2486
|
+
"popper-class": "magic-datetime-picker-popper",
|
|
2487
|
+
type: "datetime",
|
|
2488
|
+
size: _ctx.size,
|
|
2489
|
+
placeholder: _ctx.config.placeholder,
|
|
2490
|
+
disabled: _ctx.disabled,
|
|
2491
|
+
format: _ctx.config.format || "YYYY-MM-DD HH:mm:ss",
|
|
2492
|
+
"value-format": _ctx.config.valueFormat || "YYYY-MM-DD HH:mm:ss",
|
|
2493
|
+
"default-time": _ctx.config.defaultTime || [new Date(2e3, 1, 1, 23, 59, 59)],
|
|
2494
|
+
onChange: _ctx.changeHandler
|
|
2495
|
+
}, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format", "default-time", "onChange"]);
|
|
2487
2496
|
}
|
|
2488
2497
|
var DateTime = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$b]]);
|
|
2489
2498
|
|
|
@@ -2905,7 +2914,8 @@ const _sfc_main$6 = defineComponent({
|
|
|
2905
2914
|
body = body(mForm, {
|
|
2906
2915
|
model: props.model,
|
|
2907
2916
|
formValue: mForm?.values,
|
|
2908
|
-
formValues: mForm?.values
|
|
2917
|
+
formValues: mForm?.values,
|
|
2918
|
+
config: props.config
|
|
2909
2919
|
});
|
|
2910
2920
|
}
|
|
2911
2921
|
body.query = query.value;
|
|
@@ -2928,7 +2938,8 @@ const _sfc_main$6 = defineComponent({
|
|
|
2928
2938
|
res = option.afterRequest(mForm, res, {
|
|
2929
2939
|
model: props.model,
|
|
2930
2940
|
formValue: mForm?.values,
|
|
2931
|
-
formValues: mForm?.values
|
|
2941
|
+
formValues: mForm?.values,
|
|
2942
|
+
config: props.config
|
|
2932
2943
|
});
|
|
2933
2944
|
}
|
|
2934
2945
|
const optionsData = res[option.root];
|
|
@@ -3020,7 +3031,8 @@ const _sfc_main$6 = defineComponent({
|
|
|
3020
3031
|
model: props.model,
|
|
3021
3032
|
prop: props.prop,
|
|
3022
3033
|
formValues: mForm?.values,
|
|
3023
|
-
formValue: mForm?.values
|
|
3034
|
+
formValue: mForm?.values,
|
|
3035
|
+
config: props.config
|
|
3024
3036
|
})).then((data) => {
|
|
3025
3037
|
options.value = data;
|
|
3026
3038
|
});
|