!1600 优化:模板设计时,参数锁定后,表达式不能修改

pull/1602/MERGE
黄诗津 3 years ago committed by ChenX
parent 981fa5872c
commit bcb251b36c

@ -35,6 +35,8 @@ export class TemplateParam
@AutoRecord option: any[]; @AutoRecord option: any[];
@AutoRecord actions: TemplateAction[]; @AutoRecord actions: TemplateAction[];
@AutoRecord parent: TemplateRecord; @AutoRecord parent: TemplateRecord;
@AutoRecord isLock = false;
constructor() constructor()
{ {
//监听 //监听
@ -177,11 +179,14 @@ export class TemplateParam
this.actions.length = 0; this.actions.length = 0;
for (let i = 0; i < count; i++) for (let i = 0; i < count; i++)
this.actions.push(file.ReadObject()); this.actions.push(file.ReadObject());
if (ver > 1)
this.isLock = file.Read();
} }
//对象将自身数据写入到文件. //对象将自身数据写入到文件.
WriteFile(file: CADFiler) WriteFile(file: CADFiler)
{ {
file.Write(1); file.Write(2);
file.Write(this.name); file.Write(this.name);
file.Write(this.expr); file.Write(this.expr);
file.Write(this.value); file.Write(this.value);
@ -193,8 +198,8 @@ export class TemplateParam
file.Write(this.option); file.Write(this.option);
file.Write(this.actions.length); file.Write(this.actions.length);
for (let action of this.actions) for (let action of this.actions)
{
file.WriteObject(action); file.WriteObject(action);
}
file.Write(this.isLock);
} }
} }

@ -557,6 +557,7 @@ export class TemplateParamDetail extends React.Component<{}> {
value={par.expr as string} value={par.expr as string}
onChange={e => par.expr = e.target.value as string} onChange={e => par.expr = e.target.value as string}
onBlur={(e) => { this.ChangeInputUIClass(par); }} onBlur={(e) => { this.ChangeInputUIClass(par); }}
disabled={par.isLock}
/> />
</li> </li>
); );

@ -297,6 +297,7 @@ export class TempalteActionDialog extends React.Component<ITempalteActionDialogP
param.name = this.pararmConfig.name; param.name = this.pararmConfig.name;
param.value = safeEval(this.pararmConfig.value as string); param.value = safeEval(this.pararmConfig.value as string);
param.description = this.pararmConfig.description; param.description = this.pararmConfig.description;
param.isLock = this.pararmConfig.isLock;
template.Params.push(param); template.Params.push(param);
this.props.store.params.push(this.pararmConfig); this.props.store.params.push(this.pararmConfig);
this.props.store.usedParamNames.add(param.name); this.props.store.usedParamNames.add(param.name);

@ -169,7 +169,7 @@ export class TemplateDetail extends React.Component<ITemplateDetailProps> {
className={Classes.INPUT} className={Classes.INPUT}
value={par.expr as string} value={par.expr as string}
onChange={e => par.expr = e.target.value} onChange={e => par.expr = e.target.value}
disabled={disabledKeys.includes(par.name)} disabled={disabledKeys.includes(par.name) || par.isLock}
onBlur={e => onBlur={e =>
{ {
if (this.props.onBlur) if (this.props.onBlur)

@ -132,6 +132,7 @@ export class TemplateList extends React.Component<ITemplateListProps> {
value: p.value, value: p.value,
description: p.description, description: p.description,
expr: p.expr, expr: p.expr,
isLock: p.isLock
}; };
})); }));

@ -104,7 +104,11 @@ export default class TemplateParamList extends React.Component<ITemplateParamLis
<input <input
type="checkbox" type="checkbox"
checked={opt.isLock} checked={opt.isLock}
onChange={() => opt.isLock = !opt.isLock} onChange={() =>
{
opt.isLock = !opt.isLock;
this.updateTempalteParam(opt);
}}
/> />
</label> </label>
</li> </li>
@ -271,6 +275,7 @@ export default class TemplateParamList extends React.Component<ITemplateParamLis
par.value = val; par.value = val;
par.expr = opt.expr; par.expr = opt.expr;
par.description = opt.description; par.description = opt.description;
par.isLock = opt.isLock;
}, "修改参数值"); }, "修改参数值");
}; };
private moveTemplateParam = (isUp: boolean) => private moveTemplateParam = (isUp: boolean) =>

@ -427,7 +427,8 @@ export class TemplateParamPanelStore
value: p.value, value: p.value,
description: p.description, description: p.description,
expr: isNaN(Number(p.expr)) ? p.expr : FixedNotZero(p.expr, 2), expr: isNaN(Number(p.expr)) ? p.expr : FixedNotZero(p.expr, 2),
isValidExpr: true isValidExpr: true,
isLock: p.isLock
}; };
})); }));
} }

@ -35,7 +35,7 @@ export class TempalteEditorStore extends Singleton implements IConfigStore
value: FixedNotZero(par.value, 2), value: FixedNotZero(par.value, 2),
description: par.description, description: par.description,
expr: par.expr, expr: par.expr,
isLock: false isLock: par.isLock
}); });
} }
} }

Loading…
Cancel
Save