@ftjs/antd 0.1.0 → 0.1.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.
|
@@ -10,3 +10,4 @@ export interface EditMap<_TableData extends Record<string, any>> {
|
|
|
10
10
|
select: Edit<"select", SelectProps>;
|
|
11
11
|
}
|
|
12
12
|
export declare const editMap: Map<keyof EditMap<any>, Component>;
|
|
13
|
+
export declare const registerEdit: (type: keyof EditMap<any>, component: Component) => void;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed, toValue, createVNode, mergeProps, unref, isVNode, ref, useId, Fragment, createTextVNode, watchEffect, onMounted, onUnmounted, nextTick, reactive, watch, h } from "vue";
|
|
2
2
|
import { SwapOutlined, SettingOutlined } from "@ant-design/icons-vue";
|
|
3
3
|
import { getField, defineFormComponent, useFormItem, unrefs, defineFtForm, useFormInject, set, defineFtTable, useTableInject, get, cloneDeep } from "@ftjs/core";
|
|
4
|
-
import { FormItem, Input, Select, DatePicker, RangePicker, Radio, Textarea, Upload, Cascader, AutoComplete, CheckboxGroup, InputNumber, Mentions, Rate, Slider, Switch, TreeSelect, Modal, Tree, Button, Form, Table, Spin, Pagination } from "ant-design-vue";
|
|
4
|
+
import { FormItem, Input, Select, DatePicker, RangePicker, Radio, Textarea, Upload, Cascader, AutoComplete, CheckboxGroup, InputNumber, Mentions, Rate, Slider, Switch, TreeSelect, Modal, Tree, Button, Form, Divider, Table, Spin, Pagination } from "ant-design-vue";
|
|
5
5
|
import dayjs from "dayjs";
|
|
6
6
|
import { VxeGrid } from "vxe-table";
|
|
7
7
|
const useFormItemProps = (column) => {
|
|
@@ -266,7 +266,8 @@ const inputNumber = defineFormComponent((props) => {
|
|
|
266
266
|
return createVNode(FormItem, formItemProps.value, {
|
|
267
267
|
default: () => [toValue(isView.value) ? createVNode("div", null, [valueComputed.value]) : createVNode(InputNumber, mergeProps({
|
|
268
268
|
"value": valueComputed.value,
|
|
269
|
-
"onUpdate:value": ($event) => valueComputed.value = $event
|
|
269
|
+
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
270
|
+
"placeholder": `请输入${formItemProps.value.label}`
|
|
270
271
|
}, _props), null)]
|
|
271
272
|
});
|
|
272
273
|
};
|
|
@@ -441,7 +442,7 @@ const FtForm = /* @__PURE__ */ defineFtForm((_, ctx) => {
|
|
|
441
442
|
"ref": formRef,
|
|
442
443
|
"name": id,
|
|
443
444
|
"style": {
|
|
444
|
-
width
|
|
445
|
+
width: width.value
|
|
445
446
|
}
|
|
446
447
|
}, ctx.attrs, formProps.value), {
|
|
447
448
|
default: () => [ctx.slots.formContent(), !hideFooter.value && createVNode(FormItem, {
|
|
@@ -685,6 +686,9 @@ const editMap = /* @__PURE__ */ new Map([
|
|
|
685
686
|
["input", Input],
|
|
686
687
|
["select", Select]
|
|
687
688
|
]);
|
|
689
|
+
const registerEdit = (type, component) => {
|
|
690
|
+
editMap.set(type, component);
|
|
691
|
+
};
|
|
688
692
|
const FtTable = defineFtTable((_p, ctx) => {
|
|
689
693
|
const {
|
|
690
694
|
formColumns,
|
|
@@ -700,7 +704,6 @@ const FtTable = defineFtTable((_p, ctx) => {
|
|
|
700
704
|
initSearch,
|
|
701
705
|
fitFlexHeight,
|
|
702
706
|
minHeight,
|
|
703
|
-
hideSearch,
|
|
704
707
|
hidePagination,
|
|
705
708
|
onSearch,
|
|
706
709
|
onChange,
|
|
@@ -717,7 +720,7 @@ const FtTable = defineFtTable((_p, ctx) => {
|
|
|
717
720
|
if (!pagination && !hidePagination.value) {
|
|
718
721
|
pagination = {
|
|
719
722
|
page: 1,
|
|
720
|
-
pageSize: defaultPageSize.value
|
|
723
|
+
pageSize: defaultPageSize.value
|
|
721
724
|
};
|
|
722
725
|
}
|
|
723
726
|
onSearch(formData, {
|
|
@@ -745,7 +748,7 @@ const FtTable = defineFtTable((_p, ctx) => {
|
|
|
745
748
|
bordered: true,
|
|
746
749
|
pagination: hidePagination.value ? false : {
|
|
747
750
|
total: total.value,
|
|
748
|
-
defaultPageSize: defaultPageSize.value
|
|
751
|
+
defaultPageSize: defaultPageSize.value,
|
|
749
752
|
current: currentPage.value,
|
|
750
753
|
onChange: (page, pageSize) => {
|
|
751
754
|
currentPage.value = page;
|
|
@@ -779,6 +782,7 @@ const FtTable = defineFtTable((_p, ctx) => {
|
|
|
779
782
|
};
|
|
780
783
|
let tableStyle;
|
|
781
784
|
const containerRef = ref();
|
|
785
|
+
const tableRef = ref();
|
|
782
786
|
const calcTableHeight = () => {
|
|
783
787
|
const container = containerRef.value;
|
|
784
788
|
const table = container == null ? void 0 : container.querySelector(".ant-table-wrapper");
|
|
@@ -789,7 +793,7 @@ const FtTable = defineFtTable((_p, ctx) => {
|
|
|
789
793
|
let y = table.clientHeight - // pagination不是立即渲染的,其高度为64
|
|
790
794
|
// 多减去2px,避免出现小数
|
|
791
795
|
64 - 2 - ((header == null ? void 0 : header.clientHeight) ?? 0) - ((footer == null ? void 0 : footer.clientHeight) ?? 0);
|
|
792
|
-
const minHeightValue = minHeight.value
|
|
796
|
+
const minHeightValue = minHeight.value;
|
|
793
797
|
if (y < minHeightValue) y = minHeightValue;
|
|
794
798
|
_scrollY.value = y;
|
|
795
799
|
};
|
|
@@ -807,6 +811,7 @@ const FtTable = defineFtTable((_p, ctx) => {
|
|
|
807
811
|
let prevHeight;
|
|
808
812
|
let timer;
|
|
809
813
|
onMounted(() => {
|
|
814
|
+
var _a;
|
|
810
815
|
resizeObserver = new ResizeObserver((entries) => {
|
|
811
816
|
const height = entries[0].contentRect.height;
|
|
812
817
|
if (prevHeight === height) return;
|
|
@@ -818,7 +823,7 @@ const FtTable = defineFtTable((_p, ctx) => {
|
|
|
818
823
|
calcTableHeight();
|
|
819
824
|
}, 100);
|
|
820
825
|
});
|
|
821
|
-
resizeObserver.observe(
|
|
826
|
+
resizeObserver.observe((_a = tableRef.value) == null ? void 0 : _a.$el);
|
|
822
827
|
});
|
|
823
828
|
onUnmounted(() => {
|
|
824
829
|
resizeObserver.disconnect();
|
|
@@ -871,13 +876,17 @@ const FtTable = defineFtTable((_p, ctx) => {
|
|
|
871
876
|
return createVNode("div", {
|
|
872
877
|
"ref": containerRef,
|
|
873
878
|
"style": containerStyle
|
|
874
|
-
}, [
|
|
879
|
+
}, [formColumns.value.length > 0 && createVNode(Fragment, null, [createVNode(FtFormSearch, mergeProps({
|
|
875
880
|
"exposed": formExposed.value,
|
|
876
881
|
"onUpdate:exposed": ($event) => formExposed.value = $event,
|
|
877
882
|
"cache": cache.value,
|
|
878
883
|
"columns": formColumns.value,
|
|
879
884
|
"onSubmit": () => handleSearch()
|
|
880
|
-
}, internalFormProps.value), null),
|
|
885
|
+
}, internalFormProps.value), null), createVNode(Divider, {
|
|
886
|
+
"dashed": true,
|
|
887
|
+
"style": "margin: 0"
|
|
888
|
+
}, null)]), (ctx.slots.buttons || ctx.slots.tools) && createVNode("div", null, [(_b = (_a = ctx.slots).buttons) == null ? void 0 : _b.call(_a), (_d = (_c = ctx.slots).tools) == null ? void 0 : _d.call(_c)]), createVNode(Table, mergeProps({
|
|
889
|
+
"ref": tableRef,
|
|
881
890
|
"style": tableStyle,
|
|
882
891
|
"columns": columns.value,
|
|
883
892
|
"loading": loading.value,
|
|
@@ -896,11 +905,12 @@ const FtTable = defineFtTable((_p, ctx) => {
|
|
|
896
905
|
}, ["onChange", "onExpand", "onExpandedRowsChange", "onResizeColumn", "onSearch", ["initSearch", {
|
|
897
906
|
type: Boolean,
|
|
898
907
|
default: true
|
|
899
|
-
}], "fitFlexHeight", "minHeight",
|
|
900
|
-
type:
|
|
901
|
-
|
|
908
|
+
}], "fitFlexHeight", ["minHeight", {
|
|
909
|
+
type: Number,
|
|
910
|
+
default: 210
|
|
911
|
+
}], ["hidePagination", {
|
|
902
912
|
type: Boolean
|
|
903
|
-
}]]);
|
|
913
|
+
}], "exposed", "onUpdate:exposed"]);
|
|
904
914
|
function useEdit(tableData) {
|
|
905
915
|
const editRowMap = reactive(/* @__PURE__ */ new Map());
|
|
906
916
|
const createBodyCell = (bodyCellDefault) => {
|
|
@@ -986,7 +996,6 @@ const FtVxeTable = defineFtTable((_, ctx) => {
|
|
|
986
996
|
initSearch,
|
|
987
997
|
fitFlexHeight,
|
|
988
998
|
minHeight,
|
|
989
|
-
hideSearch,
|
|
990
999
|
hidePagination,
|
|
991
1000
|
rowConfig: _rowConfig,
|
|
992
1001
|
customConfig: _customConfig,
|
|
@@ -1005,7 +1014,7 @@ const FtVxeTable = defineFtTable((_, ctx) => {
|
|
|
1005
1014
|
if (!pagination && !hidePagination.value) {
|
|
1006
1015
|
pagination = {
|
|
1007
1016
|
page: 1,
|
|
1008
|
-
pageSize: defaultPageSize.value
|
|
1017
|
+
pageSize: defaultPageSize.value
|
|
1009
1018
|
};
|
|
1010
1019
|
}
|
|
1011
1020
|
await onSearch(formData, {
|
|
@@ -1138,13 +1147,16 @@ const FtVxeTable = defineFtTable((_, ctx) => {
|
|
|
1138
1147
|
return () => createVNode("div", {
|
|
1139
1148
|
"ref": containerRef,
|
|
1140
1149
|
"style": containerStyle
|
|
1141
|
-
}, [
|
|
1150
|
+
}, [formColumns.value.length > 0 && createVNode(Fragment, null, [createVNode(FtFormSearch, mergeProps({
|
|
1142
1151
|
"exposed": formExposed.value,
|
|
1143
1152
|
"onUpdate:exposed": ($event) => formExposed.value = $event,
|
|
1144
1153
|
"cache": cache.value,
|
|
1145
1154
|
"columns": formColumns.value,
|
|
1146
1155
|
"onSubmit": () => handleSearch()
|
|
1147
|
-
}, internalFormProps.value), null), createVNode(
|
|
1156
|
+
}, internalFormProps.value), null), createVNode(Divider, {
|
|
1157
|
+
"dashed": true,
|
|
1158
|
+
"style": "margin: 0"
|
|
1159
|
+
}, null)]), createVNode("div", {
|
|
1148
1160
|
"style": tableStyle
|
|
1149
1161
|
}, [createVNode(VxeGrid, mergeProps({
|
|
1150
1162
|
"ref": (ref2) => tableExposed.value = ref2,
|
|
@@ -1172,8 +1184,9 @@ const FtVxeTable = defineFtTable((_, ctx) => {
|
|
|
1172
1184
|
"onUpdate:current": ($event) => current.value = $event,
|
|
1173
1185
|
"showQuickJumper": true,
|
|
1174
1186
|
"showSizeChanger": true,
|
|
1187
|
+
"showLessItems": true,
|
|
1175
1188
|
"total": total.value,
|
|
1176
|
-
"defaultPageSize": defaultPageSize.value
|
|
1189
|
+
"defaultPageSize": defaultPageSize.value,
|
|
1177
1190
|
"showTotal": (total2) => {
|
|
1178
1191
|
if (total2 === 0) return null;
|
|
1179
1192
|
return `共 ${total2} 条数据`;
|
|
@@ -1198,14 +1211,14 @@ const FtVxeTable = defineFtTable((_, ctx) => {
|
|
|
1198
1211
|
default: true
|
|
1199
1212
|
}], "fitFlexHeight", "minHeight", ["hidePagination", {
|
|
1200
1213
|
type: Boolean
|
|
1201
|
-
}], "exposed", "onUpdate:exposed",
|
|
1202
|
-
type: Boolean
|
|
1203
|
-
}], "rowConfig", "treeConfig", "customConfig", "toolbarConfig", "columnConfig"]);
|
|
1214
|
+
}], "exposed", "onUpdate:exposed", "rowConfig", "treeConfig", "customConfig", "toolbarConfig", "columnConfig"]);
|
|
1204
1215
|
export {
|
|
1205
1216
|
FtForm,
|
|
1206
1217
|
FtFormSearch,
|
|
1207
1218
|
FtTable,
|
|
1208
1219
|
FtVxeTable,
|
|
1220
|
+
editMap,
|
|
1221
|
+
registerEdit,
|
|
1209
1222
|
registerForm,
|
|
1210
1223
|
useRules
|
|
1211
1224
|
};
|
|
@@ -92,11 +92,6 @@ interface VxeExtendedProps<TableData extends Record<string, any>, SearchData ext
|
|
|
92
92
|
* vxe-table 列配置
|
|
93
93
|
*/
|
|
94
94
|
columnConfig?: VxeGridProps<TableData>["columnConfig"];
|
|
95
|
-
/**
|
|
96
|
-
* 是否隐藏搜索
|
|
97
|
-
* @default false
|
|
98
|
-
*/
|
|
99
|
-
hideSearch?: boolean;
|
|
100
95
|
/**
|
|
101
96
|
* 是否隐藏分页
|
|
102
97
|
* @default false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ftjs/antd",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"dayjs": "^1.11.13",
|
|
24
24
|
"vue": "^3.5.13",
|
|
25
25
|
"vue-component-type-helpers": "^2.2.0",
|
|
26
|
-
"vxe-table": "4.11.
|
|
26
|
+
"vxe-table": "4.11.15",
|
|
27
27
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
28
28
|
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
|
29
29
|
"typescript": "^5.7.3",
|
|
30
30
|
"vite": "^6.1.0",
|
|
31
31
|
"vite-plugin-dts": "^4.5.0",
|
|
32
32
|
"vue-tsc": "2.2.0",
|
|
33
|
-
"@ftjs/core": "0.1.
|
|
33
|
+
"@ftjs/core": "0.1.2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@ant-design/icons-vue": ">=7.0.0",
|