UNPKG

ze-react-component-library

Version:
62 lines (52 loc) 1.71 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 Table from "../../../Table"; import { useRequest } from "@umijs/hooks"; import { requestLogicform } from "../../../../request"; var HierarchyList = function HierarchyList(_a) { var _b; var _c, _d; var result = _a.result, _e = _a.tableProps, tableProps = _e === void 0 ? {} : _e; var searchMode = true; var newLF = { schema: result === null || result === void 0 ? void 0 : result.schema._id, query: result.logicform.query || {}, limit: -1 }; if (Object.keys(newLF.query).length === 0) { var idProp = result.schema.properties.find(function (p) { return p.type === "ID"; }); newLF.query = (_b = {}, _b[idProp.name] = { $level: (_d = (_c = result === null || result === void 0 ? void 0 : result.schema.hierarchy) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.name }, _b); searchMode = false; } var data = useRequest(function () { return requestLogicform(newLF); }, { refreshDeps: [JSON.stringify(newLF)] }).data; return /*#__PURE__*/React.createElement(Table, __assign({ setLogicform: function setLogicform() {}, className: "hierarchy-list", logicform: newLF }, tableProps, { isHierarchyList: searchMode ? false : true, result: data })); }; export default HierarchyList;