增加配置项

值变更回调事件增加传参
移动端不绑表字段报错修正
子组件将formModel传给父组件
This commit is contained in:
yaoyn
2024-06-11 17:09:39 +08:00
parent 1e4b1c3452
commit 832c0f94d8
7 changed files with 823 additions and 818 deletions

View File

@ -16,6 +16,8 @@ VITE_DROP_CONSOLE = false
# 接口地址
# 如果没有跨域问题,直接在这里配置即可
VITE_GLOB_API_URL=http://10.133.96.105:8077
# 报表系统地址
VITE_GLOB_REPORT_URL=http://10.133.96.105:3100
# 文件上传接口 可选
VITE_GLOB_UPLOAD_URL = /system/oss/upload
@ -31,3 +33,6 @@ VITE_GLOB_PRINT_BASE_URL = http://114.116.210.204:3300
# 接口地址前缀,有些系统所有接口地址都有前缀,可以在这里统一加,方便切换
VITE_GLOB_API_URL_PREFIX =
# 屏蔽通知消息的轮询
VITE_DISABLE_NEWS=false

View File

@ -259,7 +259,7 @@
const val = Array.isArray(value) ? value.join(',') : value;
emitData.value = args;
emit('update:value', val);
emit('change', val);
emit('change', val, args);
selectedValue.value = props.value === undefined ? val : (((typeof props.value === 'string' && !!props.value ? props.value?.split(',') : props.value) || undefined) as any);
updateSepTextField(Array.isArray(value) ? value : [value]);
}

View File

