chore: search form

This commit is contained in:
dap 2024-09-24 10:39:36 +08:00
parent 741915e5cd
commit c5971e4407
3 changed files with 91 additions and 37 deletions

View File

@ -1,3 +1,9 @@
import type { FormSchemaGetter } from '#/adapter';
import { DictEnum } from '@vben/constants';
import { getDictOptions } from '#/utils/dict';
/** /**
* authScopeOptions user也会用到 * authScopeOptions user也会用到
*/ */
@ -8,3 +14,36 @@ export const authScopeOptions = [
{ color: 'cyan', label: '本部门及以下数据权限', value: '4' }, { color: 'cyan', label: '本部门及以下数据权限', value: '4' },
{ color: 'error', label: '仅本人数据权限', value: '5' }, { color: 'error', label: '仅本人数据权限', value: '5' },
]; ];
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
componentProps: {
placeholder: '请输入',
},
fieldName: 'roleName',
label: '角色名称',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入',
},
fieldName: 'roleKey',
label: '权限字符',
},
{
component: 'Select',
componentProps: {
options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
placeholder: '请选择',
},
fieldName: 'status',
label: '状态',
},
{
component: 'RangePicker',
fieldName: 'createTime',
label: '创建时间',
},
];

View File

@ -1,28 +1,36 @@
<script setup lang="ts"> <script setup lang="ts">
import { CodeMirror, JsonPreview, Page } from '@vben/common-ui'; import { Page } from '@vben/common-ui';
import packageJson from '#/../package.json';
import { Card } from 'ant-design-vue'; import { Card } from 'ant-design-vue';
import code from '#/components/tinymce/src/editor.vue?raw'; import { useVbenForm } from '#/adapter';
import { querySchema } from './data';
const [QueryForm] = useVbenForm({
//
collapsed: false,
//
commonConfig: {
//
componentProps: {
class: 'w-full',
},
},
schema: querySchema(),
//
showCollapseButton: true,
submitButtonOptions: {
text: '查询',
},
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
});
</script> </script>
<template> <template>
<Page content-class="flex lg:flex-row flex-col gap-[16px]"> <Page content-class="flex lg:flex-row flex-col gap-[16px]">
<Card class="flex-1" title="json预览"> <Card class="flex-1">
<div class="h-[600px] overflow-y-auto"> <QueryForm />
<JsonPreview :data="packageJson" />
</div>
</Card>
<Card class="flex-1" title="codeMirror预览">
<div class="h-[600px] overflow-y-auto">
<CodeMirror
v-model="code"
class="text-[16px]"
language="vue"
readonly
/>
</div>
</Card> </Card>
</Page> </Page>
</template> </template>

View File

@ -4,7 +4,7 @@ import { ref } from 'vue';
import { Page, useVbenDrawer, useVbenModal } from '@vben/common-ui'; import { Page, useVbenDrawer, useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales'; import { $t } from '@vben/locales';
import { message } from 'ant-design-vue'; import { Card, message } from 'ant-design-vue';
import { useVbenForm } from '#/adapter'; import { useVbenForm } from '#/adapter';
import { userExport } from '#/api/system/user'; import { userExport } from '#/api/system/user';
@ -69,25 +69,32 @@ const [QueryForm] = useVbenForm({
@select="handleSelect" @select="handleSelect"
/> />
<div class="flex w-full flex-col gap-[8px]"> <div class="flex w-full flex-col gap-[8px]">
<QueryForm /> <Card>
<div class="flex justify-end gap-[8px]"> <QueryForm />
<a-button </Card>
v-access:code="['system:user:export']" <Card>
@click="downloadExcel(userExport, '用户管理', {})" <div class="flex justify-end gap-[8px]">
> <a-button
{{ $t('pages.common.export') }} v-access:code="['system:user:export']"
</a-button> @click="downloadExcel(userExport, '用户管理', {})"
<a-button v-access:code="['system:user:import']" @click="handleImport"> >
{{ $t('pages.common.import') }} {{ $t('pages.common.export') }}
</a-button> </a-button>
<a-button <a-button
type="primary" v-access:code="['system:user:import']"
v-access:code="['system:user:add']" @click="handleImport"
@click="handleAdd" >
> {{ $t('pages.common.import') }}
{{ $t('pages.common.add') }} </a-button>
</a-button> <a-button
</div> type="primary"
v-access:code="['system:user:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</div>
</Card>
</div> </div>
<UserImpotModal /> <UserImpotModal />
<UserDrawer /> <UserDrawer />