"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _react = _interopRequireWildcard(require("react"));

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

// import { Popconfirm, Modal } from "maycur-antd";
// import _ from 'lodash';
// import Fields from 'components/FormElement';
// import allocationService from 'services/allocationService';
// import utils from 'utils/utils';
// const { TableInput: EditableTable } = Fields;
// const RedStar = () => (
//     <span style={{ color: '#f11212', fontSize: 16, marginRight: 2 }}>*</span>
// );
// const pageId = 'FETCH_FORM_FIELDS';
var EditableTableWithBtn =
/*#__PURE__*/
function (_Component) {
  _inherits(EditableTableWithBtn, _Component);

  function EditableTableWithBtn() {
    _classCallCheck(this, EditableTableWithBtn);

    return _possibleConstructorReturn(this, _getPrototypeOf(EditableTableWithBtn).apply(this, arguments));
  }

  _createClass(EditableTableWithBtn, [{
    key: "render",
    //     constructor(props) {
    //         super(props);
    //         this.state = {
    //             columns: []
    //         }
    //         this.tableRef = React.createRef();
    //     }
    //     validate = () => {
    //         return this.tableRef.current.tableValidation();
    //     }
    //     removeItem = (row, index) => {
    //         const { onChange } = this.props;
    //         let value = [...this.props.value];
    //         value.splice(index, 1);
    //         onChange(value);
    //         this.tableRef.current.removeForm(row.code);
    //     }
    //     addItem = () => {
    //         const { value, onChange } = this.props;
    //         let addedItem = { code: utils.makeId() };
    //         onChange([...value, addedItem]);
    //     }
    //     averageAllocation = () => {
    //         const { onChange } = this.props;
    //         const _value = [...this.props.value];
    //         const valueLength = _value && _value.length;
    //         const averageRatio = _.round(100 / valueLength, 2);
    //         const lastRatio = _.round(averageRatio + (100 - valueLength * averageRatio), 2);
    //         _.each(_value, (v, index) => {
    //             const ratio = (index === valueLength - 1) ? lastRatio : averageRatio;
    //             v.allocationBase = ratio;
    //             this.tableRef.current.setFieldsValue(v.code, 'allocationBase', ratio);
    //         });
    //         onChange(_value);
    //     }
    //     clearAll = () => {
    //         const message = '确定要清空方案内容吗？';
    //         Modal.confirm({
    //             title: message,
    //             onOk: () => {
    //                 this.props.onChange([]);
    //                 this.tableRef.current.removeAllForms();
    //             }
    //         });
    //     }
    //     // 生成columns
    //     generateColumns = (formFields) => {
    //         let _columns = _.map(formFields, item => {
    //             if (item.type === 'AmountRatioInput') {
    //                 item.type = 'RatioInput';
    //                 item.property.required = true;
    //             }
    //             return {
    //                 ...item,
    //                 title: <>
    //                     {
    //                         item.property && item.property.required ?
    //                             <RedStar /> :
    //                             null
    //                     }
    //                     {item.identifier === 'allocationBase' ? '承担比例（%）' : item.property.label}
    //                 </>,
    //                 width: 200,
    //                 editable: true,
    //                 dataIndex: item.identifier,
    //                 readOnly: this.props.readOnly
    //             }
    //         });
    //         _columns.unshift({
    //             title: '序号',
    //             width: 100,
    //             render: (text, record, index) => (index + 1)
    //         });
    //         _columns.push({
    //             title: '操作',
    //             width: 100,
    //             render: (text, record, index) => {
    //                 return (
    //                     <Popconfirm
    //                         placement="left"
    //                         title={'确定要删除吗？'}
    //                         onConfirm={this.removeItem.bind(this, record, index)}
    //                         onCancel={e => e.stopPropagation()}
    //                         onClick={e => e.stopPropagation()}
    //                     >
    //                         <div style={{ cursor: 'pointer', color: '#1da2ff' }}>
    //                             删除
    //                         </div>
    //                     </Popconfirm>
    //                 )
    //             }
    //         });
    //         this.setState({ columns: _columns });
    //     }
    //     calTotalWidth = (columns) => {
    //         let _t = 0;
    //         if (columns instanceof Array && columns.length > 0) {
    //             columns.forEach(col => {
    //                 _t = _t + col.width;
    //             })
    //         }
    //         return _t;
    //     }
    //     componentDidMount() {
    //         const { allocationFormCode, value, onChange } = this.props;
    //         let _value = value;
    //         allocationService.getDynamicFormFields([allocationFormCode], { pageId }).then(formFields => {
    //             formFields = formFields && formFields[allocationFormCode];
    //             this.generateColumns(formFields);
    //             if (_value && _value.length) {
    //                 _value = _value.map(item => {
    //                     item = {
    //                         ...item,
    //                         ...item.customObject,
    //                         allocationBase: item.allocationBase.ratio
    //                     };
    //                     return item;
    //                 });
    //             } else {
    //                 _value = [{ code: utils.makeId() }, { code: utils.makeId() }];
    //             }
    //             onChange(_value);
    //         })
    //     }
    value: function render() {
      return null; //         const { value: dataSource, onChange, btns } = this.props;
      //         const { columns } = this.state;
      //         return (
      //             <>
      //                 <div className={'btnGroups'}>{btns}</div>
      //                 <EditableTable
      //                     rowKey="code"
      //                     bordered={false}
      //                     value={dataSource}
      //                     columns={columns}
      //                     onChange={onChange}
      //                     ref={this.tableRef}
      //                 />
      //             </>
      //         )
    }
  }]);

  return EditableTableWithBtn;
}(_react.Component);

var _default = EditableTableWithBtn;
exports["default"] = _default;