"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __values = (this && this.__values) || function (o) {
    var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
    if (m) return m.call(o);
    return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
};
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
var antd_1 = require("antd");
var utils_1 = require("../../utils");
var RuleTip_1 = require("../RuleTip");
var SingleImage_1 = require("../Upload/SingleImage");
var React = require("react");
var _ = require("lodash");
var moment = require("moment");
var OrganizationSelect_1 = require("./OrganizationSelect");
var DomainSelect_1 = require("./DomainSelect");
var LinkColumn_1 = require("./LinkColumn");
var MORE = '__MORE';
var STOREMORE = {};
/**
 * @private
*/
var FromContent = /** @class */ (function (_super) {
    __extends(FromContent, _super);
    function FromContent() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.SelectModals = new Map();
        _this.LinkUtil = null;
        _this.state = {
            columns: []
        };
        _this.inputElement = function (column, initValue) {
            var params = {};
            if (column.disabled) {
                params.disabled = column.disabled;
            }
            switch (column.type) {
                case 'number':
                    return _this.buildNumber(column, params);
                case 'select':
                    return _this.buildSelect(column, params);
                case 'selectcode':
                    return _this.buildSelectCode(column, params);
                case 'radio':
                    return _this.buildRadio(column, params);
                case 'radiomore':
                    return _this.buildRadioMore(column, params);
                case 'checkbox':
                    return _this.buildCheckBox(column, params);
                case 'switch':
                    return _this.buildSwitch(column, params);
                case 'month':
                    return _this.buildMonth(column, params);
                case 'week':
                    return _this.buildWeek(column, params);
                case 'date':
                    return _this.buildDate(column, params);
                case 'datetime':
                    return _this.buildDateTime(column, params);
                case 'time':
                    return _this.buildTime(column, params);
                case 'daterange':
                    return _this.buildDateRange(column, params);
                case 'icon':
                    return _this.buildIcon(column, params);
                case 'customicon':
                    return _this.buildIconCustom(column, params);
                case 'image':
                    return _this.buildImage(column, params);
                case 'cascader':
                    return _this.buildCascader(column, params);
                case 'editor':
                    return _this.buildEditor(column, params, initValue);
                case 'organization':
                    return _this.buildOrganization(column, params, initValue);
                case 'domain':
                    return _this.buildDomain(column, params, initValue);
                case 'password':
                    return _this.buildPassword(column, params);
                case 'textarea':
                    return _this.buildTextArea(column, params);
                default:
                    return _this.buildText(column, params);
            }
        };
        return _this;
    }
    FromContent.prototype.componentWillMount = function () {
        this.state.columns = this.props.columns;
        this.LinkUtil = new LinkColumn_1.default(this.props.columns, this.props.form, this);
    };
    //多行文本输入框
    FromContent.prototype.buildTextArea = function (column, params) {
        if (column.placeholder) {
            params.placeholder = column.placeholder;
        }
        else {
            params.placeholder = '请输入' + column.title;
        }
        if (column.max) {
            params.maxLength = column.max;
        }
        return React.createElement(antd_1.Input.TextArea, __assign({}, column.config, params, { autoComplete: "off" }));
    };
    //文本输入框
    FromContent.prototype.buildText = function (column, params) {
        // this.__Link(column, params);
        this.LinkUtil.getLink(column, params);
        if (column.placeholder) {
            params.placeholder = column.placeholder;
        }
        else {
            params.placeholder = '请输入' + column.title;
        }
        if (column.max) {
            params.maxLength = column.max;
        }
        if (column.tip) {
            if (_.isString(column.tip)) {
                params.suffix = React.createElement(antd_1.Tooltip, { title: column.tip },
                    React.createElement(antd_1.Icon, { type: "info-circle" }));
            }
            else if (_.isPlainObject(column.tip)) {
                params.suffix = React.createElement(antd_1.Tooltip, { title: column.tip.text },
                    React.createElement(antd_1.Icon, { type: column.tip.icon }));
            }
        }
        return React.createElement(antd_1.Input, __assign({}, column.config, params, { autoComplete: "off" }));
    };
    //密码输入框
    FromContent.prototype.buildPassword = function (column, params) {
        if (column.placeholder) {
            params.placeholder = column.placeholder;
        }
        else {
            params.placeholder = '请输入' + column.title;
        }
        if (column.max) {
            params.maxLength = column.max;
        }
        return React.createElement(antd_1.Input, __assign({ type: "password" }, column.config, params, { autoComplete: "off" }));
    };
    //数字输入框
    FromContent.prototype.buildNumber = function (column, params) {
        return React.createElement(antd_1.InputNumber, __assign({}, column.config, params, { autoComplete: "off" }));
    };
    //下拉框
    FromContent.prototype.buildSelect = function (column, params) {
        this.LinkUtil.getLink(column, params);
        if (column.placeholder) {
            params.placeholder = column.placeholder;
        }
        else {
            params.placeholder = '请选择' + column.title;
        }
        return React.createElement(antd_1.Select, __assign({}, column.config, params), column.options.map(function (item) { return React.createElement(antd_1.Select.Option, { key: "form-modal-select-" + column.field + "-" + item.value, value: item.value }, item.name); }));
    };
    //下拉框(CODE模式)
    FromContent.prototype.buildSelectCode = function (column, params) {
        var e_1, _a;
        var getFieldValue = this.props.form.getFieldValue;
        var value = getFieldValue(column.field);
        var currentCode = null;
        try {
            for (var value_1 = __values(value), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
                var i = value_1_1.value;
                var tmp = _.find(column.options, { value: i });
                // @ts-ignore
                if (tmp != null && tmp.code) {
                    // @ts-ignore
                    currentCode = tmp.code;
                    break;
                }
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (value_1_1 && !value_1_1.done && (_a = value_1.return)) _a.call(value_1);
            }
            finally { if (e_1) throw e_1.error; }
        }
        if (column.placeholder) {
            params.placeholder = column.placeholder;
        }
        else {
            params.placeholder = '请选择' + column.title;
        }
        return React.createElement(antd_1.Select, __assign({ mode: "multiple" }, params), column.options.map(function (item) { return React.createElement(antd_1.Select.Option, { disabled: item.code && currentCode && currentCode != item.code, value: item.value }, item.name); }));
    };
    //单选框
    FromContent.prototype.buildRadio = function (column, params) {
        this.LinkUtil.getLink(column, params);
        return React.createElement(antd_1.Radio.Group, __assign({}, column.config, params), column.options.map(function (item) { return React.createElement(antd_1.Radio, { value: item.value + '' }, item.name); }));
    };
    //单选框
    FromContent.prototype.buildRadioMore = function (column, params) {
        var _a;
        var _this = this;
        var value = this.props.form.getFieldValue(column.field);
        var idx = _.findIndex(column.options, { value: value });
        if (idx < 0) {
            STOREMORE[MORE + column.field] = value;
            this.props.form.setFieldsValue((_a = {}, _a[column.field] = MORE, _a));
        }
        return React.createElement(antd_1.Radio.Group, __assign({}, column.config, params, { className: "radio-group-widt-more" }), column.options.map(function (item) {
            return React.createElement(antd_1.Radio, { value: item.value + '' },
                item.name,
                item.value == MORE ? (_this.props.form.getFieldValue(column.field) == MORE ? React.createElement(antd_1.Input, { onChange: function (evt) { return STOREMORE[MORE + column.field] = evt.target.value; }, defaultValue: STOREMORE[MORE + column.field], style: { width: 100, marginLeft: 10 } }) : null) : null);
        }));
    };
    //多选框
    FromContent.prototype.buildCheckBox = function (column, params) {
        return React.createElement(antd_1.Checkbox.Group, __assign({}, column.config, params), column.options.map(function (item) { return React.createElement(antd_1.Checkbox, { value: item.value + '' }, item.name); }));
    };
    //选择器
    FromContent.prototype.buildSwitch = function (column, params) {
        var intval = _.has(this.props.data, column.field) ? this.props.data[column.field] + '' : '';
        var checked = intval === '' || column.options[0].value === intval;
        return React.createElement(antd_1.Switch, __assign({}, column.config, params, { checkedChildren: column.options[0].name, unCheckedChildren: column.options[1].name, defaultChecked: checked }));
    };
    //日期选择器
    FromContent.prototype.buildDate = function (column, params) {
        return React.createElement(antd_1.DatePicker, __assign({}, column.config, params, { showTime: false, showToday: false, format: "YYYY-MM-DD" }));
    };
    //月份选择器
    FromContent.prototype.buildMonth = function (column, params) {
        return React.createElement(antd_1.DatePicker.MonthPicker, __assign({}, column.config, { placeholder: "\u8BF7\u9009\u62E9\u6708\u4EFD" }, params, { showTime: false, showToday: false, format: "YYYY-MM" }));
    };
    //月份选择器
    FromContent.prototype.buildWeek = function (column, params) {
        return React.createElement(antd_1.DatePicker.WeekPicker, __assign({}, column.config, { placeholder: "\u8BF7\u9009\u62E9\u5468" }, params, { showTime: false, showToday: false, format: "YYYY\u5E74, \u7B2Cw\u5468" }));
    };
    //日期选择器（带时间）
    FromContent.prototype.buildDateTime = function (column, params) {
        return React.createElement(antd_1.DatePicker, __assign({}, column.config, params, { showTime: true, showToday: false, format: "YYYY-MM-DD HH:mm:ss" }));
    };
    //时间选择器（仅时间）
    FromContent.prototype.buildTime = function (column, params) {
        // console.log(column, params)
        return React.createElement(antd_1.TimePicker, __assign({}, column.config, params));
        // return <DatePicker {...params} showTime={true} showToday={false} format="YYYY-MM-DD HH:mm:ss" />
    };
    //日期范围选择器
    FromContent.prototype.buildDateRange = function (column, params) {
        return React.createElement(antd_1.DatePicker.RangePicker, __assign({}, column.config, params, { showTime: false, ranges: { Today: [moment(), moment()], '本月': [moment(), moment().endOf('month')] } }));
    };
    //ICON图标选择器
    FromContent.prototype.buildIcon = function (column, params) {
        return React.createElement(antd_1.Select, __assign({}, column.config, params, { dropdownClassName: "icon-select" }), utils_1.IconUtil.IconList.map(function (icon) { return React.createElement(antd_1.Select.Option, { value: icon },
            React.createElement(antd_1.Icon, { type: icon })); }));
    };
    //ICON图标选择器:仅出现自定义图标
    FromContent.prototype.buildIconCustom = function (column, params) {
        return React.createElement(antd_1.Select, __assign({}, column.config, params, { dropdownClassName: "icon-select" }), utils_1.IconUtil.ExtraList.map(function (icon) { return React.createElement(antd_1.Select.Option, { value: icon },
            React.createElement(antd_1.Icon, { type: icon })); }));
    };
    //ICON图标选择器
    FromContent.prototype.buildImage = function (column, params) {
        var form = this.props.form;
        return React.createElement(SingleImage_1.default, __assign({}, column.config, { namespace: "app-portal" }, column.config, { def: this.initValue(column), callback: function (val) {
                var _a;
                return form.setFieldsValue((_a = {}, _a[column.field] = val, _a));
            } }));
    };
    //级联选择
    FromContent.prototype.buildCascader = function (column, params) {
        if (column.placeholder) {
            params.placeholder = column.placeholder;
        }
        else {
            params.placeholder = '请选择' + column.title;
        }
        return React.createElement(antd_1.Cascader, __assign({}, column.config, { changeOnSelect: true, options: column.options }, params, { fieldNames: { label: 'name', value: 'value', children: 'children' } }));
    };
    FromContent.prototype.setOrganizationValue = function (column, orgInfo) {
        var _a, _b;
        var filelds = column.field.split(',');
        var _c = __read(filelds, 4), code = _c[0], name = _c[1], province = _c[2], city = _c[3];
        var form = this.props.form;
        if (orgInfo == null) {
            form.setFieldsValue((_a = {},
                _a[column.field] = undefined,
                _a[code] = undefined,
                _a[name] = undefined,
                _a[province] = undefined,
                _a[city] = undefined,
                _a));
            var btn_1 = document.getElementById(column.field);
            if (btn_1) {
                btn_1.textContent = '请选择组织机构';
            }
            return;
        }
        form.setFieldsValue((_b = {}, _b[column.field] = orgInfo, _b));
        var btn = document.getElementById(column.field);
        if (btn) {
            btn.textContent = orgInfo.name;
        }
    };
    FromContent.prototype.setDomainValue = function (column, domain) {
        var _a, _b;
        var filelds = column.field.split(',');
        var _c = __read(filelds, 2), code = _c[0], domainName = _c[1];
        var form = this.props.form;
        if (domain == null) {
            form.setFieldsValue((_a = {},
                _a[column.field] = '',
                _a[code] = '',
                _a[domainName] = '',
                _a));
            var btn_2 = document.getElementById(column.field);
            if (btn_2) {
                btn_2.textContent = '请选择安全域';
            }
            return;
        }
        form.setFieldsValue((_b = {}, _b[column.field] = domain, _b));
        var btn = document.getElementById(column.field);
        if (btn) {
            btn.textContent = domain.domainName;
        }
    };
    FromContent.prototype.buildOrganizationEditor = function (column, initValue) {
        var _this = this;
        var param = { businessLine: '', useRoot: false };
        if (_.isPlainObject(column.config)) {
            if (_.has(column.config, 'businessLine') && !_.isEmpty(column.config.businessLine + '')) {
                param.businessLine = column.config.businessLine + '';
            }
            if (_.has(column.config, 'useRoot') && column.config.useRoot === true) {
                param.useRoot = true;
            }
        }
        return React.createElement(OrganizationSelect_1.default, __assign({}, param, { orgInfo: initValue, required: _.filter(column.rule, function (item) { return item.required; }).length > 0, onSelect: function (org) { return _this.setOrganizationValue(column, org); }, ref: function (modal) { return _this.SelectModals.set(column.field, modal); } }));
    };
    FromContent.prototype.buildDomainEditor = function (column, initValue) {
        var _this = this;
        return React.createElement(DomainSelect_1.default, { domainInfo: initValue, required: _.filter(column.rule, function (item) { return item.required; }).length > 0, onSelect: function (domain) { return _this.setDomainValue(column, domain); }, ref: function (modal) { return _this.SelectModals.set(column.field, modal); } });
    };
    FromContent.prototype.buildOrganization = function (column, params, initialValue) {
        var _this = this;
        var onSelect = function () {
            var modal = _this.SelectModals.get(column.field);
            modal.show();
        };
        return React.createElement(antd_1.Button, { icon: "select", onClick: function () { return onSelect(); } }, initialValue ? initialValue.name : '请选择机构');
    };
    FromContent.prototype.buildDomain = function (column, params, initialValue) {
        var _this = this;
        // console.log(this.initValue)
        // console.log(initialValue)
        var onSelect = function () {
            var modal = _this.SelectModals.get(column.field);
            modal.show();
        };
        return React.createElement(antd_1.Button, { icon: "select", onClick: function () { return onSelect(); } }, initialValue ? initialValue.domainName : '请选择管辖安全域');
    };
    FromContent.prototype.buildEditor = function (column, params, initialValue) {
        if (initialValue === void 0) { initialValue = ''; }
        return React.createElement(antd_1.Input, __assign({}, params));
    };
    // 初始化每列的值 
    FromContent.prototype.initValue = function (column) {
        if (column.type == 'date' || column.type == 'datetime' || column.type == 'month' || column.type == 'week') {
            if (_.has(this.props.data, column.field)) {
                if (this.props.data[column.field] === '') {
                    return '';
                }
                var date = moment(this.props.data[column.field], 'YYYY-MM-DD HH:mm:ss');
                if (date.format() == 'Invalid date') {
                    return moment(new Date(), 'YYYY-MM-DD HH:mm:ss');
                }
                return moment(this.props.data[column.field], 'YYYY-MM-DD HH:mm:ss');
            }
            else {
                return moment(new Date(), 'YYYY-MM-DD HH:mm:ss');
            }
        }
        else if (column.type == 'daterange') {
            var ptn = column.field.split(',');
            var _a = __read([moment(new Date(), 'YYYY-MM-DD'), moment(new Date(), 'YYYY-MM-DD')], 2), start = _a[0], end = _a[1];
            if (ptn.length == 2) {
                if (_.has(this.props.data, ptn[0])) {
                    start = moment(this.props.data[ptn[0], 'YYYY-MM-DD']);
                }
                if (_.has(this.props.data, ptn[1])) {
                    end = moment(this.props.data[ptn[1], 'YYYY-MM-DD']);
                }
            }
            return [start, end];
        }
        else if (column.type == 'time') {
            if (_.has(this.props.data, column.field)) {
                if (this.props.data[column.field] === '') {
                    return moment('00:00:00', 'HH:mm:ss');
                }
                var date = moment(this.props.data[column.field], 'HH:mm:ss');
                if (date.format() == 'Invalid date') {
                    return moment('00:00:00', 'HH:mm:ss');
                }
                return moment(this.props.data[column.field], 'HH:mm:ss');
            }
            else {
                return moment('00:00:00', ' HH:mm:ss');
            }
        }
        else if (column.type == 'checkbox' || column.type == 'selectcode') {
            if (_.has(this.props.data, column.field)) {
                return _.filter(('' + this.props.data[column.field]).split(','), function (item) { return item != ''; });
            }
            return [];
        }
        else if (column.type == 'cascader') {
            if (_.has(this.props.data, column.field)) {
                var val = this.props.data[column.field];
                var sel = [];
                for (var i = 0; i < column.options.length; i++) {
                    if (sel.length > 0) {
                        break;
                    }
                    if (column.options[i].value == val) {
                        sel = [column.options[i].value];
                    }
                    for (var j = 0; j < column.options[i].children.length; j++) {
                        if (val == column.options[i].children[j].value) {
                            sel = [column.options[i].value, column.options[i].children[j].value];
                        }
                    }
                }
                return sel;
            }
        }
        else if (column.type == 'organization') {
            var filelds = column.field.split(',');
            var _b = __read(filelds, 2), code = _b[0], name_1 = _b[1];
            if (_.isEmpty(this.props.data) || _.isEmpty(this.props.data[code])) {
                return undefined;
            }
            return { code: this.props.data[code] || null, name: this.props.data[name_1] || null };
        }
        else if (column.type == 'domain') {
            var filelds = column.field.split(',');
            var _c = __read(filelds, 2), code = _c[0], domainName = _c[1];
            if (_.isEmpty(this.props.data) || _.isEmpty(this.props.data[code])) {
                return undefined;
            }
            return { code: this.props.data[code] || null, domainName: this.props.data[domainName] || null };
        }
        return _.has(this.props.data, column.field) ? this.props.data[column.field] + '' : '';
    };
    FromContent.prototype.buildInput = function (column) {
        var getFieldDecorator = this.props.form.getFieldDecorator;
        var rules = RuleTip_1.ruleMessage(column);
        var initialValue = this.initValue(column);
        return (_.has(column, 'showed') && (column.showed === undefined || column.showed === false)) ? React.createElement(React.Fragment, null) : React.createElement(antd_1.Form.Item, __assign({ label: column.title }, (this.props.loose ? {
            labelCol: { span: 3, }, wrapperCol: { span: 20 }
        } : {
            labelCol: { span: 6, }, wrapperCol: { span: 16 }
        })),
            getFieldDecorator(column.field, {
                initialValue: initialValue,
                rules: rules,
            })(this.inputElement(column, initialValue)),
            [
                column.type == 'organization' && this.buildOrganizationEditor(column, initialValue),
                column.type == 'domain' && this.buildDomainEditor(column, initialValue),
            ]);
    };
    FromContent.prototype.buildColumn = function (columns) {
        var _this = this;
        return columns.map(function (row) {
            return row.map(function (column) { return _this.buildInput(column); });
        });
    };
    FromContent.prototype.render = function () {
        return React.createElement(antd_1.Form, null, this.buildColumn(this.state.columns));
    };
    return FromContent;
}(React.PureComponent));
/**
 * 表单弹框，支持各种类型的表单元素填写，当提交时，会调用 onOk 方法将编辑的对象信息以参数传递回去。
*/
var FormModal = /** @class */ (function (_super) {
    __extends(FormModal, _super);
    function FormModal() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.submiting = false;
        _this.form = null;
        return _this;
    }
    FormModal.prototype._warpColumns = function (columns) {
        var e_2, _a;
        var columnGroups = [];
        var breaked = false;
        try {
            for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
                var column = columns_1_1.value;
                if (!column) {
                    continue;
                }
                var group = [];
                if (!breaked) {
                    columnGroups.push(group);
                }
                else {
                    group = columnGroups[columnGroups.length - 1];
                }
                group.push(column);
                if (column.inline) {
                    breaked = true;
                }
                else {
                    breaked = false;
                }
            }
        }
        catch (e_2_1) { e_2 = { error: e_2_1 }; }
        finally {
            try {
                if (columns_1_1 && !columns_1_1.done && (_a = columns_1.return)) _a.call(columns_1);
            }
            finally { if (e_2) throw e_2.error; }
        }
        return columnGroups;
    };
    FormModal.prototype.componentDidUpdate = function (old) {
        if (!old.visible && this.props.visible) {
            this.submiting = false;
        }
    };
    FormModal.prototype.submit = function () {
        var _this = this;
        if (this.submiting) {
            return;
        }
        var form = this.form.getForm();
        form.validateFields(function (err, values) {
            if (err) {
                // this.submiting = false;
                return;
            }
            _this.submiting = true;
            _this.props.columns.map(function (column) {
                if (column.type == 'switch') {
                    if (_.has(values, column.field)) {
                        if (values[column.field] === true) {
                            values[column.field] = column.options[0].value;
                        }
                        else if (values[column.field] === false) {
                            values[column.field] = column.options[1].value;
                        }
                    }
                }
                else if (column.type == 'date') {
                    if (values[column.field]) {
                        values[column.field] = values[column.field].format('YYYY-MM-DD');
                    }
                    else {
                        return '';
                    }
                }
                else if (column.type == 'month') {
                    if (values[column.field]) {
                        values[column.field] = values[column.field].format('YYYY-MM-01');
                    }
                    else {
                        return '';
                    }
                }
                else if (column.type == 'week') {
                    if (values[column.field]) {
                        values[column.field] = moment(values[column.field]).day(1).format('YYYY-MM-DD');
                    }
                    else {
                        return '';
                    }
                }
                else if (column.type == 'datetime') {
                    if (values[column.field]) {
                        values[column.field] = values[column.field].format('YYYY-MM-DD HH:mm:ss');
                    }
                    else {
                        return '';
                    }
                }
                else if (column.type == 'time') {
                    if (values[column.field]) {
                        values[column.field] = values[column.field].format('HH:mm:ss');
                    }
                    else {
                        return '';
                    }
                }
                else if (column.type == 'daterange') {
                    var _a = __read(values[column.field], 2), start = _a[0], end = _a[1];
                    var fields = column.field.split(',');
                    if (fields.length == 2) {
                        values[fields[0]] = start.format('YYYY-MM-DD');
                        values[fields[1]] = end.format('YYYY-MM-DD');
                        _.unset(values, column.field);
                    }
                }
                else if (column.type == 'checkbox' || column.type == 'selectcode') {
                    values[column.field] = values[column.field].join(',');
                }
                else if (column.type == 'radiomore') {
                    if (values[column.field] == MORE) {
                        if (_.has(STOREMORE, MORE + column.field)) {
                            values[column.field] = STOREMORE[MORE + column.field];
                        }
                        else {
                            values[column.field] = '';
                        }
                    }
                }
                else if (column.type == 'cascader') {
                    if (values[column.field].length > 0) {
                        values[column.field] = values[column.field][values[column.field].length - 1];
                    }
                    else {
                        values[column.field] = '';
                    }
                }
                else if (column.type == 'organization') {
                    var filelds = column.field.split(',');
                    var _b = __read(filelds, 4), code = _b[0], name_2 = _b[1], province = _b[2], city = _b[3];
                    var orgInfo = values[column.field];
                    if (orgInfo) {
                        if (code)
                            values[code] = orgInfo.code;
                        if (name_2)
                            values[name_2] = orgInfo.name;
                        if (province)
                            values[province] = orgInfo.code.substr(0, 2);
                        if (city)
                            values[city] = orgInfo.code.substr(0, 4);
                    }
                    else {
                        if (code)
                            values[code] = '';
                        if (name_2)
                            values[name_2] = '';
                        if (province)
                            values[province] = '';
                        if (city)
                            values[city] = '';
                    }
                    _.unset(values, column.field);
                }
                else if (column.type == 'domain') {
                    var filelds = column.field.split(',');
                    var _c = __read(filelds, 2), code = _c[0], domainName = _c[1];
                    var domainInfo = values[column.field];
                    if (domainInfo) {
                        if (code)
                            values[code] = domainInfo.code;
                        if (domainName)
                            values[domainName] = domainInfo.domainName;
                    }
                    else {
                        if (code)
                            values[code] = '';
                        if (domainName)
                            values[domainName] = '';
                    }
                    _.unset(values, column.field);
                }
                else if (column.type == 'editor') {
                }
            });
            _this.props.onOk(_.assign({}, _this.props.default, _this.props.data, values));
        });
    };
    FormModal.prototype.render = function () {
        var _this = this;
        var data = _.assign({}, this.props.default, this.props.data);
        _.keys(data).map(function (key) {
            if (data[key] === null) {
                data[key] = '';
            }
        });
        var loose = false;
        if (_.isNumber(this.props.width) && this.props.width >= 960) {
            loose = true;
        }
        var DataFrom = antd_1.Form.create()(FromContent);
        var columns = this._warpColumns(this.props.columns);
        return React.createElement(antd_1.Modal, __assign({ footer: [React.createElement(antd_1.Button, { type: "primary", onClick: function () { return _this.submit(); } }, "\u786E\u8BA4"),
                React.createElement(antd_1.Button, { onClick: function (evt) { return _this.props.onCancel(evt); } }, "\u53D6\u6D88")
            ] }, this.props, { onOk: function () { return _this.submit(); } }),
            React.createElement(DataFrom, { loose: loose, upload: this.props.upload, data: data, columns: columns, show: this.props.visible, ref: function (form) { return _this.form = form; } }));
    };
    FormModal.MORE = MORE;
    return FormModal;
}(React.PureComponent));
exports.default = FormModal;
