@ftjs/antd 0.1.3 → 0.2.1
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/antd-table/column-edit.d.ts +12 -3
- package/dist/form/components/upload.d.ts +2 -8
- package/dist/form/style.d.ts +1 -0
- package/dist/form/utils.d.ts +2 -0
- package/dist/index.js +204 -72
- package/package.json +2 -2
|
@@ -1,14 +1,23 @@
|
|
|
1
|
+
import { Refs } from '@ftjs/core';
|
|
1
2
|
import { InputProps, SelectProps, SwitchProps } from 'ant-design-vue';
|
|
2
3
|
import { Component } from 'vue';
|
|
3
4
|
export interface Edit<Type, Props> {
|
|
4
5
|
type: Type;
|
|
5
6
|
field?: string;
|
|
6
7
|
props?: Props;
|
|
8
|
+
/**
|
|
9
|
+
* 获取值转化
|
|
10
|
+
*/
|
|
11
|
+
valueGetter?: (value: any) => any;
|
|
12
|
+
/**
|
|
13
|
+
* 设置值转化
|
|
14
|
+
*/
|
|
15
|
+
valueSetter?: (value: any) => any;
|
|
7
16
|
}
|
|
8
17
|
export interface EditMap<_TableData extends Record<string, any>> {
|
|
9
|
-
input: Edit<"input", InputProps
|
|
10
|
-
select: Edit<"select", SelectProps
|
|
11
|
-
switch: Edit<"switch", SwitchProps
|
|
18
|
+
input: Edit<"input", Refs<InputProps>>;
|
|
19
|
+
select: Edit<"select", Refs<SelectProps>>;
|
|
20
|
+
switch: Edit<"switch", Refs<SwitchProps>>;
|
|
12
21
|
}
|
|
13
22
|
export interface ComponentInfo {
|
|
14
23
|
model?: string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Refs } from '@ftjs/core';
|
|
1
|
+
import { CommonSlots, Refs } from '@ftjs/core';
|
|
2
2
|
import { UploadProps } from 'ant-design-vue';
|
|
3
|
-
import { VNodeChild } from 'vue';
|
|
4
3
|
import { AntdColumnBase } from '../register';
|
|
5
4
|
export interface FtFormColumnUpload<T extends Record<string, any>> extends AntdColumnBase<T> {
|
|
6
5
|
/**
|
|
@@ -8,12 +7,7 @@ export interface FtFormColumnUpload<T extends Record<string, any>> extends AntdC
|
|
|
8
7
|
*/
|
|
9
8
|
type: "upload";
|
|
10
9
|
props?: Refs<UploadProps>;
|
|
11
|
-
slots:
|
|
12
|
-
default: (ctx: {
|
|
13
|
-
value: any;
|
|
14
|
-
isView: boolean;
|
|
15
|
-
}) => VNodeChild;
|
|
16
|
-
};
|
|
10
|
+
slots: CommonSlots<["default"]>;
|
|
17
11
|
}
|
|
18
12
|
declare const _default: import('vue').DefineSetupFnComponent<import('@ftjs/core').CommonFormItemProps<FtFormColumnUpload<any>>, import('vue').EmitsOptions, {}, import('@ftjs/core').CommonFormItemProps<FtFormColumnUpload<any>> & ({
|
|
19
13
|
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isViewOptionsStyle = "display: flex; gap: 4px;";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, toValue, createVNode, mergeProps, unref, isVNode, ref, useId, Fragment,
|
|
1
|
+
import { computed, toValue, createVNode, mergeProps, unref, createTextVNode, isVNode, ref, useId, Fragment, 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
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";
|
|
@@ -17,8 +17,7 @@ const useFormItemProps = (column) => {
|
|
|
17
17
|
};
|
|
18
18
|
const input = defineFormComponent((props) => {
|
|
19
19
|
const {
|
|
20
|
-
valueComputed
|
|
21
|
-
isView
|
|
20
|
+
valueComputed
|
|
22
21
|
} = useFormItem({
|
|
23
22
|
props
|
|
24
23
|
});
|
|
@@ -27,7 +26,7 @@ const input = defineFormComponent((props) => {
|
|
|
27
26
|
const _props = unrefs(props.column.props);
|
|
28
27
|
const placeholder = `请输入${formItemProps.value.label}`;
|
|
29
28
|
return createVNode(FormItem, formItemProps.value, {
|
|
30
|
-
default: () => [
|
|
29
|
+
default: () => [props.isView ? createVNode("div", null, [valueComputed.value]) : createVNode(Input, mergeProps({
|
|
31
30
|
"value": valueComputed.value,
|
|
32
31
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
33
32
|
"allowClear": true,
|
|
@@ -36,10 +35,10 @@ const input = defineFormComponent((props) => {
|
|
|
36
35
|
});
|
|
37
36
|
};
|
|
38
37
|
});
|
|
38
|
+
const isViewOptionsStyle = "display: flex; gap: 4px;";
|
|
39
39
|
const select = defineFormComponent((props) => {
|
|
40
40
|
const {
|
|
41
|
-
valueComputed
|
|
42
|
-
isView
|
|
41
|
+
valueComputed
|
|
43
42
|
} = useFormItem({
|
|
44
43
|
props
|
|
45
44
|
});
|
|
@@ -47,7 +46,7 @@ const select = defineFormComponent((props) => {
|
|
|
47
46
|
const placeholder = computed(() => {
|
|
48
47
|
return `请选择${formItemProps.value.label}`;
|
|
49
48
|
});
|
|
50
|
-
const
|
|
49
|
+
const isViewTextVNode = computed(() => {
|
|
51
50
|
var _a, _b;
|
|
52
51
|
const options = unref((_a = props.column.props) == null ? void 0 : _a.options);
|
|
53
52
|
const isMultiple = ((_b = props.column.props) == null ? void 0 : _b.mode) === "multiple";
|
|
@@ -55,15 +54,17 @@ const select = defineFormComponent((props) => {
|
|
|
55
54
|
if (options) {
|
|
56
55
|
return arr.map((e) => {
|
|
57
56
|
const option = options.find((o) => o.value === e);
|
|
58
|
-
return option == null ? void 0 : option.label;
|
|
59
|
-
}).filter(Boolean)
|
|
57
|
+
return createVNode("span", null, [option == null ? void 0 : option.label]);
|
|
58
|
+
}).filter(Boolean);
|
|
60
59
|
}
|
|
61
60
|
return valueComputed.value;
|
|
62
61
|
});
|
|
63
62
|
return () => {
|
|
64
63
|
const _props = unrefs(props.column.props);
|
|
65
64
|
return createVNode(FormItem, formItemProps.value, {
|
|
66
|
-
default: () => [
|
|
65
|
+
default: () => [props.isView ? createVNode("div", {
|
|
66
|
+
"style": isViewOptionsStyle
|
|
67
|
+
}, [isViewTextVNode.value]) : createVNode(Select, mergeProps({
|
|
67
68
|
"value": valueComputed.value,
|
|
68
69
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
69
70
|
"placeholder": placeholder.value
|
|
@@ -73,8 +74,7 @@ const select = defineFormComponent((props) => {
|
|
|
73
74
|
});
|
|
74
75
|
const datePicker = defineFormComponent((props) => {
|
|
75
76
|
const {
|
|
76
|
-
valueComputed
|
|
77
|
-
isView
|
|
77
|
+
valueComputed
|
|
78
78
|
} = useFormItem({
|
|
79
79
|
props
|
|
80
80
|
});
|
|
@@ -85,7 +85,7 @@ const datePicker = defineFormComponent((props) => {
|
|
|
85
85
|
...unrefs(props.column.props)
|
|
86
86
|
};
|
|
87
87
|
return createVNode(FormItem, formItemProps.value, {
|
|
88
|
-
default: () => [
|
|
88
|
+
default: () => [props.isView ? createVNode("div", null, [valueComputed.value]) : (
|
|
89
89
|
// @ts-expect-error 类型推断错误
|
|
90
90
|
createVNode(DatePicker, mergeProps({
|
|
91
91
|
"value": valueComputed.value,
|
|
@@ -97,12 +97,17 @@ const datePicker = defineFormComponent((props) => {
|
|
|
97
97
|
});
|
|
98
98
|
const rangePicker = defineFormComponent((props) => {
|
|
99
99
|
const {
|
|
100
|
-
valueComputed
|
|
101
|
-
isView
|
|
100
|
+
valueComputed
|
|
102
101
|
} = useFormItem({
|
|
103
102
|
props
|
|
104
103
|
});
|
|
105
104
|
const formItemProps = useFormItemProps(props.column);
|
|
105
|
+
const viewText = computed(() => {
|
|
106
|
+
if (props.isView) {
|
|
107
|
+
return valueComputed.value.join(" ~ ");
|
|
108
|
+
}
|
|
109
|
+
return "";
|
|
110
|
+
});
|
|
106
111
|
return () => {
|
|
107
112
|
const unrefsProps = unrefs(props.column.props);
|
|
108
113
|
const _props = {
|
|
@@ -114,31 +119,46 @@ const rangePicker = defineFormComponent((props) => {
|
|
|
114
119
|
} : false
|
|
115
120
|
};
|
|
116
121
|
return createVNode(FormItem, formItemProps.value, {
|
|
117
|
-
default: () => [
|
|
122
|
+
default: () => [props.isView ? createVNode("div", null, [viewText.value]) : createVNode(RangePicker, mergeProps({
|
|
118
123
|
"value": valueComputed.value,
|
|
119
124
|
"onUpdate:value": ($event) => valueComputed.value = $event
|
|
120
125
|
}, _props), null)]
|
|
121
126
|
});
|
|
122
127
|
};
|
|
123
128
|
});
|
|
129
|
+
function isSimpleOption(option) {
|
|
130
|
+
return typeof option === "string" || typeof option === "number";
|
|
131
|
+
}
|
|
124
132
|
const radio = defineFormComponent((props) => {
|
|
125
133
|
const {
|
|
126
|
-
valueComputed
|
|
127
|
-
isView
|
|
134
|
+
valueComputed
|
|
128
135
|
} = useFormItem({
|
|
129
136
|
props
|
|
130
137
|
});
|
|
131
138
|
const formItemProps = useFormItemProps(props.column);
|
|
132
|
-
const
|
|
133
|
-
var _a;
|
|
139
|
+
const isViewTextVNode = computed(() => {
|
|
134
140
|
const options = unref(props.column.props.options);
|
|
135
141
|
if (!options) return valueComputed.value;
|
|
136
|
-
|
|
142
|
+
let vNode;
|
|
143
|
+
options.some((option) => {
|
|
144
|
+
if (isSimpleOption(option)) {
|
|
145
|
+
if (option === valueComputed.value) {
|
|
146
|
+
vNode = option;
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
if (option.value === valueComputed.value) {
|
|
151
|
+
vNode = option.label;
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return vNode;
|
|
137
157
|
});
|
|
138
158
|
return () => {
|
|
139
159
|
const _props = unrefs(props.column.props);
|
|
140
160
|
return createVNode(FormItem, formItemProps.value, {
|
|
141
|
-
default: () => [
|
|
161
|
+
default: () => [props.isView ? createVNode("div", null, [isViewTextVNode.value]) : createVNode(Radio.Group, mergeProps({
|
|
142
162
|
"value": valueComputed.value,
|
|
143
163
|
"onUpdate:value": ($event) => valueComputed.value = $event
|
|
144
164
|
}, _props), null)]
|
|
@@ -147,8 +167,7 @@ const radio = defineFormComponent((props) => {
|
|
|
147
167
|
});
|
|
148
168
|
const textarea = defineFormComponent((props) => {
|
|
149
169
|
const {
|
|
150
|
-
valueComputed
|
|
151
|
-
isView
|
|
170
|
+
valueComputed
|
|
152
171
|
} = useFormItem({
|
|
153
172
|
props
|
|
154
173
|
});
|
|
@@ -157,7 +176,7 @@ const textarea = defineFormComponent((props) => {
|
|
|
157
176
|
const _props = unrefs(props.column.props);
|
|
158
177
|
const placeholder = `请输入${formItemProps.value.label}`;
|
|
159
178
|
return createVNode(FormItem, formItemProps.value, {
|
|
160
|
-
default: () => [
|
|
179
|
+
default: () => [props.isView ? createVNode("div", null, [valueComputed.value]) : createVNode(Textarea, mergeProps({
|
|
161
180
|
"value": valueComputed.value,
|
|
162
181
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
163
182
|
"allowClear": true,
|
|
@@ -173,31 +192,41 @@ function _isSlot(s) {
|
|
|
173
192
|
const upload = defineFormComponent((props) => {
|
|
174
193
|
const {
|
|
175
194
|
valueComputed,
|
|
176
|
-
|
|
195
|
+
slots
|
|
177
196
|
} = useFormItem({
|
|
178
197
|
props
|
|
179
198
|
});
|
|
180
199
|
const formItemProps = useFormItemProps(props.column);
|
|
200
|
+
const disabled = computed(() => {
|
|
201
|
+
var _a;
|
|
202
|
+
return props.isView || toValue((_a = props.column.props) == null ? void 0 : _a.disabled);
|
|
203
|
+
});
|
|
181
204
|
return () => {
|
|
182
|
-
let _slot;
|
|
183
205
|
const _props = unrefs(props.column.props);
|
|
184
206
|
return createVNode(FormItem, formItemProps.value, {
|
|
185
|
-
default: () => [
|
|
207
|
+
default: () => [props.isView ? createVNode(Upload, mergeProps({
|
|
208
|
+
"file-list": valueComputed.value
|
|
209
|
+
}, _props, {
|
|
210
|
+
"disabled": true
|
|
211
|
+
}), {
|
|
212
|
+
default: () => {
|
|
213
|
+
var _a;
|
|
214
|
+
return [!((_a = valueComputed.value) == null ? void 0 : _a.length) && createVNode("div", null, [createTextVNode("-")])];
|
|
215
|
+
}
|
|
216
|
+
}) : createVNode(Upload, mergeProps({
|
|
186
217
|
"file-list": valueComputed.value,
|
|
187
218
|
"onUpdate:file-list": ($event) => valueComputed.value = $event
|
|
188
|
-
}, _props
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
default: () => [_slot]
|
|
219
|
+
}, _props, {
|
|
220
|
+
"disabled": disabled.value
|
|
221
|
+
}), _isSlot(slots) ? slots : {
|
|
222
|
+
default: () => [slots]
|
|
193
223
|
})]
|
|
194
224
|
});
|
|
195
225
|
};
|
|
196
226
|
});
|
|
197
227
|
const cascader = defineFormComponent((props) => {
|
|
198
228
|
const {
|
|
199
|
-
valueComputed
|
|
200
|
-
isView
|
|
229
|
+
valueComputed
|
|
201
230
|
} = useFormItem({
|
|
202
231
|
props
|
|
203
232
|
});
|
|
@@ -205,8 +234,31 @@ const cascader = defineFormComponent((props) => {
|
|
|
205
234
|
return () => {
|
|
206
235
|
const _props = unrefs(props.column.props);
|
|
207
236
|
const placeholder = `请选择${formItemProps.value.label}`;
|
|
237
|
+
const getTextFromOptions = (options, value, level = 0) => {
|
|
238
|
+
if (!options || !value || level >= value.length) return void 0;
|
|
239
|
+
const currentValue = value[level];
|
|
240
|
+
const currentOption = options.find((option) => option.value === currentValue);
|
|
241
|
+
if (!currentOption) return void 0;
|
|
242
|
+
if (level === value.length - 1) {
|
|
243
|
+
return currentOption.label;
|
|
244
|
+
}
|
|
245
|
+
if (currentOption.children && currentOption.children.length > 0) {
|
|
246
|
+
const childText = getTextFromOptions(currentOption.children, value, level + 1);
|
|
247
|
+
if (childText) {
|
|
248
|
+
return `${currentOption.label} / ${childText}`;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return currentOption.label;
|
|
252
|
+
};
|
|
253
|
+
const isViewText = computed(() => {
|
|
254
|
+
if (props.isView && valueComputed.value) {
|
|
255
|
+
const options = (_props == null ? void 0 : _props.options) || [];
|
|
256
|
+
return getTextFromOptions(options, valueComputed.value);
|
|
257
|
+
}
|
|
258
|
+
return "-";
|
|
259
|
+
});
|
|
208
260
|
return createVNode(FormItem, formItemProps.value, {
|
|
209
|
-
default: () => [
|
|
261
|
+
default: () => [props.isView ? createVNode("div", null, [isViewText.value]) : createVNode(Cascader, mergeProps({
|
|
210
262
|
"value": valueComputed.value,
|
|
211
263
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
212
264
|
"placeholder": placeholder
|
|
@@ -216,20 +268,18 @@ const cascader = defineFormComponent((props) => {
|
|
|
216
268
|
});
|
|
217
269
|
const autoComplete = defineFormComponent((props) => {
|
|
218
270
|
const {
|
|
219
|
-
valueComputed
|
|
220
|
-
isView
|
|
271
|
+
valueComputed
|
|
221
272
|
} = useFormItem({
|
|
222
273
|
props
|
|
223
274
|
});
|
|
224
275
|
const formItemProps = useFormItemProps(props.column);
|
|
225
276
|
return () => {
|
|
226
277
|
const _props = unrefs(props.column.props);
|
|
227
|
-
const placeholder = `请输入${formItemProps.value.label}`;
|
|
228
278
|
return createVNode(FormItem, formItemProps.value, {
|
|
229
|
-
default: () => [
|
|
279
|
+
default: () => [props.isView ? createVNode("div", null, [valueComputed.value || "-"]) : createVNode(AutoComplete, mergeProps({
|
|
230
280
|
"value": valueComputed.value,
|
|
231
281
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
232
|
-
"placeholder":
|
|
282
|
+
"placeholder": `请输入${formItemProps.value.label}`,
|
|
233
283
|
"allowClear": true
|
|
234
284
|
}, _props), null)]
|
|
235
285
|
});
|
|
@@ -237,16 +287,48 @@ const autoComplete = defineFormComponent((props) => {
|
|
|
237
287
|
});
|
|
238
288
|
const checkbox = defineFormComponent((props) => {
|
|
239
289
|
const {
|
|
240
|
-
valueComputed
|
|
241
|
-
isView
|
|
290
|
+
valueComputed
|
|
242
291
|
} = useFormItem({
|
|
243
292
|
props
|
|
244
293
|
});
|
|
245
294
|
const formItemProps = useFormItemProps(props.column);
|
|
295
|
+
const options = computed(() => {
|
|
296
|
+
var _a;
|
|
297
|
+
if (!((_a = props.column.props) == null ? void 0 : _a.options)) {
|
|
298
|
+
console.warn("checkbox 组件的 options 属性不能为空");
|
|
299
|
+
return [];
|
|
300
|
+
}
|
|
301
|
+
return toValue(props.column.props.options) ?? [];
|
|
302
|
+
});
|
|
246
303
|
return () => {
|
|
247
304
|
const _props = unrefs(props.column.props);
|
|
305
|
+
const isViewTextVNodeMap = computed(() => {
|
|
306
|
+
let result = [];
|
|
307
|
+
if (props.isView && valueComputed.value) {
|
|
308
|
+
result = valueComputed.value.map((v) => {
|
|
309
|
+
let text = "";
|
|
310
|
+
options.value.some((item) => {
|
|
311
|
+
if (isSimpleOption(item)) {
|
|
312
|
+
if (item === v) {
|
|
313
|
+
text = item;
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
} else {
|
|
317
|
+
if (item.value === v) {
|
|
318
|
+
text = item.label;
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
return text;
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
return result.length > 0 ? result : ["-"];
|
|
327
|
+
});
|
|
248
328
|
return createVNode(FormItem, formItemProps.value, {
|
|
249
|
-
default: () => [
|
|
329
|
+
default: () => [props.isView ? createVNode("div", {
|
|
330
|
+
"style": isViewOptionsStyle
|
|
331
|
+
}, [isViewTextVNodeMap.value.map((v) => createVNode("span", null, [v]))]) : createVNode(CheckboxGroup, mergeProps({
|
|
250
332
|
"value": valueComputed.value,
|
|
251
333
|
"onUpdate:value": ($event) => valueComputed.value = $event
|
|
252
334
|
}, _props), null)]
|
|
@@ -255,8 +337,7 @@ const checkbox = defineFormComponent((props) => {
|
|
|
255
337
|
});
|
|
256
338
|
const inputNumber = defineFormComponent((props) => {
|
|
257
339
|
const {
|
|
258
|
-
valueComputed
|
|
259
|
-
isView
|
|
340
|
+
valueComputed
|
|
260
341
|
} = useFormItem({
|
|
261
342
|
props
|
|
262
343
|
});
|
|
@@ -264,7 +345,7 @@ const inputNumber = defineFormComponent((props) => {
|
|
|
264
345
|
return () => {
|
|
265
346
|
const _props = unrefs(props.column.props);
|
|
266
347
|
return createVNode(FormItem, formItemProps.value, {
|
|
267
|
-
default: () => [
|
|
348
|
+
default: () => [props.isView ? createVNode("div", null, [valueComputed.value]) : createVNode(InputNumber, mergeProps({
|
|
268
349
|
"value": valueComputed.value,
|
|
269
350
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
270
351
|
"placeholder": `请输入${formItemProps.value.label}`
|
|
@@ -274,8 +355,7 @@ const inputNumber = defineFormComponent((props) => {
|
|
|
274
355
|
});
|
|
275
356
|
const mentions = defineFormComponent((props) => {
|
|
276
357
|
const {
|
|
277
|
-
valueComputed
|
|
278
|
-
isView
|
|
358
|
+
valueComputed
|
|
279
359
|
} = useFormItem({
|
|
280
360
|
props
|
|
281
361
|
});
|
|
@@ -283,7 +363,7 @@ const mentions = defineFormComponent((props) => {
|
|
|
283
363
|
return () => {
|
|
284
364
|
const _props = unrefs(props.column.props);
|
|
285
365
|
return createVNode(FormItem, formItemProps.value, {
|
|
286
|
-
default: () => [
|
|
366
|
+
default: () => [props.isView ? createVNode("div", null, [valueComputed.value]) : createVNode(Mentions, mergeProps({
|
|
287
367
|
"value": valueComputed.value,
|
|
288
368
|
"onUpdate:value": ($event) => valueComputed.value = $event
|
|
289
369
|
}, _props), null)]
|
|
@@ -292,8 +372,7 @@ const mentions = defineFormComponent((props) => {
|
|
|
292
372
|
});
|
|
293
373
|
const rate = defineFormComponent((props) => {
|
|
294
374
|
const {
|
|
295
|
-
valueComputed
|
|
296
|
-
isView
|
|
375
|
+
valueComputed
|
|
297
376
|
} = useFormItem({
|
|
298
377
|
props
|
|
299
378
|
});
|
|
@@ -304,15 +383,14 @@ const rate = defineFormComponent((props) => {
|
|
|
304
383
|
default: () => [createVNode(Rate, mergeProps({
|
|
305
384
|
"value": valueComputed.value,
|
|
306
385
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
307
|
-
"disabled": isView
|
|
386
|
+
"disabled": props.isView
|
|
308
387
|
}, _props), null)]
|
|
309
388
|
});
|
|
310
389
|
};
|
|
311
390
|
});
|
|
312
391
|
const slider = defineFormComponent((props) => {
|
|
313
392
|
const {
|
|
314
|
-
valueComputed
|
|
315
|
-
isView
|
|
393
|
+
valueComputed
|
|
316
394
|
} = useFormItem({
|
|
317
395
|
props
|
|
318
396
|
});
|
|
@@ -320,7 +398,7 @@ const slider = defineFormComponent((props) => {
|
|
|
320
398
|
return () => {
|
|
321
399
|
const _props = unrefs(props.column.props);
|
|
322
400
|
return createVNode(FormItem, formItemProps.value, {
|
|
323
|
-
default: () => [
|
|
401
|
+
default: () => [props.isView ? createVNode("div", null, [valueComputed.value]) : createVNode(Slider, mergeProps({
|
|
324
402
|
"value": valueComputed.value,
|
|
325
403
|
"onUpdate:value": ($event) => valueComputed.value = $event
|
|
326
404
|
}, _props), null)]
|
|
@@ -329,16 +407,22 @@ const slider = defineFormComponent((props) => {
|
|
|
329
407
|
});
|
|
330
408
|
const switchComponent = defineFormComponent((props) => {
|
|
331
409
|
const {
|
|
332
|
-
valueComputed
|
|
333
|
-
isView
|
|
410
|
+
valueComputed
|
|
334
411
|
} = useFormItem({
|
|
335
412
|
props
|
|
336
413
|
});
|
|
337
414
|
const formItemProps = useFormItemProps(props.column);
|
|
415
|
+
const isViewText = computed(() => {
|
|
416
|
+
var _a, _b;
|
|
417
|
+
if (props.isView) {
|
|
418
|
+
return valueComputed.value ? ((_a = props.column.props) == null ? void 0 : _a.checkedChildren) || "是" : ((_b = props.column.props) == null ? void 0 : _b.unCheckedChildren) || "否";
|
|
419
|
+
}
|
|
420
|
+
return "-";
|
|
421
|
+
});
|
|
338
422
|
return () => {
|
|
339
423
|
const _props = unrefs(props.column.props);
|
|
340
424
|
return createVNode(FormItem, formItemProps.value, {
|
|
341
|
-
default: () => [
|
|
425
|
+
default: () => [props.isView ? createVNode("div", null, [isViewText.value]) : createVNode(Switch, mergeProps({
|
|
342
426
|
"checked": valueComputed.value,
|
|
343
427
|
"onUpdate:checked": ($event) => valueComputed.value = $event
|
|
344
428
|
}, _props), null)]
|
|
@@ -347,17 +431,42 @@ const switchComponent = defineFormComponent((props) => {
|
|
|
347
431
|
});
|
|
348
432
|
const treeSelect = defineFormComponent((props) => {
|
|
349
433
|
const {
|
|
350
|
-
valueComputed
|
|
351
|
-
isView
|
|
434
|
+
valueComputed
|
|
352
435
|
} = useFormItem({
|
|
353
436
|
props
|
|
354
437
|
});
|
|
355
438
|
const formItemProps = useFormItemProps(props.column);
|
|
439
|
+
const isViewText = computed(() => {
|
|
440
|
+
var _a, _b;
|
|
441
|
+
if (props.isView && valueComputed.value) {
|
|
442
|
+
const vNodes = [];
|
|
443
|
+
const isMultiple = toValue((_a = props.column.props) == null ? void 0 : _a.multiple);
|
|
444
|
+
const options = toValue((_b = props.column.props) == null ? void 0 : _b.treeData) || [];
|
|
445
|
+
const traverse = (options2, values) => {
|
|
446
|
+
if (vNodes.length === values.length) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
for (const option of options2) {
|
|
450
|
+
if (values.includes(option.value)) {
|
|
451
|
+
vNodes.push(createVNode("span", null, [option.label]));
|
|
452
|
+
}
|
|
453
|
+
if (option.children) {
|
|
454
|
+
traverse(option.children, values);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
traverse(options, isMultiple ? valueComputed.value : [valueComputed.value]);
|
|
459
|
+
return vNodes;
|
|
460
|
+
}
|
|
461
|
+
return ["-"];
|
|
462
|
+
});
|
|
356
463
|
return () => {
|
|
357
464
|
const _props = unrefs(props.column.props);
|
|
358
465
|
const placeholder = `请输入${formItemProps.value.label}`;
|
|
359
466
|
return createVNode(FormItem, formItemProps.value, {
|
|
360
|
-
default: () => [
|
|
467
|
+
default: () => [props.isView ? createVNode("div", {
|
|
468
|
+
"style": isViewOptionsStyle
|
|
469
|
+
}, [isViewText.value]) : createVNode(TreeSelect, mergeProps({
|
|
361
470
|
"value": valueComputed.value,
|
|
362
471
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
363
472
|
"allowClear": true,
|
|
@@ -960,14 +1069,26 @@ function useEdit(tableData) {
|
|
|
960
1069
|
} else {
|
|
961
1070
|
component = componentOrTuple;
|
|
962
1071
|
}
|
|
963
|
-
|
|
964
|
-
|
|
1072
|
+
const {
|
|
1073
|
+
valueGetter,
|
|
1074
|
+
valueSetter
|
|
1075
|
+
} = edit;
|
|
1076
|
+
let value = get(scopeProps.record, field);
|
|
1077
|
+
if (valueGetter) {
|
|
1078
|
+
value = valueGetter(value);
|
|
1079
|
+
}
|
|
1080
|
+
const props = {
|
|
1081
|
+
...unrefs(edit.props),
|
|
965
1082
|
class: "ft-table-edit",
|
|
966
|
-
[model]:
|
|
967
|
-
[`onUpdate:${model}`]: (
|
|
968
|
-
|
|
1083
|
+
[model]: value,
|
|
1084
|
+
[`onUpdate:${model}`]: (value2) => {
|
|
1085
|
+
if (valueSetter) {
|
|
1086
|
+
value2 = valueSetter(value2);
|
|
1087
|
+
}
|
|
1088
|
+
set(scopeProps.record, field, value2);
|
|
969
1089
|
}
|
|
970
|
-
}
|
|
1090
|
+
};
|
|
1091
|
+
return h(component, props);
|
|
971
1092
|
}
|
|
972
1093
|
}
|
|
973
1094
|
};
|
|
@@ -1095,11 +1216,22 @@ const FtVxeTable = defineFtTable((_, ctx) => {
|
|
|
1095
1216
|
component = componentOrTuple;
|
|
1096
1217
|
}
|
|
1097
1218
|
const modelEvent = `onUpdate:${model}`;
|
|
1219
|
+
const {
|
|
1220
|
+
valueGetter,
|
|
1221
|
+
valueSetter
|
|
1222
|
+
} = editObj ?? {};
|
|
1223
|
+
let value = get(row, field);
|
|
1224
|
+
if (valueGetter) {
|
|
1225
|
+
value = valueGetter(value);
|
|
1226
|
+
}
|
|
1098
1227
|
const props = {
|
|
1099
|
-
...editObj.props,
|
|
1100
|
-
[model]:
|
|
1101
|
-
[modelEvent]: (
|
|
1102
|
-
|
|
1228
|
+
...unrefs(editObj.props),
|
|
1229
|
+
[model]: value,
|
|
1230
|
+
[modelEvent]: (value2) => {
|
|
1231
|
+
if (valueSetter) {
|
|
1232
|
+
value2 = valueSetter(value2);
|
|
1233
|
+
}
|
|
1234
|
+
set(row, field, value2);
|
|
1103
1235
|
}
|
|
1104
1236
|
};
|
|
1105
1237
|
return h(component, props);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ftjs/antd",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
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.1
|
|
33
|
+
"@ftjs/core": "0.2.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@ant-design/icons-vue": ">=7.0.0",
|