@ftjs/antd 0.5.5 → 0.5.6
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/index.d.ts +0 -1
- package/dist/index.js +25 -383
- package/dist/{antd-table → vxe-table}/column-edit.d.ts +12 -6
- package/dist/vxe-table/index.d.ts +1 -0
- package/dist/vxe-table/types.d.ts +2 -2
- package/package.json +2 -2
- package/dist/antd-table/ft-antd-table.vue.d.ts +0 -65
- package/dist/antd-table/index.d.ts +0 -3
- package/dist/antd-table/type.d.ts +0 -55
- package/dist/antd-table/use-edit.d.ts +0 -14
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getField, useFormItem, unrefs, useFormInject, useForm, set,
|
|
2
|
-
import { computed, toValue, createVNode, mergeProps, unref, createTextVNode, isVNode, defineComponent, createBlock, openBlock, resolveDynamicComponent, createElementBlock, Fragment, renderList, ref, useId, withCtx, renderSlot, createCommentVNode, createElementVNode, toDisplayString,
|
|
3
|
-
import { FormItem, Input, Select, DatePicker, RangePicker, Radio, Textarea, Upload, Cascader, AutoComplete, CheckboxGroup, InputNumber, Mentions, Rate, Slider, Switch, TreeSelect, Form, Button, Modal, Tree, Divider,
|
|
1
|
+
import { getField, useFormItem, unrefs, useFormInject, useForm, set, useTable, get } from "@ftjs/core";
|
|
2
|
+
import { computed, toValue, createVNode, mergeProps, unref, createTextVNode, isVNode, defineComponent, createBlock, openBlock, resolveDynamicComponent, createElementBlock, Fragment, renderList, ref, useId, withCtx, renderSlot, createCommentVNode, createElementVNode, toDisplayString, onMounted, h, useTemplateRef, normalizeStyle, createSlots, normalizeProps } from "vue";
|
|
3
|
+
import { FormItem, Input, Select, DatePicker, RangePicker, Radio, Textarea, Upload, Cascader, AutoComplete, CheckboxGroup, InputNumber, Mentions, Rate, Slider, Switch, TreeSelect, Form, Button, Modal, Tree, Divider, Spin, Pagination } from "ant-design-vue";
|
|
4
4
|
import dayjs from "dayjs";
|
|
5
5
|
import { SwapOutlined, SettingOutlined } from "@ant-design/icons-vue";
|
|
6
6
|
import { VxeGrid } from "vxe-table";
|
|
@@ -487,7 +487,7 @@ const formRenderMap = /* @__PURE__ */ new Map([["input", input], ["textarea", te
|
|
|
487
487
|
function registerForm(type, Component) {
|
|
488
488
|
formRenderMap.set(type, Component);
|
|
489
489
|
}
|
|
490
|
-
const _sfc_main$
|
|
490
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
491
491
|
...{
|
|
492
492
|
name: "FtAntdFormContentItem",
|
|
493
493
|
inheritAttrs: false
|
|
@@ -518,7 +518,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
518
518
|
};
|
|
519
519
|
}
|
|
520
520
|
});
|
|
521
|
-
const _sfc_main$
|
|
521
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
522
522
|
...{
|
|
523
523
|
name: "FtAntdFormContent",
|
|
524
524
|
inheritAttrs: false
|
|
@@ -531,7 +531,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
531
531
|
setup(__props) {
|
|
532
532
|
return (_ctx, _cache) => {
|
|
533
533
|
return openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.columns, (column) => {
|
|
534
|
-
return openBlock(), createBlock(_sfc_main$
|
|
534
|
+
return openBlock(), createBlock(_sfc_main$4, {
|
|
535
535
|
key: unref(getField)(column),
|
|
536
536
|
column,
|
|
537
537
|
"is-view": _ctx.isView
|
|
@@ -540,7 +540,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
540
540
|
};
|
|
541
541
|
}
|
|
542
542
|
});
|
|
543
|
-
const _sfc_main$
|
|
543
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
544
544
|
...{
|
|
545
545
|
name: "FtAntdForm",
|
|
546
546
|
inheritAttrs: false
|
|
@@ -597,7 +597,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
597
597
|
style: { width: _ctx.width }
|
|
598
598
|
}, { ..._ctx.$attrs, ...formProps.value }), {
|
|
599
599
|
default: withCtx(() => [
|
|
600
|
-
createVNode(_sfc_main$
|
|
600
|
+
createVNode(_sfc_main$3, {
|
|
601
601
|
columns: unref(visibleColumns),
|
|
602
602
|
"is-view": _ctx.isView
|
|
603
603
|
}, null, 8, ["columns", "is-view"]),
|
|
@@ -639,10 +639,10 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
639
639
|
};
|
|
640
640
|
}
|
|
641
641
|
});
|
|
642
|
-
const _hoisted_1$
|
|
642
|
+
const _hoisted_1$1 = { style: { "text-align": "center" } };
|
|
643
643
|
const _hoisted_2$1 = { style: { "display": "flex" } };
|
|
644
644
|
const _hoisted_3 = { style: { "display": "flex", "gap": "10px" } };
|
|
645
|
-
const _sfc_main$
|
|
645
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
646
646
|
...{
|
|
647
647
|
name: "FtAntdFormSearch",
|
|
648
648
|
inheritAttrs: false
|
|
@@ -787,7 +787,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
787
787
|
], -1)
|
|
788
788
|
])),
|
|
789
789
|
footer: withCtx(() => [
|
|
790
|
-
createElementVNode("div", _hoisted_1$
|
|
790
|
+
createElementVNode("div", _hoisted_1$1, [
|
|
791
791
|
createVNode(unref(Button), {
|
|
792
792
|
type: "primary",
|
|
793
793
|
danger: "",
|
|
@@ -845,7 +845,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
845
845
|
style: { "gap": "10px" }
|
|
846
846
|
}, { ..._ctx.$attrs, ...formProps.value }), {
|
|
847
847
|
default: withCtx(() => [
|
|
848
|
-
createVNode(_sfc_main$
|
|
848
|
+
createVNode(_sfc_main$3, {
|
|
849
849
|
columns: unref(visibleColumns),
|
|
850
850
|
"is-view": _ctx.isView
|
|
851
851
|
}, null, 8, ["columns", "is-view"]),
|
|
@@ -916,6 +916,7 @@ function isComponentTuple(value) {
|
|
|
916
916
|
const editMap = /* @__PURE__ */ new Map([
|
|
917
917
|
["input", Input],
|
|
918
918
|
["select", Select],
|
|
919
|
+
["input-number", InputNumber],
|
|
919
920
|
[
|
|
920
921
|
"switch",
|
|
921
922
|
[
|
|
@@ -929,372 +930,6 @@ const editMap = /* @__PURE__ */ new Map([
|
|
|
929
930
|
const registerEdit = (type, component) => {
|
|
930
931
|
editMap.set(type, component);
|
|
931
932
|
};
|
|
932
|
-
function useEdit(props) {
|
|
933
|
-
const editRowMap = reactive(/* @__PURE__ */ new Map());
|
|
934
|
-
const EditBodyCell = (scopeProps) => {
|
|
935
|
-
const column = scopeProps.column;
|
|
936
|
-
if (column.customRender) {
|
|
937
|
-
return column.customRender({
|
|
938
|
-
...scopeProps,
|
|
939
|
-
// todo:: 这个是啥?
|
|
940
|
-
renderIndex: -1
|
|
941
|
-
});
|
|
942
|
-
}
|
|
943
|
-
if (column.edit && editRowMap.has(scopeProps.record)) {
|
|
944
|
-
let edit;
|
|
945
|
-
if (typeof column.edit === "string") {
|
|
946
|
-
edit = {
|
|
947
|
-
type: column.edit
|
|
948
|
-
};
|
|
949
|
-
} else {
|
|
950
|
-
edit = column.edit;
|
|
951
|
-
}
|
|
952
|
-
const field = edit.field ?? column.field;
|
|
953
|
-
const componentOrTuple = editMap.get(edit.type);
|
|
954
|
-
if (componentOrTuple) {
|
|
955
|
-
let component;
|
|
956
|
-
let model = "value";
|
|
957
|
-
if (isComponentTuple(componentOrTuple)) {
|
|
958
|
-
component = componentOrTuple[0];
|
|
959
|
-
const info = componentOrTuple[1];
|
|
960
|
-
if (info.model) {
|
|
961
|
-
model = info.model;
|
|
962
|
-
}
|
|
963
|
-
} else {
|
|
964
|
-
component = componentOrTuple;
|
|
965
|
-
}
|
|
966
|
-
const { valueGetter, valueSetter } = edit;
|
|
967
|
-
let value = get(scopeProps.record, field);
|
|
968
|
-
if (valueGetter) {
|
|
969
|
-
value = valueGetter(value);
|
|
970
|
-
}
|
|
971
|
-
const props2 = {
|
|
972
|
-
...unrefs(edit.props),
|
|
973
|
-
class: "ft-table-edit",
|
|
974
|
-
[model]: value,
|
|
975
|
-
[`onUpdate:${model}`]: (value2) => {
|
|
976
|
-
if (valueSetter) {
|
|
977
|
-
value2 = valueSetter(value2);
|
|
978
|
-
}
|
|
979
|
-
set(scopeProps.record, field, value2);
|
|
980
|
-
}
|
|
981
|
-
};
|
|
982
|
-
return h(component, props2);
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
};
|
|
986
|
-
const setEditRow = (row) => {
|
|
987
|
-
const oldRow = cloneDeep(row);
|
|
988
|
-
editRowMap.set(row, oldRow);
|
|
989
|
-
};
|
|
990
|
-
const cancelEditRow = (row) => {
|
|
991
|
-
const oldRow = editRowMap.get(row);
|
|
992
|
-
if (!oldRow) return;
|
|
993
|
-
const index = props.tableData.indexOf(row);
|
|
994
|
-
props.tableData[index] = oldRow;
|
|
995
|
-
delEditRow(row);
|
|
996
|
-
};
|
|
997
|
-
const saveEditRow = (row) => {
|
|
998
|
-
delEditRow(row);
|
|
999
|
-
};
|
|
1000
|
-
const delEditRow = (row) => {
|
|
1001
|
-
editRowMap.delete(row);
|
|
1002
|
-
};
|
|
1003
|
-
watch(
|
|
1004
|
-
() => props.tableData,
|
|
1005
|
-
(v) => {
|
|
1006
|
-
editRowMap.forEach((_val, key) => {
|
|
1007
|
-
if (!(v == null ? void 0 : v.includes(key))) {
|
|
1008
|
-
editRowMap.delete(key);
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
);
|
|
1013
|
-
return {
|
|
1014
|
-
editRowMap,
|
|
1015
|
-
setEditRow,
|
|
1016
|
-
EditBodyCell,
|
|
1017
|
-
cancelEditRow,
|
|
1018
|
-
saveEditRow
|
|
1019
|
-
};
|
|
1020
|
-
}
|
|
1021
|
-
const _hoisted_1$1 = {
|
|
1022
|
-
key: 1
|
|
1023
|
-
};
|
|
1024
|
-
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
1025
|
-
...{
|
|
1026
|
-
name: "FtAntdTable",
|
|
1027
|
-
inheritAttrs: false
|
|
1028
|
-
},
|
|
1029
|
-
__name: "ft-antd-table",
|
|
1030
|
-
props: {
|
|
1031
|
-
initSearch: {
|
|
1032
|
-
type: Boolean,
|
|
1033
|
-
default: true
|
|
1034
|
-
},
|
|
1035
|
-
autoHeight: {
|
|
1036
|
-
type: Boolean,
|
|
1037
|
-
default: true
|
|
1038
|
-
},
|
|
1039
|
-
minHeight: {
|
|
1040
|
-
default: 210
|
|
1041
|
-
},
|
|
1042
|
-
hidePagination: {
|
|
1043
|
-
type: Boolean
|
|
1044
|
-
},
|
|
1045
|
-
internalTableProps: {},
|
|
1046
|
-
internalFormProps: {},
|
|
1047
|
-
onChange: {},
|
|
1048
|
-
onExpand: {},
|
|
1049
|
-
onExpandedRowsChange: {},
|
|
1050
|
-
onResizeColumn: {},
|
|
1051
|
-
onSearch: {},
|
|
1052
|
-
cache: {},
|
|
1053
|
-
columns: {},
|
|
1054
|
-
searchColumns: {},
|
|
1055
|
-
total: {},
|
|
1056
|
-
defaultPageSize: {},
|
|
1057
|
-
loading: {
|
|
1058
|
-
type: Boolean
|
|
1059
|
-
},
|
|
1060
|
-
tableData: {},
|
|
1061
|
-
"onUpdate:tableData": {},
|
|
1062
|
-
keyField: {}
|
|
1063
|
-
},
|
|
1064
|
-
setup(__props, {
|
|
1065
|
-
expose: __expose
|
|
1066
|
-
}) {
|
|
1067
|
-
const props = __props;
|
|
1068
|
-
const {
|
|
1069
|
-
formColumns
|
|
1070
|
-
} = useTable(props);
|
|
1071
|
-
onMounted(() => {
|
|
1072
|
-
var _a;
|
|
1073
|
-
if (props.initSearch ?? true) {
|
|
1074
|
-
(_a = props.onSearch) == null ? void 0 : _a.call(props);
|
|
1075
|
-
}
|
|
1076
|
-
});
|
|
1077
|
-
const columns = computed(() => {
|
|
1078
|
-
return props.columns.map((column) => {
|
|
1079
|
-
return {
|
|
1080
|
-
width: 120,
|
|
1081
|
-
align: "center",
|
|
1082
|
-
...column,
|
|
1083
|
-
dataIndex: column.field
|
|
1084
|
-
};
|
|
1085
|
-
});
|
|
1086
|
-
});
|
|
1087
|
-
const currentPage = ref(1);
|
|
1088
|
-
const tableProps = computed(() => {
|
|
1089
|
-
return {
|
|
1090
|
-
bordered: true,
|
|
1091
|
-
pagination: props.hidePagination ? false : {
|
|
1092
|
-
total: props.total,
|
|
1093
|
-
defaultPageSize: props.defaultPageSize,
|
|
1094
|
-
current: currentPage.value,
|
|
1095
|
-
onChange: () => {
|
|
1096
|
-
var _a;
|
|
1097
|
-
(_a = props.onSearch) == null ? void 0 : _a.call(props);
|
|
1098
|
-
}
|
|
1099
|
-
},
|
|
1100
|
-
tableLayout: "fixed",
|
|
1101
|
-
rowKey: props.keyField ?? "id",
|
|
1102
|
-
...props.internalTableProps
|
|
1103
|
-
};
|
|
1104
|
-
});
|
|
1105
|
-
const _scrollY = ref(0);
|
|
1106
|
-
const scrollY = computed(() => {
|
|
1107
|
-
if (!props.tableData || props.tableData.length === 0) return;
|
|
1108
|
-
return _scrollY.value;
|
|
1109
|
-
});
|
|
1110
|
-
const scroll = computed(() => {
|
|
1111
|
-
return {
|
|
1112
|
-
scrollToFirstRowOnChange: true,
|
|
1113
|
-
x: "100%",
|
|
1114
|
-
y: scrollY.value
|
|
1115
|
-
};
|
|
1116
|
-
});
|
|
1117
|
-
let containerStyle = {
|
|
1118
|
-
display: "flex",
|
|
1119
|
-
flexDirection: "column",
|
|
1120
|
-
gap: "10px"
|
|
1121
|
-
};
|
|
1122
|
-
let tableStyle;
|
|
1123
|
-
const containerRef = ref();
|
|
1124
|
-
const tableRef = ref();
|
|
1125
|
-
const calcTableHeight = () => {
|
|
1126
|
-
const container = containerRef.value;
|
|
1127
|
-
const table = container == null ? void 0 : container.querySelector(".ant-table-wrapper");
|
|
1128
|
-
if (!table) return;
|
|
1129
|
-
const header = container.querySelector(".ant-table-thead");
|
|
1130
|
-
const footer = container.querySelector(".ant-table-footer");
|
|
1131
|
-
if (!table) return;
|
|
1132
|
-
let y = table.clientHeight - // pagination不是立即渲染的,其高度为64
|
|
1133
|
-
// 多减去2px,避免出现小数
|
|
1134
|
-
64 - 2 - ((header == null ? void 0 : header.clientHeight) ?? 0) - ((footer == null ? void 0 : footer.clientHeight) ?? 0);
|
|
1135
|
-
const minHeightValue = props.minHeight;
|
|
1136
|
-
if (y < minHeightValue) y = minHeightValue;
|
|
1137
|
-
_scrollY.value = y;
|
|
1138
|
-
};
|
|
1139
|
-
if (props.autoHeight) {
|
|
1140
|
-
containerStyle = {
|
|
1141
|
-
...containerStyle,
|
|
1142
|
-
flex: "1",
|
|
1143
|
-
minHeight: 0,
|
|
1144
|
-
height: "100%"
|
|
1145
|
-
};
|
|
1146
|
-
tableStyle = {
|
|
1147
|
-
flex: "1",
|
|
1148
|
-
minHeight: 0
|
|
1149
|
-
};
|
|
1150
|
-
let resizeObserver;
|
|
1151
|
-
let prevHeight;
|
|
1152
|
-
let timer;
|
|
1153
|
-
onMounted(() => {
|
|
1154
|
-
var _a;
|
|
1155
|
-
resizeObserver = new ResizeObserver((entries) => {
|
|
1156
|
-
const height = entries[0].contentRect.height;
|
|
1157
|
-
if (prevHeight === height) return;
|
|
1158
|
-
prevHeight = height;
|
|
1159
|
-
if (timer) {
|
|
1160
|
-
clearTimeout(timer);
|
|
1161
|
-
}
|
|
1162
|
-
timer = setTimeout(() => {
|
|
1163
|
-
calcTableHeight();
|
|
1164
|
-
}, 100);
|
|
1165
|
-
});
|
|
1166
|
-
resizeObserver.observe((_a = tableRef.value) == null ? void 0 : _a.$el);
|
|
1167
|
-
});
|
|
1168
|
-
onUnmounted(() => {
|
|
1169
|
-
resizeObserver.disconnect();
|
|
1170
|
-
});
|
|
1171
|
-
}
|
|
1172
|
-
const scrollToIndex = (index) => {
|
|
1173
|
-
var _a;
|
|
1174
|
-
const row = (_a = containerRef.value) == null ? void 0 : _a.querySelectorAll(".ant-table-row")[index];
|
|
1175
|
-
if (!row) return;
|
|
1176
|
-
row.scrollIntoView({
|
|
1177
|
-
behavior: "smooth",
|
|
1178
|
-
block: "nearest",
|
|
1179
|
-
inline: "start"
|
|
1180
|
-
});
|
|
1181
|
-
};
|
|
1182
|
-
const scrollToRow = (row) => {
|
|
1183
|
-
const index = props.tableData.indexOf(row);
|
|
1184
|
-
scrollToIndex(index);
|
|
1185
|
-
};
|
|
1186
|
-
const formRef = useTemplateRef("form");
|
|
1187
|
-
const {
|
|
1188
|
-
editRowMap,
|
|
1189
|
-
setEditRow,
|
|
1190
|
-
cancelEditRow,
|
|
1191
|
-
saveEditRow,
|
|
1192
|
-
EditBodyCell
|
|
1193
|
-
} = useEdit(props);
|
|
1194
|
-
__expose({
|
|
1195
|
-
/**
|
|
1196
|
-
* 表单示例
|
|
1197
|
-
*/
|
|
1198
|
-
formRef,
|
|
1199
|
-
/**
|
|
1200
|
-
* 刷新表格
|
|
1201
|
-
*/
|
|
1202
|
-
refresh: async () => {
|
|
1203
|
-
var _a, _b;
|
|
1204
|
-
await ((_a = formRef.value) == null ? void 0 : _a.resetToDefault());
|
|
1205
|
-
(_b = props.onSearch) == null ? void 0 : _b.call(props);
|
|
1206
|
-
},
|
|
1207
|
-
/**
|
|
1208
|
-
* 设置编辑行
|
|
1209
|
-
*/
|
|
1210
|
-
setEditRow: (row) => {
|
|
1211
|
-
setEditRow(row);
|
|
1212
|
-
nextTick().then(() => {
|
|
1213
|
-
scrollToRow(row);
|
|
1214
|
-
});
|
|
1215
|
-
},
|
|
1216
|
-
/**
|
|
1217
|
-
* 当前全部编辑行
|
|
1218
|
-
*/
|
|
1219
|
-
editRowMap,
|
|
1220
|
-
/**
|
|
1221
|
-
* 取消编辑行
|
|
1222
|
-
*/
|
|
1223
|
-
cancelEditRow,
|
|
1224
|
-
/**
|
|
1225
|
-
* 保存编辑行
|
|
1226
|
-
*/
|
|
1227
|
-
saveEditRow,
|
|
1228
|
-
/**
|
|
1229
|
-
* 滚动到指定行
|
|
1230
|
-
*/
|
|
1231
|
-
scrollToRow,
|
|
1232
|
-
/**
|
|
1233
|
-
* 滚动到指定行索引
|
|
1234
|
-
*/
|
|
1235
|
-
scrollToIndex
|
|
1236
|
-
});
|
|
1237
|
-
const definedSlots = ["buttons", "tools", "bodyCell"];
|
|
1238
|
-
return (_ctx, _cache) => {
|
|
1239
|
-
return openBlock(), createElementBlock("div", {
|
|
1240
|
-
ref_key: "containerRef",
|
|
1241
|
-
ref: containerRef,
|
|
1242
|
-
style: normalizeStyle(unref(containerStyle))
|
|
1243
|
-
}, [unref(formColumns).length > 0 ? (openBlock(), createElementBlock(Fragment, {
|
|
1244
|
-
key: 0
|
|
1245
|
-
}, [createVNode(unref(_sfc_main$2), mergeProps({
|
|
1246
|
-
ref: "form",
|
|
1247
|
-
cache: _ctx.cache,
|
|
1248
|
-
columns: unref(formColumns)
|
|
1249
|
-
}, _ctx.internalFormProps, {
|
|
1250
|
-
onSubmit: _ctx.onSearch
|
|
1251
|
-
}), null, 16, ["cache", "columns", "onSubmit"]), createVNode(unref(Divider), {
|
|
1252
|
-
dashed: "",
|
|
1253
|
-
style: {
|
|
1254
|
-
"margin": "0"
|
|
1255
|
-
}
|
|
1256
|
-
})], 64)) : createCommentVNode("", true), _ctx.$slots.buttons || _ctx.$slots.tools ? (openBlock(), createElementBlock("div", _hoisted_1$1, [renderSlot(_ctx.$slots, "buttons"), renderSlot(_ctx.$slots, "tools")])) : createCommentVNode("", true), createVNode(unref(Table), mergeProps({
|
|
1257
|
-
ref_key: "tableRef",
|
|
1258
|
-
ref: tableRef,
|
|
1259
|
-
style: unref(tableStyle),
|
|
1260
|
-
columns: columns.value,
|
|
1261
|
-
loading: _ctx.loading,
|
|
1262
|
-
dataSource: _ctx.tableData,
|
|
1263
|
-
scroll: scroll.value
|
|
1264
|
-
}, {
|
|
1265
|
-
..._ctx.$attrs,
|
|
1266
|
-
...tableProps.value
|
|
1267
|
-
}, {
|
|
1268
|
-
onChange: _cache[0] || (_cache[0] = ($event) => ({
|
|
1269
|
-
onChange: _ctx.onChange
|
|
1270
|
-
})),
|
|
1271
|
-
onExpand: _cache[1] || (_cache[1] = ($event) => ({
|
|
1272
|
-
onExpand: _ctx.onExpand
|
|
1273
|
-
})),
|
|
1274
|
-
onExpandedRowsChange: _cache[2] || (_cache[2] = ($event) => ({
|
|
1275
|
-
onExpandedRowsChange: _ctx.onExpandedRowsChange
|
|
1276
|
-
})),
|
|
1277
|
-
onResizeColumn: _cache[3] || (_cache[3] = ($event) => ({
|
|
1278
|
-
onResizeColumn: _ctx.onResizeColumn
|
|
1279
|
-
}))
|
|
1280
|
-
}), createSlots({
|
|
1281
|
-
bodyCell: withCtx((scopedProps) => [unref(editRowMap).size === 0 ? renderSlot(_ctx.$slots, "bodyCell", normalizeProps(mergeProps({
|
|
1282
|
-
key: 0
|
|
1283
|
-
}, scopedProps))) : unref(editRowMap).has(scopedProps.record) ? (openBlock(), createBlock(resolveDynamicComponent(unref(EditBodyCell)), normalizeProps(mergeProps({
|
|
1284
|
-
key: 1
|
|
1285
|
-
}, scopedProps)), null, 16)) : createCommentVNode("", true)]),
|
|
1286
|
-
_: 2
|
|
1287
|
-
}, [renderList(_ctx.$slots, (_, name) => {
|
|
1288
|
-
return {
|
|
1289
|
-
name,
|
|
1290
|
-
fn: withCtx((slotData) => [!definedSlots.includes(name) ? renderSlot(_ctx.$slots, name, normalizeProps(mergeProps({
|
|
1291
|
-
key: 0
|
|
1292
|
-
}, slotData))) : createCommentVNode("", true)])
|
|
1293
|
-
};
|
|
1294
|
-
})]), 1040, ["style", "columns", "loading", "dataSource", "scroll"])], 4);
|
|
1295
|
-
};
|
|
1296
|
-
}
|
|
1297
|
-
});
|
|
1298
933
|
const _hoisted_1 = {
|
|
1299
934
|
key: 1,
|
|
1300
935
|
style: {
|
|
@@ -1437,6 +1072,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1437
1072
|
};
|
|
1438
1073
|
});
|
|
1439
1074
|
});
|
|
1075
|
+
const editRules = computed(() => {
|
|
1076
|
+
const entries = props.columns.map((column) => {
|
|
1077
|
+
const editObj = column.edit;
|
|
1078
|
+
return [column.field, toValue(editObj == null ? void 0 : editObj.rules)];
|
|
1079
|
+
});
|
|
1080
|
+
return Object.fromEntries(entries);
|
|
1081
|
+
});
|
|
1440
1082
|
const internalTableProps = computed(() => {
|
|
1441
1083
|
const {
|
|
1442
1084
|
columnConfig,
|
|
@@ -1472,7 +1114,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1472
1114
|
rowConfig: {
|
|
1473
1115
|
keyField: props.keyField,
|
|
1474
1116
|
...rowConfig
|
|
1475
|
-
}
|
|
1117
|
+
},
|
|
1118
|
+
editRules: editRules.value
|
|
1476
1119
|
};
|
|
1477
1120
|
});
|
|
1478
1121
|
let containerStyle = {
|
|
@@ -1544,7 +1187,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1544
1187
|
style: normalizeStyle(unref(containerStyle))
|
|
1545
1188
|
}, [unref(formColumns).length > 0 ? (openBlock(), createElementBlock(Fragment, {
|
|
1546
1189
|
key: 0
|
|
1547
|
-
}, [createVNode(unref(_sfc_main$
|
|
1190
|
+
}, [createVNode(unref(_sfc_main$1), mergeProps({
|
|
1548
1191
|
ref: "search",
|
|
1549
1192
|
cache: _ctx.cache,
|
|
1550
1193
|
columns: unref(formColumns),
|
|
@@ -1605,9 +1248,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1605
1248
|
}
|
|
1606
1249
|
});
|
|
1607
1250
|
export {
|
|
1608
|
-
_sfc_main$
|
|
1609
|
-
_sfc_main$
|
|
1610
|
-
_sfc_main$1 as FtAntdTable,
|
|
1251
|
+
_sfc_main$2 as FtAntdForm,
|
|
1252
|
+
_sfc_main$1 as FtAntdFormSearch,
|
|
1611
1253
|
_sfc_main as FtVxeTable,
|
|
1612
1254
|
defineFormItem,
|
|
1613
1255
|
editMap,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Refs } from '@ftjs/core';
|
|
2
|
-
import { InputProps, SelectProps, SwitchProps } from 'ant-design-vue';
|
|
3
|
-
import { Component } from 'vue';
|
|
4
|
-
|
|
2
|
+
import { InputProps, SelectProps, SwitchProps, InputNumberProps } from 'ant-design-vue';
|
|
3
|
+
import { Component, MaybeRefOrGetter } from 'vue';
|
|
4
|
+
import { VxeTableDefines } from 'vxe-table';
|
|
5
|
+
export interface Edit<Type, Props, Row extends Record<string, any>> {
|
|
5
6
|
type: Type;
|
|
6
7
|
field?: string;
|
|
7
8
|
props?: Props;
|
|
@@ -13,11 +14,16 @@ export interface Edit<Type, Props> {
|
|
|
13
14
|
* 设置值转化
|
|
14
15
|
*/
|
|
15
16
|
valueSetter?: (value: any) => any;
|
|
17
|
+
/**
|
|
18
|
+
* 表单验证规则,仅 vxe-table 可用
|
|
19
|
+
*/
|
|
20
|
+
rules?: MaybeRefOrGetter<VxeTableDefines.ValidatorRule<Row>[]>;
|
|
16
21
|
}
|
|
17
22
|
export interface EditMap<_TableData extends Record<string, any>> {
|
|
18
|
-
input: Edit<"input", Refs<InputProps
|
|
19
|
-
select: Edit<"select", Refs<SelectProps
|
|
20
|
-
switch: Edit<"switch", Refs<SwitchProps
|
|
23
|
+
input: Edit<"input", Refs<InputProps>, _TableData>;
|
|
24
|
+
select: Edit<"select", Refs<SelectProps>, _TableData>;
|
|
25
|
+
switch: Edit<"switch", Refs<SwitchProps>, _TableData>;
|
|
26
|
+
"input-number": Edit<"input-number", Refs<InputNumberProps>, _TableData>;
|
|
21
27
|
}
|
|
22
28
|
export interface ComponentInfo {
|
|
23
29
|
model?: string;
|
|
@@ -2,7 +2,7 @@ import { ExtractColumnType, FtBaseTableProps, FtTableColumn, ValueOf } from '@ft
|
|
|
2
2
|
import { VxeGridProps, VxeGridPropTypes } from 'vxe-table';
|
|
3
3
|
import { FtAntdFormSearchProps } from '../form';
|
|
4
4
|
import { FtAntdFormColumn } from '../form/register';
|
|
5
|
-
import { EditMap } from '
|
|
5
|
+
import { EditMap } from './column-edit';
|
|
6
6
|
/**
|
|
7
7
|
* 列定义
|
|
8
8
|
*/
|
|
@@ -15,7 +15,7 @@ type VxeTableColumn<T extends Record<string, any>, S extends Record<string, any>
|
|
|
15
15
|
/**
|
|
16
16
|
* 内部表格 props
|
|
17
17
|
*/
|
|
18
|
-
interface InternalVxeTableProps<TableData extends Record<string, any>> extends Omit<VxeGridProps<TableData>, "columns" | "minHeight"> {
|
|
18
|
+
interface InternalVxeTableProps<TableData extends Record<string, any>> extends Omit<VxeGridProps<TableData>, "columns" | "minHeight" | "editRules"> {
|
|
19
19
|
}
|
|
20
20
|
export interface FtVxeTableProps<T extends Record<string, any>, S extends Record<string, any>> extends FtBaseTableProps<T, VxeTableColumn<T, S>, FtAntdFormColumn<S>> {
|
|
21
21
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ftjs/antd",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
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.5.
|
|
33
|
+
"@ftjs/core": "0.5.6"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@ant-design/icons-vue": ">=7.0.0",
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { FtAntdTableProps } from './type';
|
|
2
|
-
declare const _default: <T extends Record<string, any>, S extends Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
-
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & FtAntdTableProps<T, S> & Partial<{}>> & import('vue').PublicProps;
|
|
4
|
-
expose(exposed: import('vue').ShallowUnwrapRef<{
|
|
5
|
-
/**
|
|
6
|
-
* 表单示例
|
|
7
|
-
*/
|
|
8
|
-
formRef: Readonly<import('vue').ShallowRef<import('vue').ShallowUnwrapRef<{
|
|
9
|
-
formInstance: import('vue').Ref<import('ant-design-vue').FormInstance | undefined, import('ant-design-vue').FormInstance | undefined>;
|
|
10
|
-
formData: import('vue').WritableComputedRef<any, any>;
|
|
11
|
-
resetToDefault: import('@ftjs/core').ResetToDefault;
|
|
12
|
-
getFormData: import('@ftjs/core').GetFormData<S>;
|
|
13
|
-
setAsDefault: import('@ftjs/core').SetAsDefault<S>;
|
|
14
|
-
}> | null>>;
|
|
15
|
-
/**
|
|
16
|
-
* 刷新表格
|
|
17
|
-
*/
|
|
18
|
-
refresh: () => Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* 设置编辑行
|
|
21
|
-
*/
|
|
22
|
-
setEditRow: (row: any) => void;
|
|
23
|
-
/**
|
|
24
|
-
* 当前全部编辑行
|
|
25
|
-
*/
|
|
26
|
-
editRowMap: Map<T, T>;
|
|
27
|
-
/**
|
|
28
|
-
* 取消编辑行
|
|
29
|
-
*/
|
|
30
|
-
cancelEditRow: (row: T) => void;
|
|
31
|
-
/**
|
|
32
|
-
* 保存编辑行
|
|
33
|
-
*/
|
|
34
|
-
saveEditRow: (row: T) => void;
|
|
35
|
-
/**
|
|
36
|
-
* 滚动到指定行
|
|
37
|
-
*/
|
|
38
|
-
scrollToRow: (row: any) => void;
|
|
39
|
-
/**
|
|
40
|
-
* 滚动到指定行索引
|
|
41
|
-
*/
|
|
42
|
-
scrollToIndex: (index: number) => void;
|
|
43
|
-
}>): void;
|
|
44
|
-
attrs: any;
|
|
45
|
-
slots: {
|
|
46
|
-
[x: string]: ((props: any) => any) | undefined;
|
|
47
|
-
[x: number]: ((props: any) => any) | undefined;
|
|
48
|
-
buttons?: ((props: {}) => any) | undefined;
|
|
49
|
-
tools?: ((props: {}) => any) | undefined;
|
|
50
|
-
bodyCell?: ((props: {
|
|
51
|
-
text: any;
|
|
52
|
-
value: any;
|
|
53
|
-
record: Record<string, any>;
|
|
54
|
-
index: number;
|
|
55
|
-
column: import('ant-design-vue').ColumnType<any>;
|
|
56
|
-
}) => any) | undefined;
|
|
57
|
-
};
|
|
58
|
-
emit: {};
|
|
59
|
-
}>) => import('vue').VNode & {
|
|
60
|
-
__ctx?: Awaited<typeof __VLS_setup>;
|
|
61
|
-
};
|
|
62
|
-
export default _default;
|
|
63
|
-
type __VLS_PrettifyLocal<T> = {
|
|
64
|
-
[K in keyof T]: T[K];
|
|
65
|
-
} & {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { ValueOf, ExtractColumnType, FtBaseTableProps, FtTableColumn } from '@ftjs/core';
|
|
2
|
-
import { TableColumnType, TableProps as AntTableProps } from 'ant-design-vue';
|
|
3
|
-
import { FtAntdFormSearchProps } from '../form';
|
|
4
|
-
import { FtAntdFormColumn } from '../form/register';
|
|
5
|
-
import { EditMap } from './column-edit';
|
|
6
|
-
/**
|
|
7
|
-
* 列定义
|
|
8
|
-
*/
|
|
9
|
-
export interface FtAntdTableColumn<T extends Record<string, any>, S extends Record<string, any>> extends FtTableColumn<T, FtAntdFormColumn<S> | ExtractColumnType<FtAntdFormColumn<S>>>, Omit<TableColumnType<T>, "title" | "dataIndex"> {
|
|
10
|
-
/**
|
|
11
|
-
* 行内编辑
|
|
12
|
-
*/
|
|
13
|
-
edit?: keyof EditMap<T> | ValueOf<EditMap<T>>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* 内部表格 props
|
|
17
|
-
*/
|
|
18
|
-
interface InternalTableProps<TableData extends Record<string, any>> extends Omit<AntTableProps<TableData>, "columns" | "pagination" | "loading"> {
|
|
19
|
-
}
|
|
20
|
-
export interface FtAntdTableProps<T extends Record<string, any>, S extends Record<string, any> = T> extends FtBaseTableProps<T, FtAntdTableColumn<T, S>, FtAntdFormColumn<S>> {
|
|
21
|
-
/**
|
|
22
|
-
* 是否初始化搜索
|
|
23
|
-
*
|
|
24
|
-
* @default true
|
|
25
|
-
*/
|
|
26
|
-
initSearch?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* 是否自适应高度
|
|
29
|
-
*
|
|
30
|
-
* 1. 父元素(flex column布局)剩余高度
|
|
31
|
-
* 2. 普通布局,占据父元素 100% 高度
|
|
32
|
-
*
|
|
33
|
-
* 可以通过 {@link minHeight} 控制最小高度,避免高度不够展示内容
|
|
34
|
-
* @default true
|
|
35
|
-
*/
|
|
36
|
-
autoHeight?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* 自适应父元素(flex布局)剩余高度时,最小高度
|
|
39
|
-
* @default 210
|
|
40
|
-
*/
|
|
41
|
-
minHeight?: number;
|
|
42
|
-
/**
|
|
43
|
-
* 是否隐藏分页
|
|
44
|
-
* @default false
|
|
45
|
-
*/
|
|
46
|
-
hidePagination?: boolean;
|
|
47
|
-
internalTableProps?: InternalTableProps<T>;
|
|
48
|
-
internalFormProps?: FtAntdFormSearchProps<S>;
|
|
49
|
-
onChange?: AntTableProps<T>["onChange"];
|
|
50
|
-
onExpand?: AntTableProps<T>["onExpand"];
|
|
51
|
-
onExpandedRowsChange?: AntTableProps<T>["onExpandedRowsChange"];
|
|
52
|
-
onResizeColumn?: AntTableProps<T>["onResizeColumn"];
|
|
53
|
-
onSearch?: () => void;
|
|
54
|
-
}
|
|
55
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FtAntdTableProps } from './type';
|
|
2
|
-
export declare function useEdit<P extends FtAntdTableProps<any, any>>(props: P): {
|
|
3
|
-
editRowMap: Map<P["tableData"][number], P["tableData"][number]>;
|
|
4
|
-
setEditRow: (row: P["tableData"][number]) => void;
|
|
5
|
-
EditBodyCell: (scopeProps: {
|
|
6
|
-
text: any;
|
|
7
|
-
value: any;
|
|
8
|
-
record: Record<string, any>;
|
|
9
|
-
index: number;
|
|
10
|
-
column: import('ant-design-vue').ColumnType<any>;
|
|
11
|
-
}) => any;
|
|
12
|
-
cancelEditRow: (row: P["tableData"][number]) => void;
|
|
13
|
-
saveEditRow: (row: P["tableData"][number]) => void;
|
|
14
|
-
};
|