Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

搜索那里添加select和date组件 #280

Open
wants to merge 4 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions packages/pro-table/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ant-design-vue/pro-table",
"version": "0.0.1",
"name": "pro-table-ant-design-vue",
"version": "0.0.9",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
Expand All @@ -17,28 +17,27 @@
],
"types": "./dist",
"style": "./dist/style.css",
"main": "./dist/pro-table.umd.js",
"module": "./dist/pro-table.es.js",
"main": "./dist/pro-table-ant-design-vue.umd.js",
"module": "./dist/pro-table-ant-design-vue.es.js",
"exports": {
".": {
"import": "./dist/pro-table.es.js",
"require": "./dist/pro-table.umd.js"
"import": "./dist/pro-table-ant-design-vue.es.js",
"require": "./dist/pro-table-ant-design-vue.umd.js"
},
"./dist/style.css": "./dist/style.css",
"./dist/style.less": "./dist/style.less"
},
"dependencies": {
"@ant-design/icons-vue": "^6.1.0",
"@ant-design-vue/pro-form": "workspace:^0.1.1",
"@ant-design-vue/pro-utils": "workspace:^0.0.0",
"@ant-design-vue/pro-form": "^0.1.1",
"lodash-es": "^4.17.21",
"screenfull": "^6.0.2"
},
"devDependencies": {
"@ant-design-vue/pro-layout": "workspace:^3.2.3",
"@ant-design-vue/pro-layout": "^3.2.3",
"@rollup/plugin-typescript": "^8.3.2",
"@rushstack/eslint-patch": "^1.1.3",
"@shared/vite-plugin-less-copy": "workspace:^0.0.0",
"@shared/vite-plugin-less-copy": "^0.0.0",
"@types/jsdom": "^16.2.14",
"@types/lodash-es": "^4.17.6",
"@types/node": "^16.11.27",
Expand Down
45 changes: 33 additions & 12 deletions packages/pro-table/src/components/Form/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { defineComponent, reactive, computed, toRaw, type PropType } from 'vue';
import { useSharedContext } from '../../shared/Context';
import { QueryFilter, queryFilterProps, ProFormText } from '@ant-design-vue/pro-form';
import { QueryFilter, queryFilterProps, ProFormText, ProFormDatePicker, ProFormSelect } from '@ant-design-vue/pro-form';
import type { ProColumnsType, ProColumnType } from '../../typings';

import './index.less';

type RecordType = Record<string, unknown>;

const filterSeatchColumns = <T extends RecordType>(columns: ProColumnsType<T> = []) =>
columns.filter(column => column.search).map(column => column as ProColumnType<T>);
columns.filter((column) => column.search).map((column) => column as ProColumnType<T>);

const searchFormProps = {
...queryFilterProps,
Expand All @@ -32,23 +32,44 @@ const SearchForm = defineComponent({
return () => {
if (searchColumns.value.length === 0) return null;

const formFields = searchColumns.value.map(column => (
<ProFormText
name={column.dataIndex as string}
label={column.title as string}
fieldProps={{
allowClear: true,
}}
/>
));
const formFields = searchColumns.value.map((column: any) => {
if (column.valueType === 'select') {
return (
<ProFormSelect
{...column}
name={column.dataIndex as string}
label={column.title as string}
options={Object.entries(column.valueEnum).map((item: any) => {
return {
label: item[1].text,
icon: item[1].icon,
value: item[0],
};
})}
/>
);
} else if (column.valueType === 'date') {
return <ProFormDatePicker name={column.dataIndex as string} label={column.title as string} {...column} />;
} else {
return (
<ProFormText
name={column.dataIndex as string}
label={column.title as string}
fieldProps={{
allowClear: true,
}}
/>
);
}
});

const onFinish = (model: Record<string, unknown>) => {
emit('finish', toRaw(model));
};

return (
<div class={className}>
<QueryFilter class={formClassName} model={model} onFinish={onFinish}>
<QueryFilter class={formClassName} defaultCollapsed={false} model={model} onFinish={onFinish}>
{...formFields}
</QueryFilter>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/pro-table/src/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export declare type FixedType = 'left' | 'right' | boolean;
export declare type DataIndex = string | number | readonly (string | number)[];

export type ProColumnType<RecordType> = ColumnType<RecordType> & {
valueType?: 'index' | 'indexBorder' | 'text' | 'select';
valueType?: 'index' | 'indexBorder' | 'text' | 'select' | 'date';
search?: boolean;
};

Expand Down