UNPKG

ming-demo3

Version:
1,415 lines (1,188 loc) 110 kB
"use strict"; 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 _react = _interopRequireDefault(require("react")); var _reactDom = require("react-dom"); var _fixedDataTable = require("fixed-data-table-2"); var _baseui = require("@mdf/baseui"); var _row = _interopRequireDefault(require("./row")); var _col = _interopRequireDefault(require("./col")); var _GridFilterModel = _interopRequireDefault(require("../grid/GridFilterModel")); var _CellModel = _interopRequireDefault(require("../grid/CellModel")); var _addEventListener = _interopRequireDefault(require("rc-util/lib/Dom/addEventListener")); var _util = require("@mdf/cube/lib/helpers/util"); var _SvgIcon = _interopRequireDefault(require("@mdf/metaui-web/lib/components/common/SvgIcon")); var _extend = require("@mdf/cube/lib/extend"); var config = { get operationPos() { return (_extend.compConfig.table || {})['operationPos']; }, get rowheight() { return (_extend.compConfig.table || {})['rowheight'] || 40; }, get headerHeight() { return (_extend.compConfig.table || {})['headerHeight'] || 40; }, get theme() { return (_extend.compConfig.theme || {})['theme']; } }; var Search = _baseui.Input.Search; var FixedDataTableControl = function (_React$Component) { (0, _inherits2["default"])(FixedDataTableControl, _React$Component); function FixedDataTableControl(props) { var _this; (0, _classCallCheck2["default"])(this, FixedDataTableControl); _this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(FixedDataTableControl).call(this, props)); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resize", function () { _this.computeTableHeight(); var renderFlag = _this.state.renderFlag; _this.setState({ renderFlag: !renderFlag }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "rowClassNameGetter", function (index) { if (_this.rowStatus[index] && _this.rowStatus[index].disabled && _this.rowStatus[index].disabled != undefined) { return 'public_fixedDataTableRow_disabled'; } if (_this.rowStatus[index] && _this.rowStatus[index].className && _this.rowStatus[index].disabled != undefined) { return 'public_fixedDataTableRow_' + _this.rowStatus[index].className; } var lookUpRowIndexes = _this.lookUpRowIndexes; if (lookUpRowIndexes.length > 0) { var className = ''; for (var i = 0; i < lookUpRowIndexes.length; i++) { if (index == lookUpRowIndexes[i]) { className = 'public_fixedDataTableRow_LookUpRow'; break; } } for (var _i = 0; _i < lookUpRowIndexes.length; _i++) { if (index == _this.lookUpRow) { className = className + ' public_fixedDataTableRow_LookUpRow_Focused'; break; } } if (className != '') return className; } if (_this.props.model) { var selectRows = _this.props.model.getSelectedRowIndexes(); for (var _i2 = 0; _i2 < selectRows.length; _i2++) { var rowIndex = selectRows[_i2]; if (index === rowIndex) return 'public_fixedDataTableRow_CheckedRow'; } } if (!_this.isExpanded) { var _this$state = _this.state, mergeMode = _this$state.mergeMode, mergeSourceName = _this$state.mergeSourceName; if (mergeMode == 2 && !cb.utils.isEmpty(mergeSourceName)) { var checkedIndex = _this.mergeMode2Indexes.findIndex(function (i) { return i == index; }); if (checkedIndex != -1) return 'public_fixedDataTableRow_selected'; } if (index === _this.selectIndex) return 'public_fixedDataTableRow_selected'; return; } if (index % 2 === 1) return 'public_fixedDataTableRow_expanded'; if (index === _this.selectIndex) return 'public_fixedDataTableRow_selected'; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_DocumentMouseDown", function (e) { var p1 = cb.dom(event.target).parents('.columnSetting'); var p2 = cb.dom(event.target).parents('.ant-popover'); if (p1.length == 0 && p2.length == 0 && _this.state.popFlag) { _this.setState({ popFlag: false }); } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_handleKeyDown", function (e) { var self = (0, _assertThisInitialized2["default"])(_this); switch (e.keyCode) { case 13: self.switchCell(); } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "switchCell", function () { if (_this.state.readOnly) return; if (_this.selectIndex == -1) return; var Status = _this.CellStatus; var data = { rowIndex: _this.selectIndex, cellName: '' }; Status.map(function (item, index) { for (var items in item) { if (items != 'GridRowNo' && items != 'CheckBox') { if (item[items]) { data.cellName = items; data.rowIndex = index; } } } }); if (data.cellName == '') data.cellName = _this.lastEditCell; _this.setCellEnter(data); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setListenerState", function (params) { if (params.columnMode === 'local' && _this.props.columns) { var columns = {}, fieldNames = []; for (var attr in _this.props.columns) { fieldNames.push(attr); var modelColumn = params.columns[attr]; if (!modelColumn) continue; var viewColumn = _this.props.columns[attr]; modelColumn.index = viewColumn.index; modelColumn.enterDirection = viewColumn.enterDirection; modelColumn.relatedActions = viewColumn.relatedActions; modelColumn.iAlign = viewColumn.iAlign; var column = {}; Object.assign(column, viewColumn, modelColumn); columns[attr] = column; } params.columns = columns; _this.props.model._set_data('fieldNames', fieldNames); } if (_this.props.widthMode == 'percent') { var tableWidth = _this.props.width || 1100; for (var key in params.columns) { var iColWidth = parseFloat(params.columns[key].iColWidth); var width = isNaN(iColWidth) ? 25 : iColWidth; width = tableWidth * width / 100; params.columns[key].iColWidth = width; } } var tmp_ColIndexs = {}; var index = 0; if (params.cellState) { _this.cellState = params.cellState; } var hasColumn = false; var hasSpecialCol = false, specialCols = []; for (var attr in params.columns) { if (params.columns[attr].cControlType == 'specialcom' && hasSpecialCol == false) { hasSpecialCol = true; specialCols.push(attr); } hasColumn = true; if (index === 0) { tmp_ColIndexs[attr] = 0; } else { tmp_ColIndexs[attr] = index; } index = index + 1; } _this.hasSpecialCol = hasSpecialCol; _this.specialCols = specialCols; if (params.pageInfo) { _this.setPageInfo(params.pageInfo); } _this.colsWidth = _this.computeColsWidth(params.columns); _this.GridProps.showCheckBox = params.showCheckBox; _this.GridProps.showRowNo = params.showRowNo; _this.GridProps.showAggregates = params.showAggregates; _this.GridProps.showSubtotal = params.showSubtotal; _this.GridProps.isRadio = !params.multiple; _this.GridProps.isPagination = params.pagination; _this.GridProps.showColumnSetting = params.showColumnSetting; _this.GridProps.multiSort = params.multiSort; _this.GridProps.heightFull = params.heightFull; _this.ColIndexs = tmp_ColIndexs; if (hasColumn) { _this.columns = params.columns; if (params.rows && params.rows.length > 0) { _this.dataList = params.rows; _this.calcSubTotalData(params.columns, _this.dataList); } else { _this.dataList = []; _this.calcSubTotalData(params.columns, _this.dataList); } _this._InitCellStatus(params.columns, params.rows, params.mergeCells); _this.readOnly = params.readOnly; var columnset = _this.RemodelingColumn(params.rows, params.columns); _this.setState({ readOnly: params.readOnly, columnset: columnset, showColumnSetting: params.showColumnSetting, mergeCells: params.mergeCells, mergeMode: params.mergeMode, mergeSourceName: params.mergeSourceName }); } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_InitCellStatus", function (Columns, DataSource, mergeCells) { var self = (0, _assertThisInitialized2["default"])(_this); var action = _this.props.action; if (action && action.cControlType && action.cControlType == 'Toolbar') { self.action = action; self.hasAction = true; var cStyle = action.cStyle; try { if (!cStyle || cStyle == '') { cStyle = {}; } else { cStyle = JSON.parse(cStyle); } } catch (e) { cb.utils.alert('Toolbar cStyle,预制错误!', 'error'); } _this.fixedwidth = cStyle.fixedwidth; } var PopMeta = {}; if (DataSource !== undefined) { var attr; var _ret = function () { var temp_cellState = cb.utils.extend(true, [], _this.cellState); var temp_isColErro = cb.utils.extend(true, [], _this.isColErro); var temp_CellStatus = cb.utils.extend(true, [], _this.CellStatus); var temp_rowStatus = cb.utils.extend(true, [], _this.rowStatus); var temp_actionState = cb.utils.extend(true, {}, _this.actionState); var temp_CompositeLayout = cb.utils.extend(true, [], _this.CompositeLayout); var temp_compositeControl = cb.utils.extend(true, [], _this.compositeControl); var length = DataSource.length; if (length <= 0) return { v: void 0 }; for (var i = 0; i < length; i++) { if (!temp_CellStatus[i]) temp_CellStatus[i] = {}; DataSource[i]._selected = false; if (!temp_rowStatus[i]) temp_rowStatus[i] = { disabled: false, visible: false }; if (_this.action && _this.action.controls) { (function () { var actionList = _this.action.controls; var _id = DataSource[i]._id; if (!temp_actionState[_id]) temp_actionState[_id] = {}; actionList.map(function (action) { if (!temp_actionState[_id][action.cItemName]) temp_actionState[_id][action.cItemName] = { disabled: false, visible: true }; }); })(); } if (!temp_cellState[i]) temp_cellState[i] = {}; if (!temp_isColErro[i]) temp_isColErro[i] = {}; if (!temp_CompositeLayout[i]) temp_CompositeLayout[i] = {}; if (!temp_compositeControl[i]) temp_compositeControl[i] = {}; for (attr in Columns) { if (attr === 'CheckBox' || attr === 'GridRowNo') { temp_CellStatus[i][attr] = true; } else { if (!temp_CellStatus[i][attr]) temp_CellStatus[i][attr] = false; if (!temp_cellState[i][attr]) temp_cellState[i][attr] = { disabled: false, visible: false, readOnly: false, style: {}, className: "" }; if (!temp_isColErro[i][attr]) temp_isColErro[i][attr] = false; if (Columns[attr].cControlType == 'composite') { temp_CompositeLayout[i][attr] = Columns[attr].cRefRetId; temp_compositeControl[i][attr] = PopMeta[attr]; } } } } if (temp_actionState) _this.actionState = temp_actionState; _this.CellStatus = temp_CellStatus; _this.rowStatus = temp_rowStatus; _this.cellState = temp_cellState; _this.isColErro = temp_isColErro; _this.CompositeLayout = temp_CompositeLayout; _this.compositeControl = temp_compositeControl; if (mergeCells || _this.state.mergeCells) _this.initMergeColContrast(DataSource, Columns); }(); if ((0, _typeof2["default"])(_ret) === "object") return _ret.v; } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "calcSubTotalData", function (columns, data) { if (!data || data.length == 0) return; var subtotalData = {}; for (var key in columns) { if (columns[key].bNeedSum) { (function () { var sum = 0; data && data.map(function (row) { var val = row[key] ? row[key] : 0; sum = (0, _util.getMultiplication)(sum, parseFloat(val), 'add'); }); subtotalData[key] = sum; })(); } } _this.setState({ subtotalData: subtotalData }); if (_this.props.model) _this.props.model.execute('afterCalcSubTotal', subtotalData); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setColumns", function (columndata) { var tmp_ColIndexs = {}, index = 0, hasSpecialCol = false, specialCols = []; if (_this.props.widthMode == 'percent') { var tableWidth = _this.props.width || 1100; for (var key in columndata) { var iColWidth = parseFloat(columndata[key].iColWidth); var width = isNaN(iColWidth) ? 25 : iColWidth; width = tableWidth * width / 100; columndata[key].iColWidth = width; } } else { for (var key in columndata) { if (columndata[key].cControlType == 'specialcom' && hasSpecialCol == false) { hasSpecialCol = true; specialCols.push(key); } if (index === 0) { tmp_ColIndexs[key] = 0; } else { tmp_ColIndexs[key] = index; } index = index + 1; } } _this.hasSpecialCol = hasSpecialCol; _this.specialCols = specialCols; _this.colsWidth = _this.computeColsWidth(columndata); _this.ColIndexs = tmp_ColIndexs; _this.groupHeaderHeight = 0; _this._InitCellStatus(columndata, _this.dataList); var columnset = _this.RemodelingColumn(_this.dataList, columndata); _this.columns = columndata; if (_this.props.tableTyep == 'rptTable') { var showAggregates = false; for (var key in columndata) { if (columndata[key].bNeedSum) { showAggregates = true; break; } } _this.GridProps.showAggregates = showAggregates; } _this.setState({ columnset: columnset }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "computeColsWidth", function (columns) { var colsWidth = 0; for (var key in columns) { var iColWidth = parseFloat(columns[key].iColWidth || 150); colsWidth += iColWidth; } return colsWidth; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "initMergeColContrast", function (dataSource, columns) { var mergeColContrast = {}; for (var key in columns) { mergeColContrast[key] = []; dataSource.map(function (row) { mergeColContrast[key].push(0); }); } if (_this.GridProps.showCheckBox && _this.state.mergeMode == 2 && !cb.utils.isEmpty(_this.state.mergeSourceName)) { mergeColContrast.CheckBox = []; dataSource.map(function (row) { mergeColContrast.CheckBox.push(0); }); } _this.mergeColContrast = mergeColContrast; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setMergeColContrast", function (mergeColContrast) { _this.mergeColContrast = mergeColContrast; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getMergeIndexes", function (index) { var indexes = [index]; if (cb.utils.isEmpty(index)) return indexes; var _this$state2 = _this.state, mergeMode = _this$state2.mergeMode, mergeSourceName = _this$state2.mergeSourceName; if (mergeMode != 2 || cb.utils.isEmpty(mergeSourceName)) return indexes; if (!_this.mergeColContrast.CheckBox) return indexes; if (_this.mergeColContrast.CheckBox[index] === 0) return indexes; if (_this.mergeColContrast.CheckBox[index] == 2) { for (var i = index - 1; i >= 0; i--) { if (_this.mergeColContrast.CheckBox[i] === 1) indexes.push(i);else break; } } if (_this.mergeColContrast.CheckBox[index] == 1) { var len = _this.mergeColContrast.CheckBox.length; for (var i = index - 1; i >= 0; i--) { if (_this.mergeColContrast.CheckBox[i] === 1) indexes.push(i);else break; } for (var i = index + 1; i <= len; i++) { if (_this.mergeColContrast.CheckBox[i] === 1) indexes.push(i); if (_this.mergeColContrast.CheckBox[i] === 2) { indexes.push(i); break; } } } return indexes; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setSum", function (sumData) { _this.setState({ sumData: sumData }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setDataSource", function (data) { _this.selectIndex = -1; _this.dataList = data; _this.allSelect = false; _this.indeterminate = false; _this._InitCellStatus(_this.columns, data); var columnset = _this.RemodelingColumn(data, _this.columns); _this.setState({ columnset: columnset }); var selectRows = _this.props.model.getSelectedRowIndexes(); if (selectRows[0]) { _this.scrollRow = selectRows[0]; } else { _this.scrollRow = 0; _this.scrollEndHeight = 0; _this.nowSetDataSource = true; } _this.scrollTop = undefined; _this.calcSubTotalData(_this.columns, _this.dataList); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "RemodelingColumn", function (dataList, columnState) { var self = (0, _assertThisInitialized2["default"])(_this), ret = [], columnData = [], actionAlign = '', Operation = {}; var isGroup = false; for (var attr in columnState) { if (columnState[attr].parent) { isGroup = true; break; } } if (isGroup) return _this.RemodelingGroupColumn(dataList, columnState); var readOnly = _this.readOnly; if (_this.action.controls) { if (config.operationPos == 'right') { columnState.Operation = { 'cItemName': 'Operation', 'iColWidth': 220, 'cControlType': 'Action' }; } else { columnState.Operation = { 'cItemName': 'Operation', 'iColWidth': readOnly === false ? 64 : 0, 'cControlType': 'Action' }; } if (_this.fixedwidth) columnState.Operation.iColWidth = _this.fixedwidth; columnData.push(columnState.Operation); } if (_this.GridProps.showCheckBox) { if (!columnState.CheckBox) columnState.CheckBox = { 'cItemName': 'CheckBox', 'iColWidth': 45, 'cControlType': 'SelectCheckBox' }; if (_this.state.mergeMode == 2 && !cb.utils.isEmpty(_this.state.mergeSourceName)) columnState.CheckBox.bMergeCol = true; columnData.push(columnState.CheckBox); } if (_this.GridProps.showRowNo) { if (!columnState.GridRowNo) columnState.GridRowNo = { 'cItemName': 'GridRowNo', 'iColWidth': 40, 'cControlType': 'Input' }; columnData.push(columnState.GridRowNo); } var tmp; for (var attr in columnState) { if (attr != 'CheckBox' && attr != 'GridRowNo' && attr != 'Operation' && attr != 'ColumnSetting') { tmp = columnState[attr]; columnData.push(columnState[attr]); } } if (_this.state.showColumnSetting) { if (!columnState.ColumnSetting) columnState.ColumnSetting = { 'cItemName': 'ColumnSetting', 'iColWidth': 50, 'cControlType': 'Input', 'bIsNull': true }; columnData.push(columnState.ColumnSetting); } if (tmp) { if (!_this.lastCol || _this.lastCol.cFieldName != tmp.cFieldName) { _this.lastCol = _.cloneDeep(tmp); } } _this.totalWidth = 0; var _index = _.findIndex(columnData, function (obj) { return obj.cItemName == _this.lockstate; }); columnData.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); } } var column = self.setColumn(col.cItemName, col); var iColWidth = parseFloat(col.iColWidth); var width = isNaN(iColWidth) ? 150 : iColWidth; this.totalWidth += width; ret.push(column); }, (0, _assertThisInitialized2["default"])(_this)); return ret; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "RemodelingGroupColumn", function (dataList, columnState) { var cols = {}; var columns = cb.utils.extend(true, {}, columnState); _this.totalWidth = 0; for (var key in columns) { var item = columns[key]; item.iColWidth = item.iColWidth ? parseFloat(item.iColWidth) : 150; if (!item.parent) { cols[item.cItemName] = item; } else { _this.loopColumn(item.parent, cols, item); } _this.totalWidth += item.iColWidth; } return _this.restructureColumn(dataList, cols); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "restructureColumn", function (dataList, columns) { var col = []; for (var key in columns) { var item = columns[key]; if (item.children) { var children = _this.loopChildren(item); var header = _this.getGroupHeader(item); col.push(_react["default"].createElement(_fixedDataTable.ColumnGroup, { key: item.cFieldName, header: header }, children)); } else { var column = _this.setColumn(item.cItemName, item); col.push(_react["default"].createElement(_fixedDataTable.ColumnGroup, { key: item.cFieldName, header: _react["default"].createElement(_fixedDataTable.Cell, null, _react["default"].createElement("div", { className: "headerName", style: { "height": _this.headerHeight } })) }, column)); } } return col; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getGroupHeader", function (item) { var header = []; header.push(_react["default"].createElement(_row["default"], { className: "group-row", style: { "height": 40 } }, _react["default"].createElement("div", { className: "group-col", style: { "height": 40 } }, item.cShowCaption))); var headerRow = _this.getHeaderRow(item.children); if (headerRow.length > 0) { var i = 1; headerRow.map(function (row) { header.push(_react["default"].createElement(_row["default"], { className: "group-row", style: { "height": 40 } }, row)); i += 1; }); _this.groupHeaderHeight = i * 40; } else { _this.groupHeaderHeight = 40; } var rowWidth = _this.getGroupHeaderWidth(item.children); return _react["default"].createElement("div", { className: "table-group-header", style: { "width": rowWidth } }, header); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getHeaderRow", function (children) { var headerRows = [], headerRow = []; children.map(function (col) { if (col.children) { var width = _this.getGroupHeaderWidth(col.children); col.iColWidth = width; headerRow.push(_react["default"].createElement("div", { className: "group-col", style: { "height": 40, "width": width } }, col.cShowCaption)); if (col.children[0].children) { var newRow = _this.getHeaderRow(col.children); headerRows[headerRows.length] = newRow; } } }); if (headerRow.length > 0) headerRows[headerRows.length] = headerRow; return headerRows; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getGroupHeaderWidth", function (item) { var width = 0; item.map(function (col) { var w = _this.loopHeader(col, width); width += w; }); return width; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "loopHeader", function (item) { var children = item.children; var width = 0; if (children) { children.map(function (col) { if (col.iColWidth) { width += col.iColWidth; } else { width += _this.loopHeader(col); } }); } else { width = item.iColWidth ? item.iColWidth : 150; } return width; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "loopChildren", function (item) { var col = []; item.children.forEach(function (ele) { if (ele.children) { var children = this.loopChildren(ele); col = col.concat(children); } else { var column = this.setColumn(ele.cItemName, ele); col.push(column); } }, (0, _assertThisInitialized2["default"])(_this)); return col; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "loopColumn", function (data, cols, item, child) { if (!data.parent) { if (!cols[data.cFieldName]) { cols[data.cFieldName] = data; cols[data.cFieldName].children = []; } if (child && child.parent) delete child.parent; var colsChild = cols[data.cFieldName].children; var existChild = false, existIndex = 0; colsChild.forEach(function (ele, index) { if (ele.cFieldName == item.cFieldName) { existIndex = index; existChild = true; } }, (0, _assertThisInitialized2["default"])(_this)); if (existChild) { cols[data.cFieldName].children[existIndex].children.push(child); } else { if (child) { item.children = [child]; } if (item.parent) delete item.parent; cols[data.cFieldName].children.push(item); } } else { _this.loopColumn(data.parent, cols, data, item); } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setColumn", function (attr, col) { var controlType = col.cControlType && col.cControlType.trim().toLocaleLowerCase(); var iColWidth = parseFloat(col.iColWidth); var width = isNaN(iColWidth) ? 150 : iColWidth; var name = col.cShowCaption; var headerCell, headerClassName = ''; var fiexd = col.bFixed == 1 ? true : false; var unSort = _this.unSort; var align = 'left'; if (col.iAlign === 2) align = 'center'; if (col.iAlign === 3) align = 'right'; if (attr === 'CheckBox') { if (!_this.GridProps.isRadio) { var model = _this.props.model.getEditRowModel().get(attr); headerCell = _react["default"].createElement(_fixedDataTable.Cell, null, _react["default"].createElement("div", { className: "checkboxHD" }, _react["default"].createElement(_baseui.Checkbox, { indeterminate: _this.indeterminate, checked: _this.allSelect, onChange: function onChange(e, i) { return _this.SelectChange(e, -1); } }))); } fiexd = true, align = 'center'; } else if (attr === 'GridRowNo') { fiexd = true, align = 'center'; headerCell = _react["default"].createElement(_fixedDataTable.Cell, null, _react["default"].createElement("div", { className: "headerName line-number" }, "\u5E8F\u53F7")); } else if (attr === 'Operation') { if (config.operationPos == 'right') { headerCell = _react["default"].createElement(_fixedDataTable.Cell, null, _react["default"].createElement("div", { className: "headerName" }, "\u64CD\u4F5C\u5217")); } else { headerCell = _react["default"].createElement(_fixedDataTable.Cell, null, _react["default"].createElement("div", { className: "headerName", style: { "height": _this.headerHeight } })); } return _react["default"].createElement(_fixedDataTable.Column, { key: attr, allowCellsRecycling: true, columnKey: attr, isResizable: true, header: headerCell, cell: function cell(rowIndex) { return _this.setCell(rowIndex, col); }, width: width, align: "center", fixedRight: true, footer: _this._setFooter }); } else if (controlType == 'vouchermoney') { width = 175, align = 'left', _this.headerHeight = 60; headerCell = _react["default"].createElement(_fixedDataTable.Cell, null, _react["default"].createElement(_row["default"], { className: "CredentialsHeader" }, _react["default"].createElement("ul", { className: "CredentialsTitle" }, name), _react["default"].createElement("ul", { className: "CredentialsMoney" }, _react["default"].createElement("li", { className: "firstCol" }, "\u4EBF"), _react["default"].createElement("li", null, "\u5343"), _react["default"].createElement("li", null, "\u767E"), _react["default"].createElement("li", { className: "lineBlue" }, "\u5341"), _react["default"].createElement("li", null, "\u4E07"), _react["default"].createElement("li", null, "\u5343"), _react["default"].createElement("li", { className: "lineBlue" }, "\u767E"), _react["default"].createElement("li", null, "\u5341"), _react["default"].createElement("li", null, "\u5143"), _react["default"].createElement("li", { className: "lineRed" }, "\u89D2"), _react["default"].createElement("li", null, "\u5206")))); } else { if (!col.bCanModify && !_this.readOnly) { headerClassName = 'public_fixedDataTableCell_disabled'; } else { headerClassName = 'headerName'; } var fixedtable = _this.refs.fixedtable; headerCell = _react["default"].createElement(_fixedDataTable.Cell, { className: headerClassName }, _react["default"].createElement(_GridFilterModel["default"], { align: align, fixedtable: fixedtable, multiSort: _this.GridProps.multiSort, tableClass: _this.props.tableClass, readOnly: _this.readOnly, Column: col, name: name, model: _this.props.model, width: width, attr: attr, data: _this.dataList, onSortChange: _this.onSortChange, sortColumn: _this.sortColumn, lookUpRow: _this.lookUpRow, onlockChange: _this.onlockChange, lockstate: _this.lockstate, lockfixed: fiexd, moveLookUpRow: _this.moveLookUpRow, lookUpKey: _this.lookUpKey, unSort: unSort })); } if (_this.lastCol && attr == _this.lastCol.cItemName) { var tableWidth = _this.props.width || 1100; if (_this.GridProps.showAggregates) { if (tableWidth > _this.totalWidth && tableWidth - _this.totalWidth > width) { width = tableWidth - _this.totalWidth; if (_this.state.showColumnSetting) width = width - 50; } } } return _react["default"].createElement(_fixedDataTable.Column, { key: attr, allowCellsRecycling: true, columnKey: attr, isResizable: true, header: headerCell, cell: function cell(rowIndex) { return _this.setCell(rowIndex, col); }, width: width, align: align, fixed: fiexd, footer: _this._setFooter }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "moveLookUpRow", function (lookUpRowIndexes, lookUpRow, key) { if (lookUpRow > -1) _this.scrollRow = lookUpRow; _this.lookUpRowIndexes = lookUpRowIndexes; _this.lookUpRow = lookUpRow; _this.lookUpKey = key; _this._triggerRender(); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onSortChange", function (key) { _this.sortColumn = key; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onlockChange", function (key, state) { _this.lockstate = key; _this.unlockstate = state; _this._triggerRender(); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleSelectedKeysChange", function (keys) { if (_this.props.handleSelectedKeysChange) _this.props.handleSelectedKeysChange(keys); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setCell", function (rowIndex, col) { var _React$createElement; var isColErro = _this.isColErro[rowIndex.rowIndex][rowIndex.columnKey] ? _this.isColErro[rowIndex.rowIndex][rowIndex.columnKey] : false; if (_this.state.style && _this.state.style.height) { _this.rowheight = _this.state.style.height; } return _react["default"].createElement(_CellModel["default"], (_React$createElement = { mergeMode: _this.state.mergeMode, mergeSourceName: _this.state.mergeSourceName, handleSelectedKeysChange: _this.handleSelectedKeysChange, dataList: _this.dataList, readOnly: _this.readOnly, selectIndex: _this.selectIndex, rowStatus: _this.rowStatus, CellStatus: _this.CellStatus, RowProperty: rowIndex, selectAllState: _this._selectAllState, ColIndexs: _this.ColIndexs, mergeColContrast: _this.mergeColContrast, getMergeIndexes: _this.getMergeIndexes, action: _this.action, actionState: _this.actionState, selectAll: _this.allSelect, indeterminate: _this.indeterminate, cellState: _this.cellState, isColErro: isColErro, Column: col, model: _this.props.model, GridProps: _this.GridProps, onCellClick: _this._onCellClick, triggerRender: _this._triggerRender, columnsList: _this.columns, CompositeLayout: _this.CompositeLayout, rowHeight: _this.props.rowHeight || 50, compositeControl: _this.compositeControl, setCellBlur: _this.setCellBlur, setMergeColContrast: _this.setMergeColContrast, mergeCells: _this.state.mergeCells, showAction: _this.state.showAction[rowIndex.rowIndex] }, (0, _defineProperty2["default"])(_React$createElement, "rowHeight", _this.rowheight), (0, _defineProperty2["default"])(_React$createElement, "showActionIndex", _this.showActionIndex), (0, _defineProperty2["default"])(_React$createElement, "ActionClick", _this.ActionClick), (0, _defineProperty2["default"])(_React$createElement, "operationPos", config.operationPos), (0, _defineProperty2["default"])(_React$createElement, "onRowMouseEnter", _this.onRowMouseEnter), (0, _defineProperty2["default"])(_React$createElement, "onRowMouseLeave", _this.onRowMouseLeave), _React$createElement)); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_triggerRender", function () { var columnset = _this.RemodelingColumn(_this.dataList, _this.columns); _this.setState({ columnset: columnset }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_selectAllState", function (selectAll, indeterminate) { _this.allSelect = selectAll; _this.indeterminate = indeterminate; _this._triggerRender(); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "SelectChange", function (e, index) { if (!e.target.checked) { _this.props.model.unselectAll(); } else { _this.props.model.selectAll(); } if (_this.props.handleSelectedKeysChange) _this.props.handleSelectedKeysChange('table'); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_onColumnResizeEndCallback", function (newColumnWidth, columnKey) { if (!_this.columns[columnKey]) return; _this.columns[columnKey].iColWidth = newColumnWidth; var columnset = _this.RemodelingColumn(_this.dataList, _this.columns); _this.setState({ columnset: columnset }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_onRowClick", function (e, index) { if (e && e.target && cb.dom((0, _reactDom.findDOMNode)(e.target)).parents('.first-checkbox').length) return; if (_this.dataList.length == 0 || !_this.dataList[index]) return; if (!_this.state.readOnly) { _this.selectIndex = index; if (_this.GridProps.showCheckBox) _this.props.model.setFocusedRowIndex(index);else _this.props.model.select(index); return; } var all = false; var _this$state3 = _this.state, mergeMode = _this$state3.mergeMode, mergeSourceName = _this$state3.mergeSourceName; if (_this.GridProps.isRadio || _this.props.hasAction) all = true; if (all) { _this.props.model.select(index, all); } else { var indexes = _this.props.model.getSelectedRowIndexes(); var i = indexes.findIndex(function (val) { return val == index; }); if (!all && mergeMode == 2 && !cb.utils.isEmpty(mergeSourceName)) { var _indexes = _this.getMergeIndexes(index); if (i == -1) { _this.props.model.select(_indexes, all); } else { _this.props.model.unselect(_indexes); } return; } if (_this.GridProps.showCheckBox) all = false;else all = true; if (i == -1) _this.props.model.select(index, all);else _this.props.model.unselect(index); } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_onCellClick", function (e, index, columnKey) { _this._isRowColChange({ rowIndex: index, columnKey: columnKey, column: _this.columns[columnKey] }, function () { var ColIndex = _this.ColIndexs[columnKey]; var data = { index: index, columnKey: columnKey }; if (!_this.props.model.execute('onEdit', data)) return; var column = _this.columns[columnKey]; if (column.cControlType == 'switchlabel') { _this.props.model.setFocusedRowIndex(index); } if (_this.CellStatus[index] !== undefined) { for (var fl = 0; fl < _this.CellStatus.length; fl++) { if (fl !== index && _this.CellStatus[fl][columnKey]) { _this.CellStatus[fl][columnKey] = false; } } _this.CellStatus[index][columnKey] = true; _this.scrollCol = ColIndex + 2; _this._triggerRender(); } }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_isRowColChange", function (value, callback) { var oldValue = _this.RowCol; _this.props.model.promiseExecute('rowColChange', { value: value, oldValue: oldValue }, function () { callback(); }); oldValue.rowIndex = value.rowIndex; oldValue.columnKey = value.columnKey; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setCellValue", function (data) { if (_this.isColErro && _this.isColErro[data.rowIndex] && _this.isColErro[data.rowIndex][data.cellName]) _this.isColErro[data.rowIndex][data.cellName] = false; _this.isColErro[data.rowIndex][data.cellName] = false; _this.dataList[data.rowIndex][data.cellName] = data.value; var columnset = _this.RemodelingColumn(_this.dataList, _this.columns); _this.calcSubTotalData(_this.columns, _this.dataList); _this.setState({ columnset: columnset }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_onRowDoubleClick", function (e, index) { if (!_this.state.readOnly) return; var dataArry = _this.dataList; var rowData = dataArry[index]; _this.props.model.fireEvent('dblClick', rowData); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setCellBlur", function (data) { _this.CellStatus[data.rowIndex][data.cellName] = false; _this.lastEditCell = data.cellName; if (_this._triggerRender) _this._triggerRender(); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setCellEnter", function (data) { var keyIndex = _this.ColIndexs[data.cellName]; var cellState = _this.cellState; var column = _this.columns; var rowsCount = _this.props.model.getRowsCount(); var firstModifyKey = null; var enterDirection = column[data.cellName] ? column[data.cellName].enterDirection : null; if (enterDirection == null) return; var i = 1, columnKey, rowIndex; for (var key in column) { if (column[key].bCanModify) { firstModifyKey = key; break; } } switch (enterDirection) { case 1: if (data.rowIndex == 0) return; columnKey = data.cellName; rowIndex = data.rowIndex - 1; _this._onRowClick(null, rowIndex); break; case 2: columnKey = data.cellName; rowIndex = data.rowIndex + 1; if (rowIndex == rowsCount) { if (!_this.props.model.execute('beforeInsertRow')) return; _this.props.model.appendRow({}); } _this._onRowClick(null, rowIndex); _this.scrollRow = rowIndex; break; case 3: if (keyIndex == 0) return; for (var attr in _this.ColIndexs) { if (_this.ColIndexs[attr] === keyIndex - i) { if (column[attr].bCanModify) { columnKey = attr; } else { i = i + 1; } } } rowIndex = data.rowIndex; break; case 4: for (var attr in _this.ColIndexs) { if (_this.ColIndexs[attr] === keyIndex + i) { if (column[attr].bCanModify) { if (cellState[data.rowIndex] && cellState[data.rowIndex][attr]) { if (cellState[data.rowIndex][attr].disabled || cellState[data.rowIndex][attr].readOnly) i = i + 1;else columnKey = attr; } else columnKey = attr; } else { i = i + 1; } } } if (!columnKey) { rowIndex = data.rowIndex + 1; columnKey = firstModifyKey; if (rowIndex == rowsCount) { if (!_this.props.model.execute('beforeInsertRow')) return; _this.props.model.appendRow({}); } } else { rowIndex = data.rowIndex; } break; default: rowIndex = data.rowIndex; break; } if (rowIndex != _this.selectIndex) { _this.props.model.setFocusedRowIndex(rowIndex); _this.selectIndex = rowIndex; } if (!columnKey) return; _this.scrollCol = _this.ColIndexs[data.cellName]; _this.scrollRow = data.rowIndex; _this.CellStatus[data.rowIndex][data.cellName] = false; _this._onCellClick(null, rowIndex, columnKey); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "select", function (indexes) { for (var i = 0; i < _this.dataList.length; i++) { _this.dataList[i]._selected = false; } indexes && indexes.forEach(function (index) { _this.dataList[index]._selected = true; }); if (_this.GridProps.showCheckBox) _this.selectIndex = -1;else _this.selectIndex = indexes[0] * 1; _this.scrollRow = indexes[0]; _this.updateindeterminate(); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "unselect", function (indexes) { for (var i = 0, len = indexes.length; i < len; i++) { _this.dataList[indexes[i]]._selected = false; } _this.updateindeterminate(); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "selectAll", function () { _this.dataList.map(function (item, index) { _this.dataList[index]._selected = true; }); _this.allSelect = true; _this.indeterminate = false; _this._triggerRender(); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "unselectAll", function () { _this.dataList.map(function (item, index) { _this.dataList[index]._selected = false; }); _this.allSelect = false; _this.indeterminate = false; _this._triggerRender(); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateindeterminate", function () { var data = _this.dataList; var j = 0, indexes = [], selectAll = false, indeterminate = false; data.forEach(function (item, index) { if (!item._selected) return; indexes.push(index); j++; }); if (j == 0) { selectAll = false; indeterminate = false; } else if (j > 0 && j < data.length) { selectAll = false; indeterminate = true; } else if (j == data.length) { selectAll = true; indeterminate = false; } _this._selectAllState(selectAll, indeterminate); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setRowState", function (data) { _this.rowStatus[data.rowIndex][data.propertyName] = data.value; _this._triggerRender(); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setActionState", function (data) { var row = _this.dataList[data.rowIndex]; var actionState = _this.actionState;