mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-26 12:48:48 +08:00
parent
d7f5dfeb9f
commit
3de5b53bcd
@ -64,7 +64,6 @@
|
|||||||
import { basicProps } from './props';
|
import { basicProps } from './props';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign';
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
import { isFunction, isArray } from '/@/utils/is';
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'BasicForm',
|
name: 'BasicForm',
|
||||||
@ -245,14 +244,11 @@
|
|||||||
|
|
||||||
function setFormModel(key: string, value: any, schema: FormSchema) {
|
function setFormModel(key: string, value: any, schema: FormSchema) {
|
||||||
formModel[key] = value;
|
formModel[key] = value;
|
||||||
const { validateTrigger } = unref(getBindValue);
|
emit('field-value-change', key, value);
|
||||||
if (isFunction(schema.dynamicRules) || isArray(schema.rules)) {
|
// TODO 优化验证,这里如果是autoLink=false手动关联的情况下才会再次触发此函数
|
||||||
return;
|
if (schema && schema.itemProps && !schema.itemProps.autoLink) {
|
||||||
}
|
|
||||||
if (!validateTrigger || validateTrigger === 'change') {
|
|
||||||
validateFields([key]).catch((_) => {});
|
validateFields([key]).catch((_) => {});
|
||||||
}
|
}
|
||||||
emit('field-value-change', key, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEnterPress(e: KeyboardEvent) {
|
function handleEnterPress(e: KeyboardEvent) {
|
||||||
|
@ -9,7 +9,11 @@
|
|||||||
import { BasicHelp } from '/@/components/Basic';
|
import { BasicHelp } from '/@/components/Basic';
|
||||||
import { isBoolean, isFunction, isNull } from '/@/utils/is';
|
import { isBoolean, isFunction, isNull } from '/@/utils/is';
|
||||||
import { getSlot } from '/@/utils/helper/tsxHelper';
|
import { getSlot } from '/@/utils/helper/tsxHelper';
|
||||||
import { createPlaceholderMessage, setComponentRuleType } from '../helper';
|
import {
|
||||||
|
createPlaceholderMessage,
|
||||||
|
NO_AUTO_LINK_COMPONENTS,
|
||||||
|
setComponentRuleType,
|
||||||
|
} from '../helper';
|
||||||
import { cloneDeep, upperFirst } from 'lodash-es';
|
import { cloneDeep, upperFirst } from 'lodash-es';
|
||||||
import { useItemLabelWidth } from '../hooks/useLabelWidth';
|
import { useItemLabelWidth } from '../hooks/useLabelWidth';
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
@ -347,6 +351,15 @@
|
|||||||
const showSuffix = !!suffix;
|
const showSuffix = !!suffix;
|
||||||
const getSuffix = isFunction(suffix) ? suffix(unref(getValues)) : suffix;
|
const getSuffix = isFunction(suffix) ? suffix(unref(getValues)) : suffix;
|
||||||
|
|
||||||
|
// TODO 自定义组件验证会出现问题,因此这里框架默认将自定义组件设置手动触发验证,如果其他组件还有此问题请手动设置autoLink=false
|
||||||
|
if (NO_AUTO_LINK_COMPONENTS.includes(component)) {
|
||||||
|
props.schema &&
|
||||||
|
(props.schema.itemProps! = {
|
||||||
|
autoLink: false,
|
||||||
|
...props.schema.itemProps,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name={field}
|
name={field}
|
||||||
|
@ -72,3 +72,16 @@ export function handleInputNumberValue(component?: ComponentType, val?: any) {
|
|||||||
export const dateItemType = genType();
|
export const dateItemType = genType();
|
||||||
|
|
||||||
export const defaultValueComponents = ['Input', 'InputPassword', 'InputSearch', 'InputTextArea'];
|
export const defaultValueComponents = ['Input', 'InputPassword', 'InputSearch', 'InputTextArea'];
|
||||||
|
|
||||||
|
// TODO 自定义组件封装会出现验证问题,因此这里目前改成手动触发验证
|
||||||
|
export const NO_AUTO_LINK_COMPONENTS: ComponentType[] = [
|
||||||
|
'Upload',
|
||||||
|
'ApiTransfer',
|
||||||
|
'ApiTree',
|
||||||
|
'ApiSelect',
|
||||||
|
'ApiTreeSelect',
|
||||||
|
'ApiRadioGroup',
|
||||||
|
'ApiCascader',
|
||||||
|
'AutoComplete',
|
||||||
|
'RadioButtonGroup',
|
||||||
|
];
|
||||||
|
@ -41,9 +41,7 @@ export function useRuleFormItem<T extends Recordable>(
|
|||||||
if (isEqual(value, defaultState.value)) return;
|
if (isEqual(value, defaultState.value)) return;
|
||||||
|
|
||||||
innerState.value = value as T[keyof T];
|
innerState.value = value as T[keyof T];
|
||||||
setTimeout(() => {
|
emit?.(changeEvent, value, ...(toRaw(unref(emitData)) || []));
|
||||||
emit?.(changeEvent, value, ...(toRaw(unref(emitData)) || []));
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@
|
|||||||
import { Select } from 'ant-design-vue';
|
import { Select } from 'ant-design-vue';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
import { areaRecord } from '/@/api/demo/cascader';
|
import { areaRecord } from '/@/api/demo/cascader';
|
||||||
|
import { uploadApi } from '/@/api/sys/upload';
|
||||||
|
|
||||||
const valueSelectA = ref<string[]>([]);
|
const valueSelectA = ref<string[]>([]);
|
||||||
const valueSelectB = ref<string[]>([]);
|
const valueSelectB = ref<string[]>([]);
|
||||||
@ -189,6 +190,18 @@
|
|||||||
},
|
},
|
||||||
suffix: '天',
|
suffix: '天',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
field: 'fieldsc',
|
||||||
|
component: 'Upload',
|
||||||
|
label: '上传',
|
||||||
|
colProps: {
|
||||||
|
span: 8,
|
||||||
|
},
|
||||||
|
rules: [{ required: true, message: '请选择上传文件' }],
|
||||||
|
componentProps: {
|
||||||
|
api: uploadApi,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'field3',
|
field: 'field3',
|
||||||
component: 'DatePicker',
|
component: 'DatePicker',
|
||||||
|
Loading…
Reference in New Issue
Block a user