This commit is contained in:
dap
2024-11-05 07:53:13 +08:00
48 changed files with 107 additions and 80 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@vben/access",
"version": "5.4.3",
"version": "5.4.4",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@vben/common-ui",
"version": "5.4.3",
"version": "5.4.4",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -52,7 +52,7 @@ const emit = defineEmits<{
const router = useRouter();
const [Form, { validate, setFieldValue, getValues }] = useVbenForm(
const [Form, formApi] = useVbenForm(
reactive({
commonConfig: {
hideLabel: true,
@@ -64,8 +64,8 @@ const [Form, { validate, setFieldValue, getValues }] = useVbenForm(
);
async function handleSubmit() {
const { valid } = await validate();
const values = await getValues();
const { valid } = await formApi.validate();
const values = await formApi.getValues();
if (valid) {
emit('submit', {
tenantId: values?.tenantId,
@@ -79,7 +79,9 @@ function goToLogin() {
router.push(props.loginPath);
}
defineExpose({ setFieldValue });
defineExpose({
getFormApi: () => formApi,
});
</script>
<template>

View File

@@ -50,7 +50,7 @@ const emit = defineEmits<{
submit: [Record<string, any>];
}>();
const [Form, { validate, getValues }] = useVbenForm(
const [Form, formApi] = useVbenForm(
reactive({
commonConfig: {
hideLabel: true,
@@ -64,8 +64,8 @@ const [Form, { validate, getValues }] = useVbenForm(
const router = useRouter();
async function handleSubmit() {
const { valid } = await validate();
const values = await getValues();
const { valid } = await formApi.validate();
const values = await formApi.getValues();
if (valid) {
emit('submit', values);
}
@@ -74,6 +74,10 @@ async function handleSubmit() {
function goToLogin() {
router.push(props.loginPath);
}
defineExpose({
getFormApi: () => formApi,
});
</script>
<template>

View File

@@ -44,7 +44,7 @@ const emit = defineEmits<{
submit: [LoginAndRegisterParams];
}>();
const [Form, { setFieldValue, validate, getValues }] = useVbenForm(
const [Form, formApi] = useVbenForm(
reactive({
commonConfig: {
hideLabel: true,
@@ -63,9 +63,9 @@ const localUsername = localStorage.getItem(REMEMBER_ME_KEY) || '';
const rememberMe = ref(!!localUsername);
async function handleSubmit() {
const { valid } = await validate();
const values = cloneDeep(await getValues());
const { valid } = await formApi.validate();
if (valid) {
const values = cloneDeep(await formApi.getValues());
localStorage.setItem(
REMEMBER_ME_KEY,
rememberMe.value ? values?.username : '',
@@ -82,11 +82,13 @@ function handleGo(path: string) {
onMounted(() => {
if (localUsername) {
setFieldValue('username', localUsername);
formApi.setFieldValue('username', localUsername);
}
});
defineExpose({ setFieldValue });
defineExpose({
getFormApi: () => formApi,
});
</script>
<template>

View File

@@ -52,7 +52,7 @@ const emit = defineEmits<{
submit: [Recordable<any>];
}>();
const [Form, { validate, getValues }] = useVbenForm(
const [Form, formApi] = useVbenForm(
reactive({
commonConfig: {
hideLabel: true,
@@ -66,8 +66,8 @@ const [Form, { validate, getValues }] = useVbenForm(
const router = useRouter();
async function handleSubmit() {
const { valid } = await validate();
const values = await getValues();
const { valid } = await formApi.validate();
const values = await formApi.getValues();
if (valid) {
emit('submit', values as { password: string; username: string });
}
@@ -76,6 +76,10 @@ async function handleSubmit() {
function goToLogin() {
router.push(props.loginPath);
}
defineExpose({
getFormApi: () => formApi,
});
</script>
<template>

View File

@@ -1,6 +1,6 @@
{
"name": "@vben/hooks",
"version": "5.4.3",
"version": "5.4.4",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@vben/layouts",
"version": "5.4.3",
"version": "5.4.4",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@vben/plugins",
"version": "5.4.3",
"version": "5.4.4",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -41,6 +41,9 @@ const props = withDefaults(defineProps<Props>(), {});
const FORM_SLOT_PREFIX = 'form-';
const TOOLBAR_ACTIONS = 'toolbar-actions';
const TOOLBAR_TOOLS = 'toolbar-tools';
const gridRef = useTemplateRef<VxeGridInstance>('gridRef');
const state = props.api?.useStore?.();
@@ -89,15 +92,16 @@ const showTableTitle = computed(() => {
const showToolbar = computed(() => {
return (
!!slots['toolbar-actions']?.() ||
!!slots['toolbar-tools']?.() ||
!!slots[TOOLBAR_ACTIONS]?.() ||
!!slots[TOOLBAR_TOOLS]?.() ||
showTableTitle.value
);
});
const toolbarOptions = computed(() => {
const slotActions = slots['toolbar-actions']?.();
const slotTools = slots['toolbar-tools']?.();
const slotActions = slots[TOOLBAR_ACTIONS]?.();
const slotTools = slots[TOOLBAR_TOOLS]?.();
if (!showToolbar.value) {
return {};
}
@@ -107,9 +111,9 @@ const toolbarOptions = computed(() => {
toolbarConfig: {
slots: {
...(slotActions || showTableTitle.value
? { buttons: 'toolbar-actions' }
? { buttons: TOOLBAR_ACTIONS }
: {}),
...(slotTools ? { tools: 'toolbar-tools' } : {}),
...(slotTools ? { tools: TOOLBAR_TOOLS } : {}),
},
},
};
@@ -124,11 +128,6 @@ const options = computed(() => {
toolbarOptions.value,
toRaw(gridOptions.value),
globalGridConfig,
{
// toolbarConfig: {
// tools: [],
// },
} as VxeTableGridProps,
),
);
@@ -187,7 +186,7 @@ const delegatedSlots = computed(() => {
const resultSlots: string[] = [];
for (const key of Object.keys(slots)) {
if (!['empty', 'form', 'loading', 'toolbar-actions'].includes(key)) {
if (!['empty', 'form', 'loading', TOOLBAR_ACTIONS].includes(key)) {
resultSlots.push(key);
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@vben/request",
"version": "5.4.3",
"version": "5.4.4",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {