UNPKG

saas-dynamic-component

Version:

saas-dynamic-component ==== saas平台动态引擎组件库,目前包括查询引擎、表格引擎,后续待增加...

233 lines (177 loc) 9.7 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _dec, _dec2, _class, _desc, _value, _class2; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _mobx = require('mobx'); var _mobxReact = require('mobx-react'); var _nornj = require('nornj'); var _nornj2 = _interopRequireDefault(_nornj); var _nornjReact = require('nornj-react'); var _coreDecorators = require('core-decorators'); require('flarej/lib/components/antd/checkbox'); var _form = require('flarej/lib/components/antd/form'); var _form2 = _interopRequireDefault(_form); var _message = require('flarej/lib/components/antd/message'); var _message2 = _interopRequireDefault(_message); var _modal = require('flarej/lib/components/antd/modal'); var _modal2 = _interopRequireDefault(_modal); var _tableListSetting = require('./tableListSetting.scss'); var _tableListSetting2 = _interopRequireDefault(_tableListSetting); var _tableListSettingT = require('./tableListSetting.t.html'); var _tableListSettingT2 = _interopRequireDefault(_tableListSettingT); var _moment = require('moment'); var _moment2 = _interopRequireDefault(_moment); require('../../utils/nj.configs'); var _util = require('../../utils/util'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object['ke' + 'ys'](descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object['define' + 'Property'](target, property, desc); desc = null; } return desc; } var TableListSetting = (_dec = (0, _nornjReact.registerTmpl)('TableListSetting'), _dec2 = (0, _mobxReact.inject)('store'), _dec(_class = _dec2(_class = (0, _mobxReact.observer)(_class = (_class2 = function (_Component) { _inherits(TableListSetting, _Component); function TableListSetting() { _classCallCheck(this, TableListSetting); return _possibleConstructorReturn(this, _Component.apply(this, arguments)); } TableListSetting.prototype.clickSetting = function clickSetting() { var _props$store = this.props.store, tableListSetting = _props$store.tableListSetting, tableEngine = _props$store.tableEngine; tableListSetting.setCheckValue(tableEngine.tableColumns.slice(0, -1).map(function (v) { return v.dataIndex; })); tableListSetting.setModalVisible(true); }; TableListSetting.prototype.onModalCancel = function onModalCancel() { var tableListSetting = this.props.store.tableListSetting; tableListSetting.setModalVisible(false); }; TableListSetting.prototype.onModalSave = function onModalSave() { var _props = this.props, _props$store2 = _props.store, tableListSetting = _props$store2.tableListSetting, tableEngine = _props$store2.tableEngine, appCode = _props.appCode, menuUrl = _props.menuUrl, tableEngineFunc = _props.tableEngineFunc; var fieldCodes = tableEngine.fieldCodes.filter(function (v) { return tableListSetting.checkValue.indexOf(v.fieldCode) > -1; }); var selColumns = tableEngine.allColumns.filter(function (v) { return tableListSetting.checkValue.indexOf(v.dataIndex) > -1; }); if (fieldCodes.length < 3) { _message2.default.error((0, _util.intlSaaS)('filterLess')); return; } if (selColumns.filter(function (v) { return v.fixed == null; }).length == 0) { _message2.default.error((0, _util.intlSaaS)('filterRequire')); return; } tableListSetting.saveUserListField({ fieldCodes: fieldCodes }, { appCode: appCode, menuUrl: menuUrl }).then(function () { tableEngine.setResultLoading(true); tableListSetting.setModalVisible(false); tableEngineFunc && tableEngineFunc(); }); }; TableListSetting.prototype.onChangeGroup = function onChangeGroup(checkedValue) { var _props$store3 = this.props.store, tableEngine = _props$store3.tableEngine, tableListSetting = _props$store3.tableListSetting; tableListSetting.setCheckValue(checkedValue); }; TableListSetting.prototype.onCheckAllChange = function onCheckAllChange(e) { var _props$store4 = this.props.store, tableEngine = _props$store4.tableEngine, tableListSetting = _props$store4.tableListSetting; if (e.target.checked) { tableListSetting.setCheckValue(tableEngine.allColumns.map(function (v) { return v.dataIndex; })); } else { tableListSetting.setCheckValue([]); } }; TableListSetting.prototype.render = function render() { var _props$store5 = this.props.store, tableListSetting = _props$store5.tableListSetting, tableEngine = _props$store5.tableEngine; return _tableListSettingT2.default.tableListSetting(this.props, this, { styles: _tableListSetting2.default, tableListSetting: tableListSetting, tableEngine: tableEngine }); }; _createClass(TableListSetting, [{ key: 'checkCell', get: function get() { var tableEngine = this.props.store.tableEngine; var cell = tableEngine.allColumns; var result = []; for (var i = 0; i < cell.length; i += 3) { result.push(cell.slice(i, i + 3)); } return result; } }, { key: 'checkAll', get: function get() { var _props$store6 = this.props.store, tableEngine = _props$store6.tableEngine, tableListSetting = _props$store6.tableListSetting; var checkValue = tableListSetting.checkValue; if (checkValue.length == tableEngine.allColumns.length) { return true; } else { return false; } } }, { key: 'indeterminate', get: function get() { var _props$store7 = this.props.store, tableEngine = _props$store7.tableEngine, tableListSetting = _props$store7.tableListSetting; var checkValue = tableListSetting.checkValue; if (checkValue.length > 0 && checkValue.length < tableEngine.allColumns.length) { return true; } else { return false; } } }]); return TableListSetting; }(_react.Component), (_applyDecoratedDescriptor(_class2.prototype, 'clickSetting', [_coreDecorators.autobind], Object.getOwnPropertyDescriptor(_class2.prototype, 'clickSetting'), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, 'onModalCancel', [_coreDecorators.autobind], Object.getOwnPropertyDescriptor(_class2.prototype, 'onModalCancel'), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, 'onModalSave', [_coreDecorators.autobind], Object.getOwnPropertyDescriptor(_class2.prototype, 'onModalSave'), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, 'checkCell', [_mobx.computed], Object.getOwnPropertyDescriptor(_class2.prototype, 'checkCell'), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, 'checkAll', [_mobx.computed], Object.getOwnPropertyDescriptor(_class2.prototype, 'checkAll'), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, 'indeterminate', [_mobx.computed], Object.getOwnPropertyDescriptor(_class2.prototype, 'indeterminate'), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, 'onChangeGroup', [_coreDecorators.autobind], Object.getOwnPropertyDescriptor(_class2.prototype, 'onChangeGroup'), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, 'onCheckAllChange', [_coreDecorators.autobind], Object.getOwnPropertyDescriptor(_class2.prototype, 'onCheckAllChange'), _class2.prototype)), _class2)) || _class) || _class) || _class); exports.default = TableListSetting;