import moment from 'moment';
import React from 'react';
import { Tooltip, message } from 'antd';
import { IconFont, BizSelect } from '@zgfe/business-lib';
// 默认日期
export function getInitDate(includeToday) {
  return {
    unit: 'day',
    relative: [7, 0],
    begin: moment().subtract(7, 'days').format('YYYY-MM-DD'),
    end: moment().subtract(includeToday ? 0 : 1, 'days').format('YYYY-MM-DD')
  };
}
// 数据质量
export var getColumns = function getColumns(classPrefix, onChangeParams, getDetails, basicConfig, authority) {
  var _basicConfig$privateC, _basicConfig$publicCo;
  return [{
    width: 400,
    title: '事件名称',
    dataIndex: 'eventName',
    key: 'eventName',
    fixed: 'left',
    // ellipsis: true,
    render: function render(text, record) {
      return /*#__PURE__*/React.createElement(Tooltip, {
        placement: "topLeft",
        title: text
      }, /*#__PURE__*/React.createElement("div", {
        className: record.showName === 1 ? '' : 'not-operable',
        onClick: function onClick() {
          if (record.showName === 1) {
            getDetails(record.eventName);
          }
        }
      }, text));
    }
  },
  // {
  //   width: 240,
  //   title: (
  //     <div>
  //       接收条数
  //       <Tooltip placement="top" title="系统接收到的数据条数，尚未进行数据校验">
  //         <IconFont type="tishi"></IconFont>
  //       </Tooltip>
  //     </div>
  //   ),
  //   sorter: true,
  //   showSorterTooltip: false,
  //   dataIndex: 'allCount',
  //   key: 'allCount',
  // },
  {
    width: 240,
    title: (/*#__PURE__*/React.createElement("div", null, "\u5165\u5E93\u6761\u6570", /*#__PURE__*/React.createElement(Tooltip, {
      placement: "top",
      title: "\u8FDB\u5165\u7CFB\u7EDF\u53EF\u4EE5\u67E5\u8BE2\u7684\u6570\u636E\u6761\u6570"
    }, /*#__PURE__*/React.createElement(IconFont, {
      type: "tishi"
    })))),
    sorter: true,
    showSorterTooltip: false,
    dataIndex: 'successCount',
    key: 'successCount'
  }, {
    width: 240,
    title: (/*#__PURE__*/React.createElement("div", null, "\u9519\u8BEF\u6761\u6570", /*#__PURE__*/React.createElement(Tooltip, {
      placement: "top",
      title: "\u6570\u636E\u56E0\u4E3A\u9519\u8BEF\u3001\u6570\u91CF\u8D85\u9650\u7B49\u539F\u56E0\u672A\u8FDB\u5165\u7CFB\u7EDF\u6761\u6570\uFF0C\u5F71\u54CD\u4E8B\u4EF6\u6570\u636E\u5165\u5E93"
    }, /*#__PURE__*/React.createElement(IconFont, {
      type: "tishi"
    })))),
    sorter: true,
    showSorterTooltip: false,
    dataIndex: 'errorCount',
    key: 'errorCount'
  }, {
    width: 240,
    title: (/*#__PURE__*/React.createElement("div", null, "\u5F02\u5E38\u5C5E\u6027\u6761\u6570", /*#__PURE__*/React.createElement(Tooltip, {
      placement: "top",
      title: "\u5305\u542B\u5F02\u5E38\u5C5E\u6027\u7684\u6B21\u6570\uFF0C\u5C5E\u6027\u5F02\u5E38\u901A\u5E38\u4EC5\u4F1A\u5BFC\u81F4\u76F8\u5173\u5C5E\u6027\u88AB\u4E22\u5F03\uFF0C\u800C\u4E0D\u4F1A\u5F71\u54CD\u4E8B\u4EF6\u672C\u8EAB"
    }, /*#__PURE__*/React.createElement(IconFont, {
      type: "tishi"
    })))),
    sorter: true,
    showSorterTooltip: false,
    dataIndex: 'errorProCount',
    key: 'errorProCount'
  }, {
    width: 240,
    title: (/*#__PURE__*/React.createElement(BizSelect, {
      defaultValue: {
        value: 0
      },
      keyField: "value",
      options: (basicConfig === null || basicConfig === void 0 ? void 0 : (_basicConfig$privateC = basicConfig.privateConfig) === null || _basicConfig$privateC === void 0 ? void 0 : _basicConfig$privateC.platform) || (basicConfig === null || basicConfig === void 0 ? void 0 : (_basicConfig$publicCo = basicConfig.publicConfig) === null || _basicConfig$publicCo === void 0 ? void 0 : _basicConfig$publicCo.platform) || [],
      onChange: function onChange(data) {
        onChangeParams(data.value, 'sdk');
      }
    })),
    dataIndex: 'sdk',
    key: 'sdk'
  }, {
    title: '操作',
    fixed: 'right',
    width: 60,
    render: function render(_, record) {
      return /*#__PURE__*/React.createElement("div", {
        className: "".concat(classPrefix, "-detail ").concat(record.showName === 1 ? '' : 'not-operable'),
        onClick: function onClick() {
          if (!authority[1709285577]) {
            message.error('无查看详情权限');
            return;
          }
          if (record.showName === 1) {
            getDetails(record);
          }
        }
      }, "\u8BE6\u60C5");
    }
  }];
};
// 跳转详情获取sdk
export var getSdk = function getSdk(sdk, basicConfig) {
  var _basicConfig$privateC2, _basicConfig$publicCo2;
  var _sdk = 0;
  var list = (basicConfig === null || basicConfig === void 0 ? void 0 : (_basicConfig$privateC2 = basicConfig.privateConfig) === null || _basicConfig$privateC2 === void 0 ? void 0 : _basicConfig$privateC2.platform) || (basicConfig === null || basicConfig === void 0 ? void 0 : (_basicConfig$publicCo2 = basicConfig.publicConfig) === null || _basicConfig$publicCo2 === void 0 ? void 0 : _basicConfig$publicCo2.platform) || [];
  if (list.length > 0) {
    list.map(function (item) {
      if (item.label.toLowerCase() === sdk.toLowerCase()) {
        _sdk = item.value;
      }
    });
  }
  return _sdk;
};