@tmagic/form 1.5.0 → 1.5.2
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 +24 -30
- package/dist/tmagic-form.umd.cjs +23 -29
- package/package.json +6 -6
- package/src/containers/Container.vue +3 -0
- package/src/containers/Table.vue +17 -29
- package/src/index.ts +1 -0
package/dist/tmagic-form.js
CHANGED
|
@@ -5,7 +5,7 @@ import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox
|
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import utc from 'dayjs/plugin/utc';
|
|
7
7
|
import Sortable from 'sortablejs';
|
|
8
|
-
import {
|
|
8
|
+
import { asyncLoadJs, getValueByKeyPath, isNumber } from '@tmagic/utils';
|
|
9
9
|
import { createPopper } from '@popperjs/core';
|
|
10
10
|
|
|
11
11
|
const isTableSelect = (type) => typeof type === "string" && ["table-select", "tableSelect"].includes(type);
|
|
@@ -405,6 +405,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
405
405
|
class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
406
406
|
prop: itemProp.value,
|
|
407
407
|
"label-width": itemLabelWidth.value,
|
|
408
|
+
"label-position": _ctx.config.labelPosition,
|
|
408
409
|
rules: rule.value
|
|
409
410
|
}, {
|
|
410
411
|
label: withCtx(() => [
|
|
@@ -452,7 +453,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
452
453
|
}, null, 8, _hoisted_4$3)) : createCommentVNode("", true)
|
|
453
454
|
]),
|
|
454
455
|
_: 1
|
|
455
|
-
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
456
|
+
}, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
|
|
456
457
|
_ctx.config.tip ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
457
458
|
key: 0,
|
|
458
459
|
placement: "left"
|
|
@@ -478,6 +479,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
478
479
|
class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
479
480
|
prop: itemProp.value,
|
|
480
481
|
"label-width": itemLabelWidth.value,
|
|
482
|
+
"label-position": _ctx.config.labelPosition,
|
|
481
483
|
rules: rule.value
|
|
482
484
|
}, {
|
|
483
485
|
label: withCtx(() => [
|
|
@@ -521,7 +523,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
521
523
|
}, null, 8, _hoisted_8$1)) : createCommentVNode("", true)
|
|
522
524
|
]),
|
|
523
525
|
_: 1
|
|
524
|
-
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
526
|
+
}, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
|
|
525
527
|
_ctx.config.tip ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
526
528
|
key: 0,
|
|
527
529
|
placement: "left"
|
|
@@ -546,6 +548,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
546
548
|
class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
547
549
|
prop: itemProp.value,
|
|
548
550
|
"label-width": itemLabelWidth.value,
|
|
551
|
+
"label-position": _ctx.config.labelPosition,
|
|
549
552
|
rules: rule.value
|
|
550
553
|
}, {
|
|
551
554
|
label: withCtx(() => [
|
|
@@ -589,7 +592,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
589
592
|
}, null, 8, _hoisted_12)) : createCommentVNode("", true)
|
|
590
593
|
]),
|
|
591
594
|
_: 1
|
|
592
|
-
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
595
|
+
}, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
|
|
593
596
|
_ctx.config.tip ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
594
597
|
key: 1,
|
|
595
598
|
placement: "left"
|
|
@@ -1445,10 +1448,6 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1445
1448
|
props.model[modelName.value] = props.model[modelName.value].sort((a, b) => b[prop] - a[prop]);
|
|
1446
1449
|
}
|
|
1447
1450
|
};
|
|
1448
|
-
const foreUpdate = () => {
|
|
1449
|
-
updateKey.value += 1;
|
|
1450
|
-
setTimeout(() => rowDrop());
|
|
1451
|
-
};
|
|
1452
1451
|
const swapArray = (index1, index2) => {
|
|
1453
1452
|
props.model[modelName.value].splice(index1, 0, props.model[modelName.value].splice(index2, 1)[0]);
|
|
1454
1453
|
if (props.sortKey) {
|
|
@@ -1458,31 +1457,25 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1458
1457
|
}
|
|
1459
1458
|
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1460
1459
|
};
|
|
1460
|
+
let sortable;
|
|
1461
1461
|
const rowDrop = () => {
|
|
1462
|
+
sortable?.destroy();
|
|
1462
1463
|
const tableEl = tMagicTable.value?.instance.$el;
|
|
1463
1464
|
const tBodyEl = tableEl?.querySelector(".el-table__body > tbody");
|
|
1464
|
-
if (tBodyEl) {
|
|
1465
|
-
|
|
1466
|
-
onEnd: ({ newIndex, oldIndex }) => {
|
|
1467
|
-
if (typeof newIndex === "undefined") return;
|
|
1468
|
-
if (typeof oldIndex === "undefined") return;
|
|
1469
|
-
swapArray(newIndex, oldIndex);
|
|
1470
|
-
emit("change", props.model[modelName.value]);
|
|
1471
|
-
foreUpdate();
|
|
1472
|
-
sortable.destroy();
|
|
1473
|
-
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1474
|
-
sleep(1e3).then(() => {
|
|
1475
|
-
const elTrs = tableEl.querySelectorAll(".el-table__body > tbody > tr");
|
|
1476
|
-
if (elTrs?.[newIndex]) {
|
|
1477
|
-
elTrs[newIndex].style.backgroundColor = "rgba(243, 89, 59, 0.2)";
|
|
1478
|
-
sleep(1e3).then(() => {
|
|
1479
|
-
elTrs[newIndex].style.backgroundColor = "";
|
|
1480
|
-
});
|
|
1481
|
-
}
|
|
1482
|
-
});
|
|
1483
|
-
}
|
|
1484
|
-
});
|
|
1465
|
+
if (!tBodyEl) {
|
|
1466
|
+
return;
|
|
1485
1467
|
}
|
|
1468
|
+
sortable = Sortable.create(tBodyEl, {
|
|
1469
|
+
draggable: ".tmagic-design-table-row",
|
|
1470
|
+
direction: "vertical",
|
|
1471
|
+
onEnd: ({ newIndex, oldIndex }) => {
|
|
1472
|
+
if (typeof newIndex === "undefined") return;
|
|
1473
|
+
if (typeof oldIndex === "undefined") return;
|
|
1474
|
+
swapArray(newIndex, oldIndex);
|
|
1475
|
+
emit("change", props.model[modelName.value]);
|
|
1476
|
+
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1486
1479
|
};
|
|
1487
1480
|
const newHandler = async (row) => {
|
|
1488
1481
|
if (props.config.max && props.model[modelName.value].length >= props.config.max) {
|
|
@@ -1794,7 +1787,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1794
1787
|
onSortChange: sortChange
|
|
1795
1788
|
}, {
|
|
1796
1789
|
default: withCtx(() => [
|
|
1797
|
-
_ctx.config.itemExtra ? (openBlock(), createBlock(unref(TMagicTableColumn), {
|
|
1790
|
+
_ctx.config.itemExtra && !_ctx.config.dropSort ? (openBlock(), createBlock(unref(TMagicTableColumn), {
|
|
1798
1791
|
key: 0,
|
|
1799
1792
|
fixed: "left",
|
|
1800
1793
|
width: "30",
|
|
@@ -4646,6 +4639,7 @@ const index = {
|
|
|
4646
4639
|
app.component("m-form-table", _sfc_main$p);
|
|
4647
4640
|
app.component("m-form-tab", _sfc_main$o);
|
|
4648
4641
|
app.component("m-fields-text", _sfc_main$5);
|
|
4642
|
+
app.component("m-fields-img-upload", _sfc_main$5);
|
|
4649
4643
|
app.component("m-fields-number", _sfc_main$a);
|
|
4650
4644
|
app.component("m-fields-number-range", _sfc_main$9);
|
|
4651
4645
|
app.component("m-fields-textarea", _sfc_main$4);
|
package/dist/tmagic-form.umd.cjs
CHANGED
|
@@ -401,6 +401,7 @@
|
|
|
401
401
|
class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
402
402
|
prop: itemProp.value,
|
|
403
403
|
"label-width": itemLabelWidth.value,
|
|
404
|
+
"label-position": _ctx.config.labelPosition,
|
|
404
405
|
rules: rule.value
|
|
405
406
|
}, {
|
|
406
407
|
label: vue.withCtx(() => [
|
|
@@ -448,7 +449,7 @@
|
|
|
448
449
|
}, null, 8, _hoisted_4$3)) : vue.createCommentVNode("", true)
|
|
449
450
|
]),
|
|
450
451
|
_: 1
|
|
451
|
-
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
452
|
+
}, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
|
|
452
453
|
_ctx.config.tip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
453
454
|
key: 0,
|
|
454
455
|
placement: "left"
|
|
@@ -474,6 +475,7 @@
|
|
|
474
475
|
class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
475
476
|
prop: itemProp.value,
|
|
476
477
|
"label-width": itemLabelWidth.value,
|
|
478
|
+
"label-position": _ctx.config.labelPosition,
|
|
477
479
|
rules: rule.value
|
|
478
480
|
}, {
|
|
479
481
|
label: vue.withCtx(() => [
|
|
@@ -517,7 +519,7 @@
|
|
|
517
519
|
}, null, 8, _hoisted_8$1)) : vue.createCommentVNode("", true)
|
|
518
520
|
]),
|
|
519
521
|
_: 1
|
|
520
|
-
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
522
|
+
}, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
|
|
521
523
|
_ctx.config.tip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
522
524
|
key: 0,
|
|
523
525
|
placement: "left"
|
|
@@ -542,6 +544,7 @@
|
|
|
542
544
|
class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
543
545
|
prop: itemProp.value,
|
|
544
546
|
"label-width": itemLabelWidth.value,
|
|
547
|
+
"label-position": _ctx.config.labelPosition,
|
|
545
548
|
rules: rule.value
|
|
546
549
|
}, {
|
|
547
550
|
label: vue.withCtx(() => [
|
|
@@ -585,7 +588,7 @@
|
|
|
585
588
|
}, null, 8, _hoisted_12)) : vue.createCommentVNode("", true)
|
|
586
589
|
]),
|
|
587
590
|
_: 1
|
|
588
|
-
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
591
|
+
}, 8, ["style", "class", "prop", "label-width", "label-position", "rules"]),
|
|
589
592
|
_ctx.config.tip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
590
593
|
key: 1,
|
|
591
594
|
placement: "left"
|
|
@@ -1441,10 +1444,6 @@
|
|
|
1441
1444
|
props.model[modelName.value] = props.model[modelName.value].sort((a, b) => b[prop] - a[prop]);
|
|
1442
1445
|
}
|
|
1443
1446
|
};
|
|
1444
|
-
const foreUpdate = () => {
|
|
1445
|
-
updateKey.value += 1;
|
|
1446
|
-
setTimeout(() => rowDrop());
|
|
1447
|
-
};
|
|
1448
1447
|
const swapArray = (index1, index2) => {
|
|
1449
1448
|
props.model[modelName.value].splice(index1, 0, props.model[modelName.value].splice(index2, 1)[0]);
|
|
1450
1449
|
if (props.sortKey) {
|
|
@@ -1454,31 +1453,25 @@
|
|
|
1454
1453
|
}
|
|
1455
1454
|
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1456
1455
|
};
|
|
1456
|
+
let sortable;
|
|
1457
1457
|
const rowDrop = () => {
|
|
1458
|
+
sortable?.destroy();
|
|
1458
1459
|
const tableEl = tMagicTable.value?.instance.$el;
|
|
1459
1460
|
const tBodyEl = tableEl?.querySelector(".el-table__body > tbody");
|
|
1460
|
-
if (tBodyEl) {
|
|
1461
|
-
|
|
1462
|
-
onEnd: ({ newIndex, oldIndex }) => {
|
|
1463
|
-
if (typeof newIndex === "undefined") return;
|
|
1464
|
-
if (typeof oldIndex === "undefined") return;
|
|
1465
|
-
swapArray(newIndex, oldIndex);
|
|
1466
|
-
emit("change", props.model[modelName.value]);
|
|
1467
|
-
foreUpdate();
|
|
1468
|
-
sortable.destroy();
|
|
1469
|
-
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1470
|
-
utils.sleep(1e3).then(() => {
|
|
1471
|
-
const elTrs = tableEl.querySelectorAll(".el-table__body > tbody > tr");
|
|
1472
|
-
if (elTrs?.[newIndex]) {
|
|
1473
|
-
elTrs[newIndex].style.backgroundColor = "rgba(243, 89, 59, 0.2)";
|
|
1474
|
-
utils.sleep(1e3).then(() => {
|
|
1475
|
-
elTrs[newIndex].style.backgroundColor = "";
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
});
|
|
1479
|
-
}
|
|
1480
|
-
});
|
|
1461
|
+
if (!tBodyEl) {
|
|
1462
|
+
return;
|
|
1481
1463
|
}
|
|
1464
|
+
sortable = Sortable.create(tBodyEl, {
|
|
1465
|
+
draggable: ".tmagic-design-table-row",
|
|
1466
|
+
direction: "vertical",
|
|
1467
|
+
onEnd: ({ newIndex, oldIndex }) => {
|
|
1468
|
+
if (typeof newIndex === "undefined") return;
|
|
1469
|
+
if (typeof oldIndex === "undefined") return;
|
|
1470
|
+
swapArray(newIndex, oldIndex);
|
|
1471
|
+
emit("change", props.model[modelName.value]);
|
|
1472
|
+
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1482
1475
|
};
|
|
1483
1476
|
const newHandler = async (row) => {
|
|
1484
1477
|
if (props.config.max && props.model[modelName.value].length >= props.config.max) {
|
|
@@ -1790,7 +1783,7 @@
|
|
|
1790
1783
|
onSortChange: sortChange
|
|
1791
1784
|
}, {
|
|
1792
1785
|
default: vue.withCtx(() => [
|
|
1793
|
-
_ctx.config.itemExtra ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
|
|
1786
|
+
_ctx.config.itemExtra && !_ctx.config.dropSort ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
|
|
1794
1787
|
key: 0,
|
|
1795
1788
|
fixed: "left",
|
|
1796
1789
|
width: "30",
|
|
@@ -4642,6 +4635,7 @@
|
|
|
4642
4635
|
app.component("m-form-table", _sfc_main$p);
|
|
4643
4636
|
app.component("m-form-tab", _sfc_main$o);
|
|
4644
4637
|
app.component("m-fields-text", _sfc_main$5);
|
|
4638
|
+
app.component("m-fields-img-upload", _sfc_main$5);
|
|
4645
4639
|
app.component("m-fields-number", _sfc_main$a);
|
|
4646
4640
|
app.component("m-fields-number-range", _sfc_main$9);
|
|
4647
4641
|
app.component("m-fields-textarea", _sfc_main$4);
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.5.
|
|
2
|
+
"version": "1.5.2",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -47,18 +47,18 @@
|
|
|
47
47
|
"@types/lodash-es": "^4.17.4",
|
|
48
48
|
"@types/node": "^18.19.0",
|
|
49
49
|
"@types/sortablejs": "^1.15.8",
|
|
50
|
-
"@vitejs/plugin-vue": "^5.1
|
|
50
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
51
51
|
"@vue/compiler-sfc": "^3.5.12",
|
|
52
52
|
"@vue/test-utils": "^2.4.6",
|
|
53
53
|
"rimraf": "^3.0.2",
|
|
54
|
-
"sass": "^1.
|
|
55
|
-
"vite": "^
|
|
54
|
+
"sass": "^1.83.0",
|
|
55
|
+
"vite": "^6.0.3"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"vue": ">=3.5.0",
|
|
59
59
|
"typescript": "*",
|
|
60
|
-
"@tmagic/design": "1.5.
|
|
61
|
-
"@tmagic/utils": "1.5.
|
|
60
|
+
"@tmagic/design": "1.5.2",
|
|
61
|
+
"@tmagic/utils": "1.5.2"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
64
64
|
"typescript": {
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
:class="{ 'tmagic-form-hidden': `${itemLabelWidth}` === '0' || !text }"
|
|
41
41
|
:prop="itemProp"
|
|
42
42
|
:label-width="itemLabelWidth"
|
|
43
|
+
:label-position="config.labelPosition"
|
|
43
44
|
:rules="rule"
|
|
44
45
|
>
|
|
45
46
|
<template #label><span v-html="type === 'checkbox' ? '' : text" :title="config.labelTitle"></span></template>
|
|
@@ -96,6 +97,7 @@
|
|
|
96
97
|
:class="{ 'tmagic-form-hidden': `${itemLabelWidth}` === '0' || !text }"
|
|
97
98
|
:prop="itemProp"
|
|
98
99
|
:label-width="itemLabelWidth"
|
|
100
|
+
:label-position="config.labelPosition"
|
|
99
101
|
:rules="rule"
|
|
100
102
|
style="background: #f7dadd"
|
|
101
103
|
>
|
|
@@ -145,6 +147,7 @@
|
|
|
145
147
|
:class="{ 'tmagic-form-hidden': `${itemLabelWidth}` === '0' || !text }"
|
|
146
148
|
:prop="itemProp"
|
|
147
149
|
:label-width="itemLabelWidth"
|
|
150
|
+
:label-position="config.labelPosition"
|
|
148
151
|
:rules="rule"
|
|
149
152
|
style="background: #def7da"
|
|
150
153
|
>
|
package/src/containers/Table.vue
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
@select="selectHandle"
|
|
19
19
|
@sort-change="sortChange"
|
|
20
20
|
>
|
|
21
|
-
<TMagicTableColumn v-if="config.itemExtra" :fixed="'left'" width="30" type="expand">
|
|
21
|
+
<TMagicTableColumn v-if="config.itemExtra && !config.dropSort" :fixed="'left'" width="30" type="expand">
|
|
22
22
|
<template v-slot="scope">
|
|
23
23
|
<span v-html="itemExtra(config.itemExtra, scope.$index)" class="m-form-tip"></span>
|
|
24
24
|
</template>
|
|
@@ -204,7 +204,7 @@ import {
|
|
|
204
204
|
TMagicUpload,
|
|
205
205
|
useZIndex,
|
|
206
206
|
} from '@tmagic/design';
|
|
207
|
-
import { asyncLoadJs
|
|
207
|
+
import { asyncLoadJs } from '@tmagic/utils';
|
|
208
208
|
|
|
209
209
|
import type { ContainerChangeEventData, FormState, SortProp, TableColumnConfig, TableConfig } from '../schema';
|
|
210
210
|
import { display as displayFunc, initValue } from '../utils/form';
|
|
@@ -286,11 +286,6 @@ const sortChange = ({ prop, order }: SortProp) => {
|
|
|
286
286
|
}
|
|
287
287
|
};
|
|
288
288
|
|
|
289
|
-
const foreUpdate = () => {
|
|
290
|
-
updateKey.value += 1;
|
|
291
|
-
setTimeout(() => rowDrop());
|
|
292
|
-
};
|
|
293
|
-
|
|
294
289
|
const swapArray = (index1: number, index2: number) => {
|
|
295
290
|
props.model[modelName.value].splice(index1, 0, props.model[modelName.value].splice(index2, 1)[0]);
|
|
296
291
|
|
|
@@ -302,32 +297,25 @@ const swapArray = (index1: number, index2: number) => {
|
|
|
302
297
|
mForm?.$emit('field-change', props.prop, props.model[modelName.value]);
|
|
303
298
|
};
|
|
304
299
|
|
|
300
|
+
let sortable: Sortable | undefined;
|
|
305
301
|
const rowDrop = () => {
|
|
302
|
+
sortable?.destroy();
|
|
306
303
|
const tableEl = tMagicTable.value?.instance.$el;
|
|
307
304
|
const tBodyEl = tableEl?.querySelector('.el-table__body > tbody');
|
|
308
|
-
if (tBodyEl) {
|
|
309
|
-
|
|
310
|
-
const sortable = Sortable.create(tBodyEl, {
|
|
311
|
-
onEnd: ({ newIndex, oldIndex }: SortableEvent) => {
|
|
312
|
-
if (typeof newIndex === 'undefined') return;
|
|
313
|
-
if (typeof oldIndex === 'undefined') return;
|
|
314
|
-
swapArray(newIndex, oldIndex);
|
|
315
|
-
emit('change', props.model[modelName.value]);
|
|
316
|
-
foreUpdate();
|
|
317
|
-
sortable.destroy();
|
|
318
|
-
mForm?.$emit('field-change', props.prop, props.model[modelName.value]);
|
|
319
|
-
sleep(1000).then(() => {
|
|
320
|
-
const elTrs = tableEl.querySelectorAll('.el-table__body > tbody > tr');
|
|
321
|
-
if (elTrs?.[newIndex]) {
|
|
322
|
-
elTrs[newIndex].style.backgroundColor = 'rgba(243, 89, 59, 0.2)';
|
|
323
|
-
sleep(1000).then(() => {
|
|
324
|
-
elTrs[newIndex].style.backgroundColor = '';
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
},
|
|
329
|
-
});
|
|
305
|
+
if (!tBodyEl) {
|
|
306
|
+
return;
|
|
330
307
|
}
|
|
308
|
+
sortable = Sortable.create(tBodyEl, {
|
|
309
|
+
draggable: '.tmagic-design-table-row',
|
|
310
|
+
direction: 'vertical',
|
|
311
|
+
onEnd: ({ newIndex, oldIndex }: SortableEvent) => {
|
|
312
|
+
if (typeof newIndex === 'undefined') return;
|
|
313
|
+
if (typeof oldIndex === 'undefined') return;
|
|
314
|
+
swapArray(newIndex, oldIndex);
|
|
315
|
+
emit('change', props.model[modelName.value]);
|
|
316
|
+
mForm?.$emit('field-change', props.prop, props.model[modelName.value]);
|
|
317
|
+
},
|
|
318
|
+
});
|
|
331
319
|
};
|
|
332
320
|
|
|
333
321
|
const newHandler = async (row?: any) => {
|
package/src/index.ts
CHANGED
|
@@ -116,6 +116,7 @@ export default {
|
|
|
116
116
|
app.component('m-form-table', Table);
|
|
117
117
|
app.component('m-form-tab', Tabs);
|
|
118
118
|
app.component('m-fields-text', Text);
|
|
119
|
+
app.component('m-fields-img-upload', Text);
|
|
119
120
|
app.component('m-fields-number', Number);
|
|
120
121
|
app.component('m-fields-number-range', NumberRange);
|
|
121
122
|
app.component('m-fields-textarea', Textarea);
|