!2152 新增:选择隐藏功能面板增加自定义板名

pull/2190/MERGE
林三 1 year ago committed by ChenX
parent e6943f2f8a
commit b55291312f

@ -209,7 +209,7 @@ export class BoardFindModify implements Command
let names = option.brName.split(",");
if (arrayLast(names) === "")
names.pop();
isVail = names.some(n => this.CompareIsEqual(brValue, n, option.compareType.brName));
isVail = names.some(n => CompareIsEqual(brValue, n, option.compareType.brName));
break;
case EBoardKeyList.Mat:
brValue = br.BoardProcessOption[EBoardKeyList.Mat];
@ -220,11 +220,11 @@ export class BoardFindModify implements Command
let bMat = option[EBoardKeyList.BrMat];
let isVailMat = (!value && option.compareType[EBoardKeyList.Mat] === ECompareType.Equal)
|| this.CompareIsEqual(brValue, value, option.compareType[EBoardKeyList.Mat]);
|| CompareIsEqual(brValue, value, option.compareType[EBoardKeyList.Mat]);
let isVailColor = (!color && option.compareType[EBoardKeyList.Color] === ECompareType.Equal)
|| this.CompareIsEqual(bColor, color, option.compareType[EBoardKeyList.Color]);
|| CompareIsEqual(bColor, color, option.compareType[EBoardKeyList.Color]);
let isVailBMat = (!bMat && option.compareType[EBoardKeyList.BrMat] === ECompareType.Equal)
|| this.CompareIsEqual(bbMat, bMat, option.compareType[EBoardKeyList.BrMat]);
|| CompareIsEqual(bbMat, bMat, option.compareType[EBoardKeyList.BrMat]);
isVail = isVailMat && isVailColor && isVailBMat;
break;
@ -236,7 +236,7 @@ export class BoardFindModify implements Command
case EBoardKeyList.ComposingFace:
brValue = br.BoardProcessOption[i];
value = option[i];
isVail = this.CompareIsEqual(brValue, value, option.compareType[i]);
isVail = CompareIsEqual(brValue, value, option.compareType[i]);
break;
case EBoardKeyList.UpSealed:
case EBoardKeyList.DownSealed:
@ -244,7 +244,7 @@ export class BoardFindModify implements Command
case EBoardKeyList.RightSealed:
brValue = br.BoardProcessOption[i];
value = option[i];
isVail = this.CompareIsEqual(brValue, value, ECompareType.Equal);
isVail = CompareIsEqual(brValue, value, ECompareType.Equal);
break;
case "upDrill":
case "downDrill":
@ -253,7 +253,7 @@ export class BoardFindModify implements Command
let index = DRILL_KEYS.indexOf(i);
brValue = br.BoardProcessOption.highDrill[index];
value = option.highDrill[index];
isVail = this.CompareIsEqual(brValue, value, ECompareType.Equal);
isVail = CompareIsEqual(brValue, value, ECompareType.Equal);
break;
case "useKeyWord":
let brRemarks = br.BoardProcessOption.remarks;
@ -307,22 +307,7 @@ export class BoardFindModify implements Command
return false;
}
}
private CompareIsEqual(brValue: string | number, value: string | number, type: ECompareType)
{
if (type === ECompareType.Equal)
return brValue === value;
else if (type === ECompareType.Include)
{
let exp = value.toString().split("").map(this.regExpEscape).join('.*') + '.*$';
return brValue.toString().match(exp) && brValue.toString().match(exp).length > 0;
}
else
return brValue !== value;
}
regExpEscape(s)
{
return s.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
}
private async ModifyBrs(option: IBoardFindOption)
{
let brs = await this.GetBoards([HardwareTopline, HardwareCompositeEntity], true);
@ -665,23 +650,23 @@ export class BoardFindModify implements Command
let bColor = br.HardwareOption[EBoardKeyList.Color];
let color = option[EBoardKeyList.Color];
let isVailMat = (!value && option.compareType[EBoardKeyList.Mat] === ECompareType.Equal)
|| this.CompareIsEqual(brValue, value, option.compareType[EBoardKeyList.Mat]);
|| CompareIsEqual(brValue, value, option.compareType[EBoardKeyList.Mat]);
let isVailColor = (!color && option.compareType[EBoardKeyList.Color] === ECompareType.Equal)
|| this.CompareIsEqual(bColor, color, option.compareType[EBoardKeyList.Color]);
|| CompareIsEqual(bColor, color, option.compareType[EBoardKeyList.Color]);
isVail = !option[EBoardKeyList.BrMat] && isVailMat && isVailColor;
break;
case EBoardKeyList.RoomName:
case EBoardKeyList.CabinetName:
brValue = br.HardwareOption[i];
value = option[i];
isVail = this.CompareIsEqual(brValue, value, option.compareType[i]);
isVail = CompareIsEqual(brValue, value, option.compareType[i]);
break;
case "hardwareName":
brValue = br.HardwareOption.name;
let names = option[i].split(",");
if (arrayLast(names) === "")
names.pop();
isVail = names.some(n => this.CompareIsEqual(brValue, n, option.compareType[i]));
isVail = names.some(n => CompareIsEqual(brValue, n, option.compareType[i]));
break;
default:
isVail = false;
@ -695,3 +680,48 @@ export class BoardFindModify implements Command
return hadVailCondition;
}
}
function regExpEscape(str: string)
{
return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
}
/**
* @param {(string[] | number[])} [values]
*/
export function CompareIsEqual(brValue: string | number, value: string | number, type: ECompareType, values?: string[])
{
if (type === ECompareType.Equal)
{
if (values)
return values.includes(brValue.toString());
else
return brValue === value;
}
else if (type === ECompareType.Include) //模糊匹配
{
const getExp = (value: string | number) =>
{
return value.toString().split("").map(regExpEscape).join('.*') + '.*$';
};
if (values) //多个匹配项
{
for (let value of values)
{
let exp = getExp(value);
if (brValue.toString().match(exp) && brValue.toString().match(exp).length > 0)
return true;
}
return false;
}
else
{
//单个匹配项
let exp = getExp(value);
return brValue.toString().match(exp) && brValue.toString().match(exp).length > 0;
}
}
else
return brValue !== value;
}

