import { ComponentsType, DataType, getComponentsType, getMappingType, iFunction, iProperty } from './base/type'; import iGrapesJSConfig from './type'; import {default as IOTNavBarConfig} from './base/IOTNavBar/grapesjsConfig'; import { default as IOTPowerConfig } from './bool/power/grapesjsConfig'; import { default as IOTSwitchConfig } from "./bool/switch/grapesjsConfig"; import {default as IOTCardMultiTextConfig} from './common/IOTCardMultiText/grapesjsConfig'; import {default as IOTGridConfig } from './enum/IOTGrid/grapesjsConfig'; import {default as IOTCordEntryNumberConfig } from './number/IOTCordEntryNumber/grapesjsConfig'; import {default as IOTIconSliderConfig } from './number/IOTIconSlider/grapesjsConfig'; import {default as IOTTimeSliderConfig } from './number/IOTTimeSlider/grapesjsConfig'; import {default as IOTSliderConfig } from './number/IOTSlider/grapesjsConfig'; import {default as IOTWeatherConfig } from './service/IOTWeather/grapesjsConfig'; import {default as IOTCordEntryEnumConfig} from './enum/IOTCordEntryEnum/grapesjsConfig'; import {default as IOTMiniCardTextConfig } from './common/IOTMiniCardText/grapesjsConfig'; import {default as IOTImgConfig } from "./element/IOTImg/grapesjsConfig"; import {default as IOTCustomConfig} from './common/IOTCustom/grapesjsConfig'; import {default as IOTTimeTaskConfig} from './service/IOTTimeTask/grapesjsConfig'; import { default as IOTAlertConfig } from './service/IOTAlert/grapesjsConfig'; import {default as IOTPoleSliderConfig} from './enum/IOTPoleSlider/grapesjsConfig'; import {default as IOTNoPoleSliderConfig} from './number/IOTNoPoleSlider/grapesjsConfig'; import {default as IOTIconGridConfig} from './enum/IOTIconGrid/grapesjsConfig' import {default as IOTExecutePowerConfig} from './enum/IOTExecutePower/grapesjsConfig'; // import {default as IOTConsumablesConfig} from './service/IOTConsumables/grapesjsConfig'; import {default as IOTIconNavigationConfig} from './common/IOTIconNavigation/grapesjsConfig'; // import { default as IOTFaultAlarmConfig } from './service/IOTFaultAlarm/grapesjsConfig'; import { default as IOTDataLogConfig } from './service/IOTDataLog/grapesjsConfig'; import {default as IOTEntryConfig} from './common/IOTEntry/grapesjsConfig'; // 导出组件 export {default as IOTNavBar} from './base/IOTNavBar/IOTNavBar'; export {default as IOTPower} from './bool/power/IOTPower'; export {default as IOTSwitch} from './bool/switch/IOTSwitch'; export {default as IOTCardMultiText} from './common/IOTCardMultiText/IOTCardMultiText'; export {default as IOTGrid} from './enum/IOTGrid/IOTGrid'; export {default as IOTCordEntryNumber} from './number/IOTCordEntryNumber/IOTCordEntryNumber'; export {default as IOTIconSlider} from './number/IOTIconSlider/IOTIconSlider'; export {default as IOTTimeSlider} from './number/IOTTimeSlider/IOTTimeSlider'; export {default as IOTSlider} from './number/IOTSlider/IOTSlider'; export {default as IOTWeather} from './service/IOTWeather/IOTWeather'; export {default as IOTCordEntryEnum} from './enum/IOTCordEntryEnum/IOTCordEntryEnum'; export {default as IOTMiniCardText} from './common/IOTMiniCardText/IOTMiniCardText'; export {default as IOTImg} from './element/IOTImg/IOTImg'; export {default as IOTCustom} from './common/IOTCustom/IOTCustom'; export {default as IOTAlert} from './service/IOTAlert/IOTAlert'; export {default as IOTTimeTask} from './service/IOTTimeTask/IOTTimeTask'; export {default as IOTPoleSlider} from './enum/IOTPoleSlider/IOTPoleSlider'; export {default as IOTNoPoleSlider} from './number/IOTNoPoleSlider/IOTNoPoleSlider'; export {default as IOTIconGrid} from './enum/IOTIconGrid/IOTIconGrid'; export {default as IOTExecutePower} from './enum/IOTExecutePower/IOTExecutePower'; // export {default as IOTConsumables} from './service/IOTConsumables/IOTConsumables'; export {default as IOTIconNavigation} from './common/IOTIconNavigation/IOTIconNavigation'; // export {default as IOTFaultAlarm } from './service/IOTFaultAlarm/IOTFaultAlarm'; export {default as IOTDataLog } from './service/IOTDataLog/IOTDataLog'; export {default as IOTEntry} from './common/IOTEntry/IOTEntry'; // 提供给打包工具使用 export {default as IOTPowerBuild} from './bool/power/build'; export {default as IOTSwitchBuild} from './bool/switch/build'; export {default as IOTCardMultiTextBuild} from './common/IOTCardMultiText/build'; export {default as IOTGridBuild} from './enum/IOTGrid/build'; export {default as IOTCordEntryNumberBuild} from './number/IOTCordEntryNumber/build'; export {default as IOTIconSliderBuild} from './number/IOTIconSlider/build'; export {default as IOTTimeSliderBuild} from './number/IOTTimeSlider/build'; export {default as IOTSliderBuild} from './number/IOTSlider/build'; export {default as IOTWeatherBuild} from './service/IOTWeather/build'; export {default as IOTCordEntryEnumBuild} from './enum/IOTCordEntryEnum/build'; export {default as IOTMiniCardTextBuild} from './common/IOTMiniCardText/build'; export {default as IOTImgBuild} from './element/IOTImg/build'; export {default as IOTPoleSliderBuild} from './enum/IOTPoleSlider/build'; export {default as IOTNoPoleSliderBuild} from './number/IOTNoPoleSlider/build'; export {default as IOTCustomBuild} from './common/IOTCustom/build'; export {default as IOTIconGridBuild} from './enum/IOTIconGrid/build'; export {default as IOTExecutePowerBuild} from './enum/IOTExecutePower/build'; export {default as IOTConsumablesBuild} from './service/IOTConsumables/build'; export {default as IOTIconNavigationBuild} from './common/IOTIconNavigation/build'; /** * 拖拽平台物模型支持的组件列表 * * 处理属性支持的组件 * 处理组件在右侧展示顺序 * // 获取来源值 detailType === '1' 是为 小程序接入 否则 是 h5 接入 * // 获取来源值 appType === '1' 是为 小京鱼APP 否则 是 小家APP */ export default ( detailType:string,appType:string,allGrapesJSConfig:boolean = false,func:iFunction) => { if (allGrapesJSConfig) { return [ IOTNavBarConfig, IOTPowerConfig, IOTSwitchConfig, IOTCordEntryEnumConfig, IOTGridConfig, IOTCordEntryNumberConfig, IOTIconSliderConfig, IOTSliderConfig, IOTTimeSliderConfig, IOTWeatherConfig, IOTPoleSliderConfig, IOTNoPoleSliderConfig, IOTIconGridConfig, IOTExecutePowerConfig, // IOTConsumablesConfig, IOTTimeTaskConfig, IOTIconNavigationConfig, //以上是控制以下是展示展示组件 IOTCardMultiTextConfig, IOTMiniCardTextConfig, IOTImgConfig, IOTCustomConfig, IOTAlertConfig, // IOTFaultAlarmConfig, IOTDataLogConfig, IOTEntryConfig ]; } let components = Array(); let mappingType = getComponentsType(func.type) as ComponentsType; if (detailType === '1'){ showInBlock(func, IOTSwitchConfig, components); showInBlock(func, IOTPowerConfig, components); return components; } showInBlock(func, IOTSwitchConfig, components); showInBlock(func, IOTPowerConfig, components); showInBlock(func, IOTGridConfig, components); showInBlock(func, IOTCordEntryNumberConfig, components); showInBlock(func, IOTSliderConfig, components); showInBlock(func, IOTIconSliderConfig, components); showInBlock(func, IOTCordEntryEnumConfig, components); showInBlock(func, IOTWeatherConfig, components); showInBlock(func, IOTIconGridConfig, components); showInBlock(func, IOTExecutePowerConfig, components); // showInBlock(func, IOTConsumablesConfig, components); showInBlock(func, IOTIconNavigationConfig, components); //数值类型 if (mappingType === ComponentsType.NumberType && checkLabelContainTag('7', func.property?.label ?? '')) { showInBlock(func, IOTTimeSliderConfig, components); } showInBlock(func, IOTCardMultiTextConfig, components); showInBlock(func, IOTMiniCardTextConfig, components); showInBlock(func, IOTImgConfig, components); showInBlock(func, IOTPoleSliderConfig,components); showInBlock(func, IOTNoPoleSliderConfig,components); showInBlock(func, IOTCustomConfig, components); showInBlock(func, IOTTimeTaskConfig, components); showInBlock(func, IOTAlertConfig, components); // showInBlock(func, IOTFaultAlarmConfig, components); showInBlock(func, IOTDataLogConfig, components); showInBlock(func, IOTEntryConfig, components); return components; } /** * 检查组件是否展示到拖拽列表中 * 判断成立添加到返回数组中,不成立则不添加 * @memberof iGrapesJSConfig */ const showInBlock = (func:iFunction,config:iGrapesJSConfig,configs:Array) =>{ let mappingType = getComponentsType(func.type) as ComponentsType; if (config.type.includes(mappingType)) { if (func.property){ if (func.property.access.indexOf(config.access) !== -1) { configs.push(config); } }else{ configs.push(config); } } } /** *检查label('2,3,7')字符中是否包含特定tag *1:耗村类 2:故障类 3:支持别名 4:支持云定时 5:事件型 6:用户数据类 7:时间类 * @param {string} tag * @param {string} label * @return {*} */ export const checkLabelContainTag = (tag:string,label:string) => { if (label == undefined){ return false; } let labelContainTag = false; label.split(',').forEach((item:string)=>{ if (item === tag){ labelContainTag = true; } }) return labelContainTag; }