!2749 功能:分享图纸命令添加有效天数参数设置

pull/2516/MERGE
黄诗津 4 months ago committed by ChenX
parent de61b736b7
commit b09df3ffd9

@ -101,6 +101,8 @@ export class Command_ShareView implements Command
formData.append("logo", GetCurrentViewPreViewImage() as Blob, "cover.jpg");
formData.append("file", deflate(f.ToString()));
formData.append("props", props);
if (store.m_Option.expireDays)
formData.append("expire_days", store.m_Option.expireDays);
fetch(CURRENT_HOST + "/CAD-viewerUpload", {
method: "POST",

@ -1,6 +1,7 @@
import { observable, toJS } from "mobx";
import { Singleton } from "../../Common/Singleton";
import { safeEval } from "../../Common/eval";
import { Board } from "../../DatabaseServices/Entity/Board";
import { DefaultShareBoardInfConfigurationOption } from "../../Editor/DefaultConfig";
import { IConfigOption } from "../../UI/Components/Board/UserConfigComponent";
@ -48,6 +49,14 @@ export class ShareViewStore extends Singleton implements IConfigStore
@observable viewUploadProps: ShareBoardInfConfigurationOption = DefaultShareBoardInfConfigurationOption;
@observable configName = "默认";
HasInvailValue()
{
let val = safeEval(this.m_Option.expireDays);
if (this.m_Option.expireDays !== "" && (isNaN(val) || val != Math.floor(val) || val <= 0))
return "有效天数必须是大于0的整数";
return "";
}
SaveConfig()
{
//新的配置
@ -63,6 +72,11 @@ export class ShareViewStore extends Singleton implements IConfigStore
}
UpdateOption(cof: IConfigOption<ShareBoardInfConfigurationOption>)
{
if (!cof.option.version)
{
cof.option.version = 1;
cof.option.expireDays = "";
}
Object.assign(this.m_Option, cof.option);
}

@ -109,7 +109,7 @@ export function ColorSelect({ value, onChange, options }: SelectProps)
setIsOpen(false);
}}
onMouseEnter={() => setHighlightedIndex(index)}
key={option.value}
key={option.label.toString()}
className={`option ${isOptionSelected(index) ? "selected" : ""} ${index === highlightedIndex ? "highlighted" : ""}`}
>
<span> {option.label}. </span>

@ -3,11 +3,12 @@ import { observer } from "mobx-react";
import React from "react";
import { begin } from "xaop";
import { app } from "../../../ApplicationServices/Application";
import { CheckObjectType } from "../../../Common/CheckoutVaildValue";
import { ColorPalette } from "../../../Common/ColorPalette";
import { KeyBoard } from "../../../Common/KeyEnum";
import { BoardModalType } from "../../../UI/Components/Board/BoardModalType";
import { Config_ModalType, UserConfigComponent } from "../../../UI/Components/Board/UserConfigComponent";
import { AppToaster } from "../../../UI/Components/Toaster";
import { AppToaster, ToasterInput } from "../../../UI/Components/Toaster";
import { ViewAngleTypes, ViewStyleTypes } from "../ShareViewRules";
import { ShareViewStore } from "../ShareViewStore";
import { ColorSelect } from "./ColorSelect";
@ -129,6 +130,12 @@ export class ShareBoardInfoConfiguration extends React.Component<{ store: ShareV
onChange={(e) => { option.VisualStyle = parseInt(e.target.value); }}
/>
</div>
<div className="label">
<span>:</span>
<ToasterInput
inputClassName={"expire-days"}
type={CheckObjectType.ExpireDays} option={option} optKey="expireDays" />
</div>
</div>
<div className={Classes.DIALOG_FOOTER} >
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
@ -137,7 +144,20 @@ export class ShareBoardInfoConfiguration extends React.Component<{ store: ShareV
<Button
intent={Intent.SUCCESS}
text="确定"
onClick={() => { app.Editor.ModalManage.DestoryAndExec(); }}
onClick={() =>
{
let v = this.props.store.HasInvailValue();
if (v)
{
AppToaster.show({
message: v,
timeout: 3000,
intent: Intent.DANGER,
});
return;
}
app.Editor.ModalManage.DestoryAndExec();
}}
/>
</div>
</div>

@ -6,6 +6,13 @@
label{
width: fit-content;
}
.label {
.bp3-input.expire-days {
height: 28px;
width: 95px;
}
}
}
.bp3-dialog-footer{

@ -24,6 +24,7 @@ export enum CheckObjectType
BF = "boardFind",//查找修改
CONF = "configuration",//配置
Modeling2Depth = "modeling2Depth",// 大于0且支持BH
ExpireDays = "expireDays", //过期天数
}
export namespace CheckoutValid
@ -90,6 +91,7 @@ export namespace CheckoutValid
}
export function CheckOption(type: CheckObjectType, k: string, v: string)
{
let val: number;
switch (type)
{
case CheckObjectType.BR:
@ -133,7 +135,7 @@ export namespace CheckoutValid
case CheckObjectType.SmoothEdge:
if (!isNum(v))
return "数值不能为空且必须为数字";
let val = safeEval(v);
val = safeEval(v);
if (val < 0)
return "数值不能小于0";
case CheckObjectType.Modeling2Depth:
@ -143,6 +145,10 @@ export namespace CheckoutValid
return "表达式错误";
if (safeEval(v) < 0)
return "数值不能小于0";
case CheckObjectType.ExpireDays:
val = safeEval(v);
if (v !== "" && (isNaN(val) || val != Math.floor(val) || val <= 0))
return "请输入大于0的整数";
default:
return "";
}

@ -1061,12 +1061,14 @@ export const DefaultChangeColorByBoardMaterialOption: ChangeColorByBoardMaterial
Object.freeze(DefaultChangeColorByBoardMaterialOption);
export const DefaultShareBoardInfConfigurationOption: ShareBoardInfConfigurationOption = {
version: 1,
Physical2EdgeColor: 7,
VisualStyle: RenderType.Conceptual,
Viewport: ViewDirection.Southwest,
IsExportBoard: true,
IsExportHardware: true,
showBom: true,
expireDays: "",
};
Object.freeze(DefaultShareBoardInfConfigurationOption);

@ -313,7 +313,7 @@ export interface ChangeColorByBoardMaterialOption
accordMaterialColor: boolean;
}
export interface ShareBoardInfConfigurationOption
export interface ShareBoardInfConfigurationOption extends IBaseOption
{
Physical2EdgeColor: number; //真实带线框颜色
VisualStyle: RenderType; //视觉样式
@ -321,6 +321,7 @@ export interface ShareBoardInfConfigurationOption
IsExportBoard: boolean; //是否导出板件
IsExportHardware: boolean; //是否导出五金
showBom: boolean; //是否展示物料明细
expireDays: string; //有效天数
}
export interface ProcessingGroupOption

Loading…
Cancel
Save