control.config.ts 1.01 KB
import { DataComponentRecord, DataSource } from '/@/api/dataBoard/model';

export interface ControlComponentLayout {
  [key: string]: any;
}

export interface ControlComponentValue {
  value?: boolean;
  attribute?: string;
  attributeRename?: string;
  icon?: string;
  iconColor?: string;
  deviceId?: string;
  fontColor?: string;
  slaveDeviceId?: string;
  deviceProfileId?: string;
}

export const ControlComponentDefaultConfig: ControlComponentValue = {
  icon: 'shuiwen',
  iconColor: '#367BFF',
  fontColor: '#000',
};

export const transformControlConfig = (
  _ComponentConfig: Recordable,
  _record: DataComponentRecord,
  dataSourceRecord: DataSource
) => {
  return {
    value: {
      ...dataSourceRecord.componentInfo,
      attribute: dataSourceRecord.attribute,
      attributeRename: dataSourceRecord.attributeRename,
      deviceProfileId: dataSourceRecord.deviceProfileId,
      deviceId: dataSourceRecord.deviceId,
      slaveDeviceId: dataSourceRecord.slaveDeviceId,
    } as ControlComponentValue,
  };
};