/*
 * @Author: sjl
 * @Date: 2023-04-08 11:51:03
 * @Descripttion: 
 */
import { DataComponentRecord, DataSource } from '/@/api/dataBoard/model';
// import { DeviceTypeEnum } from '/@/api/device/model/deviceModel';

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;
  deviceType?: DeviceTypeEnum;
  organizationId?: 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,
      deviceType: dataSourceRecord.deviceType,
      slaveDeviceId: dataSourceRecord.slaveDeviceId,
      organizationId: dataSourceRecord.organizationId,
    } as ControlComponentValue,
  };
};
