function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _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(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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(arr) { if (Array.isArray(arr)) return arr; }
import { request } from '@vtx/utils';
import { useEffect, useState } from 'react';
import { VmEmpty, VmTabs } from "../../../_components";
import ViewRichText from "../CkEditorCustom/view";
import Right from "../Right";
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
var listInstrument = function listInstrument(params) {
  return request.get('/cloud/zhzf/api/v101/case/listInstrument', {
    data: params
  });
};
export default (function (props) {
  var id = props.id,
    detail = props.detail;
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    activeKey = _useState2[0],
    setActiveKey = _useState2[1];
  var _useState3 = useState([]),
    _useState4 = _slicedToArray(_useState3, 2),
    list = _useState4[0],
    setList = _useState4[1];
  var _useState5 = useState({}),
    _useState6 = _slicedToArray(_useState5, 2),
    current = _useState6[0],
    setCurrent = _useState6[1];
  useEffect(function () {
    id && listInstrument({
      caseId: id
    }).then(function (res) {
      if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
        var _res$data$;
        setList(res.data || []);
        setCurrent(res.data[0] || {});
        setActiveKey(((_res$data$ = res.data[0]) === null || _res$data$ === void 0 ? void 0 : _res$data$.id) || '');
      }
    });
  }, [id]);
  return /*#__PURE__*/_jsxs("div", {
    className: "zf-document-content",
    children: [/*#__PURE__*/_jsx("div", {
      className: "zf-document-left",
      children: list.length ? /*#__PURE__*/_jsxs(_Fragment, {
        children: [/*#__PURE__*/_jsx("div", {
          style: {
            paddingLeft: '16px'
          },
          children: /*#__PURE__*/_jsx(VmTabs, {
            activeKey: activeKey,
            items: list.map(function (item) {
              return {
                label: item.instrumentName,
                key: item.id
              };
            }),
            onChange: function onChange(key) {
              setActiveKey(key);
              setCurrent(list.find(function (item) {
                return item.id === key;
              }));
            }
          })
        }), /*#__PURE__*/_jsx("div", {
          className: "zf-document-text",
          children: current.id && /*#__PURE__*/_jsx(ViewRichText, {
            content: current.templateContent,
            configJson: current.elementContent,
            values: JSON.parse(current.instrumentValue),
            viewMode: true,
            configDisabled: {}
          })
        })]
      }) : /*#__PURE__*/_jsx(VmEmpty, {})
    }), /*#__PURE__*/_jsx(Right, {
      detail: detail
    })]
  });
});