@ -1,12 +1,16 @@
<template>
<div ref="formWrap">
<Form ref="formRef" :label-col="getProps?.labelCol" :labelAlign="getProps?.labelAlign" :layout="getProps?.layout" :model="formModel" :wrapper-col="getProps?.wrapperCol" @keypress.enter="handleEnterPress">
<Form ref="formRef" :label-col="getProps?.labelCol" :labelAlign="getProps?.labelAlign"
:layout="getProps?.layout" :model="formModel" :wrapper-col="getProps?.wrapperCol"
@keypress.enter="handleEnterPress">
<Row v-bind="getRow">
<template v-for="schema in getSchemas" :key="schema.field">
<Col v-if="getIfShow(schema, formModel[schema.field])" v-show="getIsShow(schema, formModel[schema.field])" :span="getColWidth(schema)">
<Col v-if="getIfShow(schema, formModel[schema.field])"
v-show="getIsShow(schema, formModel[schema.field])" :span="getColWidth(schema)">
<div v-if="schema?.componentProps.respBreakLine" style="width: 100%; height: 1px"></div>
<template v-if="showComponent(schema) && schema.type !== 'slot'">
<SimpleFormItem v-model:value="formModel[schema.field]" :form-api="formApi" :isWorkFlow="isWorkFlow" :refreshFieldObj="refreshFieldObj" :schema="schema" />
<SimpleFormItem v-model:value="formModel[schema.field]" :form-api="formApi"
:isWorkFlow="isWorkFlow" :refreshFieldObj="refreshFieldObj" :schema="schema" />
</template>
<template v-if="schema.type === 'slot'">
<slot :formModel="formModel" :name="schema.slotName" :schema="schema"></slot>
@ -199,6 +203,7 @@
provide('formProps', getProps);
provide('isCustomForm', isCustom || props.isWorkFlow);
provide('isCamelCase', props.isCamelCase);
formData.formModel=formModel;
const handleSubmit = async () => {
try {
const { submitFunc } = unref(getProps);

View File

@ -85,6 +85,16 @@
>
<template v-if="getDisable && readonlySupport(schema.component)">
<readonly :schema="schema" :model="formModel"/>
<component
:is="componentMap.get(schema.component)"
v-show="false"
v-model:endField="schema.field.split(',')[1]"
v-model:startField="schema.field.split(',')[0]"
v-model:value="formModel![schema.field]"
:disabled="getDisable"
:size="formProps?.size"
v-bind="schema.componentProps"
/>
</template>
<template v-else>
<component
@ -303,13 +313,13 @@
} else if (typeof fun === 'function') {
event = fun;
}
componentProps['on' + upperFirst(eventKey)] = function () {
componentProps['on' + upperFirst(eventKey)] = function (value, selectedOptions) {
let cloneFormModel = cloneDeep(formModel);
for (let item in cloneFormModel) {
let field = camelCaseString(item);
if (field) cloneFormModel[field] = cloneFormModel[item];
}
event(props.schema, isCamelCase ? cloneFormModel : formModel, props.formApi, { formData });
event(props.schema, isCamelCase ? cloneFormModel : formModel, props.formApi, { formData, value, selectedOptions });
if (isCamelCase) {
for (let item in formModel) {

View File

@ -22,21 +22,10 @@ export function getAppEnvConfig() {
(import.meta.env as unknown as GlobEnvConfig)
: window[ENV_NAME as any]) as unknown as GlobEnvConfig;
const {
VITE_GLOB_APP_TITLE,
VITE_GLOB_API_URL,
VITE_GLOB_APP_SHORT_NAME,
VITE_GLOB_API_URL_PREFIX,
VITE_GLOB_UPLOAD_URL,
VITE_GLOB_UPLOAD_PREVIEW,
VITE_GLOB_OUT_LINK_URL,
VITE_GLOB_PRINT_BASE_URL,
} = ENV;
const { VITE_GLOB_APP_TITLE, VITE_GLOB_API_URL, VITE_GLOB_APP_SHORT_NAME, VITE_GLOB_API_URL_PREFIX, VITE_GLOB_UPLOAD_URL, VITE_GLOB_UPLOAD_PREVIEW, VITE_GLOB_OUT_LINK_URL, VITE_GLOB_REPORT_URL, VITE_GLOB_PRINT_BASE_URL } = ENV;
if (!/^[a-zA-Z\_]*$/.test(VITE_GLOB_APP_SHORT_NAME)) {
warn(
`VITE_GLOB_APP_SHORT_NAME Variables can only be characters/underscores, please modify in the environment variables and re-running.`,
);
warn(`VITE_GLOB_APP_SHORT_NAME Variables can only be characters/underscores, please modify in the environment variables and re-running.`);
}
return {
@ -47,7 +36,8 @@ export function getAppEnvConfig() {
VITE_GLOB_UPLOAD_URL,
VITE_GLOB_UPLOAD_PREVIEW,
VITE_GLOB_OUT_LINK_URL,
VITE_GLOB_PRINT_BASE_URL,
VITE_GLOB_REPORT_URL,
VITE_GLOB_PRINT_BASE_URL
};
}

View File

@ -498,7 +498,8 @@
}
// TODO 这里继续写各组件自己特有的一些验证
if (!component.bindTable) {
if ((component.type == 'input' && !component.options!.isSave && !component.bindTable) ||
(component.type !== 'input' && !component.bindTable)) {
return t(`{name}未绑定表`, { name: component.label });
}

10
types/config.d.ts vendored
View File

@ -1,12 +1,5 @@
import { MenuTypeEnum, MenuModeEnum, TriggerEnum, MixSidebarTriggerEnum } from '/@/enums/menuEnum';
import {
ContentEnum,
PermissionModeEnum,
ThemeEnum,
RouterTransitionEnum,
SettingButtonPositionEnum,
SessionTimeoutProcessingEnum,
} from '/@/enums/appEnum';
import { ContentEnum, PermissionModeEnum, ThemeEnum, RouterTransitionEnum, SettingButtonPositionEnum, SessionTimeoutProcessingEnum } from '/@/enums/appEnum';
import { CacheTypeEnum } from '/@/enums/cacheEnum';
@ -166,6 +159,7 @@ export interface GlobEnvConfig {
VITE_GLOB_PRINT_BASE_URL?: string;
//file preview
VITE_GLOB_UPLOAD_PREVIEW?: string;
VITE_GLOB_REPORT_URL: string;
}
export interface LogoConfig {