react-admin-kit
Version:
A react based UI components for admin system
579 lines (558 loc) • 29.9 kB
JavaScript
var _excluded = ["title"],
_excluded2 = ["btnText", "title"],
_excluded3 = ["rowKey", "name", "columns", "options", "pagination", "formColumns", "scroll", "onFinish", "tableAlertOption", "rowSelection", "sticky", "className", "optionColSpaceSize", "noPadding", "search", "request", "onOpen", "modalProps", "formProps", "defaultHideInSearch", "confirmModalProps", "confirmModelType", "optionColumnSpaceProps", "actionRef"],
_excluded4 = ["modalProps", "formProps", "searchConfig", "options", "defaultHideInSearch", "confirmModalType", "confirmModalProps", "tableAlertOption"];
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import produce from 'immer';
import { Component, createRef } from 'react';
import AntProTable from '@ant-design/pro-table';
import { message, Popconfirm, Space } from 'antd';
import LinkButton from "../LinkButton";
import ModalForm from "../ModalForm";
import { filterExportCols } from "./filterCols";
import { handleRequestParams } from "./utils";
import cs from 'classnames';
import { ProTableContext } from "../SettingProvider/context";
import { exportAntTableToExcel } from "../utils/exceljs";
import ModalConfirm from "./components/ModalConfirm";
import { BaseInnerFn } from "../context";
import { mergeOptions, myMergeBoolean, myMergeOptions } from "../utils/index";
import { normalizeTree } from "../utils/treeUtil";
import "./styles.css";
/**
* 表单类型的映射
*/
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
export var FORM_TYPE_MAP = {
new: '新增',
edit: '编辑',
read: '查看'
};
var ProTable = /*#__PURE__*/function (_Component) {
_inherits(ProTable, _Component);
var _super = _createSuper(ProTable);
function ProTable(props) {
var _this;
_classCallCheck(this, ProTable);
_this = _super.call(this, props);
_defineProperty(_assertThisInitialized(_this), "targetId", void 0);
_defineProperty(_assertThisInitialized(_this), "selfInnerRef", void 0);
_defineProperty(_assertThisInitialized(_this), "selfActionRef", void 0);
_defineProperty(_assertThisInitialized(_this), "baseInnerObj", void 0);
_defineProperty(_assertThisInitialized(_this), "context", void 0);
_defineProperty(_assertThisInitialized(_this), "tableReload", function () {
var _currentActionRef$cur;
var currentActionRef = _this.props.actionRef || _this.selfActionRef;
(_currentActionRef$cur = currentActionRef.current) === null || _currentActionRef$cur === void 0 || _currentActionRef$cur.reload();
});
_defineProperty(_assertThisInitialized(_this), "getInnerRef", function () {
return _this.props.innerRef || _this.selfInnerRef;
});
_defineProperty(_assertThisInitialized(_this), "getTitle", function () {
var _this$props = _this.props,
name = _this$props.name,
_this$props$toolbar = _this$props.toolbar,
toolbar = _this$props$toolbar === void 0 ? {} : _this$props$toolbar;
var title = toolbar.title;
if (title) return title;
if (name) return "".concat(name, "\u5217\u8868");
return false;
});
_defineProperty(_assertThisInitialized(_this), "getModalTitle", function () {
var _this$props$name = _this.props.name,
name = _this$props$name === void 0 ? '' : _this$props$name;
var formType = _this.state.formType;
return "".concat(FORM_TYPE_MAP[formType]).concat(name) || '';
});
/**
* 增强列功能
* 1. 给 option 列增加 innerRef
* 2. option 列的 renderDom 包裹 Space 组件
* @param cols
* @returns cols
*/
_defineProperty(_assertThisInitialized(_this), "patchColumn", function ($cols) {
/**
* 全局默认设置
*/
var setting = _this.context || {};
var globalSpaceProps = setting.optionColumnSpaceProps;
var _this$props$optionCol = _this.props.optionColumnSpaceProps,
optionColumnSpaceProps = _this$props$optionCol === void 0 ? {} : _this$props$optionCol;
var innerRef = _this.getInnerRef();
var mergedSpaceProps = mergeOptions({
size: 'small'
}, globalSpaceProps, optionColumnSpaceProps);
return produce($cols, function (cols) {
cols.forEach(function (col) {
var render = col.render;
// 给valueType为option列的render增加ref参数
if (col.valueType === 'option' && render) {
col.render = function (text, record, index, action) {
var renderDom = render(text, record, index, action, innerRef);
//数组的话外面包一个 Space 组件
return Array.isArray(renderDom) ? /*#__PURE__*/_jsx(Space, _objectSpread(_objectSpread({}, mergedSpaceProps), {}, {
children: renderDom
})) : renderDom;
};
}
});
});
});
_defineProperty(_assertThisInitialized(_this), "enableDelete", function ($cols) {
/**
* 全局默认设置
*/
var setting = _this.context || {};
var globalType = setting.confirmModalType,
globalProps = setting.confirmModalProps;
// props
var _this$props2 = _this.props,
_this$props2$rowKey = _this$props2.rowKey,
rowKey = _this$props2$rowKey === void 0 ? 'id' : _this$props2$rowKey,
delPermission = _this$props2.delPermission,
delFunction = _this$props2.delFunction,
_this$props2$confirmM = _this$props2.confirmModelType,
confirmModelType = _this$props2$confirmM === void 0 ? globalType || 'popconfirm' : _this$props2$confirmM,
_this$props2$confirmM2 = _this$props2.confirmModalProps,
confirmModalProps = _this$props2$confirmM2 === void 0 ? {} : _this$props2$confirmM2;
var mergedProps = mergeOptions(globalProps, confirmModalProps);
var hasDelPermission = delPermission ? delPermission() : true;
// state
var delLoading = _this.state.delLoading;
// 使用produce是为了改变columns的引用, 从而可以重渲染
return produce($cols, function (cols) {
cols.forEach(function (col) {
var render = col.render,
_col$enableDelete = col.enableDelete,
enableDelete = _col$enableDelete === void 0 ? false : _col$enableDelete;
// 如果列上开启了删除enableDelete, 复写render
if (col.valueType === 'option' && delFunction && hasDelPermission && enableDelete && render) {
col.render = function (text, record, index, actionRef, innerRef) {
// 增强 rowKey 为函数
// @ts-ignore
var key = typeof rowKey === 'function' ? rowKey(record) : rowKey;
// 增强 enableDelete 为函数
var $enableDelete = typeof enableDelete === 'function' ? enableDelete(record, index) : {};
// enabledDelete为true时的默认值
var _$enableDelete$disabl = $enableDelete.disabled,
disabled = _$enableDelete$disabl === void 0 ? false : _$enableDelete$disabl,
_$enableDelete$visibl = $enableDelete.visible,
visible = _$enableDelete$visibl === void 0 ? true : _$enableDelete$visibl,
danger = $enableDelete.danger,
_$enableDelete$btnTex = $enableDelete.btnText,
btnText = _$enableDelete$btnTex === void 0 ? '删除' : _$enableDelete$btnTex;
var renderDom = render(text, record, index, actionRef, innerRef);
if (Array.isArray(renderDom) && visible) {
var deleteDom;
// 弹框的默认属性
var _mergedProps$title = mergedProps.title,
title = _mergedProps$title === void 0 ? '确定删除吗?' : _mergedProps$title,
rest = _objectWithoutProperties(mergedProps, _excluded);
if (confirmModelType === 'modal') {
deleteDom = /*#__PURE__*/_jsx(ModalConfirm, _objectSpread(_objectSpread({
title: title
}, rest), {}, {
onOk: function onOk() {
_this.handleDelete([record[key]], record);
},
children: /*#__PURE__*/_jsx(LinkButton, {
disabled: disabled,
onClick: function onClick(e) {
return e.stopPropagation();
},
loading: delLoading && record[key] === _this.targetId,
danger: danger,
children: btnText
})
}), renderDom.length + 1);
} else {
deleteDom = /*#__PURE__*/_jsx(Popconfirm, _objectSpread(_objectSpread({
title: title
}, rest), {}, {
onConfirm: function onConfirm(e) {
e === null || e === void 0 || e.stopPropagation();
_this.handleDelete([record[key]], record);
},
onCancel: function onCancel(e) {
return e === null || e === void 0 ? void 0 : e.stopPropagation();
},
children: /*#__PURE__*/_jsx(LinkButton, {
disabled: disabled,
onClick: function onClick(e) {
return e.stopPropagation();
},
loading: delLoading && record[key] === _this.targetId,
danger: danger,
children: btnText
})
}), renderDom.length + 1);
}
renderDom.push(deleteDom);
}
return renderDom;
};
}
});
});
});
// 分受控和非受控
_defineProperty(_assertThisInitialized(_this), "getRowSelection", function () {
// props
var rowSelection = _this.props.rowSelection;
//state
var selectedRowKeys = _this.state.selectedRowKeys;
if (rowSelection && !rowSelection.selectedRowKeys) {
return _objectSpread(_objectSpread({}, rowSelection), {}, {
selectedRowKeys: selectedRowKeys,
onChange: function onChange(keys, selectedRows) {
return _this.setState({
selectedRowKeys: keys,
selectedRows: selectedRows
});
}
});
}
return rowSelection;
});
_defineProperty(_assertThisInitialized(_this), "handleDelete", function (selectedIds, record, callback) {
var _this$props3 = _this.props,
_this$props3$rowKey = _this$props3.rowKey,
rowKey = _this$props3$rowKey === void 0 ? 'id' : _this$props3$rowKey,
delFunction = _this$props3.delFunction,
_this$props3$rowSelec = _this$props3.rowSelection,
rowSelection = _this$props3$rowSelec === void 0 ? {} : _this$props3$rowSelec,
_this$props3$actionRe = _this$props3.actionRef,
actionRef = _this$props3$actionRe === void 0 ? _this.selfActionRef : _this$props3$actionRe;
//@ts-ignore
var key = typeof rowKey === 'function' ? rowKey(record) : rowKey;
_this.setState({
delLoading: true
});
if (record[key]) {
_this.targetId = record[key];
}
if (delFunction) {
delFunction(selectedIds, record).then(function () {
message.success('删除成功!');
if (callback) callback();
// bugfix: 如果在多选选中后, 点的行上的删除, 不是点的批量删除, 删除后要去除掉selectedKeys
if (record[key] && rowSelection) {
var ids = (selectedIds || []).filter(function (_key) {
return _key !== record[key];
});
if (rowSelection.selectedRowKeys) {
// @ts-ignore onChange 应有三个参数
if (rowSelection.onChange) rowSelection.onChange(ids);
} else {
_this.setState({
selectedRowKeys: ids
});
}
}
var action = actionRef.current;
if (action) {
// bugfix: 假如数据一共有两页, 并且第二页只有一条数据, 删除该数据后应该自动切到上一页
var _action$pageInfo = action.pageInfo,
current = _action$pageInfo.current,
total = _action$pageInfo.total,
pageSize = _action$pageInfo.pageSize;
// 判断当前是否为空
var deleteRecordLength = record.id ? 1 : (selectedIds || []).length;
var isCurrentEmpty = total - deleteRecordLength === (current - 1) * pageSize;
if (current > 1 && isCurrentEmpty) {
action.setPageInfo({
current: current - 1
});
return;
}
action.reload();
}
}).finally(function () {
_this.setState({
delLoading: false
});
});
}
});
_defineProperty(_assertThisInitialized(_this), "tableAlertOptionRender", function (_ref) {
var _selectedRowKeys = _ref.selectedRowKeys,
onCleanSelected = _ref.onCleanSelected;
// state
var _this$state = _this.state,
delLoading = _this$state.delLoading,
selectedRows = _this$state.selectedRows;
/**
* 全局默认设置
*/
var setting = _this.context || {};
var globalOption = setting.tableAlertOption;
// props
var _this$props4 = _this.props,
_this$props4$tableAle = _this$props4.tableAlertOption,
tableAlertOption = _this$props4$tableAle === void 0 ? {} : _this$props4$tableAle,
columns = _this$props4.columns,
name = _this$props4.name,
delFunction = _this$props4.delFunction,
delPermission = _this$props4.delPermission,
confirmModelType = _this$props4.confirmModelType;
// 合并全局设置和组件传入的属性, 后者传入的优先级高
var mergedOption = mergeOptions(globalOption, tableAlertOption);
// tableAlertOption
var _mergedOption$hideDel = mergedOption.hideDelete,
hideDelete = _mergedOption$hideDel === void 0 ? false : _mergedOption$hideDel,
_mergedOption$enableE = mergedOption.enableExport,
enableExport = _mergedOption$enableE === void 0 ? false : _mergedOption$enableE,
_mergedOption$actions = mergedOption.actions,
alertActions = _mergedOption$actions === void 0 ? [] : _mergedOption$actions,
exportName = mergedOption.exportName,
deleteProps = mergedOption.deleteProps;
var _ref2 = deleteProps || {},
_ref2$btnText = _ref2.btnText,
btnText = _ref2$btnText === void 0 ? '批量删除' : _ref2$btnText,
title = _ref2.title,
rest = _objectWithoutProperties(_ref2, _excluded2);
var hasDelPermission = delPermission ? delPermission() : true;
/* 多选删除 */
var getDelDom = function getDelDom() {
if (!hideDelete && delFunction && hasDelPermission) {
var defaultTitle = title ? title(_selectedRowKeys.length) : "\u786E\u5B9A\u5220\u9664".concat(_selectedRowKeys.length, "\u6761\u6570\u636E\u5417?");
if (confirmModelType === 'modal') {
return /*#__PURE__*/_jsx(ModalConfirm, _objectSpread(_objectSpread({
title: defaultTitle
}, rest), {}, {
onOk: function onOk() {
_this.handleDelete(_selectedRowKeys, {}, onCleanSelected);
},
okButtonProps: {
loading: delLoading
},
children: /*#__PURE__*/_jsx(LinkButton, {
loading: delLoading,
children: btnText
})
}));
} else {
return /*#__PURE__*/_jsx(Popconfirm, _objectSpread(_objectSpread({
overlayStyle: {
width: '180px'
},
title: defaultTitle
}, rest), {}, {
onConfirm: function onConfirm() {
_this.handleDelete(_selectedRowKeys, {}, onCleanSelected);
},
okButtonProps: {
loading: delLoading
},
children: /*#__PURE__*/_jsx(LinkButton, {
loading: delLoading,
children: btnText
})
}));
}
}
};
return /*#__PURE__*/_jsxs(Space, {
size: 'middle',
children: [enableExport && /*#__PURE__*/_jsx(LinkButton, {
onClick: function onClick() {
exportAntTableToExcel(filterExportCols(columns), selectedRows, exportName || "".concat(name ? name + '列表' : '', "\u5BFC\u51FA"));
onCleanSelected();
},
children: "\u5BFC\u51FA\u6240\u9009"
}), getDelDom(), alertActions, /*#__PURE__*/_jsx("a", {
onClick: onCleanSelected,
children: "\u53D6\u6D88\u9009\u62E9"
})]
});
});
_defineProperty(_assertThisInitialized(_this), "selfOnOpen", function (formType, formRef, formData) {
_this.setState({
formType: formType
});
if (_this.props.onOpen) {
_this.props.onOpen(formType, formRef, formData);
}
});
_this.state = {
formType: '',
delLoading: false,
selectedRowKeys: [],
selectedRows: []
};
_this.targetId = '';
_this.selfInnerRef = /*#__PURE__*/createRef();
_this.selfActionRef = /*#__PURE__*/createRef();
_this.baseInnerObj = BaseInnerFn();
// @ts-ignore
_this.getInnerRef().current = {};
_this.getInnerRef().current.data = _this.baseInnerObj.data;
_this.getInnerRef().current.setData = _this.baseInnerObj.setData;
return _this;
}
_createClass(ProTable, [{
key: "componentDidMount",
value: function componentDidMount() {
/** 注册一个事件用于 reload 表格; 这对于一些已缓存的页面比较有用, 在其它页面可以控制刷新表格 */
document.addEventListener('reload', this.tableReload);
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
document.removeEventListener('reload', this.tableReload);
}
}, {
key: "render",
value: function render() {
var _this2 = this;
var _this$props5 = this.props,
_this$props5$rowKey = _this$props5.rowKey,
rowKey = _this$props5$rowKey === void 0 ? 'id' : _this$props5$rowKey,
name = _this$props5.name,
columns = _this$props5.columns,
options = _this$props5.options,
_this$props5$paginati = _this$props5.pagination,
pagination = _this$props5$paginati === void 0 ? {} : _this$props5$paginati,
formColumns = _this$props5.formColumns,
_this$props5$scroll = _this$props5.scroll,
scroll = _this$props5$scroll === void 0 ? {
x: '100%'
} : _this$props5$scroll,
onFinish = _this$props5.onFinish,
tableAlertOption = _this$props5.tableAlertOption,
rowSelection = _this$props5.rowSelection,
_this$props5$sticky = _this$props5.sticky,
sticky = _this$props5$sticky === void 0 ? true : _this$props5$sticky,
className = _this$props5.className,
optionColSpaceSize = _this$props5.optionColSpaceSize,
_this$props5$noPaddin = _this$props5.noPadding,
noPadding = _this$props5$noPaddin === void 0 ? false : _this$props5$noPaddin,
search = _this$props5.search,
request = _this$props5.request,
onOpen = _this$props5.onOpen,
_this$props5$modalPro = _this$props5.modalProps,
modalProps = _this$props5$modalPro === void 0 ? {} : _this$props5$modalPro,
_this$props5$formProp = _this$props5.formProps,
formProps = _this$props5$formProp === void 0 ? {} : _this$props5$formProp,
defaultHideInSearch = _this$props5.defaultHideInSearch,
confirmModalProps = _this$props5.confirmModalProps,
confirmModelType = _this$props5.confirmModelType,
optionColumnSpaceProps = _this$props5.optionColumnSpaceProps,
actionRef = _this$props5.actionRef,
rest = _objectWithoutProperties(_this$props5, _excluded3);
/**
* 全局默认设置
*/
var setting = this.context || {};
var _setting$modalProps = setting.modalProps,
settingModalProps = _setting$modalProps === void 0 ? {} : _setting$modalProps,
_setting$formProps = setting.formProps,
settingFormProps = _setting$formProps === void 0 ? {} : _setting$formProps,
_setting$searchConfig = setting.searchConfig,
searchConfig = _setting$searchConfig === void 0 ? {} : _setting$searchConfig,
globalOptions = setting.options,
globalDefaultHideInSearch = setting.defaultHideInSearch,
a = setting.confirmModalType,
b = setting.confirmModalProps,
c = setting.tableAlertOption,
restSetting = _objectWithoutProperties(setting, _excluded4);
var tableRest = _objectSpread(_objectSpread({}, restSetting), rest);
var modalRest = _objectSpread(_objectSpread({}, settingModalProps), modalProps);
var defaultSearchConfig = _objectSpread(_objectSpread({}, searchConfig), {}, {
className: 'searchFormStyleFix'
});
/**
* 处理 options 属性的合并
* 1. 组件属性为 false, 优先级高
* 2. 组件属性为 undefined, 走全局
*
*/
var mergedOptions = myMergeOptions(globalOptions, options, false);
var mergedDefaultHideInSearch = myMergeBoolean(globalDefaultHideInSearch, defaultHideInSearch, false);
return /*#__PURE__*/_jsxs(_Fragment, {
children: [/*#__PURE__*/_jsx(AntProTable, _objectSpread({
className: cs(className, optionColSpaceSize === 'small' && 'myTableSmallOptionCol', noPadding && 'rak-protable-no-padding'),
rowKey: rowKey,
headerTitle: this.getTitle()
// @ts-ignore
,
columns: this.patchColumn(this.enableDelete(normalizeTree(columns, function (_item) {
var item = _objectSpread({}, _item);
if (item.hideInSearch === undefined) {
item.hideInSearch = mergedDefaultHideInSearch;
}
if (item.type === 'search' || item.valueType === 'dependency') {
item.search = true;
item.hideInSearch = false;
item.hideInTable = true;
item.hideInForm = true;
}
return item;
}))).filter(function (col) {
if (col.type === 'form') return false;
return true;
}),
options: mergedOptions,
pagination: pagination,
scroll: scroll,
tableAlertOptionRender: this.tableAlertOptionRender,
rowSelection: this.getRowSelection(),
sticky: sticky,
search: search === false ? false : _objectSpread(_objectSpread({}, defaultSearchConfig), search),
request: request ? function (params, sort, filter) {
return new Promise(function (resolve, reject) {
request(handleRequestParams(params, sort), sort, filter).then(function (res) {
var innerRef = _this2.getInnerRef();
if (innerRef) {
innerRef.current.total = res.total;
innerRef.current.dataSource = res.data;
innerRef.current.params = handleRequestParams(params, sort);
}
resolve(res);
}).catch(function (err) {
return reject(err);
});
});
} : undefined,
actionRef: actionRef || this.selfActionRef
}, tableRest)), /*#__PURE__*/_jsx(ModalForm, _objectSpread({
innerRef: this.getInnerRef(),
title: this.getModalTitle()
// @ts-ignore
,
columns: (formColumns || columns).filter(function (col) {
if (col.type === 'form') return true;
if (!col.type) return true;
return false;
}),
onFinish: onFinish,
onOpen: this.selfOnOpen,
formProps: _objectSpread(_objectSpread({}, settingFormProps), formProps)
}, modalRest))]
});
}
}]);
return ProTable;
}(Component);
_defineProperty(ProTable, "contextType", ProTableContext);
export default ProTable;