|
@@ -34,17 +34,6 @@ const submitButtonOptions = computed(() => {
|
|
// return !!unref(rootProps).showCollapseButton;
|
|
// return !!unref(rootProps).showCollapseButton;
|
|
// });
|
|
// });
|
|
|
|
|
|
-const queryFormStyle = computed(() => {
|
|
|
|
- if (!unref(rootProps).actionWrapperClass) {
|
|
|
|
- return {
|
|
|
|
- 'grid-column': `-2 / -1`,
|
|
|
|
- marginLeft: 'auto',
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return {};
|
|
|
|
-});
|
|
|
|
-
|
|
|
|
async function handleSubmit(e: Event) {
|
|
async function handleSubmit(e: Event) {
|
|
e?.preventDefault();
|
|
e?.preventDefault();
|
|
e?.stopPropagation();
|
|
e?.stopPropagation();
|
|
@@ -86,22 +75,59 @@ watch(
|
|
},
|
|
},
|
|
);
|
|
);
|
|
|
|
|
|
|
|
+const actionWrapperClass = computed(() => {
|
|
|
|
+ const props = unref(rootProps);
|
|
|
|
+ const actionLayout = props.actionLayout || 'rowEnd';
|
|
|
|
+ const actionPosition = props.actionPosition || 'right';
|
|
|
|
+
|
|
|
|
+ const cls = [
|
|
|
|
+ 'flex',
|
|
|
|
+ 'w-full',
|
|
|
|
+ 'items-center',
|
|
|
|
+ 'gap-3',
|
|
|
|
+ props.compact ? 'pb-2' : 'pb-4',
|
|
|
|
+ props.layout === 'vertical' ? 'self-end' : 'self-center',
|
|
|
|
+ props.actionWrapperClass,
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ switch (actionLayout) {
|
|
|
|
+ case 'newLine': {
|
|
|
|
+ cls.push('col-span-full');
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ case 'rowEnd': {
|
|
|
|
+ cls.push('col-[-2/-1]');
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ // 'inline' 不需要额外类名,保持默认
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ switch (actionPosition) {
|
|
|
|
+ case 'center': {
|
|
|
|
+ cls.push('justify-center');
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ case 'left': {
|
|
|
|
+ cls.push('justify-start');
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ default: {
|
|
|
|
+ // case 'right': 默认右对齐
|
|
|
|
+ cls.push('justify-end');
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return cls.join(' ');
|
|
|
|
+});
|
|
|
|
+
|
|
defineExpose({
|
|
defineExpose({
|
|
handleReset,
|
|
handleReset,
|
|
handleSubmit,
|
|
handleSubmit,
|
|
});
|
|
});
|
|
</script>
|
|
</script>
|
|
<template>
|
|
<template>
|
|
- <div
|
|
|
|
- :class="
|
|
|
|
- cn(
|
|
|
|
- 'col-span-full w-full text-right',
|
|
|
|
- rootProps.compact ? 'pb-2' : 'pb-6',
|
|
|
|
- rootProps.actionWrapperClass,
|
|
|
|
- )
|
|
|
|
- "
|
|
|
|
- :style="queryFormStyle"
|
|
|
|
- >
|
|
|
|
|
|
+ <div :class="cn(actionWrapperClass)">
|
|
<template v-if="rootProps.actionButtonsReverse">
|
|
<template v-if="rootProps.actionButtonsReverse">
|
|
<!-- 提交按钮前 -->
|
|
<!-- 提交按钮前 -->
|
|
<slot name="submit-before"></slot>
|
|
<slot name="submit-before"></slot>
|
|
@@ -109,7 +135,6 @@ defineExpose({
|
|
<component
|
|
<component
|
|
:is="COMPONENT_MAP.PrimaryButton"
|
|
:is="COMPONENT_MAP.PrimaryButton"
|
|
v-if="submitButtonOptions.show"
|
|
v-if="submitButtonOptions.show"
|
|
- class="ml-3"
|
|
|
|
type="button"
|
|
type="button"
|
|
@click="handleSubmit"
|
|
@click="handleSubmit"
|
|
v-bind="submitButtonOptions"
|
|
v-bind="submitButtonOptions"
|
|
@@ -124,7 +149,6 @@ defineExpose({
|
|
<component
|
|
<component
|
|
:is="COMPONENT_MAP.DefaultButton"
|
|
:is="COMPONENT_MAP.DefaultButton"
|
|
v-if="resetButtonOptions.show"
|
|
v-if="resetButtonOptions.show"
|
|
- class="ml-3"
|
|
|
|
type="button"
|
|
type="button"
|
|
@click="handleReset"
|
|
@click="handleReset"
|
|
v-bind="resetButtonOptions"
|
|
v-bind="resetButtonOptions"
|
|
@@ -139,7 +163,6 @@ defineExpose({
|
|
<component
|
|
<component
|
|
:is="COMPONENT_MAP.PrimaryButton"
|
|
:is="COMPONENT_MAP.PrimaryButton"
|
|
v-if="submitButtonOptions.show"
|
|
v-if="submitButtonOptions.show"
|
|
- class="ml-3"
|
|
|
|
type="button"
|
|
type="button"
|
|
@click="handleSubmit"
|
|
@click="handleSubmit"
|
|
v-bind="submitButtonOptions"
|
|
v-bind="submitButtonOptions"
|
|
@@ -152,9 +175,9 @@ defineExpose({
|
|
<slot name="expand-before"></slot>
|
|
<slot name="expand-before"></slot>
|
|
|
|
|
|
<VbenExpandableArrow
|
|
<VbenExpandableArrow
|
|
|
|
+ class="ml-[-0.3em]"
|
|
v-if="rootProps.showCollapseButton"
|
|
v-if="rootProps.showCollapseButton"
|
|
v-model:model-value="collapsed"
|
|
v-model:model-value="collapsed"
|
|
- class="ml-2"
|
|
|
|
>
|
|
>
|
|
<span>{{ collapsed ? $t('expand') : $t('collapse') }}</span>
|
|
<span>{{ collapsed ? $t('expand') : $t('collapse') }}</span>
|
|
</VbenExpandableArrow>
|
|
</VbenExpandableArrow>
|