diff --git a/src/components/Common/fullScreen.tsx b/src/components/Common/fullScreen.tsx index efe92ccbc4349dcf23cea9dfb7a21aca4d6b7bf0..14f1bd748d135a8ca53c9cfc6941b8bf475f4b0e 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 e67b58b3d0788107d5ba1689f83bb3a6f5c81e3c..d0d7391a501027899c08ea63340669f396ff5018 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 4ea9670bf77c2bbf824218df5af521f786488a83..4567975a77e00f53866198b0e572ed91283f59b5 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 6f42a25f55b9420c42368681b0e6ec096218a3ed..b4da071b53f680af6dc5849bd2beda2d1068cf04 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) {