From bea6824fd7c28e2b9097c7a308d58b8976d1767d Mon Sep 17 00:00:00 2001 From: bqy_fe <1743369777@qq.com> Date: Wed, 16 Mar 2022 16:12:39 +0800 Subject: [PATCH] feat: update basic-form demo --- package.json | 10 +- src/api/demos/select.ts | 18 + .../basic/excel/src/ExportExcelModal.tsx | 1 - .../dynamic-table/src/hooks/useTableForm.ts | 3 +- src/components/core/schema-form/index.ts | 6 +- .../schema-form/src/components/ApiSelect.vue | 141 +++++ .../src/components/form-action.vue | 2 +- .../core/schema-form/src/components/index.ts | 1 + src/components/core/schema-form/src/helper.ts | 2 +- .../core/schema-form/src/hooks/useAdvanced.ts | 4 +- .../core/schema-form/src/schema-form-item.vue | 76 +-- .../core/schema-form/src/schema-form.ts | 2 +- .../core/schema-form/src/schema-form.vue | 4 +- .../core/schema-form/src/types/component.ts | 125 +++++ .../core/schema-form/src/types/form.ts | 9 +- .../core/schema-form/src/types/index.ts | 124 +---- src/layout/header/index.vue | 2 +- src/layout/tabs/tabs-view.vue | 2 +- src/mock/demo/index.js | 26 + src/mock/index.js | 3 +- src/utils/propTypes.ts | 34 ++ src/views/demos/custom-modal.vue | 7 + .../demos/form/basic-form/form-schema.ts | 222 -------- .../demos/form/basic-form/form-schema.tsx | 499 ++++++++++++++++++ src/views/demos/form/basic-form/index.vue | 127 ++++- src/views/demos/form/use-form/index.vue | 2 +- yarn.lock | 77 ++- 27 files changed, 1083 insertions(+), 446 deletions(-) create mode 100644 src/api/demos/select.ts create mode 100644 src/components/core/schema-form/src/components/ApiSelect.vue create mode 100644 src/components/core/schema-form/src/components/index.ts create mode 100644 src/components/core/schema-form/src/types/component.ts create mode 100644 src/mock/demo/index.js create mode 100644 src/utils/propTypes.ts delete mode 100644 src/views/demos/form/basic-form/form-schema.ts create mode 100644 src/views/demos/form/basic-form/form-schema.tsx diff --git a/package.json b/package.json index 4cb3c4d20..29adcbfda 100644 --- a/package.json +++ b/package.json @@ -46,10 +46,11 @@ "vue": "^3.2.31", "vue-i18n": "^9.2.0-beta.30", "vue-router": "^4.0.14", - "xlsx": "^0.18.3" + "vue-types": "^4.1.1", + "xlsx": "^0.18.4" }, "devDependencies": { - "@commitlint/cli": "^16.2.1", + "@commitlint/cli": "^16.2.3", "@commitlint/config-conventional": "^16.2.1", "@types/lodash-es": "^4.17.6", "@types/node": "^17.0.21", @@ -62,7 +63,6 @@ "@vue/cli-plugin-typescript": "^5.0.3", "@vue/cli-plugin-vuex": "^5.0.3", "@vue/cli-service": "^5.0.3", - "@vue/compiler-sfc": "^3.2.31", "@vue/eslint-config-typescript": "^10.0.0", "babel-plugin-import": "^1.13.3", "commitizen": "^4.2.4", @@ -76,10 +76,10 @@ "husky": "^7.0.4", "less": "^4.1.2", "less-loader": "10.2.0", - "lint-staged": "^12.3.5", + "lint-staged": "^12.3.6", "path-browserify": "^1.0.1", "postcss-html": "^1.3.0", - "prettier": "^2.5.1", + "prettier": "^2.6.0", "regenerator-runtime": "^0.13.9", "stylelint": "^14.5.3", "stylelint-config-html": "^1.0.0", diff --git a/src/api/demos/select.ts b/src/api/demos/select.ts new file mode 100644 index 000000000..6e0e7a2ac --- /dev/null +++ b/src/api/demos/select.ts @@ -0,0 +1,18 @@ +import { request } from '@/utils/request'; + +/** + * @description Get sample options value + */ +export function optionsListApi(params?: any) { + return request<{ list: { id: string; name: string }[] }>( + { + url: '/select/getDemoOptions', + method: 'get', + params, + }, + { + isMock: true, + isGetDataDirectly: true, + }, + ); +} diff --git a/src/components/basic/excel/src/ExportExcelModal.tsx b/src/components/basic/excel/src/ExportExcelModal.tsx index 1cc230e5b..a44763486 100644 --- a/src/components/basic/excel/src/ExportExcelModal.tsx +++ b/src/components/basic/excel/src/ExportExcelModal.tsx @@ -67,7 +67,6 @@ export const useExportExcelModal = () => { }, formProps: { labelWidth: 100, - layout: 'vertical', schemas: getSchemas(t), }, }); diff --git a/src/components/core/dynamic-table/src/hooks/useTableForm.ts b/src/components/core/dynamic-table/src/hooks/useTableForm.ts index 2eb58e5f5..1fc4c6910 100644 --- a/src/components/core/dynamic-table/src/hooks/useTableForm.ts +++ b/src/components/core/dynamic-table/src/hooks/useTableForm.ts @@ -1,5 +1,4 @@ import { unref, computed, watchEffect } from 'vue'; -import { omit } from 'lodash-es'; import type { TableMethods } from './useTableMethods'; import type { TableState } from './useTableState'; import type { ComputedRef, Slots } from 'vue'; @@ -49,7 +48,7 @@ export function useTableForm({ tableState, slots, tableMethods }: UseTableFormCo }); // 同步外部对props的修改 - watchEffect(() => getQueryFormRef()?.setSchemaFormProps(omit(unref(getFormProps), 'schemas')), { + watchEffect(() => getQueryFormRef()?.setSchemaFormProps(unref(getFormProps)), { flush: 'post', }); diff --git a/src/components/core/schema-form/index.ts b/src/components/core/schema-form/index.ts index 0347e0c2f..080e17746 100644 --- a/src/components/core/schema-form/index.ts +++ b/src/components/core/schema-form/index.ts @@ -1,13 +1,11 @@ -// export { default as SchemaForm } from './schema-form.vue' import SchemaForm from './src/schema-form.vue'; import type { DefineComponent } from 'vue'; import type { SchemaFormProps } from './src/schema-form'; -export * from './src/types/form'; -export * from './src/types/formItem'; +export * from './src/types/'; export * from './src/schema-form'; - export * from './src/hooks/'; +export * from './src/components/'; export { SchemaForm }; diff --git a/src/components/core/schema-form/src/components/ApiSelect.vue b/src/components/core/schema-form/src/components/ApiSelect.vue new file mode 100644 index 000000000..a09537c64 --- /dev/null +++ b/src/components/core/schema-form/src/components/ApiSelect.vue @@ -0,0 +1,141 @@ + + diff --git a/src/components/core/schema-form/src/components/form-action.vue b/src/components/core/schema-form/src/components/form-action.vue index c054a6129..db01e2820 100644 --- a/src/components/core/schema-form/src/components/form-action.vue +++ b/src/components/core/schema-form/src/components/form-action.vue @@ -43,7 +43,7 @@ import { computed, type PropType } from 'vue'; import { Form, Col } from 'ant-design-vue'; import { useFormContext } from '../hooks/useFormContext'; - import type { ColEx } from '../types/index'; + import type { ColEx } from '../types/component'; import { Button, ButtonProps } from '@/components/basic/button'; import { BasicArrow } from '@/components/basic/basic-arrow'; import { useI18n } from '@/hooks/useI18n'; diff --git a/src/components/core/schema-form/src/components/index.ts b/src/components/core/schema-form/src/components/index.ts new file mode 100644 index 000000000..9137b5876 --- /dev/null +++ b/src/components/core/schema-form/src/components/index.ts @@ -0,0 +1 @@ +export { default as ApiSelect } from './ApiSelect.vue'; diff --git a/src/components/core/schema-form/src/helper.ts b/src/components/core/schema-form/src/helper.ts index 254e00e41..c92b67205 100644 --- a/src/components/core/schema-form/src/helper.ts +++ b/src/components/core/schema-form/src/helper.ts @@ -1,6 +1,6 @@ import dayjs from 'dayjs'; import type { ValidationRule } from 'ant-design-vue/es/form/Form'; -import type { ComponentMapType } from './types'; +import type { ComponentMapType } from './types/component'; import { isNumber } from '@/utils/is'; import { useI18n } from '@/hooks/useI18n'; diff --git a/src/components/core/schema-form/src/hooks/useAdvanced.ts b/src/components/core/schema-form/src/hooks/useAdvanced.ts index 594b749bf..7d654d41c 100644 --- a/src/components/core/schema-form/src/hooks/useAdvanced.ts +++ b/src/components/core/schema-form/src/hooks/useAdvanced.ts @@ -1,6 +1,6 @@ import { computed, unref, watch } from 'vue'; import type { SchemaFormEmitFn } from '../schema-form'; -import type { ColEx } from '../types'; +import type { ColEx } from '../types/component'; import type { SchemaFormType } from './'; import { isBoolean, isFunction, isNumber, isObject } from '@/utils/is'; import { useBreakpoint } from '@/hooks/event/useBreakpoint'; @@ -40,7 +40,7 @@ export const useAdvanced = ({ instance, emit }: UseAdvancedContext) => { () => { const { showAdvancedButton } = unref(getFormProps); if (showAdvancedButton) { - requestIdleCallback(updateAdvanced); + updateAdvanced(); } }, { immediate: true }, 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 6255a9fe2..024cf90fa 100644 --- a/src/components/core/schema-form/src/schema-form-item.vue +++ b/src/components/core/schema-form/src/schema-form-item.vue @@ -1,6 +1,10 @@