UNPKG

ming-demo3

Version:
1,424 lines (1,231 loc) 57.2 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _findIndex2 = _interopRequireDefault(require("lodash/findIndex")); var _forEach2 = _interopRequireDefault(require("lodash/forEach")); var _react = _interopRequireWildcard(require("react")); var _fixedDataTable = require("fixed-data-table-2"); var _baseui = require("@mdf/baseui"); var _row = _interopRequireDefault(require("./row")); var _util = require("@mdf/cube/lib/helpers/util"); var _extend = require("@mdf/cube/lib/extend"); var _TreeTableEditCell = _interopRequireDefault(require("../grid/TreeTableEditCell")); var _GridFilterModel = _interopRequireDefault(require("../grid/GridFilterModel")); var TreeTable = function (_Component) { (0, _inherits2["default"])(TreeTable, _Component); function TreeTable(props) { var _this; (0, _classCallCheck2["default"])(this, TreeTable); _this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(TreeTable).call(this, props)); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setColumns", function (columndata) { var columns = [], actionMeta = _this.props.actionMeta; columns.push({ "cFieldName": "expandCol", "cItemName": "expandCol", "cCaption": "", "cShowCaption": "", "iColWidth": 30, "cControlType": "expand", "iAlign": 2 }); if (actionMeta && actionMeta.controls) { columns.push({ "cFieldName": "action", "cItemName": "action", "cCaption": "", "cShowCaption": "", "iColWidth": _this.fixedwidth, "cControlType": "action", "iAlign": 2, "fixedRight": true }); } (0, _forEach2["default"])(columndata, function (column, key) { columns.push(column); }); _this.setState({ columns: columns }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setActionState", function (data) { var rowKey = _this.state.rowKey; var key = data.key, itemName = data.itemName, name = data.name, value = data.value; _this.actionState[key][itemName][name] = value; _this.setState({ rowKey: rowKey }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setActionsState", function (data) { if (data && data.length > 0) { var rowKey = _this.state.rowKey; data.map(function (row) { _this.actionState[row.key][row.itemName][row.name] = row.value; }); _this.setState({ rowKey: rowKey }); } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setShowActionRows", function (rows) { if ((0, _typeof2["default"])(rows) == 'object' && rows.length > 0) { rows.map(function (row) { if (_this.keyMap[row.rowKey]) _this.keyMap[row.rowKey].showAction = row.showAction; }); } else { console.log('setShowActionRows------参数错误!'); } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getKeyMap", function (data, rowKey) { var actionList = _this.props.actionMeta ? _this.props.actionMeta.controls : []; var contrast = {}; data.map(function (item) { var key = item[rowKey]; contrast[key] = { "isExpand": false, "showAction": false, "isEnd": item.isEnd, "level": item.level, "parent": item.parent, "key": key, "row": item }; if (_this.state.expandAllRow) contrast[key].isExpand = true; if (_this.keyMap[key] && _this.keyMap[key].isExpand) contrast[key].isExpand = _this.keyMap[key].isExpand; _this.keyMap[key] = contrast[key]; _this.cellStatus[key] = {}; _this.actionState[key] = {}; actionList.map(function (action) { if (!_this.actionState[key][action.cItemName]) _this.actionState[key][action.cItemName] = { disabled: false, visible: true }; }); if (item.children) contrast[key].children = _this.getKeyMap(item.children, rowKey, {}, status); }); return contrast; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setExpandRow", function (data) { if (!data) return; var rowKey = data.rowKey, isExpand = data.isExpand; if (_this.keyMap[rowKey]) { _this.selectRowIndex = rowKey; var parentRowKey = _this.keyMap[rowKey].parent; _this.keyMap[parentRowKey].isExpand = isExpand; } _this.setState({ "rowKey": _this.state.rowKey }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleRowClick", function (e, index) { if (!e || e.target.className == 'acticonCell') return; var selectKey = ''; if (_this.expandActionClick) { _this.expandActionClick = false; _this.currentKey = _this.selectRowIndex; return; } var _this$state = _this.state, dataSource = _this$state.dataSource, rowKey = _this$state.rowKey; if (e) { var target = e.target; var className = target.className ? target.className : ''; if (className.indexOf('expand-row') >= 0 || className.indexOf('expand-col') >= 0) { _this.selectRowIndex = target.id; _this.setState({ rowKey: rowKey }); return; } } if ((0, _typeof2["default"])(index) == 'object') { selectKey = _this.keyMap[index.key].row[rowKey]; } else { _this.selectRowIndex = index; if (dataSource.length == 0 || !dataSource[index]) return; selectKey = dataSource[index][rowKey]; } _this.currentKey = selectKey; if (_this.props.model) _this.props.model.select(selectKey); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getColumnControl", function () { var columns = _this.state.columns; var ret = []; columns.map(function (col) { var column = this.getColumn(col); ret.push(column); }, (0, _assertThisInitialized2["default"])(_this)); return ret; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getColumn", function (col) { var bIsNull = col.bIsNull, cShowCaption = col.cShowCaption, fixedRight = col.fixedRight, iAlign = col.iAlign, cItemName = col.cItemName, iColWidth = col.iColWidth, bCanModify = col.bCanModify; var headerCell = _react["default"].createElement(_fixedDataTable.Cell, null, _react["default"].createElement("div", { className: "billing-head-name" }, cShowCaption)); var width, align, fixed = col.bFixed == 1 ? true : false; width = isNaN(parseFloat(iColWidth)) ? 200 : parseFloat(iColWidth); if (iAlign === 1) align = 'left';else if (iAlign === 2) align = 'center';else align = 'right'; if (cItemName != 'expandCol' && cItemName != 'action') headerCell = _react["default"].createElement(_fixedDataTable.Cell, { className: "billing-head-name" }, _react["default"].createElement(_GridFilterModel["default"], { fixedtable: _this.refs.fixedtable, bTree: true, readOnly: _this.state.readOnly, Column: col, name: cShowCaption, model: _this.props.model, width: width, attr: cItemName, data: _this.state.dataSource, onlockChange: _this.onlockChange, lockstate: _this.lockstate, lockfixed: fixed, onLookUpChange: _this.onLookUpChange, lookUpKey: _this.lookUpKey })); if (fixedRight) { return _react["default"].createElement(_fixedDataTable.Column, { key: cItemName, isResizable: true, allowCellsRecycling: true, columnKey: cItemName, header: headerCell, cell: function cell(rowIndex) { return _this.setCell(rowIndex, col); }, width: width, align: "center", fixedRight: true }); } else { return _react["default"].createElement(_fixedDataTable.Column, { key: cItemName, isResizable: true, allowCellsRecycling: true, columnKey: cItemName, header: headerCell, cell: function cell(rowProperty) { return _this.setCell(rowProperty, col); }, width: width, align: align, fixed: fixed }); } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onLookUpChange", function (lookUpVal, type, cItemName) { if (!type) { _this.lookUpRowIndexes = []; _this.lookUpRow = {}; _this.lookUpKey = ''; } var _this$state2 = _this.state, rowKey = _this$state2.rowKey, dataSource = _this$state2.dataSource; if (cb.utils.isEmpty(lookUpVal)) lookUpVal = null; if (!dataSource || dataSource.length == 0) return; for (var i = 0; i < dataSource.length; i++) { var val = dataSource[i][cItemName]; var text = val; if ((0, _typeof2["default"])(val) == 'object') { text = val.text; } if (!cb.utils.isEmpty(text)) { if (text.toString().indexOf(lookUpVal) != -1) { _this.lookUpRowIndexes.push({ 'type': 'main', 'index': i }); } } if (dataSource[i].children) _this.loopLookUp(dataSource[i].children, lookUpVal, rowKey, cItemName, dataSource[i][rowKey]); } var index = _this.lookUpRowIndexes.findIndex(function (item) { return _this.lookUpRow.index == item.index; }); if (index == -1) { _this.lookUpRow = _this.lookUpRowIndexes[0]; index = 0; } if (type == 'up' && index != 0) _this.lookUpRow = _this.lookUpRowIndexes[index - 1]; if (type == 'down' && index != _this.lookUpRowIndexes.length - 1) _this.lookUpRow = _this.lookUpRowIndexes[index + 1]; if (!_this.lookUpRow) _this.lookUpRow = {};else { _this.scrollTop = _this.getScrollTop(type, index); _this.scrollTop -= 160; } _this.lookUpKey = cItemName; _this.setState({ 'rowKey': _this.state.rowKey }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onlockChange", function (key, state) { _this.lockstate = key; _this.unlockstate = state; var columns = _this.state.columns; var _index = (0, _findIndex2["default"])(columns, function (obj) { return obj.cItemName == _this.lockstate; }); columns.map(function (col, index) { if (_index > -1) { var colfixed = { bFixed: 1 }; var _colfixed = { bFixed: 0 }; if (_index != index) { _index > index ? Object.assign(col, colfixed) : Object.assign(col, _colfixed); } else { this.unlockstate ? Object.assign(col, colfixed) : Object.assign(col, _colfixed); } } }, (0, _assertThisInitialized2["default"])(_this)); _this.setState({ 'rowKey': _this.state.rowKey, columns: columns }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getScrollTop", function (type, index) { var _self = (0, _assertThisInitialized2["default"])(_this); var loopIndex = function loopIndex(parentId) { var data = _this.keyMap[parentId]; if (data.parent) return loopIndex(data.parent);else return parentId; }; var checkChild = function checkChild(id, pId) { var bChild = false, nowPId = _this.keyMap[id].parent; var nextPId = _this.keyMap[nowPId] ? _this.keyMap[nowPId].parent : null; if (nowPId == pId) { bChild = true; } else if (nextPId) bChild = checkChild(nowPId, pId); return bChild; }; var loopHeight = function loopHeight(scrollTop, data, id, rowKey, bInit) { for (var i = 0; i < data.length; i++) { if (data[i][rowKey] == id) break; scrollTop += 40; if (data[i].children) { var _id = data[i][rowKey]; if (_self.keyMap[_id]) { if (_self.keyMap[_id].isExpand) { scrollTop = loopHeight(scrollTop, data[i].children, id, rowKey); } } else { console.error("this.keyMap[" + _id + "] don't exist!"); } } if (checkChild(id, data[i][rowKey])) break; } return scrollTop; }; var scrollTop = 0; var _this$state3 = _this.state, rowKey = _this$state3.rowKey, dataSource = _this$state3.dataSource; if (_this.lookUpRow.type == 'main') { scrollTop = loopHeight(scrollTop, dataSource, dataSource[_this.lookUpRow.index][rowKey], rowKey); } else { scrollTop = loopHeight(scrollTop, dataSource, _this.lookUpRow.index, rowKey, true); } return scrollTop; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "loopLookUp", function (rows, lookUpVal, rowKey, cItemName, parentKey) { rows.map(function (row) { var val = row[cItemName]; var text = val; if ((0, _typeof2["default"])(val) == 'object') { text = val.text; } if (!cb.utils.isEmpty(text)) { if (text.toString().indexOf(lookUpVal) != -1) { _this.lookUpRowIndexes.push({ 'type': 'sub', 'index': row[rowKey], 'parent': parentKey }); _this.loopSetExpand(parentKey); } } if (row.children) _this.loopLookUp(row.children, lookUpVal, rowKey, cItemName, row[rowKey]); }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "loopSetExpand", function (parentKey) { _this.keyMap[parentKey].isExpand = true; if (_this.keyMap[parentKey].parent) _this.loopSetExpand(_this.keyMap[parentKey].parent); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setCell", function (rowProperty, col) { var dataSource = _this.state.dataSource; var index = rowProperty.rowIndex; var row = dataSource[index]; var text = _this.compareCell(row, col, index, false, rowProperty); var titile = text; if ((0, _typeof2["default"])(text) == 'object') { if (text.props && (0, _typeof2["default"])(text.props.children) != 'object') titile = text.props.children;else titile = ''; } return _react["default"].createElement(_fixedDataTable.Cell, { width: rowProperty.width, height: _this.rowHeight, className: "billing-table-cell" }, _react["default"].createElement("div", { title: titile, className: "cell-text", onClick: function onClick(e) { return _this.onCellClick(e, col, index); } }, text)); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "compareCell", function (row, col, index, bExpand, rowProperty) { var _this$state4 = _this.state, rowKey = _this$state4.rowKey, dataSource = _this$state4.dataSource; var ctrlType = col.cControlType && col.cControlType.trim().toLocaleLowerCase(); var cItemName = col.cItemName, bCanModify = col.bCanModify, bJointQuery = col.bJointQuery, formatter = col.formatter; var text = cb.utils.isEmpty(row[cItemName]) ? "" : row[cItemName]; if (formatter) { var cellObj = formatter(rowProperty, bExpand ? index.row : dataSource[index]); if (cellObj) { if (cellObj.formatterKey) { var ComName = _extend.extendComp.formatter[cellObj.formatterKey]; if (!ComName) return null; return _react["default"].createElement(ComName, (0, _extends2["default"])({ model: _this.props.model }, cellObj.props)); } var cellHtml = '', cellText = ''; var cellProps = {}; if (cellObj.html) { cellHtml += cellObj.html; cellText += cellObj.text || cellObj.html; Object.assign(cellProps, cellObj.props); } var cellCom = _react["default"].createElement("span", (0, _extends2["default"])({ title: cellText, dangerouslySetInnerHTML: { __html: cellHtml } }, cellProps)); return _react["default"].createElement("div", { style: cellState.style }, cellObj && cellObj.override ? null : _react["default"].createElement("span", { title: data[index][columnKey] }, data[index][columnKey]), cellCom); } } if (bCanModify && _this.state.readOnly === false) { var bEditCell = false; if (bExpand) { bEditCell = _this.cellStatus[index.key] ? _this.cellStatus[index.key][cItemName] : false; } else { var key = _this.state.dataSource[index][rowKey]; bEditCell = _this.cellStatus[key] ? _this.cellStatus[key][cItemName] : false; } if (bEditCell) { return _react["default"].createElement(_TreeTableEditCell["default"], (0, _extends2["default"])({}, _this.state, _this.props, { bExpand: bExpand, keyMap: _this.keyMap, column: col, rowIndex: index, onCellBlur: _this.onCellBlur, row: row })); } } switch (ctrlType) { case 'select': return _this.renderSelect(col, text); case 'inputnumber': case 'money': case 'price': if (cb.utils.isEmpty(text)) return ''; if (isNaN(text)) return text; var cFormatData = col.cFormatData; try { if (!cFormatData || cFormatData == '') { cFormatData = {}; } else { cFormatData = JSON.parse(cFormatData); } } catch (e) { cb.utils.alert('数量/金额/单价,预制错误!', 'error'); } var iNumPoint = col.iNumPoint; var decimal = cFormatData.decimal ? (0, _util.getPredicateValue)(cFormatData.decimal) : null; if (ctrlType === 'money') { if (decimal) iNumPoint = decimal;else iNumPoint = cb.rest.AppContext.option.amountofdecimal; } else if (ctrlType === 'price') { if (decimal) iNumPoint = decimal;else iNumPoint = cb.rest.AppContext.option.monovalentdecimal; } else { if (decimal) iNumPoint = decimal;else if (cb.utils.isEmpty(iNumPoint)) iNumPoint = null; } if (!isNaN(iNumPoint) && iNumPoint != null) { text = parseFloat(text); text = (0, _util.getRoundValue)(text, iNumPoint); } if (cFormatData.after) text = text + cFormatData.after; return text; case 'expand': var isExpand; if (row.children) { if (bExpand) isExpand = _this.keyMap[index.key].isExpand;else isExpand = _this.keyMap[row[rowKey]].isExpand; if (isExpand) text = _react["default"].createElement("div", { className: "expand-icon", onClick: function onClick(e) { return _this.onExpandClick(e, index); } }, _react["default"].createElement(_baseui.Icon, { type: "minus-square-o" }));else text = _react["default"].createElement("div", { className: "expand-icon", onClick: function onClick(e) { return _this.onExpandClick(e, index); } }, _react["default"].createElement(_baseui.Icon, { type: "plus-square-o" })); } else { text = ""; } break; case 'checkbox': if (text == null || text == '') text = false; var indeterminate = _this.getIndeterminate(index, col.cItemName, bExpand); if (indeterminate) text = 0; return _react["default"].createElement(_baseui.Checkbox, { onChange: function onChange(e) { return _this.onCheckChange(e, index, col.cItemName, bExpand); }, checked: text, indeterminate: indeterminate }); break; case 'action': text = _this.getActionControl(index); return text; } return bJointQuery ? _react["default"].createElement("a", { className: "joinQueryCell", onClick: function onClick(e) { return _this.handleJointQuery(e, index, cItemName); } }, text) : text; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCellBlur", function (value, bExpand, rowIndex, cItemName, updateData) { var node, key; if (bExpand) { node = _this.keyMap[rowIndex.key].row; key = rowIndex.key; } else { var _this$state5 = _this.state, dataSource = _this$state5.dataSource, rowKey = _this$state5.rowKey; node = dataSource[rowIndex]; key = node[rowKey]; } if (updateData) { if (!cb.utils.isEmpty(value) && (0, _typeof2["default"])(value) == 'object') { for (var a in value) { node[a] = value[a]; } } else { node[cItemName] = value; } _this.props.model.updateNode(node); } _this.cellStatus[key][cItemName] = false; _this.setState({ rowKey: _this.state.rowKey }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCellClick", function (e, col, index, isExpand) { if (!col.bCanModify || _this.state.readOnly) return; _this.props.model.promiseExecute('cellClick', { col: col, index: index, isExpand: isExpand }, function () { var _this$state6 = _this.state, rowKey = _this$state6.rowKey, dataSource = _this$state6.dataSource; var key; if (isExpand) { key = index; } else { key = dataSource[index][rowKey]; } if (_this.cellStatus[key]) _this.cellStatus[key][col.cItemName] = true; _this.setState({ rowKey: rowKey }); }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCheckChange", function (e, index, cItemName, isExpand) { var _this$state7 = _this.state, dataSource = _this$state7.dataSource, rowKey = _this$state7.rowKey; var checked = e.target.checked; var node = {}; if (isExpand) { node = index.row; if (node.parent) { node[cItemName] = checked; _this.updateNodes.push(node); if (node.children) _this.loopChildNodes(_this.keyMap[node[rowKey]], cItemName, checked); _this.loopUpdateNodes(_this.keyMap[node.parent], cItemName, checked); _this.props.model.updateNodes(_this.updateNodes); _this.updateNodes = []; return; } } else { node = dataSource[index]; } _this.props.model.updateNodeRecursive(node, cItemName, checked); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "loopChildNodes", function (data, cItemName, checked) { var children = data.children; for (var key in children) { var childRow = children[key].row; var child = children[key].children; if (childRow[cItemName] != checked) { childRow[cItemName] = checked; _this.updateNodes.push(childRow); } if (child) _this.loopChildNodes(_this.keyMap[children[key].key], cItemName, checked); } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "loopUpdateNodes", function (data, cItemName, checked) { var children = data.children, row = data.row, level = data.level; if (checked) { var allChecked = true; for (var key in children) { var childRow = children[key].row; if (!childRow[cItemName] || childRow[cItemName] == '') { allChecked = false; } } if (allChecked) { row[cItemName] = checked; _this.updateNodes.push(row); } } else { if (!row[cItemName]) { return; } else { row[cItemName] = checked; _this.updateNodes.push(row); } } if (level > 1) _this.loopUpdateNodes(_this.keyMap[data.parent], cItemName, checked); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getIndeterminate", function (index, cItemName, bExpand) { var _this$state8 = _this.state, dataSource = _this$state8.dataSource, rowKey = _this$state8.rowKey; var key = null, indeterminate = false, node; if (bExpand) key = index.key;else key = dataSource[index][rowKey]; node = _this.keyMap[key]; if (node.isEnd) return false; indeterminate = _this.loopChildIndeterminate(node, cItemName); return indeterminate; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "loopChildIndeterminate", function (data, cItemName) { var children = data.children; var indeterminate = true; var checkedLen = 0; var allLen = 0; for (var key in children) { allLen += 1; var childRow = children[key].row; var child = children[key].children; var cInde = void 0; if (child) cInde = _this.loopChildIndeterminate(_this.keyMap[children[key].key], cItemName); if (childRow[cItemName] || cInde) checkedLen += 1; } if (checkedLen == 0 || checkedLen == allLen) indeterminate = false; return indeterminate; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getActionControl", function (index) { var _this$state9 = _this.state, dataSource = _this$state9.dataSource, rowKey = _this$state9.rowKey; if (_this.currentKey) { _this.keyMap[_this.currentKey].showAction = true; } var actionList = _this.props.actionMeta.controls; var actionControl = [], key = ""; if ((0, _typeof2["default"])(index) == 'object') { key = index.row[rowKey]; if (index.showAction) { actionList.map(function (action) { if (this.actionState[key] && this.actionState[key][action.cItemName].visible) { var temp_action = this.getPopControl(action, index); actionControl.push(temp_action); } }, (0, _assertThisInitialized2["default"])(_this)); } } else { var _this$state10 = _this.state, _dataSource = _this$state10.dataSource, _rowKey = _this$state10.rowKey; key = _dataSource[index][_rowKey]; if (_this.keyMap[key].showAction) { actionList.map(function (action) { if (this.actionState[key] && this.actionState[key][action.cItemName].visible) { var temp_action = this.getPopControl(action, index); actionControl.push(temp_action); } }, (0, _assertThisInitialized2["default"])(_this)); } } var className = "acticonCell"; if (actionControl.length == 0) return _react["default"].createElement("div", null); return _react["default"].createElement("div", { className: className, style: { "width": _this.fixedwidth } }, actionControl); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getPopControl", function (action, index) { var text = action.iStyle === 2 ? null : action.cShowCaption; var temp_action = _react["default"].createElement("span", { key: action.cItemName }, _react["default"].createElement("a", { className: "table-list-btn", onClick: function onClick(e) { return _this.ActionClick(e, action, index); } }, text)); if (action.popoverKey) { var ComName = _extend.extendComp.popover[action.popoverKey]; var rowData; if ((0, _typeof2["default"])(index) == 'object') rowData = index.row;else rowData = _this.state.dataSource[index]; if (ComName) temp_action = _react["default"].createElement(ComName, { model: action.model, data: rowData }, temp_action); } return temp_action; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "ActionClick", function (e, action, rowIndex) { var _this$state11 = _this.state, dataSource = _this$state11.dataSource, rowKey = _this$state11.rowKey; if ((0, _typeof2["default"])(rowIndex) != "object") { if (dataSource.length == 0 || !dataSource[rowIndex]) return; if (_this.props.model) _this.props.model.select(dataSource[rowIndex][rowKey]); } else { _this.expandActionClick = true; var selectKey = _this.keyMap[rowIndex.key].row[rowKey]; _this.selectRowIndex = selectKey; _this.currentKey = selectKey; if (_this.props.model) _this.props.model.select(selectKey); } if (_this.actionClickTime) { var nowTime = new Date().valueOf(); if (nowTime - _this.actionClickTime < 1000) return; _this.actionClickTime = nowTime; } else { _this.actionClickTime = new Date().valueOf(); } var viewModel = _this.props.model.getParent(); while (viewModel.getParent()) { viewModel = viewModel.getParent(); } var params = { index: rowIndex, cItemName: action.cItemName }; viewModel.get(action.cItemName).fireEvent('click', params); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_subRowHeightGetter", function (index) { var _this$state12 = _this.state, dataSource = _this$state12.dataSource, rowKey = _this$state12.rowKey; var rowData = dataSource[index]; var key = rowData[rowKey]; var subRowHeight = 40; if (!cb.utils.isEmpty(_this.keyMap[key]) && rowData.children) { if (_this.keyMap[key].isExpand) { var children = rowData.children; subRowHeight = _this.getSubRowHeight(_this.keyMap[key].children, children.length * 40); } else { subRowHeight = 0; } } else { subRowHeight = 0; } return subRowHeight; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getSubRowHeight", function (children, height) { for (var key in children) { var child = children[key]; if (child.isExpand) { var len = 0; for (var key1 in child.children) { len = len + 1; } height = height + len * 40; if (child.children) { height = _this.getSubRowHeight(child.children, height); } } } return height; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getGridHeight", function () { var _this$state13 = _this.state, dataSource = _this$state13.dataSource, rowKey = _this$state13.rowKey; var len = dataSource.length > 10 ? 10 : dataSource.length; var maxHeight = 10 * 40 + 40 + 17; var height = len * 40 + 40 + 17; dataSource.map(function (rowData, index) { var key = rowData[rowKey]; var subRowHeight = 40; if (!cb.utils.isEmpty(_this.keyMap[key]) && rowData.children) { if (_this.keyMap[key].isExpand) { var children = rowData.children; subRowHeight = _this.getSubRowHeight(_this.keyMap[key].children, children.length * 40); } else { subRowHeight = 0; } } else { subRowHeight = 0; } height = height + subRowHeight; }); if (maxHeight < height) height = maxHeight; return height; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_rowExpandedGetter", function (_ref) { var rowIndex = _ref.rowIndex, width = _ref.width, height = _ref.height; var _this$state14 = _this.state, dataSource = _this$state14.dataSource, rowKey = _this$state14.rowKey; var rowData = dataSource[rowIndex]; var key = rowData[rowKey]; if (!cb.utils.isEmpty(_this.keyMap[key]) && rowData.children) { if (_this.keyMap[key].isExpand) { return _react["default"].createElement("div", { className: "expand-rows" }, _this.getExpandRow(rowData.children, key)); } else { return null; } } else { return null; } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getExpandRow", function (rows, parentKey) { var _this$state15 = _this.state, columns = _this$state15.columns, rowKey = _this$state15.rowKey; var controls = []; rows.map(function (row) { var control, key = row[rowKey]; control = _this.getExpandCol(row, key); controls.push(control); if (row.children && _this.keyMap[key].isExpand) { control = _this.getExpandRow(row.children, _this.keyMap[key].children, key); controls = controls.concat(control); } }); return controls; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getExpandCol", function (row, parentKey) { var _this$state16 = _this.state, columns = _this$state16.columns, rowKey = _this$state16.rowKey; var _this$keyMap$parentKe = _this.keyMap[parentKey], level = _this$keyMap$parentKe.level, isEnd = _this$keyMap$parentKe.isEnd; var controls = [], bExpand = false; columns.map(function (col) { var width, align, style = { height: 40, "float": 'left' }; var expandColClass = "expand-col cell-text"; width = isNaN(parseFloat(col.iColWidth)) ? 200 : parseFloat(col.iColWidth); if (col.iAlign === 1) align = 'left';else if (col.iAlign === 2) align = 'center';else align = 'left'; var rowProperty = { 'columnKey': col.cItemName, 'height': 40, 'rowIndex': _this.keyMap[parentKey], 'width': width }; var text = _this.compareCell(row, col, _this.keyMap[parentKey], true, rowProperty); style.width = width; style.textAlign = align; if (col.cControlType == 'action') { style.position = 'fixed'; style.textAlign = 'right'; style.left = (_this.props.width || 1100) - width; if (!text.props.children || text.props.children.length == 0) { expandColClass = expandColClass + " " + "action-col"; style.height = style.height - 2; } } if (col.cControlType == 'expand') { style.textOverflow = 'initial'; } if (level > 1 && col.cControlType != 'action') { if (col.cControlType == 'expand') { style.marginLeft = (level - 1) * 15; bExpand = true; } else { if (bExpand) { style.width = style.width - (level - 1) * 15; if (style.width < 0) style.width = 0; bExpand = false; } } } controls.push(_react["default"].createElement("div", { className: expandColClass, onClick: function onClick(e) { return _this.onCellClick(e, col, parentKey, true); }, id: parentKey, style: style }, text)); }); var expandRowClass = "expand-row level-" + level; if (_this.selectRowIndex == parentKey) expandRowClass = expandRowClass + ' ' + 'expand-row-selected'; if (isEnd) expandRowClass = expandRowClass + ' ' + 'expand-row-end'; var bSelect = _this.lookUpRowIndexes.findIndex(function (item) { return item.type == 'sub' && item.index == parentKey; }); if (bSelect != -1) expandRowClass = expandRowClass + ' ' + 'expand-row-selected'; if (_this.lookUpRow.type == 'sub' && _this.lookUpRow.index == parentKey) expandRowClass = expandRowClass + ' ' + 'expand-row-lookup-focused'; var rowStyle = { "height": "40px" }; rowStyle.width = _this.getRowWidth(); return _react["default"].createElement("div", { className: expandRowClass, id: parentKey, style: rowStyle, onMouseEnter: function onMouseEnter(e) { return _this.onExpandMouseEnter(e, parentKey); }, onMouseLeave: function onMouseLeave(e) { return _this.onExpandMouseLeave(e, parentKey); } }, controls); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getRowWidth", function () { var columns = _this.state.columns; var rowWidth = 20, tableWith = _this.props.width || 1100; columns.map(function (col) { var width = isNaN(parseFloat(col.iColWidth)) ? 200 : parseFloat(col.iColWidth); rowWidth = rowWidth + width; }); if (rowWidth < tableWith) rowWidth = tableWith; return rowWidth; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onExpandMouseEnter", function (e, key) { if (_this.currentKey) { _this.keyMap[_this.currentKey].showAction = false; _this.currentKey = null; } for (var key1 in _this.keyMap) { if (key1 == key) { _this.keyMap[key].showAction = true; } else { _this.keyMap[key1].showAction = false; } } _this.setState({ rowKey: _this.state.rowKey }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onExpandMouseLeave", function (e, key) { var actionParent1 = new cb.dom(e.relatedTarget).parents('.ant-popover'); if (actionParent1.length) return; if (_this.currentKey == key) _this.currentKey = null; _this.keyMap[key].showAction = false; _this.keyMap[_this.keyMap[key].parent].showAction = true; _this.setState({ rowKey: _this.state.rowKey }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getRowClassName", function (index) { var lookUpRowIndexes = _this.lookUpRowIndexes; if (lookUpRowIndexes.length > 0) { var className = ''; for (var i = 0; i < lookUpRowIndexes.length; i++) { if (lookUpRowIndexes[i].type == 'main' && index == lookUpRowIndexes[i].index) { className = 'public_fixedDataTableRow_LookUpRow'; break; } } for (var _i = 0; _i < lookUpRowIndexes.length; _i++) { if (_this.lookUpRow.type == 'main' && index == _this.lookUpRow.index) { className = className + ' public_fixedDataTableRow_LookUpRow_Focused'; break; } } if (className != '') return className; } if (_this.selectRowIndex == index) return 'public_fixedDataTableRow_selected'; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_onHorizontalScroll", function (scrollLeft) { var expandRows = document.getElementsByClassName('expand-rows'); if (expandRows.length <= 0) return true; for (var i = 0; i < expandRows.length; i++) { expandRows[i].scrollLeft = scrollLeft; } return true; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onExpandClick", function (e, index) { e.preventDefault(); e.stopPropagation(); var _this$state17 = _this.state, dataSource = _this$state17.dataSource, rowKey = _this$state17.rowKey; if ((0, _typeof2["default"])(index) === 'object') { _this.keyMap[index.key].isExpand = !index.isExpand; } else { var rowData = dataSource[index]; var key = rowData[rowKey]; _this.keyMap[key].isExpand = !_this.keyMap[key].isExpand; } _this.setState({ rowKey: rowKey }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "columnSetting", function () { _this.setState({ popFlag: !_this.state.popFlag }); _this.props.model.columnSetting(_this.props.code); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setTitle", function (titleList) { _this.setState({ titleList: titleList }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMouseEnter", function (e, index) { var titleList = _this.state.titleList; titleList[index].bShowPop = true; _this.setState({ titleList: titleList }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMouseLeave", function (e, index) { var titleList = _this.state.titleList; titleList.forEach(function (ele, i) { ele.bShowPop = false; }); _this.sort = ""; _this.setState({ titleList: titleList }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "sortClick", function (type, index) { var titleList = _this.state.titleList; if (type == 'up' && index == 0) return; if (type == 'down' && index == titleList.length - 1) return; if (titleList[index] && titleList[index].bJointQuery) { cb.utils.alert('关键字段不允许移动!', 'warning'); return; } var pre = cb.utils.extend(true, {}, titleList[index - 1]); var next = cb.utils.extend(true, {}, titleList[index + 1]); var now = cb.utils.extend(true, {}, titleList[index]); var preOrder = pre.iOrder; var nextOrder = next.iOrder; var nowOrder = now.iOrder; if (type == 'up') { _this.sort = "up"; titleList[index] = pre; titleList[index].iOrder = nowOrder; titleList[index - 1] = now; titleList[index - 1].iOrder = preOrder; } else { _this.sort = "down"; titleList[index] = next; titleList[index].iOrder = nowOrder; titleList[index + 1] = now; titleList[index + 1].iOrder = nextOrder; } _this.setState({ titleList: titleList }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChecked", function (e, element, index) { var checked = e.target.checked; var id = element.id; var titleList = _this.state.titleList; if (titleList[index].bJointQuery) { cb.utils.alert('关联字段不允许修改!', 'warning'); } else { if (checked) { titleList[index].bShowIt = 1; } else { titleList[index].bShowIt = 0; } } _this.setState({ titleList: titleList }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "buttonClick", function (type) { if (type == 'save') { _this.props.model.setTitleData(_this.state.titleList); } _this.setState({ popFlag: false }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_onColumnResizeEndCallback", function (newColumnWidth, columnKey) { var columns = _this.state.columns; columns && columns.forEach(function (col) { if (col.cItemName == columnKey) col.iColWidth = newColumnWidth; }); _this.setState({ columns: columns }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getSettingContent", function () { var titleList = _this.state.titleList; var titileItem = []; titleList.forEach(function (element, index) { var _this2 = this; var item; var bShowPop = element.bShowPop ? element.bShowPop : false; if (!element.bHidden) { var showIt = false; if (element.bShowIt == 1) { showIt = true; } item = bShowPop ? _react["default"].createElement(_row["default"], { style: { minHeight: "25px" }, onMouseEnter: function onMouseEnter(e) { return _this2.onMouseEnter(e, index); }, onMouseLeave: function onMouseLeave(e) { return _this2.onMouseLeave(e, index); } }, _react["default"].createElement("div", { className: "pull-left", title: element.cShowCaption }, _react["default"].createElement(_baseui.Checkbox, { checked: showIt, onChange: function onChange(e) { return _this2.onChecked(e, element, index); } }, element.cShowCaption || element.cCaption)), _react["default"].createElement("div", { className: "pull-right" }, _react["default"].createElement(_baseui.Button, { style: { borderWidth: 0 }, icon: "arrow-up", onClick: function onClick() { return _this2.sortClick('up', index); } }), _react["default"].createElement(_baseui.Button, { style: { borderWidth: 0 }, icon: "arrow-down", onClick: function onClick() { return _this2.sortClick('down', index); } }))) : _react["default"].createElement(_row["default"], { colCount: 2, style: { minHeight: "25px" }, onMouseEnter: function onMouseEnter(e) { return _this2.onMouseEnter(e, index); }, onMouseLeave: function onMouseLeave(e) { return _this2.onMouseLeave(e, index); } }, _react["default"].createElement("div", { className: "pull-left" }, _react["default"].createElement(_baseui.Checkbox, { checked: showIt, onChange: function onChange(e) { return _this2.onChecked(e, element, index); } }, element.cShowCaption || element.cCaption)), _react["default"].createElement("div", { className: "pull-right" })); titileItem.push(item); } }, (0, _assertThisInitialized2["default"])(_this)); var buttonClass = 'filter-btn-fixed'; var settingContent = _react["default"].createElement("div", { className: buttonClass, style: { overflow: "auto", height: "250px" } }, _react["default"].createElement("div", { className: "filter-txt" }, titileItem), _react["default"].createElement("div", { className: "filter-btn-1" }, _react["default"].createElement(_baseui.Button, { type: "primary", size: "small", onClick: function onClick() { return _this.buttonClick('save'); } }, "\u4FDD\u5B58"), _react["default"].createElement(_baseui.Button, { type: "default", size: "small", onClick: function onClick() { return _this.buttonClick('cancel'); } }, "\u53D6\u6D88"))); return settingContent; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getC