@ftjs/antd 0.1.3 → 0.2.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/antd-table/column-edit.d.ts +12 -3
- package/dist/form/style.d.ts +1 -0
- package/dist/form/utils.d.ts +2 -0
- package/dist/index.js +198 -76
- 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;
|
|
@@ -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,
|
|
1
|
+
import { computed, toValue, createVNode, mergeProps, unref, createTextVNode, 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,
|
|
@@ -167,37 +186,37 @@ const textarea = defineFormComponent((props) => {
|
|
|
167
186
|
});
|
|
168
187
|
};
|
|
169
188
|
});
|
|
170
|
-
function _isSlot(s) {
|
|
171
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
172
|
-
}
|
|
173
189
|
const upload = defineFormComponent((props) => {
|
|
174
190
|
const {
|
|
175
|
-
valueComputed
|
|
176
|
-
isView
|
|
191
|
+
valueComputed
|
|
177
192
|
} = useFormItem({
|
|
178
193
|
props
|
|
179
194
|
});
|
|
180
195
|
const formItemProps = useFormItemProps(props.column);
|
|
196
|
+
const disabled = computed(() => {
|
|
197
|
+
var _a;
|
|
198
|
+
return props.isView || toValue((_a = props.column.props) == null ? void 0 : _a.disabled);
|
|
199
|
+
});
|
|
181
200
|
return () => {
|
|
182
|
-
let _slot;
|
|
183
201
|
const _props = unrefs(props.column.props);
|
|
184
202
|
return createVNode(FormItem, formItemProps.value, {
|
|
185
|
-
default: () => [
|
|
203
|
+
default: () => [createVNode(Upload, mergeProps({
|
|
186
204
|
"file-list": valueComputed.value,
|
|
187
205
|
"onUpdate:file-list": ($event) => valueComputed.value = $event
|
|
188
|
-
}, _props
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
206
|
+
}, _props, {
|
|
207
|
+
"disabled": disabled.value
|
|
208
|
+
}), {
|
|
209
|
+
default: () => [props.isView ? !valueComputed.value || valueComputed.value.length === 0 ? createVNode("div", null, [createTextVNode("-")]) : null : props.column.slots.default({
|
|
210
|
+
value: valueComputed.value,
|
|
211
|
+
isView: props.isView
|
|
212
|
+
})]
|
|
193
213
|
})]
|
|
194
214
|
});
|
|
195
215
|
};
|
|
196
216
|
});
|
|
197
217
|
const cascader = defineFormComponent((props) => {
|
|
198
218
|
const {
|
|
199
|
-
valueComputed
|
|
200
|
-
isView
|
|
219
|
+
valueComputed
|
|
201
220
|
} = useFormItem({
|
|
202
221
|
props
|
|
203
222
|
});
|
|
@@ -205,8 +224,31 @@ const cascader = defineFormComponent((props) => {
|
|
|
205
224
|
return () => {
|
|
206
225
|
const _props = unrefs(props.column.props);
|
|
207
226
|
const placeholder = `请选择${formItemProps.value.label}`;
|
|
227
|
+
const getTextFromOptions = (options, value, level = 0) => {
|
|
228
|
+
if (!options || !value || level >= value.length) return void 0;
|
|
229
|
+
const currentValue = value[level];
|
|
230
|
+
const currentOption = options.find((option) => option.value === currentValue);
|
|
231
|
+
if (!currentOption) return void 0;
|
|
232
|
+
if (level === value.length - 1) {
|
|
233
|
+
return currentOption.label;
|
|
234
|
+
}
|
|
235
|
+
if (currentOption.children && currentOption.children.length > 0) {
|
|
236
|
+
const childText = getTextFromOptions(currentOption.children, value, level + 1);
|
|
237
|
+
if (childText) {
|
|
238
|
+
return `${currentOption.label} / ${childText}`;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return currentOption.label;
|
|
242
|
+
};
|
|
243
|
+
const isViewText = computed(() => {
|
|
244
|
+
if (props.isView && valueComputed.value) {
|
|
245
|
+
const options = (_props == null ? void 0 : _props.options) || [];
|
|
246
|
+
return getTextFromOptions(options, valueComputed.value);
|
|
247
|
+
}
|
|
248
|
+
return "-";
|
|
249
|
+
});
|
|
208
250
|
return createVNode(FormItem, formItemProps.value, {
|
|
209
|
-
default: () => [
|
|
251
|
+
default: () => [props.isView ? createVNode("div", null, [isViewText.value]) : createVNode(Cascader, mergeProps({
|
|
210
252
|
"value": valueComputed.value,
|
|
211
253
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
212
254
|
"placeholder": placeholder
|
|
@@ -216,20 +258,18 @@ const cascader = defineFormComponent((props) => {
|
|
|
216
258
|
});
|
|
217
259
|
const autoComplete = defineFormComponent((props) => {
|
|
218
260
|
const {
|
|
219
|
-
valueComputed
|
|
220
|
-
isView
|
|
261
|
+
valueComputed
|
|
221
262
|
} = useFormItem({
|
|
222
263
|
props
|
|
223
264
|
});
|
|
224
265
|
const formItemProps = useFormItemProps(props.column);
|
|
225
266
|
return () => {
|
|
226
267
|
const _props = unrefs(props.column.props);
|
|
227
|
-
const placeholder = `请输入${formItemProps.value.label}`;
|
|
228
268
|
return createVNode(FormItem, formItemProps.value, {
|
|
229
|
-
default: () => [
|
|
269
|
+
default: () => [props.isView ? createVNode("div", null, [valueComputed.value || "-"]) : createVNode(AutoComplete, mergeProps({
|
|
230
270
|
"value": valueComputed.value,
|
|
231
271
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
232
|
-
"placeholder":
|
|
272
|
+
"placeholder": `请输入${formItemProps.value.label}`,
|
|
233
273
|
"allowClear": true
|
|
234
274
|
}, _props), null)]
|
|
235
275
|
});
|
|
@@ -237,16 +277,48 @@ const autoComplete = defineFormComponent((props) => {
|
|
|
237
277
|
});
|
|
238
278
|
const checkbox = defineFormComponent((props) => {
|
|
239
279
|
const {
|
|
240
|
-
valueComputed
|
|
241
|
-
isView
|
|
280
|
+
valueComputed
|
|
242
281
|
} = useFormItem({
|
|
243
282
|
props
|
|
244
283
|
});
|
|
245
284
|
const formItemProps = useFormItemProps(props.column);
|
|
285
|
+
const options = computed(() => {
|
|
286
|
+
var _a;
|
|
287
|
+
if (!((_a = props.column.props) == null ? void 0 : _a.options)) {
|
|
288
|
+
console.warn("checkbox 组件的 options 属性不能为空");
|
|
289
|
+
return [];
|
|
290
|
+
}
|
|
291
|
+
return toValue(props.column.props.options) ?? [];
|
|
292
|
+
});
|
|
246
293
|
return () => {
|
|
247
294
|
const _props = unrefs(props.column.props);
|
|
295
|
+
const isViewTextVNodeMap = computed(() => {
|
|
296
|
+
let result = [];
|
|
297
|
+
if (props.isView && valueComputed.value) {
|
|
298
|
+
result = valueComputed.value.map((v) => {
|
|
299
|
+
let text = "";
|
|
300
|
+
options.value.some((item) => {
|
|
301
|
+
if (isSimpleOption(item)) {
|
|
302
|
+
if (item === v) {
|
|
303
|
+
text = item;
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
if (item.value === v) {
|
|
308
|
+
text = item.label;
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
return text;
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
return result.length > 0 ? result : ["-"];
|
|
317
|
+
});
|
|
248
318
|
return createVNode(FormItem, formItemProps.value, {
|
|
249
|
-
default: () => [
|
|
319
|
+
default: () => [props.isView ? createVNode("div", {
|
|
320
|
+
"style": isViewOptionsStyle
|
|
321
|
+
}, [isViewTextVNodeMap.value.map((v) => createVNode("span", null, [v]))]) : createVNode(CheckboxGroup, mergeProps({
|
|
250
322
|
"value": valueComputed.value,
|
|
251
323
|
"onUpdate:value": ($event) => valueComputed.value = $event
|
|
252
324
|
}, _props), null)]
|
|
@@ -255,8 +327,7 @@ const checkbox = defineFormComponent((props) => {
|
|
|
255
327
|
});
|
|
256
328
|
const inputNumber = defineFormComponent((props) => {
|
|
257
329
|
const {
|
|
258
|
-
valueComputed
|
|
259
|
-
isView
|
|
330
|
+
valueComputed
|
|
260
331
|
} = useFormItem({
|
|
261
332
|
props
|
|
262
333
|
});
|
|
@@ -264,7 +335,7 @@ const inputNumber = defineFormComponent((props) => {
|
|
|
264
335
|
return () => {
|
|
265
336
|
const _props = unrefs(props.column.props);
|
|
266
337
|
return createVNode(FormItem, formItemProps.value, {
|
|
267
|
-
default: () => [
|
|
338
|
+
default: () => [props.isView ? createVNode("div", null, [valueComputed.value]) : createVNode(InputNumber, mergeProps({
|
|
268
339
|
"value": valueComputed.value,
|
|
269
340
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
270
341
|
"placeholder": `请输入${formItemProps.value.label}`
|
|
@@ -274,8 +345,7 @@ const inputNumber = defineFormComponent((props) => {
|
|
|
274
345
|
});
|
|
275
346
|
const mentions = defineFormComponent((props) => {
|
|
276
347
|
const {
|
|
277
|
-
valueComputed
|
|
278
|
-
isView
|
|
348
|
+
valueComputed
|
|
279
349
|
} = useFormItem({
|
|
280
350
|
props
|
|
281
351
|
});
|
|
@@ -283,7 +353,7 @@ const mentions = defineFormComponent((props) => {
|
|
|
283
353
|
return () => {
|
|
284
354
|
const _props = unrefs(props.column.props);
|
|
285
355
|
return createVNode(FormItem, formItemProps.value, {
|
|
286
|
-
default: () => [
|
|
356
|
+
default: () => [props.isView ? createVNode("div", null, [valueComputed.value]) : createVNode(Mentions, mergeProps({
|
|
287
357
|
"value": valueComputed.value,
|
|
288
358
|
"onUpdate:value": ($event) => valueComputed.value = $event
|
|
289
359
|
}, _props), null)]
|
|
@@ -292,8 +362,7 @@ const mentions = defineFormComponent((props) => {
|
|
|
292
362
|
});
|
|
293
363
|
const rate = defineFormComponent((props) => {
|
|
294
364
|
const {
|
|
295
|
-
valueComputed
|
|
296
|
-
isView
|
|
365
|
+
valueComputed
|
|
297
366
|
} = useFormItem({
|
|
298
367
|
props
|
|
299
368
|
});
|
|
@@ -304,15 +373,14 @@ const rate = defineFormComponent((props) => {
|
|
|
304
373
|
default: () => [createVNode(Rate, mergeProps({
|
|
305
374
|
"value": valueComputed.value,
|
|
306
375
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
307
|
-
"disabled": isView
|
|
376
|
+
"disabled": props.isView
|
|
308
377
|
}, _props), null)]
|
|
309
378
|
});
|
|
310
379
|
};
|
|
311
380
|
});
|
|
312
381
|
const slider = defineFormComponent((props) => {
|
|
313
382
|
const {
|
|
314
|
-
valueComputed
|
|
315
|
-
isView
|
|
383
|
+
valueComputed
|
|
316
384
|
} = useFormItem({
|
|
317
385
|
props
|
|
318
386
|
});
|
|
@@ -320,7 +388,7 @@ const slider = defineFormComponent((props) => {
|
|
|
320
388
|
return () => {
|
|
321
389
|
const _props = unrefs(props.column.props);
|
|
322
390
|
return createVNode(FormItem, formItemProps.value, {
|
|
323
|
-
default: () => [
|
|
391
|
+
default: () => [props.isView ? createVNode("div", null, [valueComputed.value]) : createVNode(Slider, mergeProps({
|
|
324
392
|
"value": valueComputed.value,
|
|
325
393
|
"onUpdate:value": ($event) => valueComputed.value = $event
|
|
326
394
|
}, _props), null)]
|
|
@@ -329,16 +397,22 @@ const slider = defineFormComponent((props) => {
|
|
|
329
397
|
});
|
|
330
398
|
const switchComponent = defineFormComponent((props) => {
|
|
331
399
|
const {
|
|
332
|
-
valueComputed
|
|
333
|
-
isView
|
|
400
|
+
valueComputed
|
|
334
401
|
} = useFormItem({
|
|
335
402
|
props
|
|
336
403
|
});
|
|
337
404
|
const formItemProps = useFormItemProps(props.column);
|
|
405
|
+
const isViewText = computed(() => {
|
|
406
|
+
var _a, _b;
|
|
407
|
+
if (props.isView) {
|
|
408
|
+
return valueComputed.value ? ((_a = props.column.props) == null ? void 0 : _a.checkedChildren) || "是" : ((_b = props.column.props) == null ? void 0 : _b.unCheckedChildren) || "否";
|
|
409
|
+
}
|
|
410
|
+
return "-";
|
|
411
|
+
});
|
|
338
412
|
return () => {
|
|
339
413
|
const _props = unrefs(props.column.props);
|
|
340
414
|
return createVNode(FormItem, formItemProps.value, {
|
|
341
|
-
default: () => [
|
|
415
|
+
default: () => [props.isView ? createVNode("div", null, [isViewText.value]) : createVNode(Switch, mergeProps({
|
|
342
416
|
"checked": valueComputed.value,
|
|
343
417
|
"onUpdate:checked": ($event) => valueComputed.value = $event
|
|
344
418
|
}, _props), null)]
|
|
@@ -347,17 +421,42 @@ const switchComponent = defineFormComponent((props) => {
|
|
|
347
421
|
});
|
|
348
422
|
const treeSelect = defineFormComponent((props) => {
|
|
349
423
|
const {
|
|
350
|
-
valueComputed
|
|
351
|
-
isView
|
|
424
|
+
valueComputed
|
|
352
425
|
} = useFormItem({
|
|
353
426
|
props
|
|
354
427
|
});
|
|
355
428
|
const formItemProps = useFormItemProps(props.column);
|
|
429
|
+
const isViewText = computed(() => {
|
|
430
|
+
var _a, _b;
|
|
431
|
+
if (props.isView && valueComputed.value) {
|
|
432
|
+
const vNodes = [];
|
|
433
|
+
const isMultiple = toValue((_a = props.column.props) == null ? void 0 : _a.multiple);
|
|
434
|
+
const options = toValue((_b = props.column.props) == null ? void 0 : _b.treeData) || [];
|
|
435
|
+
const traverse = (options2, values) => {
|
|
436
|
+
if (vNodes.length === values.length) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
for (const option of options2) {
|
|
440
|
+
if (values.includes(option.value)) {
|
|
441
|
+
vNodes.push(createVNode("span", null, [option.label]));
|
|
442
|
+
}
|
|
443
|
+
if (option.children) {
|
|
444
|
+
traverse(option.children, values);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
traverse(options, isMultiple ? valueComputed.value : [valueComputed.value]);
|
|
449
|
+
return vNodes;
|
|
450
|
+
}
|
|
451
|
+
return ["-"];
|
|
452
|
+
});
|
|
356
453
|
return () => {
|
|
357
454
|
const _props = unrefs(props.column.props);
|
|
358
455
|
const placeholder = `请输入${formItemProps.value.label}`;
|
|
359
456
|
return createVNode(FormItem, formItemProps.value, {
|
|
360
|
-
default: () => [
|
|
457
|
+
default: () => [props.isView ? createVNode("div", {
|
|
458
|
+
"style": isViewOptionsStyle
|
|
459
|
+
}, [isViewText.value]) : createVNode(TreeSelect, mergeProps({
|
|
361
460
|
"value": valueComputed.value,
|
|
362
461
|
"onUpdate:value": ($event) => valueComputed.value = $event,
|
|
363
462
|
"allowClear": true,
|
|
@@ -960,14 +1059,26 @@ function useEdit(tableData) {
|
|
|
960
1059
|
} else {
|
|
961
1060
|
component = componentOrTuple;
|
|
962
1061
|
}
|
|
963
|
-
|
|
964
|
-
|
|
1062
|
+
const {
|
|
1063
|
+
valueGetter,
|
|
1064
|
+
valueSetter
|
|
1065
|
+
} = edit;
|
|
1066
|
+
let value = get(scopeProps.record, field);
|
|
1067
|
+
if (valueGetter) {
|
|
1068
|
+
value = valueGetter(value);
|
|
1069
|
+
}
|
|
1070
|
+
const props = {
|
|
1071
|
+
...unrefs(edit.props),
|
|
965
1072
|
class: "ft-table-edit",
|
|
966
|
-
[model]:
|
|
967
|
-
[`onUpdate:${model}`]: (
|
|
968
|
-
|
|
1073
|
+
[model]: value,
|
|
1074
|
+
[`onUpdate:${model}`]: (value2) => {
|
|
1075
|
+
if (valueSetter) {
|
|
1076
|
+
value2 = valueSetter(value2);
|
|
1077
|
+
}
|
|
1078
|
+
set(scopeProps.record, field, value2);
|
|
969
1079
|
}
|
|
970
|
-
}
|
|
1080
|
+
};
|
|
1081
|
+
return h(component, props);
|
|
971
1082
|
}
|
|
972
1083
|
}
|
|
973
1084
|
};
|
|
@@ -1095,11 +1206,22 @@ const FtVxeTable = defineFtTable((_, ctx) => {
|
|
|
1095
1206
|
component = componentOrTuple;
|
|
1096
1207
|
}
|
|
1097
1208
|
const modelEvent = `onUpdate:${model}`;
|
|
1209
|
+
const {
|
|
1210
|
+
valueGetter,
|
|
1211
|
+
valueSetter
|
|
1212
|
+
} = editObj ?? {};
|
|
1213
|
+
let value = get(row, field);
|
|
1214
|
+
if (valueGetter) {
|
|
1215
|
+
value = valueGetter(value);
|
|
1216
|
+
}
|
|
1098
1217
|
const props = {
|
|
1099
|
-
...editObj.props,
|
|
1100
|
-
[model]:
|
|
1101
|
-
[modelEvent]: (
|
|
1102
|
-
|
|
1218
|
+
...unrefs(editObj.props),
|
|
1219
|
+
[model]: value,
|
|
1220
|
+
[modelEvent]: (value2) => {
|
|
1221
|
+
if (valueSetter) {
|
|
1222
|
+
value2 = valueSetter(value2);
|
|
1223
|
+
}
|
|
1224
|
+
set(row, field, value2);
|
|
1103
1225
|
}
|
|
1104
1226
|
};
|
|
1105
1227
|
return h(component, props);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ftjs/antd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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.
|
|
33
|
+
"@ftjs/core": "0.2.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@ant-design/icons-vue": ">=7.0.0",
|