@vunk/form 2.0.2 → 2.1.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/components/esri-input-geojson/index.cjs +484 -2
- package/components/esri-input-geojson/index.mjs +483 -1
- package/components/esri-input-geojson/src/ctx.d.ts +1 -1
- package/components/esri-input-geojson/src/index.vue.d.ts +1 -1
- package/components/index2.cjs +0 -19
- package/components/index2.mjs +1 -19
- package/components/input-collection/index.mjs +1 -1
- package/components/input-number/src/ctx.d.ts +1 -1
- package/components/input-number/src/index.vue.d.ts +2 -2
- package/components/select/index.cjs +12 -0
- package/components/select/index.d.ts +1 -0
- package/components/select/index.mjs +12 -1
- package/components/select/src/ctx.d.ts +2 -0
- package/components/select/src/index.vue.d.ts +1 -1
- package/components/tables-select/index.cjs +225 -0
- package/components/tables-select/index.css +3 -0
- package/components/tables-select/index.d.ts +4 -0
- package/components/tables-select/index.mjs +219 -0
- package/components/tables-select/src/ctx.d.ts +338 -0
- package/components/tables-select/src/index.vue.d.ts +4953 -0
- package/components/tables-select/src/types.d.ts +1 -0
- package/components/upload/index.mjs +1 -1
- package/components/upload-plus/index.mjs +1 -1
- package/index.css +4 -41
- package/package.json +9 -9
- package/shared/element-plus/ctx.d.ts +1 -1
- package/components/geoinput-update/index.cjs +0 -406
- package/components/geoinput-update/index.css +0 -40
- package/components/geoinput-update/index.d.ts +0 -5
- package/components/geoinput-update/index.mjs +0 -399
- package/components/geoinput-update/src/append.vue.d.ts +0 -815
- package/components/geoinput-update/src/ctx.d.ts +0 -219
- package/components/geoinput-update/src/index.vue.d.ts +0 -1143
- package/components/geoinput-update/src/types.d.ts +0 -6
- package/components/index3.cjs +0 -486
- package/components/index3.mjs +0 -484
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var formItem = require('@vunk/form/components/form-item');
|
|
6
6
|
var elementPlus = require('@vunk/form/shared/element-plus');
|
|
7
|
+
var utilsVue = require('@vunk/core/shared/utils-vue');
|
|
7
8
|
var vue = require('vue');
|
|
8
9
|
var elementPlus$1 = require('element-plus');
|
|
9
10
|
var utilsObject = require('@vunk/core/shared/utils-object');
|
|
@@ -34,9 +35,19 @@ const props = {
|
|
|
34
35
|
default: false
|
|
35
36
|
}
|
|
36
37
|
};
|
|
38
|
+
const createBindProps = utilsVue.bindPropsFactory(props);
|
|
37
39
|
const emits = {
|
|
38
40
|
...elementPlus.selectEmits
|
|
39
41
|
};
|
|
42
|
+
const createOnEmits = utilsVue.onEmitsFactory(emits);
|
|
43
|
+
|
|
44
|
+
var ctx = /*#__PURE__*/Object.freeze({
|
|
45
|
+
__proto__: null,
|
|
46
|
+
createBindProps: createBindProps,
|
|
47
|
+
createOnEmits: createOnEmits,
|
|
48
|
+
emits: emits,
|
|
49
|
+
props: props
|
|
50
|
+
});
|
|
40
51
|
|
|
41
52
|
var _sfc_main = vue.defineComponent({
|
|
42
53
|
name: "VkfSelect",
|
|
@@ -194,5 +205,6 @@ VkfSelect.install = (app) => {
|
|
|
194
205
|
};
|
|
195
206
|
|
|
196
207
|
exports.VkfSelect = VkfSelect;
|
|
208
|
+
exports._VkfSelectCtx = ctx;
|
|
197
209
|
exports.__VkfSelect = types;
|
|
198
210
|
exports.default = VkfSelect;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { _VkfFormItemCtx, VkfFormItem } from '@vunk/form/components/form-item';
|
|
2
2
|
import { selectProps, selectEmits, createSelectBindProps, createSelectOnEmits } from '@vunk/form/shared/element-plus';
|
|
3
|
+
import { bindPropsFactory, onEmitsFactory } from '@vunk/core/shared/utils-vue';
|
|
3
4
|
import { defineComponent, computed, ref, watch, nextTick, resolveComponent, openBlock, createBlock, normalizeProps, guardReactiveProps, withCtx, mergeProps, toHandlers, createSlots, createElementBlock, Fragment, renderList, resolveDynamicComponent, createCommentVNode, renderSlot } from 'vue';
|
|
4
5
|
import { ElSelect, ElOption } from 'element-plus';
|
|
5
6
|
import { isNotEmptyObject, isPlainObject } from '@vunk/core/shared/utils-object';
|
|
@@ -30,9 +31,19 @@ const props = {
|
|
|
30
31
|
default: false
|
|
31
32
|
}
|
|
32
33
|
};
|
|
34
|
+
const createBindProps = bindPropsFactory(props);
|
|
33
35
|
const emits = {
|
|
34
36
|
...selectEmits
|
|
35
37
|
};
|
|
38
|
+
const createOnEmits = onEmitsFactory(emits);
|
|
39
|
+
|
|
40
|
+
var ctx = /*#__PURE__*/Object.freeze({
|
|
41
|
+
__proto__: null,
|
|
42
|
+
createBindProps: createBindProps,
|
|
43
|
+
createOnEmits: createOnEmits,
|
|
44
|
+
emits: emits,
|
|
45
|
+
props: props
|
|
46
|
+
});
|
|
36
47
|
|
|
37
48
|
var _sfc_main = defineComponent({
|
|
38
49
|
name: "VkfSelect",
|
|
@@ -189,4 +200,4 @@ VkfSelect.install = (app) => {
|
|
|
189
200
|
app.component(VkfSelect.name, VkfSelect);
|
|
190
201
|
};
|
|
191
202
|
|
|
192
|
-
export { VkfSelect, types as __VkfSelect, VkfSelect as default };
|
|
203
|
+
export { VkfSelect, ctx as _VkfSelectCtx, types as __VkfSelect, VkfSelect as default };
|
|
@@ -158,6 +158,7 @@ export declare const props: {
|
|
|
158
158
|
inlineMessage: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, BooleanConstructor], unknown, unknown, "", boolean>;
|
|
159
159
|
showMessage: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
|
|
160
160
|
};
|
|
161
|
+
export declare const createBindProps: <T2 extends import("@vunk/core").NormalObject, EX extends (Extract<"size", keyof T2> | Extract<"disabled", keyof T2> | Extract<"loading", keyof T2> | Extract<"required", keyof T2> | Extract<"name", keyof T2> | Extract<"formItemSize", keyof T2> | Extract<"formItemSlots", keyof T2> | Extract<"elRef", keyof T2> | Extract<"inline", keyof T2> | Extract<"readonly", keyof T2> | Extract<"formItemTip", keyof T2> | Extract<"formItemTipClass", keyof T2> | Extract<"labelTip", keyof T2> | Extract<"label", keyof T2> | Extract<"labelWidth", keyof T2> | Extract<"labelPosition", keyof T2> | Extract<"prop", keyof T2> | Extract<"rules", keyof T2> | Extract<"error", keyof T2> | Extract<"validateStatus", keyof T2> | Extract<"for", keyof T2> | Extract<"inlineMessage", keyof T2> | Extract<"showMessage", keyof T2> | Extract<"options", keyof T2> | Extract<"id", keyof T2> | Extract<"multiple", keyof T2> | Extract<"placeholder", keyof T2> | Extract<"clearable", keyof T2> | Extract<"filterable", keyof T2> | Extract<"filterMethod", keyof T2> | Extract<"collapseTags", keyof T2> | Extract<"collapseTagsTooltip", keyof T2> | Extract<"popperClass", keyof T2> | Extract<"teleported", keyof T2> | Extract<"tagType", keyof T2> | Extract<"persistent", keyof T2> | Extract<"modelValue", keyof T2> | Extract<"optionsUrl", keyof T2> | Extract<"defaultModelValue", keyof T2> | Extract<"clearIcon", keyof T2> | Extract<"autocomplete", keyof T2> | Extract<"suffixIcon", keyof T2> | Extract<"effect", keyof T2> | Extract<"automaticDropdown", keyof T2> | Extract<"allowCreate", keyof T2> | Extract<"remote", keyof T2> | Extract<"loadingText", keyof T2> | Extract<"noMatchText", keyof T2> | Extract<"noDataText", keyof T2> | Extract<"remoteMethod", keyof T2> | Extract<"multipleLimit", keyof T2> | Extract<"defaultFirstOption", keyof T2> | Extract<"reserveKeyword", keyof T2> | Extract<"valueKey", keyof T2> | Extract<"fitInputWidth", keyof T2> | Extract<"selectSlots", keyof T2> | Extract<"stringify", keyof T2>)[]>(propsArg: T2, excludes?: EX) => import("vue").ComputedRef<{ [P in EX extends (infer KE)[] ? Exclude<Extract<"size" | "disabled" | "loading" | "required" | "name" | "formItemSize" | "formItemSlots" | "elRef" | "inline" | "readonly" | "formItemTip" | "formItemTipClass" | "labelTip" | "label" | "labelWidth" | "labelPosition" | "prop" | "rules" | "error" | "validateStatus" | "for" | "inlineMessage" | "showMessage" | "options" | "id" | "multiple" | "placeholder" | "clearable" | "filterable" | "filterMethod" | "collapseTags" | "collapseTagsTooltip" | "popperClass" | "teleported" | "tagType" | "persistent" | "modelValue" | "optionsUrl" | "defaultModelValue" | "clearIcon" | "autocomplete" | "suffixIcon" | "effect" | "automaticDropdown" | "allowCreate" | "remote" | "loadingText" | "noMatchText" | "noDataText" | "remoteMethod" | "multipleLimit" | "defaultFirstOption" | "reserveKeyword" | "valueKey" | "fitInputWidth" | "selectSlots" | "stringify", keyof T2>, KE> : Extract<"size" | "disabled" | "loading" | "required" | "name" | "formItemSize" | "formItemSlots" | "elRef" | "inline" | "readonly" | "formItemTip" | "formItemTipClass" | "labelTip" | "label" | "labelWidth" | "labelPosition" | "prop" | "rules" | "error" | "validateStatus" | "for" | "inlineMessage" | "showMessage" | "options" | "id" | "multiple" | "placeholder" | "clearable" | "filterable" | "filterMethod" | "collapseTags" | "collapseTagsTooltip" | "popperClass" | "teleported" | "tagType" | "persistent" | "modelValue" | "optionsUrl" | "defaultModelValue" | "clearIcon" | "autocomplete" | "suffixIcon" | "effect" | "automaticDropdown" | "allowCreate" | "remote" | "loadingText" | "noMatchText" | "noDataText" | "remoteMethod" | "multipleLimit" | "defaultFirstOption" | "reserveKeyword" | "valueKey" | "fitInputWidth" | "selectSlots" | "stringify", keyof T2>]: { [k in Extract<"size" | "disabled" | "loading" | "required" | "name" | "formItemSize" | "formItemSlots" | "elRef" | "inline" | "readonly" | "formItemTip" | "formItemTipClass" | "labelTip" | "label" | "labelWidth" | "labelPosition" | "prop" | "rules" | "error" | "validateStatus" | "for" | "inlineMessage" | "showMessage" | "options" | "id" | "multiple" | "placeholder" | "clearable" | "filterable" | "filterMethod" | "collapseTags" | "collapseTagsTooltip" | "popperClass" | "teleported" | "tagType" | "persistent" | "modelValue" | "optionsUrl" | "defaultModelValue" | "clearIcon" | "autocomplete" | "suffixIcon" | "effect" | "automaticDropdown" | "allowCreate" | "remote" | "loadingText" | "noMatchText" | "noDataText" | "remoteMethod" | "multipleLimit" | "defaultFirstOption" | "reserveKeyword" | "valueKey" | "fitInputWidth" | "selectSlots" | "stringify", keyof T2>]: T2[k]; }[P]; }>;
|
|
161
162
|
export declare const emits: {
|
|
162
163
|
'update:modelValue': any;
|
|
163
164
|
change: any;
|
|
@@ -167,3 +168,4 @@ export declare const emits: {
|
|
|
167
168
|
focus: any;
|
|
168
169
|
blur: any;
|
|
169
170
|
};
|
|
171
|
+
export declare const createOnEmits: <T2 extends import("@vunk/core").AnyFunc, EX extends ("clear" | "update:modelValue" | "change" | "focus" | "blur" | "visible-change" | "remove-tag")[]>(emit: T2, excludes?: EX) => { [P in EX extends (infer KE)[] ? Exclude<"clear" | "update:modelValue" | "change" | "focus" | "blur" | "visible-change" | "remove-tag", KE> : "clear" | "update:modelValue" | "change" | "focus" | "blur" | "visible-change" | "remove-tag"]: { [k in "clear" | "update:modelValue" | "change" | "focus" | "blur" | "visible-change" | "remove-tag"]: (...e: import("@vunk/core").RestParameters<T2>) => void; }[P]; };
|
|
@@ -157,8 +157,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
157
157
|
size: "" | "small" | "default" | "large";
|
|
158
158
|
loading: boolean;
|
|
159
159
|
name: string;
|
|
160
|
-
multiple: boolean;
|
|
161
160
|
id: string;
|
|
161
|
+
multiple: boolean;
|
|
162
162
|
placeholder: string;
|
|
163
163
|
clearable: boolean;
|
|
164
164
|
filterable: boolean;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tablesV1Checkbox = require('@vunk/plus/components/tables-v1-checkbox');
|
|
6
|
+
var formItem = require('@vunk/form/components/form-item');
|
|
7
|
+
var vue = require('vue');
|
|
8
|
+
var select = require('@vunk/form/components/select');
|
|
9
|
+
var elementPlus = require('element-plus');
|
|
10
|
+
var array = require('@vunk/shared/array');
|
|
11
|
+
var object = require('@vunk/shared/object');
|
|
12
|
+
var composables = require('@vunk/form/composables');
|
|
13
|
+
var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
|
|
14
|
+
|
|
15
|
+
const props = {
|
|
16
|
+
...formItem._VkfFormItemCtx.props,
|
|
17
|
+
...tablesV1Checkbox._VkTablesV1CheckboxCtx.props,
|
|
18
|
+
/**
|
|
19
|
+
* @description v-model 绑定值
|
|
20
|
+
*/
|
|
21
|
+
modelValue: {
|
|
22
|
+
type: [Array, String],
|
|
23
|
+
default: () => []
|
|
24
|
+
},
|
|
25
|
+
labelField: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: "label"
|
|
28
|
+
},
|
|
29
|
+
clearable: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: true
|
|
32
|
+
},
|
|
33
|
+
multiple: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: true
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* @description 获取完整数据
|
|
39
|
+
*/
|
|
40
|
+
getRows: {
|
|
41
|
+
type: Function,
|
|
42
|
+
default: () => []
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* @description 是否在补全 Rows 后更新 modelValue
|
|
46
|
+
*/
|
|
47
|
+
updateWhenCompleted: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* @description 是否将选中的数据 join 为字符串
|
|
53
|
+
*/
|
|
54
|
+
stringify: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: false
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* @description 是否只读
|
|
60
|
+
*/
|
|
61
|
+
readonly: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: void 0
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const emits = {
|
|
67
|
+
...tablesV1Checkbox._VkTablesV1CheckboxCtx.emits
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var _sfc_main = vue.defineComponent({
|
|
71
|
+
name: "VkfTablesSelect",
|
|
72
|
+
components: {
|
|
73
|
+
VkfSelect: select.VkfSelect,
|
|
74
|
+
VkTablesV1Checkbox: tablesV1Checkbox.VkTablesV1Checkbox,
|
|
75
|
+
ElDialog: elementPlus.ElDialog
|
|
76
|
+
},
|
|
77
|
+
props,
|
|
78
|
+
emits,
|
|
79
|
+
setup(props2, { emit }) {
|
|
80
|
+
const formItemProps = formItem._VkfFormItemCtx.createBindProps(props2);
|
|
81
|
+
const tablesProps = tablesV1Checkbox._VkTablesV1CheckboxCtx.createBindProps(props2, ["modelValue"]);
|
|
82
|
+
const tablesEmits = tablesV1Checkbox._VkTablesV1CheckboxCtx.createOnEmits(emit, ["update:modelValue"]);
|
|
83
|
+
const readonly = composables.useComputedReadonly(props2);
|
|
84
|
+
const dialogVisible = vue.ref(false);
|
|
85
|
+
const backupRowMap = vue.ref(/* @__PURE__ */ new Map());
|
|
86
|
+
const theModelValue = vue.computed({
|
|
87
|
+
get: () => {
|
|
88
|
+
if (props2.stringify && typeof props2.modelValue === "string") {
|
|
89
|
+
return props2.modelValue ? props2.modelValue.split(",").map((v) => ({ [props2.oidField]: v })) : [];
|
|
90
|
+
}
|
|
91
|
+
return props2.modelValue;
|
|
92
|
+
},
|
|
93
|
+
set: (modelValue) => {
|
|
94
|
+
if (!Array.isArray(modelValue)) {
|
|
95
|
+
modelValue = modelValue ? [modelValue] : [];
|
|
96
|
+
}
|
|
97
|
+
if (props2.stringify) {
|
|
98
|
+
const value = modelValue.reduce((a, v) => {
|
|
99
|
+
if (object.isNotEmptyObject(v) && v[props2.oidField] !== void 0) {
|
|
100
|
+
a.push(v[props2.oidField]);
|
|
101
|
+
}
|
|
102
|
+
return a;
|
|
103
|
+
}, []).join(",");
|
|
104
|
+
emit("update:modelValue", value);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
emit("update:modelValue", modelValue);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
const selectOptions = vue.computed(() => {
|
|
111
|
+
return theModelValue.value.map((item) => {
|
|
112
|
+
const backupRow = backupRowMap.value.get(item[props2.oidField]);
|
|
113
|
+
return {
|
|
114
|
+
label: item[props2.labelField] || backupRow?.[props2.labelField],
|
|
115
|
+
value: item
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
const selectValue = vue.computed(() => {
|
|
120
|
+
return props2.multiple ? theModelValue.value : theModelValue.value[0];
|
|
121
|
+
});
|
|
122
|
+
vue.watch(
|
|
123
|
+
() => selectOptions.value.filter((v) => !v.label),
|
|
124
|
+
(rows) => {
|
|
125
|
+
if (!rows.length) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
readItems(rows.map((v) => v.value[props2.oidField])).then(() => {
|
|
129
|
+
if (props2.stringify) return;
|
|
130
|
+
if (!props2.updateWhenCompleted) return;
|
|
131
|
+
const newModelValue = theModelValue.value.reduce((a, v) => {
|
|
132
|
+
const backupRow = backupRowMap.value.get(v[props2.oidField]);
|
|
133
|
+
backupRow ? a.push(backupRow) : a.push(v);
|
|
134
|
+
return a;
|
|
135
|
+
}, []);
|
|
136
|
+
theModelValue.value = newModelValue;
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
{ immediate: true }
|
|
140
|
+
);
|
|
141
|
+
async function readItems(ids) {
|
|
142
|
+
const idRows = ids.filter((v) => !backupRowMap.value.has(v)).map((id) => ({ [props2.oidField]: id }));
|
|
143
|
+
if (!idRows.length) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const { updateRows, addMap } = array.compareArray(props2.data, idRows, props2.oidField);
|
|
147
|
+
updateRows.forEach((row) => {
|
|
148
|
+
backupRowMap.value.set(row[props2.oidField], row);
|
|
149
|
+
});
|
|
150
|
+
if (!addMap.size) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const oids = Array.from(addMap.keys());
|
|
154
|
+
const rows = await props2.getRows(oids);
|
|
155
|
+
rows.forEach((row) => {
|
|
156
|
+
backupRowMap.value.set(row[props2.oidField], row);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
formItemProps,
|
|
161
|
+
selectOptions,
|
|
162
|
+
tablesProps,
|
|
163
|
+
tablesEmits,
|
|
164
|
+
dialogVisible,
|
|
165
|
+
selectValue,
|
|
166
|
+
theModelValue,
|
|
167
|
+
readonly
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
173
|
+
const _component_VkfSelect = vue.resolveComponent("VkfSelect");
|
|
174
|
+
const _component_VkTablesV1Checkbox = vue.resolveComponent("VkTablesV1Checkbox");
|
|
175
|
+
const _component_ElDialog = vue.resolveComponent("ElDialog");
|
|
176
|
+
return vue.openBlock(), vue.createElementBlock(
|
|
177
|
+
vue.Fragment,
|
|
178
|
+
null,
|
|
179
|
+
[
|
|
180
|
+
vue.createVNode(_component_VkfSelect, vue.mergeProps(_ctx.formItemProps, {
|
|
181
|
+
multiple: _ctx.multiple,
|
|
182
|
+
options: _ctx.selectOptions,
|
|
183
|
+
"model-value": _ctx.selectValue,
|
|
184
|
+
clearable: _ctx.clearable,
|
|
185
|
+
"popper-class": "vkf-tables-select__popper",
|
|
186
|
+
"value-key": _ctx.oidField,
|
|
187
|
+
readonly: _ctx.readonly,
|
|
188
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.theModelValue = $event),
|
|
189
|
+
onVisibleChange: _cache[1] || (_cache[1] = ($event) => !_ctx.readonly && (_ctx.dialogVisible = true))
|
|
190
|
+
}), null, 16, ["multiple", "options", "model-value", "clearable", "value-key", "readonly"]),
|
|
191
|
+
vue.createVNode(_component_ElDialog, {
|
|
192
|
+
modelValue: _ctx.dialogVisible,
|
|
193
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => _ctx.dialogVisible = $event),
|
|
194
|
+
title: _ctx.label ?? "\u8BF7\u9009\u62E9",
|
|
195
|
+
"append-to-body": "",
|
|
196
|
+
"model-class": "vkf-tables-select__model",
|
|
197
|
+
class: "vkf-tables-select__dialog"
|
|
198
|
+
}, {
|
|
199
|
+
default: vue.withCtx(() => [
|
|
200
|
+
vue.createVNode(_component_VkTablesV1Checkbox, vue.mergeProps(_ctx.tablesProps, {
|
|
201
|
+
modelValue: _ctx.theModelValue,
|
|
202
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.theModelValue = $event)
|
|
203
|
+
}, vue.toHandlers(_ctx.tablesEmits)), null, 16, ["modelValue"])
|
|
204
|
+
]),
|
|
205
|
+
_: 1
|
|
206
|
+
/* STABLE */
|
|
207
|
+
}, 8, ["modelValue", "title"])
|
|
208
|
+
],
|
|
209
|
+
64
|
|
210
|
+
/* STABLE_FRAGMENT */
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
var VkfTablesSelect = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/tables-select/src/index.vue"]]);
|
|
214
|
+
|
|
215
|
+
var types = /*#__PURE__*/Object.freeze({
|
|
216
|
+
__proto__: null
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
VkfTablesSelect.install = (app) => {
|
|
220
|
+
app.component(VkfTablesSelect.name || "VkfTablesSelect", VkfTablesSelect);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
exports.VkfTablesSelect = VkfTablesSelect;
|
|
224
|
+
exports.__VkfTablesSelect = types;
|
|
225
|
+
exports.default = VkfTablesSelect;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { _VkTablesV1CheckboxCtx, VkTablesV1Checkbox } from '@vunk/plus/components/tables-v1-checkbox';
|
|
2
|
+
import { _VkfFormItemCtx } from '@vunk/form/components/form-item';
|
|
3
|
+
import { defineComponent, ref, computed, watch, resolveComponent, openBlock, createElementBlock, Fragment, createVNode, mergeProps, withCtx, toHandlers } from 'vue';
|
|
4
|
+
import { VkfSelect } from '@vunk/form/components/select';
|
|
5
|
+
import { ElDialog } from 'element-plus';
|
|
6
|
+
import { compareArray } from '@vunk/shared/array';
|
|
7
|
+
import { isNotEmptyObject } from '@vunk/shared/object';
|
|
8
|
+
import { useComputedReadonly } from '@vunk/form/composables';
|
|
9
|
+
import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
|
|
10
|
+
|
|
11
|
+
const props = {
|
|
12
|
+
..._VkfFormItemCtx.props,
|
|
13
|
+
..._VkTablesV1CheckboxCtx.props,
|
|
14
|
+
/**
|
|
15
|
+
* @description v-model 绑定值
|
|
16
|
+
*/
|
|
17
|
+
modelValue: {
|
|
18
|
+
type: [Array, String],
|
|
19
|
+
default: () => []
|
|
20
|
+
},
|
|
21
|
+
labelField: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: "label"
|
|
24
|
+
},
|
|
25
|
+
clearable: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: true
|
|
28
|
+
},
|
|
29
|
+
multiple: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: true
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* @description 获取完整数据
|
|
35
|
+
*/
|
|
36
|
+
getRows: {
|
|
37
|
+
type: Function,
|
|
38
|
+
default: () => []
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* @description 是否在补全 Rows 后更新 modelValue
|
|
42
|
+
*/
|
|
43
|
+
updateWhenCompleted: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: false
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* @description 是否将选中的数据 join 为字符串
|
|
49
|
+
*/
|
|
50
|
+
stringify: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* @description 是否只读
|
|
56
|
+
*/
|
|
57
|
+
readonly: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: void 0
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const emits = {
|
|
63
|
+
..._VkTablesV1CheckboxCtx.emits
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var _sfc_main = defineComponent({
|
|
67
|
+
name: "VkfTablesSelect",
|
|
68
|
+
components: {
|
|
69
|
+
VkfSelect,
|
|
70
|
+
VkTablesV1Checkbox,
|
|
71
|
+
ElDialog
|
|
72
|
+
},
|
|
73
|
+
props,
|
|
74
|
+
emits,
|
|
75
|
+
setup(props2, { emit }) {
|
|
76
|
+
const formItemProps = _VkfFormItemCtx.createBindProps(props2);
|
|
77
|
+
const tablesProps = _VkTablesV1CheckboxCtx.createBindProps(props2, ["modelValue"]);
|
|
78
|
+
const tablesEmits = _VkTablesV1CheckboxCtx.createOnEmits(emit, ["update:modelValue"]);
|
|
79
|
+
const readonly = useComputedReadonly(props2);
|
|
80
|
+
const dialogVisible = ref(false);
|
|
81
|
+
const backupRowMap = ref(/* @__PURE__ */ new Map());
|
|
82
|
+
const theModelValue = computed({
|
|
83
|
+
get: () => {
|
|
84
|
+
if (props2.stringify && typeof props2.modelValue === "string") {
|
|
85
|
+
return props2.modelValue ? props2.modelValue.split(",").map((v) => ({ [props2.oidField]: v })) : [];
|
|
86
|
+
}
|
|
87
|
+
return props2.modelValue;
|
|
88
|
+
},
|
|
89
|
+
set: (modelValue) => {
|
|
90
|
+
if (!Array.isArray(modelValue)) {
|
|
91
|
+
modelValue = modelValue ? [modelValue] : [];
|
|
92
|
+
}
|
|
93
|
+
if (props2.stringify) {
|
|
94
|
+
const value = modelValue.reduce((a, v) => {
|
|
95
|
+
if (isNotEmptyObject(v) && v[props2.oidField] !== void 0) {
|
|
96
|
+
a.push(v[props2.oidField]);
|
|
97
|
+
}
|
|
98
|
+
return a;
|
|
99
|
+
}, []).join(",");
|
|
100
|
+
emit("update:modelValue", value);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
emit("update:modelValue", modelValue);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
const selectOptions = computed(() => {
|
|
107
|
+
return theModelValue.value.map((item) => {
|
|
108
|
+
const backupRow = backupRowMap.value.get(item[props2.oidField]);
|
|
109
|
+
return {
|
|
110
|
+
label: item[props2.labelField] || backupRow?.[props2.labelField],
|
|
111
|
+
value: item
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
const selectValue = computed(() => {
|
|
116
|
+
return props2.multiple ? theModelValue.value : theModelValue.value[0];
|
|
117
|
+
});
|
|
118
|
+
watch(
|
|
119
|
+
() => selectOptions.value.filter((v) => !v.label),
|
|
120
|
+
(rows) => {
|
|
121
|
+
if (!rows.length) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
readItems(rows.map((v) => v.value[props2.oidField])).then(() => {
|
|
125
|
+
if (props2.stringify) return;
|
|
126
|
+
if (!props2.updateWhenCompleted) return;
|
|
127
|
+
const newModelValue = theModelValue.value.reduce((a, v) => {
|
|
128
|
+
const backupRow = backupRowMap.value.get(v[props2.oidField]);
|
|
129
|
+
backupRow ? a.push(backupRow) : a.push(v);
|
|
130
|
+
return a;
|
|
131
|
+
}, []);
|
|
132
|
+
theModelValue.value = newModelValue;
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
{ immediate: true }
|
|
136
|
+
);
|
|
137
|
+
async function readItems(ids) {
|
|
138
|
+
const idRows = ids.filter((v) => !backupRowMap.value.has(v)).map((id) => ({ [props2.oidField]: id }));
|
|
139
|
+
if (!idRows.length) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const { updateRows, addMap } = compareArray(props2.data, idRows, props2.oidField);
|
|
143
|
+
updateRows.forEach((row) => {
|
|
144
|
+
backupRowMap.value.set(row[props2.oidField], row);
|
|
145
|
+
});
|
|
146
|
+
if (!addMap.size) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const oids = Array.from(addMap.keys());
|
|
150
|
+
const rows = await props2.getRows(oids);
|
|
151
|
+
rows.forEach((row) => {
|
|
152
|
+
backupRowMap.value.set(row[props2.oidField], row);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
formItemProps,
|
|
157
|
+
selectOptions,
|
|
158
|
+
tablesProps,
|
|
159
|
+
tablesEmits,
|
|
160
|
+
dialogVisible,
|
|
161
|
+
selectValue,
|
|
162
|
+
theModelValue,
|
|
163
|
+
readonly
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
169
|
+
const _component_VkfSelect = resolveComponent("VkfSelect");
|
|
170
|
+
const _component_VkTablesV1Checkbox = resolveComponent("VkTablesV1Checkbox");
|
|
171
|
+
const _component_ElDialog = resolveComponent("ElDialog");
|
|
172
|
+
return openBlock(), createElementBlock(
|
|
173
|
+
Fragment,
|
|
174
|
+
null,
|
|
175
|
+
[
|
|
176
|
+
createVNode(_component_VkfSelect, mergeProps(_ctx.formItemProps, {
|
|
177
|
+
multiple: _ctx.multiple,
|
|
178
|
+
options: _ctx.selectOptions,
|
|
179
|
+
"model-value": _ctx.selectValue,
|
|
180
|
+
clearable: _ctx.clearable,
|
|
181
|
+
"popper-class": "vkf-tables-select__popper",
|
|
182
|
+
"value-key": _ctx.oidField,
|
|
183
|
+
readonly: _ctx.readonly,
|
|
184
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.theModelValue = $event),
|
|
185
|
+
onVisibleChange: _cache[1] || (_cache[1] = ($event) => !_ctx.readonly && (_ctx.dialogVisible = true))
|
|
186
|
+
}), null, 16, ["multiple", "options", "model-value", "clearable", "value-key", "readonly"]),
|
|
187
|
+
createVNode(_component_ElDialog, {
|
|
188
|
+
modelValue: _ctx.dialogVisible,
|
|
189
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => _ctx.dialogVisible = $event),
|
|
190
|
+
title: _ctx.label ?? "\u8BF7\u9009\u62E9",
|
|
191
|
+
"append-to-body": "",
|
|
192
|
+
"model-class": "vkf-tables-select__model",
|
|
193
|
+
class: "vkf-tables-select__dialog"
|
|
194
|
+
}, {
|
|
195
|
+
default: withCtx(() => [
|
|
196
|
+
createVNode(_component_VkTablesV1Checkbox, mergeProps(_ctx.tablesProps, {
|
|
197
|
+
modelValue: _ctx.theModelValue,
|
|
198
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.theModelValue = $event)
|
|
199
|
+
}, toHandlers(_ctx.tablesEmits)), null, 16, ["modelValue"])
|
|
200
|
+
]),
|
|
201
|
+
_: 1
|
|
202
|
+
/* STABLE */
|
|
203
|
+
}, 8, ["modelValue", "title"])
|
|
204
|
+
],
|
|
205
|
+
64
|
|
206
|
+
/* STABLE_FRAGMENT */
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
var VkfTablesSelect = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/tables-select/src/index.vue"]]);
|
|
210
|
+
|
|
211
|
+
var types = /*#__PURE__*/Object.freeze({
|
|
212
|
+
__proto__: null
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
VkfTablesSelect.install = (app) => {
|
|
216
|
+
app.component(VkfTablesSelect.name || "VkfTablesSelect", VkfTablesSelect);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export { VkfTablesSelect, types as __VkfTablesSelect, VkfTablesSelect as default };
|