@ -834,7 +834,7 @@ export const DefaultR2b2Option: IRect2Br2Option = {
Object.freeze(DefaultR2b2Option);
export const DefaultHSOption: IHSOption = {
version: 1,
version: 3,
isAll: true,
isHide: true,
isDelete: false,
@ -861,7 +861,10 @@ export const DefaultHSOption: IHSOption = {
line: false,
polyline: false,
circle: false,
arc: false
arc: false,
custom: false,
customBoardName: "",
matchType: ECompareType.Equal
};
export const DefaultCommonPanelOption: CommonPanelConfigOption = {

@ -0,0 +1,39 @@
.selectHide {
.bp3-checkbox {
width: 80px;
margin-right: 10px;
}
.shcustom {
width: 335px;
display: flex;
margin-right: 0;
input::-webkit-input-placeholder {
/*WebKit browsers*/
color: #aaa
}
input::-moz-input-placeholder {
/*Mozilla Firefox*/
color: #aaa
}
input::-ms-input-placeholder {
/*Internet Explorer*/
color: #aaa
}
.bp3-checkbox {
width: 55px;
margin-right: 0px;
}
.bp3-html-select {
margin: -1.5px 0 0 6px;
}
}
}

@ -1,6 +1,7 @@
import { Button, Card, Checkbox, H5, Intent, Radio, RadioGroup } from '@blueprintjs/core';
import { Button, Card, Checkbox, H5, HTMLSelect, Intent, Radio, RadioGroup, Tooltip } from '@blueprintjs/core';
import { observer } from 'mobx-react';
import React from 'react';
import { CompareIsEqual } from '../../../Add-on/BoardFindModify';
import { isDingDiBan, IsDoor, IsDrawer, IsHandle, IsHinge, IsLattice, IsWinerack } from '../../../Add-on/HideSelect/HideSelectUtils';
import { app } from '../../../ApplicationServices/Application';
import { arrayRemoveIf } from '../../../Common/ArrayExt';
@ -24,11 +25,13 @@ import { TemplateRecord } from '../../../DatabaseServices/Template/TemplateRecor
import { CommandWrap } from '../../../Editor/CommandMachine';
import { PromptStatus } from '../../../Editor/PromptResult';
import { SelectSetBase } from '../../../Editor/SelectBase';
import { ECompareType } from '../../Store/BoardFindInterface';
import { BoardType } from '../../Store/BoardInterface';
import { HideSelectStore } from '../../Store/HideSelectStore';
import { IHSOption } from '../../Store/HSInterface';
import { BoardModalType } from "../Board/BoardModalType";
import { Config_ModalType } from '../Board/UserConfigComponent';
import './HideSelectModal.less';
import { CommonModal } from './ModalContainer';
@ -63,12 +66,13 @@ export const KEY2LABEL: AllString<IHSOption> = {
polyline: "多段线",
circle: "圆",
arc: "圆弧",
custom: '板名',
};
const Board_KEYS = [
const BOARD_KEYS = [
"layer", "behind", "vertial", "footer", "tbBoard",
"closingStrip", "specialShape", "door", "drawer", "winerack",
"lattice",
"lattice", "custom",
];
const HOLE_KEYS = [
"hole", "wood", "nails"
@ -83,16 +87,15 @@ const OTHERS = [
"dim"
];
const KEYS: [string, string[]][] = [
["板件类", Board_KEYS], ["孔类", HOLE_KEYS], ["五金组件类", HW_KEYS], ["曲线类", CURVE_KEYS], ["其他", OTHERS]
["板件类", BOARD_KEYS], ["孔类", HOLE_KEYS], ["五金组件类", HW_KEYS], ["曲线类", CURVE_KEYS], ["其他", OTHERS]
];
@observer
export class HideSelectModal extends React.Component<{ store: HideSelectStore; hideEntitys: Entity[]; }>
{
render()
{
const { store } = this.props;
const store = this.props.store;
const option = store.m_Option;
return (
@ -117,7 +120,7 @@ export class HideSelectModal extends React.Component<{ store: HideSelectStore; h
</>
}
>
<Card style={{ width: 430 }}>
<Card className='selectHide' style={{ width: 430 }}>
<div>
<RadioGroup selectedValue={option.isHide ? 1 : option.isDelete ? 2 : 0} inline onChange={this.toggle}>
<Radio value={1} label="使用隐藏功能" />
@ -137,14 +140,42 @@ export class HideSelectModal extends React.Component<{ store: HideSelectStore; h
d[1].map(k =>
{
return (
<div className={"sh" + k}>
<Checkbox
key={k}
style={{ width: "80px", marginRight: 10 }}
disabled={Boolean(this.isDisable(k))}
label={KEY2LABEL[k]}
checked={option[k]}
onChange={() => this.change(k)}
/>
{
k === "custom" &&
<div>
<Tooltip content={option[k] ? "勾选后不可修改" : "多个板名可以用 逗号 或 空格 相隔"}>
<input
className='bp3-input'
style={{ height: 22, width: 187, margin: "-1px 0 0 2px" }}
placeholder={'自定义板名...'}
value={option.customBoardName}
readOnly={option[k]}
onKeyUp={(e) => { e.currentTarget.value = e.currentTarget.value.replaceAll(//g, ','); }}
onChange={(e) => { option.customBoardName = e.currentTarget.value; }}
/>
</Tooltip>
<HTMLSelect
options={
[
{ label: "完全匹配", value: ECompareType.Equal },
{ label: "模糊匹配", value: ECompareType.Include },
]
}
style={{ height: 22.5 }}
value={option.matchType}
onChange={e => option.matchType = e.currentTarget.value as ECompareType}
/>
</div>
}
</div>
);
})
}
@ -177,7 +208,7 @@ export class HideSelectModal extends React.Component<{ store: HideSelectStore; h
/>
</div>
</Card>
</CommonModal>
</CommonModal >
);
}
private isDisable = (k: string) =>
@ -323,6 +354,8 @@ export class HideSelectModal extends React.Component<{ store: HideSelectStore; h
{
let store = new HideSelectStore();
store.m_Option[key] = true;
store.m_Option.customBoardName = option.customBoardName;
store.m_Option.matchType = option.matchType;
option = store.m_Option;
}
@ -366,6 +399,23 @@ export class HideSelectModal extends React.Component<{ store: HideSelectStore; h
{
if (resEntSet.has(b) || disEns.has(b)) continue;
if (option.custom)
{
let nameList = [];
let nameList1 = option.customBoardName.split(" ");
for (let item of nameList1)
nameList.push(...item.split(","));
nameList = nameList.filter(item => item !== ""); //过滤空字符
if (CompareIsEqual(b.Name, null, option.matchType, nameList))
{
resEntSet.add(b);
continue;
}
}
if (option.specialShape)
{
if (b.IsSpecialShape)
@ -442,7 +492,6 @@ export class HideSelectModal extends React.Component<{ store: HideSelectStore; h
continue;
}
}
}
for (let hw of compositeEntitys)

@ -1,3 +1,4 @@
import { ECompareType } from "./BoardFindInterface";
import { IBaseOption } from "./BoardInterface";
export interface IHSOption extends IBaseOption
@ -29,4 +30,7 @@ export interface IHSOption extends IBaseOption
polyline: boolean;
circle: boolean;
arc: boolean;
custom: boolean;
matchType?: ECompareType;
customBoardName?: string;
}

@ -1,11 +1,10 @@
import { action, observable, toJS } from "mobx";
import { DefaultHSOption } from "../../Editor/DefaultConfig";
import { IConfigOption } from "../Components/Board/UserConfigComponent";
import { ECompareType } from "./BoardFindInterface";
import { IConfigStore } from "./BoardStore";
import { IHSOption } from "./HSInterface";
export class HideSelectStore implements IConfigStore
{
@observable configName = "默认";
@ -13,6 +12,8 @@ export class HideSelectStore implements IConfigStore
@observable m_Option: IHSOption = { ...DefaultHSOption };
@observable isAll = false;
@observable isRev = false;
private _IsNotCheckBoxKeys = ["customBoardName", "matchType"];
InitOption()
{
Object.assign(this.m_Option, DefaultHSOption);
@ -40,6 +41,15 @@ export class HideSelectStore implements IConfigStore
cof.option.circle = cof.option.curve;
cof.option.arc = cof.option.curve;
}
if (cof.option.version < 3)
{
cof.option.version = 3;
cof.option.customBoardName = "";
cof.option.custom = false;
cof.option.matchType = ECompareType.Equal;
}
Object.assign(this.m_Option, cof.option);
this.CheckIsAll();
this.isRev = false;
@ -50,7 +60,7 @@ export class HideSelectStore implements IConfigStore
this.isAll = !this.isAll;
for (let k in this.m_Option)
{
if (k !== "isAll" && k !== "isHide" && k !== "isDelete" && this.m_Option.hasOwnProperty(k))
if (k !== "isAll" && k !== "isHide" && k !== "isDelete" && !this._IsNotCheckBoxKeys.includes(k) && this.m_Option.hasOwnProperty(k))
{
this.m_Option[k] = this.isAll;
}
@ -63,7 +73,7 @@ export class HideSelectStore implements IConfigStore
const option = this.m_Option;
for (let k in option)
{
if (k !== "isAll" && k !== "isHide" && k !== "isDelete" && option.hasOwnProperty(k))
if (k !== "isAll" && k !== "isHide" && k !== "isDelete" && !this._IsNotCheckBoxKeys.includes(k) && option.hasOwnProperty(k))
{
option[k] = !option[k];
}
@ -74,7 +84,7 @@ export class HideSelectStore implements IConfigStore
const option = this.m_Option;
for (let k in option)
{
if (k !== "isAll" && k !== "isHide" && k !== "isDelete" && option.hasOwnProperty(k))
if (k !== "isAll" && k !== "isHide" && k !== "isDelete" && !this._IsNotCheckBoxKeys.includes(k) && option.hasOwnProperty(k))
{
if (!option[k])
{

Loading…
Cancel
Save