UNPKG

ze-react-component-library

Version:
98 lines (86 loc) 3.26 kB
var __assign = this && this.__assign || function () { __assign = Object.assign || function (t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } } return t; }; return __assign.apply(this, arguments); }; import React from "react"; import { getNameProperty, isEntity } from "zeroetp-api-sdk"; import UrlList from "../../../components/UrlList"; import Detail from "../../../components/Detail"; import moment from "moment"; var entity = { key: "value", title: "指标", icon: "", tip: "", type: "basic", hideInMenu: true, component: function component(_a) { var _b, _c, _d, _e, _f, _g, _h, _j; var data = _a.data, tableProps = _a.tableProps, detailProps = _a.detailProps; var entity = data.result[0]; // feat: modality if (((_d = (_c = (_b = data.schema) === null || _b === void 0 ? void 0 : _b.modality) === null || _c === void 0 ? void 0 : _c.detail) === null || _d === void 0 ? void 0 : _d.type) === "url" && ((_h = (_g = (_f = (_e = data.schema) === null || _e === void 0 ? void 0 : _e.modality) === null || _f === void 0 ? void 0 : _f.detail) === null || _g === void 0 ? void 0 : _g.config) === null || _h === void 0 ? void 0 : _h.property) && ((_j = entity[data.schema.modality.detail.config.property]) === null || _j === void 0 ? void 0 : _j.length) > 0) { var url = entity[data.schema.modality.detail.config.property]; if (data.schema.modality.detail.config.inline) { // querys var urlObj_1 = new URL(url); if (data.schema.modality.detail.config.querys) { if (typeof data.schema.modality.detail.config.querys === "string") { var func = new Function("return " + data.schema.modality.detail.config.querys)(); var querys = func(data.logicform, entity, { moment: moment }); Object.entries(querys).forEach(function (_a) { var k = _a[0], v = _a[1]; return urlObj_1.searchParams.set(k, v); }); } } if (data.schema.modality.detail.config.hash) { urlObj_1.hash = data.schema.modality.detail.config.hash; } return /*#__PURE__*/React.createElement("iframe", { src: urlObj_1.href, style: { width: "100%", height: data.schema.modality.detail.config.height || 1000 } }); } else { var nameProp = getNameProperty(data.schema); return /*#__PURE__*/React.createElement(UrlList, { data: [{ url: url, title: nameProp ? entity[nameProp.name] : "" }] }); } } else { return /*#__PURE__*/React.createElement(Detail, __assign({}, detailProps, { schema: data.schema, columnProperties: data.columnProperties, item: entity, tableProps: tableProps })); } }, valid: function valid(result) { if (!result) return false; var logicform = result.logicform; if (isEntity(logicform)) { return true; } return false; } }; export default entity;