| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- /**
- * 设备字段图标
- * static/icon-new 下的图标已按接口 showColum 的 monitorcode 命名,
- * 这里统一按 monitorcode 取图,取不到再按描述/关键字兜底。
- */
- // 已按 monitorcode 命名的图标(忽略大小写匹配)
- const ICON_FILE_LIST = [
- "airLeakageRatePerHundred_merge",
- "airSupplyDistence_merge",
- "atomizeState",
- "atomizeState_str",
- "batteryLevel",
- "centerTemperature",
- "ch2val",
- "ch4",
- "chval",
- "co2_merge",
- "co2val",
- "controlState",
- "controlState_str",
- "coval",
- "createtime",
- "cumulativeFlow",
- "density",
- "ductOutletAirVolume_merge",
- "dustval",
- "Fan_MOT1_Power",
- "Fan_MOT2_Power",
- "Fan1StartStatus_str",
- "Fan2StartStatus_str",
- "FanStartStatus",
- "FanStartStatus_str",
- "favg",
- "fengsu_merge",
- "fireval",
- "fireval_str",
- "flow_merge",
- "flowRate",
- "fmax",
- "fmin",
- "frontRearDifference",
- "frontRearDP",
- "fsectarea",
- "fy_merge",
- "gasC",
- "gasMixMass",
- "gasval",
- "gcreatetime",
- "groutingPump",
- "groutingPump_str",
- "humidity",
- "inletAirVolume_merge",
- "instantaneousFlow",
- "kpa",
- "monitorValue",
- "nitrogenContent",
- "nitrogenPressure",
- "o2val",
- "onState",
- "onState_str",
- "outletTemperature",
- "pa",
- "pressure",
- "pulpingMachine",
- "pulpingMachine_str",
- "ratio",
- "readTime",
- "smokeval",
- "smokeval_str",
- "sprayval",
- "strname",
- "T",
- "temperature",
- "timedState",
- "timeval",
- "ttime",
- "type_merge",
- "typeName",
- "unitval",
- "V",
- "valvestate_str",
- "waterPump",
- "waterPump_str",
- "waterSupply",
- "windSpeed",
- "ws_merge",
- ];
- const ICON_CODE_MAP = {};
- ICON_FILE_LIST.forEach((name) => {
- ICON_CODE_MAP[name.toLowerCase()] = name;
- });
- // 匹配不到时的默认图标
- const DEFAULT_ICON = "/static/icon-new/type_merge.svg";
- /**
- * 按字段取图标
- * @param {String} monitorcode 接口字段编码
- * @param {String} des 字段中文描述
- * @param {Number} fanNo 风机编号(1-主机 2-备机),非风机页面可不传
- * @returns {String} 图标路径
- */
- export function getDeviceIcon(monitorcode, des, fanNo) {
- let code = (monitorcode || "").toLowerCase();
- const desText = des || "";
- // 风机型号(code = type_merge)固定使用 type_merge.svg
- if (code == "type_merge" || desText.indexOf("风机型号") > -1) {
- return "/static/icon-new/type_merge.svg";
- }
- // 甲烷类字段(ch4_merge 等,含 ch4 即可)使用 ch4.svg
- if (code.indexOf("ch4") > -1) {
- return "/static/icon-new/ch4.svg";
- }
- // 时间类字段(readTime、时间 等)使用 T.svg,排除“是否定时”等 timed 字段
- if (
- (code.indexOf("time") > -1 && code.indexOf("timed") == -1) ||
- desText.indexOf("时间") > -1
- ) {
- return "/static/icon-new/T.svg";
- }
- if (desText.indexOf("温度") > -1) {
- return "/static/icon-new/centerTemperature.svg";
- }
- // 风机主机/备机:monitorcode 形如 fan1xxx / fan_mot1_xxx,按编号取对应图标
- if (fanNo) {
- code = code.replace(/^(fan)_?mot[12]/, "$1_mot" + fanNo);
- code = code.replace(/^(fan)[12]/, "$1" + fanNo);
- }
- // 优先按 monitorcode 直接取同名图标
- if (code && ICON_CODE_MAP[code]) {
- return "/static/icon-new/" + ICON_CODE_MAP[code] + ".svg";
- }
- if (code.indexOf("frontarea") > -1) {
- return "/static/home/gfmj.svg";
- }
- if (code.indexOf("area") > -1) {
- return "/static/icon-new/dmj.svg";
- }
- if (
- code.indexOf("m3") > -1 ||
- code.indexOf("va") > -1 ||
- code.indexOf("forward") > -1
- ) {
- return "/static/icon-new/fl.svg";
- }
- if (code.indexOf("gate") > -1 || code.indexOf("door") > -1) {
- return "/static/icon-new/door-icon.svg";
- }
- if (
- code.indexOf("press") > -1 ||
- code.indexOf("pressure") > -1 ||
- code.indexOf("pa1") > -1 ||
- code.indexOf("pa2") > -1 ||
- code.indexOf("dp") > -1
- ) {
- return "/static/icon-new/qyyl-icon.svg";
- }
- return DEFAULT_ICON;
- }
- export default getDeviceIcon;
|