import cloneDeep from 'lodash/cloneDeep';
import { PublicConfigClass } from '@/packages/public';
import { CreateComponentType } from '@/packages/index.d';
import { chartInitConfig, requestSqlConfig } from '@/settings/designSetting';
import { ZhiGan_ModalButtonConfig } from './index';
import { getAppEnvConfig } from '@/utils/env';

const { VITE_GLOB_API_URL } = getAppEnvConfig();
export const option = {
  dataset: {
    // value: '辅助决策',
  },
  dataStyle: {
    color: 'yellow',
    fontsize: 16,
    fontcolor: '#FFFFFF',
  },
};

export default class Config extends PublicConfigClass implements CreateComponentType {
  public key = ZhiGan_ModalButtonConfig.key;
  public attr = { ...chartInitConfig, w: 121, h: 44, zIndex: 5 };
  public chartConfig = cloneDeep(ZhiGan_ModalButtonConfig);
  public option = cloneDeep(option);
  public events = getDeafultEvents();
  // public request = { ...requestSqlConfig, requestSQLContent: { sql: 'UPDATE fm_fireclueinfo SET "Status" = #{Status} WHERE "Id" = #{Id}' }}
  // public filter = "return res.result;"
}

function getDeafultEvents() {
  return {
    baseEvent: {
      click: null,
      dblclick: null,
      mouseenter: null,
      mouseleave: null,
    },
    advancedEvents: {
      vnodeMounted: null,
      vnodeBeforeMount: null,
    },
    interactEvents: [],
    interactConfigEvents: [
      {
        type: 'click',
        movementList: [
          {
            movement: 'callBackRequest',
            elementId: '',
            callBackRequest: {
              requestUrl: VITE_GLOB_API_URL,
              requestApi: '/api/FireManagement/UpdatFireStateById',
              requestContentType: '',
              requestDataType: 0,
              requestHttpType: 'post',
              requestParams: {
                Body: {
                  'form-data': {},
                  'x-www-form-urlencoded': {},
                  json: '',
                  xml: '',
                },
                Header: [
                  {
                    key: '',
                    value: '',
                    error: false,
                  },
                ],
                Params: [
                  {
                    key: 'id',
                    value: '{id}',
                    error: false,
                  },
                  {
                    key: 'state',
                    value: '1',
                    error: false,
                  },
                ],
              },
            },
          },
        ],
      },
    ],
  };
}
