feat: 添加签到页面,整合用户选择和日期选择功能,支持数据过滤
This commit is contained in:
@@ -40,7 +40,7 @@ export type TableFilterColumn = {
|
||||
key: string;
|
||||
title: string;
|
||||
component?: Component | VNode;
|
||||
componentProps?: Record<string, any>;
|
||||
componentProps?: Record<string, any> | ((form: Record<string, any>) => Record<string, any>);
|
||||
};
|
||||
|
||||
export type TableFilterColumns = Array<TableFilterColumn>;
|
||||
|
||||
@@ -31,6 +31,7 @@ const props = withDefaults(
|
||||
{
|
||||
title: '',
|
||||
showHeaderOperation: true,
|
||||
filterColumnsCount: 4,
|
||||
filterColumns: () => [],
|
||||
headerOperations: () => ({
|
||||
add: true,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { NInput } from 'naive-ui';
|
||||
import type { TableFilterColumns } from '.';
|
||||
import type { TableFilterColumn, TableFilterColumns } from '.';
|
||||
|
||||
const props = defineProps<{
|
||||
columns?: TableFilterColumns;
|
||||
@@ -15,8 +15,22 @@ const inlineForm: Record<string, any> = {};
|
||||
|
||||
const form = ref<Record<string, any>>({});
|
||||
|
||||
function transformProps(col: TableFilterColumn) {
|
||||
if (typeof col.componentProps === 'object') {
|
||||
return col.componentProps;
|
||||
} else if (typeof col.componentProps === 'function') {
|
||||
return col.componentProps(form.value);
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
props.columns?.forEach(col => {
|
||||
if (col.key.includes(',')) {
|
||||
col.key.split(',').forEach(k => {
|
||||
inlineForm[k] = null;
|
||||
form.value[k] = null;
|
||||
});
|
||||
return;
|
||||
}
|
||||
inlineForm[col.key] = null;
|
||||
form.value[col.key] = null;
|
||||
});
|
||||
@@ -41,7 +55,7 @@ function handleConfirm() {
|
||||
<component
|
||||
:is="col.component || NInput"
|
||||
:value="form[col.key]"
|
||||
v-bind="col.componentProps"
|
||||
v-bind="transformProps(col)"
|
||||
@update:value="(val: any) => (form[col.key] = val)"
|
||||
/>
|
||||
</NFormItem>
|
||||
|
||||
Reference in New Issue
Block a user