@tongfun/ui 0.0.0-alpha.3 → 0.0.1-alpha.2
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/.claude/settings.local.json +7 -0
- package/.hermes/plans/datapicker-object-mode.md +57 -0
- package/.hermes/plans/design-spec-fusion-5175-v2.md +146 -0
- package/.hermes/plans/design-spec-fusion-5175.md +88 -0
- package/.hermes/plans/file-upload-chip-redesign.md +66 -0
- package/.hermes/plans/form-image-upload-modelvalue-fix.md +38 -0
- package/.hermes/plans/form-layout-responsive-span-plan.md +137 -0
- package/.hermes/plans/global-audit-report.md +728 -0
- package/.hermes/plans/global-audit-report.v1.md +604 -0
- package/.hermes/plans/global-audit-report.v3.md +777 -0
- package/.hermes/plans/image-file-erp-redesign.md +173 -0
- package/.hermes/plans/location-picker-baidu-modal.md +173 -0
- package/.hermes/plans/new-document-3b-color-componentization-plan.md +155 -0
- package/.hermes/plans/new-document-form-layout-rebuild-plan.md +150 -0
- package/.hermes/plans/new-document-fullwidth-3col-plan.md +177 -0
- package/.hermes/plans/picker-quick-options-range-mode.md +143 -0
- package/.hermes/plans/region-picker-mock-contract.md +202 -0
- package/.hermes/plans/zero-div-component-contracts.md +466 -0
- package/README.md +110 -0
- package/components.json +19 -0
- package/docs/DEVELOPMENT.md +315 -0
- package/docs/PRD.md +170 -0
- package/docs/ai-api-layering.md +141 -0
- package/docs/anchor-component-plan.md +165 -0
- package/docs/components-analysis.md +2911 -0
- package/docs/demo-scan-report.md +142 -0
- package/docs/editable-table-research.md +8 -0
- package/docs/form-panorama-plan.md +141 -0
- package/docs/lowcode-agent-component-registry.sample.json +36364 -0
- package/docs/tf-form-table-modification-plan.md +503 -0
- package/docs/token-compliance-audit-report.md +542 -0
- package/env.d.ts +5 -0
- package/eslint.config.js +66 -0
- package/package.json +85 -38
- package/packages/ui/__tests__/package-exports.test.ts +23 -0
- package/packages/ui/components/affix/README.md +78 -0
- package/packages/ui/components/affix/__tests__/affix.test.ts +204 -0
- package/packages/ui/components/affix/index.ts +13 -0
- package/packages/ui/components/affix/src/affix.vue +216 -0
- package/packages/ui/components/affix/src/types.ts +47 -0
- package/packages/ui/components/affix/styles/affix.css +17 -0
- package/packages/ui/components/ai-overlay/README.md +180 -0
- package/packages/ui/components/ai-overlay/__tests__/ai-action-menu.test.ts +133 -0
- package/packages/ui/components/ai-overlay/__tests__/ai-overlay.test.ts +117 -0
- package/packages/ui/components/ai-overlay/index.ts +32 -0
- package/packages/ui/components/ai-overlay/src/ai-action-menu-types.ts +22 -0
- package/packages/ui/components/ai-overlay/src/ai-action-menu.vue +200 -0
- package/packages/ui/components/ai-overlay/src/ai-overlay.vue +329 -0
- package/packages/ui/components/ai-overlay/src/types.ts +84 -0
- package/packages/ui/components/ai-overlay/styles/ai-overlay.css +306 -0
- package/packages/ui/components/ai-state-flow/README.md +111 -0
- package/packages/ui/components/ai-state-flow/__tests__/ai-state-flow.test.ts +69 -0
- package/packages/ui/components/ai-state-flow/ai-state-flow.ts +16 -0
- package/packages/ui/components/ai-state-flow/ai-state-flow.vue +67 -0
- package/packages/ui/components/ai-state-flow/index.ts +24 -0
- package/packages/ui/components/ai-state-flow/styles/ai-state-flow.css +144 -0
- package/packages/ui/components/alert/README.md +83 -0
- package/packages/ui/components/alert/__tests__/alert.test.ts +155 -0
- package/packages/ui/components/alert/index.ts +13 -0
- package/packages/ui/components/alert/src/alert.ts +90 -0
- package/packages/ui/components/alert/src/alert.vue +87 -0
- package/packages/ui/components/alert/styles/alert.css +158 -0
- package/packages/ui/components/anchor/README.md +50 -0
- package/packages/ui/components/anchor/__tests__/anchor.test.ts +284 -0
- package/packages/ui/components/anchor/index.ts +13 -0
- package/packages/ui/components/anchor/src/anchor.vue +94 -0
- package/packages/ui/components/anchor/src/types.ts +55 -0
- package/packages/ui/components/anchor/src/use-anchor.ts +253 -0
- package/packages/ui/components/anchor/styles/anchor.css +90 -0
- package/packages/ui/components/avatar/README.md +118 -0
- package/packages/ui/components/avatar/__tests__/avatar.test.ts +83 -0
- package/packages/ui/components/avatar/index.ts +12 -0
- package/packages/ui/components/avatar/src/avatar.ts +62 -0
- package/packages/ui/components/avatar/src/avatar.vue +106 -0
- package/packages/ui/components/back-top/README.md +63 -0
- package/packages/ui/components/back-top/__tests__/back-top.test.ts +215 -0
- package/packages/ui/components/back-top/index.ts +13 -0
- package/packages/ui/components/back-top/src/back-top.ts +51 -0
- package/packages/ui/components/back-top/src/back-top.vue +104 -0
- package/packages/ui/components/back-top/styles/back-top.css +24 -0
- package/packages/ui/components/badge/README.md +71 -0
- package/packages/ui/components/badge/__tests__/badge.test.ts +142 -0
- package/packages/ui/components/badge/index.ts +13 -0
- package/packages/ui/components/badge/src/badge.ts +64 -0
- package/packages/ui/components/badge/src/badge.vue +76 -0
- package/packages/ui/components/badge/styles/badge.css +45 -0
- package/packages/ui/components/batch-action-button/README.md +68 -0
- package/packages/ui/components/batch-action-button/__tests__/batch-action-button.test.ts +30 -0
- package/packages/ui/components/batch-action-button/index.ts +11 -0
- package/packages/ui/components/batch-action-button/src/batch-action-button.vue +59 -0
- package/packages/ui/components/batch-action-button/src/types.ts +9 -0
- package/packages/ui/components/breadcrumb/README.md +115 -0
- package/packages/ui/components/breadcrumb/__tests__/breadcrumb.test.ts +168 -0
- package/packages/ui/components/breadcrumb/index.ts +13 -0
- package/packages/ui/components/breadcrumb/src/breadcrumb.ts +60 -0
- package/packages/ui/components/breadcrumb/src/breadcrumb.vue +86 -0
- package/packages/ui/components/business/document/action-header/index.ts +14 -0
- package/packages/ui/components/business/document/action-header/src/context.ts +10 -0
- package/packages/ui/components/business/document/action-header/src/document-action-header.vue +296 -0
- package/packages/ui/components/business/document/action-header/src/types.ts +100 -0
- package/packages/ui/components/business/document/ai-toolbar/index.ts +12 -0
- package/packages/ui/components/business/document/ai-toolbar/src/document-ai-toolbar.vue +72 -0
- package/packages/ui/components/business/document/form-page/index.ts +16 -0
- package/packages/ui/components/business/document/form-page/src/composables/use-document-ai-toolbar.ts +37 -0
- package/packages/ui/components/business/document/form-page/src/composables/use-document-layout-mode.ts +24 -0
- package/packages/ui/components/business/document/form-page/src/composables/use-document-recognition.ts +55 -0
- package/packages/ui/components/business/document/form-page/src/composables/use-document-save.ts +243 -0
- package/packages/ui/components/business/document/form-page/src/composables/use-document-sections.ts +234 -0
- package/packages/ui/components/business/document/form-page/src/context.ts +15 -0
- package/packages/ui/components/business/document/form-page/src/document-form-page.vue +251 -0
- package/packages/ui/components/business/document/form-page/src/document-section-card.vue +187 -0
- package/packages/ui/components/business/document/form-page/src/types.ts +245 -0
- package/packages/ui/components/business/document/form-page/styles/document-form-page.css +40 -0
- package/packages/ui/components/business/enum-select/index.ts +18 -0
- package/packages/ui/components/business/enum-select/src/enum-select.vue +171 -0
- package/packages/ui/components/business/enum-select/src/types.ts +33 -0
- package/packages/ui/components/button/README.md +155 -0
- package/packages/ui/components/button/__tests__/button.test.ts +261 -0
- package/packages/ui/components/button/index.ts +14 -0
- package/packages/ui/components/button/src/button.ts +168 -0
- package/packages/ui/components/button/src/button.vue +341 -0
- package/packages/ui/components/button/styles/button.css +149 -0
- package/packages/ui/components/carousel/README.md +48 -0
- package/packages/ui/components/carousel/__tests__/carousel.test.ts +82 -0
- package/packages/ui/components/carousel/index.ts +11 -0
- package/packages/ui/components/carousel/src/carousel.ts +38 -0
- package/packages/ui/components/carousel/src/carousel.vue +101 -0
- package/packages/ui/components/carousel/styles/carousel.css +40 -0
- package/packages/ui/components/chart/README.md +120 -0
- package/packages/ui/components/chart/__tests__/chart.test.ts +86 -0
- package/packages/ui/components/chart/__tests__/simple-charts.test.ts +130 -0
- package/packages/ui/components/chart/index.ts +22 -0
- package/packages/ui/components/chart/src/bar-chart.vue +83 -0
- package/packages/ui/components/chart/src/chart.ts +135 -0
- package/packages/ui/components/chart/src/chart.vue +147 -0
- package/packages/ui/components/chart/src/donut-chart.vue +96 -0
- package/packages/ui/components/chart/src/line-chart.vue +101 -0
- package/packages/ui/components/chart/src/metric-grid.vue +55 -0
- package/packages/ui/components/chart/src/types.ts +91 -0
- package/packages/ui/components/chart/src/utils.ts +68 -0
- package/packages/ui/components/chart/styles/bar-chart.css +134 -0
- package/packages/ui/components/chart/styles/chart.css +48 -0
- package/packages/ui/components/chart/styles/donut-chart.css +114 -0
- package/packages/ui/components/chart/styles/line-chart.css +61 -0
- package/packages/ui/components/chart/styles/metric-grid.css +115 -0
- package/packages/ui/components/code-block/README.md +56 -0
- package/packages/ui/components/code-block/__tests__/code-block.test.ts +166 -0
- package/packages/ui/components/code-block/index.ts +13 -0
- package/packages/ui/components/code-block/src/code-block.vue +216 -0
- package/packages/ui/components/code-block/src/types.ts +31 -0
- package/packages/ui/components/code-block/styles/code-block.css +192 -0
- package/packages/ui/components/data-grid/CellRendererActions.vue +77 -0
- package/packages/ui/components/data-grid/CellRendererButton.vue +51 -0
- package/packages/ui/components/data-grid/CellRendererCsCheckbox.vue +16 -0
- package/packages/ui/components/data-grid/CellRendererCsInput.vue +29 -0
- package/packages/ui/components/data-grid/CellRendererCsSelect.vue +19 -0
- package/packages/ui/components/data-grid/CellRendererInput.vue +120 -0
- package/packages/ui/components/data-grid/CellRendererText.vue +94 -0
- package/packages/ui/components/data-grid/ColumnSettings.vue +40 -0
- package/packages/ui/components/data-grid/ColumnSettingsDialog.vue +367 -0
- package/packages/ui/components/data-grid/DataGrid.vue +850 -0
- package/packages/ui/components/data-grid/DataGridFilter.vue +242 -0
- package/packages/ui/components/data-grid/column-settings-api.ts +62 -0
- package/packages/ui/components/data-grid/index.ts +29 -0
- package/packages/ui/components/data-grid/props.ts +246 -0
- package/packages/ui/components/data-grid/variants.ts +26 -0
- package/packages/ui/components/divider/README.md +84 -0
- package/packages/ui/components/divider/__tests__/divider.test.ts +105 -0
- package/packages/ui/components/divider/index.ts +13 -0
- package/packages/ui/components/divider/src/divider.ts +50 -0
- package/packages/ui/components/divider/src/divider.vue +76 -0
- package/packages/ui/components/divider/styles/divider.css +65 -0
- package/packages/ui/components/drawer/README.md +90 -0
- package/packages/ui/components/drawer/__tests__/drawer.test.ts +218 -0
- package/packages/ui/components/drawer/index.ts +13 -0
- package/packages/ui/components/drawer/src/drawer.ts +88 -0
- package/packages/ui/components/drawer/src/drawer.vue +157 -0
- package/packages/ui/components/drawer/styles/drawer.css +164 -0
- package/packages/ui/components/dropdown/README.md +51 -0
- package/packages/ui/components/dropdown/__tests__/dropdown.test.ts +143 -0
- package/packages/ui/components/dropdown/index.ts +11 -0
- package/packages/ui/components/dropdown/src/dropdown.ts +47 -0
- package/packages/ui/components/dropdown/src/dropdown.vue +75 -0
- package/packages/ui/components/dropdown/styles/dropdown.css +16 -0
- package/packages/ui/components/dropdown-button/README.md +78 -0
- package/packages/ui/components/dropdown-button/__tests__/dropdown-button.test.ts +75 -0
- package/packages/ui/components/dropdown-button/index.ts +11 -0
- package/packages/ui/components/dropdown-button/src/dropdown-button-menu-items.vue +79 -0
- package/packages/ui/components/dropdown-button/src/dropdown-button.vue +152 -0
- package/packages/ui/components/dropdown-button/src/types.ts +98 -0
- package/packages/ui/components/dropdown-button/styles/dropdown-button.css +171 -0
- package/packages/ui/components/empty/README.md +48 -0
- package/packages/ui/components/empty/__tests__/empty.test.ts +37 -0
- package/packages/ui/components/empty/index.ts +13 -0
- package/packages/ui/components/empty/src/empty.vue +73 -0
- package/packages/ui/components/empty/src/types.ts +32 -0
- package/packages/ui/components/empty/styles/empty.css +69 -0
- package/packages/ui/components/error/README.md +44 -0
- package/packages/ui/components/error/__tests__/error.test.ts +34 -0
- package/packages/ui/components/error/index.ts +13 -0
- package/packages/ui/components/error/src/error.vue +65 -0
- package/packages/ui/components/error/src/types.ts +28 -0
- package/packages/ui/components/error/styles/error.css +69 -0
- package/packages/ui/components/filter-button/README.md +68 -0
- package/packages/ui/components/filter-button/__tests__/filter-button.test.ts +30 -0
- package/packages/ui/components/filter-button/index.ts +11 -0
- package/packages/ui/components/filter-button/src/filter-button.vue +59 -0
- package/packages/ui/components/filter-button/src/types.ts +9 -0
- package/packages/ui/components/form/README.md +750 -0
- package/packages/ui/components/form/__tests__/form-ai-registry-integration.test.ts +214 -0
- package/packages/ui/components/form/__tests__/form-field.test.ts +377 -0
- package/packages/ui/components/form/__tests__/form-item-ai-actions.test.ts +299 -0
- package/packages/ui/components/form/__tests__/form-item.test.ts +110 -0
- package/packages/ui/components/form/__tests__/form-wrapper-reject-forward.test.ts +269 -0
- package/packages/ui/components/form/__tests__/form.test.ts +148 -0
- package/packages/ui/components/form/base/cascader/README.md +75 -0
- package/packages/ui/components/form/base/cascader/__tests__/ai-capability.test.ts +507 -0
- package/packages/ui/components/form/base/cascader/__tests__/cascader.test.ts +203 -0
- package/packages/ui/components/form/base/cascader/index.ts +14 -0
- package/packages/ui/components/form/base/cascader/src/cascader.vue +505 -0
- package/packages/ui/components/form/base/cascader/src/types.ts +168 -0
- package/packages/ui/components/form/base/cascader/styles/cascader.css +186 -0
- package/packages/ui/components/form/base/checkbox/README.md +110 -0
- package/packages/ui/components/form/base/checkbox/__tests__/ai-capability.test.ts +465 -0
- package/packages/ui/components/form/base/checkbox/__tests__/checkbox.test.ts +98 -0
- package/packages/ui/components/form/base/checkbox/__tests__/group-integration.test.ts +192 -0
- package/packages/ui/components/form/base/checkbox/index.ts +18 -0
- package/packages/ui/components/form/base/checkbox/src/checkbox-group.vue +311 -0
- package/packages/ui/components/form/base/checkbox/src/checkbox.ts +210 -0
- package/packages/ui/components/form/base/checkbox/src/checkbox.vue +368 -0
- package/packages/ui/components/form/base/checkbox/styles/checkbox.css +24 -0
- package/packages/ui/components/form/base/data-picker/README.md +192 -0
- package/packages/ui/components/form/base/data-picker/__tests__/ai-capability.test.ts +566 -0
- package/packages/ui/components/form/base/data-picker/__tests__/data-picker.test.ts +628 -0
- package/packages/ui/components/form/base/data-picker/index.ts +23 -0
- package/packages/ui/components/form/base/data-picker/src/data-picker.ts +192 -0
- package/packages/ui/components/form/base/data-picker/src/data-picker.vue +1267 -0
- package/packages/ui/components/form/base/data-picker/styles/data-picker.css +174 -0
- package/packages/ui/components/form/base/date-picker/README.md +94 -0
- package/packages/ui/components/form/base/date-picker/__tests__/ai-capability.test.ts +462 -0
- package/packages/ui/components/form/base/date-picker/__tests__/date-picker.test.ts +115 -0
- package/packages/ui/components/form/base/date-picker/index.ts +13 -0
- package/packages/ui/components/form/base/date-picker/src/date-picker.ts +212 -0
- package/packages/ui/components/form/base/date-picker/src/date-picker.vue +871 -0
- package/packages/ui/components/form/base/date-picker/styles/date-picker.css +210 -0
- package/packages/ui/components/form/base/datetime-picker/README.md +197 -0
- package/packages/ui/components/form/base/datetime-picker/__tests__/ai-capability.test.ts +368 -0
- package/packages/ui/components/form/base/datetime-picker/__tests__/datetime-picker.test.ts +445 -0
- package/packages/ui/components/form/base/datetime-picker/index.ts +13 -0
- package/packages/ui/components/form/base/datetime-picker/src/datetime-picker.ts +149 -0
- package/packages/ui/components/form/base/datetime-picker/src/datetime-picker.vue +1158 -0
- package/packages/ui/components/form/base/datetime-picker/styles/datetime-picker.css +570 -0
- package/packages/ui/components/form/base/file-upload/README.md +73 -0
- package/packages/ui/components/form/base/file-upload/__tests__/ai-capability.test.ts +223 -0
- package/packages/ui/components/form/base/file-upload/__tests__/file-upload.spec.ts +199 -0
- package/packages/ui/components/form/base/file-upload/index.ts +11 -0
- package/packages/ui/components/form/base/file-upload/src/file-upload.ts +95 -0
- package/packages/ui/components/form/base/file-upload/src/file-upload.vue +451 -0
- package/packages/ui/components/form/base/file-upload/styles/file-upload.css +57 -0
- package/packages/ui/components/form/base/image-upload/README.md +70 -0
- package/packages/ui/components/form/base/image-upload/__tests__/ai-capability.test.ts +149 -0
- package/packages/ui/components/form/base/image-upload/__tests__/image-upload.spec.ts +282 -0
- package/packages/ui/components/form/base/image-upload/index.ts +11 -0
- package/packages/ui/components/form/base/image-upload/src/image-upload.ts +76 -0
- package/packages/ui/components/form/base/image-upload/src/image-upload.vue +657 -0
- package/packages/ui/components/form/base/index.ts +24 -0
- package/packages/ui/components/form/base/input/README.md +63 -0
- package/packages/ui/components/form/base/input/__tests__/ai-capability.test.ts +143 -0
- package/packages/ui/components/form/base/input/__tests__/input.test.ts +195 -0
- package/packages/ui/components/form/base/input/index.ts +37 -0
- package/packages/ui/components/form/base/input/src/input.ts +104 -0
- package/packages/ui/components/form/base/input/src/input.vue +384 -0
- package/packages/ui/components/form/base/input/styles/input.css +198 -0
- package/packages/ui/components/form/base/location-picker/README.md +92 -0
- package/packages/ui/components/form/base/location-picker/__tests__/ai-capability.test.ts +147 -0
- package/packages/ui/components/form/base/location-picker/__tests__/location-picker.test.ts +161 -0
- package/packages/ui/components/form/base/location-picker/index.ts +13 -0
- package/packages/ui/components/form/base/location-picker/src/location-picker.ts +99 -0
- package/packages/ui/components/form/base/location-picker/src/location-picker.vue +558 -0
- package/packages/ui/components/form/base/radio/README.md +95 -0
- package/packages/ui/components/form/base/radio/__tests__/ai-capability.test.ts +578 -0
- package/packages/ui/components/form/base/radio/__tests__/group-integration.test.ts +191 -0
- package/packages/ui/components/form/base/radio/__tests__/radio.test.ts +64 -0
- package/packages/ui/components/form/base/radio/index.ts +18 -0
- package/packages/ui/components/form/base/radio/src/radio-group.vue +270 -0
- package/packages/ui/components/form/base/radio/src/radio.ts +154 -0
- package/packages/ui/components/form/base/radio/src/radio.vue +141 -0
- package/packages/ui/components/form/base/radio/styles/radio.css +12 -0
- package/packages/ui/components/form/base/region-picker/README.md +166 -0
- package/packages/ui/components/form/base/region-picker/__tests__/ai-capability.test.ts +147 -0
- package/packages/ui/components/form/base/region-picker/__tests__/region-picker.spec.ts +556 -0
- package/packages/ui/components/form/base/region-picker/index.ts +19 -0
- package/packages/ui/components/form/base/region-picker/src/region-picker.ts +333 -0
- package/packages/ui/components/form/base/region-picker/src/region-picker.vue +552 -0
- package/packages/ui/components/form/base/select/README.md +66 -0
- package/packages/ui/components/form/base/select/__tests__/ai-capability.test.ts +463 -0
- package/packages/ui/components/form/base/select/__tests__/select.test.ts +167 -0
- package/packages/ui/components/form/base/select/index.ts +15 -0
- package/packages/ui/components/form/base/select/src/select.ts +173 -0
- package/packages/ui/components/form/base/select/src/select.vue +534 -0
- package/packages/ui/components/form/base/select/styles/select.css +206 -0
- package/packages/ui/components/form/base/signature/README.md +96 -0
- package/packages/ui/components/form/base/signature/__tests__/ai-capability.test.ts +147 -0
- package/packages/ui/components/form/base/signature/__tests__/signature.spec.ts +156 -0
- package/packages/ui/components/form/base/signature/index.ts +14 -0
- package/packages/ui/components/form/base/signature/src/signature.ts +100 -0
- package/packages/ui/components/form/base/signature/src/signature.vue +871 -0
- package/packages/ui/components/form/base/switch/README.md +102 -0
- package/packages/ui/components/form/base/switch/__tests__/ai-capability.test.ts +545 -0
- package/packages/ui/components/form/base/switch/__tests__/switch.test.ts +105 -0
- package/packages/ui/components/form/base/switch/index.ts +12 -0
- package/packages/ui/components/form/base/switch/src/switch.ts +133 -0
- package/packages/ui/components/form/base/switch/src/switch.vue +385 -0
- package/packages/ui/components/form/base/switch/styles/switch.css +35 -0
- package/packages/ui/components/form/base/text-area/README.md +89 -0
- package/packages/ui/components/form/base/text-area/__tests__/ai-capability.test.ts +176 -0
- package/packages/ui/components/form/base/text-area/__tests__/text-area.test.ts +152 -0
- package/packages/ui/components/form/base/text-area/index.ts +37 -0
- package/packages/ui/components/form/base/text-area/src/text-area.ts +137 -0
- package/packages/ui/components/form/base/text-area/src/text-area.vue +405 -0
- package/packages/ui/components/form/base/text-area/styles/text-area.css +137 -0
- package/packages/ui/components/form/base/time-picker/README.md +75 -0
- package/packages/ui/components/form/base/time-picker/__tests__/ai-capability.test.ts +135 -0
- package/packages/ui/components/form/base/time-picker/__tests__/time-picker.test.ts +258 -0
- package/packages/ui/components/form/base/time-picker/index.ts +13 -0
- package/packages/ui/components/form/base/time-picker/src/time-picker.ts +141 -0
- package/packages/ui/components/form/base/time-picker/src/time-picker.vue +844 -0
- package/packages/ui/components/form/base/time-picker/styles/time-picker.css +124 -0
- package/packages/ui/components/form/base/upload/README.md +126 -0
- package/packages/ui/components/form/base/upload/__tests__/ai-capability.test.ts +145 -0
- package/packages/ui/components/form/base/upload/__tests__/upload.spec.ts +288 -0
- package/packages/ui/components/form/base/upload/index.ts +11 -0
- package/packages/ui/components/form/base/upload/src/upload.ts +171 -0
- package/packages/ui/components/form/base/upload/src/upload.vue +890 -0
- package/packages/ui/components/form/base/upload/styles/upload.css +116 -0
- package/packages/ui/components/form/index.ts +138 -0
- package/packages/ui/components/form/items/form-array/README.md +61 -0
- package/packages/ui/components/form/items/form-array/__tests__/form-array.test.ts +122 -0
- package/packages/ui/components/form/items/form-array/index.ts +2 -0
- package/packages/ui/components/form/items/form-array/src/form-array.vue +80 -0
- package/packages/ui/components/form/items/form-array/src/types.ts +27 -0
- package/packages/ui/components/form/items/form-array/styles/form-array.css +99 -0
- package/packages/ui/components/form/items/form-cascader/README.md +132 -0
- package/packages/ui/components/form/items/form-cascader/__tests__/form-cascader.test.ts +99 -0
- package/packages/ui/components/form/items/form-cascader/index.ts +1 -0
- package/packages/ui/components/form/items/form-cascader/src/form-cascader.ts +7 -0
- package/packages/ui/components/form/items/form-cascader/src/form-cascader.vue +15 -0
- package/packages/ui/components/form/items/form-checkbox/README.md +121 -0
- package/packages/ui/components/form/items/form-checkbox/__tests__/form-checkbox.test.ts +93 -0
- package/packages/ui/components/form/items/form-checkbox/index.ts +1 -0
- package/packages/ui/components/form/items/form-checkbox/src/form-checkbox.ts +7 -0
- package/packages/ui/components/form/items/form-checkbox/src/form-checkbox.vue +15 -0
- package/packages/ui/components/form/items/form-data-picker/README.md +111 -0
- package/packages/ui/components/form/items/form-data-picker/__tests__/form-data-picker.test.ts +98 -0
- package/packages/ui/components/form/items/form-data-picker/index.ts +1 -0
- package/packages/ui/components/form/items/form-data-picker/src/form-data-picker.ts +7 -0
- package/packages/ui/components/form/items/form-data-picker/src/form-data-picker.vue +17 -0
- package/packages/ui/components/form/items/form-date-picker/README.md +119 -0
- package/packages/ui/components/form/items/form-date-picker/__tests__/form-date-picker.test.ts +104 -0
- package/packages/ui/components/form/items/form-date-picker/index.ts +1 -0
- package/packages/ui/components/form/items/form-date-picker/src/form-date-picker.ts +7 -0
- package/packages/ui/components/form/items/form-date-picker/src/form-date-picker.vue +17 -0
- package/packages/ui/components/form/items/form-datetime-picker/README.md +112 -0
- package/packages/ui/components/form/items/form-datetime-picker/__tests__/form-datetime-picker.test.ts +105 -0
- package/packages/ui/components/form/items/form-datetime-picker/index.ts +1 -0
- package/packages/ui/components/form/items/form-datetime-picker/src/form-datetime-picker.ts +7 -0
- package/packages/ui/components/form/items/form-datetime-picker/src/form-datetime-picker.vue +17 -0
- package/packages/ui/components/form/items/form-dynamic/README.md +105 -0
- package/packages/ui/components/form/items/form-dynamic/__tests__/form-dynamic.test.ts +172 -0
- package/packages/ui/components/form/items/form-dynamic/index.ts +2 -0
- package/packages/ui/components/form/items/form-dynamic/src/form-dynamic.vue +222 -0
- package/packages/ui/components/form/items/form-dynamic/src/types.ts +63 -0
- package/packages/ui/components/form/items/form-file-upload/README.md +92 -0
- package/packages/ui/components/form/items/form-file-upload/__tests__/form-file-upload.test.ts +99 -0
- package/packages/ui/components/form/items/form-file-upload/index.ts +1 -0
- package/packages/ui/components/form/items/form-file-upload/src/form-file-upload.ts +7 -0
- package/packages/ui/components/form/items/form-file-upload/src/form-file-upload.vue +15 -0
- package/packages/ui/components/form/items/form-group/README.md +57 -0
- package/packages/ui/components/form/items/form-group/__tests__/form-group.test.ts +108 -0
- package/packages/ui/components/form/items/form-group/index.ts +2 -0
- package/packages/ui/components/form/items/form-group/src/form-group.vue +85 -0
- package/packages/ui/components/form/items/form-group/src/types.ts +37 -0
- package/packages/ui/components/form/items/form-group/styles/form-group.css +92 -0
- package/packages/ui/components/form/items/form-image-upload/README.md +92 -0
- package/packages/ui/components/form/items/form-image-upload/__tests__/form-image-upload.test.ts +109 -0
- package/packages/ui/components/form/items/form-image-upload/index.ts +1 -0
- package/packages/ui/components/form/items/form-image-upload/src/form-image-upload.ts +7 -0
- package/packages/ui/components/form/items/form-image-upload/src/form-image-upload.vue +37 -0
- package/packages/ui/components/form/items/form-input/README.md +110 -0
- package/packages/ui/components/form/items/form-input/__tests__/form-input.test.ts +87 -0
- package/packages/ui/components/form/items/form-input/index.ts +1 -0
- package/packages/ui/components/form/items/form-input/src/form-input.ts +7 -0
- package/packages/ui/components/form/items/form-input/src/form-input.vue +15 -0
- package/packages/ui/components/form/items/form-location-picker/README.md +119 -0
- package/packages/ui/components/form/items/form-location-picker/__tests__/form-location-picker.test.ts +98 -0
- package/packages/ui/components/form/items/form-location-picker/index.ts +1 -0
- package/packages/ui/components/form/items/form-location-picker/src/form-location-picker.ts +7 -0
- package/packages/ui/components/form/items/form-location-picker/src/form-location-picker.vue +15 -0
- package/packages/ui/components/form/items/form-radio/README.md +125 -0
- package/packages/ui/components/form/items/form-radio/__tests__/form-radio.test.ts +104 -0
- package/packages/ui/components/form/items/form-radio/index.ts +1 -0
- package/packages/ui/components/form/items/form-radio/src/form-radio.ts +7 -0
- package/packages/ui/components/form/items/form-radio/src/form-radio.vue +15 -0
- package/packages/ui/components/form/items/form-region-picker/README.md +111 -0
- package/packages/ui/components/form/items/form-region-picker/__tests__/form-region-picker.test.ts +95 -0
- package/packages/ui/components/form/items/form-region-picker/index.ts +1 -0
- package/packages/ui/components/form/items/form-region-picker/src/form-region-picker.ts +7 -0
- package/packages/ui/components/form/items/form-region-picker/src/form-region-picker.vue +15 -0
- package/packages/ui/components/form/items/form-select/README.md +117 -0
- package/packages/ui/components/form/items/form-select/__tests__/form-select.test.ts +80 -0
- package/packages/ui/components/form/items/form-select/index.ts +1 -0
- package/packages/ui/components/form/items/form-select/src/form-select.ts +7 -0
- package/packages/ui/components/form/items/form-select/src/form-select.vue +15 -0
- package/packages/ui/components/form/items/form-signature/README.md +89 -0
- package/packages/ui/components/form/items/form-signature/__tests__/form-signature.test.ts +109 -0
- package/packages/ui/components/form/items/form-signature/index.ts +1 -0
- package/packages/ui/components/form/items/form-signature/src/form-signature.ts +7 -0
- package/packages/ui/components/form/items/form-signature/src/form-signature.vue +15 -0
- package/packages/ui/components/form/items/form-slider/README.md +125 -0
- package/packages/ui/components/form/items/form-slider/__tests__/form-slider.test.ts +95 -0
- package/packages/ui/components/form/items/form-slider/index.ts +1 -0
- package/packages/ui/components/form/items/form-slider/src/form-slider.ts +7 -0
- package/packages/ui/components/form/items/form-slider/src/form-slider.vue +15 -0
- package/packages/ui/components/form/items/form-subform/README.md +71 -0
- package/packages/ui/components/form/items/form-subform/__tests__/form-subform.test.ts +116 -0
- package/packages/ui/components/form/items/form-subform/index.ts +2 -0
- package/packages/ui/components/form/items/form-subform/src/form-subform.vue +92 -0
- package/packages/ui/components/form/items/form-subform/src/types.ts +32 -0
- package/packages/ui/components/form/items/form-subform/styles/form-subform.css +127 -0
- package/packages/ui/components/form/items/form-switch/README.md +118 -0
- package/packages/ui/components/form/items/form-switch/__tests__/form-switch.test.ts +88 -0
- package/packages/ui/components/form/items/form-switch/index.ts +1 -0
- package/packages/ui/components/form/items/form-switch/src/form-switch.ts +7 -0
- package/packages/ui/components/form/items/form-switch/src/form-switch.vue +15 -0
- package/packages/ui/components/form/items/form-table/OPTIMIZATION_REPORT.md +205 -0
- package/packages/ui/components/form/items/form-table/README.md +144 -0
- package/packages/ui/components/form/items/form-table/__tests__/form-table.test.ts +373 -0
- package/packages/ui/components/form/items/form-table/index.ts +3 -0
- package/packages/ui/components/form/items/form-table/src/column-filter-popover.vue +149 -0
- package/packages/ui/components/form/items/form-table/src/form-table.vue +1315 -0
- package/packages/ui/components/form/items/form-table/src/types.ts +165 -0
- package/packages/ui/components/form/items/form-table/styles/column-filter-popover.css +138 -0
- package/packages/ui/components/form/items/form-table/styles/form-table.css +393 -0
- package/packages/ui/components/form/items/form-textarea/README.md +123 -0
- package/packages/ui/components/form/items/form-textarea/__tests__/form-textarea.test.ts +93 -0
- package/packages/ui/components/form/items/form-textarea/index.ts +1 -0
- package/packages/ui/components/form/items/form-textarea/src/form-textarea.ts +7 -0
- package/packages/ui/components/form/items/form-textarea/src/form-textarea.vue +15 -0
- package/packages/ui/components/form/items/form-time-picker/README.md +117 -0
- package/packages/ui/components/form/items/form-time-picker/__tests__/form-time-picker.test.ts +105 -0
- package/packages/ui/components/form/items/form-time-picker/index.ts +1 -0
- package/packages/ui/components/form/items/form-time-picker/src/form-time-picker.ts +7 -0
- package/packages/ui/components/form/items/form-time-picker/src/form-time-picker.vue +17 -0
- package/packages/ui/components/form/items/form-upload/README.md +92 -0
- package/packages/ui/components/form/items/form-upload/__tests__/form-upload.test.ts +137 -0
- package/packages/ui/components/form/items/form-upload/index.ts +1 -0
- package/packages/ui/components/form/items/form-upload/src/form-upload.ts +7 -0
- package/packages/ui/components/form/items/form-upload/src/form-upload.vue +15 -0
- package/packages/ui/components/form/shared/types.ts +82 -0
- package/packages/ui/components/form/src/form-field.ts +96 -0
- package/packages/ui/components/form/src/form-field.vue +404 -0
- package/packages/ui/components/form/src/form-item.vue +646 -0
- package/packages/ui/components/form/src/form.ts +11 -0
- package/packages/ui/components/form/src/form.vue +156 -0
- package/packages/ui/components/form/src/types.ts +337 -0
- package/packages/ui/components/form/src/use-form-field.ts +190 -0
- package/packages/ui/components/form/styles/form-ai-actions.css +41 -0
- package/packages/ui/components/form/styles/form-field.css +123 -0
- package/packages/ui/components/form/styles/form-item-ai-status.css +212 -0
- package/packages/ui/components/form/styles/form-item.css +218 -0
- package/packages/ui/components/form/styles/form.css +132 -0
- package/packages/ui/components/form-ai-status/README.md +86 -0
- package/packages/ui/components/form-ai-status/__tests__/form-ai-status.test.ts +183 -0
- package/packages/ui/components/form-ai-status/index.ts +12 -0
- package/packages/ui/components/form-ai-status/src/form-ai-status.vue +254 -0
- package/packages/ui/components/form-ai-status/src/types.ts +36 -0
- package/packages/ui/components/form-ai-status/styles/form-ai-status.css +238 -0
- package/packages/ui/components/form-ai-toolbar/README.md +100 -0
- package/packages/ui/components/form-ai-toolbar/__tests__/form-ai-toolbar.test.ts +344 -0
- package/packages/ui/components/form-ai-toolbar/index.ts +13 -0
- package/packages/ui/components/form-ai-toolbar/src/form-ai-toolbar.vue +598 -0
- package/packages/ui/components/form-ai-toolbar/src/types.ts +130 -0
- package/packages/ui/components/form-ai-toolbar/styles/form-ai-toolbar.css +281 -0
- package/packages/ui/components/icon/README.md +137 -0
- package/packages/ui/components/icon/__tests__/icon.test.ts +125 -0
- package/packages/ui/components/icon/index.ts +13 -0
- package/packages/ui/components/icon/src/icon.ts +67 -0
- package/packages/ui/components/icon/src/icon.vue +69 -0
- package/packages/ui/components/icon/styles/icon.css +41 -0
- package/packages/ui/components/image-preview/README.md +90 -0
- package/packages/ui/components/image-preview/__tests__/image-preview.test.ts +183 -0
- package/packages/ui/components/image-preview/index.ts +13 -0
- package/packages/ui/components/image-preview/src/image-preview.vue +71 -0
- package/packages/ui/components/image-preview/src/index.ts +11 -0
- package/packages/ui/components/image-preview/src/preview-layer.vue +90 -0
- package/packages/ui/components/image-preview/src/types.ts +63 -0
- package/packages/ui/components/image-preview/styles/image-preview.css +39 -0
- package/packages/ui/components/layout/app-bar/README.md +59 -0
- package/packages/ui/components/layout/app-bar/__tests__/app-bar.test.ts +124 -0
- package/packages/ui/components/layout/app-bar/index.ts +13 -0
- package/packages/ui/components/layout/app-bar/src/app-bar.vue +106 -0
- package/packages/ui/components/layout/app-bar/src/types.ts +43 -0
- package/packages/ui/components/layout/app-bar/styles/app-bar.css +175 -0
- package/packages/ui/components/layout/card/README.md +90 -0
- package/packages/ui/components/layout/card/__tests__/card.test.ts +321 -0
- package/packages/ui/components/layout/card/index.ts +13 -0
- package/packages/ui/components/layout/card/src/card.vue +210 -0
- package/packages/ui/components/layout/card/src/types.ts +79 -0
- package/packages/ui/components/layout/card/styles/card.css +334 -0
- package/packages/ui/components/layout/container/README.md +29 -0
- package/packages/ui/components/layout/container/__tests__/container.test.ts +74 -0
- package/packages/ui/components/layout/container/index.ts +13 -0
- package/packages/ui/components/layout/container/src/container.vue +35 -0
- package/packages/ui/components/layout/container/src/types.ts +15 -0
- package/packages/ui/components/layout/container/styles/container.css +50 -0
- package/packages/ui/components/layout/detail-layout/README.md +30 -0
- package/packages/ui/components/layout/detail-layout/__tests__/detail-layout.test.ts +75 -0
- package/packages/ui/components/layout/detail-layout/index.ts +13 -0
- package/packages/ui/components/layout/detail-layout/src/detail-layout.vue +53 -0
- package/packages/ui/components/layout/detail-layout/src/types.ts +22 -0
- package/packages/ui/components/layout/detail-layout/styles/detail-layout.css +71 -0
- package/packages/ui/components/layout/form-layout/README.md +59 -0
- package/packages/ui/components/layout/form-layout/__tests__/form-layout.test.ts +140 -0
- package/packages/ui/components/layout/form-layout/index.ts +13 -0
- package/packages/ui/components/layout/form-layout/src/form-layout.vue +93 -0
- package/packages/ui/components/layout/form-layout/src/types.ts +64 -0
- package/packages/ui/components/layout/form-layout/styles/form-layout.css +98 -0
- package/packages/ui/components/layout/grid/README.md +41 -0
- package/packages/ui/components/layout/grid/__tests__/grid.test.ts +77 -0
- package/packages/ui/components/layout/grid/index.ts +13 -0
- package/packages/ui/components/layout/grid/src/grid.vue +79 -0
- package/packages/ui/components/layout/grid/src/types.ts +44 -0
- package/packages/ui/components/layout/grid/styles/grid.css +46 -0
- package/packages/ui/components/layout/hero/README.md +59 -0
- package/packages/ui/components/layout/hero/__tests__/hero.test.ts +112 -0
- package/packages/ui/components/layout/hero/index.ts +13 -0
- package/packages/ui/components/layout/hero/src/hero.vue +143 -0
- package/packages/ui/components/layout/hero/src/types.ts +44 -0
- package/packages/ui/components/layout/hero/styles/hero.css +129 -0
- package/packages/ui/components/layout/inline/README.md +30 -0
- package/packages/ui/components/layout/inline/__tests__/inline.test.ts +154 -0
- package/packages/ui/components/layout/inline/index.ts +13 -0
- package/packages/ui/components/layout/inline/src/inline.vue +99 -0
- package/packages/ui/components/layout/inline/src/types.ts +23 -0
- package/packages/ui/components/layout/inline/styles/inline.css +150 -0
- package/packages/ui/components/layout/master-detail/README.md +36 -0
- package/packages/ui/components/layout/master-detail/__tests__/master-detail.test.ts +104 -0
- package/packages/ui/components/layout/master-detail/index.ts +13 -0
- package/packages/ui/components/layout/master-detail/src/master-detail.vue +72 -0
- package/packages/ui/components/layout/master-detail/src/types.ts +28 -0
- package/packages/ui/components/layout/master-detail/styles/master-detail.css +82 -0
- package/packages/ui/components/layout/page/README.md +35 -0
- package/packages/ui/components/layout/page/__tests__/page.test.ts +136 -0
- package/packages/ui/components/layout/page/index.ts +13 -0
- package/packages/ui/components/layout/page/src/page.vue +85 -0
- package/packages/ui/components/layout/page/src/types.ts +39 -0
- package/packages/ui/components/layout/page/styles/page.css +177 -0
- package/packages/ui/components/layout/page-header/README.md +39 -0
- package/packages/ui/components/layout/page-header/__tests__/page-header.test.ts +198 -0
- package/packages/ui/components/layout/page-header/index.ts +13 -0
- package/packages/ui/components/layout/page-header/src/page-header.vue +133 -0
- package/packages/ui/components/layout/page-header/src/types.ts +56 -0
- package/packages/ui/components/layout/page-header/styles/page-header.css +155 -0
- package/packages/ui/components/layout/section/README.md +40 -0
- package/packages/ui/components/layout/section/__tests__/section.test.ts +121 -0
- package/packages/ui/components/layout/section/index.ts +13 -0
- package/packages/ui/components/layout/section/src/section.vue +79 -0
- package/packages/ui/components/layout/section/src/types.ts +28 -0
- package/packages/ui/components/layout/section/styles/section.css +103 -0
- package/packages/ui/components/layout/sidebar-layout/README.md +60 -0
- package/packages/ui/components/layout/sidebar-layout/__tests__/sidebar-layout.test.ts +220 -0
- package/packages/ui/components/layout/sidebar-layout/index.ts +13 -0
- package/packages/ui/components/layout/sidebar-layout/src/sidebar-layout.vue +113 -0
- package/packages/ui/components/layout/sidebar-layout/src/types.ts +54 -0
- package/packages/ui/components/layout/sidebar-layout/styles/sidebar-layout.css +211 -0
- package/packages/ui/components/layout/split/README.md +40 -0
- package/packages/ui/components/layout/split/__tests__/split.test.ts +99 -0
- package/packages/ui/components/layout/split/index.ts +13 -0
- package/packages/ui/components/layout/split/src/split.vue +65 -0
- package/packages/ui/components/layout/split/src/types.ts +49 -0
- package/packages/ui/components/layout/split/styles/split.css +40 -0
- package/packages/ui/components/layout/stack/README.md +29 -0
- package/packages/ui/components/layout/stack/__tests__/stack.test.ts +66 -0
- package/packages/ui/components/layout/stack/index.ts +13 -0
- package/packages/ui/components/layout/stack/src/stack.vue +31 -0
- package/packages/ui/components/layout/stack/src/types.ts +14 -0
- package/packages/ui/components/layout/stack/styles/stack.css +61 -0
- package/packages/ui/components/layout/state-container/README.md +45 -0
- package/packages/ui/components/layout/state-container/__tests__/state-container.test.ts +123 -0
- package/packages/ui/components/layout/state-container/index.ts +13 -0
- package/packages/ui/components/layout/state-container/src/state-container.vue +72 -0
- package/packages/ui/components/layout/state-container/src/types.ts +46 -0
- package/packages/ui/components/layout/state-container/styles/state-container.css +71 -0
- package/packages/ui/components/layout/toolbar/README.md +34 -0
- package/packages/ui/components/layout/toolbar/__tests__/toolbar.test.ts +90 -0
- package/packages/ui/components/layout/toolbar/index.ts +13 -0
- package/packages/ui/components/layout/toolbar/src/toolbar.vue +50 -0
- package/packages/ui/components/layout/toolbar/src/types.ts +19 -0
- package/packages/ui/components/layout/toolbar/styles/toolbar.css +80 -0
- package/packages/ui/components/loading/README.md +39 -0
- package/packages/ui/components/loading/__tests__/loading.test.ts +37 -0
- package/packages/ui/components/loading/index.ts +13 -0
- package/packages/ui/components/loading/src/loading.vue +59 -0
- package/packages/ui/components/loading/src/types.ts +27 -0
- package/packages/ui/components/loading/styles/loading.css +59 -0
- package/packages/ui/components/menu/README.md +51 -0
- package/packages/ui/components/menu/__tests__/menu.test.ts +80 -0
- package/packages/ui/components/menu/index.ts +11 -0
- package/packages/ui/components/menu/src/menu.ts +49 -0
- package/packages/ui/components/menu/src/menu.vue +103 -0
- package/packages/ui/components/menu/styles/menu.css +19 -0
- package/packages/ui/components/message/README.md +69 -0
- package/packages/ui/components/message/__tests__/message.test.ts +98 -0
- package/packages/ui/components/message/index.ts +13 -0
- package/packages/ui/components/message/src/message.ts +87 -0
- package/packages/ui/components/message/src/message.vue +88 -0
- package/packages/ui/components/message/styles/message.css +70 -0
- package/packages/ui/components/metric/README.md +63 -0
- package/packages/ui/components/metric/__tests__/metric.test.ts +166 -0
- package/packages/ui/components/metric/index.ts +13 -0
- package/packages/ui/components/metric/src/metric.vue +107 -0
- package/packages/ui/components/metric/src/types.ts +50 -0
- package/packages/ui/components/metric/styles/metric.css +233 -0
- package/packages/ui/components/modal/README.md +91 -0
- package/packages/ui/components/modal/__tests__/modal.test.ts +145 -0
- package/packages/ui/components/modal/index.ts +13 -0
- package/packages/ui/components/modal/src/modal.ts +153 -0
- package/packages/ui/components/modal/src/modal.vue +234 -0
- package/packages/ui/components/modal/styles/modal.css +104 -0
- package/packages/ui/components/more-action-button/README.md +68 -0
- package/packages/ui/components/more-action-button/__tests__/more-action-button.test.ts +30 -0
- package/packages/ui/components/more-action-button/index.ts +11 -0
- package/packages/ui/components/more-action-button/src/more-action-button.vue +59 -0
- package/packages/ui/components/more-action-button/src/types.ts +9 -0
- package/packages/ui/components/navigation/side-nav/README.md +59 -0
- package/packages/ui/components/navigation/side-nav/__tests__/side-nav.test.ts +105 -0
- package/packages/ui/components/navigation/side-nav/index.ts +13 -0
- package/packages/ui/components/navigation/side-nav/src/side-nav.vue +147 -0
- package/packages/ui/components/navigation/side-nav/src/types.ts +50 -0
- package/packages/ui/components/navigation/side-nav/styles/side-nav.css +171 -0
- package/packages/ui/components/notification/README.md +82 -0
- package/packages/ui/components/notification/__tests__/notification.test.ts +150 -0
- package/packages/ui/components/notification/index.ts +30 -0
- package/packages/ui/components/notification/src/notification.vue +114 -0
- package/packages/ui/components/notification/src/types.ts +67 -0
- package/packages/ui/components/notification/src/use-notification.ts +136 -0
- package/packages/ui/components/notification/styles/notification.css +4 -0
- package/packages/ui/components/pagination/README.md +82 -0
- package/packages/ui/components/pagination/__tests__/pagination.test.ts +210 -0
- package/packages/ui/components/pagination/index.ts +13 -0
- package/packages/ui/components/pagination/src/pagination.ts +86 -0
- package/packages/ui/components/pagination/src/pagination.vue +270 -0
- package/packages/ui/components/pagination/styles/pagination.css +143 -0
- package/packages/ui/components/progress/README.md +132 -0
- package/packages/ui/components/progress/__tests__/progress.test.ts +81 -0
- package/packages/ui/components/progress/index.ts +12 -0
- package/packages/ui/components/progress/src/progress.ts +80 -0
- package/packages/ui/components/progress/src/progress.vue +202 -0
- package/packages/ui/components/skeleton/README.md +71 -0
- package/packages/ui/components/skeleton/__tests__/skeleton.test.ts +138 -0
- package/packages/ui/components/skeleton/index.ts +13 -0
- package/packages/ui/components/skeleton/src/skeleton.ts +46 -0
- package/packages/ui/components/skeleton/src/skeleton.vue +67 -0
- package/packages/ui/components/skeleton/styles/skeleton.css +75 -0
- package/packages/ui/components/slider/README.md +87 -0
- package/packages/ui/components/slider/__tests__/ai-capability.test.ts +469 -0
- package/packages/ui/components/slider/__tests__/slider.test.ts +235 -0
- package/packages/ui/components/slider/index.ts +26 -0
- package/packages/ui/components/slider/src/slider.ts +192 -0
- package/packages/ui/components/slider/src/slider.vue +504 -0
- package/packages/ui/components/slider/src/use-slider.ts +399 -0
- package/packages/ui/components/slider/styles/slider.css +344 -0
- package/packages/ui/components/split-button/README.md +71 -0
- package/packages/ui/components/split-button/__tests__/split-button.test.ts +32 -0
- package/packages/ui/components/split-button/index.ts +11 -0
- package/packages/ui/components/split-button/src/split-button.vue +69 -0
- package/packages/ui/components/split-button/src/types.ts +34 -0
- package/packages/ui/components/split-button/styles/split-button.css +15 -0
- package/packages/ui/components/status-dot/README.md +42 -0
- package/packages/ui/components/status-dot/__tests__/status-dot.test.ts +53 -0
- package/packages/ui/components/status-dot/index.ts +13 -0
- package/packages/ui/components/status-dot/src/status-dot.vue +39 -0
- package/packages/ui/components/status-dot/src/types.ts +23 -0
- package/packages/ui/components/status-dot/styles/status-dot.css +65 -0
- package/packages/ui/components/steps/README.md +101 -0
- package/packages/ui/components/steps/__tests__/steps.test.ts +261 -0
- package/packages/ui/components/steps/index.ts +15 -0
- package/packages/ui/components/steps/src/step.vue +99 -0
- package/packages/ui/components/steps/src/steps.ts +93 -0
- package/packages/ui/components/steps/src/steps.vue +143 -0
- package/packages/ui/components/steps/styles/step.css +116 -0
- package/packages/ui/components/steps/styles/steps.css +200 -0
- package/packages/ui/components/table/README.md +81 -0
- package/packages/ui/components/table/__tests__/table.test.ts +162 -0
- package/packages/ui/components/table/index.ts +13 -0
- package/packages/ui/components/table/src/table.ts +195 -0
- package/packages/ui/components/table/src/table.vue +453 -0
- package/packages/ui/components/table/styles/table.css +88 -0
- package/packages/ui/components/tabs/README.md +88 -0
- package/packages/ui/components/tabs/__tests__/tabs.test.ts +161 -0
- package/packages/ui/components/tabs/index.ts +19 -0
- package/packages/ui/components/tabs/src/tab-pane.ts +18 -0
- package/packages/ui/components/tabs/src/tab-pane.vue +11 -0
- package/packages/ui/components/tabs/src/tabs-content.vue +58 -0
- package/packages/ui/components/tabs/src/tabs-list.vue +36 -0
- package/packages/ui/components/tabs/src/tabs-trigger.vue +70 -0
- package/packages/ui/components/tabs/src/tabs.ts +94 -0
- package/packages/ui/components/tabs/src/tabs.vue +101 -0
- package/packages/ui/components/tabs/src/types.ts +126 -0
- package/packages/ui/components/tabs/styles/tabs.css +239 -0
- package/packages/ui/components/tag/README.md +67 -0
- package/packages/ui/components/tag/__tests__/tag.test.ts +222 -0
- package/packages/ui/components/tag/index.ts +13 -0
- package/packages/ui/components/tag/src/tag.ts +87 -0
- package/packages/ui/components/tag/src/tag.vue +163 -0
- package/packages/ui/components/tag/styles/tag.css +47 -0
- package/packages/ui/components/timeline/README.md +80 -0
- package/packages/ui/components/timeline/__tests__/timeline.test.ts +78 -0
- package/packages/ui/components/timeline/index.ts +15 -0
- package/packages/ui/components/timeline/src/timeline-item.vue +38 -0
- package/packages/ui/components/timeline/src/timeline.ts +76 -0
- package/packages/ui/components/timeline/src/timeline.vue +30 -0
- package/packages/ui/components/timeline/styles/timeline-item.css +49 -0
- package/packages/ui/components/timeline/styles/timeline.css +43 -0
- package/packages/ui/components/tooltip/README.md +134 -0
- package/packages/ui/components/tooltip/__tests__/tooltip.test.ts +125 -0
- package/packages/ui/components/tooltip/index.ts +12 -0
- package/packages/ui/components/tooltip/src/tooltip.ts +66 -0
- package/packages/ui/components/tooltip/src/tooltip.vue +189 -0
- package/packages/ui/components/tree/README.md +54 -0
- package/packages/ui/components/tree/__tests__/tree.test.ts +80 -0
- package/packages/ui/components/tree/index.ts +11 -0
- package/packages/ui/components/tree/src/tree.ts +51 -0
- package/packages/ui/components/tree/src/tree.vue +242 -0
- package/packages/ui/components/tree/styles/tree.css +31 -0
- package/packages/ui/components/typography/README.md +120 -0
- package/packages/ui/components/typography/__tests__/typography.test.ts +164 -0
- package/packages/ui/components/typography/index.ts +13 -0
- package/packages/ui/components/typography/src/typography.ts +95 -0
- package/packages/ui/components/typography/src/typography.vue +94 -0
- package/packages/ui/components/typography/styles/typography.css +47 -0
- package/packages/ui/components/upload/README.md +103 -0
- package/packages/ui/components/upload/__tests__/upload.test.ts +181 -0
- package/packages/ui/components/upload/index.ts +11 -0
- package/packages/ui/components/upload/src/upload.ts +92 -0
- package/packages/ui/components/upload/src/upload.vue +382 -0
- package/packages/ui/components/upload/styles/upload.css +283 -0
- package/packages/ui/components/watermark/README.md +94 -0
- package/packages/ui/components/watermark/__tests__/watermark.test.ts +252 -0
- package/packages/ui/components/watermark/index.ts +13 -0
- package/packages/ui/components/watermark/src/index.ts +13 -0
- package/packages/ui/components/watermark/src/types.ts +86 -0
- package/packages/ui/components/watermark/src/use-watermark.ts +132 -0
- package/packages/ui/components/watermark/src/watermark.vue +181 -0
- package/packages/ui/components/watermark/styles/watermark.css +27 -0
- package/packages/ui/index.ts +338 -0
- package/packages/ui/lib/utils.ts +6 -0
- package/packages/ui/lowcode-agent/icons.ts +148 -0
- package/packages/ui/lowcode-agent/index.ts +26 -0
- package/packages/ui/lowcode-agent/registry.json +37004 -0
- package/packages/ui/lowcode-agent/types.ts +312 -0
- package/packages/ui/src/composables/__tests__/use-floating-popup.test.ts +275 -0
- package/packages/ui/src/composables/__tests__/use-form-ai-actions.test.ts +101 -0
- package/packages/ui/src/composables/__tests__/use-form-ai-registry.test.ts +92 -0
- package/packages/ui/src/composables/__tests__/use-form-ai.test.ts +116 -0
- package/packages/ui/src/composables/index.ts +10 -0
- package/packages/ui/src/composables/use-ai-state-machine.ts +142 -0
- package/packages/ui/src/composables/use-floating-popup.ts +237 -0
- package/packages/ui/src/composables/use-form-ai-registry.ts +198 -0
- package/packages/ui/src/composables/use-form-ai.ts +280 -0
- package/packages/ui/src/composables/useLightbox.ts +51 -0
- package/packages/ui/src/request/document.ts +53 -0
- package/packages/ui/src/request/enum.ts +18 -0
- package/packages/ui/src/request/index.ts +4 -0
- package/packages/ui/src/request/request.ts +200 -0
- package/packages/ui/src/request/types.ts +27 -0
- package/packages/ui/src/types/form-ai-registry.ts +70 -0
- package/packages/ui/src/types/form-ai.ts +84 -0
- package/packages/ui/src/utils/date-format.ts +60 -0
- package/packages/ui/styles/design-tokens.css +383 -0
- package/packages/ui/styles/tailwind.css +76 -0
- package/packages/ui/styles/tokens.css +7 -0
- package/playground/index.html +12 -0
- package/playground/postcss.config.cjs +5 -0
- package/playground/src/App.vue +3 -0
- package/playground/src/__tests__/__debug-input.test.ts +29 -0
- package/playground/src/__tests__/button-ai-confirm.test.ts +41 -0
- package/playground/src/__tests__/home-render.test.ts +87 -0
- package/playground/src/__tests__/icon-library.test.ts +107 -0
- package/playground/src/__tests__/input-ai-confirm.test.ts +113 -0
- package/playground/src/__tests__/textarea-ai-button.test.ts +87 -0
- package/playground/src/__tests__/textarea-wordlimit.test.ts +66 -0
- package/playground/src/chart-theme.ts +22 -0
- package/playground/src/components/AiStateFlow.vue +59 -0
- package/playground/src/components/ComponentShowcase.vue +180 -0
- package/playground/src/composables/useAiStateMachine.ts +111 -0
- package/playground/src/data/component-api.ts +187 -0
- package/playground/src/data/component-meta.ts +84 -0
- package/playground/src/layouts/DefaultLayout.vue +318 -0
- package/playground/src/main.ts +18 -0
- package/playground/src/router/index.ts +101 -0
- package/playground/src/views/AffixDemo.vue +133 -0
- package/playground/src/views/AiStateFlowDemo.vue +170 -0
- package/playground/src/views/AlertDemo.vue +554 -0
- package/playground/src/views/AnchorDemo.vue +150 -0
- package/playground/src/views/AppBarDemo.vue +722 -0
- package/playground/src/views/AvatarDemo.vue +266 -0
- package/playground/src/views/BackTopDemo.vue +71 -0
- package/playground/src/views/BadgeDemo.vue +109 -0
- package/playground/src/views/BatchActionButtonDemo.vue +65 -0
- package/playground/src/views/BreadcrumbDemo.vue +248 -0
- package/playground/src/views/ButtonDemo.vue +344 -0
- package/playground/src/views/CardDemo.vue +254 -0
- package/playground/src/views/CarouselDemo.vue +158 -0
- package/playground/src/views/CascaderDemo.vue +425 -0
- package/playground/src/views/ChartDemo.vue +232 -0
- package/playground/src/views/CheckboxDemo.vue +339 -0
- package/playground/src/views/DataGridDemo.vue +518 -0
- package/playground/src/views/DataPickerDemo.vue +240 -0
- package/playground/src/views/DatePickerDemo.vue +292 -0
- package/playground/src/views/DateTimePickerDemo.vue +208 -0
- package/playground/src/views/DesignSpecDemo.vue +1647 -0
- package/playground/src/views/DividerDemo.vue +77 -0
- package/playground/src/views/DocumentActionHeaderDemo.vue +113 -0
- package/playground/src/views/DocumentFormPageDemo.vue +200 -0
- package/playground/src/views/DrawerDemo.vue +166 -0
- package/playground/src/views/DropdownButtonDemo.vue +74 -0
- package/playground/src/views/DropdownDemo.vue +306 -0
- package/playground/src/views/EmptyDemo.vue +104 -0
- package/playground/src/views/ErrorDemo.vue +111 -0
- package/playground/src/views/FileUploadDemo.vue +241 -0
- package/playground/src/views/FilterButtonDemo.vue +65 -0
- package/playground/src/views/FormFieldAiDemo.vue +364 -0
- package/playground/src/views/FormFieldBasicDemo.vue +174 -0
- package/playground/src/views/FormFieldBusinessDemo.vue +245 -0
- package/playground/src/views/FormFieldDemo.vue +178 -0
- package/playground/src/views/FormFieldLayoutDemo.vue +183 -0
- package/playground/src/views/FormFieldValidationDemo.vue +163 -0
- package/playground/src/views/FormItemAiDemo.vue +371 -0
- package/playground/src/views/FormSelectDemo.vue +519 -0
- package/playground/src/views/FormUploadDemo.vue +536 -0
- package/playground/src/views/HeroDemo.vue +836 -0
- package/playground/src/views/Home.vue +213 -0
- package/playground/src/views/IconDemo.vue +186 -0
- package/playground/src/views/IconLibraryView.vue +370 -0
- package/playground/src/views/IconRenderTest.vue +86 -0
- package/playground/src/views/ImagePreviewDemo.vue +368 -0
- package/playground/src/views/ImageUploadDemo.vue +199 -0
- package/playground/src/views/InputDemo.vue +348 -0
- package/playground/src/views/LayoutDemo.vue +946 -0
- package/playground/src/views/LoadingDemo.vue +95 -0
- package/playground/src/views/LocationPickerDemo.vue +218 -0
- package/playground/src/views/MenuDemo.vue +283 -0
- package/playground/src/views/MessageDemo.vue +201 -0
- package/playground/src/views/MetricDemo.vue +535 -0
- package/playground/src/views/ModalDemo.vue +291 -0
- package/playground/src/views/MoreActionButtonDemo.vue +65 -0
- package/playground/src/views/NewDocumentDemo.vue +973 -0
- package/playground/src/views/NotificationDemo.vue +255 -0
- package/playground/src/views/PaginationDemo.vue +292 -0
- package/playground/src/views/ProgressDemo.vue +356 -0
- package/playground/src/views/RadioDemo.vue +414 -0
- package/playground/src/views/RegionPickerDemo.vue +249 -0
- package/playground/src/views/ScalingRulesDemo.vue +333 -0
- package/playground/src/views/SelectDemo.vue +453 -0
- package/playground/src/views/SideNavDemo.vue +769 -0
- package/playground/src/views/SignatureDemo.vue +205 -0
- package/playground/src/views/SkeletonDemo.vue +109 -0
- package/playground/src/views/SliderDemo.vue +312 -0
- package/playground/src/views/SplitButtonDemo.vue +65 -0
- package/playground/src/views/StatusDotDemo.vue +131 -0
- package/playground/src/views/StepsDemo.vue +587 -0
- package/playground/src/views/SwitchDemo.vue +442 -0
- package/playground/src/views/TableDemo.vue +438 -0
- package/playground/src/views/TabsDemo.vue +246 -0
- package/playground/src/views/TagDemo.vue +113 -0
- package/playground/src/views/TextAreaDemo.vue +317 -0
- package/playground/src/views/TimePickerDemo.vue +291 -0
- package/playground/src/views/TimelineDemo.vue +133 -0
- package/playground/src/views/TooltipDemo.vue +102 -0
- package/playground/src/views/TreeDemo.vue +521 -0
- package/playground/src/views/TypographyDemo.vue +175 -0
- package/playground/src/views/UploadDemo.vue +331 -0
- package/playground/src/views/WatermarkDemo.vue +112 -0
- package/playground/src/views/_mocks/new-document.mock.ts +506 -0
- package/playground/src/views/data/form-field-events-table.ts +243 -0
- package/playground/src/views/data/form-field-options.ts +77 -0
- package/playground/src/views/data/form-field-props-table.ts +227 -0
- package/playground/src/views/data/form-field-snippets.ts +149 -0
- package/playground/src/views/data/slider-snippets.ts +100 -0
- package/playground/src/views/inner/FormFieldEventsDoc.vue +147 -0
- package/playground/src/views/inner/FormFieldPropsDoc.vue +138 -0
- package/playground/vite.config.ts +25 -0
- package/pnpm-workspace.yaml +3 -0
- package/postcss.config.cjs +5 -0
- package/scripts/check-design-token-compliance.mjs +223 -0
- package/scripts/generate-package-dts.mjs +105 -0
- package/tsconfig.json +35 -0
- package/tsconfig.node.json +13 -0
- package/vite.config.ts +68 -0
- package/Button/button-props.d.ts +0 -9
- package/Button/button-variants.d.ts +0 -5
- package/Button/index.d.ts +0 -20
- package/Button/index.js +0 -111
- package/index.css +0 -596
- package/index.d.ts +0 -15
- package/index.js +0 -19
- package/utils/forward-attrs.d.ts +0 -6
- package/utils/install.d.ts +0 -6
- package/utils/utils.d.ts +0 -2
|
@@ -0,0 +1,890 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* TfUpload v2 表单附件组件
|
|
4
|
+
* 与 TfFileUpload(字段附件紧凑 Chip)不同,本组件用于表单级附件区。
|
|
5
|
+
* v2:统一 Card Header 操作、上传 Modal、分组管理 Modal、审批 Drawer、文件行更多菜单。
|
|
6
|
+
*/
|
|
7
|
+
import { computed, reactive, ref, watch, onUnmounted } from 'vue'
|
|
8
|
+
import { cn } from '../../../../../lib/utils'
|
|
9
|
+
import type {
|
|
10
|
+
UploadApprovalRecord,
|
|
11
|
+
UploadApprovalStatus,
|
|
12
|
+
UploadEmits,
|
|
13
|
+
UploadFileItem,
|
|
14
|
+
UploadGroup,
|
|
15
|
+
UploadGroupChange,
|
|
16
|
+
UploadProps,
|
|
17
|
+
UploadSlots,
|
|
18
|
+
AiConfig
|
|
19
|
+
} from './upload'
|
|
20
|
+
import { useAiStateMachine } from '../../../../../src/composables/use-ai-state-machine'
|
|
21
|
+
import type { AiState } from '../../../../../src/composables/use-ai-state-machine'
|
|
22
|
+
|
|
23
|
+
const props = withDefaults(defineProps<UploadProps>(), {
|
|
24
|
+
modelValue: () => [],
|
|
25
|
+
groups: () => [],
|
|
26
|
+
multiple: true,
|
|
27
|
+
accept: '*',
|
|
28
|
+
maxCount: undefined,
|
|
29
|
+
maxSize: undefined,
|
|
30
|
+
disabled: false,
|
|
31
|
+
showUploadDate: true,
|
|
32
|
+
showFileType: true,
|
|
33
|
+
showProgress: true,
|
|
34
|
+
buttonText: '上传附件',
|
|
35
|
+
cardTitle: '表单附件',
|
|
36
|
+
cardDescription: '统一管理本表单的附件、分组与审批状态',
|
|
37
|
+
showSummary: true,
|
|
38
|
+
uploadTargetGroupKey: undefined,
|
|
39
|
+
showUploadTargetSelector: true,
|
|
40
|
+
editableGroups: false,
|
|
41
|
+
allowMoveBetweenGroups: false,
|
|
42
|
+
defaultGroupLabel: '新分组',
|
|
43
|
+
approval: false,
|
|
44
|
+
groupApproval: false,
|
|
45
|
+
pendingGroupChanges: () => [],
|
|
46
|
+
currentUser: '当前用户',
|
|
47
|
+
showApprovalHistory: false
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const emit = defineEmits<UploadEmits>()
|
|
51
|
+
defineSlots<UploadSlots>()
|
|
52
|
+
|
|
53
|
+
const UNGROUPED_KEY = '__ungrouped__'
|
|
54
|
+
const inputRef = ref<HTMLInputElement | null>(null)
|
|
55
|
+
const visibleError = ref('')
|
|
56
|
+
const deleteGroupError = ref('')
|
|
57
|
+
|
|
58
|
+
const uploadModalOpen = ref(false)
|
|
59
|
+
const stagedFiles = ref<UploadFileItem[]>([])
|
|
60
|
+
const stagedDefaultGroupKey = ref(props.uploadTargetGroupKey ?? '')
|
|
61
|
+
|
|
62
|
+
const groupModalOpen = ref(false)
|
|
63
|
+
const groupDraftMode = ref<'add' | 'edit'>('add')
|
|
64
|
+
const editingGroupKey = ref<string | null>(null)
|
|
65
|
+
const groupFormKey = ref('')
|
|
66
|
+
const groupFormLabel = ref('')
|
|
67
|
+
const groupFormDescription = ref('')
|
|
68
|
+
const groupFormAccept = ref('')
|
|
69
|
+
const groupFormMaxCount = ref('')
|
|
70
|
+
const groupFormError = ref('')
|
|
71
|
+
const groupDraftNotice = ref('')
|
|
72
|
+
const savedGroupDrafts = ref<Array<{ mode: 'add' | 'edit'; group: UploadGroup; oldGroup?: UploadGroup }>>([])
|
|
73
|
+
|
|
74
|
+
const approvalDrawerOpen = ref(false)
|
|
75
|
+
const completedGroupChanges = ref<UploadGroupChange[]>([])
|
|
76
|
+
const approvalComments = reactive<Record<string, string>>({})
|
|
77
|
+
const openMoreFileId = ref<string | null>(null)
|
|
78
|
+
|
|
79
|
+
const fileList = computed(() => props.modelValue ?? [])
|
|
80
|
+
const internalGroups = ref<UploadGroup[]>([...(props.groups ?? [])])
|
|
81
|
+
const localPendingGroupChanges = ref<UploadGroupChange[]>([...(props.pendingGroupChanges ?? [])])
|
|
82
|
+
const localUploadTargetGroupKey = ref(props.uploadTargetGroupKey ?? '')
|
|
83
|
+
|
|
84
|
+
watch(() => props.groups, groups => { internalGroups.value = [...(groups ?? [])] }, { deep: true })
|
|
85
|
+
watch(() => props.pendingGroupChanges, changes => { localPendingGroupChanges.value = [...(changes ?? [])] }, { deep: true })
|
|
86
|
+
watch(() => props.uploadTargetGroupKey, key => {
|
|
87
|
+
localUploadTargetGroupKey.value = key ?? ''
|
|
88
|
+
stagedDefaultGroupKey.value = key ?? ''
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
const activeGroups = computed(() => internalGroups.value)
|
|
92
|
+
const hasGroups = computed(() => activeGroups.value.length > 0)
|
|
93
|
+
const totalMaxedOut = computed(() => props.maxCount != null && fileList.value.length >= props.maxCount)
|
|
94
|
+
const effectiveGroupApproval = computed(() => props.groupApproval || props.approval)
|
|
95
|
+
const pendingGroups = computed(() => localPendingGroupChanges.value.filter(change => change.status === 'pending'))
|
|
96
|
+
const pendingFileCount = computed(() => fileList.value.filter(file => file.approvalStatus === 'pending').length)
|
|
97
|
+
const errorFileCount = computed(() => fileList.value.filter(file => file.status === 'error').length)
|
|
98
|
+
const pendingTotalCount = computed(() => pendingFileCount.value + pendingGroups.value.length)
|
|
99
|
+
const uploadTargetKey = computed(() => props.uploadTargetGroupKey ?? localUploadTargetGroupKey.value)
|
|
100
|
+
|
|
101
|
+
const ungroupedGroup = computed<UploadGroup | null>(() => {
|
|
102
|
+
if (!hasGroups.value) return null
|
|
103
|
+
return fileList.value.some(file => !file.groupKey)
|
|
104
|
+
? { key: UNGROUPED_KEY, label: '未分组', description: '未指定分组的附件' }
|
|
105
|
+
: null
|
|
106
|
+
})
|
|
107
|
+
const displayGroups = computed(() => {
|
|
108
|
+
const groups = [...activeGroups.value]
|
|
109
|
+
if (ungroupedGroup.value) groups.push(ungroupedGroup.value)
|
|
110
|
+
return groups
|
|
111
|
+
})
|
|
112
|
+
const flatListGroup: UploadGroup = { key: UNGROUPED_KEY, label: '附件列表', description: '未启用分组时的表单附件' }
|
|
113
|
+
|
|
114
|
+
const CATEGORY_LABEL: Record<NonNullable<UploadFileItem['category']>, string> = {
|
|
115
|
+
pdf: 'PDF', word: 'Word', excel: 'Excel', image: '图片', zip: '压缩包', other: '其他'
|
|
116
|
+
}
|
|
117
|
+
const CATEGORY_DOT: Record<NonNullable<UploadFileItem['category']>, string> = {
|
|
118
|
+
pdf: 'var(--tf-color-filetype-pdf)', word: 'var(--tf-color-filetype-word)', excel: 'var(--tf-color-filetype-excel)', image: 'var(--tf-color-filetype-image)', zip: 'var(--tf-color-filetype-zip)', other: 'var(--tf-color-filetype-default)'
|
|
119
|
+
}
|
|
120
|
+
const APPROVAL_STATUS_LABEL: Record<UploadApprovalStatus, string> = {
|
|
121
|
+
draft: '草稿', pending: '待审批', approved: '已通过', rejected: '已驳回', supplement_required: '需补充'
|
|
122
|
+
}
|
|
123
|
+
const APPROVAL_STATUS_COLOR: Record<UploadApprovalStatus, string> = {
|
|
124
|
+
draft: 'var(--tf-color-upload-draft)', pending: 'var(--tf-color-upload-pending)', approved: 'var(--tf-color-upload-approved)', rejected: 'var(--tf-color-upload-rejected)', supplement_required: 'var(--tf-color-upload-supplement)'
|
|
125
|
+
}
|
|
126
|
+
const GROUP_CHANGE_LABEL = { add: '新增分组', edit: '编辑分组' }
|
|
127
|
+
|
|
128
|
+
function setVisibleError(message: string) { visibleError.value = message }
|
|
129
|
+
function createError(message: string): Error { return new Error(message) }
|
|
130
|
+
function emitError(message: string, error?: Error) {
|
|
131
|
+
const err = error ?? createError(message)
|
|
132
|
+
console.warn('[TfUpload]', err)
|
|
133
|
+
setVisibleError(message)
|
|
134
|
+
emit('error', err)
|
|
135
|
+
}
|
|
136
|
+
function warnUi(message: string) {
|
|
137
|
+
console.warn('[TfUpload]', message)
|
|
138
|
+
setVisibleError(message)
|
|
139
|
+
}
|
|
140
|
+
function getExtension(name: string): string { return name.includes('.') ? name.split('.').pop()?.toLowerCase() ?? '' : '' }
|
|
141
|
+
function inferCategoryByNameAndType(name: string, type = ''): UploadFileItem['category'] {
|
|
142
|
+
const ext = getExtension(name); const mime = type.toLowerCase()
|
|
143
|
+
if (ext === 'pdf' || mime.includes('pdf')) return 'pdf'
|
|
144
|
+
if (['doc', 'docx'].includes(ext) || mime.includes('word') || mime.includes('document')) return 'word'
|
|
145
|
+
if (['xls', 'xlsx', 'csv'].includes(ext) || mime.includes('sheet') || mime.includes('excel') || mime.includes('csv')) return 'excel'
|
|
146
|
+
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'svg'].includes(ext) || mime.startsWith('image/')) return 'image'
|
|
147
|
+
if (['zip', 'rar', '7z', 'tar', 'gz'].includes(ext) || mime.includes('zip') || mime.includes('rar') || mime.includes('compressed')) return 'zip'
|
|
148
|
+
return 'other'
|
|
149
|
+
}
|
|
150
|
+
function inferTypeByNameAndType(name: string, type = ''): string {
|
|
151
|
+
if (type) return type
|
|
152
|
+
const ext = getExtension(name)
|
|
153
|
+
const typeMap: Record<string, string> = {
|
|
154
|
+
pdf: 'application/pdf', doc: 'application/msword', docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
155
|
+
xls: 'application/vnd.ms-excel', xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', csv: 'text/csv',
|
|
156
|
+
jpg: 'image/jpeg', jpeg: 'image/jpeg', png: 'image/png', gif: 'image/gif', webp: 'image/webp', zip: 'application/zip', rar: 'application/vnd.rar', txt: 'text/plain'
|
|
157
|
+
}
|
|
158
|
+
return typeMap[ext] ?? 'application/octet-stream'
|
|
159
|
+
}
|
|
160
|
+
function getFileCategory(file: UploadFileItem): NonNullable<UploadFileItem['category']> { return file.category ?? inferCategoryByNameAndType(file.name, file.type) ?? 'other' }
|
|
161
|
+
function getTypeLabel(file: UploadFileItem): string { return CATEGORY_LABEL[getFileCategory(file)] }
|
|
162
|
+
function getDotColor(file: UploadFileItem): string { return CATEGORY_DOT[getFileCategory(file)] }
|
|
163
|
+
function pad(value: number): string { return String(value).padStart(2, '0') }
|
|
164
|
+
function formatNow(): string {
|
|
165
|
+
const date = new Date()
|
|
166
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`
|
|
167
|
+
}
|
|
168
|
+
function formatUploadDate(value?: string | Date): string {
|
|
169
|
+
if (!value) return ''
|
|
170
|
+
if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(value)) return value
|
|
171
|
+
const date = value instanceof Date ? value : new Date(value)
|
|
172
|
+
if (Number.isNaN(date.getTime())) return ''
|
|
173
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`
|
|
174
|
+
}
|
|
175
|
+
function formatFileSize(bytes: number): string { return bytes < 1024 ? `${bytes}B` : bytes < 1024 * 1024 ? `${(bytes / 1024).toFixed(1)}KB` : `${(bytes / 1024 / 1024).toFixed(1)}MB` }
|
|
176
|
+
function statusLabel(status?: UploadFileItem['status']): string {
|
|
177
|
+
return ({ ready: '待上传', uploading: '上传中', done: '已完成', error: '失败' } as Record<NonNullable<UploadFileItem['status']>, string>)[status ?? 'ready']
|
|
178
|
+
}
|
|
179
|
+
function getGroupFiles(groupKey: string): UploadFileItem[] {
|
|
180
|
+
if (groupKey === UNGROUPED_KEY) return hasGroups.value ? fileList.value.filter(file => !file.groupKey) : fileList.value
|
|
181
|
+
return fileList.value.filter(file => file.groupKey === groupKey)
|
|
182
|
+
}
|
|
183
|
+
function getGlobalIndex(file: UploadFileItem): number { return fileList.value.indexOf(file) }
|
|
184
|
+
function getUploadTargetGroup(groupKey = stagedDefaultGroupKey.value): UploadGroup | undefined { return activeGroups.value.find(group => group.key === groupKey) }
|
|
185
|
+
function getUploadAccept(): string { return getUploadTargetGroup()?.accept ?? props.accept }
|
|
186
|
+
function isGroupMaxedOut(group: UploadGroup): boolean { return group.key !== UNGROUPED_KEY && group.maxCount != null && getGroupFiles(group.key).length >= group.maxCount }
|
|
187
|
+
function isUploadDisabled(): boolean {
|
|
188
|
+
const targetGroup = getUploadTargetGroup(uploadTargetKey.value)
|
|
189
|
+
return props.disabled || totalMaxedOut.value || !!targetGroup?.disabled || (targetGroup?.maxCount != null && getGroupFiles(targetGroup.key).length >= targetGroup.maxCount)
|
|
190
|
+
}
|
|
191
|
+
function validateFiles(files: File[], groupKey?: string, stagedExisting = stagedFiles.value): boolean {
|
|
192
|
+
visibleError.value = ''
|
|
193
|
+
if (props.maxCount != null && fileList.value.length + stagedExisting.length + files.length > props.maxCount) {
|
|
194
|
+
const message = `附件数量超出限制,最多允许 ${props.maxCount} 个文件`
|
|
195
|
+
warnUi(message); emit('exceed', { type: 'count', message, groupKey }); return false
|
|
196
|
+
}
|
|
197
|
+
const group = activeGroups.value.find(item => item.key === groupKey)
|
|
198
|
+
if (group?.maxCount != null) {
|
|
199
|
+
const stagedInGroup = stagedExisting.filter(file => file.groupKey === group.key).length
|
|
200
|
+
if (getGroupFiles(group.key).length + stagedInGroup + files.length > group.maxCount) {
|
|
201
|
+
const message = `分组「${group.label}」附件数量超出限制,最多允许 ${group.maxCount} 个文件`
|
|
202
|
+
warnUi(message); emit('exceed', { type: 'count', message, groupKey }); return false
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (props.maxSize != null) {
|
|
206
|
+
const maxBytes = props.maxSize * 1024 * 1024
|
|
207
|
+
const invalid = files.find(file => file.size > maxBytes)
|
|
208
|
+
if (invalid) {
|
|
209
|
+
const message = `文件「${invalid.name}」超出大小限制,最大允许 ${props.maxSize}MB`
|
|
210
|
+
emit('exceed', { type: 'size', message, groupKey }); emitError(message); return false
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return true
|
|
214
|
+
}
|
|
215
|
+
function normalizeFiles(files: File[], groupKey?: string): UploadFileItem[] {
|
|
216
|
+
const normalizedGroupKey = groupKey === UNGROUPED_KEY || !groupKey ? undefined : groupKey
|
|
217
|
+
return files.map(file => ({
|
|
218
|
+
id: `${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
219
|
+
name: file.name,
|
|
220
|
+
size: file.size,
|
|
221
|
+
type: inferTypeByNameAndType(file.name, file.type),
|
|
222
|
+
category: inferCategoryByNameAndType(file.name, file.type),
|
|
223
|
+
groupKey: normalizedGroupKey,
|
|
224
|
+
uploadedAt: formatNow(),
|
|
225
|
+
status: 'done',
|
|
226
|
+
progress: 100,
|
|
227
|
+
raw: file
|
|
228
|
+
}))
|
|
229
|
+
}
|
|
230
|
+
function openUploadModal() {
|
|
231
|
+
if (props.disabled) return
|
|
232
|
+
visibleError.value = ''
|
|
233
|
+
stagedDefaultGroupKey.value = uploadTargetKey.value || ''
|
|
234
|
+
stagedFiles.value = []
|
|
235
|
+
uploadModalOpen.value = true
|
|
236
|
+
}
|
|
237
|
+
function cancelUploadModal() {
|
|
238
|
+
stagedFiles.value = []
|
|
239
|
+
uploadModalOpen.value = false
|
|
240
|
+
if (inputRef.value) inputRef.value.value = ''
|
|
241
|
+
}
|
|
242
|
+
function triggerFileInput() {
|
|
243
|
+
if (isUploadDisabled()) return
|
|
244
|
+
if (inputRef.value) inputRef.value.accept = getUploadAccept()
|
|
245
|
+
inputRef.value?.click()
|
|
246
|
+
}
|
|
247
|
+
function handleInputChange(event: Event) {
|
|
248
|
+
try {
|
|
249
|
+
const input = event.target as HTMLInputElement
|
|
250
|
+
const files = input.files ? Array.from(input.files) : []
|
|
251
|
+
if (!files.length) return
|
|
252
|
+
const selected = props.multiple ? files : files.slice(0, 1)
|
|
253
|
+
const targetKey = stagedDefaultGroupKey.value || undefined
|
|
254
|
+
if (!validateFiles(selected, targetKey)) return
|
|
255
|
+
stagedFiles.value = [...stagedFiles.value, ...normalizeFiles(selected, targetKey)]
|
|
256
|
+
input.value = ''
|
|
257
|
+
} catch (error) { emitError('读取附件失败,请重新选择文件', error as Error) }
|
|
258
|
+
}
|
|
259
|
+
function updateStagedDefaultGroupKey(key: string) {
|
|
260
|
+
stagedDefaultGroupKey.value = key
|
|
261
|
+
localUploadTargetGroupKey.value = key
|
|
262
|
+
emit('update:uploadTargetGroupKey', key)
|
|
263
|
+
}
|
|
264
|
+
function updateStagedFileGroup(index: number, key: string) {
|
|
265
|
+
stagedFiles.value = stagedFiles.value.map((file, currentIndex) => currentIndex === index ? { ...file, groupKey: key === UNGROUPED_KEY || !key ? undefined : key } : file)
|
|
266
|
+
}
|
|
267
|
+
function removeStagedFile(index: number) {
|
|
268
|
+
stagedFiles.value = stagedFiles.value.filter((_, currentIndex) => currentIndex !== index)
|
|
269
|
+
}
|
|
270
|
+
function confirmUpload() {
|
|
271
|
+
if (props.disabled || !stagedFiles.value.length) return
|
|
272
|
+
const updated = [...fileList.value, ...stagedFiles.value]
|
|
273
|
+
emit('update:modelValue', updated); emit('change', updated)
|
|
274
|
+
stagedFiles.value = []
|
|
275
|
+
uploadModalOpen.value = false
|
|
276
|
+
}
|
|
277
|
+
function handleRemove(file: UploadFileItem, index: number) {
|
|
278
|
+
if (props.disabled) return
|
|
279
|
+
const updated = fileList.value.filter((_, currentIndex) => currentIndex !== index)
|
|
280
|
+
emit('update:modelValue', updated); emit('change', updated); emit('remove', { file, index, groupKey: file.groupKey })
|
|
281
|
+
openMoreFileId.value = null
|
|
282
|
+
}
|
|
283
|
+
function handlePreview(file: UploadFileItem, index: number) {
|
|
284
|
+
try { emit('preview', { file, index, groupKey: file.groupKey }); if (file.url) window.open(file.url, '_blank') }
|
|
285
|
+
catch (error) { emitError(`预览「${file.name}」失败`, error as Error) }
|
|
286
|
+
}
|
|
287
|
+
function handleDownload(file: UploadFileItem, index: number) {
|
|
288
|
+
try {
|
|
289
|
+
emit('download', { file, index, groupKey: file.groupKey })
|
|
290
|
+
if (!file.url) return
|
|
291
|
+
const a = document.createElement('a'); a.href = file.url; a.download = file.name; a.click()
|
|
292
|
+
} catch (error) { emitError(`下载「${file.name}」失败`, error as Error) }
|
|
293
|
+
}
|
|
294
|
+
function fileIdentity(file: UploadFileItem, index: number) { return file.id ?? `${file.name}-${index}` }
|
|
295
|
+
function toggleMore(file: UploadFileItem, index: number) {
|
|
296
|
+
const id = fileIdentity(file, index)
|
|
297
|
+
openMoreFileId.value = openMoreFileId.value === id ? null : id
|
|
298
|
+
}
|
|
299
|
+
function isMoreOpen(file: UploadFileItem, index: number) { return openMoreFileId.value === fileIdentity(file, index) }
|
|
300
|
+
|
|
301
|
+
function openGroupModal() {
|
|
302
|
+
groupModalOpen.value = true
|
|
303
|
+
groupFormError.value = ''
|
|
304
|
+
groupDraftNotice.value = ''
|
|
305
|
+
if (!groupFormKey.value) resetGroupDraft('add')
|
|
306
|
+
}
|
|
307
|
+
function closeGroupModal() { groupModalOpen.value = false }
|
|
308
|
+
function resetGroupDraft(mode: 'add' | 'edit' = 'add', group?: UploadGroup) {
|
|
309
|
+
groupDraftMode.value = mode
|
|
310
|
+
editingGroupKey.value = mode === 'edit' ? group?.key ?? null : null
|
|
311
|
+
groupFormKey.value = group?.key ?? ''
|
|
312
|
+
groupFormLabel.value = group?.label ?? (mode === 'add' ? props.defaultGroupLabel : '')
|
|
313
|
+
groupFormDescription.value = group?.description ?? ''
|
|
314
|
+
groupFormAccept.value = group?.accept ?? ''
|
|
315
|
+
groupFormMaxCount.value = group?.maxCount != null ? String(group.maxCount) : ''
|
|
316
|
+
groupFormError.value = ''
|
|
317
|
+
groupDraftNotice.value = ''
|
|
318
|
+
}
|
|
319
|
+
function editGroupDraft(group: UploadGroup) { resetGroupDraft('edit', group) }
|
|
320
|
+
function buildGroupDraft(): { mode: 'add' | 'edit'; group: UploadGroup; oldGroup?: UploadGroup } | null {
|
|
321
|
+
groupFormError.value = ''
|
|
322
|
+
if (!groupFormKey.value.trim()) { groupFormError.value = '分组标识不能为空'; return null }
|
|
323
|
+
if (!groupFormLabel.value.trim()) { groupFormError.value = '分组名称不能为空'; return null }
|
|
324
|
+
const maxCount = groupFormMaxCount.value.trim() ? Number(groupFormMaxCount.value) : undefined
|
|
325
|
+
if (maxCount != null && (!Number.isFinite(maxCount) || maxCount < 1)) { groupFormError.value = '最大数量必须是大于 0 的数字'; return null }
|
|
326
|
+
const group: UploadGroup = {
|
|
327
|
+
key: groupFormKey.value.trim(),
|
|
328
|
+
label: groupFormLabel.value.trim(),
|
|
329
|
+
description: groupFormDescription.value.trim() || undefined,
|
|
330
|
+
accept: groupFormAccept.value.trim() || undefined,
|
|
331
|
+
maxCount
|
|
332
|
+
}
|
|
333
|
+
const oldGroup = groupDraftMode.value === 'edit' ? activeGroups.value.find(g => g.key === editingGroupKey.value) : undefined
|
|
334
|
+
return { mode: groupDraftMode.value, group, oldGroup }
|
|
335
|
+
}
|
|
336
|
+
function saveGroupDraft() {
|
|
337
|
+
const draft = buildGroupDraft()
|
|
338
|
+
if (!draft) return false
|
|
339
|
+
savedGroupDrafts.value = [...savedGroupDrafts.value, draft]
|
|
340
|
+
groupDraftNotice.value = `已保存草稿:${draft.group.label}`
|
|
341
|
+
return true
|
|
342
|
+
}
|
|
343
|
+
function emitPendingChanges(changes: UploadGroupChange[]) {
|
|
344
|
+
localPendingGroupChanges.value = changes
|
|
345
|
+
emit('update:pendingGroupChanges', changes)
|
|
346
|
+
}
|
|
347
|
+
function createGroupChange(type: 'add' | 'edit', group: UploadGroup, oldGroup?: UploadGroup): UploadGroupChange {
|
|
348
|
+
return {
|
|
349
|
+
id: `${type}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
350
|
+
type,
|
|
351
|
+
group,
|
|
352
|
+
oldGroup,
|
|
353
|
+
status: 'pending',
|
|
354
|
+
applicant: props.currentUser ?? '当前用户',
|
|
355
|
+
appliedAt: formatNow()
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
function applyDraftDirectly(draft: { mode: 'add' | 'edit'; group: UploadGroup; oldGroup?: UploadGroup }) {
|
|
359
|
+
if (draft.mode === 'edit') {
|
|
360
|
+
emit('group-edit', { oldKey: draft.oldGroup?.key ?? draft.group.key, group: draft.group })
|
|
361
|
+
const updatedGroups = [...activeGroups.value]
|
|
362
|
+
const idx = updatedGroups.findIndex(g => g.key === (draft.oldGroup?.key ?? draft.group.key))
|
|
363
|
+
if (idx >= 0) updatedGroups[idx] = { ...updatedGroups[idx], ...draft.group }
|
|
364
|
+
else updatedGroups.push(draft.group)
|
|
365
|
+
internalGroups.value = updatedGroups; emit('update:groups', updatedGroups)
|
|
366
|
+
return
|
|
367
|
+
}
|
|
368
|
+
emit('group-add', draft.group)
|
|
369
|
+
const updatedGroups = [...activeGroups.value, draft.group]
|
|
370
|
+
internalGroups.value = updatedGroups; emit('update:groups', updatedGroups)
|
|
371
|
+
}
|
|
372
|
+
function submitGroupDraft(draft: { mode: 'add' | 'edit'; group: UploadGroup; oldGroup?: UploadGroup }) {
|
|
373
|
+
if (effectiveGroupApproval.value) {
|
|
374
|
+
const change = createGroupChange(draft.mode, draft.group, draft.oldGroup)
|
|
375
|
+
if (draft.mode === 'add') emit('group-add', draft.group)
|
|
376
|
+
else emit('group-edit', { oldKey: draft.oldGroup?.key ?? draft.group.key, group: draft.group })
|
|
377
|
+
emitPendingChanges([...localPendingGroupChanges.value, change]); emit('group-change-submit', change)
|
|
378
|
+
} else {
|
|
379
|
+
applyDraftDirectly(draft)
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function submitCurrentGroupDraft() {
|
|
383
|
+
const drafts = [...savedGroupDrafts.value]
|
|
384
|
+
const current = buildGroupDraft()
|
|
385
|
+
if (current) drafts.push(current)
|
|
386
|
+
if (!drafts.length) return
|
|
387
|
+
drafts.forEach(submitGroupDraft)
|
|
388
|
+
savedGroupDrafts.value = []
|
|
389
|
+
groupDraftNotice.value = effectiveGroupApproval.value ? '已提交审批,审批通过后生效' : '分组已更新'
|
|
390
|
+
}
|
|
391
|
+
function addAnotherGroupDraft() {
|
|
392
|
+
const draft = buildGroupDraft()
|
|
393
|
+
if (!draft) return
|
|
394
|
+
submitGroupDraft(draft)
|
|
395
|
+
resetGroupDraft('add')
|
|
396
|
+
groupFormLabel.value = ''
|
|
397
|
+
groupDraftNotice.value = '已生成待审批变更,可继续新增'
|
|
398
|
+
}
|
|
399
|
+
function removeGroup(groupKey: string) {
|
|
400
|
+
deleteGroupError.value = ''
|
|
401
|
+
const groupFiles = getGroupFiles(groupKey)
|
|
402
|
+
if (groupFiles.length > 0) {
|
|
403
|
+
const group = activeGroups.value.find(g => g.key === groupKey)
|
|
404
|
+
deleteGroupError.value = `分组「${group?.label ?? groupKey}」内有 ${groupFiles.length} 个文件,无法删除`
|
|
405
|
+
console.warn('[TfUpload]', deleteGroupError.value); return
|
|
406
|
+
}
|
|
407
|
+
emit('group-remove', groupKey)
|
|
408
|
+
internalGroups.value = activeGroups.value.filter(g => g.key !== groupKey)
|
|
409
|
+
emit('update:groups', internalGroups.value)
|
|
410
|
+
}
|
|
411
|
+
function applyGroupChangeToGroups(change: UploadGroupChange): UploadGroup[] {
|
|
412
|
+
if (change.type === 'add') return [...activeGroups.value, change.group]
|
|
413
|
+
const oldKey = change.oldGroup?.key ?? change.group.key
|
|
414
|
+
const updatedGroups = [...activeGroups.value]
|
|
415
|
+
const idx = updatedGroups.findIndex(g => g.key === oldKey)
|
|
416
|
+
if (idx >= 0) updatedGroups[idx] = { ...updatedGroups[idx], ...change.group }
|
|
417
|
+
else updatedGroups.push(change.group)
|
|
418
|
+
if (oldKey !== change.group.key) {
|
|
419
|
+
const updatedFiles = fileList.value.map(f => f.groupKey === oldKey ? { ...f, groupKey: change.group.key } : f)
|
|
420
|
+
emit('update:modelValue', updatedFiles); emit('change', updatedFiles)
|
|
421
|
+
}
|
|
422
|
+
return updatedGroups
|
|
423
|
+
}
|
|
424
|
+
function approveGroupChange(change: UploadGroupChange) {
|
|
425
|
+
const approved: UploadGroupChange = { ...change, status: 'approved', approver: props.currentUser ?? '当前用户', approvedAt: formatNow() }
|
|
426
|
+
const updatedGroups = applyGroupChangeToGroups(approved)
|
|
427
|
+
internalGroups.value = updatedGroups; emit('update:groups', updatedGroups)
|
|
428
|
+
completedGroupChanges.value = [approved, ...completedGroupChanges.value]
|
|
429
|
+
emitPendingChanges(localPendingGroupChanges.value.filter(item => item.id !== change.id))
|
|
430
|
+
emit('group-change-approve', approved)
|
|
431
|
+
}
|
|
432
|
+
function rejectGroupChange(change: UploadGroupChange) {
|
|
433
|
+
const rejected: UploadGroupChange = { ...change, status: 'rejected', approver: props.currentUser ?? '当前用户', approvedAt: formatNow() }
|
|
434
|
+
completedGroupChanges.value = [rejected, ...completedGroupChanges.value]
|
|
435
|
+
emitPendingChanges(localPendingGroupChanges.value.filter(item => item.id !== change.id))
|
|
436
|
+
emit('group-change-reject', rejected)
|
|
437
|
+
}
|
|
438
|
+
function moveFileToGroup(file: UploadFileItem, toGroupKey: string) {
|
|
439
|
+
const fromGroupKey = file.groupKey
|
|
440
|
+
const updatedFiles = fileList.value.map(f => f.id === file.id ? { ...f, groupKey: toGroupKey === UNGROUPED_KEY ? undefined : toGroupKey } : f)
|
|
441
|
+
emit('update:modelValue', updatedFiles); emit('change', updatedFiles); emit('move', { file, fromGroupKey, toGroupKey })
|
|
442
|
+
openMoreFileId.value = null
|
|
443
|
+
}
|
|
444
|
+
function createApprovalRecord(action: UploadApprovalRecord['action'], comment?: string): UploadApprovalRecord {
|
|
445
|
+
return { id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, action, operator: props.currentUser ?? '当前用户', operatedAt: formatNow(), comment }
|
|
446
|
+
}
|
|
447
|
+
function updateFileAndEmit(file: UploadFileItem, updates: Partial<UploadFileItem>) {
|
|
448
|
+
const updatedFiles = fileList.value.map(f => f.id === file.id ? { ...f, ...updates } : f)
|
|
449
|
+
emit('update:modelValue', updatedFiles); emit('change', updatedFiles)
|
|
450
|
+
}
|
|
451
|
+
function getApprovalComment(file: UploadFileItem): string { return approvalComments[file.id ?? file.name] ?? '' }
|
|
452
|
+
function setApprovalComment(file: UploadFileItem, comment: string) { approvalComments[file.id ?? file.name] = comment }
|
|
453
|
+
function handleApprovalSubmit(file: UploadFileItem) {
|
|
454
|
+
const record = createApprovalRecord('submit')
|
|
455
|
+
updateFileAndEmit(file, { approvalStatus: 'pending', approvalHistory: [...(file.approvalHistory ?? []), record] })
|
|
456
|
+
emit('approval-submit', { ...file, approvalStatus: 'pending' })
|
|
457
|
+
openMoreFileId.value = null
|
|
458
|
+
}
|
|
459
|
+
function handleApprovalApprove(file: UploadFileItem) {
|
|
460
|
+
const comment = getApprovalComment(file) || undefined
|
|
461
|
+
const record = createApprovalRecord('approve', comment)
|
|
462
|
+
updateFileAndEmit(file, { approvalStatus: 'approved', approver: props.currentUser ?? '当前用户', approvedAt: formatNow(), approvalComment: comment, approvalHistory: [...(file.approvalHistory ?? []), record] })
|
|
463
|
+
emit('approval-approve', { file, comment }); if (file.id) approvalComments[file.id] = ''
|
|
464
|
+
openMoreFileId.value = null
|
|
465
|
+
}
|
|
466
|
+
function handleApprovalReject(file: UploadFileItem) {
|
|
467
|
+
const comment = getApprovalComment(file) || undefined
|
|
468
|
+
const record = createApprovalRecord('reject', comment)
|
|
469
|
+
updateFileAndEmit(file, { approvalStatus: 'rejected', approvalComment: comment, approvalHistory: [...(file.approvalHistory ?? []), record] })
|
|
470
|
+
emit('approval-reject', { file, comment }); if (file.id) approvalComments[file.id] = ''
|
|
471
|
+
openMoreFileId.value = null
|
|
472
|
+
}
|
|
473
|
+
function handleApprovalSupplement(file: UploadFileItem) {
|
|
474
|
+
const comment = getApprovalComment(file) || undefined
|
|
475
|
+
const record = createApprovalRecord('request_supplement', comment)
|
|
476
|
+
updateFileAndEmit(file, { approvalStatus: 'supplement_required', approvalComment: comment, approvalHistory: [...(file.approvalHistory ?? []), record] })
|
|
477
|
+
emit('approval-supplement', { file, comment }); if (file.id) approvalComments[file.id] = ''
|
|
478
|
+
openMoreFileId.value = null
|
|
479
|
+
}
|
|
480
|
+
function formatApprovalActionLabel(action: UploadApprovalRecord['action']): string {
|
|
481
|
+
return ({ submit: '提交审批', approve: '通过', reject: '驳回', request_supplement: '要求补充' } as Record<UploadApprovalRecord['action'], string>)[action]
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// ============== AI 状态机集成 ==============
|
|
485
|
+
const aiEnabled = computed(() => !!props.ai)
|
|
486
|
+
const preset = computed(() => props.ai?.preset ?? 'complete')
|
|
487
|
+
|
|
488
|
+
const defaultLabels = computed(() => {
|
|
489
|
+
switch (preset.value) {
|
|
490
|
+
case 'check':
|
|
491
|
+
return { trigger: 'AI 质量检测', retry: '重新检测', confirm: '✓ 确认结果' }
|
|
492
|
+
case 'validate':
|
|
493
|
+
return { trigger: 'AI 校验附件', retry: '重新校验', confirm: '✓ 确认结果' }
|
|
494
|
+
case 'complete':
|
|
495
|
+
default:
|
|
496
|
+
return { trigger: 'AI 分类建议', retry: '重新建议', confirm: '✓ 应用' }
|
|
497
|
+
}
|
|
498
|
+
})
|
|
499
|
+
|
|
500
|
+
const triggerLabel = computed(() => props.ai?.triggerLabel ?? defaultLabels.value.trigger)
|
|
501
|
+
const retryLabel = computed(() => props.ai?.retryLabel ?? defaultLabels.value.retry)
|
|
502
|
+
const confirmLabel = computed(() => props.ai?.confirmLabel ?? defaultLabels.value.confirm)
|
|
503
|
+
|
|
504
|
+
const ai = useAiStateMachine({
|
|
505
|
+
needConfirm: props.ai?.needConfirm ?? true,
|
|
506
|
+
errorRate: props.ai?.errorRate ?? 0,
|
|
507
|
+
runningDuration: props.ai?.runningDuration ?? 1500,
|
|
508
|
+
autoReset: props.ai?.autoReset ?? 0
|
|
509
|
+
})
|
|
510
|
+
|
|
511
|
+
const aiStateLabels: Record<AiState, string> = {
|
|
512
|
+
idle: '空闲', running: 'AI 处理中', confirming: '⚠ 等待确认', done: '✓ 已完成', error: '✗ 失败'
|
|
513
|
+
}
|
|
514
|
+
const aiStateClasses: Record<AiState, string> = {
|
|
515
|
+
idle: 'tf-form-ai-state--idle', running: 'bg-[var(--info-50)] text-[var(--info-600)] animate-pulse',
|
|
516
|
+
confirming: 'bg-[var(--warning-50)] text-[var(--warning-700)]', done: 'bg-[var(--success-50)] text-[var(--success-700)]', error: 'bg-[var(--error-50)] text-[var(--error-600)]'
|
|
517
|
+
}
|
|
518
|
+
const aiStateLabel = computed(() => aiStateLabels[ai.state.value])
|
|
519
|
+
const aiStateClass = computed(() => aiStateClasses[ai.state.value])
|
|
520
|
+
|
|
521
|
+
const currentTriggerLabel = computed(() => {
|
|
522
|
+
const s = ai.state.value
|
|
523
|
+
if (s === 'error') return retryLabel.value
|
|
524
|
+
if (s === 'done') return retryLabel.value
|
|
525
|
+
return triggerLabel.value
|
|
526
|
+
})
|
|
527
|
+
|
|
528
|
+
const defaultApply = (result: any, current: UploadFileItem[]): UploadFileItem[] => {
|
|
529
|
+
if (result == null) return current
|
|
530
|
+
if (Array.isArray(result)) return result
|
|
531
|
+
if (typeof result.files === 'object' && Array.isArray(result.files)) return result.files
|
|
532
|
+
return current
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const applyAndConfirm = () => {
|
|
536
|
+
const result = ai.result.value
|
|
537
|
+
const applyFn = props.ai?.applyResult ?? defaultApply
|
|
538
|
+
const next = applyFn(result, fileList.value)
|
|
539
|
+
if (next !== fileList.value) {
|
|
540
|
+
emit('update:modelValue', next)
|
|
541
|
+
emit('change', next)
|
|
542
|
+
}
|
|
543
|
+
ai.confirm()
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
const handleAiTrigger = () => {
|
|
547
|
+
if (typeof props.ai?.onTrigger === 'function') {
|
|
548
|
+
ai.trigger(() => props.ai!.onTrigger(fileList.value))
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
let aiWatchTimer: ReturnType<typeof setTimeout> | null = null
|
|
553
|
+
const clearAiWatchTimer = () => {
|
|
554
|
+
if (aiWatchTimer) { clearTimeout(aiWatchTimer); aiWatchTimer = null }
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
watch(
|
|
558
|
+
() => [aiEnabled.value, props.ai?.mode, fileList.value] as const,
|
|
559
|
+
([enabled, mode]) => {
|
|
560
|
+
if (!enabled || mode !== 'watch') return
|
|
561
|
+
if (ai.busy.value) return
|
|
562
|
+
clearAiWatchTimer()
|
|
563
|
+
aiWatchTimer = setTimeout(() => { handleAiTrigger() }, 600)
|
|
564
|
+
}
|
|
565
|
+
)
|
|
566
|
+
|
|
567
|
+
watch(
|
|
568
|
+
() => ai.state.value,
|
|
569
|
+
(s) => {
|
|
570
|
+
if (!aiEnabled.value) return
|
|
571
|
+
emit('ai-state-change', s, ai.result.value, ai.error.value)
|
|
572
|
+
}
|
|
573
|
+
)
|
|
574
|
+
|
|
575
|
+
onUnmounted(() => { clearAiWatchTimer() })
|
|
576
|
+
</script>
|
|
577
|
+
|
|
578
|
+
<template>
|
|
579
|
+
<div class="tf-upload tf-upload-card tf-form-control">
|
|
580
|
+
<div class="tf-upload__card-header">
|
|
581
|
+
<div class="tf-upload__card-title-area">
|
|
582
|
+
<h3 class="tf-upload__card-title">{{ cardTitle }}</h3>
|
|
583
|
+
<p v-if="cardDescription" class="tf-upload__card-desc">{{ cardDescription }}</p>
|
|
584
|
+
<div v-if="showSummary" class="tf-upload__summary" aria-label="附件汇总">
|
|
585
|
+
<span class="tf-upload__summary-item">共 {{ fileList.length }} 个附件</span>
|
|
586
|
+
<span class="tf-upload__summary-item">待审批 {{ pendingTotalCount }} 项</span>
|
|
587
|
+
<span class="tf-upload__summary-item" :class="{ 'tf-upload__summary-item--danger': errorFileCount > 0 }">异常 {{ errorFileCount }} 项</span>
|
|
588
|
+
</div>
|
|
589
|
+
</div>
|
|
590
|
+
<div class="tf-upload__header-actions" aria-label="表单附件统一操作区">
|
|
591
|
+
<button type="button" class="tf-upload__button tf-upload__button--primary tf-upload__global-upload" :disabled="isUploadDisabled()" @click="openUploadModal">
|
|
592
|
+
{{ buttonText }}
|
|
593
|
+
</button>
|
|
594
|
+
<button type="button" class="tf-upload__button tf-upload__manage-groups" :disabled="disabled" @click="openGroupModal">管理分组</button>
|
|
595
|
+
<button type="button" class="tf-upload__button tf-upload__approval-entry" @click="approvalDrawerOpen = true">
|
|
596
|
+
审批记录 <span class="tf-upload__badge">{{ pendingTotalCount }}</span>
|
|
597
|
+
</button>
|
|
598
|
+
</div>
|
|
599
|
+
<!-- AI 状态栏 -->
|
|
600
|
+
<div
|
|
601
|
+
v-if="aiEnabled"
|
|
602
|
+
class="tf-upload__ai-bar flex items-center gap-2 mt-1.5 text-[10px] h-5 w-full"
|
|
603
|
+
>
|
|
604
|
+
<span class="flex items-center gap-2 min-w-0 flex-1 h-5">
|
|
605
|
+
<span :class="cn('px-2 py-0.5 rounded-full font-medium whitespace-nowrap shrink-0 inline-flex items-center leading-none h-5', aiStateClass)">
|
|
606
|
+
{{ aiStateLabel }}
|
|
607
|
+
</span>
|
|
608
|
+
<span v-if="ai.state.value === 'error' && ai.error.value" class="text-[var(--tf-color-error)] truncate min-w-0" :title="ai.error.value">
|
|
609
|
+
{{ ai.error.value }}
|
|
610
|
+
</span>
|
|
611
|
+
</span>
|
|
612
|
+
<span class="flex items-center gap-1.5 shrink-0 h-5">
|
|
613
|
+
<button
|
|
614
|
+
v-if="ai.state.value === 'idle' || ai.state.value === 'error' || ai.state.value === 'done'"
|
|
615
|
+
type="button"
|
|
616
|
+
:disabled="disabled"
|
|
617
|
+
class="px-2 py-0.5 rounded tf-form-ai-action--primary disabled:opacity-50 disabled:cursor-not-allowed transition inline-flex items-center leading-none h-5"
|
|
618
|
+
@click="handleAiTrigger"
|
|
619
|
+
>
|
|
620
|
+
{{ currentTriggerLabel }}
|
|
621
|
+
</button>
|
|
622
|
+
<button
|
|
623
|
+
v-else-if="ai.state.value === 'confirming'"
|
|
624
|
+
type="button"
|
|
625
|
+
:disabled="disabled"
|
|
626
|
+
class="px-2 py-0.5 rounded tf-form-ai-action--success disabled:opacity-50 disabled:cursor-not-allowed transition inline-flex items-center leading-none h-5"
|
|
627
|
+
@click="applyAndConfirm"
|
|
628
|
+
>
|
|
629
|
+
{{ confirmLabel }}
|
|
630
|
+
</button>
|
|
631
|
+
<button
|
|
632
|
+
v-else-if="ai.state.value === 'running'"
|
|
633
|
+
type="button"
|
|
634
|
+
:disabled="disabled"
|
|
635
|
+
class="px-2 py-0.5 rounded tf-form-ai-action--neutral disabled:opacity-50 disabled:cursor-not-allowed transition inline-flex items-center leading-none h-5"
|
|
636
|
+
@click="ai.reset()"
|
|
637
|
+
>
|
|
638
|
+
取消
|
|
639
|
+
</button>
|
|
640
|
+
</span>
|
|
641
|
+
</div>
|
|
642
|
+
</div>
|
|
643
|
+
|
|
644
|
+
<div class="tf-upload__card-body">
|
|
645
|
+
<template v-if="hasGroups">
|
|
646
|
+
<div class="tf-upload__groups">
|
|
647
|
+
<section v-for="group in displayGroups" :key="group.key" class="tf-upload__group">
|
|
648
|
+
<div class="tf-upload__group-head">
|
|
649
|
+
<div class="tf-upload__group-head-left">
|
|
650
|
+
<div class="tf-upload__group-title"><span>{{ group.label }}</span><span class="tf-upload__count">{{ getGroupFiles(group.key).length }} 个</span></div>
|
|
651
|
+
<p v-if="group.description" class="tf-upload__group-desc">{{ group.description }}</p>
|
|
652
|
+
</div>
|
|
653
|
+
</div>
|
|
654
|
+
<div v-if="getGroupFiles(group.key).length" class="tf-upload__list" role="list">
|
|
655
|
+
<div v-for="file in getGroupFiles(group.key)" :key="fileIdentity(file, getGlobalIndex(file))" class="tf-upload__file" role="listitem">
|
|
656
|
+
<slot name="file" :file="file" :index="getGlobalIndex(file)">
|
|
657
|
+
<span class="tf-upload__dot" :style="{ backgroundColor: getDotColor(file) }"></span>
|
|
658
|
+
<div class="tf-upload__file-main">
|
|
659
|
+
<div class="tf-upload__file-row">
|
|
660
|
+
<span class="tf-upload__file-name">{{ file.name }}</span>
|
|
661
|
+
<span class="tf-upload__status" :class="`tf-upload__status--${file.status ?? 'ready'}`">{{ statusLabel(file.status) }}</span>
|
|
662
|
+
<span v-if="approval && file.approvalStatus" class="tf-upload__approval-badge" :style="{ backgroundColor: APPROVAL_STATUS_COLOR[file.approvalStatus] + '20', color: APPROVAL_STATUS_COLOR[file.approvalStatus], borderColor: APPROVAL_STATUS_COLOR[file.approvalStatus] }">{{ APPROVAL_STATUS_LABEL[file.approvalStatus] }}</span>
|
|
663
|
+
</div>
|
|
664
|
+
<div class="tf-upload__meta">
|
|
665
|
+
<span v-if="showFileType" class="tf-upload__type">{{ getTypeLabel(file) }}</span>
|
|
666
|
+
<span>{{ formatFileSize(file.size) }}</span>
|
|
667
|
+
<span v-if="showUploadDate && formatUploadDate(file.uploadedAt)">{{ formatUploadDate(file.uploadedAt) }}</span>
|
|
668
|
+
</div>
|
|
669
|
+
<div v-if="showProgress && file.status === 'uploading'" class="tf-upload__progress"><div class="tf-upload__progress-bar" :style="{ width: `${file.progress ?? 0}%` }"></div></div>
|
|
670
|
+
<p v-if="file.status === 'error' && file.errorMessage" class="tf-upload__file-error">{{ file.errorMessage }}</p>
|
|
671
|
+
<input v-if="approval && file.approvalStatus === 'pending'" class="tf-upload__comment-input tf-upload__comment-input--inline" placeholder="审批意见..." :value="getApprovalComment(file)" @input="setApprovalComment(file, ($event.target as HTMLInputElement).value)" />
|
|
672
|
+
<div v-if="approval && showApprovalHistory && file.approvalHistory && file.approvalHistory.length" class="tf-upload__approval-history">
|
|
673
|
+
<div v-for="record in file.approvalHistory" :key="record.id" class="tf-upload__approval-record"><span class="tf-upload__approval-record-action">{{ formatApprovalActionLabel(record.action) }}</span><span>{{ record.operator }}</span><span>{{ formatUploadDate(record.operatedAt) }}</span><span v-if="record.comment">:{{ record.comment }}</span></div>
|
|
674
|
+
</div>
|
|
675
|
+
</div>
|
|
676
|
+
<div class="tf-upload__actions">
|
|
677
|
+
<button type="button" class="tf-upload__action" :aria-label="`预览 ${file.name}`" @click="handlePreview(file, getGlobalIndex(file))">预览</button>
|
|
678
|
+
<button type="button" class="tf-upload__action" :aria-label="`下载 ${file.name}`" @click="handleDownload(file, getGlobalIndex(file))">下载</button>
|
|
679
|
+
<div class="tf-upload__more-wrap">
|
|
680
|
+
<button type="button" class="tf-upload__action tf-upload__more-button" :aria-label="`更多 ${file.name}`" @click="toggleMore(file, getGlobalIndex(file))">更多</button>
|
|
681
|
+
<div v-if="isMoreOpen(file, getGlobalIndex(file))" class="tf-upload__more-menu">
|
|
682
|
+
<div v-if="allowMoveBetweenGroups" class="tf-upload__more-section">
|
|
683
|
+
<div class="tf-upload__more-title">移动到分组</div>
|
|
684
|
+
<button v-for="g in displayGroups" :key="g.key" type="button" class="tf-upload__more-item" :disabled="g.key === (file.groupKey ?? UNGROUPED_KEY)" @click="moveFileToGroup(file, g.key)">{{ g.label }}</button>
|
|
685
|
+
</div>
|
|
686
|
+
<template v-if="approval">
|
|
687
|
+
<button v-if="file.approvalStatus === undefined || file.approvalStatus === 'draft'" type="button" class="tf-upload__more-item" :aria-label="`提交审批 ${file.name}`" @click="handleApprovalSubmit(file)">提交审批</button>
|
|
688
|
+
<template v-if="file.approvalStatus === 'pending'">
|
|
689
|
+
<button type="button" class="tf-upload__more-item tf-upload__more-item--success" :aria-label="`通过 ${file.name}`" @click="handleApprovalApprove(file)">通过</button>
|
|
690
|
+
<button type="button" class="tf-upload__more-item tf-upload__more-item--danger" :aria-label="`驳回 ${file.name}`" @click="handleApprovalReject(file)">驳回</button>
|
|
691
|
+
<button type="button" class="tf-upload__more-item tf-upload__more-item--warning" :aria-label="`要求补充 ${file.name}`" @click="handleApprovalSupplement(file)">要求补充</button>
|
|
692
|
+
</template>
|
|
693
|
+
<span v-if="file.approvalStatus === 'approved'" class="tf-upload__approval-done">已通过</span>
|
|
694
|
+
<span v-if="file.approvalStatus === 'rejected'" class="tf-upload__approval-done">已驳回</span>
|
|
695
|
+
<span v-if="file.approvalStatus === 'supplement_required'" class="tf-upload__approval-done">需补充</span>
|
|
696
|
+
</template>
|
|
697
|
+
<button type="button" class="tf-upload__more-item tf-upload__more-item--danger" :disabled="disabled" :aria-label="`删除 ${file.name}`" @click="handleRemove(file, getGlobalIndex(file))">删除</button>
|
|
698
|
+
</div>
|
|
699
|
+
</div>
|
|
700
|
+
</div>
|
|
701
|
+
</slot>
|
|
702
|
+
</div>
|
|
703
|
+
</div>
|
|
704
|
+
<p v-else class="tf-upload__empty">暂无附件</p>
|
|
705
|
+
<p v-if="isGroupMaxedOut(group)" class="tf-upload__limit">本组最多上传 {{ group.maxCount }} 个附件</p>
|
|
706
|
+
</section>
|
|
707
|
+
</div>
|
|
708
|
+
</template>
|
|
709
|
+
|
|
710
|
+
<template v-else>
|
|
711
|
+
<section class="tf-upload__group tf-upload__group--plain">
|
|
712
|
+
<div class="tf-upload__group-head">
|
|
713
|
+
<div class="tf-upload__group-head-left">
|
|
714
|
+
<div class="tf-upload__group-title"><span>{{ flatListGroup.label }}</span><span class="tf-upload__count">{{ fileList.length }} 个</span></div>
|
|
715
|
+
<p class="tf-upload__group-desc">{{ flatListGroup.description }}</p>
|
|
716
|
+
</div>
|
|
717
|
+
</div>
|
|
718
|
+
<div v-if="fileList.length" class="tf-upload__list tf-upload__list--plain" role="list" aria-label="附件列表">
|
|
719
|
+
<div v-for="(file, index) in fileList" :key="fileIdentity(file, index)" class="tf-upload__file" role="listitem">
|
|
720
|
+
<slot name="file" :file="file" :index="index">
|
|
721
|
+
<span class="tf-upload__dot" :style="{ backgroundColor: getDotColor(file) }"></span>
|
|
722
|
+
<div class="tf-upload__file-main">
|
|
723
|
+
<div class="tf-upload__file-row">
|
|
724
|
+
<span class="tf-upload__file-name">{{ file.name }}</span>
|
|
725
|
+
<span class="tf-upload__status" :class="`tf-upload__status--${file.status ?? 'ready'}`">{{ statusLabel(file.status) }}</span>
|
|
726
|
+
<span v-if="approval && file.approvalStatus" class="tf-upload__approval-badge" :style="{ backgroundColor: APPROVAL_STATUS_COLOR[file.approvalStatus] + '20', color: APPROVAL_STATUS_COLOR[file.approvalStatus], borderColor: APPROVAL_STATUS_COLOR[file.approvalStatus] }">{{ APPROVAL_STATUS_LABEL[file.approvalStatus] }}</span>
|
|
727
|
+
</div>
|
|
728
|
+
<div class="tf-upload__meta"><span v-if="showFileType" class="tf-upload__type">{{ getTypeLabel(file) }}</span><span>{{ formatFileSize(file.size) }}</span><span v-if="showUploadDate && formatUploadDate(file.uploadedAt)">{{ formatUploadDate(file.uploadedAt) }}</span></div>
|
|
729
|
+
<div v-if="showProgress && file.status === 'uploading'" class="tf-upload__progress"><div class="tf-upload__progress-bar" :style="{ width: `${file.progress ?? 0}%` }"></div></div>
|
|
730
|
+
<p v-if="file.status === 'error' && file.errorMessage" class="tf-upload__file-error">{{ file.errorMessage }}</p>
|
|
731
|
+
<input v-if="approval && file.approvalStatus === 'pending'" class="tf-upload__comment-input tf-upload__comment-input--inline" placeholder="审批意见..." :value="getApprovalComment(file)" @input="setApprovalComment(file, ($event.target as HTMLInputElement).value)" />
|
|
732
|
+
<div v-if="approval && showApprovalHistory && file.approvalHistory && file.approvalHistory.length" class="tf-upload__approval-history">
|
|
733
|
+
<div v-for="record in file.approvalHistory" :key="record.id" class="tf-upload__approval-record"><span class="tf-upload__approval-record-action">{{ formatApprovalActionLabel(record.action) }}</span><span>{{ record.operator }}</span><span>{{ formatUploadDate(record.operatedAt) }}</span><span v-if="record.comment">:{{ record.comment }}</span></div>
|
|
734
|
+
</div>
|
|
735
|
+
</div>
|
|
736
|
+
<div class="tf-upload__actions">
|
|
737
|
+
<button type="button" class="tf-upload__action" :aria-label="`预览 ${file.name}`" @click="handlePreview(file, index)">预览</button>
|
|
738
|
+
<button type="button" class="tf-upload__action" :aria-label="`下载 ${file.name}`" @click="handleDownload(file, index)">下载</button>
|
|
739
|
+
<div class="tf-upload__more-wrap">
|
|
740
|
+
<button type="button" class="tf-upload__action tf-upload__more-button" :aria-label="`更多 ${file.name}`" @click="toggleMore(file, index)">更多</button>
|
|
741
|
+
<div v-if="isMoreOpen(file, index)" class="tf-upload__more-menu">
|
|
742
|
+
<template v-if="approval">
|
|
743
|
+
<button v-if="file.approvalStatus === undefined || file.approvalStatus === 'draft'" type="button" class="tf-upload__more-item" :aria-label="`提交审批 ${file.name}`" @click="handleApprovalSubmit(file)">提交审批</button>
|
|
744
|
+
<template v-if="file.approvalStatus === 'pending'">
|
|
745
|
+
<button type="button" class="tf-upload__more-item tf-upload__more-item--success" :aria-label="`通过 ${file.name}`" @click="handleApprovalApprove(file)">通过</button>
|
|
746
|
+
<button type="button" class="tf-upload__more-item tf-upload__more-item--danger" :aria-label="`驳回 ${file.name}`" @click="handleApprovalReject(file)">驳回</button>
|
|
747
|
+
<button type="button" class="tf-upload__more-item tf-upload__more-item--warning" :aria-label="`要求补充 ${file.name}`" @click="handleApprovalSupplement(file)">要求补充</button>
|
|
748
|
+
</template>
|
|
749
|
+
<span v-if="file.approvalStatus === 'approved'" class="tf-upload__approval-done">已通过</span>
|
|
750
|
+
<span v-if="file.approvalStatus === 'rejected'" class="tf-upload__approval-done">已驳回</span>
|
|
751
|
+
<span v-if="file.approvalStatus === 'supplement_required'" class="tf-upload__approval-done">需补充</span>
|
|
752
|
+
</template>
|
|
753
|
+
<button type="button" class="tf-upload__more-item tf-upload__more-item--danger" :disabled="disabled" :aria-label="`删除 ${file.name}`" @click="handleRemove(file, index)">删除</button>
|
|
754
|
+
</div>
|
|
755
|
+
</div>
|
|
756
|
+
</div>
|
|
757
|
+
</slot>
|
|
758
|
+
</div>
|
|
759
|
+
</div>
|
|
760
|
+
<p v-else class="tf-upload__empty tf-upload__empty--plain">暂无附件</p>
|
|
761
|
+
</section>
|
|
762
|
+
</template>
|
|
763
|
+
</div>
|
|
764
|
+
|
|
765
|
+
<div v-if="visibleError || totalMaxedOut || deleteGroupError" class="tf-upload__card-footer">
|
|
766
|
+
<div v-if="visibleError" class="tf-upload__error" role="alert">{{ visibleError }}</div>
|
|
767
|
+
<div v-if="deleteGroupError" class="tf-upload__error" role="alert">{{ deleteGroupError }}</div>
|
|
768
|
+
<p v-if="totalMaxedOut" class="tf-upload__limit">最多上传 {{ maxCount }} 个附件</p>
|
|
769
|
+
</div>
|
|
770
|
+
|
|
771
|
+
<div v-if="uploadModalOpen" class="tf-upload__overlay" role="dialog" aria-modal="true" aria-label="上传附件 Modal">
|
|
772
|
+
<div class="tf-upload__modal tf-upload__upload-modal">
|
|
773
|
+
<div class="tf-upload__modal-header">
|
|
774
|
+
<div><h4>上传附件</h4><p>先选择文件和归属分组,确认后才写入表单附件。</p></div>
|
|
775
|
+
<button type="button" class="tf-upload__icon-button" aria-label="关闭上传附件" @click="cancelUploadModal">×</button>
|
|
776
|
+
</div>
|
|
777
|
+
<div class="tf-upload__modal-body">
|
|
778
|
+
<div class="tf-upload__picker">
|
|
779
|
+
<button type="button" class="tf-upload__button" :disabled="isUploadDisabled()" @click="triggerFileInput">{{ stagedFiles.length ? '继续添加' : '选择文件' }}</button>
|
|
780
|
+
<span class="tf-upload__picker-tip">{{ stagedFiles.length ? `已暂存 ${stagedFiles.length} 个文件` : '尚未选择文件' }}</span>
|
|
781
|
+
</div>
|
|
782
|
+
<div v-if="stagedFiles.length" class="tf-upload__staged-list">
|
|
783
|
+
<div v-for="(file, index) in stagedFiles" :key="file.id" class="tf-upload__staged-item">
|
|
784
|
+
<span class="tf-upload__dot" :style="{ backgroundColor: getDotColor(file) }"></span>
|
|
785
|
+
<div class="tf-upload__file-main"><strong>{{ file.name }}</strong><div class="tf-upload__meta">{{ formatFileSize(file.size) }} / {{ getTypeLabel(file) }}</div></div>
|
|
786
|
+
<select v-if="hasGroups" class="tf-upload__target-select tf-upload__staged-group" :value="file.groupKey ?? ''" @change="updateStagedFileGroup(index, ($event.target as HTMLSelectElement).value)">
|
|
787
|
+
<option value="">未分组</option>
|
|
788
|
+
<option v-for="group in activeGroups" :key="group.key" :value="group.key" :disabled="group.disabled">{{ group.label }}</option>
|
|
789
|
+
</select>
|
|
790
|
+
<button type="button" class="tf-upload__action tf-upload__action--danger" :aria-label="`移除暂存 ${file.name}`" @click="removeStagedFile(index)">移除</button>
|
|
791
|
+
</div>
|
|
792
|
+
</div>
|
|
793
|
+
<p v-else class="tf-upload__empty">Modal 内选择文件后仅进入暂存列表,不会立即更新 modelValue。</p>
|
|
794
|
+
<div v-if="visibleError" class="tf-upload__error" role="alert">{{ visibleError }}</div>
|
|
795
|
+
</div>
|
|
796
|
+
<div class="tf-upload__modal-footer">
|
|
797
|
+
<button type="button" class="tf-upload__button" @click="cancelUploadModal">取消</button>
|
|
798
|
+
<button type="button" class="tf-upload__button tf-upload__button--primary tf-upload__confirm-upload" :disabled="!stagedFiles.length || disabled" @click="confirmUpload">确认上传</button>
|
|
799
|
+
</div>
|
|
800
|
+
</div>
|
|
801
|
+
</div>
|
|
802
|
+
|
|
803
|
+
<div v-if="groupModalOpen" class="tf-upload__overlay" role="dialog" aria-modal="true" aria-label="管理分组 Modal">
|
|
804
|
+
<div class="tf-upload__modal tf-upload__group-modal">
|
|
805
|
+
<div class="tf-upload__modal-header">
|
|
806
|
+
<div><h4>管理分组</h4><p>新增/编辑分组可先保存草稿;提交审批后按配置生效。</p></div>
|
|
807
|
+
<button type="button" class="tf-upload__icon-button" aria-label="关闭管理分组" @click="closeGroupModal">×</button>
|
|
808
|
+
</div>
|
|
809
|
+
<div class="tf-upload__modal-body tf-upload__group-manager">
|
|
810
|
+
<div class="tf-upload__group-list-panel">
|
|
811
|
+
<div class="tf-upload__panel-title">现有分组</div>
|
|
812
|
+
<button type="button" class="tf-upload__button tf-upload__button--small" @click="resetGroupDraft('add')">新增分组</button>
|
|
813
|
+
<div v-if="activeGroups.length" class="tf-upload__group-list">
|
|
814
|
+
<div v-for="group in activeGroups" :key="group.key" class="tf-upload__group-list-item">
|
|
815
|
+
<div><strong>{{ group.label }}</strong><span>{{ group.key }}</span><p v-if="group.description">{{ group.description }}</p></div>
|
|
816
|
+
<div class="tf-upload__group-list-actions">
|
|
817
|
+
<button type="button" class="tf-upload__action" aria-label="编辑分组" @click="editGroupDraft(group)">编辑</button>
|
|
818
|
+
<button v-if="group.removable !== false" type="button" class="tf-upload__action tf-upload__action--danger" aria-label="删除分组" @click="removeGroup(group.key)">删除</button>
|
|
819
|
+
</div>
|
|
820
|
+
</div>
|
|
821
|
+
</div>
|
|
822
|
+
<p v-else class="tf-upload__empty">暂无分组</p>
|
|
823
|
+
</div>
|
|
824
|
+
<div class="tf-upload__group-form">
|
|
825
|
+
<div class="tf-upload__group-form-title">{{ groupDraftMode === 'edit' ? '编辑分组' : '新增分组' }}{{ effectiveGroupApproval ? '(审批通过后生效)' : '' }}</div>
|
|
826
|
+
<label class="tf-upload__field"><span>标识</span><input class="tf-upload__group-form-input tf-upload__group-key-input" v-model="groupFormKey" placeholder="如:contract" :disabled="groupDraftMode === 'edit'" /></label>
|
|
827
|
+
<label class="tf-upload__field"><span>名称</span><input class="tf-upload__group-form-input tf-upload__group-label-input" v-model="groupFormLabel" placeholder="如:合同附件" /></label>
|
|
828
|
+
<label class="tf-upload__field"><span>说明</span><input class="tf-upload__group-form-input tf-upload__group-description-input" v-model="groupFormDescription" placeholder="可选" /></label>
|
|
829
|
+
<label class="tf-upload__field"><span>允许类型</span><input class="tf-upload__group-form-input tf-upload__group-accept-input" v-model="groupFormAccept" placeholder="如:.pdf,.docx 或 image/*" /></label>
|
|
830
|
+
<label class="tf-upload__field"><span>最大数量</span><input class="tf-upload__group-form-input tf-upload__group-max-count-input" v-model="groupFormMaxCount" placeholder="可选,如:5" /></label>
|
|
831
|
+
<div v-if="groupFormError" class="tf-upload__error" role="alert">{{ groupFormError }}</div>
|
|
832
|
+
<div v-if="deleteGroupError" class="tf-upload__error" role="alert">{{ deleteGroupError }}</div>
|
|
833
|
+
<div v-if="groupDraftNotice" class="tf-upload__notice">{{ groupDraftNotice }}</div>
|
|
834
|
+
<div class="tf-upload__group-form-actions">
|
|
835
|
+
<button type="button" class="tf-upload__button tf-upload__button--small" @click="saveGroupDraft">保存草稿</button>
|
|
836
|
+
<button type="button" class="tf-upload__button tf-upload__button--small tf-upload__add-another" @click="addAnotherGroupDraft">连续新增</button>
|
|
837
|
+
<button type="button" class="tf-upload__button tf-upload__button--small tf-upload__button--primary tf-upload__submit-group-approval" @click="submitCurrentGroupDraft">提交审批</button>
|
|
838
|
+
</div>
|
|
839
|
+
</div>
|
|
840
|
+
</div>
|
|
841
|
+
<div class="tf-upload__modal-footer"><button type="button" class="tf-upload__button" @click="closeGroupModal">关闭</button></div>
|
|
842
|
+
</div>
|
|
843
|
+
</div>
|
|
844
|
+
|
|
845
|
+
<div v-if="approvalDrawerOpen" class="tf-upload__drawer-mask" role="dialog" aria-modal="true" aria-label="审批记录 Drawer">
|
|
846
|
+
<aside class="tf-upload__drawer">
|
|
847
|
+
<div class="tf-upload__drawer-header">
|
|
848
|
+
<div><h4>审批记录</h4><p>查看待审批与已完成的分组变更。</p></div>
|
|
849
|
+
<button type="button" class="tf-upload__icon-button" aria-label="关闭审批记录" @click="approvalDrawerOpen = false">×</button>
|
|
850
|
+
</div>
|
|
851
|
+
<div class="tf-upload__drawer-body">
|
|
852
|
+
<section class="tf-upload__approval-section">
|
|
853
|
+
<h5>待审批</h5>
|
|
854
|
+
<div v-if="pendingGroups.length" class="tf-upload__pending-groups" aria-label="待审批分组变更">
|
|
855
|
+
<div v-for="change in pendingGroups" :key="change.id" class="tf-upload__pending-item">
|
|
856
|
+
<div>
|
|
857
|
+
<span class="tf-upload__pending-type">{{ GROUP_CHANGE_LABEL[change.type] }}</span>
|
|
858
|
+
<strong>{{ change.group.label }}</strong>
|
|
859
|
+
<span class="tf-upload__pending-meta">{{ change.group.key }} / {{ change.applicant || '当前用户' }} / {{ formatUploadDate(change.appliedAt) }}</span>
|
|
860
|
+
<p v-if="change.comment" class="tf-upload__pending-desc">{{ change.comment }}</p>
|
|
861
|
+
<p v-else-if="change.group.description" class="tf-upload__pending-desc">{{ change.group.description }}</p>
|
|
862
|
+
</div>
|
|
863
|
+
<div class="tf-upload__pending-actions">
|
|
864
|
+
<button type="button" class="tf-upload__action tf-upload__action--success" :aria-label="`通过分组变更 ${change.group.label}`" @click="approveGroupChange(change)">通过</button>
|
|
865
|
+
<button type="button" class="tf-upload__action tf-upload__action--danger" :aria-label="`驳回分组变更 ${change.group.label}`" @click="rejectGroupChange(change)">驳回</button>
|
|
866
|
+
</div>
|
|
867
|
+
</div>
|
|
868
|
+
</div>
|
|
869
|
+
<p v-else class="tf-upload__empty">暂无待审批变更</p>
|
|
870
|
+
</section>
|
|
871
|
+
<section class="tf-upload__approval-section">
|
|
872
|
+
<h5>已完成</h5>
|
|
873
|
+
<div v-if="completedGroupChanges.length" class="tf-upload__completed-list">
|
|
874
|
+
<div v-for="change in completedGroupChanges" :key="`${change.id}-${change.status}`" class="tf-upload__completed-item">
|
|
875
|
+
{{ GROUP_CHANGE_LABEL[change.type] }} / {{ change.group.label }} / {{ change.status === 'approved' ? '已通过' : '已驳回' }} / {{ change.approver }} / {{ formatUploadDate(change.approvedAt) }}
|
|
876
|
+
</div>
|
|
877
|
+
</div>
|
|
878
|
+
<p v-else class="tf-upload__empty">暂无已完成记录</p>
|
|
879
|
+
</section>
|
|
880
|
+
</div>
|
|
881
|
+
</aside>
|
|
882
|
+
</div>
|
|
883
|
+
|
|
884
|
+
<input ref="inputRef" type="file" class="tf-upload__input" :accept="getUploadAccept()" :multiple="multiple" :disabled="disabled" @change="handleInputChange" />
|
|
885
|
+
</div>
|
|
886
|
+
</template>
|
|
887
|
+
|
|
888
|
+
<style scoped>
|
|
889
|
+
@import '../styles/upload.css';
|
|
890
|
+
</style>
|