var motorPropHelper = {
|
IsMotorPowerProp(prop) {
|
if (prop == null) return false;
|
if (
|
prop.ID == 12 ||
|
prop.Tag == "电机_额定功率" ||
|
prop.Tag == "MotorPower" ||
|
prop.Tag == "电机功率"
|
)
|
return true;
|
else return false;
|
},
|
IsMotorSpeedProp(prop) {
|
if (prop == null) return false;
|
if (
|
prop.Tag == "电机_额定转速" ||
|
prop.Tag == "MotorSpeed" ||
|
prop.Tag == "电机转速"
|
)
|
return true;
|
else return false;
|
},
|
//是否是安全计算系数
|
IsCalcCoeffProp(prop) {
|
if (prop == null) return false;
|
if (
|
prop.ID == 40 ||
|
prop.Tag == "电机安全系数" ||
|
prop.Tag == "电机功率安全系数"
|
)
|
return true;
|
else return false;
|
},
|
//电机功率显示值规整
|
BuildMotorPowerDispValue(propValue) {
|
if (propValue == null || propValue == "") return "";
|
if (typeof propValue == "string") {
|
propValue = propValue.toUpperCase();
|
if (propValue.indexOf("KW") < 0) {
|
propValue = propValue + "KW";
|
if (propValue == "3KW") propValue = "3.0kW";
|
if (propValue == "4KW") propValue = "4.0kW";
|
}
|
return propValue;
|
} else {
|
var power = parseFloat(propValue);
|
if (power < 1) return power + "kW";
|
else if (power == 18.5) return "18.5kW";
|
else if (power < 10) {
|
return power.toFixed(1) + "kW";
|
} else {
|
return power + "kW";
|
}
|
}
|
},
|
//把数据库中电机参数放在产品属性中
|
SetPartPropByDsMotorInfo(motor, partPropList) {
|
if (partPropList == null || partPropList.length == 0) return partPropList;
|
if (motor == null) return partPropList;
|
|
for (let i = 0; i < partPropList.length; i++) {
|
var prop = partPropList[i];
|
if (prop.Tag == null) continue;
|
if (prop.Tag == "电机额定电流") {
|
if (motor.DianLiu != null) {
|
prop.PropValue = motor.DianLiu;
|
}
|
continue;
|
}
|
if (prop.Tag == "电机满载效率") {
|
if (motor.XiaoLv != null) {
|
prop.PropValue = motor.XiaoLv;
|
}
|
}
|
if (prop.Tag == "电机启动电流") {
|
if (motor.DuZhuanDianLiu != null) {
|
prop.PropValue = motor.DuZhuanDianLiu;
|
}
|
continue;
|
}
|
if (prop.Tag == "电机额定转速") {
|
if (motor.ZhuanSu != null) {
|
prop.PropValue = motor.ZhuanSu;
|
}
|
continue;
|
}
|
if (prop.Tag == "电机功率因素" || prop.Tag == "电机功率因子") {
|
if (motor.GongLvYingZi != null) {
|
prop.PropValue = motor.GongLvYingZi;
|
}
|
continue;
|
}
|
if (prop.Tag == "电机型号") {
|
if (motor.XingHao != null) {
|
prop.PropValue = motor.XingHao;
|
}
|
continue;
|
}
|
if (prop.Tag == "电机重量") {
|
if (motor.ZhongLiang != null) {
|
prop.PropValue = motor.ZhongLiang;
|
}
|
continue;
|
}
|
if (prop.Tag == "电机防护等级") {
|
if (motor.FangFu != null) {
|
prop.PropValue = motor.FangFu;
|
}
|
continue;
|
}
|
if (prop.Tag == "电机额定电压") {
|
if (motor.DianYa != null) {
|
prop.PropValue = motor.DianYa;
|
}
|
continue;
|
}
|
if (prop.Tag == "电机能效等级") {
|
if (motor.NengXiao > 0) {
|
prop.PropValue = motor.NengXiao;
|
}
|
continue;
|
}
|
if (prop.Tag == "电机极数") {
|
if (motor.PoleNum > 0) {
|
prop.PropValue = motor.PoleNum;
|
}
|
continue;
|
}
|
if (prop.Tag == "防爆等级") {
|
if (motor.FangBao != null) {
|
prop.PropValue = motor.FangBao;
|
}
|
continue;
|
}
|
if (prop.Tag == "电机机座号") {
|
if (motor.JiZuoHao != null) {
|
prop.PropValue = motor.JiZuoHao;
|
}
|
continue;
|
}
|
}
|
|
return partPropList;
|
},
|
TranValueToHp(kw, isAddHpLabel) {
|
if (isNaN(kw)) return "";
|
|
if (typeof value === "number") {
|
if (isAddHpLabel)
|
return motorPropHelper.getDispValueP(kw / 0.7457) + " hp";
|
else return motorPropHelper.getDispValueP(kw / 0.7457);
|
} else {
|
if (kw.toLowerCase().indexOf("kw") >= 0)
|
kw = kw.toLowerCase().replace("kw", "");
|
kw = parseFloat(kw);
|
|
if (isAddHpLabel)
|
return motorPropHelper.getDispValueP(kw / 0.7457) + " hp";
|
else return motorPropHelper.getDispValueP(kw / 0.7457);
|
}
|
},
|
getDispValueP(v) {
|
if (v == null || v == "") {
|
return 0;
|
}
|
if (v == 0) return 0;
|
if (v < 0.1) {
|
return v.toFixed(3);
|
} else if (v < 1) {
|
return v.toFixed(2);
|
} else if (v < 5) {
|
return v.toFixed(1);
|
} else if (v < 20) {
|
return v.toFixed(1);
|
} else {
|
return v.toFixed(0);
|
}
|
},
|
/**
|
* 获取功率数值
|
*
|
* @param {any} val - 输入的功率值,可以是数字、字符串或null
|
* @returns {number} 返回处理后的功率数值,如果输入无效则返回0
|
*/
|
getPowerNumberValue(val) {
|
if (val == null || val == "") return 0;
|
if (val == 0) return 0;
|
if (typeof val === "number") {
|
return val;
|
}
|
if (typeof val === "string") {
|
val = val.replace("kW", "").replace("kw", "").replace("KW", "");
|
return parseFloat(val);
|
}
|
},
|
/**
|
* 比较两个功率值是否相等
|
*
|
* @param {string|number} val1 - 第一个功率值,可以是字符串或数字
|
* @param {string|number} val2 - 第二个功率值,可以是字符串或数字
|
* @returns {boolean} 如果两个功率值相等则返回 true,否则返回 false
|
*/
|
comparePowerValue(val1, val2) {
|
const v1 = motorPropHelper.getPowerNumberValue(val1);
|
const v2 = motorPropHelper.getPowerNumberValue(val2);
|
if (v1 == v2) return true;
|
if (v1 !== v2) return false;
|
return false;
|
},
|
};
|
|
export default motorPropHelper;
|