function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
import React, { useEffect, useState, useContext, Fragment } from 'react';
import { BizGlobalDataContext } from '@zgfe/business-lib';
import apis from '../../constants/api';
import request from '../../utils/ajax';
import './index.less';
import banner from './imgs/banner.png';
import img1 from './imgs/img-1.png';
import img2 from './imgs/img-2.png';
import img3 from './imgs/img-3.png';
import img4 from './imgs/img-4.png';
import img5 from './imgs/img-5.png';
import img6 from './imgs/img-6.png';
import img7 from './imgs/img-7.png';
import img8 from './imgs/img-8.png';
import img9 from './imgs/img-9.png';
import img10 from './imgs/img-10.png';
import img11 from './imgs/img-11.png';
import img12 from './imgs/img-12.png';
var DataOpen = function DataOpen() {
  var classPrefix = 'open-data';
  var _useContext = useContext(BizGlobalDataContext),
    authority = _useContext.authority;
  var _useState = useState([]),
    _useState2 = _slicedToArray(_useState, 2),
    list = _useState2[0],
    setList = _useState2[1];
  var imgList = [img1, img2, img3, img4, img5, img6, img7, img8, img9, img10, img11, img12];
  var authorityList = {
    数据统计API: 10024,
    用户查询API: 10025,
    用户行为轨迹API: 10026,
    用户群查询API: 10110,
    用户群创建API: 10027,
    Kafka订阅: 10028,
    明细数据查询API: 10029,
    数据集查询API: 10030,
    数据集结构查询API: 10031,
    标签导入API: 10032,
    标签导出API: 10033,
    数据集创建API: 10034
  };
  var getList = function getList() {
    request(apis.getOpenDataList, {
      method: 'get'
    }).then(function (res) {
      if (!res) throw new Error();
      setList(res.data);
    }).catch(function (err) {
      console.error('失败', err);
    });
  };
  useEffect(function () {
    getList();
  }, []);
  var clickHandle = function clickHandle(name) {
    // url && window.open(url);
    request(apis.downloadTemplate, {
      method: 'post',
      data: {
        fileName: name + '.docx'
      },
      responseType: 'blob',
      fileName: name
    }).then(function () {});
  };
  var _useState3 = useState(''),
    _useState4 = _slicedToArray(_useState3, 2),
    tooltip = _useState4[0],
    setTooltip = _useState4[1];
  return /*#__PURE__*/React.createElement("div", {
    className: classPrefix
  }, /*#__PURE__*/React.createElement("div", {
    className: "".concat(classPrefix, "-banner")
  }, /*#__PURE__*/React.createElement("img", {
    src: banner
  }), /*#__PURE__*/React.createElement("div", {
    className: "".concat(classPrefix, "-banner-desc")
  }, /*#__PURE__*/React.createElement("p", null, "\u8BF8\u845B\u667A\u80FD\u5F00\u653E\u5E73\u53F0"), /*#__PURE__*/React.createElement("p", null, "\u8BF8\u845B\u667A\u80FD\u5F00\u653E\u5E73\u53F0\u63D0\u4F9B\u4E86\u5927\u91CF\u7684\u5F00\u653EAPI\u4F9B\u60A8\u5E94\u7528\uFF0C\u6211\u4EEC\u5728\u8BBE\u8BA1\u7684\u6BCF\u4E00\u6B65\u90FD\u5F3A\u8C03\u4E86\u7075\u6D3B\u6027\u548C\u6807\u51C6\u9075\u4ECE\u6027\uFF0C\u4F7F\u7528\u7B80\u5355\u4E14\u573A\u666F\u4E30\u5BCC\u3002"), /*#__PURE__*/React.createElement("p", null, "\u540C\u65F6\uFF0C\u4E3A\u4E86\u83B7\u5F97\u6700\u5927\u5B89\u5168\u6027\uFF0C\u4E0D\u652F\u6301\u4F7F\u7528\u975E\u52A0\u5BC6HTTP\u4E0A\u7684API\u3002"), /*#__PURE__*/React.createElement("p", null, "\u5728\u4F7F\u7528API\u524D\uFF0C\u60A8\u9700\u8981\u5148\u6210\u4E3A\u8BF8\u845B\u667A\u80FD\u7684\u4EA7\u54C1\u7528\u6237\uFF0C\u7528\u4F5C\u8EAB\u4EFD\u7684\u9A8C\u8BC1\u3002"))), /*#__PURE__*/React.createElement("div", {
    className: "".concat(classPrefix, "-content clearfix")
  }, list.map(function (item, index) {
    return /*#__PURE__*/React.createElement(Fragment, {
      key: index
    }, authorityList[item.name] && authority[authorityList[item.name]] && (/*#__PURE__*/React.createElement("div", {
      className: "".concat(classPrefix, "-content-item"),
      onClick: function onClick() {
        return clickHandle(item.name);
      },
      onMouseOver: function onMouseOver() {
        return setTooltip(item.name);
      },
      onMouseLeave: function onMouseLeave() {
        return setTooltip('');
      }
    }, /*#__PURE__*/React.createElement("img", {
      src: imgList[index]
    }), /*#__PURE__*/React.createElement("p", {
      className: "dest-title"
    }, item.name), /*#__PURE__*/React.createElement("p", {
      className: "description"
    }, item.description), tooltip === item.name && (/*#__PURE__*/React.createElement("p", {
      className: "tooltip-plus ".concat(item.url === '' ? 'empty-tips' : '')
    }, item.description)))));
  })));
};
export default DataOpen;