import React from 'react'; import { ComponentsType, DataType, iProperty, TagType } from '../../base/type'; import IOTConsumables from './IOTConsumables'; import { IOTConsumablesProps } from './interface'; import iGrapesJSConfig from '../../type'; import { mergeParameters } from '../../base/utils'; import { IOTConsumablesJSON } from '.'; const grapesJSConfig: iGrapesJSConfig = { type: [ComponentsType.Consumables], id: 'IOTConsumables', tag: TagType.IOTConsumables, access: 'rw', render: (jsonData, ...args) => { const props = mergeParameters(jsonData, ...args); return ; }, buildData: (mock: boolean = false, property?: iProperty) => { // 区分类 const props: IOTConsumablesJSON = { title: '耗材剩余情况', icon: { value: 'insideicon-cu-1', show: true }, subTitle: { show: true, value: '耗材状态:', }, type:'', streamId: 'consumables', thumbnailTheme1:'https://iotfestatic.s3.cn-north-1.jdcloud-oss.com/%E5%B0%8F%E4%BA%AC%E9%B1%BC%E5%B9%B3%E5%8F%B0/%E6%8B%96%E6%8B%BD%E5%B9%B3%E5%8F%B0%E9%9D%99%E6%80%81%E8%B5%84%E6%BA%90/thumbnailTheme1.png', thumbnailTheme12:'https://storage.jd.com/testsmartcloud/dcp_consumable.png', disabled: false, streamValue:100, handler (): void { // throw new Error('Function not implemented.'); } }; return props; }, traits: () => { return [ { type: 'option-icon', name: 'icon', label: '显示图标', }, { type: 'text', name: 'title', label: '', }, { type:'setConsumables', name:'consumablesList', label: '耗材配置', } ]; }, }; export const getEnumItems = (propery: iProperty) => { const items = Array<{ text: string; value: string; icon: string }>(); const values = propery?.valuedef?.specs?.values; for (const key in values) { // 对此对象属性中的每个键执行的代码 items.push({ text: values[`${key}`], value: key, icon: 'insideicon-cu-1', }); } return items; }; export default grapesJSConfig;