From 69ce11ce8a18854ce60e57d93dc441c36cee8485 Mon Sep 17 00:00:00 2001 From: buqiyuan <1743369777@qq.com> Date: Wed, 6 Mar 2024 23:28:13 +0800 Subject: [PATCH] fix(schema-form): componentProps merge logic close #157 --- .vscode/extensions.json | 2 +- package.json | 6 +- pnpm-lock.yaml | 124 +++++++++--------- src/api/demo/hero.ts | 9 +- src/api/demo/select.ts | 3 +- .../src/components/editable-cell/index.vue | 13 +- .../src/components/table-action.vue | 15 ++- .../core/schema-form/src/hooks/useAdvanced.ts | 7 +- .../schema-form/src/hooks/useFormEvents.ts | 42 +++--- .../core/schema-form/src/schema-form-item.vue | 44 ++++--- .../core/schema-form/src/types/form.ts | 10 +- src/layout/header/index.vue | 1 + src/layout/tabs/tabs-view.vue | 6 +- src/router/helper/routeHelper.tsx | 11 +- src/utils/index.ts | 52 +++++++- src/utils/is.ts | 20 ++- .../demos/form/basic-form/form-schema.tsx | 23 ++-- .../demos/tables/edit-row-table/columns.tsx | 8 +- .../demos/tables/search-table/columns.tsx | 15 ++- src/views/system/dept/formSchemas.ts | 5 +- src/views/system/menu/formSchemas.tsx | 6 +- src/views/system/menu/index.vue | 2 +- 22 files changed, 263 insertions(+), 161 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 63d8f279a..80dd05827 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,13 +1,13 @@ { "recommendations": [ "Vue.volar", - "Vue.vscode-typescript-vue-plugin", "dbaeumer.vscode-eslint", "stylelint.vscode-stylelint", "esbenp.prettier-vscode", "mrmlnc.vscode-less", "lokalise.i18n-ally", "antfu.iconify", + "antfu.unocss", "mikestead.dotenv" ] } diff --git a/package.json b/package.json index 7cee96fbd..36c2e3348 100644 --- a/package.json +++ b/package.json @@ -75,8 +75,8 @@ "@iconify/json": "^2.2.180", "@types/lodash-es": "~4.17.12", "@types/node": "~20.11.16", - "@typescript-eslint/eslint-plugin": "~7.1.0", - "@typescript-eslint/parser": "~7.1.0", + "@typescript-eslint/eslint-plugin": "~7.1.1", + "@typescript-eslint/parser": "~7.1.1", "@umijs/openapi": "^1.10.1", "@vitejs/plugin-vue": "~5.0.4", "@vitejs/plugin-vue-jsx": "~3.1.0", @@ -110,7 +110,7 @@ "stylelint-config-standard": "~36.0.0", "stylelint-order": "~6.0.4", "stylelint-prettier": "^5.0.0", - "terser": "~5.28.1", + "terser": "~5.29.1", "ts-node": "^10.9.2", "typescript": "~5.3.3", "unocss": "^0.58.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6c2ea722e..98bb73dad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -115,11 +115,11 @@ importers: specifier: ~20.11.16 version: 20.11.22 '@typescript-eslint/eslint-plugin': - specifier: ~7.1.0 - version: 7.1.0(@typescript-eslint/parser@7.1.0)(eslint@8.57.0)(typescript@5.3.3) + specifier: ~7.1.1 + version: 7.1.1(@typescript-eslint/parser@7.1.1)(eslint@8.57.0)(typescript@5.3.3) '@typescript-eslint/parser': - specifier: ~7.1.0 - version: 7.1.0(eslint@8.57.0)(typescript@5.3.3) + specifier: ~7.1.1 + version: 7.1.1(eslint@8.57.0)(typescript@5.3.3) '@umijs/openapi': specifier: ^1.10.1 version: 1.10.1 @@ -155,7 +155,7 @@ importers: version: 2.1.0 eslint-plugin-import: specifier: ~2.29.1 - version: 2.29.1(@typescript-eslint/parser@7.1.0)(eslint@8.57.0) + version: 2.29.1(@typescript-eslint/parser@7.1.1)(eslint@8.57.0) eslint-plugin-prettier: specifier: ~5.1.3 version: 5.1.3(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.2.5) @@ -220,8 +220,8 @@ importers: specifier: ^5.0.0 version: 5.0.0(prettier@3.2.5)(stylelint@16.2.1) terser: - specifier: ~5.28.1 - version: 5.28.1 + specifier: ~5.29.1 + version: 5.29.1 ts-node: specifier: ^10.9.2 version: 10.9.2(@types/node@20.11.22)(typescript@5.3.3) @@ -236,7 +236,7 @@ importers: version: 0.26.0(vue@3.4.21) vite: specifier: ~5.1.5 - version: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.28.1) + version: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.29.1) vite-plugin-checker: specifier: ~0.6.4 version: 0.6.4(eslint@8.57.0)(stylelint@16.2.1)(typescript@5.3.3)(vite@5.1.5)(vue-tsc@1.8.27) @@ -264,7 +264,7 @@ importers: devDependencies: vite: specifier: ^5.1.5 - version: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.28.1) + version: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.29.1) packages/vite-plugin-msw: dependencies: @@ -289,7 +289,7 @@ importers: dependencies: vite: specifier: ^5.0.0 - version: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.28.1) + version: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.29.1) packages: @@ -2829,8 +2829,8 @@ packages: - supports-color dev: true - /@typescript-eslint/eslint-plugin@7.1.0(@typescript-eslint/parser@7.1.0)(eslint@8.57.0)(typescript@5.3.3): - resolution: {integrity: sha512-j6vT/kCulhG5wBmGtstKeiVr1rdXE4nk+DT1k6trYkwlrvW9eOF5ZbgKnd/YR6PcM4uTEXa0h6Fcvf6X7Dxl0w==} + /@typescript-eslint/eslint-plugin@7.1.1(@typescript-eslint/parser@7.1.1)(eslint@8.57.0)(typescript@5.3.3): + resolution: {integrity: sha512-zioDz623d0RHNhvx0eesUmGfIjzrk18nSBC8xewepKXbBvN/7c1qImV7Hg8TI1URTxKax7/zxfxj3Uph8Chcuw==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: '@typescript-eslint/parser': ^7.0.0 @@ -2841,11 +2841,11 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 7.1.0(eslint@8.57.0)(typescript@5.3.3) - '@typescript-eslint/scope-manager': 7.1.0 - '@typescript-eslint/type-utils': 7.1.0(eslint@8.57.0)(typescript@5.3.3) - '@typescript-eslint/utils': 7.1.0(eslint@8.57.0)(typescript@5.3.3) - '@typescript-eslint/visitor-keys': 7.1.0 + '@typescript-eslint/parser': 7.1.1(eslint@8.57.0)(typescript@5.3.3) + '@typescript-eslint/scope-manager': 7.1.1 + '@typescript-eslint/type-utils': 7.1.1(eslint@8.57.0)(typescript@5.3.3) + '@typescript-eslint/utils': 7.1.1(eslint@8.57.0)(typescript@5.3.3) + '@typescript-eslint/visitor-keys': 7.1.1 debug: 4.3.4 eslint: 8.57.0 graphemer: 1.4.0 @@ -2896,8 +2896,8 @@ packages: - supports-color dev: true - /@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3): - resolution: {integrity: sha512-V1EknKUubZ1gWFjiOZhDSNToOjs63/9O0puCgGS8aDOgpZY326fzFu15QAUjwaXzRZjf/qdsdBrckYdv9YxB8w==} + /@typescript-eslint/parser@7.1.1(eslint@8.57.0)(typescript@5.3.3): + resolution: {integrity: sha512-ZWUFyL0z04R1nAEgr9e79YtV5LbafdOtN7yapNbn1ansMyaegl2D4bL7vHoJ4HPSc4CaLwuCVas8CVuneKzplQ==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^8.56.0 @@ -2906,10 +2906,10 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 7.1.0 - '@typescript-eslint/types': 7.1.0 - '@typescript-eslint/typescript-estree': 7.1.0(typescript@5.3.3) - '@typescript-eslint/visitor-keys': 7.1.0 + '@typescript-eslint/scope-manager': 7.1.1 + '@typescript-eslint/types': 7.1.1 + '@typescript-eslint/typescript-estree': 7.1.1(typescript@5.3.3) + '@typescript-eslint/visitor-keys': 7.1.1 debug: 4.3.4 eslint: 8.57.0 typescript: 5.3.3 @@ -2933,12 +2933,12 @@ packages: '@typescript-eslint/visitor-keys': 5.62.0 dev: true - /@typescript-eslint/scope-manager@7.1.0: - resolution: {integrity: sha512-6TmN4OJiohHfoOdGZ3huuLhpiUgOGTpgXNUPJgeZOZR3DnIpdSgtt83RS35OYNNXxM4TScVlpVKC9jyQSETR1A==} + /@typescript-eslint/scope-manager@7.1.1: + resolution: {integrity: sha512-cirZpA8bJMRb4WZ+rO6+mnOJrGFDd38WoXCEI57+CYBqta8Yc8aJym2i7vyqLL1vVYljgw0X27axkUXz32T8TA==} engines: {node: ^16.0.0 || >=18.0.0} dependencies: - '@typescript-eslint/types': 7.1.0 - '@typescript-eslint/visitor-keys': 7.1.0 + '@typescript-eslint/types': 7.1.1 + '@typescript-eslint/visitor-keys': 7.1.1 dev: true /@typescript-eslint/type-utils@5.62.0(eslint@7.32.0)(typescript@4.9.5): @@ -2961,8 +2961,8 @@ packages: - supports-color dev: true - /@typescript-eslint/type-utils@7.1.0(eslint@8.57.0)(typescript@5.3.3): - resolution: {integrity: sha512-UZIhv8G+5b5skkcuhgvxYWHjk7FW7/JP5lPASMEUoliAPwIH/rxoUSQPia2cuOj9AmDZmwUl1usKm85t5VUMew==} + /@typescript-eslint/type-utils@7.1.1(eslint@8.57.0)(typescript@5.3.3): + resolution: {integrity: sha512-5r4RKze6XHEEhlZnJtR3GYeCh1IueUHdbrukV2KSlLXaTjuSfeVF8mZUVPLovidCuZfbVjfhi4c0DNSa/Rdg5g==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^8.56.0 @@ -2971,8 +2971,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 7.1.0(typescript@5.3.3) - '@typescript-eslint/utils': 7.1.0(eslint@8.57.0)(typescript@5.3.3) + '@typescript-eslint/typescript-estree': 7.1.1(typescript@5.3.3) + '@typescript-eslint/utils': 7.1.1(eslint@8.57.0)(typescript@5.3.3) debug: 4.3.4 eslint: 8.57.0 ts-api-utils: 1.2.1(typescript@5.3.3) @@ -2991,8 +2991,8 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/types@7.1.0: - resolution: {integrity: sha512-qTWjWieJ1tRJkxgZYXx6WUYtWlBc48YRxgY2JN1aGeVpkhmnopq+SUC8UEVGNXIvWH7XyuTjwALfG6bFEgCkQA==} + /@typescript-eslint/types@7.1.1: + resolution: {integrity: sha512-KhewzrlRMrgeKm1U9bh2z5aoL4s7K3tK5DwHDn8MHv0yQfWFz/0ZR6trrIHHa5CsF83j/GgHqzdbzCXJ3crx0Q==} engines: {node: ^16.0.0 || >=18.0.0} dev: true @@ -3038,8 +3038,8 @@ packages: - supports-color dev: true - /@typescript-eslint/typescript-estree@7.1.0(typescript@5.3.3): - resolution: {integrity: sha512-k7MyrbD6E463CBbSpcOnwa8oXRdHzH1WiVzOipK3L5KSML92ZKgUBrTlehdi7PEIMT8k0bQixHUGXggPAlKnOQ==} + /@typescript-eslint/typescript-estree@7.1.1(typescript@5.3.3): + resolution: {integrity: sha512-9ZOncVSfr+sMXVxxca2OJOPagRwT0u/UHikM2Rd6L/aB+kL/QAuTnsv6MeXtjzCJYb8PzrXarypSGIPx3Jemxw==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: typescript: '*' @@ -3047,8 +3047,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 7.1.0 - '@typescript-eslint/visitor-keys': 7.1.0 + '@typescript-eslint/types': 7.1.1 + '@typescript-eslint/visitor-keys': 7.1.1 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 @@ -3080,8 +3080,8 @@ packages: - typescript dev: true - /@typescript-eslint/utils@7.1.0(eslint@8.57.0)(typescript@5.3.3): - resolution: {integrity: sha512-WUFba6PZC5OCGEmbweGpnNJytJiLG7ZvDBJJoUcX4qZYf1mGZ97mO2Mps6O2efxJcJdRNpqweCistDbZMwIVHw==} + /@typescript-eslint/utils@7.1.1(eslint@8.57.0)(typescript@5.3.3): + resolution: {integrity: sha512-thOXM89xA03xAE0lW7alstvnyoBUbBX38YtY+zAUcpRPcq9EIhXPuJ0YTv948MbzmKh6e1AUszn5cBFK49Umqg==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^8.56.0 @@ -3089,9 +3089,9 @@ packages: '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) '@types/json-schema': 7.0.15 '@types/semver': 7.5.8 - '@typescript-eslint/scope-manager': 7.1.0 - '@typescript-eslint/types': 7.1.0 - '@typescript-eslint/typescript-estree': 7.1.0(typescript@5.3.3) + '@typescript-eslint/scope-manager': 7.1.1 + '@typescript-eslint/types': 7.1.1 + '@typescript-eslint/typescript-estree': 7.1.1(typescript@5.3.3) eslint: 8.57.0 semver: 7.6.0 transitivePeerDependencies: @@ -3115,11 +3115,11 @@ packages: eslint-visitor-keys: 3.4.3 dev: true - /@typescript-eslint/visitor-keys@7.1.0: - resolution: {integrity: sha512-FhUqNWluiGNzlvnDZiXad4mZRhtghdoKW6e98GoEOYSu5cND+E39rG5KwJMUzeENwm1ztYBRqof8wMLP+wNPIA==} + /@typescript-eslint/visitor-keys@7.1.1: + resolution: {integrity: sha512-yTdHDQxY7cSoCcAtiBzVzxleJhkGB9NncSIyMYe2+OGON1ZsP9zOPws/Pqgopa65jvknOjlk/w7ulPlZ78PiLQ==} engines: {node: ^16.0.0 || >=18.0.0} dependencies: - '@typescript-eslint/types': 7.1.0 + '@typescript-eslint/types': 7.1.1 eslint-visitor-keys: 3.4.3 dev: true @@ -3205,7 +3205,7 @@ packages: '@unocss/core': 0.58.5 '@unocss/reset': 0.58.5 '@unocss/vite': 0.58.5(vite@5.1.5) - vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.28.1) + vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.29.1) transitivePeerDependencies: - rollup dev: true @@ -3403,7 +3403,7 @@ packages: chokidar: 3.6.0 fast-glob: 3.3.2 magic-string: 0.30.7 - vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.28.1) + vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.29.1) transitivePeerDependencies: - rollup dev: true @@ -3418,7 +3418,7 @@ packages: '@babel/core': 7.24.0 '@babel/plugin-transform-typescript': 7.23.6(@babel/core@7.24.0) '@vue/babel-plugin-jsx': 1.2.1(@babel/core@7.24.0) - vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.28.1) + vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.29.1) vue: 3.4.21(typescript@5.3.3) transitivePeerDependencies: - supports-color @@ -3431,7 +3431,7 @@ packages: vite: ^5.0.0 vue: ^3.2.25 dependencies: - vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.28.1) + vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.29.1) vue: 3.4.21(typescript@5.3.3) dev: true @@ -5427,7 +5427,7 @@ packages: - supports-color dev: true - /eslint-module-utils@2.8.1(@typescript-eslint/parser@7.1.0)(eslint-import-resolver-node@0.3.9)(eslint@8.57.0): + /eslint-module-utils@2.8.1(@typescript-eslint/parser@7.1.1)(eslint-import-resolver-node@0.3.9)(eslint@8.57.0): resolution: {integrity: sha512-rXDXR3h7cs7dy9RNpUlQf80nX31XWJEyGq1tRMo+6GsO5VmTe4UTwtmonAD4ZkAsrfMVDA2wlGJ3790Ys+D49Q==} engines: {node: '>=4'} peerDependencies: @@ -5448,7 +5448,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 7.1.0(eslint@8.57.0)(typescript@5.3.3) + '@typescript-eslint/parser': 7.1.1(eslint@8.57.0)(typescript@5.3.3) debug: 3.2.7 eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 @@ -5466,7 +5466,7 @@ packages: eslint-rule-composer: 0.3.0 dev: true - /eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.1.0)(eslint@8.57.0): + /eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.1.1)(eslint@8.57.0): resolution: {integrity: sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==} engines: {node: '>=4'} peerDependencies: @@ -5476,7 +5476,7 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 7.1.0(eslint@8.57.0)(typescript@5.3.3) + '@typescript-eslint/parser': 7.1.1(eslint@8.57.0)(typescript@5.3.3) array-includes: 3.1.7 array.prototype.findlastindex: 1.2.4 array.prototype.flat: 1.3.2 @@ -5485,7 +5485,7 @@ packages: doctrine: 2.1.0 eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.1.0)(eslint-import-resolver-node@0.3.9)(eslint@8.57.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.1.1)(eslint-import-resolver-node@0.3.9)(eslint@8.57.0) hasown: 2.0.1 is-core-module: 2.13.1 is-glob: 4.0.3 @@ -10325,8 +10325,8 @@ packages: temp-dir: 3.0.0 dev: true - /terser@5.28.1: - resolution: {integrity: sha512-wM+bZp54v/E9eRRGXb5ZFDvinrJIOaTapx3WUokyVGZu5ucVCK55zEgGd5Dl2fSr3jUo5sDiERErUWLY6QPFyA==} + /terser@5.29.1: + resolution: {integrity: sha512-lZQ/fyaIGxsbGxApKmoPTODIzELy3++mXhS5hOqaAWZjQtpq/hFHAc+rm29NND1rYRxRWKcjuARNwULNXa5RtQ==} engines: {node: '>=10'} hasBin: true dependencies: @@ -10825,7 +10825,7 @@ packages: '@unocss/transformer-directives': 0.58.5 '@unocss/transformer-variant-group': 0.58.5 '@unocss/vite': 0.58.5(vite@5.1.5) - vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.28.1) + vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.29.1) transitivePeerDependencies: - postcss - rollup @@ -10990,7 +10990,7 @@ packages: stylelint: 16.2.1(typescript@5.3.3) tiny-invariant: 1.3.3 typescript: 5.3.3 - vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.28.1) + vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.29.1) vscode-languageclient: 7.0.0 vscode-languageserver: 7.0.0 vscode-languageserver-textdocument: 1.0.11 @@ -11008,7 +11008,7 @@ packages: axios: 1.6.7(debug@4.3.4) debug: 4.3.4 picocolors: 1.0.0 - vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.28.1) + vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.29.1) transitivePeerDependencies: - supports-color dev: true @@ -11026,12 +11026,12 @@ packages: pathe: 0.2.0 svg-baker: 1.7.0 svgo: 2.8.0 - vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.28.1) + vite: 5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.29.1) transitivePeerDependencies: - supports-color dev: true - /vite@5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.28.1): + /vite@5.1.5(@types/node@20.11.22)(less@4.2.0)(lightningcss@1.24.0)(terser@5.29.1): resolution: {integrity: sha512-BdN1xh0Of/oQafhU+FvopafUp6WaYenLU/NFoL5WyJL++GxkNfieKzBhM24H3HVsPQrlAqB7iJYTHabzaRed5Q==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -11065,7 +11065,7 @@ packages: lightningcss: 1.24.0 postcss: 8.4.35 rollup: 4.12.0 - terser: 5.28.1 + terser: 5.29.1 optionalDependencies: fsevents: 2.3.3 diff --git a/src/api/demo/hero.ts b/src/api/demo/hero.ts index ccd9d586a..04d9e49c7 100644 --- a/src/api/demo/hero.ts +++ b/src/api/demo/hero.ts @@ -4,7 +4,8 @@ import { request } from '@/utils/request'; * @description 获取王者荣耀英雄列表 */ export function getWzryHeroList(query: API.PageParams) { - return request('/demo/wzry/hero_list', { + return request({ + url: '/demo/wzry/hero_list', method: 'get', params: query, }); @@ -14,7 +15,8 @@ export function getWzryHeroList(query: API.PageParams) { * @description 获取英雄联盟英雄列表 */ export function getLolHeroList(query: API.PageParams) { - return request('/demo/lol/hero_list', { + return request({ + url: '/demo/lol/hero_list', method: 'get', params: query, }); @@ -24,7 +26,8 @@ export function getLolHeroList(query: API.PageParams) { * @description 获取英雄联盟英雄列表 */ export function getLolHeroInfo({ id }) { - return request(`/demo/lol/hero_info/${id}`, { + return request({ + url: `/demo/lol/hero_info/${id}`, method: 'get', }); } diff --git a/src/api/demo/select.ts b/src/api/demo/select.ts index 2d3f840ba..2de166093 100644 --- a/src/api/demo/select.ts +++ b/src/api/demo/select.ts @@ -6,7 +6,8 @@ interface DemoOptionsItem { } export async function optionsListApi(params?: Recordable) { - return request('/select/getDemoOptions', { + return request({ + url: '/select/getDemoOptions', method: 'GET', params, }); diff --git a/src/components/core/dynamic-table/src/components/editable-cell/index.vue b/src/components/core/dynamic-table/src/components/editable-cell/index.vue index 7e66f778c..1237eb5eb 100644 --- a/src/components/core/dynamic-table/src/components/editable-cell/index.vue +++ b/src/components/core/dynamic-table/src/components/editable-cell/index.vue @@ -40,7 +40,7 @@ import type { PropType } from 'vue'; import type { CustomRenderParams, EditableType } from '@/components/core/dynamic-table/src/types'; import { schemaFormItemProps, SchemaFormItem } from '@/components/core/schema-form'; - import { isFunction } from '@/utils/is'; + import { isPromise } from '@/utils/is'; const props = defineProps({ ...schemaFormItemProps, @@ -105,14 +105,13 @@ const handleSaveCell = async () => { const { rowKey, column } = props; await validateCell(rowKey!, dataIndex.value); - if (isFunction(tableContext?.onSave)) { + const saveRes = tableContext.onSave?.(rowKey!, editFormModel.value[rowKey!], column?.record); + if (isPromise(saveRes)) { saving.value = true; - await tableContext - .onSave(rowKey!, editFormModel.value[rowKey!], column?.record) - .finally(() => (saving.value = false)); - cancelCellEditable(rowKey!, dataIndex.value); - isCellEdit.value = false; + await saveRes.finally(() => (saving.value = false)); } + cancelCellEditable(rowKey!, dataIndex.value); + isCellEdit.value = false; }; const handleCancelSaveCell = () => { diff --git a/src/components/core/dynamic-table/src/components/table-action.vue b/src/components/core/dynamic-table/src/components/table-action.vue index 22efa723d..ea74f0c41 100644 --- a/src/components/core/dynamic-table/src/components/table-action.vue +++ b/src/components/core/dynamic-table/src/components/table-action.vue @@ -22,6 +22,7 @@ import type { CustomRenderParams } from '../types/column'; import { hasPermission } from '@/permission'; import { Icon } from '@/components/basic/icon'; + import { isPromise } from '@/utils/is'; const ActionItemRender: FunctionalComponent = (action, { slots }) => { const { popConfirm, tooltip } = action; @@ -89,11 +90,15 @@ if (isFunction(onClick) && !hasClickFnFlag(onClick)) { item.onClick = debounce(async () => { - const key = getKey(item, index); - loadingMap.value.set(key, true); - await onClick(props.columnParams).finally(() => { - loadingMap.value.delete(key); - }); + const callbackRes = onClick(props.columnParams); + + if (isPromise(callbackRes)) { + const key = getKey(item, index); + loadingMap.value.set(key, true); + await callbackRes.finally(() => { + loadingMap.value.delete(key); + }); + } }); setClickFnFlag(item.onClick); } diff --git a/src/components/core/schema-form/src/hooks/useAdvanced.ts b/src/components/core/schema-form/src/hooks/useAdvanced.ts index d55d8ea80..c456f2be6 100644 --- a/src/components/core/schema-form/src/hooks/useAdvanced.ts +++ b/src/components/core/schema-form/src/hooks/useAdvanced.ts @@ -110,10 +110,11 @@ export const useAdvanced = ({ instance, emit }: UseAdvancedContext) => { } if (isFunction(vShow)) { - // @ts-ignore isShow = vShow({ - // @ts-ignore - schema, + schema: computed(() => { + // @ts-ignore + return unref(formSchemasRef).find((n) => n.field === schema.field) as any; + }), formModel, field: schema.field, formInstance: instance, diff --git a/src/components/core/schema-form/src/hooks/useFormEvents.ts b/src/components/core/schema-form/src/hooks/useFormEvents.ts index 6d7316168..1083b801b 100644 --- a/src/components/core/schema-form/src/hooks/useFormEvents.ts +++ b/src/components/core/schema-form/src/hooks/useFormEvents.ts @@ -186,29 +186,33 @@ export function useFormEvents(formActionContext: UseFormActionContext) { return; } const schemas: FormSchema[] = []; - updateData.forEach((item) => { - unref(formSchemasRef).forEach((val) => { - if (val.field === item.field) { - const newSchema = deepMerge(val, item); - if (originComponentPropsFnMap.has(val.field)) { - const originCompPropsFn = originComponentPropsFnMap.get(val.field)!; - const compProps = { ...newSchema.componentProps }; - newSchema.componentProps = (opt) => { - const res = { - ...originCompPropsFn(opt), - ...compProps, - }; - return res; + const updatedSchemas: FormSchema[] = []; + + unref(formSchemasRef).forEach((val) => { + const updateItem = updateData.find((n) => val.field === n.field); + if (updateItem) { + const compProps = updateItem.componentProps; + const newSchema = deepMerge(val, updateItem); + + if (originComponentPropsFnMap.has(val.field)) { + const originCompPropsFn = originComponentPropsFnMap.get(val.field)!; + + newSchema.componentProps = (opt) => { + return { + ...originCompPropsFn(opt), + ...(isFunction(compProps) ? compProps(opt) : compProps), }; - } - schemas.push(newSchema); - } else { - schemas.push(val); + }; } - }); + + updatedSchemas.push(newSchema); + schemas.push(newSchema); + } else { + schemas.push(val); + } }); + _setDefaultValue(updatedSchemas); formPropsRef.value.schemas = uniqBy(schemas, 'field'); - _setDefaultValue(formPropsRef.value.schemas!); }; function _setDefaultValue(data: FormSchema | FormSchema[]) { diff --git a/src/components/core/schema-form/src/schema-form-item.vue b/src/components/core/schema-form/src/schema-form-item.vue index bc0bfb26c..10b0d971d 100644 --- a/src/components/core/schema-form/src/schema-form-item.vue +++ b/src/components/core/schema-form/src/schema-form-item.vue @@ -15,6 +15,7 @@