|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|