From 8031216cc320ecef03315f25f2e3e22da7e158e3 Mon Sep 17 00:00:00 2001 From: JY <1140938202@qq.com> Date: Tue, 14 Oct 2025 18:53:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=A1=A8=E5=8D=95=EF=BC=8C=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=EF=BC=8C=E4=BF=9D=E5=AD=98=E6=97=B6=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=98=AF=E5=90=A6=E6=9B=B4=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Common/fullScreen.tsx | 12 +++++++----- src/executor/design/formModal/index.tsx | 5 +++-- src/executor/open/reconfirm/index.tsx | 22 +++++++++++++++++++--- src/ts/core/thing/standard/form.ts | 23 +++++++++++++---------- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/components/Common/fullScreen.tsx b/src/components/Common/fullScreen.tsx index efe92ccbc..14f1bd748 100644 --- a/src/components/Common/fullScreen.tsx +++ b/src/components/Common/fullScreen.tsx @@ -21,8 +21,8 @@ import { FileItemShare } from '@/ts/base/model'; interface IFullModalProps extends ModalProps { hideMaxed?: boolean; fullScreen?: boolean; - onSave?: () => void; - onSaveAsync?: () => Promise; + onSave?: (versionType?: string) => void; + onSaveAsync?: (versionType?: string) => Promise; onSaveModal?: () => void; modal?: boolean; icon?: React.ReactNode; @@ -31,6 +31,7 @@ interface IFullModalProps extends ModalProps { bodyHeight?: number | string; isCusClsNames?: boolean; helpDoc?: FileItemShare[]; + typeName?: string; } const FullScreenModal: React.FC = (props) => { const [fileopen, setFileopen] = useState(false); @@ -208,10 +209,11 @@ const FullScreenModal: React.FC = (props) => { <> {(props.onSave || props.onSaveAsync) && ( { - props.onSave && props.onSave(); - props.onSaveAsync && (await props.onSaveAsync()); + onOk={async (versionType?:string) => { + props.onSave && props.onSave(versionType); + props.onSaveAsync && (await props.onSaveAsync(versionType)); setOpen(false); }} onCancel={() => { diff --git a/src/executor/design/formModal/index.tsx b/src/executor/design/formModal/index.tsx index e67b58b3d..d0d7391a5 100644 --- a/src/executor/design/formModal/index.tsx +++ b/src/executor/design/formModal/index.tsx @@ -22,8 +22,9 @@ const FromModal: React.FC = ({ current, finished }: IProps) => { hideMaxed width={'80vw'} destroyOnClose - onSaveAsync={async () => { - await current.save(); + typeName={current.typeName} + onSaveAsync={async (versionType?: string) => { + await current.save(versionType); finished(); }} title={current.name + '(配置)'} diff --git a/src/executor/open/reconfirm/index.tsx b/src/executor/open/reconfirm/index.tsx index 4ea9670bf..4567975a7 100644 --- a/src/executor/open/reconfirm/index.tsx +++ b/src/executor/open/reconfirm/index.tsx @@ -1,14 +1,17 @@ -import { Modal, message } from 'antd'; +import { Modal, message, Radio, Space } from 'antd'; import React, { useState, useEffect, useRef } from 'react'; interface IProps { open: boolean; onOk: Function; onCancel?: () => void; + typeName?: string; } -const Confirm: React.FC = ({ open, onOk, onCancel }) => { +const Confirm: React.FC = ({ open, onOk, onCancel, typeName }) => { const saveStatus = useRef(false); + const typeValues = ['表单', '视图']; + const [versionType, setVersionType] = useState('default'); useEffect(() => { saveStatus.current = false; @@ -27,7 +30,9 @@ const Confirm: React.FC = ({ open, onOk, onCancel }) => { } saveStatus.current = true; setLoading(true); - await onOk(); + const versionStatus = + typeName && typeValues.includes(typeName) && versionType == 'default'; + await onOk(versionStatus ? versionType : undefined); setLoading(false); }} confirmLoading={loading} @@ -36,6 +41,17 @@ const Confirm: React.FC = ({ open, onOk, onCancel }) => { saveStatus.current = false; }}>

您确认进行当前操作吗?

+ {typeName && typeValues.includes(typeName) && ( + setVersionType(e.target.value)} + style={{ width: '100%' }}> + + 使用当前版本(推荐) + 创建新版本 + + + )} ); }; diff --git a/src/ts/core/thing/standard/form.ts b/src/ts/core/thing/standard/form.ts index 6f42a25f5..b4da071b5 100644 --- a/src/ts/core/thing/standard/form.ts +++ b/src/ts/core/thing/standard/form.ts @@ -50,7 +50,7 @@ export interface IForm extends IStandardFileInfo { /** 加载字段 */ loadFields(reload?: boolean): Promise; /** 保存 */ - save(): Promise; + save(versionType?: string): Promise; /** 新建表单特性 */ createAttribute(propertys: schema.XProperty[]): Promise; /** 创建表单视图 */ @@ -236,21 +236,24 @@ export class Form extends StandardFileInfo implements IForm { return false; } - override async update(data: schema.XForm): Promise { + override async update(data: schema.XForm, versionType?: string): Promise { if (data.attributes && data.attributes.length > 0) { const result = await this.coll.replace({ ...data, - id: 'snowId()', + id: versionType && data.id ? data.id : 'snowId()', primaryId: this.primaryId, attributes: [], }); if (result) { - await this.coll.update(this.id, { - _set_: { - applicationId: '', - }, - }); + if (!versionType) { + await this.coll.update(this.id, { + _set_: { + applicationId: '', + }, + }); + } data.attributes = await this.fullAttributes(data.attributes); + await this.attributeColl.deleteMatch({ formId: this.id }); await this.attributeColl.replaceMany( data.attributes.map((a) => { return { @@ -315,9 +318,9 @@ export class Form extends StandardFileInfo implements IForm { } return this.metadata; } - async save(): Promise { + async save(versionType?: string): Promise { resetFormRule(this.metadata); - return this.update(this.metadata); + return this.update(this.metadata, versionType); } override allowMove(destination: IDirectory): boolean { if ('works' in destination) { -- Gitee