tanghaolin
2025-04-17 63465b857a7e7fa2ac18701f01d966bb2c5fa421
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
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;