fastlion-amis
Version:
一种MIS页面生成工具
403 lines (402 loc) • 32.3 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TableRow = void 0;
var tslib_1 = require("tslib");
var mobx_react_1 = require("mobx-react");
var react_1 = tslib_1.__importStar(require("react"));
var helper_1 = require("../../utils/helper");
var cloneDeep_1 = (0, tslib_1.__importDefault)(require("lodash/cloneDeep"));
var SimpleSpan_1 = tslib_1.__importStar(require("./simpleTableCell/SimpleSpan"));
var tpl_builtin_1 = require("../../utils/tpl-builtin");
var lodash_1 = require("lodash");
var sub_1 = require("../../utils/sub");
var tpl_1 = require("../../utils/tpl");
var icons_1 = require("@ant-design/icons");
var utils_1 = require("../../utils/utils");
var TableRow = /** @class */ (function (_super) {
(0, tslib_1.__extends)(TableRow, _super);
function TableRow(props) {
var _this = _super.call(this, props) || this;
// reaction?: () => void;
_this.dom = react_1.default.createRef();
_this.state = {
visited: false,
};
_this.clearVistiMapEventId = '';
_this.showVistiMapEventId = '';
_this.cellCache = new Map();
_this.state = {
visited: false,
};
_this.handleAction = _this.handleAction.bind(_this);
_this.handleQuickChange = _this.handleQuickChange.bind(_this);
_this.handleChange = _this.handleChange.bind(_this);
_this.handleItemClick = _this.handleItemClick.bind(_this);
return _this;
}
TableRow.prototype.componentDidMount = function () {
var _this = this;
if (!this.clearVistiMapEventId)
this.clearVistiMapEventId = sub_1.EventSub.on(this.props.tableId + "/" + sub_1.EventEnum.ClearVistiMap, function () {
_this.setState({ visited: false });
});
if (!this.showVistiMapEventId)
this.showVistiMapEventId = sub_1.EventSub.on(this.props.tableId + "/" + sub_1.EventEnum.ShowVistiMap, function (rowIndex, columnIndex, byKey) {
var _a, _b;
if (rowIndex === _this.props.itemIndex && byKey)
(_b = (_a = _this.props) === null || _a === void 0 ? void 0 : _a.headCurrentRows) === null || _b === void 0 ? void 0 : _b.call(_a, _this.props.itemIndex, _this.dom); // 如果用键盘触发才选中
if (Math.abs(_this.props.itemIndex - rowIndex) === 1 || _this.props.itemIndex === rowIndex) {
// 如果时第一次聚焦?
if (!_this.state.visited) {
_this.setState({ visited: true });
}
}
});
var _a = this.props, item = _a.item, headCurrentRows = _a.headCurrentRows;
if (this.props.itemIndex === 0) {
headCurrentRows === null || headCurrentRows === void 0 ? void 0 : headCurrentRows(0, this.dom, true);
}
};
TableRow.prototype.componentWillUnmount = function () {
sub_1.EventSub.off(this.props.tableId + "/" + sub_1.EventEnum.ClearVistiMap, this.clearVistiMapEventId);
sub_1.EventSub.off(this.props.tableId + "/" + sub_1.EventEnum.ShowVistiMap, this.showVistiMapEventId);
};
// 定义点击一行的行为,通过 itemAction配置
TableRow.prototype.handleItemClick = function (e) {
if ((0, helper_1.isClickOnInput)(e)) {
return;
}
var _a = this.props, itemAction = _a.itemAction, itemIndex = _a.itemIndex, onAction = _a.onAction, item = _a.item, headCurrentRows = _a.headCurrentRows, checkOnItemClick = _a.checkOnItemClick, onCheck = _a.onCheck, store = _a.store;
headCurrentRows === null || headCurrentRows === void 0 ? void 0 : headCurrentRows(itemIndex, this.dom);
if (itemAction) {
//itemAction中的某个字段在当前表格中不存在,会被赋值为undefined传到目标组件,导致目标组件获取不到该字段
var ctx = (0, helper_1.createObject)(store.data, (item === null || item === void 0 ? void 0 : item.data) || {}, {}, true);
onAction === null || onAction === void 0 ? void 0 : onAction(e, itemAction, ctx, true);
}
if (checkOnItemClick) {
onCheck === null || onCheck === void 0 ? void 0 : onCheck(item);
}
};
TableRow.prototype.handleAction = function (e, action, ctx) {
var _a = this.props, onAction = _a.onAction, item = _a.item;
onAction && onAction(e, action, ctx || item.data);
};
TableRow.prototype.handleQuickChange = function (values, saveImmediately, savePristine, resetOnFailed) {
var _a = this.props, onQuickChange = _a.onQuickChange, item = _a.item;
onQuickChange &&
onQuickChange(item, values, saveImmediately, savePristine, resetOnFailed);
};
TableRow.prototype.handleChange = function (value, name, submit, changePristine) {
var _a;
if (!name || typeof name !== 'string') {
return;
}
var _b = this.props, item = _b.item, onQuickChange = _b.onQuickChange;
onQuickChange === null || onQuickChange === void 0 ? void 0 : onQuickChange(item, (_a = {},
_a[name] = value,
_a), submit, changePristine);
};
TableRow.prototype.renderMobileRow = function () {
var _this = this;
var _a = this.props, itemClassName = _a.itemClassName, itemIndex = _a.itemIndex, item = _a.item, renderCell = _a.renderCell, children = _a.children, footableMode = _a.footableMode, ignoreFootableContent = _a.ignoreFootableContent, footableColSpan = _a.footableColSpan, regionPrefix = _a.regionPrefix, checkOnItemClick = _a.checkOnItemClick, ns = _a.classPrefix, render = _a.render, cx = _a.classnames, parent = _a.parent, itemAction = _a.itemAction, handleJump = _a.handleJump, tableLayout = _a.tableLayout, rest = (0, tslib_1.__rest)(_a, ["itemClassName", "itemIndex", "item", "renderCell", "children", "footableMode", "ignoreFootableContent", "footableColSpan", "regionPrefix", "checkOnItemClick", "classPrefix", "render", "classnames", "parent", "itemAction", "handleJump", "tableLayout"]);
var columns = (0, cloneDeep_1.default)(this.props.columns);
var checkIndex = columns.findIndex(function (item) { return item.type === '__checkme'; });
// 勾选框单独一列放置
var checkColumn = ~checkIndex ? columns.splice(checkIndex, 1)[0] : null;
return (react_1.default.createElement(react_1.default.Fragment, null,
checkColumn && renderCell("" + regionPrefix + itemIndex + "/" + checkColumn.index, checkColumn, item, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, rest), { width: null, rowIndex: itemIndex, colIndex: checkColumn.index, key: checkColumn.index, onAction: this.handleAction, onQuickChange: this.handleQuickChange, onChange: this.handleChange, handleJump: handleJump, tableLayout: tableLayout })),
react_1.default.createElement("td", { className: cx("Table-foot"), colSpan: footableColSpan },
react_1.default.createElement("table", { className: cx("Table-footTable") },
react_1.default.createElement("tbody", null, ignoreFootableContent
? columns.map(function (column) { return (react_1.default.createElement("tr", { key: column.index },
column.label !== false ? react_1.default.createElement("th", null) : null,
react_1.default.createElement("td", null))); })
: columns.map(function (column) { return (react_1.default.createElement("tr", { key: column.index },
column.label !== false ? (react_1.default.createElement("th", null, render("" + regionPrefix + itemIndex + "/" + column.index + "/tpl", column.label))) : null,
renderCell("" + regionPrefix + itemIndex + "/" + column.index, column, item, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, rest), { width: null, rowIndex: itemIndex, colIndex: column.index, key: column.index, onAction: _this.handleAction, onQuickChange: _this.handleQuickChange, onChange: _this.handleChange, handleJump: handleJump, tableLayout: tableLayout })))); }))))));
};
TableRow.prototype.renderTableCells = function (restProps) {
var _this = this;
var _a = this.props, itemClassName = _a.itemClassName, itemIndex = _a.itemIndex, item = _a.item, renderCell = _a.renderCell, handleJump = _a.handleJump, ns = _a.classPrefix, tableLayout = _a.tableLayout, render = _a.render, rowHeight = _a.rowHeight, cx = _a.classnames, columns = _a.columns, activeCol = _a.activeCol, activeRow = _a.activeRow, stickyWidths = _a.stickyWidths, store = _a.store, _b = _a.trRowSpans, trRowSpans = _b === void 0 ? {} : _b, tableId = _a.tableId, startColIndex = _a.startColIndex, endColIndex = _a.endColIndex; // @ts-ignore
var visited = this.state.visited;
var hiddenColspan = 0;
var renderedCells = [];
columns === null || columns === void 0 ? void 0 : columns.forEach(function (column, index) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
// 判断普通列是否可见
var isColumnVisible = index >= (startColIndex !== null && startColIndex !== void 0 ? startColIndex : 0) &&
index <= (endColIndex !== null && endColIndex !== void 0 ? endColIndex : columns.length - 1);
// const isColumnVisible = true
// 处理当前可见列
if (column.fixed || isColumnVisible) {
var classNameExpr = column.pristine.classNameExpr;
var showExpand = column.name === _this.props.firstColumnName && _this.props.hasChildrenRows;
var tdClassName = itemClassName + " " + cx(column.pristine.className, _this.props.setBorder ? 'td-border' : '', {
'active-cell': activeCol === column.name && activeRow === itemIndex,
'fixed-left-last': column.index === ((_a = store.leftFixedColumns[store.leftFixedColumns.length - 1]) === null || _a === void 0 ? void 0 : _a.index),
'fixed-right-first': column.index === ((_b = store.rightFixedColumns[0]) === null || _b === void 0 ? void 0 : _b.index)
}, classNameExpr ? (0, tpl_1.filter)(classNameExpr.replaceAll("." + column.pristine.rawName, "['" + column.name + "']"), item.data) : null);
// 在渲染第一个固定列之前,先处理之前积累的隐藏列
if (hiddenColspan > 0) {
renderedCells.push(react_1.default.createElement("td", { key: "hidden-" + index, className: cx(tdClassName), colSpan: hiddenColspan, style: {
position: 'relative',
width: 'auto',
minWidth: 'auto'
} }));
hiddenColspan = 0;
}
var groupValue_1 = {};
if ((_c = column.pristine.group) === null || _c === void 0 ? void 0 : _c.length) {
column.pristine.group.forEach(function (ele) {
var _a;
groupValue_1 = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, groupValue_1), (_a = {}, _a[ele.name] = item.locals[ele.name], _a));
});
}
// 尝试直接使用键值对获取值
var itemValue = ((_d = column.pristine.group) === null || _d === void 0 ? void 0 : _d.length) ? groupValue_1 :
column.name
? (_e = (_this.props.canAccessSuperData ? item.locals : item.data)) === null || _e === void 0 ? void 0 : _e[column.name] : column.value;
// const itemValue = column.pristine.group?.length ? groupValue :
// column.name
// ? resolveVariable(
// column.name,
// this.props.canAccessSuperData ? item.locals : item.data,
// ) : column.value
// 空的文件值判断
var blobImageValueIsEmpty = column.type === 'lion-upload' && ((0, lodash_1.isNil)(itemValue === null || itemValue === void 0 ? void 0 : itemValue.info) || ((_f = itemValue === null || itemValue === void 0 ? void 0 : itemValue.info) === null || _f === void 0 ? void 0 : _f.length) === 0);
// 无值的类型
var emptyValue = !!(((0, lodash_1.isNil)(itemValue)) || blobImageValueIsEmpty);
var textWidth = '';
if (!column.pristine.quickEdit) {
if (_this.props.autoWidth) {
textWidth = Array.isArray(itemValue) ? 5 : (_j = (_h = (_g = _this.props.store) === null || _g === void 0 ? void 0 : _g.textWidhMap) === null || _h === void 0 ? void 0 : _h[column.pristine.name]) === null || _j === void 0 ? void 0 : _j.textWidth;
}
}
var tdStyle = {
position: column.fixed && "sticky",
left: column.fixed === 'left' && (stickyWidths === null || stickyWidths === void 0 ? void 0 : stickyWidths["" + column.index]),
right: column.fixed === 'right' && (stickyWidths === null || stickyWidths === void 0 ? void 0 : stickyWidths["" + column.index]),
zIndex: column.fixed && 1,
textAlign: column.align,
height: rowHeight,
};
var tdWidth = column.pristine.editWidth || ((_l = (_k = column.pristine) === null || _k === void 0 ? void 0 : _k.quickEdit) === null || _l === void 0 ? void 0 : _l.width) || column.pristine.width || textWidth || (!['operation'].includes(column.type) && "200px");
if (!['__checkme'].includes(column.type)) {
tdStyle.maxWidth = tdWidth;
tdStyle.width = tdWidth;
}
else {
tdStyle.textAlign = "center";
}
var hasRecordMaping = column.type === 'mapping' && !(0, lodash_1.isNil)(itemValue) && ((_m = column === null || column === void 0 ? void 0 : column.map) === null || _m === void 0 ? void 0 : _m[itemValue]) && !column.pristine.quickEdit;
// 合法空值内容
var EMPTY_COLUMNS_TYPES = [
'__dragme',
'__expandme',
'__pseudoColumn',
'operation',
];
// 需要显示原始内容的特殊列类型-控制不展示
var SPECIAL_COLUMN_TYPES = [
'formula',
'__pseudoColumn',
'progress',
'color',
'lion-upload',
'lion-calc-tpl',
'link',
'images'
];
var visialbeChangeTd_1 = column.pristine.quickEdit && SimpleSpan_1.fakeQuickEdit.includes(column.pristine.quickEdit.type);
var unChangeQuickEditTd = column.pristine.quickEdit && !SimpleSpan_1.fakeQuickEdit.includes(column.pristine.quickEdit.type);
/**
* 判断是否显示原始单元格内容(不显示简单文本)
*
* 显示原始内容的条件分为两类:
* 1. 如果是空值列类型(如操作列、拖拽列等),直接显示原始内容
* 2. 存在行合并(trRowSpans)
* 3. 如果值不为空,并且满足以下任一条件:
* a. 特殊列类型(如公式列、进度条列等)
* b. 配置了备注效果(defaultOpen)
* c. 含有模板字符(tpl配置)
* d. 配置了跳转链接(linkUrl)
* e. 配置了跳转链接(href)
* f. 有远程资源(source)且不是映射类型
*/
var showOriginTd = (
// 如果是空值列类型(如操作列、拖拽列等),直接显示原始内容
EMPTY_COLUMNS_TYPES.includes(column.type) ||
// 如果值不为空,并且满足以下任一条件:
!emptyValue && (
// 1. 特殊列类型(如公式列、进度条列等)
SPECIAL_COLUMN_TYPES.includes(column.type) ||
// 2. 配置了备注效果(defaultOpen)
column.pristine.defaultOpen ||
// 3. 含有模板字符(tpl配置)
column.pristine.tpl ||
// 4. 配置了跳转链接(linkUrl-并且可以跳转)
(column.pristine.linkUrl && (0, utils_1.linkJump)((_o = column.pristine.linkId) !== null && _o !== void 0 ? _o : '', item.data, column.pristine.jumpDisabledOn)) ||
// 5. 配置了跳转链接(href)
column.pristine.href ||
// 6. 有远程资源(source)且不是映射类型
(column.pristine.source && !hasRecordMaping) ||
// 7. 复杂类型
typeof itemValue === 'object'));
var showSimpleText = !(showOriginTd || (visialbeChangeTd_1 && visited) || unChangeQuickEditTd);
if (column.name && trRowSpans[column.name] === 0) {
return;
}
var cell = void 0;
if (showSimpleText) {
var cacheKey = item.id + "-index:" + (column.index + '') + "-trRowSpans:" + ((trRowSpans[(column === null || column === void 0 ? void 0 : column.name) || ''] + '') || '') + "-itemValue:" + ((itemValue + '') || '') + "-checked:" + (item.checked ? 1 : 0) + "-fixed:" + (column.fixed ? stickyWidths === null || stickyWidths === void 0 ? void 0 : stickyWidths[column.index] : 0) + "-expanded:" + (item.expanded ? 1 : 0);
// 使用缓存的条件:
if (_this.cellCache.has(cacheKey)) {
renderedCells.push(_this.cellCache.get(cacheKey));
return;
}
cell = (react_1.default.createElement("td", { key: item.id + "-" + index + "-" + trRowSpans[column.name], rowSpan: trRowSpans[(column === null || column === void 0 ? void 0 : column.name) || ''], "table-name": _this.props.tableName, "column-name": column.name, "column-index": column.index, onClick: function (e) {
if (column.type === '__checkme') {
if (!_this.props.checkOnItemClick) {
e.stopPropagation();
}
;
if (!e.shiftKey)
_this.props.checkItem(item);
if (e.shiftKey)
_this.props.onCheck(item, false, true);
}
}, onMouseEnter: function () {
if (visialbeChangeTd_1) {
_this.setState({ visited: true });
sub_1.EventSub.emit(tableId + "/" + sub_1.EventEnum.ShowVistiMap, itemIndex, column.index);
}
}, className: tdClassName + (showExpand ? ' expand-cell' : ''), onContextMenu: function () {
_this.props.tableCtxMenuStore.showContextMenu(itemIndex, column.name, tableId);
}, style: (0, tslib_1.__assign)({}, tdStyle) },
react_1.default.createElement(SimpleSpan_1.default, { prefixContent: showExpand ? (react_1.default.createElement("span", { className: 'expand-tag', onClick: function () { return item.toggleExpanded(); } }, item.expandable ? (item.expanded ? react_1.default.createElement(icons_1.MinusSquareOutlined, null) : react_1.default.createElement(icons_1.PlusSquareOutlined, null)) : react_1.default.createElement(icons_1.PlusSquareOutlined, { style: { opacity: 0 } }))) : null, checked: item.checked, env: _this.props.env, primaryField: _this.props.store.primaryField, tableId: tableId, key: item.id + "-" + index, prefix: column.pristine.prefix, suffix: column.pristine.suffix, multiple: _this.props.multiple, ns: ns, value: itemValue, column: column, render: render, cx: _this.props.classnames, item: item, itemIndex: itemIndex, className: tdClassName })));
if (rowHeight)
_this.cellCache.set(cacheKey, cell);
}
else {
cell = renderCell(itemIndex + "/" + column.index, column, item, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, restProps), { rowIndex: itemIndex, itemRowSpans: trRowSpans, colIndex: column.index, key: column.index, onAction: _this.handleAction, onQuickChange: _this.handleQuickChange, onChange: _this.handleChange, handleJump: handleJump, className: tdClassName, style: tdStyle, tableLayout: tableLayout }));
}
renderedCells.push(cell);
}
else if (!isColumnVisible) {
// 非固定列不可见时增加隐藏列计数
hiddenColspan++;
return;
}
});
// 处理循环结束后剩余的隐藏列
if (hiddenColspan > 0) {
renderedCells.push(react_1.default.createElement("td", { key: "hidden-end", className: cx(itemClassName), colSpan: hiddenColspan, style: {
position: 'relative',
width: 'auto',
minWidth: 'auto'
} }));
}
return renderedCells;
};
TableRow.prototype.render = function () {
var _a, _b;
var _this = this;
var _c, _d, _e;
var _f = this.props, itemClassName = _f.itemClassName, itemIndex = _f.itemIndex, item = _f.item, renderCell = _f.renderCell, handleJump = _f.handleJump, children = _f.children, footableMode = _f.footableMode, ignoreFootableContent = _f.ignoreFootableContent, footableColSpan = _f.footableColSpan, regionPrefix = _f.regionPrefix, checkOnItemClick = _f.checkOnItemClick, ns = _f.classPrefix, tableLayout = _f.tableLayout, render = _f.render, cx = _f.classnames, parent = _f.parent, itemAction = _f.itemAction, headCurrentRows = _f.headCurrentRows, itemHighlight = _f.itemHighlight, currentHighlight = _f.currentHighlight, primaryField = _f.primaryField, hasEdit = _f.hasEdit, columns = _f.columns, activeCol = _f.activeCol, activeRow = _f.activeRow, rest = (0, tslib_1.__rest)(_f, ["itemClassName", "itemIndex", "item", "renderCell", "handleJump", "children", "footableMode", "ignoreFootableContent", "footableColSpan", "regionPrefix", "checkOnItemClick", "classPrefix", "tableLayout", "render", "classnames", "parent", "itemAction", "headCurrentRows", "itemHighlight", "currentHighlight", "primaryField", "hasEdit", "columns", "activeCol", "activeRow"]);
if (footableMode) {
if (!item.expanded) {
return null;
}
return (react_1.default.createElement("tr", { "data-id": item.id, key: item.id, "data-index": item.newIndex, onClick: this.handleItemClick, className: cx(itemClassName, (_a = {
// 'is-hovered': item.isHover,
'is-checked': item.checked,
'is-modified': hasEdit ? item.modified : '',
'is-moved': item.moved
},
_a["Table-tr--hasItemAction"] = itemAction,
_a["Table-tr--odd"] = itemIndex % 2 === 0,
_a["Table-tr--even"] = itemIndex % 2 === 1,
_a)) },
react_1.default.createElement("td", { className: cx("Table-foot"), colSpan: footableColSpan },
react_1.default.createElement("table", { className: cx("Table-footTable") },
react_1.default.createElement("tbody", null, ignoreFootableContent
? columns.map(function (column) { return (react_1.default.createElement("tr", { key: column.index },
column.label !== false ? react_1.default.createElement("th", null) : null,
react_1.default.createElement("td", null))); })
: columns.map(function (column) { return (react_1.default.createElement("tr", { key: column.index },
column.label !== false ? (react_1.default.createElement("th", null, render("" + regionPrefix + itemIndex + "/" + column.index + "/tpl", column.label))) : null,
renderCell("" + regionPrefix + itemIndex + "/" + column.index, column, item, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, rest), { width: null, rowIndex: itemIndex, colIndex: column.index, key: column.index, onAction: _this.handleAction, onQuickChange: _this.handleQuickChange, onChange: _this.handleChange, handleJump: handleJump, tableLayout: tableLayout })))); }))))));
}
if (parent && !parent.expanded) {
return null;
}
// Jay
var _g = this.props, store = _g.store, _h = _g.trRowSpans, trRowSpans = _h === void 0 ? {} : _h; // @ts-ignore
var leftFixedColumns = store.leftFixedColumns;
var lastLeftFixedIndex = (_c = leftFixedColumns[leftFixedColumns.length - 1]) === null || _c === void 0 ? void 0 : _c.index;
var rightFixedColumns = store.rightFixedColumns;
var firstRightFixedIndex = (_d = rightFixedColumns[0]) === null || _d === void 0 ? void 0 : _d.index;
var operationColumn = this.props.operationColumn; // @ts-ignore
// 根据TableBody计算的列范围渲染元素
return (react_1.default.createElement("tr", { key: item.id, ref: this.dom, onMouseEnter: function () {
if (!_this.state.visited && columns.some(function (_) { return _.pristine.quickEdit; })) {
_this.setState({ visited: true });
sub_1.EventSub.emit(_this.props.tableId + "/" + sub_1.EventEnum.ShowVistiMap, itemIndex); // 广播订阅事件
}
}, onClick: this.handleItemClick, "data-index": item.depth === 1 ? item.newIndex : undefined, "data-id": item.id, className: cx(itemClassName, (_b = {
// 'is-hovered': item.isHover,
'is-checked': item.checked,
'is-Highlight': itemHighlight,
'is-current': currentHighlight,
'is-modified': hasEdit ? item.modified : '',
'is-moved': item.moved,
'is-expanded': item.expanded,
'is-expandable': item.expandable
},
_b["Table-tr--hasItemAction"] = itemAction,
_b["Table-tr--odd"] = itemIndex % 2 === 0,
_b["Table-tr--even"] = itemIndex % 2 === 1,
_b['is-border'] = (0, helper_1.isMobile)() && !operationColumn,
_b), "Table-tr--" + item.depth + "th") }, !(store.mobileUI && tableLayout === 'vertical') ?
this.renderTableCells(rest) : (react_1.default.createElement("td", { className: cx("Table-foot"), colSpan: footableColSpan, style: { padding: operationColumn ? '0 0 12px 0' : '0' } },
react_1.default.createElement("table", { className: cx("Table-footTable") },
react_1.default.createElement("tbody", null, ignoreFootableContent
? columns.map(function (column) { return (react_1.default.createElement("tr", { key: column.index },
column.label !== false ? react_1.default.createElement("th", null) : null,
react_1.default.createElement("td", null))); })
: columns.filter(function (column) { return column.type != 'operation'; }).map(function (column) {
var _a, _b, _c;
var groupValue = {};
if ((_a = column.pristine.group) === null || _a === void 0 ? void 0 : _a.length) {
column.pristine.group.forEach(function (ele) {
var _a;
groupValue = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, groupValue), (_a = {}, _a[ele.name] = item.locals[ele.name], _a));
});
}
var tdClassName = '';
var itemValue = ((_b = column.pristine.group) === null || _b === void 0 ? void 0 : _b.length) ? groupValue :
column.name
? (0, tpl_builtin_1.resolveVariable)(column.name, _this.props.canAccessSuperData ? item.locals : item.data) : column.value;
var showOriginTd = ['__dragme', '__expandme', 'progress', 'operation', 'color', '__checkme', '__pseudoColumn'].includes(column.type) || column.pristine.defaultOpen || column.pristine.tpl || column.pristine.linkUrl || (column.pristine.source && !((_c = column === null || column === void 0 ? void 0 : column.map) === null || _c === void 0 ? void 0 : _c[itemValue])) || (typeof itemValue === 'object' && !(0, lodash_1.isNil)(itemValue)); // 正式用
// 合并表格
if (column.name && trRowSpans[column.name] === 0) {
return null;
}
return (react_1.default.createElement("tr", { key: column.index },
column.label !== false ? (column.type == '__expandme' ? null : react_1.default.createElement("th", null, (0, helper_1.isMobile)() ? react_1.default.createElement("span", null, column.label) : render("" + regionPrefix + itemIndex + "/" + column.index + "/tpl", column.label))) : null,
!showOriginTd ? react_1.default.createElement("td", { rowSpan: trRowSpans[(column === null || column === void 0 ? void 0 : column.name) || ''] },
" ",
react_1.default.createElement(SimpleSpan_1.default, { key: item.id + column.index, prefix: column.pristine.prefix, checked: item.checked, suffix: column.pristine.suffix, multiple: _this.props.multiple, ns: ns, value: itemValue, column: column, render: render, cx: _this.props.classnames, item: item, className: tdClassName })) : renderCell("" + regionPrefix + itemIndex + "/" + column.index, column, item, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, rest), { width: null, rowIndex: itemIndex, colIndex: column.index, key: column.index, tableLayout: tableLayout, onAction: _this.handleAction, onQuickChange: _this.handleQuickChange, onChange: _this.handleChange }))));
})),
operationColumn && react_1.default.createElement("tfoot", null,
react_1.default.createElement("th", { style: { textAlign: 'right' }, colSpan: 2 }, render('operations-buttons', (_e = operationColumn === null || operationColumn === void 0 ? void 0 : operationColumn.pristine) === null || _e === void 0 ? void 0 : _e.buttons, { data: item.data }))))))));
};
TableRow = (0, tslib_1.__decorate)([
(0, mobx_react_1.inject)('tableCtxMenuStore'),
mobx_react_1.observer,
(0, tslib_1.__metadata)("design:paramtypes", [Object])
], TableRow);
return TableRow;
}(react_1.PureComponent));
exports.TableRow = TableRow;
//# sourceMappingURL=./renderers/Table/TableRow.js.map