cnhis-design-vue 3.1.39-release.3 → 3.1.40-beta.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/es/components/button-print/index.d.ts +16 -1
- package/es/components/button-print/src/ButtonPrint.vue.d.ts +16 -1
- package/es/components/button-print/src/ButtonPrint.vue2.js +37 -6
- package/es/components/button-print/src/utils/print.d.ts +1 -0
- package/es/components/button-print/src/utils/print.js +10 -0
- package/es/components/form-render/index.js +2 -2
- package/es/components/form-render/src/components/renderer/lineBar/FormCollapse.vue.d.ts +3 -0
- package/es/components/form-render/src/components/renderer/lineBar/FormCollapse.vue.js +9 -4
- package/es/components/form-render/src/components/renderer/lineBar/index.d.ts +3 -0
- package/es/components/form-render/src/components/renderer/select.js +26 -8
- package/es/components/form-render/src/hooks/index.js +1 -1
- package/es/components/form-render/src/hooks/useFormRenderOptions.d.ts +4 -3
- package/es/components/form-render/src/hooks/useFormRenderOptions.js +53 -13
- package/es/components/form-render/src/utils/index.d.ts +2 -4
- package/es/components/form-render/src/utils/index.js +1 -15
- package/es/components/form-render/style/index.css +1 -1
- package/es/components/iho-table/index.d.ts +119 -119
- package/es/components/iho-table/src/IhoTable.vue.d.ts +119 -119
- package/es/components/iho-table/src/IhoTable.vue.js +6 -6
- package/es/components/iho-table/src/hooks/tapHooks/index.d.ts +60 -62
- package/es/components/iho-table/src/hooks/tapHooks/index.js +2 -6
- package/es/components/iho-table/src/hooks/tapHooks/useEventHooks.d.ts +1 -1
- package/es/components/iho-table/src/hooks/tapHooks/useEventHooks.js +2 -2
- package/es/components/iho-table/src/plugins/lowCodeFieldAdaptorPlugin/index.js +1 -0
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/dateRendererPlugin/index.js +4 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/numberRendererPlugin.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/separateRendererPlugin/index.js +6 -5
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/timeRendererPlugin.js +1 -1
- package/es/components/iho-table/src/types/index.d.ts +1 -0
- package/es/components/index.css +1 -1
- package/es/components/index.js +2 -2
- package/es/components/keyboard/index.d.ts +4 -0
- package/es/components/keyboard/src/Keyboard.vue.d.ts +4 -0
- package/es/components/keyboard/src/Keyboard.vue.js +10 -2
- package/es/components/keyboard/src/components/InputNumber.vue.d.ts +3 -1
- package/es/components/keyboard/src/components/InputNumber.vue.js +13 -1
- package/es/components/keyboard/src/components/NumberPanel.vue.d.ts +2 -0
- package/package.json +2 -2
|
@@ -64,6 +64,10 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
64
64
|
type: StringConstructor;
|
|
65
65
|
default: string;
|
|
66
66
|
};
|
|
67
|
+
directPrint: {
|
|
68
|
+
type: BooleanConstructor;
|
|
69
|
+
default: boolean;
|
|
70
|
+
};
|
|
67
71
|
}, {
|
|
68
72
|
$message: import("naive-ui").MessageApi;
|
|
69
73
|
printInstance: import("./src/utils").Print | null;
|
|
@@ -130,6 +134,10 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
130
134
|
type: StringConstructor;
|
|
131
135
|
default: string;
|
|
132
136
|
};
|
|
137
|
+
directPrint: {
|
|
138
|
+
type: BooleanConstructor;
|
|
139
|
+
default: boolean;
|
|
140
|
+
};
|
|
133
141
|
}>> & {
|
|
134
142
|
onError?: ((...args: any[]) => any) | undefined;
|
|
135
143
|
onSuccess?: ((...args: any[]) => any) | undefined;
|
|
@@ -154,6 +162,7 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
154
162
|
currentFormatItem: import("vue").ComputedRef<{} | undefined>;
|
|
155
163
|
formatTitle: import("vue").ComputedRef<any>;
|
|
156
164
|
getTemplateIdByFormatId: import("vue").ComputedRef<any>;
|
|
165
|
+
buttonClick: (origin: string) => Promise<false | undefined>;
|
|
157
166
|
renderLabel: (option: import("naive-ui").MenuOption) => JSX.Element;
|
|
158
167
|
callLocalServicesSuccessCb: (res: any, type: any) => void;
|
|
159
168
|
callLocalServicesErrorCb: (res: unknown) => void;
|
|
@@ -179,9 +188,10 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
179
188
|
}, params?: any[]) => any;
|
|
180
189
|
initCRM: (formatListResult: any) => Promise<boolean | undefined>;
|
|
181
190
|
init: () => Promise<boolean>;
|
|
182
|
-
handleClickBtn: () => Promise<false | undefined>;
|
|
191
|
+
handleClickBtn: (visible?: boolean) => Promise<false | undefined>;
|
|
183
192
|
reformatPrintParams: () => void;
|
|
184
193
|
verifiySuccess: (token: string) => void;
|
|
194
|
+
directPrint: () => Promise<void>;
|
|
185
195
|
NDropdown: any;
|
|
186
196
|
NButton: any;
|
|
187
197
|
NIcon: any;
|
|
@@ -1878,6 +1888,10 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
1878
1888
|
type: StringConstructor;
|
|
1879
1889
|
default: string;
|
|
1880
1890
|
};
|
|
1891
|
+
directPrint: {
|
|
1892
|
+
type: BooleanConstructor;
|
|
1893
|
+
default: boolean;
|
|
1894
|
+
};
|
|
1881
1895
|
}>> & {
|
|
1882
1896
|
onError?: ((...args: any[]) => any) | undefined;
|
|
1883
1897
|
onSuccess?: ((...args: any[]) => any) | undefined;
|
|
@@ -1897,5 +1911,6 @@ declare const ButtonPrint: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
1897
1911
|
noDataMsg: string;
|
|
1898
1912
|
printdlgshow: string;
|
|
1899
1913
|
btnprint: string;
|
|
1914
|
+
directPrint: boolean;
|
|
1900
1915
|
}>>;
|
|
1901
1916
|
export default ButtonPrint;
|
|
@@ -69,6 +69,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
69
69
|
type: StringConstructor;
|
|
70
70
|
default: string;
|
|
71
71
|
};
|
|
72
|
+
directPrint: {
|
|
73
|
+
type: BooleanConstructor;
|
|
74
|
+
default: boolean;
|
|
75
|
+
};
|
|
72
76
|
}, {
|
|
73
77
|
$message: import("naive-ui").MessageApi;
|
|
74
78
|
printInstance: Print | null;
|
|
@@ -138,6 +142,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
138
142
|
type: StringConstructor;
|
|
139
143
|
default: string;
|
|
140
144
|
};
|
|
145
|
+
directPrint: {
|
|
146
|
+
type: BooleanConstructor;
|
|
147
|
+
default: boolean;
|
|
148
|
+
};
|
|
141
149
|
}>> & {
|
|
142
150
|
onError?: ((...args: any[]) => any) | undefined;
|
|
143
151
|
onSuccess?: ((...args: any[]) => any) | undefined;
|
|
@@ -162,6 +170,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
162
170
|
currentFormatItem: import("vue").ComputedRef<{} | undefined>;
|
|
163
171
|
formatTitle: import("vue").ComputedRef<any>;
|
|
164
172
|
getTemplateIdByFormatId: import("vue").ComputedRef<any>;
|
|
173
|
+
buttonClick: (origin: string) => Promise<false | undefined>;
|
|
165
174
|
renderLabel: (option: DropdownOption) => JSX.Element;
|
|
166
175
|
callLocalServicesSuccessCb: (res: any, type: any) => void;
|
|
167
176
|
callLocalServicesErrorCb: (res: unknown) => void;
|
|
@@ -187,9 +196,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
187
196
|
}, params?: any[]) => any;
|
|
188
197
|
initCRM: (formatListResult: any) => Promise<boolean | undefined>;
|
|
189
198
|
init: () => Promise<boolean>;
|
|
190
|
-
handleClickBtn: () => Promise<false | undefined>;
|
|
199
|
+
handleClickBtn: (visible?: boolean) => Promise<false | undefined>;
|
|
191
200
|
reformatPrintParams: () => void;
|
|
192
201
|
verifiySuccess: (token: string) => void;
|
|
202
|
+
directPrint: () => Promise<void>;
|
|
193
203
|
NDropdown: any;
|
|
194
204
|
NButton: any;
|
|
195
205
|
NIcon: any;
|
|
@@ -1889,6 +1899,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1889
1899
|
type: StringConstructor;
|
|
1890
1900
|
default: string;
|
|
1891
1901
|
};
|
|
1902
|
+
directPrint: {
|
|
1903
|
+
type: BooleanConstructor;
|
|
1904
|
+
default: boolean;
|
|
1905
|
+
};
|
|
1892
1906
|
}>> & {
|
|
1893
1907
|
onError?: ((...args: any[]) => any) | undefined;
|
|
1894
1908
|
onSuccess?: ((...args: any[]) => any) | undefined;
|
|
@@ -1908,5 +1922,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1908
1922
|
noDataMsg: string;
|
|
1909
1923
|
printdlgshow: string;
|
|
1910
1924
|
btnprint: string;
|
|
1925
|
+
directPrint: boolean;
|
|
1911
1926
|
}>;
|
|
1912
1927
|
export default _default;
|
|
@@ -71,10 +71,15 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
71
71
|
btnprint: {
|
|
72
72
|
type: String,
|
|
73
73
|
default: "1"
|
|
74
|
+
},
|
|
75
|
+
directPrint: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: false
|
|
74
78
|
}
|
|
75
79
|
},
|
|
76
80
|
emits: ["success", "error", "clickoutside"],
|
|
77
81
|
setup(__props, {
|
|
82
|
+
expose,
|
|
78
83
|
emit
|
|
79
84
|
}) {
|
|
80
85
|
const props = __props;
|
|
@@ -118,6 +123,19 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
118
123
|
let find = state.formatList.find((item) => item.id === state.currentFormatId);
|
|
119
124
|
return find == null ? void 0 : find.templateId;
|
|
120
125
|
});
|
|
126
|
+
const buttonClick = async (origin) => {
|
|
127
|
+
if (props.directPrint) {
|
|
128
|
+
if (state.spinning)
|
|
129
|
+
return;
|
|
130
|
+
if (origin === "button") {
|
|
131
|
+
await directPrint();
|
|
132
|
+
return;
|
|
133
|
+
} else {
|
|
134
|
+
return handleClickBtn();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return handleClickBtn();
|
|
138
|
+
};
|
|
121
139
|
const renderLabel = (option) => {
|
|
122
140
|
return createVNode("span", {
|
|
123
141
|
"class": {
|
|
@@ -402,7 +420,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
402
420
|
state.spinning = false;
|
|
403
421
|
return true;
|
|
404
422
|
};
|
|
405
|
-
const handleClickBtn = async () => {
|
|
423
|
+
const handleClickBtn = async (visible = true) => {
|
|
406
424
|
var _a;
|
|
407
425
|
const status = await props.clickPrevFn();
|
|
408
426
|
if (!status)
|
|
@@ -416,7 +434,9 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
416
434
|
if (!result)
|
|
417
435
|
return false;
|
|
418
436
|
}
|
|
419
|
-
|
|
437
|
+
if (visible) {
|
|
438
|
+
state.visible = !state.visible;
|
|
439
|
+
}
|
|
420
440
|
};
|
|
421
441
|
const reformatPrintParams = () => {
|
|
422
442
|
state.watchPrintParamsReformatFn && state.watchPrintParamsReformatFn();
|
|
@@ -457,6 +477,13 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
457
477
|
}, {
|
|
458
478
|
deep: true
|
|
459
479
|
});
|
|
480
|
+
async function directPrint() {
|
|
481
|
+
await handleClickBtn(false);
|
|
482
|
+
handleClickPrint();
|
|
483
|
+
}
|
|
484
|
+
expose({
|
|
485
|
+
directPrint
|
|
486
|
+
});
|
|
460
487
|
return (_ctx, _cache) => {
|
|
461
488
|
return openBlock(), createElementBlock(Fragment, null, [createVNode(unref(NDropdown), {
|
|
462
489
|
class: "c-dropdown",
|
|
@@ -475,17 +502,21 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
475
502
|
printVisible: state.visible
|
|
476
503
|
}, () => [createVNode(unref(NButton), {
|
|
477
504
|
class: "dropdown-button",
|
|
478
|
-
onClick: withModifiers(
|
|
505
|
+
onClick: _cache[1] || (_cache[1] = withModifiers(() => buttonClick("button"), ["stop"]))
|
|
479
506
|
}, {
|
|
480
507
|
default: withCtx(() => [createCommentVNode(' <n-spin v-show="state.spinning" size="small"></n-spin> '), createTextVNode(toDisplayString(__props.btnText) + " ", 1), createVNode(unref(NIcon), {
|
|
481
|
-
component: unref(ChevronDown)
|
|
508
|
+
component: unref(ChevronDown),
|
|
509
|
+
style: {
|
|
510
|
+
"margin-left": "5px"
|
|
511
|
+
},
|
|
512
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => buttonClick("icon"), ["stop"]))
|
|
482
513
|
}, null, 8, ["component"])]),
|
|
483
514
|
_: 1
|
|
484
|
-
}
|
|
515
|
+
})])]),
|
|
485
516
|
_: 3
|
|
486
517
|
}, 8, ["show", "options"]), createVNode(IdentityVerification, mergeProps(_ctx.$attrs, {
|
|
487
518
|
modelValue: state.identityVerification.visible,
|
|
488
|
-
"onUpdate:modelValue": _cache[
|
|
519
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => state.identityVerification.visible = $event),
|
|
489
520
|
formatId: state.currentFormatId,
|
|
490
521
|
templateId: unref(getTemplateIdByFormatId),
|
|
491
522
|
onSuccess: verifiySuccess
|
|
@@ -27,6 +27,7 @@ class Print {
|
|
|
27
27
|
this.dialog = new IdentityVerificationDialog();
|
|
28
28
|
this.dialogPreview = new PreviewDialog();
|
|
29
29
|
this.instance = null;
|
|
30
|
+
this.downloadPath = "";
|
|
30
31
|
this.messageHandlerQueue = [];
|
|
31
32
|
var _a;
|
|
32
33
|
const _window = window;
|
|
@@ -35,13 +36,19 @@ class Print {
|
|
|
35
36
|
return;
|
|
36
37
|
this.currentMessageHandler = this.messageHandler.bind(this);
|
|
37
38
|
this.webview.addEventListener("message", this.currentMessageHandler);
|
|
39
|
+
this.postMessage({ exec: "config", data: "" });
|
|
38
40
|
}
|
|
39
41
|
messageHandler(e) {
|
|
42
|
+
var _a;
|
|
40
43
|
const handler = this.messageHandlerQueue.pop();
|
|
41
44
|
if (!handler)
|
|
42
45
|
return console.log("\u5F53\u524D\u56DE\u6267", e, "\u6CA1\u6709\u53EF\u7528\u7684handler");
|
|
43
46
|
const { resolve, reject } = handler;
|
|
44
47
|
try {
|
|
48
|
+
const { exec } = JSON.parse(e.data);
|
|
49
|
+
if (exec === "config") {
|
|
50
|
+
this.downloadPath = ((_a = JSON.parse(e.data).res) == null ? void 0 : _a.downloadpath) || "";
|
|
51
|
+
}
|
|
45
52
|
console.log(e);
|
|
46
53
|
resolve(JSON.parse(e.data).res);
|
|
47
54
|
} catch (e2) {
|
|
@@ -311,6 +318,9 @@ class Print {
|
|
|
311
318
|
return httpFn.get(PDF_URL, { params: { inputData } }).then(({ data }) => data);
|
|
312
319
|
}
|
|
313
320
|
downloadPDF(params, onResolve, onReject) {
|
|
321
|
+
if (this.webview && this.downloadPath) {
|
|
322
|
+
params.print.filename = this.downloadPath.replace(/\\/g, "/");
|
|
323
|
+
}
|
|
314
324
|
this.printDirect(
|
|
315
325
|
params,
|
|
316
326
|
async (res) => {
|
|
@@ -15,8 +15,8 @@ export { FormItemDepsCollector, useFormItemDeps } from './src/hooks/useFormItemD
|
|
|
15
15
|
export { useAnchor } from './src/hooks/useAnchor.js';
|
|
16
16
|
export { useFormContext } from './src/hooks/useFormContext.js';
|
|
17
17
|
export { useCommonInjection, useSelectOptionProps } from './src/hooks/useCommonInjection.js';
|
|
18
|
-
export { useAutographOptions, useRecommendOptions, useUrlConfigOptions } from './src/hooks/useFormRenderOptions.js';
|
|
19
|
-
export { combineExtendKey, createInputSlot, createSlot, createUrlConfigParams, formRenderLog, injectOrProvide, isNestedFieldType, isNestedType,
|
|
18
|
+
export { optionMatcherCache, useAutographOptions, useRecommendOptions, useUrlConfigOptions } from './src/hooks/useFormRenderOptions.js';
|
|
19
|
+
export { combineExtendKey, createInputSlot, createSlot, createUrlConfigParams, formRenderLog, injectOrProvide, isNestedFieldType, isNestedType, keywordMatcher, mergeDeepProperties, parseNumberFromMaybeString, presetRequestHandler, splitExtendKey, validateMessageParser } from './src/utils/index.js';
|
|
20
20
|
export * from '@formily/core';
|
|
21
21
|
export { businessDateParser, isIdCard, isMobile, parseAge2Birthday, parseAgeFromContext, parseBirthday, parseIdCard, transformDateFormat } from './src/utils/business.js';
|
|
22
22
|
export { findNextWidget, queryDecorator, queryInput } from './src/utils/dom.js';
|
|
@@ -30,6 +30,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
30
30
|
}>> & {}>>;
|
|
31
31
|
_show: import("vue").Ref<boolean>;
|
|
32
32
|
toggleShow: () => void;
|
|
33
|
+
headerClass: import("vue").ComputedRef<(string | {
|
|
34
|
+
'form-render__linebarHeader--disabled': boolean;
|
|
35
|
+
})[]>;
|
|
33
36
|
fieldKey: import("vue").ComputedRef<string>;
|
|
34
37
|
formItemDepsCollector: import("../../../../../../../es/components/form-render").FormItemDepsCollector;
|
|
35
38
|
TooltipMessage: import("vue").DefineComponent<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, ref, inject, openBlock, createElementBlock, createElementVNode, createTextVNode, toDisplayString, createBlock, createCommentVNode,
|
|
1
|
+
import { defineComponent, ref, computed, inject, openBlock, createElementBlock, createElementVNode, normalizeClass, unref, createTextVNode, toDisplayString, createBlock, createCommentVNode, Fragment, createVNode, withCtx, renderSlot } from 'vue';
|
|
2
2
|
import '../../../../index.js';
|
|
3
3
|
import TooltipMessage from '../../tooltipMessage.vue.js';
|
|
4
4
|
import { InjectionFormItemDepsCollector, FormItemLineBarDepKeyPrepend } from '../../../constants/index.js';
|
|
@@ -28,6 +28,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
28
28
|
return;
|
|
29
29
|
_show.value = !_show.value;
|
|
30
30
|
}
|
|
31
|
+
const headerClass = computed(() => {
|
|
32
|
+
return ["form-render__linebarHeader", { "form-render__linebarHeader--disabled": !!props.disabled }];
|
|
33
|
+
});
|
|
31
34
|
const { fieldKey } = useFormField();
|
|
32
35
|
const formItemDepsCollector = inject(InjectionFormItemDepsCollector);
|
|
33
36
|
formItemDepsCollector.setDeps(fieldKey.value, FormItemLineBarDepKeyPrepend + fieldKey.value, (v = true) => {
|
|
@@ -36,7 +39,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
36
39
|
return (_ctx, _cache) => {
|
|
37
40
|
return openBlock(), createElementBlock("section", _hoisted_1, [
|
|
38
41
|
createElementVNode("header", {
|
|
39
|
-
class:
|
|
42
|
+
class: normalizeClass(unref(headerClass)),
|
|
40
43
|
onClick: toggleShow
|
|
41
44
|
}, [
|
|
42
45
|
createElementVNode("div", _hoisted_2, [
|
|
@@ -46,8 +49,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
46
49
|
message: __props.remark
|
|
47
50
|
}, null, 8, ["message"])) : createCommentVNode("v-if", true)
|
|
48
51
|
]),
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
!__props.disabled ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
53
|
+
_show.value ? (openBlock(), createBlock(unref(ChevronDown), { key: 0 })) : (openBlock(), createBlock(unref(ChevronUp), { key: 1 }))
|
|
54
|
+
], 64)) : createCommentVNode("v-if", true)
|
|
55
|
+
], 2),
|
|
51
56
|
createVNode(unref(NCollapseTransition), {
|
|
52
57
|
class: "form-render__linebarItem",
|
|
53
58
|
show: _show.value
|
|
@@ -30,6 +30,9 @@ export declare const LINEBAR: import("vue").DefineComponent<{
|
|
|
30
30
|
}>> & {}>>;
|
|
31
31
|
_show: import("vue").Ref<boolean>;
|
|
32
32
|
toggleShow: () => void;
|
|
33
|
+
headerClass: import("vue").ComputedRef<(string | {
|
|
34
|
+
'form-render__linebarHeader--disabled': boolean;
|
|
35
|
+
})[]>;
|
|
33
36
|
fieldKey: import("vue").ComputedRef<string>;
|
|
34
37
|
formItemDepsCollector: import("../../../hooks").FormItemDepsCollector;
|
|
35
38
|
TooltipMessage: import("vue").DefineComponent<{
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { defineComponent, computed, inject, createVNode } from 'vue';
|
|
2
|
-
import {
|
|
2
|
+
import { useDebounceFn } from '@vueuse/core';
|
|
3
|
+
import { cloneDeep, isString } from 'lodash-es';
|
|
3
4
|
import { useCommonInjection, useSelectOptionProps } from '../../hooks/useCommonInjection.js';
|
|
4
5
|
import { InjectionChangeContextCollector } from '../../constants/index.js';
|
|
5
6
|
import '../../../../../shared/utils/index.js';
|
|
6
7
|
import '../../../index.js';
|
|
7
8
|
import '../../utils/index.js';
|
|
8
9
|
import { useFormField } from '../../hooks/useFormField.js';
|
|
9
|
-
import '@vueuse/core';
|
|
10
10
|
import '../../../../../shared/utils/tapable/SyncHook.js';
|
|
11
11
|
import '../../../../../shared/utils/tapable/SyncBailHook.js';
|
|
12
12
|
import '../../../../../shared/utils/tapable/SyncWaterfallHook.js';
|
|
@@ -23,7 +23,7 @@ import 'date-fns';
|
|
|
23
23
|
import { connect, mapProps } from '@formily/vue';
|
|
24
24
|
import '@vue/shared';
|
|
25
25
|
import './index.js';
|
|
26
|
-
import { useUrlConfigOptions, useAutographOptions, useRecommendOptions } from '../../hooks/useFormRenderOptions.js';
|
|
26
|
+
import { useUrlConfigOptions, useAutographOptions, useRecommendOptions, optionMatcherCache } from '../../hooks/useFormRenderOptions.js';
|
|
27
27
|
import { NSelect } from 'naive-ui';
|
|
28
28
|
import { createVisitedSetter, assignUpdateValue, assignClearBindVisited } from '../../utils/schema.js';
|
|
29
29
|
|
|
@@ -101,7 +101,7 @@ const script = defineComponent({
|
|
|
101
101
|
getRecommend,
|
|
102
102
|
postRecommend,
|
|
103
103
|
sortedOptions
|
|
104
|
-
} = useRecommendOptions(props, options, emit, valueKey);
|
|
104
|
+
} = useRecommendOptions(props, options, emit, labelKey, valueKey);
|
|
105
105
|
const {
|
|
106
106
|
field,
|
|
107
107
|
fieldKey
|
|
@@ -115,10 +115,10 @@ const script = defineComponent({
|
|
|
115
115
|
return sortedOptions.value.find((option) => option[valueKey.value] === v2);
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
|
-
|
|
118
|
+
const fetchData = useDebounceFn(async (content = "") => {
|
|
119
119
|
fetchOptions(content);
|
|
120
|
-
getRecommend();
|
|
121
|
-
}
|
|
120
|
+
getRecommend(content);
|
|
121
|
+
}, 400);
|
|
122
122
|
const {
|
|
123
123
|
injectValueValidate,
|
|
124
124
|
injectValueWatchFromEmpty,
|
|
@@ -131,6 +131,23 @@ const script = defineComponent({
|
|
|
131
131
|
menuProps,
|
|
132
132
|
nodeProps
|
|
133
133
|
} = useSelectOptionProps();
|
|
134
|
+
function renderLabel(option) {
|
|
135
|
+
const label = option[labelKey.value];
|
|
136
|
+
if (!label || !isString(label))
|
|
137
|
+
return "";
|
|
138
|
+
const renderLabels = optionMatcherCache.get(option);
|
|
139
|
+
if (!renderLabels)
|
|
140
|
+
return label;
|
|
141
|
+
return createVNode("section", null, [renderLabels.map((chars, idx) => {
|
|
142
|
+
if (idx === 0 || !chars)
|
|
143
|
+
return null;
|
|
144
|
+
return createVNode("span", {
|
|
145
|
+
"style": {
|
|
146
|
+
color: idx % 2 === 0 ? "var(--n-option-text-color-active)" : ""
|
|
147
|
+
}
|
|
148
|
+
}, [chars]);
|
|
149
|
+
})]);
|
|
150
|
+
}
|
|
134
151
|
return () => createVNode(NSelect, {
|
|
135
152
|
"key": key.value,
|
|
136
153
|
"remote": true,
|
|
@@ -144,7 +161,8 @@ const script = defineComponent({
|
|
|
144
161
|
"options": sortedOptions.value,
|
|
145
162
|
"onSearch": fetchData,
|
|
146
163
|
"onUpdate:show": (show) => show && fetchData(),
|
|
147
|
-
"onFocus": createVisitedSetter(field)
|
|
164
|
+
"onFocus": createVisitedSetter(field),
|
|
165
|
+
"renderLabel": renderLabel
|
|
148
166
|
}, slots);
|
|
149
167
|
}
|
|
150
168
|
});
|
|
@@ -12,4 +12,4 @@ export { FormItemDepsCollector, useFormItemDeps } from './useFormItemDeps.js';
|
|
|
12
12
|
export { useAnchor } from './useAnchor.js';
|
|
13
13
|
export { useFormContext } from './useFormContext.js';
|
|
14
14
|
export { useCommonInjection, useSelectOptionProps } from './useCommonInjection.js';
|
|
15
|
-
export { useAutographOptions, useRecommendOptions, useUrlConfigOptions } from './useFormRenderOptions.js';
|
|
15
|
+
export { optionMatcherCache, useAutographOptions, useRecommendOptions, useUrlConfigOptions } from './useFormRenderOptions.js';
|
|
@@ -2,6 +2,7 @@ import { AnyObject, Func } from '../../../../../es/shared/types';
|
|
|
2
2
|
import { Ref } from 'vue';
|
|
3
3
|
import { FormWordbook, RecommendIds, UrlConfig } from '../../../../../es/components/form-render';
|
|
4
4
|
import { RecommendItem } from '../../../../../es/components/recommend-search/src/types';
|
|
5
|
+
export declare const optionMatcherCache: WeakMap<AnyObject, string[]>;
|
|
5
6
|
export declare function useRecommendOptions(props: {
|
|
6
7
|
recommend: boolean;
|
|
7
8
|
commonList?: RecommendItem[];
|
|
@@ -9,10 +10,10 @@ export declare function useRecommendOptions(props: {
|
|
|
9
10
|
getRecommendInfo?: () => RecommendIds;
|
|
10
11
|
recommendCache: boolean;
|
|
11
12
|
recommendNum: number;
|
|
12
|
-
}, options: Ref<AnyObject[]>, emit: Func, valueKey: Ref<string>): {
|
|
13
|
+
}, options: Ref<AnyObject[]>, emit: Func, labelKey: Ref<string>, valueKey: Ref<string>): {
|
|
13
14
|
postRecommend: (value: unknown) => Promise<void>;
|
|
14
|
-
getRecommend: () => Promise<void>;
|
|
15
|
-
sortedOptions: import("vue").ComputedRef<
|
|
15
|
+
getRecommend: (content?: string) => Promise<void>;
|
|
16
|
+
sortedOptions: import("vue").ComputedRef<AnyObject[]>;
|
|
16
17
|
};
|
|
17
18
|
export declare function useUrlConfigOptions(props: {
|
|
18
19
|
urlConfig?: UrlConfig;
|
|
@@ -4,7 +4,7 @@ import { isString, isEqual, omit, isFunction } from 'lodash-es';
|
|
|
4
4
|
import { computed, inject, ref, watch } from 'vue';
|
|
5
5
|
import '../../index.js';
|
|
6
6
|
import { InjectionAsyncQueue, InjectionFormItemDepsCollector } from '../constants/index.js';
|
|
7
|
-
import { createUrlConfigParams, formRenderLog,
|
|
7
|
+
import { createUrlConfigParams, formRenderLog, keywordMatcher } from '../utils/index.js';
|
|
8
8
|
import { useFormField } from './useFormField.js';
|
|
9
9
|
import { useFormRequest } from './useFormRequest.js';
|
|
10
10
|
|
|
@@ -21,9 +21,44 @@ function createPropRef(props, key) {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
const optionMatcherCache = /* @__PURE__ */ new WeakMap();
|
|
25
|
+
const searchContentMatcherCache = /* @__PURE__ */ new Map();
|
|
26
|
+
function useSearchContent() {
|
|
27
|
+
const searchContent = ref();
|
|
28
|
+
const searchContentMatcher = computed(() => {
|
|
29
|
+
if (!searchContent.value)
|
|
30
|
+
return /./;
|
|
31
|
+
return new RegExp(
|
|
32
|
+
`(.*)${searchContent.value.split("").map((char) => `(${char})`).join("(.*)")}(.*)`
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
function filter(option, labelKey) {
|
|
36
|
+
if (!searchContent.value)
|
|
37
|
+
return true;
|
|
38
|
+
const label = option ? option[labelKey] : "";
|
|
39
|
+
if (!isString(label))
|
|
40
|
+
return false;
|
|
41
|
+
const cacheObj = searchContentMatcherCache.get(searchContent.value) || {};
|
|
42
|
+
const matched = Reflect.has(cacheObj, label) ? cacheObj[label] : label.match(searchContentMatcher.value);
|
|
43
|
+
cacheObj[label] = matched;
|
|
44
|
+
searchContentMatcherCache.set(searchContent.value, cacheObj);
|
|
45
|
+
if (matched) {
|
|
46
|
+
optionMatcherCache.set(option, matched);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return keywordMatcher(label, option.keyword);
|
|
50
|
+
}
|
|
51
|
+
function optionSearchFilter(options, _labelKey) {
|
|
52
|
+
if (!searchContent.value)
|
|
53
|
+
return options;
|
|
54
|
+
return options.filter((option) => filter(option, _labelKey));
|
|
55
|
+
}
|
|
56
|
+
return { searchContent, searchContentMatcher, optionSearchFilter };
|
|
57
|
+
}
|
|
58
|
+
function useRecommendOptions(props, options, emit, labelKey, valueKey) {
|
|
25
59
|
const commonListRef = createPropRef(props, "commonList");
|
|
26
60
|
const recentListRef = createPropRef(props, "recentList");
|
|
61
|
+
const { searchContent, optionSearchFilter } = useSearchContent();
|
|
27
62
|
function getRecommendOption(item) {
|
|
28
63
|
return jsonParse(item.itemObj);
|
|
29
64
|
}
|
|
@@ -44,7 +79,11 @@ function useRecommendOptions(props, options, emit, valueKey) {
|
|
|
44
79
|
return item[valueKey.value] !== option[valueKey.value];
|
|
45
80
|
}
|
|
46
81
|
});
|
|
47
|
-
return [
|
|
82
|
+
return [
|
|
83
|
+
...optionSearchFilter(commonOptions.value, labelKey.value),
|
|
84
|
+
...optionSearchFilter(recentOptions.value, labelKey.value),
|
|
85
|
+
...optionWithoutRecommend
|
|
86
|
+
];
|
|
48
87
|
});
|
|
49
88
|
const { getRecommendRequestInfo, getHttpInstance } = useFormRequest();
|
|
50
89
|
function getRecommendConfig(type) {
|
|
@@ -55,9 +94,10 @@ function useRecommendOptions(props, options, emit, valueKey) {
|
|
|
55
94
|
}
|
|
56
95
|
const { fieldKey } = useFormField();
|
|
57
96
|
const asyncQueue = inject(InjectionAsyncQueue);
|
|
58
|
-
async function getRecommend() {
|
|
97
|
+
async function getRecommend(content) {
|
|
59
98
|
if (!props.recommend)
|
|
60
99
|
return;
|
|
100
|
+
searchContent.value = content;
|
|
61
101
|
if (commonListRef.value && recentListRef.value && props.recommendCache)
|
|
62
102
|
return;
|
|
63
103
|
const list = await asyncQueue.addAsync(createParams(fieldKey.value, props.recommendCache));
|
|
@@ -125,11 +165,11 @@ function useUrlConfigOptions(props, valueRef) {
|
|
|
125
165
|
var _a, _b;
|
|
126
166
|
return (_b = (_a = props.urlConfig) == null ? void 0 : _a.valueKey) != null ? _b : "value";
|
|
127
167
|
});
|
|
168
|
+
const { searchContent, optionSearchFilter } = useSearchContent();
|
|
128
169
|
const remoteOptions = ref(null);
|
|
129
|
-
const lastSearch = ref("");
|
|
130
170
|
const { field, fieldKey } = useFormField();
|
|
131
171
|
const fetchData = useDebounceFn(async function(content) {
|
|
132
|
-
|
|
172
|
+
searchContent.value = content || "";
|
|
133
173
|
if (!props.urlConfig) {
|
|
134
174
|
return remoteOptions.value = null;
|
|
135
175
|
}
|
|
@@ -147,10 +187,10 @@ function useUrlConfigOptions(props, valueRef) {
|
|
|
147
187
|
}, 300);
|
|
148
188
|
const options = computed(() => {
|
|
149
189
|
if (remoteOptions.value)
|
|
150
|
-
return
|
|
190
|
+
return optionSearchFilter(remoteOptions.value, labelKey.value);
|
|
151
191
|
if (!Array.isArray(props.options))
|
|
152
192
|
return [];
|
|
153
|
-
return
|
|
193
|
+
return optionSearchFilter(props.options, labelKey.value);
|
|
154
194
|
});
|
|
155
195
|
const formItemDepsCollector = inject(InjectionFormItemDepsCollector);
|
|
156
196
|
watch(
|
|
@@ -183,12 +223,12 @@ function useAutographOptions(props, valueRef) {
|
|
|
183
223
|
var _a, _b;
|
|
184
224
|
return (_b = (_a = props.wordbook) == null ? void 0 : _a.value_key) != null ? _b : "value";
|
|
185
225
|
});
|
|
226
|
+
const { searchContent, optionSearchFilter } = useSearchContent();
|
|
186
227
|
const remoteOptions = ref(null);
|
|
187
|
-
const lastSearch = ref("");
|
|
188
228
|
const { fieldKey } = useFormField();
|
|
189
229
|
const { getSearchRequestInfo } = useFormRequest();
|
|
190
230
|
const fetchData = useDebounceFn(async function(content) {
|
|
191
|
-
|
|
231
|
+
searchContent.value = content || "";
|
|
192
232
|
if (!props.autograph || !props.wordbook) {
|
|
193
233
|
return remoteOptions.value = null;
|
|
194
234
|
}
|
|
@@ -211,10 +251,10 @@ function useAutographOptions(props, valueRef) {
|
|
|
211
251
|
}, 300);
|
|
212
252
|
const options = computed(() => {
|
|
213
253
|
if (remoteOptions.value)
|
|
214
|
-
return
|
|
254
|
+
return optionSearchFilter(remoteOptions.value, labelKey.value);
|
|
215
255
|
if (!Array.isArray(props.options))
|
|
216
256
|
return [];
|
|
217
|
-
return
|
|
257
|
+
return optionSearchFilter(props.options, labelKey.value);
|
|
218
258
|
});
|
|
219
259
|
watch(
|
|
220
260
|
() => props.wordbook,
|
|
@@ -231,4 +271,4 @@ function useAutographOptions(props, valueRef) {
|
|
|
231
271
|
return { labelKey, valueKey, options, fetchData };
|
|
232
272
|
}
|
|
233
273
|
|
|
234
|
-
export { useAutographOptions, useRecommendOptions, useUrlConfigOptions };
|
|
274
|
+
export { optionMatcherCache, useAutographOptions, useRecommendOptions, useUrlConfigOptions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyObject, ArrayAble
|
|
1
|
+
import { AnyObject, ArrayAble } from '../../../../../es/shared/types';
|
|
2
2
|
import { GeneralField } from '@formily/core';
|
|
3
3
|
import { FunctionalComponent, InjectionKey, VNode } from 'vue';
|
|
4
4
|
import { FieldItem, UrlConfig } from '../types';
|
|
@@ -14,9 +14,7 @@ export declare function createSlot(renderer: unknown, props: AnyObject, defaultR
|
|
|
14
14
|
};
|
|
15
15
|
export declare function createInputSlot(props: AnyObject, defaultRenderer?: (v: unknown) => unknown[]): import("vue").ComputedRef<Record<string, FunctionalComponent<{}, {}>>>;
|
|
16
16
|
export declare function presetRequestHandler(res: unknown): AnyObject[];
|
|
17
|
-
export declare
|
|
18
|
-
keyword?: string;
|
|
19
|
-
}): AnyObject[];
|
|
17
|
+
export declare const keywordMatcher: import("@vueuse/core").UseMemoizedFn<boolean, [text: unknown, keyword: unknown]>;
|
|
20
18
|
export declare function validateMessageParser(message: string, fieldItem: Omit<FieldItem, 'reactions'>): string;
|
|
21
19
|
export declare function combineExtendKey(fieldList: FieldItem[], values: AnyObject): AnyObject;
|
|
22
20
|
export declare function splitExtendKey(fieldList: FieldItem[], values: AnyObject): AnyObject;
|
|
@@ -138,20 +138,6 @@ const keywordMatcher = useMemoize(function(text, keyword) {
|
|
|
138
138
|
}, "");
|
|
139
139
|
}
|
|
140
140
|
});
|
|
141
|
-
function optionMatcherWithKeyword(options, input, key, matcherOption = {
|
|
142
|
-
keyword: "keyword"
|
|
143
|
-
}) {
|
|
144
|
-
if (!input)
|
|
145
|
-
return options;
|
|
146
|
-
return options.filter((option) => {
|
|
147
|
-
if (!isString(keyFor(option)))
|
|
148
|
-
return;
|
|
149
|
-
return keyFor(option).includes(input) || matcherOption.keyword && keywordMatcher(input, option[matcherOption.keyword]);
|
|
150
|
-
});
|
|
151
|
-
function keyFor(option) {
|
|
152
|
-
return option[key];
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
141
|
function validateMessageParser(message, fieldItem) {
|
|
156
142
|
if (!isString(message) || !message)
|
|
157
143
|
return "";
|
|
@@ -252,4 +238,4 @@ async function createUrlConfigParams({
|
|
|
252
238
|
};
|
|
253
239
|
}
|
|
254
240
|
|
|
255
|
-
export { combineExtendKey, createInputSlot, createSlot, createUrlConfigParams, formRenderLog, injectOrProvide, isNestedFieldType, isNestedType,
|
|
241
|
+
export { combineExtendKey, createInputSlot, createSlot, createUrlConfigParams, formRenderLog, injectOrProvide, isNestedFieldType, isNestedType, keywordMatcher, mergeDeepProperties, parseNumberFromMaybeString, presetRequestHandler, splitExtendKey, validateMessageParser };
|