From 16042d2897acb84cf58cdb955fc16b20d4c23735 Mon Sep 17 00:00:00 2001 From: bqy_fe <1743369777@qq.com> Date: Fri, 17 Dec 2021 17:50:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E7=9A=84=E6=97=A7=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/api/demos/hero.ts | 15 + src/components/JSON-schema-form/helper.ts | 1 + .../JSON-schema-form/schema-form-item.vue | 20 +- .../components/query-form/index.vue | 5 +- .../table-settings/column-setting.vue | 33 +- .../dynamic-table/dynamic-table.vue | 15 - src/components/dynamic-table/typing.ts | 29 +- src/mock/hero/heroList.json | 1977 +++++++++++++++++ src/mock/hero/index.js | 15 + src/mock/index.js | 3 +- src/mock/utils.js | 36 + src/router/staticModules/demos.ts | 27 +- .../demos/form/basic-form/form-schema.ts | 2 +- .../shared/demos/form/basic-form/index.vue | 4 +- .../shared/demos/form/rule-form/index.vue | 4 +- .../demos/tables/summary-table/columns.ts | 103 - .../demos/tables/summary-table/index.vue | 79 - .../demos/tables/summary-table/mockData.json | 710 ------ .../demos/tables/wzry-table/columns.tsx | 50 + .../shared/demos/tables/wzry-table/index.vue | 54 + 21 files changed, 2210 insertions(+), 974 deletions(-) create mode 100644 src/api/demos/hero.ts create mode 100644 src/mock/hero/heroList.json create mode 100644 src/mock/hero/index.js delete mode 100644 src/views/shared/demos/tables/summary-table/columns.ts delete mode 100644 src/views/shared/demos/tables/summary-table/index.vue delete mode 100644 src/views/shared/demos/tables/summary-table/mockData.json create mode 100644 src/views/shared/demos/tables/wzry-table/columns.tsx create mode 100644 src/views/shared/demos/tables/wzry-table/index.vue diff --git a/README.md b/README.md index 41475d923..a9b100d89 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ - [x] 动态表格(完善中) - [x] 动态表单(完善中) - [ ] 电商 SKU 功能演示 -- [ ] 纯前端导出 PDF 动态分页 +- [ ] 纯前端导出 PDF 自动分页 - [ ] 其他... ## Project setup diff --git a/src/api/demos/hero.ts b/src/api/demos/hero.ts new file mode 100644 index 000000000..1bd00a32d --- /dev/null +++ b/src/api/demos/hero.ts @@ -0,0 +1,15 @@ +import { request, BaseResponse } from '@/utils/request'; + +export function getHeroList(query: API.PageParams) { + return request>( + { + url: '/demos/hero/list', + method: 'get', + params: query, + }, + { + isMock: true, + isGetDataDirectly: false, + }, + ); +} diff --git a/src/components/JSON-schema-form/helper.ts b/src/components/JSON-schema-form/helper.ts index 0a71cc9d2..7e2a5e097 100644 --- a/src/components/JSON-schema-form/helper.ts +++ b/src/components/JSON-schema-form/helper.ts @@ -14,6 +14,7 @@ export function createPlaceholderMessage(component: ComponentMapType, label = '' 'Select', 'Cascader', 'Checkbox', + 'CheckboxGroup', 'Switch', 'TreeSelect', ]; diff --git a/src/components/JSON-schema-form/schema-form-item.vue b/src/components/JSON-schema-form/schema-form-item.vue index ff9edebd1..cd9085f80 100644 --- a/src/components/JSON-schema-form/schema-form-item.vue +++ b/src/components/JSON-schema-form/schema-form-item.vue @@ -2,11 +2,11 @@ { const { label, helpMessage, helpComponentProps, subLabel } = props.schemaItem; const renderLabel = subLabel ? ( @@ -167,7 +167,7 @@ ); - } + }); const getComponentsProps = computed(() => { const { schemaItem, tableAction, formModel, formActionType } = props; @@ -192,7 +192,7 @@ } } - function handleRules(): ValidationRule[] { + const getRules = computed(() => { const { rules: defRules = [], component, @@ -200,8 +200,13 @@ label, dynamicRules, required, + field, } = props.schemaItem; + if (field == 'field5') { + console.log('rules', props.schemaItem); + } + if (isFunction(dynamicRules)) { return dynamicRules(unref(getValues)) as ValidationRule[]; } @@ -214,10 +219,11 @@ : globalRulesMessageJoinLabel; const defaultMsg = isString(component) ? `${createPlaceholderMessage(component, label)}${joinLabel ? label : ''}` - : ''; + : undefined; function validator(rule: any, value: any) { const msg = rule.message || defaultMsg; + if (value === undefined || isNull(value)) { // 空值 return Promise.reject(msg); @@ -277,7 +283,7 @@ } return rules; - } + }); onMounted(async () => { if (getComponentProps.value?.request) { diff --git a/src/components/dynamic-table/components/query-form/index.vue b/src/components/dynamic-table/components/query-form/index.vue index 554f2cca8..916ab4fbb 100644 --- a/src/components/dynamic-table/components/query-form/index.vue +++ b/src/components/dynamic-table/components/query-form/index.vue @@ -76,7 +76,10 @@ const formItemSchemas = computed(() => { return props.columns - .filter((n) => !n.hideInSearch && !!getColumnKey(n)) + .filter((n) => { + const field = getColumnKey(n); + return !n.hideInSearch && !!field && field !== '$action'; + }) .map((n) => { return { field: n.formItemProps?.field ?? n.searchField ?? getColumnKey(n), diff --git a/src/components/dynamic-table/components/table-settings/column-setting.vue b/src/components/dynamic-table/components/table-settings/column-setting.vue index e9ca34d80..e158d31ea 100644 --- a/src/components/dynamic-table/components/table-settings/column-setting.vue +++ b/src/components/dynamic-table/components/table-settings/column-setting.vue @@ -3,7 +3,6 @@ -
列展示 - 序号列 - + + 边框 + 重置
-