fix(table): fix table search criteria collapse failure

This commit is contained in:
vben
2020-11-01 01:07:41 +08:00
parent da4aea1399
commit 84b8302c09
9 changed files with 58 additions and 52 deletions

View File

@@ -24,9 +24,9 @@
</template>
<script lang="ts">
import type { FormActionType, FormProps, FormSchema } from './types/form';
import type { Form as FormType, ValidateFields } from 'ant-design-vue/types/form/form';
import type { AdvanceState } from './types/hooks';
import type { Ref } from 'vue';
import type { ValidateFields } from 'ant-design-vue/lib/form/interface';
import {
defineComponent,
@@ -41,12 +41,13 @@
import { Form, Row } from 'ant-design-vue';
import FormItem from './FormItem';
import { basicProps } from './props';
import { deepMerge } from '/@/utils';
import FormAction from './FormAction';
import { dateItemType } from './helper';
import moment from 'moment';
import { cloneDeep } from 'lodash-es';
import { deepMerge } from '/@/utils';
import { useFormValues } from './hooks/useFormValues';
import useAdvanced from './hooks/useAdvanced';
import { useFormAction } from './hooks/useFormAction';
@@ -75,7 +76,7 @@
const defaultValueRef = ref<any>({});
const propsRef = ref<Partial<FormProps>>({});
const schemaRef = ref<FormSchema[] | null>(null);
const formElRef = ref<Nullable<FormType>>(null);
const formElRef = ref<Nullable<FormActionType>>(null);
const getMergePropsRef = computed(
(): FormProps => {

View File

@@ -1,9 +1,11 @@
import type { ColEx } from './types/index';
import { defineComponent, unref, computed, PropType } from 'vue';
import { Form, Col } from 'ant-design-vue';
import type { ColEx } from './types/index';
import { getSlot } from '/@/utils/helper/tsxHelper';
import Button from '/@/components/Button/index.vue';
import { UpOutlined, DownOutlined } from '@ant-design/icons-vue';
import { BasicArrow } from '/@/components/Basic/index';
import { getSlot } from '/@/utils/helper/tsxHelper';
export default defineComponent({
name: 'BasicFormAction',
@@ -107,11 +109,7 @@ export default defineComponent({
{() => (
<>
{isAdvanced ? '收起' : '展开'}
{isAdvanced ? (
<UpOutlined class="advanced-icon" />
) : (
<DownOutlined class="advanced-icon" />
)}
<BasicArrow expand={!isAdvanced} />
</>
)}
</Button>

View File

@@ -1,7 +1,7 @@
import type { ValidationRule } from 'ant-design-vue/types/form/form';
import type { PropType } from 'vue';
import type { FormProps } from './types/form';
import type { FormSchema } from './types/form';
import type { ValidationRule } from 'ant-design-vue/lib/form/Form';
import { defineComponent, computed, unref, toRef } from 'vue';
import { Form, Col } from 'ant-design-vue';
@@ -54,10 +54,25 @@ export default defineComponent({
};
});
const getShowRef = computed(() => {
const { show, ifShow, isAdvanced } = props.schema;
const getDisableRef = computed(() => {
const { disabled: globDisabled } = props.formProps;
const { dynamicDisabled } = props.schema;
let disabled = !!globDisabled;
if (isBoolean(dynamicDisabled)) {
disabled = dynamicDisabled;
}
if (isFunction(dynamicDisabled)) {
disabled = dynamicDisabled(unref(getValuesRef));
}
return disabled;
});
function getShow() {
const { show, ifShow } = props.schema;
const { showAdvancedButton } = props.formProps;
const itemIsAdvanced = showAdvancedButton ? !!isAdvanced : true;
const itemIsAdvanced = showAdvancedButton ? !!props.schema.isAdvanced : true;
let isShow = true;
let isIfShow = true;
@@ -75,22 +90,7 @@ export default defineComponent({
}
isShow = isShow && itemIsAdvanced;
return { isShow, isIfShow };
});
const getDisableRef = computed(() => {
const { disabled: globDisabled } = props.formProps;
const { dynamicDisabled } = props.schema;
let disabled = !!globDisabled;
if (isBoolean(dynamicDisabled)) {
disabled = dynamicDisabled;
}
if (isFunction(dynamicDisabled)) {
disabled = dynamicDisabled(unref(getValuesRef));
}
return disabled;
});
}
function handleRules(): ValidationRule[] {
const {
@@ -246,7 +246,7 @@ export default defineComponent({
<Form.Item
name={field}
colon={colon}
{...itemProps}
{...(itemProps as any)}
label={renderLabelHelpMessage()}
rules={handleRules()}
labelCol={labelCol}
@@ -261,7 +261,7 @@ export default defineComponent({
if (!componentMap.has(component)) return null;
const { baseColProps = {} } = props.formProps;
const realColProps = { ...baseColProps, ...colProps };
const { isIfShow, isShow } = unref(getShowRef);
const { isIfShow, isShow } = getShow();
const getContent = () => {
return colSlot
? getSlot(slots, colSlot)

View File

@@ -1,6 +1,6 @@
import type { ColEx } from '../types';
import type { AdvanceState } from '../types/hooks';
import type { ComputedRef, Ref } from 'vue';
import { ComputedRef, Ref } from 'vue';
import type { FormProps, FormSchema } from '../types/form';
import { computed, unref, watch } from 'vue';
@@ -69,6 +69,7 @@ export default function ({
actionColOptions,
};
});
watch(
[() => unref(getSchema), () => advanceState.isAdvanced, () => unref(realWidthRef)],
() => {
@@ -169,6 +170,7 @@ export default function ({
itemColSum,
true
);
emit('advanced-change');
}