@robot-admin/naive-ui-components 0.22.1 → 0.23.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/CHANGELOG.md +10 -0
- package/README.md +7 -5
- package/README_EN.md +7 -5
- package/dist/C_ActionBar.d.cts +2 -1
- package/dist/C_ActionBar.d.ts +2 -1
- package/dist/C_AntV2.cjs +3 -3
- package/dist/C_AntV2.js +3 -3
- package/dist/C_BatchResult.cjs +1 -0
- package/dist/C_BatchResult.css +32 -0
- package/dist/C_BatchResult.d.cts +2 -0
- package/dist/C_BatchResult.d.ts +2 -0
- package/dist/C_BatchResult.js +1 -0
- package/dist/C_BatchResult2.cjs +1 -0
- package/dist/C_BatchResult2.js +1 -0
- package/dist/C_Breadcrumb.d.cts +2 -2
- package/dist/C_Breadcrumb.d.ts +1 -1
- package/dist/C_Cascade.d.cts +1 -1
- package/dist/C_Cascade.d.ts +1 -1
- package/dist/C_Chat.d.cts +1 -1
- package/dist/C_Chat.d.ts +1 -1
- package/dist/C_City.d.cts +1 -1
- package/dist/C_City.d.ts +1 -1
- package/dist/C_Code.d.cts +1 -1
- package/dist/C_Code.d.ts +1 -1
- package/dist/C_ContextMenu.d.cts +1 -1
- package/dist/C_ContextMenu.d.ts +1 -1
- package/dist/C_DataPicker.cjs +1 -0
- package/dist/C_DataPicker.css +54 -0
- package/dist/C_DataPicker.d.cts +2 -0
- package/dist/C_DataPicker.d.ts +5 -0
- package/dist/C_DataPicker.js +1 -0
- package/dist/C_DataPicker2.cjs +1 -0
- package/dist/C_DataPicker2.js +1 -0
- package/dist/C_Date.d.cts +1 -1
- package/dist/C_Date.d.ts +1 -1
- package/dist/C_Density.cjs +1 -0
- package/dist/C_Density.css +1 -0
- package/dist/C_Density.d.cts +3 -0
- package/dist/C_Density.d.ts +3 -0
- package/dist/C_Density.js +1 -0
- package/dist/C_Density2.cjs +1 -0
- package/dist/C_Density2.js +1 -0
- package/dist/C_Editor.d.cts +1 -1
- package/dist/C_Editor.d.ts +1 -1
- package/dist/C_ErrorSummary.cjs +1 -0
- package/dist/C_ErrorSummary.css +29 -0
- package/dist/C_ErrorSummary.d.cts +3 -0
- package/dist/C_ErrorSummary.d.ts +3 -0
- package/dist/C_ErrorSummary.js +1 -0
- package/dist/C_ErrorSummary2.cjs +1 -0
- package/dist/C_ErrorSummary2.js +1 -0
- package/dist/C_Form.base.css +150 -148
- package/dist/C_Form.css +151 -253
- package/dist/C_Form.d.cts +1 -1
- package/dist/C_Form.d.ts +19 -2
- package/dist/C_FormModal.css +1 -2
- package/dist/C_FormModal.d.cts +1 -1
- package/dist/C_FormModal.d.ts +17 -2
- package/dist/C_FormSearch.cjs +1 -1
- package/dist/C_FormSearch.css +124 -52
- package/dist/C_FormSearch.d.cts +3 -3
- package/dist/C_FormSearch.d.ts +5 -4
- package/dist/C_FormSearch.js +1 -1
- package/dist/C_FormulaEditor.d.cts +1 -1
- package/dist/C_FormulaEditor.d.ts +1 -1
- package/dist/C_Guide.d.cts +1 -1
- package/dist/C_Guide.d.ts +1 -1
- package/dist/C_Icon.d.cts +1 -1
- package/dist/C_Icon.d.ts +1 -1
- package/dist/C_Language.d.cts +1 -1
- package/dist/C_Language.d.ts +1 -1
- package/dist/C_Loading.d.cts +1 -1
- package/dist/C_Loading.d.ts +1 -1
- package/dist/C_Login.d.cts +1 -1
- package/dist/C_Login.d.ts +1 -1
- package/dist/C_Markdown.d.cts +1 -1
- package/dist/C_Markdown.d.ts +1 -1
- package/dist/C_Menu.d.cts +2 -2
- package/dist/C_Menu.d.ts +1 -1
- package/dist/C_OrgChart.d.cts +1 -1
- package/dist/C_OrgChart.d.ts +1 -1
- package/dist/C_Progress.d.cts +1 -1
- package/dist/C_Progress.d.ts +1 -1
- package/dist/C_SectionNav.cjs +1 -0
- package/dist/C_SectionNav.css +46 -0
- package/dist/C_SectionNav.d.cts +2 -0
- package/dist/C_SectionNav.d.ts +2 -0
- package/dist/C_SectionNav.js +1 -0
- package/dist/C_SectionNav2.cjs +1 -0
- package/dist/C_SectionNav2.js +1 -0
- package/dist/C_Skeleton.d.cts +1 -1
- package/dist/C_Skeleton.d.ts +1 -1
- package/dist/C_Steps.d.cts +1 -1
- package/dist/C_Steps.d.ts +1 -1
- package/dist/C_Table.base.css +258 -256
- package/dist/C_Table.cjs +1 -1
- package/dist/C_Table.css +109 -1283
- package/dist/C_Table.d.cts +2 -1
- package/dist/C_Table.d.ts +9 -8
- package/dist/C_Table.js +1 -1
- package/dist/C_Table2.cjs +3 -0
- package/dist/C_Table2.js +3 -0
- package/dist/C_Tabs.cjs +1 -1
- package/dist/C_Tabs.d.cts +1 -1
- package/dist/C_Tabs.d.ts +1 -1
- package/dist/C_Tabs.js +1 -1
- package/dist/C_TagsView.d.cts +1 -1
- package/dist/C_Theme.d.cts +1 -1
- package/dist/C_Theme.d.ts +1 -1
- package/dist/C_Timeline.d.cts +1 -1
- package/dist/C_Timeline.d.ts +1 -1
- package/dist/C_Transfer.d.cts +1 -1
- package/dist/C_Transfer.d.ts +1 -1
- package/dist/C_Tree.d.cts +1 -1
- package/dist/C_Tree.d.ts +9 -8
- package/dist/C_Upload.d.cts +1 -1
- package/dist/C_Upload.d.ts +1 -1
- package/dist/C_WorkFlow2.cjs +1 -1
- package/dist/C_WorkFlow2.js +1 -1
- package/dist/Card.cjs +1 -1
- package/dist/Card.js +1 -1
- package/dist/Steps.cjs +1 -1
- package/dist/Steps.js +1 -1
- package/dist/Tabs.cjs +1 -1
- package/dist/Tabs.js +1 -1
- package/dist/batchPatch.cjs +1 -0
- package/dist/batchPatch.d.cts +26 -0
- package/dist/batchPatch.d.ts +26 -0
- package/dist/batchPatch.js +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +4 -1
- package/dist/config.d.ts +6 -2
- package/dist/config.js +1 -1
- package/dist/config2.d.ts +1 -1
- package/dist/constants.d.cts +3 -3
- package/dist/constants.d.ts +3 -3
- package/dist/constants2.d.cts +402 -173
- package/dist/constants2.d.ts +402 -173
- package/dist/constants3.d.cts +4 -4
- package/dist/constants3.d.ts +4 -4
- package/dist/constants4.d.cts +173 -402
- package/dist/constants4.d.ts +173 -402
- package/dist/constants5.d.cts +2 -2
- package/dist/constants5.d.ts +2 -2
- package/dist/contracts.d.ts +24 -0
- package/dist/data.cjs +1 -1
- package/dist/data.d.cts +5 -108
- package/dist/data.d.ts +5 -108
- package/dist/data.js +1 -1
- package/dist/data2.cjs +1 -1
- package/dist/data2.d.cts +108 -0
- package/dist/data2.d.ts +108 -0
- package/dist/data2.js +1 -1
- package/dist/data3.cjs +1 -0
- package/dist/data3.js +1 -0
- package/dist/dateRange.d.cts +108 -13
- package/dist/dateRange.d.ts +110 -14
- package/dist/density.d.ts +15 -0
- package/dist/dictionary.cjs +1 -0
- package/dist/dictionary.d.cts +38 -0
- package/dist/dictionary.d.ts +38 -0
- package/dist/dictionary.js +1 -0
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +63 -52
- package/dist/index.d.ts +71 -57
- package/dist/index.js +1 -1
- package/dist/index.vue.d.cts +5 -5
- package/dist/index.vue.d.ts +5 -5
- package/dist/index10.vue.d.cts +37 -80
- package/dist/index10.vue.d.ts +77 -53
- package/dist/index11.vue.d.cts +77 -53
- package/dist/index11.vue.d.ts +1117 -45
- package/dist/index12.vue.d.cts +1117 -45
- package/dist/index12.vue.d.ts +17 -128
- package/dist/index13.vue.d.cts +17 -128
- package/dist/index13.vue.d.ts +57 -53
- package/dist/index14.vue.d.cts +57 -53
- package/dist/index14.vue.d.ts +16 -25
- package/dist/index15.vue.d.cts +16 -25
- package/dist/index15.vue.d.ts +52 -12
- package/dist/index16.vue.d.cts +52 -12
- package/dist/index16.vue.d.ts +13 -129
- package/dist/index17.vue.d.cts +13 -129
- package/dist/index17.vue.d.ts +123 -74
- package/dist/index18.vue.d.cts +123 -74
- package/dist/index18.vue.d.ts +48 -71
- package/dist/index19.vue.d.cts +40 -91
- package/dist/index19.vue.d.ts +36 -96
- package/dist/index2.vue.d.cts +2 -2
- package/dist/index2.vue.d.ts +2 -2
- package/dist/index20.vue.d.cts +38 -47
- package/dist/index20.vue.d.ts +13 -48
- package/dist/index21.vue.d.cts +12 -96
- package/dist/index21.vue.d.ts +25 -95
- package/dist/index22.vue.d.cts +20 -32
- package/dist/index22.vue.d.ts +75 -37
- package/dist/index23.vue.d.cts +77 -13
- package/dist/index23.vue.d.ts +71 -13
- package/dist/index24.vue.d.cts +1 -1
- package/dist/index25.vue.d.cts +116 -90
- package/dist/index25.vue.d.ts +116 -90
- package/dist/index26.vue.d.cts +94 -59
- package/dist/index26.vue.d.ts +94 -59
- package/dist/index27.vue.d.cts +75 -0
- package/dist/index27.vue.d.ts +75 -0
- package/dist/index28.vue.d.cts +103 -0
- package/dist/index28.vue.d.ts +103 -0
- package/dist/index29.vue.d.cts +105 -0
- package/dist/index29.vue.d.ts +105 -0
- package/dist/index3.vue.d.cts +5 -5
- package/dist/index3.vue.d.ts +5 -5
- package/dist/index30.vue.d.cts +28 -0
- package/dist/index30.vue.d.ts +28 -0
- package/dist/index4.vue.d.cts +19 -128
- package/dist/index4.vue.d.ts +17 -34
- package/dist/index5.vue.d.cts +127 -35
- package/dist/index5.vue.d.ts +30 -19
- package/dist/index6.vue.d.cts +30 -19
- package/dist/index6.vue.d.ts +22 -118
- package/dist/index7.vue.d.cts +22 -118
- package/dist/index7.vue.d.ts +112 -18
- package/dist/index8.vue.d.cts +112 -18
- package/dist/index8.vue.d.ts +24 -35
- package/dist/index9.vue.d.cts +24 -35
- package/dist/index9.vue.d.ts +37 -80
- package/dist/mapUtils.d.cts +4 -4
- package/dist/mapUtils.d.ts +4 -4
- package/dist/numberCodec.cjs +1 -0
- package/dist/numberCodec.d.cts +25 -0
- package/dist/numberCodec.d.ts +25 -0
- package/dist/numberCodec.js +1 -0
- package/dist/observer.cjs +1 -0
- package/dist/observer.js +1 -0
- package/dist/presets.d.cts +3 -66
- package/dist/presets.d.ts +3 -66
- package/dist/resolver.cjs +1 -1
- package/dist/resolver.d.cts +1 -1
- package/dist/resolver.d.ts +1 -1
- package/dist/resolver.js +1 -1
- package/dist/serializeSearch.cjs +1 -0
- package/dist/serializeSearch.js +1 -0
- package/dist/style.css +547 -308
- package/dist/types.d.cts +60 -103
- package/dist/types.d.ts +62 -52
- package/dist/types2.d.cts +104 -51
- package/dist/types2.d.ts +56 -0
- package/dist/types3.d.cts +56 -0
- package/dist/useCollapsePanel.d.cts +6 -6
- package/dist/useCollapsePanel.d.ts +6 -6
- package/dist/useComponentLocale.cjs +1 -1
- package/dist/useComponentLocale.js +1 -1
- package/dist/useCropperCore.d.cts +13 -13
- package/dist/useCropperCore.d.ts +13 -13
- package/dist/useDataResource.cjs +1 -0
- package/dist/useDataResource.js +1 -0
- package/dist/useDictionary.cjs +1 -0
- package/dist/useDictionary.js +1 -0
- package/dist/useDynamicFormState.d.cts +960 -10
- package/dist/useDynamicFormState.d.ts +951 -11
- package/dist/useEdgeInteraction.d.cts +3 -3
- package/dist/useEdgeInteraction.d.ts +3 -3
- package/dist/useFormArray.cjs +1 -0
- package/dist/useFormArray.d.cts +69 -0
- package/dist/useFormArray.d.ts +69 -0
- package/dist/useFormArray.js +1 -0
- package/dist/useFormConfig.d.cts +14 -0
- package/dist/useFormConfig.d.ts +17 -38
- package/dist/useGridWidth.cjs +1 -0
- package/dist/useGridWidth.js +1 -0
- package/dist/useInfiniteScroll.d.cts +3 -3
- package/dist/useInfiniteScroll.d.ts +3 -3
- package/dist/useQRCode.d.cts +5 -5
- package/dist/useQRCode.d.ts +5 -5
- package/dist/useSignatureHistory.d.cts +7 -7
- package/dist/useSignatureHistory.d.ts +7 -7
- package/dist/useSplitResize.d.cts +9 -9
- package/dist/useSplitResize.d.ts +9 -9
- package/dist/useTableGlobalConfig.cjs +1 -0
- package/dist/useTableGlobalConfig.js +1 -0
- package/dist/useTableQuery.cjs +1 -3
- package/dist/useTableQuery.js +1 -3
- package/dist/useWorkflowValidation.d.cts +5 -5
- package/dist/useWorkflowValidation.d.ts +5 -5
- package/dist/validation.cjs +1 -0
- package/dist/validation.d.cts +18 -0
- package/dist/validation.d.ts +18 -0
- package/dist/validation.js +1 -0
- package/dist/verification.d.cts +4 -4
- package/dist/verification.d.ts +5 -5
- package/dist/workflows.cjs +1 -0
- package/dist/workflows.d.cts +2 -0
- package/dist/workflows.d.ts +2 -0
- package/dist/workflows.js +1 -0
- package/docs/components.en.md +13 -1
- package/docs/components.md +13 -1
- package/docs/guides/batch-results.md +47 -0
- package/docs/guides/data-picker.md +65 -0
- package/docs/guides/data-workflows.md +123 -0
- package/docs/guides/form-density.en.md +39 -0
- package/docs/guides/form-density.md +39 -0
- package/docs/guides/search-workflows.md +164 -0
- package/package.json +21 -1
- package/dist/C_FormSearch2.cjs +0 -1
- package/dist/C_FormSearch2.js +0 -1
- package/dist/useTableQuery.d.cts +0 -1957
- package/dist/useTableQuery.d.ts +0 -1946
package/dist/verification.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as ComponentLocale, t as ComponentFeedback } from "./contracts.js";
|
|
2
2
|
import * as vue from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/C_Captcha/types.d.ts
|
|
@@ -76,20 +76,20 @@ declare const __VLS_export: vue.DefineComponent<CaptchaProps, {
|
|
|
76
76
|
reset: () => void;
|
|
77
77
|
show: () => void;
|
|
78
78
|
}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {} & {
|
|
79
|
+
reset: () => any;
|
|
79
80
|
change: (valid: boolean) => any;
|
|
80
81
|
success: (data: CaptchaSuccessPayload) => any;
|
|
81
|
-
reset: () => any;
|
|
82
|
-
"load-error": (error: unknown) => any;
|
|
83
82
|
fail: (error: string) => any;
|
|
84
83
|
"verify-error": (error: unknown) => any;
|
|
84
|
+
"load-error": (error: unknown) => any;
|
|
85
85
|
"visible-change": (visible: boolean) => any;
|
|
86
86
|
}, string, vue.PublicProps, Readonly<CaptchaProps> & Readonly<{
|
|
87
|
+
onReset?: (() => any) | undefined;
|
|
87
88
|
onChange?: ((valid: boolean) => any) | undefined;
|
|
88
89
|
onSuccess?: ((data: CaptchaSuccessPayload) => any) | undefined;
|
|
89
|
-
onReset?: (() => any) | undefined;
|
|
90
|
-
"onLoad-error"?: ((error: unknown) => any) | undefined;
|
|
91
90
|
onFail?: ((error: string) => any) | undefined;
|
|
92
91
|
"onVerify-error"?: ((error: unknown) => any) | undefined;
|
|
92
|
+
"onLoad-error"?: ((error: unknown) => any) | undefined;
|
|
93
93
|
"onVisible-change"?: ((visible: boolean) => any) | undefined;
|
|
94
94
|
}>, {
|
|
95
95
|
disabled: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useDataResource.cjs`),t=require(`./useFormArray.cjs`);exports.useDataResource=e.t,exports.useFormArray=t.t,exports.useValidationScope=t.n;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DataResourceOptions, i as useValidationScope, n as useFormArray, o as DataResourceStatus, r as ValidationParticipant, s as useDataResource, t as FormArrayEntry } from "./useFormArray.cjs";
|
|
2
|
+
export { type DataResourceOptions, type DataResourceStatus, type FormArrayEntry, type ValidationParticipant, useDataResource, useFormArray, useValidationScope };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DataResourceOptions, i as useValidationScope, n as useFormArray, o as DataResourceStatus, r as ValidationParticipant, s as useDataResource, t as FormArrayEntry } from "./useFormArray.js";
|
|
2
|
+
export { type DataResourceOptions, type DataResourceStatus, type FormArrayEntry, type ValidationParticipant, useDataResource, useFormArray, useValidationScope };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./useDataResource.js";import{n as t,t as n}from"./useFormArray.js";export{e as useDataResource,n as useFormArray,t as useValidationScope};
|
package/docs/components.en.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Component catalog
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Use the online docs and repository guides for component contracts, and Robot Admin demos for combined workflows.
|
|
6
6
|
|
|
7
7
|
## Basic Components
|
|
8
8
|
|
|
@@ -120,3 +120,15 @@ bun add vue naive-ui
|
|
|
120
120
|
```
|
|
121
121
|
|
|
122
122
|
Install optional peers per feature: `vue-router` for `C_Breadcrumb`/`C_TagsView`, and `sortablejs` for C_Table row/column dragging. Subpath imports do not require unrelated optional peers. The formula editor uses a bounded built-in parser and does not execute dynamic JavaScript.
|
|
123
|
+
|
|
124
|
+
## Business workspace components
|
|
125
|
+
|
|
126
|
+
| Component | Purpose |
|
|
127
|
+
| ---------------- | --------------------------------------------------------- |
|
|
128
|
+
| `C_Density` | Regional density defaults without wrapper DOM |
|
|
129
|
+
| `C_SectionNav` | Section navigation, error badges and keyboard focus |
|
|
130
|
+
| `C_ErrorSummary` | Navigable validation issues with bounded DOM |
|
|
131
|
+
| `C_DataPicker` | Paged entity selection, cross-page draft and batch labels |
|
|
132
|
+
| `C_BatchResult` | Per-item results, filtering, paging and explicit retry |
|
|
133
|
+
|
|
134
|
+
The [data/workflow guide](./guides/data-workflows.md) covers shared dictionaries, numeric codecs, dependent resources, validation scopes and repeatable forms.
|
package/docs/components.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# 组件目录
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
组件用法见在线文档与本仓库指南,组合场景可在 Robot Admin 演示中体验。
|
|
6
6
|
|
|
7
7
|
## 基础组件
|
|
8
8
|
|
|
@@ -120,3 +120,15 @@ bun add vue naive-ui
|
|
|
120
120
|
```
|
|
121
121
|
|
|
122
122
|
按功能安装可选 peer:使用 `C_Breadcrumb`/`C_TagsView` 时安装 `vue-router`;启用 C_Table 行/列拖拽时安装 `sortablejs`。子路径导入不会要求无关的可选 peer。公式编辑器使用组件库内置的受限表达式解析器,不执行动态 JavaScript。
|
|
123
|
+
|
|
124
|
+
## 业务工作台组件
|
|
125
|
+
|
|
126
|
+
| 组件 | 说明 |
|
|
127
|
+
| ---------------- | -------------------------------- |
|
|
128
|
+
| `C_Density` | 子树密度默认值,无额外 DOM |
|
|
129
|
+
| `C_SectionNav` | 分区导航、错误计数与键盘焦点 |
|
|
130
|
+
| `C_ErrorSummary` | 可导航错误摘要,分页限制 DOM |
|
|
131
|
+
| `C_DataPicker` | 分页实体选择、跨页草稿与批量回显 |
|
|
132
|
+
| `C_BatchResult` | 分项结果、筛选分页与显式重试 |
|
|
133
|
+
|
|
134
|
+
[数据与工作流指南](./guides/data-workflows.md):共享字典、数值转换、主从资源、跨区域校验及重复表单。
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# 批量操作结果
|
|
2
|
+
|
|
3
|
+
`C_BatchResult` 呈现成功、失败、冲突、跳过及失败原因,支持筛选、分页与显式重试。组件不提交请求,也不自行重试。
|
|
4
|
+
|
|
5
|
+
```vue
|
|
6
|
+
<script setup lang="ts">
|
|
7
|
+
import { C_BatchResult } from '@robot-admin/naive-ui-components/C_BatchResult'
|
|
8
|
+
import type { BatchOperationResult } from '@robot-admin/naive-ui-components/data'
|
|
9
|
+
import '@robot-admin/naive-ui-components/C_BatchResult/style.css'
|
|
10
|
+
|
|
11
|
+
const results: BatchOperationResult[] = [
|
|
12
|
+
{ key: 'ORDER-1', status: 'success' },
|
|
13
|
+
{
|
|
14
|
+
key: 'ORDER-2',
|
|
15
|
+
status: 'conflict',
|
|
16
|
+
message: '版本已改变,请核对后重试',
|
|
17
|
+
retryable: true,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
key: 'ORDER-3',
|
|
21
|
+
status: 'failure',
|
|
22
|
+
message: '当前状态不允许操作',
|
|
23
|
+
retryable: false,
|
|
24
|
+
},
|
|
25
|
+
]
|
|
26
|
+
function retry(keys: (string | number)[]) {
|
|
27
|
+
// 使用应用已有的命令适配器;后端仍须再次校验权限、状态、版本和幂等令牌。
|
|
28
|
+
orderActions.retry(keys)
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<C_BatchResult
|
|
34
|
+
:results="results"
|
|
35
|
+
title="下达结果"
|
|
36
|
+
@retry="retry"
|
|
37
|
+
/>
|
|
38
|
+
</template>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
同一 `key` 多次出现时,以最后一条结果为准,摘要、表格和重试资格保持一致。`retry` 只发送最后状态为 `failure` / `conflict` 且 `retryable: true` 的去重key;后来已成功或跳过的行不会再次发送。失败不等于允许重试。
|
|
42
|
+
|
|
43
|
+
默认每页20条,可通过 `pageSize` 调整;表格只接收当前页行并使用虚拟滚动,万条结果不会同时创建万条DOM。切换状态筛选时回到第一页,结果数量缩小会修正页码。
|
|
44
|
+
|
|
45
|
+
原因按文本显示。不要把HTML、Vue节点或后端原始异常堆栈塞进 `message`;业务应提供可以行动的原因,并决定是否保留失败行的编辑草稿、是否刷新成功行以及如何处理冲突。
|
|
46
|
+
|
|
47
|
+
`locale` 支持应用默认和组件局部中英文配置,统计、筛选、列头与重试文案会随配置更新;显式 `title` 优先。
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# 远程实体选择器
|
|
2
|
+
|
|
3
|
+
`C_DataPicker` 用于客户、订单、人员、物料等需要分页查询和多列辨认的选择场景。它复用 `C_Table`、Naive Modal 和资源生命周期,不绑定后端地址,也不维护第二份请求缓存。
|
|
4
|
+
|
|
5
|
+
```vue
|
|
6
|
+
<script setup lang="ts">
|
|
7
|
+
import { ref } from 'vue'
|
|
8
|
+
import {
|
|
9
|
+
C_DataPicker,
|
|
10
|
+
type DataPickerSource,
|
|
11
|
+
} from '@robot-admin/naive-ui-components/C_DataPicker'
|
|
12
|
+
import '@robot-admin/naive-ui-components/C_DataPicker/style.css'
|
|
13
|
+
|
|
14
|
+
interface Customer {
|
|
15
|
+
id: string
|
|
16
|
+
code: string
|
|
17
|
+
name: string
|
|
18
|
+
}
|
|
19
|
+
const selected = ref<string[]>([])
|
|
20
|
+
|
|
21
|
+
// customerClient 是应用已有的请求/缓存适配器;signal 透传给真实请求。
|
|
22
|
+
const source: DataPickerSource<Customer> = {
|
|
23
|
+
rowKey: 'id',
|
|
24
|
+
value: row => row.code,
|
|
25
|
+
label: row => row.name,
|
|
26
|
+
request: query => customerClient.page(query), // { rows: Customer[], total: number }
|
|
27
|
+
resolve: (codes, signal) => customerClient.byCodes(codes, { signal }),
|
|
28
|
+
}
|
|
29
|
+
const columns = [
|
|
30
|
+
{ key: 'code', title: '客户编码', width: 140 },
|
|
31
|
+
{ key: 'name', title: '客户名称', minWidth: 180 },
|
|
32
|
+
]
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<C_DataPicker
|
|
37
|
+
v-model="selected"
|
|
38
|
+
:source="source"
|
|
39
|
+
:columns="columns"
|
|
40
|
+
multiple
|
|
41
|
+
clearable
|
|
42
|
+
title="选择客户"
|
|
43
|
+
/>
|
|
44
|
+
</template>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 值与会话
|
|
48
|
+
|
|
49
|
+
- `source.rowKey` 是表格行身份;`source.value(row)` 是业务提交值,两者可以不同,均须稳定且唯一。业务值支持字符串和数值,`0` 是有效值。
|
|
50
|
+
- 选择在本地草稿中进行,跨分页保留;只有“确认选择”或显式清空才发出 `update:modelValue`。取消、关闭弹窗、卸载不会提交草稿。
|
|
51
|
+
- `select(rows)` 返回已解析的选中行。提供 `source.resolve(values, signal)` 可一次批量回显全部初值;未提供时,尚未加载的初值显示原编码且保留,不猜测标签,不逐条请求。需要完整 `rows` 事件的场景应提供 `resolve`。
|
|
52
|
+
- 源、受控值、单多选模式或可用状态改变时关闭旧会话;旧请求即使忽略 signal,也不能回写到新会话。
|
|
53
|
+
- `readonly` 保留名称展示,但不打开选择、清空或确认;`disabled` 同样禁止变更。名称加载失败保留编码并提供重试。
|
|
54
|
+
|
|
55
|
+
## 请求与布局
|
|
56
|
+
|
|
57
|
+
`request` 接收 `{ page, pageSize, search, signal }`,返回 `{ rows, total }`。应用负责接口字段转换、鉴权、业务过滤、去重及缓存。组件不猜测 `data.records` 等响应信封。
|
|
58
|
+
|
|
59
|
+
默认 `pageSize=20`;密度按显式 `density`、区域 `C_Density` / 表单默认密度、`compact` 依次解析,支持 `default`、`comfortable`。列表使用虚拟表格,已选标签最多同时呈现30个,其余显示数量。可通过实例 `open()` / `close()` 控制选择会话。
|
|
60
|
+
|
|
61
|
+
`locale` 可覆盖应用中英文配置,标题和 placeholder 的显式配置优先;运行时切换语言不会清空选择草稿。
|
|
62
|
+
|
|
63
|
+
同一页的业务值必须唯一且为字符串或有限数值;响应的 `rows`、`total` 无效时显示失败和重试入口。`total` 必须为非负安全整数;行身份不可缺失或重复,返回行数不得超过所请求的 `pageSize` 或 `total`,不靠静默截断伪装成合法分页。跨页再次出现同一实体时保留一项选择,移除已选标签会取消该实体。
|
|
64
|
+
|
|
65
|
+
在 Form/Search 中通过现有自定义渲染器使用这一组件。将 `source` 在业务集成层定义一次并复用即可,不需要让所有表单或搜索入口静态依赖实体选择器。
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# 业务数据与多区域工作台
|
|
2
|
+
|
|
3
|
+
搜索、表单和表格共享值语义,应用保留接口、权限、缓存和业务事务。新增能力均按需接入;未配置时沿用既有行为。
|
|
4
|
+
|
|
5
|
+
## 一个字典数据源
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import Components from '@robot-admin/naive-ui-components'
|
|
9
|
+
import type { DictionarySource } from '@robot-admin/naive-ui-components/config'
|
|
10
|
+
|
|
11
|
+
const planState: DictionarySource = {
|
|
12
|
+
getOptions: () => [
|
|
13
|
+
{ value: 'released', label: '已下达' },
|
|
14
|
+
{ value: 'running', label: '执行中' },
|
|
15
|
+
],
|
|
16
|
+
}
|
|
17
|
+
app.use(Components, {
|
|
18
|
+
dictionaries: {
|
|
19
|
+
getDictionary: name => (name === 'planState' ? planState : undefined),
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
字段只写 `dictionary: 'planState'`。C_Form 的 `children`、`asyncOptions`,C_FormSearch 的显式 `list/attrs.options`,C_Table 的 `render/formatter/editProps.options` 仍按各自既有优先级生效,未使用的字典不会被加载。
|
|
25
|
+
|
|
26
|
+
按需安装可通过 `/config` 导出的 `DICTIONARY_PROVIDER_KEY` 注入同一个 Provider。不要因为使用表单而导入 MachTable 根包。
|
|
27
|
+
|
|
28
|
+
`DictionarySource` 支持:
|
|
29
|
+
|
|
30
|
+
- `getOptions()`:同步快照,编码保留 string/number/boolean 类型。
|
|
31
|
+
- `load({ signal })`:可选的异步准备;视图会忽略已失效的请求。
|
|
32
|
+
- `subscribe(listener)`:可选的更新通知,返回取消订阅函数。
|
|
33
|
+
|
|
34
|
+
应用已有 store/resolver 时直接桥接,不叠加第二套 TTL 缓存。源负责组织、租户、语言和业务参数隔离:请求开始时捕获作用域,参数切换后不得把旧响应写进新作用域。可由 `getDictionary` 返回该作用域的稳定源,或发布当前快照变更通知。组件仅管理可销毁的选项视图及派生索引。
|
|
35
|
+
|
|
36
|
+
选项必须是有效且唯一的原始编码、字符串标签及可选 boolean disabled。空数组是已提供的空选项,不回退到旧数据。未知编码原样回显;停用历史编码可以保留在源中供展示。重复标签在反向解析时报告歧义,不自动选择第一项。高频展示使用 `createDictionaryLabelResolver(options)`,快照变化时重建一次索引。
|
|
37
|
+
|
|
38
|
+
## 数值:存储、显示和校验分别定义
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { createNumberCodec } from '@robot-admin/naive-ui-components/data'
|
|
42
|
+
import { numeric } from '@robot-admin/form-validate'
|
|
43
|
+
|
|
44
|
+
const weight = createNumberCodec({
|
|
45
|
+
storage: 'decimal-string',
|
|
46
|
+
fractionDigits: 3,
|
|
47
|
+
suffix: ' t',
|
|
48
|
+
})
|
|
49
|
+
const weightRules = [numeric({ totalDigits: 11, fractionDigits: 3, min: 0 })]
|
|
50
|
+
|
|
51
|
+
weight.parse('12345678.005') // '12345678.005'
|
|
52
|
+
weight.format('12.5004') // '12.500 t',只舍入显示,不改原值
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
精确小数用文本控件保留编辑草稿,C_Form 直接消费 `weightRules`,提交前再调用 `parse`。不要在每次输入时解析半成品文本,也不要把 `precision` 当作提交校验。清空得到 null,0 仍为有效数值。默认 number 存储会拒绝不安全整数和不能十进制往返的转换;已经被上游 number 损坏的精度不能恢复,精确接口应传原始字符串。
|
|
56
|
+
|
|
57
|
+
`fractionDigits: 0` 有效;HALF_UP 处理负数中点。parse 接收普通十进制原始值,format 可加千分位、前后缀;带单位/货币符号的显示文本不是接口值。合计、精确排序、汇率和税费按业务数值策略处理,不拿格式化文本计算。
|
|
58
|
+
|
|
59
|
+
MachTable 使用侧可在全局列类型中一次接入 `valueParser` 和 `valueFormatter`;精确字符串字段提供相应业务 comparator。其 `createDictionaryColumn` 可显式设置各输出 target 的编码/标签/码名策略,`summarizeRows` 可注入已有精确运算策略。Naive 库不会依赖或代替网格内核。
|
|
60
|
+
|
|
61
|
+
## 主从资源:本地空值与迟到响应
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { useDataResource } from '@robot-admin/naive-ui-components/workflows'
|
|
65
|
+
|
|
66
|
+
const details = useDataResource({
|
|
67
|
+
key: () => activeOrderId.value,
|
|
68
|
+
load: ({ key, signal }) => orderApi.details(key, { signal }),
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
更换 key 会取消旧请求、清除旧主记录数据;即使传输忽略 signal,旧结果也不能覆盖新记录。同 key 刷新失败保留原展示,`status: 'error'` 与 `stale` 明确表达旧快照,可通过 `reload()` 重试。reload 返回成功与否的 boolean,可直接交给 Search 的 `config.onSearch`。
|
|
73
|
+
|
|
74
|
+
可选 `source` 表示本地受控数据:undefined 才是未提供,`[]` 和 null 都是明确的本地源。本地源生效时不请求远端。组件卸载会清理 watcher/请求,KeepAlive 停用期间不开始新请求;恢复后按最新 key 继续。普通 effectScope 外使用时调用 `dispose()`。每个 panel 独立实例,互不共享请求状态;不缓存所有访问过的订单。
|
|
75
|
+
|
|
76
|
+
## 多区域校验和导航
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { useValidationScope } from '@robot-admin/naive-ui-components/workflows'
|
|
80
|
+
|
|
81
|
+
const validation = useValidationScope()
|
|
82
|
+
const unregister = validation.register({
|
|
83
|
+
id: 'header',
|
|
84
|
+
dirty: () => formRef.value?.isDirty ?? false,
|
|
85
|
+
validate: () => formRef.value!.validate(),
|
|
86
|
+
reveal: issue =>
|
|
87
|
+
formRef.value?.revealField(issue.target?.field ?? '') ?? false,
|
|
88
|
+
})
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
原生 `validate(): Promise<void>` 无需转换器,拒绝的字段错误会被标准化。表格校验可返回 `{ key, source, message, target: { section, tab, rowKey, field } }[]`;行地址使用稳定业务 key。注册标识必须唯一;动态区域移除时调用 unregister,旧验证结果不会回填。`dirty` 仅聚合已注册区域,不深遍历整张业务单据。
|
|
92
|
+
|
|
93
|
+
`C_ErrorSummary` 接收 `validation.issues`,`@navigate="validation.reveal"` 定位问题,默认每页仅挂载8项。`C_SectionNav` 的 items 包含 key/label/errorCount/disabled,通过 `@select` 接入现有分区或折叠面板;它不查找全局 DOM、不监听全局滚动。
|
|
94
|
+
|
|
95
|
+
Form 的 `revealField` 保留 Tab/Step 原有导航和校验约束,禁用或只读目标不强行聚焦,受阻返回 false。自定义控件通过 `focusTarget` 准备并返回真实元素;迟到的异步定位不会抢走当前焦点。
|
|
96
|
+
|
|
97
|
+
校验协调不等于数据库事务。保存使用业务接口的版本、幂等和分项结果;结果未确认时保留原操作及请求快照,避免自动重复提交。
|
|
98
|
+
|
|
99
|
+
## 密度和重复行
|
|
100
|
+
|
|
101
|
+
```vue
|
|
102
|
+
<C_Density density="compact">
|
|
103
|
+
<C_FormSearch ... />
|
|
104
|
+
<C_Form ... />
|
|
105
|
+
<C_Table ... />
|
|
106
|
+
<C_Density density="comfortable">
|
|
107
|
+
<!-- 工位操作区使用较大控件 -->
|
|
108
|
+
<C_Form ... />
|
|
109
|
+
</C_Density>
|
|
110
|
+
</C_Density>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
C_Density 无额外 DOM,只提供子树默认值,不修改应用或兄弟区域。局部 config、显式 size 继续优先。MachTable 的密度由其公开 size/config 独立配置。
|
|
114
|
+
|
|
115
|
+
少量异构重复行使用 `useFormArray(initial, { maxRows })`:items 中每行有稳定 key 与独立 value,增删移动保留身份,`getValues()` 返回隔离副本。reset 使用初始快照;动态删除时同步移除该行校验参与者。大量同构明细使用虚拟表格,不挂载整页常驻输入框。
|
|
116
|
+
|
|
117
|
+
## 批改、结果和输出边界
|
|
118
|
+
|
|
119
|
+
`createBatchPatch` 把 keep/clear/set 转为明确的标量 payload:keep 不发送,clear 发送 null,set 保留空串、0、false。非标量子记录仍由领域协议定义,不自动猜测嵌套更新。
|
|
120
|
+
|
|
121
|
+
`C_BatchResult` 只呈现结果和发出可重试 key,不调用后端。重复 key 以最新结果为准,后续成功项不会因旧失败再次重试。批改范围、差异预览、服务端授权和乐观锁由应用负责。见 [批量结果](./batch-results.md)、[远程实体选择](./data-picker.md)。
|
|
122
|
+
|
|
123
|
+
显示、复制、CSV、XLSX 各 target 可以采用不同策略,但必须使用同一已执行查询、字典和精度快照。大数据导出使用后端任务,模板排版/分页打印使用报表产品。不要把当前加载页当筛选全量,也不要在同步 formatter/serializer 内发请求。
|
|
@@ -54,3 +54,42 @@ app.provide(FORM_GLOBAL_CONFIG_KEY, { density: 'compact' })
|
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
Compact search fields default to 208px and fill the available width on narrow screens; explicit field `attrs.style.width` takes precedence. Compact numeric fields hide step buttons by default while preserving keyboard Up / Down, step, precision and limits. Set `attrs: { showButton: true }` when buttons are useful. Naive UI still owns number handling and themes; the text input avoids browser-native number spinners. Field `attrs.inputProps` can override accessible names and numeric semantics.
|
|
57
|
+
|
|
58
|
+
## Arrange fields by container width
|
|
59
|
+
|
|
60
|
+
Opt into `config.grid.minItemWidth` to budget the entire field, including its label. Default spans adapt to the actual split pane or dialog width. Explicit spans stay intact while they fit, and expand only when necessary, up to a full row. Existing `cols`, `offset`, `suffix`, and Naive UI wrapping remain in charge.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
const config = {
|
|
64
|
+
density: 'compact',
|
|
65
|
+
layout: 'grid',
|
|
66
|
+
grid: { cols: 24, minItemWidth: 300, xGap: 16, yGap: 8 },
|
|
67
|
+
} as const
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Omitting the option preserves existing spans. `responsive: false` disables automatic expansion. A container narrower than the budget uses a full row without forcing an overflowing CSS minimum width. One local `ResizeObserver` follows activation, deactivation, and disposal; no global resize listener is added.
|
|
71
|
+
|
|
72
|
+
## Reveal an invalid field
|
|
73
|
+
|
|
74
|
+
`await formRef.revealField(field)` enters the field's tab or step, or expands its card group, then scrolls to and focuses an available control. It returns `true` only after actual focus succeeds. Missing, hidden, disabled, or readonly fields, unloaded layouts, and navigation blocked by existing validation or business guards return `false`. It never clears errors, changes validation rules, or enables an editing mode.
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
const focused = await formRef.value?.revealField('customer.name')
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Lookup stays within this form's item references. Unmounting, KeepAlive deactivation, a layout change, or a newer reveal request cancels older work, so late results cannot steal focus. A custom or virtual control may supply `focusTarget` on its field. Prepare the control and return its actual element; let the form recheck access and apply focus rather than focusing inside the adapter.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const fields = [
|
|
84
|
+
{
|
|
85
|
+
type: 'custom-customer',
|
|
86
|
+
prop: 'customerId',
|
|
87
|
+
focusTarget: async ({ signal }) => {
|
|
88
|
+
await customerEditor.ensureMounted(signal)
|
|
89
|
+
return signal.aborted ? null : customerEditor.inputElement
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The context also provides `field`, the form item's `element` (possibly null), and the current `model`. An adapter that ignores cancellation still cannot apply an obsolete focus result. Return null when no real target exists; callers can keep the error summary visible or explain a navigation restriction.
|
|
@@ -71,3 +71,42 @@ app.provide(FORM_GLOBAL_CONFIG_KEY, { density: 'compact' })
|
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
紧凑搜索的字段默认宽度为 208px,窄屏自动占满可用宽度;显式字段 `attrs.style.width` 仍可覆盖。紧凑数字字段默认隐藏增减按钮,保留键盘 ↑ / ↓、步长、精度及上下限;需要按钮的字段配置 `attrs: { showButton: true }`。控件继续使用 Naive UI 的数值处理与主题,输入为文本,不叠加浏览器原生数字箭头;`attrs.inputProps` 可覆盖可访问名称和数值语义。
|
|
74
|
+
|
|
75
|
+
## 按容器安排字段
|
|
76
|
+
|
|
77
|
+
网格可显式设置 `config.grid.minItemWidth`,预算包含标签和控件整体,不是仅输入框宽度。根据当前分栏或弹窗容器的真实宽度调整默认跨度;已有显式 `span` 在宽度足够时保留,只有容纳不了该预算时才扩展,最多占满整行。`cols`、`offset`、`suffix` 与 Naive UI 换行规则不变。
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const config = {
|
|
81
|
+
density: 'compact',
|
|
82
|
+
layout: 'grid',
|
|
83
|
+
grid: { cols: 24, minItemWidth: 300, xGap: 16, yGap: 8 },
|
|
84
|
+
} as const
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
未设置该项时保持原有跨度行为;`responsive: false` 禁用自动扩展。容器比最小预算还窄时使用整行,不通过固定 `min-width` 撑破页面。宽度由局部 `ResizeObserver` 提供,停用、重新激活及销毁时管理自身订阅,无全局 resize 监听。
|
|
88
|
+
|
|
89
|
+
## 定位校验字段
|
|
90
|
+
|
|
91
|
+
实例方法 `await formRef.revealField(field)` 会先进入字段所在标签页、步骤或展开对应卡片分组,再滚动并聚焦真实可用控件;仅成功获得焦点才返回 `true`。找不到字段、字段隐藏/禁用/只读、布局尚未加载、切换前业务回调或已有校验阻止导航时返回 `false`。它不清除错误、不修改校验规则,也不会替业务切换编辑模式。
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
const focused = await formRef.value?.revealField('customer.name')
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
定位只使用当前表单实例的字段引用。卸载、KeepAlive 停用、布局改变或新定位请求会取消旧请求,迟到结果不会抢回焦点。自定义或虚拟控件可在字段上配置 `focusTarget`,异步准备后返回真实元素;由表单重新检查访问约束并执行 focus,适配器不要自行聚焦,也不要返回占位元素。
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
const fields = [
|
|
101
|
+
{
|
|
102
|
+
type: 'custom-customer',
|
|
103
|
+
prop: 'customerId',
|
|
104
|
+
focusTarget: async ({ signal }) => {
|
|
105
|
+
await customerEditor.ensureMounted(signal)
|
|
106
|
+
return signal.aborted ? null : customerEditor.inputElement
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`focusTarget` 上下文还提供 `field`、字段表单项的 `element`(可能为空)和当前 `model`。即使异步适配器忽略取消,库也会拒绝旧元素;没有可聚焦目标时诚实返回 `false`,由使用侧保留错误摘要或提示导航限制。
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# 密集搜索区与查询快照
|
|
2
|
+
|
|
3
|
+
`C_FormSearch` 保留已有 `formItemList`、`v-model`、`formParams`、历史记录和 `@search` 接口。普通接入仍采用 `inline` 布局;复杂业务可显式开启容器网格。组件只管理搜索条件与执行状态,不绑定分页接口、租户规则或特定表格。
|
|
4
|
+
|
|
5
|
+
## 容器布局与字段
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import { ref } from 'vue'
|
|
10
|
+
import {
|
|
11
|
+
C_FormSearch,
|
|
12
|
+
serializeSearch,
|
|
13
|
+
type SearchFormItem,
|
|
14
|
+
type SearchNumberRangeValue,
|
|
15
|
+
type FormSearchExpose,
|
|
16
|
+
} from '@robot-admin/naive-ui-components/C_FormSearch'
|
|
17
|
+
|
|
18
|
+
interface Query {
|
|
19
|
+
organization: string
|
|
20
|
+
keyword: string
|
|
21
|
+
amount: SearchNumberRangeValue
|
|
22
|
+
month: string | null
|
|
23
|
+
enabled: boolean | null
|
|
24
|
+
customer: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const query = ref<Query>({
|
|
28
|
+
organization: '001',
|
|
29
|
+
keyword: '',
|
|
30
|
+
amount: null,
|
|
31
|
+
month: null,
|
|
32
|
+
enabled: false,
|
|
33
|
+
customer: '',
|
|
34
|
+
})
|
|
35
|
+
const search = ref<FormSearchExpose<Query>>()
|
|
36
|
+
const fields: SearchFormItem<Query>[] = [
|
|
37
|
+
{ type: 'input', prop: 'organization', label: '组织', fixed: true },
|
|
38
|
+
{ type: 'input', prop: 'keyword', label: '关键词' },
|
|
39
|
+
{
|
|
40
|
+
type: 'number-range',
|
|
41
|
+
prop: 'amount',
|
|
42
|
+
label: '金额范围',
|
|
43
|
+
span: 2,
|
|
44
|
+
query: { keys: ['minimumAmount', 'maximumAmount'] },
|
|
45
|
+
},
|
|
46
|
+
{ type: 'month', prop: 'month', label: '月份', valueMode: 'formatted' },
|
|
47
|
+
{
|
|
48
|
+
type: 'select',
|
|
49
|
+
prop: 'enabled',
|
|
50
|
+
label: '状态',
|
|
51
|
+
list: [
|
|
52
|
+
{ label: '启用', value: true },
|
|
53
|
+
{ label: '停用', value: false },
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: 'custom',
|
|
58
|
+
prop: 'customer',
|
|
59
|
+
label: '客户',
|
|
60
|
+
slot: 'customer',
|
|
61
|
+
defaultValue: '',
|
|
62
|
+
},
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
async function execute(params: Query) {
|
|
66
|
+
const request = serializeSearch(params, fields)
|
|
67
|
+
// await api.list(request),或交给已有的 useMachTableQuery 执行器。
|
|
68
|
+
// 必须返回真实任务的 Promise;仅启动异步任务然后返回 void 无法等待业务完成。
|
|
69
|
+
await Promise.resolve(request)
|
|
70
|
+
}
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<template>
|
|
74
|
+
<C_FormSearch
|
|
75
|
+
ref="search"
|
|
76
|
+
v-model="query"
|
|
77
|
+
:form-item-list="fields"
|
|
78
|
+
:config="{
|
|
79
|
+
density: 'compact',
|
|
80
|
+
layout: 'grid',
|
|
81
|
+
columns: 4,
|
|
82
|
+
fieldMinWidth: 208,
|
|
83
|
+
labelPlacement: 'left',
|
|
84
|
+
labelWidth: 88,
|
|
85
|
+
foldThreshold: 4,
|
|
86
|
+
onSearch: execute,
|
|
87
|
+
}"
|
|
88
|
+
>
|
|
89
|
+
<template #customer="{ value, model, disabled, updateValue }">
|
|
90
|
+
<!-- 接入已有客户 Picker;选择结果通过 updateValue 回写。 -->
|
|
91
|
+
<button
|
|
92
|
+
type="button"
|
|
93
|
+
:disabled="disabled"
|
|
94
|
+
@click="updateValue(model.customer)"
|
|
95
|
+
>
|
|
96
|
+
{{ value || '选择客户' }}
|
|
97
|
+
</button>
|
|
98
|
+
</template>
|
|
99
|
+
</C_FormSearch>
|
|
100
|
+
</template>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- `layout: 'grid'` 按**搜索区容器**宽度分栏,`columns` 是最大列数。窄分栏中即使浏览器很宽也会减少列数;不使用视口宽度判断可用空间。
|
|
104
|
+
- `fieldMinWidth` 为基础轨道预算,字段 `span` / `minWidth` 可申请更多空间;实际跨度不会超过容器当前列数。操作区自然位于最后一列。
|
|
105
|
+
- `labelPlacement: 'left' | 'top'` 与 `labelWidth` 对应 Naive UI 表单标签。省略字段 `label` 保持旧的无标签外观。
|
|
106
|
+
- `density` 与表单共用,字段显式 `attrs.size` 和组件 `size` 保持优先。
|
|
107
|
+
- 折叠只影响显示,条件和校验仍有效。隐藏/折叠且有值的字段会显示生效数量;`0`、`false` 也是有效条件。
|
|
108
|
+
|
|
109
|
+
## 控件与原始模型
|
|
110
|
+
|
|
111
|
+
支持 `input`、`select`、`number`、`number-range`、`date`、`month`、`date-range`、`custom`、`spacer`。
|
|
112
|
+
|
|
113
|
+
数字输入继续使用 Naive UI;`attrs` 可配置 `min`、`max`、`precision` 等。紧凑模式的单数字默认隐藏步进按钮,显式 `attrs.showButton` 可覆盖。范围模型为 `[number | null, number | null] | null`,允许先填写单边,两边清空时回到 `null`。范围先后、跨度上限等业务规则通过字段 `rules` 声明,组件不预设业务阈值。
|
|
114
|
+
|
|
115
|
+
数字控件只用于 `number` 模型。精确十进制字符串、超出安全范围的金额/编号应使用 `custom` 输入与明确的 codec,避免先转 `Number` 导致原值损失。搜索组件不负责计算税额或汇率。
|
|
116
|
+
|
|
117
|
+
日期/月默认使用时间戳;已有 `date-range` 时间戳模型保持兼容。字符串模型声明 `valueMode: 'formatted'`,包括初始值为 `null` 时。默认格式分别为 `yyyy-MM-dd`、`yyyy-MM`、`yyyy-MM-dd HH:mm`,可通过 `attrs.format` / `attrs.valueFormat` 显式覆盖。展示格式与回写类型分开,清空不会将字符串日期改成时间戳。
|
|
118
|
+
|
|
119
|
+
`select` 保留字符串、数字、布尔值及多选数组的业务类型。内部布尔编码仅用于适配原生选择器,提交的 `false` 不会变成字符串或 `0`。
|
|
120
|
+
|
|
121
|
+
## 字典与自定义控件
|
|
122
|
+
|
|
123
|
+
字段可配置 `dictionary: 'orderStatus'`,由应用已提供的字典 Provider 解析;也可直接传入 `DictionarySource`。搜索不另建字典缓存,使用同一来源的选项、订阅与可取消加载。
|
|
124
|
+
|
|
125
|
+
显式 `list`(包括空数组)和 `attrs.options` 优先于字典,且不会加载未使用的字典。加载失败在选择器中显示重试入口;字典标签更新不会重置输入草稿。组织切换和字典加载策略仍由应用 Provider 决定。
|
|
126
|
+
|
|
127
|
+
`custom` 可使用 `slot` 或 `render(context)`;必须声明类型正确的 `defaultValue`,使 reset 和 clear 有确定语义。上下文提供 `value`、只读 `model`、`prop`、`size`、`disabled`、`readonly` 和 `updateValue`。修改走 `updateValue`;`fixed`、`readonly`、`disabled` 字段会拦截控件回写。自定义按钮使用 `type="button"`,避免误触发表单提交。
|
|
128
|
+
|
|
129
|
+
## 草稿、执行结果和重置
|
|
130
|
+
|
|
131
|
+
- `v-model` / `formParams` 是可编辑草稿;字段配置或字典选项变化不拿旧 props 覆盖未提交输入。
|
|
132
|
+
- `@search` 是经过校验的执行通知,保留原有时机;它不表示后台查询成功。
|
|
133
|
+
- 使用 `config.onSearch` 返回任务 Promise 后,只有成功完成才更新 `appliedParams` 并发出 `@applied`。回调拒绝或显式返回 `false` 时,`searchFn()` 返回 `false`,保留上一次成功条件并允许重试。可直接返回 `useDataResource.reload()` 的 boolean 结果;接入自行收拢错误的其它控制器时,回调应检查其错误状态并返回 `false`。
|
|
134
|
+
- 仅使用旧 `@search` 的接入无法观察事件监听器异步结果,因此不会伪造 `appliedParams`;需要成功快照时使用 `onSearch`。
|
|
135
|
+
- 查询期间继续输入只改变草稿;成功快照仍是当次发送的条件。`hasUnappliedChanges` 可判断草稿与已执行条件是否不同。
|
|
136
|
+
- `cleanFn()` 只重置草稿,不主动执行查询,也不把重置值标记为成功查询。`defaultValue: 0 / false` 保留原类型;未配置字段、隐藏上下文、分页参数不被清除。
|
|
137
|
+
- `fixed: true` 的字段参与查询,但控件与 reset 不可改写。固定作用域切换时清空已执行快照,迟到请求不能在新作用域下标记成功。宿主仍应在执行器中取消失效请求,防止业务结果覆盖;`fixed` 不是后端授权机制。
|
|
138
|
+
|
|
139
|
+
原生表单提交(包括 Enter)共享搜索任务锁,验证期间与请求期间都防重;外部 `loading` 仍生效。
|
|
140
|
+
|
|
141
|
+
## 显式请求编码
|
|
142
|
+
|
|
143
|
+
`serializeSearch(params, fields, { omitEmpty: true })` 是纯辅助函数,组件不会隐式调用,也不会更改 `onSearch`、事件或 `v-model` 的类型。
|
|
144
|
+
|
|
145
|
+
字段 `query` 支持:
|
|
146
|
+
|
|
147
|
+
- `name`:仅将请求字段改名。
|
|
148
|
+
- `keys: ['start', 'end']`:将范围拆成两个请求字段,移除原范围键。
|
|
149
|
+
- `serialize(value)`:显式转换单个字段的传输格式;入参是隔离数据,不能改变草稿。
|
|
150
|
+
|
|
151
|
+
默认省略已配置字段的空值,保留 `0`、`false`、`'001'`。范围两端分别清理;`omitEmpty: false` 保留显式空值。未配置的上下文字段继续保留。重复目标键和不安全路径会报错,避免编码覆盖固定组织等条件。
|
|
152
|
+
|
|
153
|
+
表格列表、合计与导出应使用同一次成功执行的条件快照,按各自 target 选择编码或标签。页面负责把该快照交给后端导出任务;不读取用户正在修改的草稿冒充已查询范围。
|
|
154
|
+
|
|
155
|
+
## 常用条件
|
|
156
|
+
|
|
157
|
+
通过公开实例的 `applyPreset(values)` 应用“今日”“待处理”等业务预设,无需再封装一个搜索组件。它只更新已声明且可编辑的字段,固定组织、隐藏上下文、只读字段与分页参数保持原值;0/false 不会被丢弃。传入值先隔离复制,失败不会部分改写模型。
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
searchRef.value?.applyPreset({ status: 'running', amountRange: [0, null] })
|
|
161
|
+
// 用户确认执行时再调用 searchFn();应用预设本身不发请求、不更新 appliedParams。
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
动态日期和班次的定义留在业务预设中,点击时产生当次值;预设不引入全局存储、额外 watcher 或另一套查询规则。
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.23.0",
|
|
7
7
|
"description": "基于 Naive UI 的 Vue 3 组件库",
|
|
8
8
|
"packageManager": "bun@1.3.14",
|
|
9
9
|
"engines": {
|
|
@@ -35,6 +35,26 @@
|
|
|
35
35
|
"default": "./dist/config.cjs"
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
|
+
"./data": {
|
|
39
|
+
"import": {
|
|
40
|
+
"types": "./dist/data.d.ts",
|
|
41
|
+
"default": "./dist/data.js"
|
|
42
|
+
},
|
|
43
|
+
"require": {
|
|
44
|
+
"types": "./dist/data.d.cts",
|
|
45
|
+
"default": "./dist/data.cjs"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"./workflows": {
|
|
49
|
+
"import": {
|
|
50
|
+
"types": "./dist/workflows.d.ts",
|
|
51
|
+
"default": "./dist/workflows.js"
|
|
52
|
+
},
|
|
53
|
+
"require": {
|
|
54
|
+
"types": "./dist/workflows.d.cts",
|
|
55
|
+
"default": "./dist/workflows.cjs"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
38
58
|
"./style.css": "./dist/style.css",
|
|
39
59
|
"./resolver": {
|
|
40
60
|
"import": {
|