UNPKG

fastlion-amis

Version:

一种MIS页面生成工具

2,618 lines 157 kB
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormRenderer = void 0;
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importDefault(require("react"));
var factory_1 = require("../../factory");
var form_1 = require("../../store/form");
var types_1 = require("../../types");
var tpl_1 = require("../../utils/tpl");
var classnames_1 = tslib_1.__importDefault(require("classnames"));
var filter_schema_1 = tslib_1.__importDefault(require("../../utils/filter-schema"));
var helper_1 = require("../../utils/helper");
var debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
var flatten_1 = tslib_1.__importDefault(require("lodash/flatten"));
var find_1 = tslib_1.__importDefault(require("lodash/find"));
var Scoped_1 = require("../../Scoped");
var tpl_builtin_1 = require("../../utils/tpl-builtin");
var api_1 = require("../../utils/api");
var Spinner_1 = tslib_1.__importDefault(require("../../components/Spinner"));
var components_1 = require("../../components");
var mobx_state_tree_1 = require("mobx-state-tree");
var msgsub_1 = tslib_1.__importDefault(require("../Lion/utils/msgsub"));
var amis_formula_1 = require("amis-formula");
// import Checkbox from '../../components/Checkbox';
var Button_1 = tslib_1.__importDefault(require("../../components/Button"));
var OptionTransfer_1 = tslib_1.__importDefault(require("../../components/Lion/OptionTransfer"));
var row_1 = tslib_1.__importDefault(require("antd/lib/row"));
var col_1 = tslib_1.__importDefault(require("antd/lib/col"));
var antd_1 = require("antd");
var divider_1 = tslib_1.__importDefault(require("antd/lib/divider"));
var lodash_1 = require("lodash");
var AdvancedModlePopup_1 = tslib_1.__importDefault(require("../../components/Lion/AdvancedModlePopup"));
var icons_1 = require("../../components/icons");
var utils_1 = require("../Lion/utils/utils");
var ScrollMB_1 = tslib_1.__importDefault(require("../../components/ScrollMB"));
var LabelPrint_1 = require("../Lion/LabelPrint");
var LodopFuncs_1 = require("../../utils/print/LodopFuncs");
var Workflow_1 = tslib_1.__importDefault(require("../../components/Mobileprocess/Workflow"));
var locale_1 = require("../../locale");
var keyStep_1 = require("../../utils/keyStep");
var CrudFilter_1 = tslib_1.__importDefault(require("../../components/Lion/CrudFilter"));
var icons_2 = require("@ant-design/icons");
var sortablejs_1 = tslib_1.__importDefault(require("sortablejs"));
/**
 * 枚举 RangeOptionsEnum 用于表示范围选项
 */
var RangeOptionsEnum;
(function (RangeOptionsEnum) {
    RangeOptionsEnum[RangeOptionsEnum["Equal"] = 2] = "Equal";
    RangeOptionsEnum[RangeOptionsEnum["GreaterThan"] = 3] = "GreaterThan";
    RangeOptionsEnum[RangeOptionsEnum["GreaterThanOrEqual"] = 4] = "GreaterThanOrEqual";
    RangeOptionsEnum[RangeOptionsEnum["LessThan"] = 5] = "LessThan";
    RangeOptionsEnum[RangeOptionsEnum["LessThanOrEqual"] = 6] = "LessThanOrEqual";
    RangeOptionsEnum[RangeOptionsEnum["Between"] = 7] = "Between";
    RangeOptionsEnum[RangeOptionsEnum["ContainWithin"] = 8] = "ContainWithin";
    RangeOptionsEnum[RangeOptionsEnum["Contain"] = 9] = "Contain";
    RangeOptionsEnum[RangeOptionsEnum["IsEmpty"] = 10] = "IsEmpty";
    RangeOptionsEnum[RangeOptionsEnum["Fuzzy"] = 11] = "Fuzzy";
    RangeOptionsEnum[RangeOptionsEnum["DataTag"] = 12] = "DataTag"; // 数据标签
})(RangeOptionsEnum || (RangeOptionsEnum = {}));
var rangeOptions = [
    { label: '等于', value: RangeOptionsEnum.Equal },
    { label: '大于', value: RangeOptionsEnum.GreaterThan },
    { label: '大于等于', value: RangeOptionsEnum.GreaterThanOrEqual },
    { label: '小于', value: RangeOptionsEnum.LessThan },
    { label: '小于等于', value: RangeOptionsEnum.LessThanOrEqual },
    { label: '介于', value: RangeOptionsEnum.Between },
    { label: '包含于', value: RangeOptionsEnum.ContainWithin },
    { label: '包含', value: RangeOptionsEnum.Contain },
    { label: '为空', value: RangeOptionsEnum.IsEmpty },
    { label: '模糊', value: RangeOptionsEnum.Fuzzy },
    { label: '不等于', value: RangeOptionsEnum.Equal, not: true },
    { label: '不大于', value: RangeOptionsEnum.GreaterThan, not: true },
    { label: '不大于等于', value: RangeOptionsEnum.GreaterThanOrEqual, not: true },
    { label: '不小于', value: RangeOptionsEnum.LessThan, not: true },
    { label: '不小于等于', value: RangeOptionsEnum.LessThanOrEqual, not: true },
    { label: '不介于', value: RangeOptionsEnum.Between, not: true },
    { label: '不包含于', value: RangeOptionsEnum.ContainWithin, not: true },
    { label: '不包含', value: RangeOptionsEnum.Contain, not: true },
    { label: '不为空', value: RangeOptionsEnum.IsEmpty, not: true },
    { label: '不模糊', value: RangeOptionsEnum.Fuzzy, not: true },
    { label: '属于标签', value: RangeOptionsEnum.DataTag }
];
// onlyEmptyRangeOptions 数组映射
var onlyEmptyRangeOptions = [
    { label: '为空', value: RangeOptionsEnum.IsEmpty },
];
// 类型枚举类
var TagTypeEnum;
(function (TagTypeEnum) {
    TagTypeEnum["Select"] = "select";
    TagTypeEnum["TreeSelect"] = "tree-select";
    TagTypeEnum["TransferPicker"] = "transfer-picker";
    TagTypeEnum["TabsTransferPicker"] = "tabs-transfer-picker";
    TagTypeEnum["InputDateRange"] = "input-date-range";
    TagTypeEnum["InputDatetimeRange"] = "input-datetime-range";
    TagTypeEnum["InputMonthRange"] = "input-month-range";
    TagTypeEnum["InputYearRange"] = "input-year-range";
    TagTypeEnum["InputQuarterRange"] = "input-quarter-range";
    TagTypeEnum["InputTimeRange"] = "input-time-range";
    TagTypeEnum["InputTag"] = "input-tag";
    TagTypeEnum["NestedSelect"] = "nested-select";
    TagTypeEnum["InputNumber"] = "input-number";
    TagTypeEnum["InputText"] = "input-text";
    TagTypeEnum["InputDatetime"] = "input-datetime";
    TagTypeEnum["InputDate"] = "input-date";
    TagTypeEnum["InputMonth"] = "input-month";
    TagTypeEnum["file"] = "lion-upload";
    TagTypeEnum["Picker"] = "picker";
    TagTypeEnum["Switch"] = "switch";
    TagTypeEnum["Checkboxes"] = "checkboxes"; //复选按钮
})(TagTypeEnum || (TagTypeEnum = {}));
var notRange = [
    //   TagTypeEnum.Select,
    TagTypeEnum.TreeSelect,
    // TagTypeEnum.TransferPicker,
    TagTypeEnum.TabsTransferPicker,
    TagTypeEnum.InputDateRange,
    TagTypeEnum.InputDatetimeRange,
    TagTypeEnum.InputMonthRange,
    TagTypeEnum.InputYearRange,
    TagTypeEnum.InputQuarterRange,
    TagTypeEnum.InputTimeRange,
    TagTypeEnum.InputTag,
    TagTypeEnum.NestedSelect,
    TagTypeEnum.Switch
];
var Form = /** @class */ (function (_super) {
    tslib_1.__extends(Form, _super);
    function Form(props) {
        var _this = this;
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
        _this = _super.call(this, props) || this;
        _this.hooks = {};
        _this.shouldLoadInitApi = false;
        _this.lazyEmitChange = (0, debounce_1.default)(_this.emitChange.bind(_this), 250, {
            trailing: true,
            leading: false
        });
        _this.changeFields = [];
        _this.handleUserChange = function () { return _this.setState({ userChange: true }); };
        _this.changeTimes = 0;
        _this.filterObj = {};
        _this.casestatr = true;
        _this.limitInputRef = react_1.default.createRef();
        _this.showBody = true;
        _this.valueChanged = false;
        _this.handleInputFocus = function () {
            _this.setState({ inputfocus: false });
        };
        _this.hanldeAdvancedQueryDefault = function () {
            var _a, _b, _c, _d, _e, _f;
            var filtersArr = [];
            var filtersHeader = [];
            if ((_a = _this.filterOptions) === null || _a === void 0 ? void 0 : _a.length) {
                filtersArr = _this.getDefaultFilterArrs();
            }
            if ((_b = _this.filterNorma) === null || _b === void 0 ? void 0 : _b.length) {
                filtersHeader = _this.filterNorma;
            }
            if (((_c = _this.props) === null || _c === void 0 ? void 0 : _c.filtercont) && Object.keys(_this.props.filtercont).length) {
                var _g = _this.props, advancedFilter = _g.advancedFilter, handlePrefix = _g.handlePrefix, store_1 = _g.store, body_1 = _g.body;
                var conten = handlePrefix === null || handlePrefix === void 0 ? void 0 : handlePrefix(_this.props.filtercont);
                var prefix = conten ? tslib_1.__spreadArray(tslib_1.__spreadArray([], conten === null || conten === void 0 ? void 0 : conten.advancedFilter, true), conten === null || conten === void 0 ? void 0 : conten.advancedFilterSub, true) : [];
                var defaultHeader = [];
                var defaultFilterArr = [];
                if (conten === null || conten === void 0 ? void 0 : conten.advancedHeader) {
                    defaultHeader = Object.entries(conten === null || conten === void 0 ? void 0 : conten.advancedHeader).map(function (_a) {
                        var key = _a[0], value = _a[1];
                        return ({ key: key, value: value });
                    });
                }
                if (advancedFilter && ((_d = _this.filterOptions) === null || _d === void 0 ? void 0 : _d.length) && prefix.length) {
                    defaultFilterArr = prefix;
                    var newList_1 = [];
                    prefix.forEach(function (item) {
                        newList_1.push({
                            field: item.field,
                            condition: item.condition,
                            not: item.not,
                            op: item.op,
                            dateLine: item.dateLine
                        });
                        if (item.field.includes('--')) {
                            var originField = item.field.split('--')[0];
                            _this.dealFilterOptions(originField, item.field);
                        }
                    });
                    var dateList = _this.getDateArr();
                    var dateLineItem = newList_1.find(function (item) { return item.dateLine; });
                    filtersArr = dateList.length > 0 && !dateLineItem ? tslib_1.__spreadArray([
                        {
                            field: dateList[0].name,
                            condition: 1,
                            not: false,
                            op: 7,
                            dateLine: true
                        }
                    ], newList_1, true) : tslib_1.__spreadArray([], newList_1, true);
                    _this.casestatr = ((_e = prefix === null || prefix === void 0 ? void 0 : prefix[0]) === null || _e === void 0 ? void 0 : _e.caseSensitive) == 0 ? false : true;
                }
                // 高级查询默认值
                if (defaultFilterArr.length) {
                    var filter_1 = (_f = advancedFilter === null || advancedFilter === void 0 ? void 0 : advancedFilter.body) === null || _f === void 0 ? void 0 : _f.find(function (item) { return item.name == "advancedFilter"; });
                    defaultFilterArr.map(function (item, key) {
                        var _a, _b, _c;
                        var isTime = false;
                        if (filter_1) {
                            var data_1 = (_a = filter_1.body) === null || _a === void 0 ? void 0 : _a.find(function (data) { return data.name == (item === null || item === void 0 ? void 0 : item.field); });
                            if (data_1 && [TagTypeEnum.InputDatetime, TagTypeEnum.InputDate, TagTypeEnum.InputMonth].some(function (item) { return item == (data_1 === null || data_1 === void 0 ? void 0 : data_1.type); })) {
                                isTime = true;
                            }
                            else {
                                isTime = false;
                            }
                        }
                        var values = item === null || item === void 0 ? void 0 : item.values;
                        var compareField = (0, lodash_1.cloneDeep)(item.compareField);
                        if (values && typeof values == 'string' && values.includes('(') && values.includes(')') && compareField) {
                            var columns_1 = (_c = (_b = body_1 === null || body_1 === void 0 ? void 0 : body_1.find(function (item) { return item.name == 'advancedFilter'; })) === null || _b === void 0 ? void 0 : _b.body) !== null && _c !== void 0 ? _c : [];
                            var result_1 = values.substring(1, values.length - 1);
                            compareField.forEach(function (item) {
                                var match = item;
                                var regex = new RegExp(match, 'g');
                                // advancedFilter 默认值设置完善
                                var content = columns_1.find(function (item) { return item.name == "advancedFilter.".concat(match) || item.name == "advancedFilterSub.".concat(match); });
                                if (content) {
                                    result_1 = result_1.replace(regex, "[".concat(content.label, "]"));
                                }
                            });
                            if (!!result_1) {
                                filtersArr[key].compareField = compareField;
                                store_1.changeValue(item.field, result_1, false);
                            }
                        }
                        else {
                            if (item.op == 7 && (item === null || item === void 0 ? void 0 : item.values) && !isTime) {
                                var between = (item === null || item === void 0 ? void 0 : item.values).split(",");
                                if (between.length == 2) {
                                    between.forEach(function (val, index) {
                                        if (index == 0) {
                                            store_1.changeValue(item.field + '-a8', val, false);
                                        }
                                        else {
                                            store_1.changeValue(item.field + '-b8', val, false);
                                        }
                                    });
                                    return;
                                }
                            }
                            store_1.changeValue(item.field, item === null || item === void 0 ? void 0 : item.values, false);
                        }
                    });
                }
                // 高级查询默认值高级查询默认值中的advancedHeader
                if (defaultHeader.length) {
                    defaultHeader.map(function (item) {
                        store_1.changeValue(item.key, item === null || item === void 0 ? void 0 : item.value, false);
                    });
                }
                _this.setState({ filtersHeader: filtersHeader, defaultHeader: defaultHeader, defaultFilterArr: defaultFilterArr, filtersArr: filtersArr });
            }
            else {
                _this.setState({ filtersArr: filtersArr, filtersHeader: filtersHeader });
            }
        };
        _this.handleJump = function (body) {
            var _a;
            if (body.redirectType === '2') {
                _this.props.env.fetcher(body.linkUrl, body.bodydata).then(function (res) {
                    if (res.ok && res.data != null) {
                        _this.flowDetail = res.data;
                        _this.setState({ flowModalVisible: true });
                    }
                    else {
                        antd_1.message.error(res.msg);
                    }
                });
                return;
            }
            var types = (0, helper_1.isMobile)() ? 'drawer' : 'dialog';
            var action = {
                type: "action",
                actionType: types,
                close: true
            };
            action[types] = {
                title: body.linkTitle,
                type: types,
                name: "form-dialog-service-".concat((0, utils_1.createRandomValue)()),
                size: (_a = body.linkSize) !== null && _a !== void 0 ? _a : 'lg',
                bodyClassName: "overflow-y-auto max-h-nestSide-".concat(types),
                className: "h-full",
                actions: [],
                body: {
                    schemaApi: {
                        "method": "get",
                        "url": body.linkUrl
                    },
                    type: "service",
                    name: "form-service-".concat((0, utils_1.createRandomValue)())
                }
            };
            _this.handleAction(_this.props.e, action, body.bodydata);
        };
        //处理高级查询对应的下拉选择列表,允许字段重复出现,需要构造key
        _this.dealFilterOptions = function (value, createName) {
            var origin = _this.filterObj[value];
            _this.filterObj[createName] = tslib_1.__assign(tslib_1.__assign({}, origin), { name: createName });
            if (!_this.filterOptions.find(function (item) { return item.value === createName; })) {
                _this.filterOptions.push({ label: (origin.groupName ? "".concat(origin.groupName, " \u00B7 ") : '') + (origin.label || origin.placeholder), value: createName, type: origin.type, isNumber: origin.isNumber || null });
            }
        };
        _this.changePare = function (value, index) {
            var filtersArr = _this.state.filtersArr;
            filtersArr[index].compareField = value;
            _this.setState({ filtersArr: filtersArr });
        };
        _this.selectEmptyTime = function (index) {
            var filtersArr = _this.state.filtersArr;
            var store = _this.props.store;
            store.changeValue(filtersArr[index].field, '', false);
            filtersArr[index].op = 2;
            _this.setState({ filtersArr: filtersArr, emptyTimeSelected: true });
        };
        _this.getDateArr = function () {
            var _a;
            var _b = _this.props, body = _b.body, advancedQueryFields = _b.advancedQueryFields;
            var filters = Array.isArray(body) ? body : body
                ? [body] : [];
            var adv = (_a = filters.find(function (item) { return item.name === 'advancedFilter'; })) === null || _a === void 0 ? void 0 : _a.body;
            if (adv === null || adv === void 0 ? void 0 : adv.length) {
                var list = adv.filter(function (item) { return item.type && ['input-date', 'input-datetime', 'input-time', 'input-month', 'input-quarter', 'input-year'].includes(item.type); });
                if (advancedQueryFields) {
                    list = list.filter(function (item) { var _a, _b; return advancedQueryFields.includes((_b = (_a = item.name) === null || _a === void 0 ? void 0 : _a.split('.')) === null || _b === void 0 ? void 0 : _b[1]); });
                }
                return list;
            }
            return [];
        };
        _this.getDefaultFilterArrs = function () {
            var body = _this.filterPropsArr();
            var dateList = _this.getDateArr();
            var defaultCondition = {
                field: body[0].value,
                condition: 1,
                not: false,
                op: 2
            };
            if (dateList.length > 0 && defaultCondition.field === dateList[0].name) {
                _this.dealFilterOptions(defaultCondition.field, defaultCondition.field + '--1');
            }
            var list = dateList.length > 0 ? [
                {
                    field: dateList[0].name,
                    condition: 1,
                    not: false,
                    op: 7,
                    dateLine: true
                },
                tslib_1.__assign(tslib_1.__assign({}, defaultCondition), { field: defaultCondition.field === dateList[0].name ? defaultCondition.field + '--1' : defaultCondition.field })
            ] : [tslib_1.__assign({}, defaultCondition)];
            return list;
        };
        _this.clearAdvancedFilter = function (columnInfo) {
            var store = _this.props.store;
            if (columnInfo) {
                var defaultHeader_1 = columnInfo.advancedHeader;
                var defaultFilters_1 = columnInfo.advancedFilter;
                _this.resetAdvancedOptionsFilter(columnInfo.optionsParam);
                store.changeValue("advancedHeader", undefined);
                Object.keys(defaultHeader_1 !== null && defaultHeader_1 !== void 0 ? defaultHeader_1 : {}).forEach(function (key) {
                    store.changeValue("advancedHeader.".concat(key), defaultHeader_1[key]);
                });
                if (Array.isArray(defaultFilters_1)) {
                    _this.setState(function (pre) { return ({ filtersArr: pre.filtersArr.filter(function (item) { var _a, _b, _c; return defaultFilters_1.map(function (f) { return f.field; }).includes((_c = (_b = (_a = item.field.split('.')) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.split('--')) === null || _c === void 0 ? void 0 : _c[0]); }) }); }, function () {
                        store.clear();
                        defaultFilters_1.forEach(function (item) { store.changeValue("advancedFilter.".concat(item.field), item.values); });
                    });
                }
            }
            else {
                _this.resetDefaultQuery();
            }
        };
        _this.resetDefaultQuery = function () {
            var _a = _this.props, body = _a.body, store = _a.store;
            _this.resetAdvancedOptionsFilter();
            var list = _this.getDefaultFilterArrs();
            _this.setState({ caseSensitive: true, topN: 3000, limitStatus: false, filtersArr: list }, function () {
                var _a, _b;
                if (Array.isArray(body)) {
                    store.clear();
                    var filterBodys_1 = (_a = body.find(function (b) { return b.name === 'advancedFilter'; })) === null || _a === void 0 ? void 0 : _a.body;
                    if (Array.isArray(filterBodys_1)) {
                        list.forEach(function (item) {
                            var _a;
                            var value = (_a = filterBodys_1.find(function (f) { return f.name === item.field; })) === null || _a === void 0 ? void 0 : _a.value;
                            store.changeValue(item.field, value);
                        });
                    }
                    var filterHeaders = (_b = body.find(function (b) { return b.name === 'advancedHeader'; })) === null || _b === void 0 ? void 0 : _b.body;
                    if (Array.isArray(filterHeaders)) {
                        filterHeaders.forEach(function (item) {
                            store.changeValue(item.name, item.value);
                        });
                    }
                }
            });
        };
        _this.clearDefaultQuery = function () {
            _this.props.store.clear();
        };
        _this.getSameEle = function (marr1, marr2) {
            var eleIsInArr = function (ele, arr) { return arr.some(function (m) { return m === ele.name.split(".")[1]; }); };
            return marr1.filter(function (x) { return eleIsInArr(x, marr2); });
        };
        _this.handleOptionTransfer = function () {
            var _a;
            var _b = _this.props, columns = _b.columns, filtercont = _b.filtercont;
            var mobile = (0, helper_1.isMobile)();
            var allFileds = (_a = columns === null || columns === void 0 ? void 0 : columns.filter(function (column) { return !(column === null || column === void 0 ? void 0 : column.hidden) && column.type !== 'operation'; }).map(function (option) { var _a, _b; return ({ type: option.type, comparable: (_a = option.comparable) !== null && _a !== void 0 ? _a : true, isNumerical: option.isNumerical, label: (option.groupName ? "".concat(option.groupName, " \u00B7 ") : '') + String(option.label), name: (_b = option.name) !== null && _b !== void 0 ? _b : '' }); })) !== null && _a !== void 0 ? _a : [];
            return (react_1.default.createElement("div", { style: mobile ? {} : { height: _this.state.unfoldQuery ? 0 : 'auto', overflow: _this.state.unfoldQuery ? 'hidden' : 'auto' } },
                react_1.default.createElement(OptionTransfer_1.default, { ref: _this.filterOptionRef, defaultOptionsParam: filtercont === null || filtercont === void 0 ? void 0 : filtercont.optionsParam, allFields: allFileds, onChange: function (data) { return _this.filterOptionData = data; } })));
        };
        _this.handleMenuClick = function (body) {
            var _a, _b, _c;
            var item = body.item;
            var store = _this.props.store;
            var val = item;
            if (val.props) {
                var name = val.props.name;
                var head = name.split(".")[0];
                var advancedName = name.split(".").pop();
                var data = (_b = (_a = store.data) === null || _a === void 0 ? void 0 : _a[head]) !== null && _b !== void 0 ? _b : {};
                var value = (_c = data === null || data === void 0 ? void 0 : data[advancedName]) !== null && _c !== void 0 ? _c : '';
                var current = val.props.value;
                var key = val.props.valKey;
                var headPare = current.value.split(".").pop();
                // 所有的条件
                var selectList_1 = val.props.items;
                //将字符串变成数组只有携带【】的
                var valMatch = value.match(/\[([^\]]*)\]/g);
                //汉字从selectList获取对应的id name获取到后面的
                var valList = valMatch === null || valMatch === void 0 ? void 0 : valMatch.map(function (item) {
                    var labelToFind = item.substring(1, item.length - 1); // 去除方括号
                    var foundItem = selectList_1.find(function (obj) { return obj.label === labelToFind; });
                    if (foundItem) {
                        return foundItem.value.split(".").pop(); // 替换为匹配的value值
                    }
                    return item; // 如果没找到匹配项,则保持原值不变
                });
                // 要是stort中没有值就只取当前上的值
                var List = valList ? tslib_1.__spreadArray(tslib_1.__spreadArray([], valList, true), [headPare], false) : [headPare];
                // 能一直写  而不是更新
                var valueList = "".concat(value, "[").concat(current.label, "]");
                _this.changePare(List, key);
                store.changeValue(name, valueList, false);
            }
        };
        // 下拉框参数获取
        _this.getDownCondition = function () {
            var options = _this.filterPropsArr().map(function (item) { return (tslib_1.__assign(tslib_1.__assign({}, item), { value: item.value.split('--')[0] })); });
            var selectList = [];
            options.forEach(function (item) {
                if (!selectList.some(function (i) { return i.value === item.value; })) {
                    selectList.push(item);
                }
            });
            return selectList.filter(function (val) { return (val.type && ['input-number', 'input-text', 'input-date', 'input-datetime'].includes(val.type)) || val.isNumber; });
        };
        //粘贴
        _this.pasteContent = function (item) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
            var content, store, name, _a, parentName, fieldName, obj, value, error_1;
            var _b, _c, _d;
            return tslib_1.__generator(this, function (_e) {
                switch (_e.label) {
                    case 0:
                        _e.trys.push([0, 4, , 5]);
                        if (!(navigator.clipboard && typeof navigator.clipboard.readText === 'function')) return [3 /*break*/, 2];
                        return [4 /*yield*/, navigator.clipboard.readText()];
                    case 1:
                        content = _e.sent();
                        if (!(0, lodash_1.isNil)(content) && content !== '') {
                            store = this.props.store;
                            name = item.field;
                            _a = name.split("."), parentName = _a[0], fieldName = _a[1];
                            obj = (_c = (_b = store.data) === null || _b === void 0 ? void 0 : _b[parentName]) !== null && _c !== void 0 ? _c : {};
                            value = (_d = obj === null || obj === void 0 ? void 0 : obj[fieldName]) !== null && _d !== void 0 ? _d : '';
                            store.changeValue(name, value + content, false);
                        }
                        return [3 /*break*/, 3];
                    case 2:
                        antd_1.message.warning('当前浏览器不支持此功能');
                        _e.label = 3;
                    case 3: return [3 /*break*/, 5];
                    case 4:
                        error_1 = _e.sent();
                        console.error('读取剪切板内容时发生错误:', error_1);
                        antd_1.message.warning('读取剪切板失败');
                        return [3 /*break*/, 5];
                    case 5: return [2 /*return*/];
                }
            });
        }); };
        _this.pullDown = function () {
            var _a = _this.props, initApi = _a.initApi, store = _a.store, initAsyncApi = _a.initAsyncApi, initFinishedField = _a.initFinishedField, initCheckInterval = _a.initCheckInterval, _b = _a.messages, fetchFailed = _b.fetchFailed, fetchSuccess = _b.fetchSuccess;
            return store
                .fetchInitData(initApi, store.data, {
                successMessage: fetchSuccess,
                errorMessage: fetchFailed,
                onSuccess: function () {
                    if (!(0, api_1.isEffectiveApi)(initAsyncApi, store.data) ||
                        store.data[initFinishedField || 'finished']) {
                        return;
                    }
                    return (0, helper_1.until)(function () { return store.checkRemote(initAsyncApi, store.data); }, function (ret) { return ret && ret[initFinishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); }, initCheckInterval);
                }
            })
                .then(_this.initInterval)
                .then(_this.onInit);
        };
        _this.onInit = _this.onInit.bind(_this);
        _this.handleAction = _this.handleAction.bind(_this);
        _this.handleQuery = _this.handleQuery.bind(_this);
        _this.handleChange = _this.handleChange.bind(_this);
        // Jay
        _this.handleInputTableChange = _this.handleInputTableChange.bind(_this);
        _this.abandonFormItem = _this.abandonFormItem.bind(_this);
        _this.received = false;
        _this.setEdited = _this.setEdited.bind(_this);
        _this.setFormLoading = _this.setFormLoading.bind(_this);
        _this.confirmAdvancedFilter.bind(_this);
        _this.resetAdvancedFilter.bind(_this);
        (_b = (_a = _this.props).getFilterForm) === null || _b === void 0 ? void 0 : _b.call(_a, _this);
        (_d = (_c = _this.props).getAdvancedFilterForm) === null || _d === void 0 ? void 0 : _d.call(_c, _this);
        (_f = (_e = _this.props).getFormInstance) === null || _f === void 0 ? void 0 : _f.call(_e, _this);
        _this.shouldCommit = _this.shouldCommit.bind(_this);
        _this.handleDialogConfirm = _this.handleDialogConfirm.bind(_this);
        _this.resetIsModleFilter = _this.resetIsModleFilter.bind(_this);
        _this.handleDialogClose = _this.handleDialogClose.bind(_this);
        _this.handleDrawerConfirm = _this.handleDrawerConfirm.bind(_this);
        _this.handleDrawerClose = _this.handleDrawerClose.bind(_this);
        _this.handleFormSubmit = _this.handleFormSubmit.bind(_this);
        _this.validate = _this.validate.bind(_this);
        _this.submit = _this.submit.bind(_this);
        _this.addHook = _this.addHook.bind(_this);
        _this.removeHook = _this.removeHook.bind(_this);
        _this.emitChange = _this.emitChange.bind(_this);
        _this.handleBulkChange = _this.handleBulkChange.bind(_this);
        _this.renderFormItems = _this.renderFormItems.bind(_this);
        _this.reload = _this.reload.bind(_this);
        _this.silentReload = _this.silentReload.bind(_this);
        _this.initInterval = _this.initInterval.bind(_this);
        _this.blockRouting = _this.blockRouting.bind(_this);
        _this.handleChangeFields = _this.handleChangeFields.bind(_this);
        _this.beforePageUnload = _this.beforePageUnload.bind(_this);
        _this.handleSendAction = _this.handleSendAction.bind(_this);
        _this.handlerenew = _this.handlerenew.bind(_this);
        _this.handleFiltersArr = _this.handleFiltersArr.bind(_this);
        _this.contentRef = react_1.default.createRef();
        _this.filterOptionRef = react_1.default.createRef();
        if (_this.props.getAdvancedFilterForm) {
            _this.getFiltersOptions();
        }
        _this.state = {
            filtersArr: [],
            defaultHeader: [],
            defaultFilterArr: [],
            collpased: true,
            caseSensitive: _this.casestatr,
            filtersHeader: [],
            userChange: false,
            disabled: false,
            inputfocus: false,
            topN: ((_h = (_g = _this.props.filtercont) === null || _g === void 0 ? void 0 : _g.limitParam) === null || _h === void 0 ? void 0 : _h.topN) || 3000,
            limitStatus: ((_k = (_j = _this.props.filtercont) === null || _j === void 0 ? void 0 : _j.limitParam) === null || _k === void 0 ? void 0 : _k.limitStatus) || false,
            printVisible: false,
            flowModalVisible: false,
            // 缓存查询条件
            cacheFilterParams: [],
            expanded: false,
            // 选项查询默认不折叠
            unfoldQuery: false,
            // 条件查询折叠
            unfoldParam: false
        };
        _this.showMoreBtn = props.maxFilterCount != undefined && (props.maxFilterCount > 0 && Array.isArray(props.body) && props.body.length - 1 > props.maxFilterCount);
        _this._formName = props.name;
        var store = props.store, canAccessSuperData = props.canAccessSuperData, persistData = props.persistData, simpleMode = props.simpleMode;
        store.setCanAccessSuperData(canAccessSuperData !== false);
        store.setPersistData(persistData);
        if (simpleMode) {
            store.setInited(true);
        }
        if (store &&
            store.parentStore &&
            store.parentStore.storeType === 'ComboStore') {
            var combo = store.parentStore;
            combo.addForm(store);
            combo.forms.forEach(function (form) {
                return form.items.forEach(function (item) { return item.unique && item.syncOptions(undefined, form.data); });
            });
        }
        return _this;
    }
    Form.prototype.componentDidMount = function () {
        var _this = this;
        var _a, _b, _c, _d, _e;
        var _f = this.props, initApi = _f.initApi, initFetch = _f.initFetch, initFetchOn = _f.initFetchOn, initAsyncApi = _f.initAsyncApi, initOneApi = _f.initOneApi, initFinishedField = _f.initFinishedField, initCheckInterval = _f.initCheckInterval, store = _f.store, _g = _f.messages, fetchSuccess = _g.fetchSuccess, fetchFailed = _g.fetchFailed, onValidate = _f.onValidate, promptPageLeave = _f.promptPageLeave, env = _f.env, rules = _f.rules, body = _f.body, sortable = _f.sortable, crudName = _f.crudName, classPrefix = _f.classPrefix;
        // 是否要展示表格体的判断
        // 不是快速查询都展示
        // 或者 是快速查询没有group以外的条件
        this.showBody = this.props.name !== 'filterParam' || !!(!Array.isArray(body) || ((_a = (body)) === null || _a === void 0 ? void 0 : _a.filter(function (_) { return _.type !== 'group'; }).length));
        if (sortable && crudName && this.showBody) {
            var labels = (_b = this.contentRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll(".".concat(classPrefix, "Form-label"));
            labels === null || labels === void 0 ? void 0 : labels.forEach(function (element) { element.setAttribute('style', 'cursor: move'); });
            this.sortable = new sortablejs_1.default(this.contentRef.current, {
                animation: 150,
                handle: ".".concat(classPrefix, "Form-label"),
                ghostClass: 'is-dragging',
                onEnd: function (event) {
                    var nodeList = event.target.querySelectorAll('form > [data-name]');
                    var names = [];
                    nodeList.forEach(function (element) {
                        var name = element.getAttribute('data-name');
                        if (name) {
                            names.push(name);
                        }
                    });
                    if (names.length > 0) {
                        localStorage.setItem("filter_".concat(crudName), JSON.stringify(names));
                    }
                }
            });
        }
        if ((_c = this.props) === null || _c === void 0 ? void 0 : _c._bindRef) {
            this.props._bindRef(this);
        }
        if (this.props.name) {
            this._formName = this.props.name;
        }
        // 高级查询打开,查询后,在打开一个有高级查询的弹窗会找到__super下会有高级查询的东西,导致输入值会将其他的值清空掉所以先给他清空初始化一下要是找到的话
        this.resetIsModleFilter();
        this.hanldeAdvancedQueryDefault();
        this.mounted = true;
        setTimeout(function () {
            _this.is_edit = false;
        }, 0);
        this.is_edit = false;
        if (onValidate) {
            var finalValidate_1 = (0, helper_1.promisify)(onValidate);
            this.disposeOnValidate = this.addHook(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
                var result;
                return tslib_1.__generator(this, function (_a) {
                    switch (_a.label) {
                        case 0: return [4 /*yield*/, finalValidate_1(store.data, store)];
                        case 1:
                            result = _a.sent();
                            if (result && (0, helper_1.isObject)(result)) {
                                Object.keys(result).forEach(function (key) {
                                    var msg = result[key];
                                    var items = store.getItemsByPath(key);
                                    // 没有找到
                                    if (!Array.isArray(items) || !items.length) {
                                        return;
                                    }
                                    // 在setError之前,提前把残留的error信息清除掉,否则每次onValidate后都会一直把报错 append 上去
                                    items.forEach(function (item) { return item.clearError(); });
                                    if (msg) {
                                        msg = Array.isArray(msg) ? msg : [msg];
                                        items.forEach(function (item) { return item.addError(msg); });
                                    }
                                    delete result[key];
                                });
                                (0, helper_1.isEmpty)(result)
                                    ? store.clearRestError()
                                    : store.setRestError(Object.keys(result).map(function (key) { return result[key]; }));
                            }
                            return [2 /*return*/];
                    }
                });
            }); });
        }
        if (Array.isArray(rules) && rules.length) {
            this.disposeRulesValidate = this.addHook(function () {
                if (!store.valid) {
                    return;
                }
                rules.forEach(function (item) {
                    return !(0, tpl_1.evalExpression)(item.rule, store.data) &&
                        store.addRestError(item.message);
                });
            });
        }
        // Jay
        // 处理initOneApi字段
        if ((0, api_1.isEffectiveApi)(initOneApi, store.data, initFetch, initFetchOn)) {
            store
                .fetchInitData(initOneApi, store.data, {
                successMessage: fetchSuccess,
                errorMessage: fetchFailed,
                onSuccess: function () { }
            })
                .then(this.initInterval)
                .then(this.onInit);
        }
        else if ((0, api_1.isEffectiveApi)(initApi, store.data, initFetch, initFetchOn)) {
            store
                .fetchInitData(initApi, store.data, {
                successMessage: fetchSuccess,
                errorMessage: fetchFailed,
                onSuccess: function () {
                    if (!(0, api_1.isEffectiveApi)(initAsyncApi, store.data) ||
                        store.data[initFinishedField || 'finished']) {
                        return;
                    }
                    return (0, helper_1.until)(function () { return store.checkRemote(initAsyncApi, store.data); }, function (ret) { return ret && ret[initFinishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); }, initCheckInterval);
                }
            })
                .then(this.initInterval)
                .then(this.onInit);
        }
        else {
            setTimeout(this.onInit.bind(this), 4);
        }
        if (promptPageLeave) {
            window.addEventListener('beforeunload', this.beforePageUnload);
            this.unBlockRouting = (_e = (_d = env.blockRouting) === null || _d === void 0 ? void 0 : _d.call(env, this.blockRouting)) !== null && _e !== void 0 ? _e : undefined;
        }
        if (this.props.flowSpinning) {
            this.allFromReadyInterval = setInterval(function () {
                var _a, _b, _c;
                var subComponents = _this.context.getAllChildrenComponets(_this).filter(function (item) { var _a; return !['dialog', 'drawer'].includes((_a = item === null || item === void 0 ? void 0 : item.props) === null || _a === void 0 ? void 0 : _a.type); });
                // 所有子组件就绪状态
                var allComponentsReady = !subComponents.some(function (item) { var _a; return (_a = item === null || item === void 0 ? void 0 : item.props) === null || _a === void 0 ? void 0 : _a.store.loading; });
                if (allComponentsReady) {
                    (_b = (_a = _this.props) === null || _a === void 0 ? void 0 : _a.getSpinning) === null || _b === void 0 ? void 0 : _b.call(_a, allComponentsReady, (_c = _this.props) === null || _c === void 0 ? void 0 : _c._formName);
                    clearInterval(_this.allFromReadyInterval);
                }
            }, 250);
        }
    };
    Form.prototype.componentDidUpdate = function (prevProps, prevState) {
        var _a, _b;
        var props = this.props;
        var store = props.store;
        if ((0, api_1.isApiOutdated)(prevProps.initApi, props.initApi, prevProps.data, props.data)
            || (((_a = prevProps.initApi) === null || _a === void 0 ? void 0 : _a.url) !== ((_b = props.initApi) === null || _b === void 0 ? void 0 : _b.url))) {
            var fetchSuccess = props.fetchSuccess, fetchFailed = props.fetchFailed;
            // Jay
            this.is_edit = false;
            store[store.hasRemoteData ? 'fetchData' : 'fetchInitData'](props.initApi, store.data, {
                successMessage: fetchSuccess,
                errorMessage: fetchFailed
            }).then(this.initInterval);
        }
        // if (props.flowSpinning) {
        //   const spinArr: boolean[] = this.context.getComponents().filter((item: any) => item.props.type == 'service').map((item: any) => item.props.store.loading)
        //   const spin = spinArr.some(item => item)
        //   props?.getSpinning?.(store.loading || spin, props?._formName)
        // }
        if (prevProps.body !== props.body) {
            if (this.props.getAdvancedFilterForm) {
            }
            this.getFiltersOptions();
        }
    };
    Form.prototype.componentWillUnmount = function () {
        var _a, _b;
        (_a = this.sortable) === null || _a === void 0 ? void 0 : _a.destroy();
        this.mounted = false;
        clearTimeout(this.timer);
        // this.lazyHandleChange.flush();
        this.lazyEmitChange.cancel();
        this.asyncCancel && this.asyncCancel();
        this.disposeOnValidate && this.disposeOnValidate();
        this.disposeRulesValidate && this.disposeRulesValidate();
        window.removeEventListener('beforeunload', this.beforePageUnload);
        (_b = this.unBlockRouting) === null || _b === void 0 ? void 0 : _b.call(this);
    };
    Form.prototype.blockRouting = function () {
        var store = this.props.store;
        var _a = this.props, promptPageLeaveMessage = _a.promptPageLeaveMessage, promptPageLeave = _a.promptPageLeave;
        if (promptPageLeave && store.modified) {
            return promptPageLeaveMessage || '新的修改没有保存,确认要离开?';
        }
    };
    Form.prototype.beforePageUnload = function (e) {
        var blocked = this.blockRouting();
        if (blocked) {
            e.preventDefault();
            e.returnValue = '';
        }
    };
    Form.prototype.onInit = function () {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var _a, onInit, store, persistData, submitOnInit, advancedFilterVisible, data, initedAt, hooks;
            return tslib_1.__generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        _a = this.props, onInit = _a.onInit, store = _a.store, persistData = _a.persistData, submitOnInit = _a.submitOnInit, advancedFilterVisible = _a.advancedFilterVisible;
                        if (!(0, mobx_state_tree_1.isAlive)(store)) {
                            return [2 /*return*/];
                        }
                        data = (0, helper_1.cloneObject)(store.data);
                        initedAt = store.initedAt;
                        store.setInited(true);
                        hooks = this.hooks['init'] || [];
                        return [4 /*yield*/, Promise.all(hooks.map(function (hook) { return hook(data); }))];
                    case 1:
                        _b.sent();
                        if (!(0, mobx_state_tree_1.isAlive)(store)) {
                            return [2 /*return*/];
                        }
                        if (store.initedAt !== initedAt) {
                            // 说明,之前的数据已经失效了。
                            // 比如 combo 一开始设置了初始值,然后 form 的 initApi 又返回了新的值。
                            // 这个时候 store 的数据应该已经 init 了新的值。但是 data 还是老的,这个时候
                            // onInit 出去就是错误的。
                            data = tslib_1.__assign(tslib_1.__assign({}, data), store.data);
                        }
                        persistData && store.getLocalPersistData();
                        //处理高级查询初始化的时候就查询一次
                        !(0, helper_1.isMobile)() && !advancedFilterVisible && onInit && onInit(data, this.props, true);
                        this.is_edit = false; // Jay
                        submitOnInit &&
                            this.handleAction(undefined, {
                                type: 'submit'
                            }, store.data);
                        return [2 /*return*/];
                }
            });
        });
    };
    Form.prototype.reload = function (subPath, query, ctx, silent) {
        var _a;
        var _this = this;
        if (query) {
            return this.receive(query);
        }
        var _b = this.props, store = _b.store, initApi = _b.initApi, initAsyncApi = _b.initAsyncApi, initFinishedField = _b.initFinishedField, _c = _b.messages, fetchSuccess = _c.fetchSuccess, fetchFailed = _c.fetchFailed;
        (0, api_1.isEffectiveApi)(initAsyncApi, store.data) &&
            store.updateData((_a = {},
                _a[initFinishedField || 'finished'] = false,
                _a));
        (0, api_1.isEffectiveApi)(initApi, store.data)
            ? store
                .fetchInitData(initApi, store.data, {
                successMessage: fetchSuccess,
                errorMessage: fetchFailed,
                silent: silent,
                onSuccess: function () {
                    if (!(0, api_1.isEffectiveApi)(initAsyncApi, store.data) ||
                        store.data[initFinishedField || 'finished']) {
                        return;
                    }
                    return (0, helper_1.until)(function () { return store.checkRemote(initAsyncApi, store.data); }, function (ret) { return ret && ret[initFinishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); });
                }
            })
                .then(function (result) {
                if (result === null || result === void 0 ? void 0 : result.ok) {
                    _this.initInterval(result);
                    store.reset(undefined, false);
                }
            })
            : store.reset(undefined, false);
    };
    Form.prototype.receive = function (values) {
        var store = this.props.store;
        // Jay
        this.received = true;
        store.updateData(values, store.data);
        this.reload();
    };
    Form.prototype.silentReload = function (target, query) {
        this.reload(target, query, undefined, true);
    };
    Form.prototype.initInterval = function (value) {
        var _a = this.props, interval = _a.interval, silentPolling = _a.silentPolling, stopAutoRefreshWhen = _a.stopAutoRefreshWhen, data = _a.data;
        clearTimeout(this.timer);
        interval &&
            this.mounted &&
            (!stopAutoRefreshWhen || !(0, tpl_1.evalExpression)(stopAutoRefreshWhen, data)) &&
            (this.timer = setTimeout(silentPolling ? this.silentReload : this.reload, Math.max(interval, 1000)));
        return value;
    };
    Form.prototype.isValidated = function () {
        return this.props.store.validated;
    };
    Form.prototype.validate = function (forceValidate) {
        var store = this.props.store;
        this.flush();
        return store.validate(this.hooks['validate'] || [], forceValidate);
    };
    Form.prototype.clearErrors = function () {
        var store = this.props.store;
        return store.clearErrors();
    };
    Form.prototype.getValues = function () {
        var store = this.props.store;
        this.flush();
        return store.data;
    };
    Form.prototype.setValues = function (value) {
        var store = this.props.store;
        this.flush();
        store.setValues(value);
    };
    Form.prototype.submit = function (fn) {
        var _a = this.props, store = _a.store, messages = _a.messages, __ = _a.translate;
        this.flush();
        return store.submit(fn, this.hooks['validate'] || [], __(messages && messages.validateFailed));
    };
    // 如果开启了 lazyChange,需要一个 flush 方法把队列中值应用上。
    Form.prototype.flush = function () {
        var hooks = this.hooks['flush'] || [];
        hooks.forEach(function (fn) { return fn(); });
        this.lazyEmitChange.flush();
    };
    Form.prototype.reset = function () {
        var _a = this.props, store = _a.store, onReset = _a.onReset;
        store.reset(onReset);
    };
    Form.prototype.addHook = function (fn, type) {
        var _this = this;
        if (type === void 0) { type = 'validate'; }
        this.hooks[type] = this.hooks[type] || [];
        this.hooks[type].push(type === 'flush' ? fn : (0, helper_1.promisify)(fn));
        return function () {
            _this.removeHook(fn, type);
            fn = helper_1.noop;
        };
    };
    Form.prototype.removeHook = function (fn, type) {
        if (type === void 0) { type = 'validate'; }
        var hooks = this.hooks[type];
        if (!hooks) {
            return;
        }
        for (var i = 0, len = hooks.length; i < len; i++) {
            var hook = hooks[i];
            if (hook === fn || hook.raw === fn) {
                hooks.splice(i, 1);
                len--;
                i--;
            }
        }
    };
    // Jay
    // input-table组件增删改时的处理函数
    // 传递:form->wrapControl->input-table
    // exec:是否执行
    Form.prototype.handleInputTableChange = function (value, name) {
        var _a;
        var _b = this.props, store = _b.store, onFormChange = _b.onFormChange;
        !((_a = this.changeFields) === null || _a === void 0 ? void 0 : _a.includes(name)) && (this.changeFields = tslib_1.__spreadArray(tslib_1.__spreadArray([], this.changeFields, true), [name], false));
        this.is_edit = true;
        this.valueChanged = true;
        onFormChange === null || onFormChange === void 0 ? void 0 : onFormChange(value, name);
        store.changeInputTableValue(value, name);
    };
    // Jay
    Form.prototype.abandonFormItem = function (value, name) {
        var store = this.props.store;
        store.abandonFormItem(value, name);
    };
    // Jay
    Form.prototype.setEdited = function () {
        this.is_edit = true;
    };
    // Jay
    Form.prototype.setFormLoading = function (loading) {
        var store = this.props.store;
        store.markFetching(loading);
    };
    Form.prototype.handleChange = function (value, name, submit, changePristine, type) {
        var _a;
        if (changePristine === void 0) { changePristine = false; }
        var _b = this.props, store = _b.store, formLazyChange = _b.formLazyChange, handleFilterOptions = _b.handleFilterOptions, handleSaveData = _b.handleSaveData;
        if (typeof name !== 'string') {
            return;
        }
        store.changeValue(name, value, changePristine);
        handleFilterOptions && (handleFilterOptions === null || handleFilterOptions === void 0 ? void 0 : handleFilterOptions(store.data));
        if (store.items) {
            store.items.forEach(function (item) {
                if (item.name == name && item.options && item.options.length) {
                    handleSaveData && (handleSaveData === null || handleSaveData === void 0 ? void 0 : handleSaveData(name, item.options));
                }
            });
        }
        // 首次初始化:componentDidmount将is_edit置为false
        // 再次点击编辑:富文本插件会触发一次onChange,在componentDidMount之后触发
        //               富文本内进行了处理 ---> Tinymce组件
        // 数据被修改,直接将标识符设为true
        if (!this.is_edit) {
            this.is_edit = true;
        }
        if (!changePristine) {
            if (!this.valueChanged)
                this.valueChanged = true;
            if (this.props.api && !((_a = this.changeFields) === null || _a === void 0 ? void 0 : _a.includes(name))) {
                this.changeFields = tslib_1.__spreadArray(tslib_1.__spreadArray([], this.changeFields, true), [name], false);
            }
            (formLazyChange === false ? this.emitChange : this.lazyEmitChange)(submit);
        }
        if (store.persistData && store.inited) {
            store.setLocalPersistData();
        }
    };
    Form.prototype.emitChange = function (submit) {
        var _a, _b;
        var _c = this.props, onChange = _c.onChange, store = _c.store, submitOnChange = _c.submitOnChange;
        if (!(0, mobx_state_tree_1.isAlive)(store)) {
            return;
        }
        (_b = (_a = this.props).getFormStore) === null || _b === void 0 ? void 0 : _b.call(_a, store === null || store === void 0 ? void 0 : store.inputTableData);
        onChange &&
            onChange(store.data, (0, helper_1.difference)(store.data, store.pristine), this.props);
        store.clearRestError();
        (submit || (submitOnChange && store.inited)) &&
            this.handleAction(undefined, {
                type: 'submit'
            }, store.data);
    };
    Form.prototype.handleBulkChange = function (values, submit, is_mount) {
        var _a = this.props, onChange = _a.onChange, store = _a.store, formLazyChange = _a.formLazyChange;
        store.updateData(values);
        store.items.forEach(function (formItem) {
            var updatedValue = (0, helper_1.getVariable)(values, formItem.name, false);
            if (updatedValue !== undefined) {
                // 更新验证状态但保留错误信息
                formItem.reset(true);
                // 这里需要更新value,否则提交时不会使用新的字段值校验
                formItem.changeTmpValue(updatedValue);
                formItem.validateOnChange && formItem.validate(values);
            }
        });
        // 数据被修改,将标识符设为true
        this.is_edit = true;
        if (is_mount) {
            this.is_edit = false;
        }
        (formLazyChange === false ? this.emitChange : this.lazyEmitChange)(submit);
    };
    Form.prototype.handleFormSubmit = function (e) {
        var preventEnterSubmit = this.props.preventEnterSubmit;
        e.preventDefault();
        e.stopPropagation();
        if (preventEnterSubmit) {
            return false;
        }
        return this.handleAction(e, {
            type: 'submit'
        }, this.props.store.data);
    };
    //判断是否提交数据
    Form.prototype.shouldCommit = function (action, isReload) {
        var _a, _b;
        if (isReload === void 0) { isReload = false; }
        /**
          * @author:Chencicsy
          * @description:控制当数据未修改时不进行api请求
          * @param:preventModifySubmit,is_edit
        **/
        var _c = this.props, store = _c.store, onFinished = _c.onFinished, env = _c.env, onReset = _c.onReset;
        if (action.redirect) {
            var redirect = action.redirect && (0, tpl_1.filter)(action.redirect, store.data);
            redirect && env.jumpTo(redirect, action);
        }
        else if (action.reload && isReload) {
            this.reloadTarget(action.reload, store.data);
        }
        action.close && this.closeTarget(action.close);
        action.close && ((_b = (_a = this.props).onDialogClose) === null || _b === void 0 ? void 0 : _b.call(_a));
        onFinished(store.data, action);
        store.reset(onReset);
        msgsub_1.default._warning('未修改数据', env === null || env === void 0 ? void 0 : env.getModalContainer);
    };
    Form.prototype.handleSendAction = function () {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var _a, store, env, __, e, result;
            return tslib_1.__generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        _a = this.props, store = _a.store, env = _a.env, __ = _a.translate, e = _a.e;
                        return [4 /*yield*/, store.submit()];
                    case 1:
                        result = _b.sent();
                        if (!result) {
                            env.notify('error', __('Form.validateFailed'));
                        }
                        return [2 /*return*/, result];
                }
            });
        });
    };
    Form.prototype.autoFocusFirstInputControl = function () {
        var _this = this;
        // 如果在表单内部存在一个需要保持聚焦的输入框,则在清空的时候自动聚焦-多个只取第一个
        setTimeout(function () {
            var _a;
            return (_a = (0, find_1.default)(_this.context.getComponents(), (function (component) {
                var _a, _b;
                return component.input && ((_b = (_a = component === null || component === void 0 ? void 0 : component.props) === null || _a === void 0 ? void 0 : _a.$schema) === null || _b === void 0 ? void 0 : _b.keepcursor);
            }))) === null || _a === void 0 ? void 0 : _a.focus();
        }, 200);
    };
    Form.prototype.handleAction = function (e, action, data, throwErrors, delegate) {
        var _this = this;
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
        if (throwErrors === void 0) { throwErrors = false; }
        var _q = this.props, store = _q.store, onSubmit = _q.onSubmit, api = _q.api, asyncApi = _q.asyncApi, finishedField = _q.finishedField, checkInterval = _q.checkInterval, _r = _q.messages, saveSuccess = _r.saveSuccess, saveFailed = _r.saveFailed, resetAfterSubmit = _q.resetAfterSubmit, clearAfterSubmit = _q.clearAfterSubmit, onAction = _q.onAction, onSaved = _q.onSaved, onReset = _q.onReset, onFinished = _q.onFinished, onFailed = _q.onFailed, redirect = _q.redirect, reload = _q.reload, target = _q.target, withTarget = _q.withTarget, env = _q.env, onChange = _q.onChange, clearPersistDataAfterSubmit = _q.clearPersistDataAfterSubmit, trimValues = _q.trimValues, __ = _q.translate, preventModifySubmit = _q.preventModifySubmit;
        // 做动作之前,先把数据同步一下。
        this.flush();
        if (trimValues) {
            store.trimValues();
        }
        // 如果 data 就是当前层,则 flush 一下。
        if (data === this.props.data) {
            data = store.data;
        }
        if (Array.isArray(action.required) && action.required.length) {
            return store.validateFields(action.required).then(function (result) {
                if (!result) {
                    env.notify('error', __('Form.validateFailed'));
                }
                else {
                    _this.handleAction(e, tslib_1.__assign(tslib_1.__assign({}, action), { required: undefined }), data, throwErrors, delegate);
                }
            });
        }
        if (action.type === 'submit' ||
            action.actionType === 'submit' ||
            action.actionType === 'confirm' ||
            action.actionType === 'reset-and-submit' ||
            action.actionType === 'clear-and-submit') {
            store.setCurrentAction(action);
            (_b = (_a = this.props).handleReset) === null || _b === void 0 ? void 0 : _b.call(_a);
            if (action.actionType === 'reset-and-submit') {
                store.reset(onReset);
            }
            else if (action.actionType === 'clear-and-submit') {
                store.clear(onReset);
            }
            if (action.actionType == "flow_save_drat") {
                store.updateData({ FLOW_SAVE_DRAT_VALUE: 1 });
            }
            return this.submit(function (values) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
                var data_2, finnalAsyncApi_1;
                var _a;
                var _this = this;
                var _b;
                return tslib_1.__generator(this, function (_c) {
                    if (onSubmit && onSubmit(values, action) === false) {
                        return [2 /*return*/, Promise.resolve(false)];
                    }
                    if (preventModifySubmit && !this.is_edit && !this.valueChanged) {
                        this.shouldCommit(action);
                        return [2 /*return*/];
                    }
                    if (target) {
                        this.submitToTarget(target, values, withTarget);
                    }
                    else if (action.actionType === 'reload') {
                        action.target && this.reloadTarget(action.target, values);
                    }
                    else if (action.actionType === 'dialog') {
                        store.openDialog(data);
                    }
                    else if (action.actionType === 'drawer') {
                        store.openDrawer(data);
                    }
                    else if ((0, api_1.isEffectiveApi)(action.api || api, values)) {
                        data_2 = Object.assign(values, store.hiddenIputTable, store.inputTableData, { changeFields: (_b = this.changeFields) === null || _b === void 0 ? void 0 : _b.join() });
                        finnalAsyncApi_1 = action.asyncApi || asyncApi;
                        (0, api_1.isEffectiveApi)(finnalAsyncApi_1, store.data) &&
                            store.updateData((_a = {},
                                _a[finishedField || 'finished'] = false,
                                _a));
                        return [2 /*return*/, store
                                .saveRemote(action.api || api, data_2, {
                                successMessage: saveSuccess,
                                errorMessage: saveFailed,
                                onSuccess: function () {
                                    if (!(0, api_1.isEffectiveApi)(finnalAsyncApi_1, store.data) ||
                                        store.data[finishedField || 'finished']) {
                                        return;
                                    }
                                    return (0, helper_1.until)(function () { return store.checkRemote(finnalAsyncApi_1, store.data); }, function (ret) { return ret && ret[finishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); }, checkInterval);
                                }
                            })
                                .then(function (response) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
                                var feedback, scanAfterDo, confirmed;
                                var _this = this;
                                var _a;
                                return tslib_1.__generator(this, function (_b) {
                                    switch (_b.label) {
                                        case 0:
                                            onSaved && onSaved(values, response);
                                            feedback = action.feedback || this.props.feedback;
                                            if (!((response === null || response === void 0 ? void 0 : response.status) === 20003)) return [3 /*break*/, 2];
                                            scanAfterDo = (_a = response === null || response === void 0 ? void 0 : response.scanAfterDo) !== null && _a !== void 0 ? _a : [];
                                            return [4 /*yield*/, (0, keyStep_1.KeyStepCommonFunction)(scanAfterDo, data_2, env, this.props, undefined, this.props.reload ? function () { _this.reloadTarget(_this.props.reload, _this.props.store.data); } : undefined)];
                                        case 1:
                                            _b.sent();
                                            this.setState({ inputfocus: true });
                                            _b.label = 2;
                                        case 2:
                                            if (!(feedback && (0, helper_1.isVisible)(feedback, store.data))) return [3 /*break*/, 4];
                                            return [4 /*yield*/, this.openFeedback(feedback, store.data)];
                                        case 3:
                                            confirmed = _b.sent();
                                            // 如果 feedback 配置了,取消就跳过原有逻辑。
                                            if (feedback.skipRestOnCancel && !confirmed) {
                                                throw new helper_1.SkipOperation();
                                            }
                                            else if (feedback.skipRestOnConfirm && confirmed) {
                                                throw new helper_1.SkipOperation();
                                            }
                                            _b.label = 4;
                                        case 4: return [2 /*return*/];
                                    }
                                });
                            }); })];
                    }
                    return [2 /*return*/, Promise.resolve(null)];
                });
            }); })
                .then(function (values) {
                // 有可能 onSubmit return false 了,那么后面的就不应该再执行了。
                if (values === false) {
                    return store.data;
                }
                if (onFinished && onFinished(values, action) === false) {
                    return values;
                }
                resetAfterSubmit && store.reset(onReset);
                clearAfterSubmit && store.clear(onReset);
                clearPersistDataAfterSubmit && store.clearLocalPersistData();
                if (action.redirect || redirect) {
                    var finalRedirect = (0, tpl_1.filter)(action.redirect || redirect, store.data);
                    finalRedirect && env.jumpTo(finalRedirect, action);
                }
                else if ((action.reload || reload)) {
                    _this.reloadTarget(action.reload || reload, store.data);
                }
                action.close && _this.closeTarget(action.close);
                return values;
            })
                .catch(function (reason) {
                if (reason instanceof helper_1.SkipOperation) {
                    return;
                }
                onFailed && onFailed(reason, store.errors);
                if (throwErrors) {
                    throw reason;
                }
            });
        }
        else if (action.type === 'reset' || action.actionType === 'reset') {
            (_d = (_c = this.props).handledelVisible) === null || _d === void 0 ? void 0 : _d.call(_c, undefined, true);
            store.setCurrentAction(action);
            store.reset(function (data) { return onReset === null || onReset === void 0 ? void 0 : onReset(data, action); });
            (_f = (_e = this.props).handleFilterOptions) === null || _f === void 0 ? void 0 : _f.call(_e, store.data);
            (_h = (_g = this.props).handleReset) === null || _h === void 0 ? void 0 : _h.call(_g);
            // 如果在表单内部存在一个需要保持聚焦的输入框,则在清空的时候自动聚焦-多个只取第一个
            this.autoFocusFirstInputControl();
        }
        else if (action.actionType === 'clear') {
            store.setCurrentAction(action);
            store.clear(onReset);
        }
        else if (action.actionType === 'dialog') {
            store.setCurrentAction(action);
            store.openDialog(data);
        }
        else if (action.actionType === 'drawer') {
            store.setCurrentAction(action);
            store.openDrawer(data);
        }
        else if (action.actionType === 'ajax') {
            store.setCurrentAction(action);
            if (!(0, api_1.isEffectiveApi)(action.api)) {
                return env.alert(__("\u5F53 actionType \u4E3A ajax \u65F6\uFF0C\u8BF7\u8BBE\u7F6E api \u5C5E\u6027"));
            }
            if (preventModifySubmit && !this.is_edit && !this.valueChanged) {
                return this.shouldCommit(action, true);
            }
            return store
                .saveRemote(action.api, data, {
                successMessage: __((action.messages && action.messages.success) || saveSuccess),
                errorMessage: __((action.messages && action.messages.failed) || saveFailed)
            })
                .then(function (response) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
                var _data, redirect;
                var _a, _b;
                return tslib_1.__generator(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            response &&
                                onChange &&
                                onChange(store.data, (0, helper_1.difference)(store.data, store.pristine), this.props);
                            _data = (0, amis_formula_1.createObject)(data, response);
                            if (!store.validated) return [3 /*break*/, 2];
                            return [4 /*yield*/, this.validate(true)];
                        case 1:
                            _c.sent();
                            _c.label = 2;
                        case 2:
                            if (!(action.feedback && (0, helper_1.isVisible)(action.feedback, store.data))) return [3 /*break*/, 4];
                            return [4 /*yield*/, this.openFeedback(action.feedback, store.data)];
                        case 3:
                            _c.sent();
                            _c.label = 4;
                        case 4:
                            redirect = action.redirect && (0, tpl_1.filter)(action.redirect, store.data);
                            redirect && env.jumpTo(redirect, action);
                            action.reload && this.reloadTarget(action.reload, store.data);
                            action.close && this.closeTarget(action.close);
                            // Jay
                            // ajax类型支持关闭dialog
                            action.close && ((_b = (_a = this.props).onDialogClose) === null || _b === void 0 ? void 0 : _b.call(_a));
                            return [2 /*return*/];
                    }
                });
            }); })
                .catch(function (e) {
                onFailed && onFailed(e, store.errors);
                if (throwErrors) {
                    throw e;
                }
            });
        }
        else if (action.actionType === 'reload') {
            store.setCurrentAction(action);
            if (action.target) {
                this.reloadTarget(action.target, data);
            }
            else {
                // 刷自己
                this.receive(data);
            }
            // action.target && this.reloadTarget(action.target, data);
        }
        else if (action.actionType === 'advanced-filter') {
            (_k = (_j = this.props).handleFilterOptions) === null || _k === void 0 ? void 0 : _k.call(_j, store.data);
            // 高级查询
            (_m = (_l = this.props).handleFilterAdvanced) === null || _m === void 0 ? void 0 : _m.call(_l);
        }
        else if (action.actionType === 'form-print' || action.actionType === 'flow-print') {
            var LODOP = (0, LodopFuncs_1.getLodop)();
            if (LODOP) {
                this.printActionData = { printInfo: action.printInfo, callbackApi: action.callbackApi, actionType: action.actionType };
                this.setState({ printVisible: true });
                (_o = this.contentRef.current) === null || _o === void 0 ? void 0 : _o.setAttribute('id', "FORM_".concat((_p = this.props.name) !== null && _p !== void 0 ? _p : 'detail'));
            }
        }
        else if (onAction) {
            // 不识别的丢给上层去处理。
            return onAction(e, action, data, throwErrors, delegate || this.context);
        }
    };
    Form.prototype.handleQuery = function (query) {
        var _a, _b;
        if (this.props.initApi) {
            this.receive(query);
        }
        else {
            (_b = (_a = this.props).onQuery) === null || _b === void 0 ? void 0 : _b.call(_a, query);
        }
    };
    Form.prototype.handleDialogConfirm = function (values, action, ctx, targets) {
        var _a = this.props, store = _a.store, onChange = _a.onChange;
        if ((action.mergeData || store.action.mergeData) &&
            values.length === 1 &&
            values[0] &&
            targets[0].props.type === 'form') {
            this.handleBulkChange(values[0], false);
        }
        store.closeDialog(true);
    };
    Form.prototype.handleDialogClose = function (confirmed, formInstance, tableInstance) {
        if (confirmed === void 0) { confirmed = false; }
        var store = this.props.store;
        var _a = this.props, __ = _a.translate, env = _a.env;
        if (tableInstance) {
            var count = tableInstance.props.store.modified;
            if (count > 0) {
                antd_1.Modal.warning({
                    title: (react_1.default.createElement("div", null,
                        react_1.default.createElement("div", { style: { position: 'absolute', right: '10px', top: '10px', fontSize: '12px', cursor: "pointer" }, onClick: function () { antd_1.Modal.destroyAll(); } },
                            react_1.default.createElement(icons_1.Icon, { icon: "close", className: "icon" })))),
                    content: '当前表格存在已修改的数据,请先提交或放弃,再进行其他操作!',
                    getContainer: env.getModalContainer,
                    zIndex: 1020,
                    okText: __('confirm')
                });
                return;
            }
        }
        store.closeDialog(confirmed);
    };
    Form.prototype.handleDrawerConfirm = function (values, action, ctx, targets, saveStateOnClose) {
        var _a = this.props, store = _a.store, onChange = _a.onChange;
        if ((action.mergeData || store.action.mergeData) &&
            values.length === 1 &&
            values[0] &&
            targets[0].props.type === 'form') {
            store.updateData(values[0]);
            onChange &&
                onChange(store.data, (0, helper_1.difference)(store.data, store.pristine), this.props);
        }
        store.closeDrawer(true, saveStateOnClose);
    };
    Form.prototype.handleDrawerClose = function (saveStateOnClose) {
        var store = this.props.store;
        store.closeDrawer(false, saveStateOnClose);
    };
    Form.prototype.submitToTarget = function (target, values, withTarget) {
        // 会被覆写
    };
    Form.prototype.reloadTarget = function (target, data) {
        // 会被覆写
    };
    Form.prototype.closeTarget = function (target) {
        // 会被覆写
    };
    Form.prototype.openFeedback = function (dialog, ctx) {
        var _this = this;
        return new Promise(function (resolve) {
            var store = _this.props.store;
            store.setCurrentAction({
                type: 'button',
                actionType: 'dialog',
                dialog: dialog
            });
            store.openDialog(ctx, undefined, function (confirmed) {
                resolve(confirmed);
            });
        });
    };
    Form.prototype.buildActions = function () {
        var _a = this.props, actions = _a.actions, submitText = _a.submitText, body = _a.body, __ = _a.translate;
        if (typeof actions !== 'undefined' ||
            !submitText ||
            (Array.isArray(body) &&
                body.some(function (item) {
                    var _a, _b, _c;
                    return item &&
                        !!~['submit', 'button', 'button-group', 'reset',].indexOf(((_b = (_a = item === null || item === void 0 ? void 0 : item.body) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.type) ||
                            ((_c = item === null || item === void 0 ? void 0 : item.body) === null || _c === void 0 ? void 0 : _c.type) ||
                            item.type);
                }))) {
            return actions;
        }
        return [
            {
                type: 'submit',
                label: __(submitText),
                primary: true
            }
        ];
    };
    Form.prototype.handleChangeFields = function (autoFillObj) {
        var _this = this;
        if (autoFillObj === void 0) { autoFillObj = {}; }
        Object.keys(autoFillObj).forEach(function (item) {
            var _a;
            if (!((_a = _this.changeFields) === null || _a === void 0 ? void 0 : _a.includes(item))) {
                _this.changeFields = tslib_1.__spreadArray(tslib_1.__spreadArray([], _this.changeFields, true), [item], false);
            }
        });
    };
    Form.prototype.renderFormItems = function (schema, region, otherProps) {
        if (region === void 0) { region = ''; }
        if (otherProps === void 0) { otherProps = {}; }
        var body = Array.isArray(schema.body)
            ? schema.body
            : schema.body
                ? [schema.body]
                : [];
        // 旧用法,让 wrapper 走走 compat 逻辑兼容旧用法
        // 后续可以删除。
        if (!body.length && schema.controls) {
            console.warn('请用 body 代替 controls');
            body = [
                {
                    size: 'none',
                    type: 'wrapper',
                    wrap: false,
                    controls: schema.controls
                }
            ];
        }
        return this.renderChildren(body, region, otherProps);
    };
    Form.prototype.renderChildren = function (children, region, otherProps) {
        var _this = this;
        if (otherProps === void 0) { otherProps = {}; }
        children = children || [];
        if (!Array.isArray(children)) {
            children = [children];
        }
        if (this.props.mode === 'row') {
            var ns_1 = this.props.classPrefix;
            children = (0, flatten_1.default)(children).filter(function (item) {
                if ((item === null || item === void 0 ? void 0 : item.hidden) || (item === null || item === void 0 ? void 0 : item.visible) === false) {
                    return false;
                }
                var exprProps = (0, filter_schema_1.default)(item, _this.props.store.data, undefined, _this.props);
                if ((exprProps === null || exprProps === void 0 ? void 0 : exprProps.hidden) || (exprProps === null || exprProps === void 0 ? void 0 : exprProps.visible) === false) {
                    return false;
                }
                return true;
            });
            if (!children.length) {
                return null;
            }
            return (react_1.default.createElement("div", { className: "".concat(ns_1, "Form-row") }, children.map(function (control, key) {
                return ~['hidden', 'formula'].indexOf(control.type) ||
                    control.mode === 'inline' ? (_this.renderChild(control, key, otherProps)) : (react_1.default.createElement("div", { key: key, className: (0, classnames_1.default)("".concat(ns_1, "Form-col"), control.columnClassName) }, _this.renderChild(control, '', tslib_1.__assign(tslib_1.__assign({}, otherProps), { mode: 'row' }))));
            })));
        }
        return children.map(function (control, key) {
            return _this.renderChild(control, key, otherProps, region);
        });
    };
    Form.prototype.renderChild = function (control, key, otherProps, region) {
        var _a, _b;
        if (key === void 0) { key = ''; }
        if (otherProps === void 0) { otherProps = {}; }
        if (region === void 0) { region = ''; }
        var butColor = false;
        if (control.actionType === 'advanced-filter') {
            if (this.props.advancedFilter === undefined) {
                return;
            }
            var filt = this.props.filtercont;
            if (Object.keys(filt || {}).length && (((_a = filt === null || filt === void 0 ? void 0 : filt.advancedFilter) === null || _a === void 0 ? void 0 : _a.length) || ((_b = filt === null || filt === void 0 ? void 0 : filt.advancedFitlerSub) === null || _b === void 0 ? void 0 : _b.length) || Object.keys((filt === null || filt === void 0 ? void 0 : filt.advancedHeader) || {}).length)) {
                butColor = true;
            }
        }
        if (!control) {
            return null;
        }
        else if (typeof control === 'string') {
            control = {
                type: 'tpl',
                tpl: control
            };
        }
        var props = tslib_1.__assign(tslib_1.__assign({}, this.props), otherProps);
        var form = this.props.store;
        var render = props.render, mode = props.mode, horizontal = props.horizontal, store = props.store, disabled = props.disabled, controlWidth = props.controlWidth, resolveDefinitions = props.resolveDefinitions, lazyChange = props.lazyChange, preventEnterSubmit = props.preventEnterSubmit, formMobileHorizontal = props.formMobileHorizontal, isDetail = props.isDetail, flowProcess = props.flowProcess, initApi = props.initApi, notPrintFieldList = props.notPrintFieldList, maxFilterCount = props.maxFilterCount;
        var subProps = {
            formStore: form,
            data: store.data,
            key: "".concat(control.name || '', "-").concat(control.type, "-").concat(key),
            formInited: form.inited,
            formSubmited: form.submited,
            formMode: maxFilterCount ? (this.state.expanded ? 'grid' : 'inline') : mode,
            readOnlyItem: preventEnterSubmit,
            formHorizontal: horizontal,
            controlWidth: controlWidth,
            butColor: butColor,
            disabled: disabled || control.disabled || form.loading,
            btnDisabled: form.loading || form.validating,
            onAction: this.handleAction,
            onQuery: this.handleQuery,
            onChange: this.handleChange,
            handleChangeFields: this.handleChangeFields,
            // Jay
            // 下发给子组件(wrapControl)
            onInputTableChange: this.handleInputTableChange,
            abandonFormItem: this.abandonFormItem,
            setEdited: this.setEdited,
            setFormLoading: this.setFormLoading,
            store: store,
            onBulkChange: this.handleBulkChange,
            userChange: this.state.userChange,
            handleUserChange: this.handleUserChange,
            addHook: this.addHook,
            removeHook: this.removeHook,
            renderFormItems: this.renderFormItems,
            formPristine: form.pristine,
            _formName: this.props.name,
            inputfocus: this.state.inputfocus,
            handleInputFocus: this.handleInputFocus,
            handleJump: this.handleJump,
            isDetail: isDetail,
            flowProcess: flowProcess,
            isShowHide: !!initApi && isDetail && (0, helper_1.isMobile)(),
            isNumber: control.isNumber,
            notPrintFieldList: notPrintFieldList,
            inputFocusShowPicker: props.inputFocusShowPicker,
            inputBlurCheckValue: props.inputBlurCheckValue,
            validations: props.validations,
            // value: (control as any)?.name
            //   ? getVariable(form.data, (control as any)?.name, canAccessSuperData)
            //   : (control as any)?.value,
            // defaultValue: (control as any)?.value
        };
        var subSchema = tslib_1.__assign({}, control);
        if (subSchema.$ref) {
            subSchema = tslib_1.__assign(tslib_1.__assign({}, resolveDefinitions(subSchema.$ref)), subSchema);
        }
        lazyChange === false && (subSchema.changeImmediately = true);
        return render("".concat(region ? "".concat(region, "/") : '').concat(key), subSchema, subProps);
    };
    // Jay
    Form.prototype.changeCondition = function (val, index) {
        var filtersArr = this.state.filtersArr;
        filtersArr[index].condition = val === 0 ? 1 : 0;
        this.setState({ filtersArr: filtersArr });
    };
    Form.prototype.changeField = function (value, index) {
        var _a;
        var store = this.props.store;
        var filtersArr = this.state.filtersArr;
        var repeatList = filtersArr.filter(function (item) { return item.field.includes(value); });
        var repeatNum = 0;
        if (repeatList.length > 0) {
            var lastINdex = (_a = repeatList[repeatList.length - 1].field.split('--')) === null || _a === void 0 ? void 0 : _a[1];
            repeatNum = lastINdex ? Number(lastINdex) + 1 : 1;
        }
        var createName = repeatNum > 0 ? value + "--".concat(repeatNum) : value;
        filtersArr[index].field = createName;
        repeatNum > 0 && this.dealFilterOptions(value, createName);
        var filter = this.filterObj[value];
        if (filter.type === "switch") {
            store.changeValue(filter.name, filter.falseValue, false);
        }
    };
    Form.prototype.changeNot = function (value, index) {
        var filtersArr = this.state.filtersArr;
        filtersArr[index].not = value;
        this.setState({ filtersArr: filtersArr });
    };
    Form.prototype.changeRange = function (value, index) {
        var filtersArr = this.state.filtersArr;
        var store = this.props.store;
        if (filtersArr[index].op === RangeOptionsEnum.Between && value !== RangeOptionsEnum.Between) {
            store.changeValue(filtersArr[index].field, '', false);
        }
        filtersArr[index].op = value;
        this.setState({ filtersArr: filtersArr, emptyTimeSelected: false });
    };
    Form.prototype.filterPropsArr = function () {
        return this.filterOptions || [];
    };
    Form.prototype.addFilter = function () {
        var _a, _b;
        var _c = this.state, filtersArr = _c.filtersArr, cacheFilterParams = _c.cacheFilterParams;
        // 原始的条件数组
        var body = this.filterPropsArr();
        var originBody = body.filter(function (item) { return !item.value.includes('--'); });
        var params = !(cacheFilterParams === null || cacheFilterParams === void 0 ? void 0 : cacheFilterParams.length) ? originBody : cacheFilterParams;
        // 视图上最后一个高级查询字段
        var lastParam = (_a = filtersArr[filtersArr.length - 1]) === null || _a === void 0 ? void 0 : _a['field'];
        var nextParamIndex = params.findIndex(function (item) { return lastParam.split('--')[0] === item.value; }) + 1;
        // 当前最后一个条件在所有初始条件中的index 如果是最后一个条件,则从第一个开始
        var nextParam = originBody[nextParamIndex > originBody.length - 1 ? 0 : nextParamIndex];
        // 该条件已有的数量
        var repeatList = filtersArr.filter(function (item) { return item.field.split('--')[0] === nextParam.value; });
        var repeatNum = 0;
        if (repeatList.length > 0) {
            var lastINdex = repeatList[repeatList.length - 1].field.split('--')[1];
            repeatNum = lastINdex ? Number(lastINdex) + 1 : 1;
        }
        var createName = repeatNum > 0 ? nextParam.value + "--".concat(repeatNum) : nextParam.value;
        var InputDateRange = TagTypeEnum.InputDateRange, InputDatetimeRange = TagTypeEnum.InputDatetimeRange, InputMonthRange = TagTypeEnum.InputMonthRange, InputYearRange = TagTypeEnum.InputYearRange, InputQuarterRange = TagTypeEnum.InputQuarterRange, InputTimeRange = TagTypeEnum.InputTimeRange, InputDatetime = TagTypeEnum.InputDatetime, InputDate = TagTypeEnum.InputDate, InputMonth = TagTypeEnum.InputMonth;
        var dateTypes = [InputDateRange, InputDatetimeRange, InputMonthRange, InputYearRange, InputQuarterRange, InputTimeRange, InputDatetime, InputDate, InputMonth];
        var type = ((_b = originBody.find(function (item) { return createName.startsWith(item.value); })) !== null && _b !== void 0 ? _b : {}).type;
        // 2025-03 新增逻辑:添加日期类型的条件的时候,默认使用介于条件
        var op = dateTypes.includes(type) ? RangeOptionsEnum.Between : (type == TagTypeEnum.file ? RangeOptionsEnum.IsEmpty : RangeOptionsEnum.Equal);
        filtersArr.push({
            field: createName,
            condition: 1,
            not: false,
            op: op
        });
        if (repeatNum > 0) {
            var origin = this.filterObj[nextParam.value];
            this.filterObj[createName] = tslib_1.__assign(tslib_1.__assign({}, origin), { name: createName });
            if (!this.filterOptions.find(function (item) { return item.value === createName; })) {
                this.filterOptions.push({ label: (origin.groupName ? "".concat(origin.groupName, " \u00B7 ") : '') + (origin.label || origin.placeholder), value: createName, type: origin.type, isNumber: origin.isNumber || null });
            }
        }
        this.setState({ filtersArr: filtersArr });
        // 如果没有配置缓存的条件 则进行配置
        if (!(cacheFilterParams === null || cacheFilterParams === void 0 ? void 0 : cacheFilterParams.length)) {
            this.setState({ cacheFilterParams: (0, lodash_1.cloneDeep)(body) });
        }
        this.handleDispatchDragModalHeight();
    };
    Form.prototype.deleteFilter = function (index) {
        var filtersArr = this.state.filtersArr;
        // 只有一个的时候禁止删除
        if (filtersArr.length === 1)
            return;
        var prevField = filtersArr[index].field;
        filtersArr.splice(index, 1);
        this.setState({ filtersArr: filtersArr });
        this.props.store.changeValue(prevField, undefined);
        this.handleDispatchDragModalHeight(true);
    };
    Form.prototype.handleDispatchDragModalHeight = function (isDecrease) {
        if (isDecrease === void 0) { isDecrease = false; }
        document.body.dispatchEvent(new Event(isDecrease ? types_1.ResizeEvent.RESET_HEIGHT_FIT_CONTENT_ON_DECREASE : types_1.ResizeEvent.RESET_HEIGHT_FIT_CONTENT));
    };
    // saveEmptyValue 是否保存空值
    Form.prototype.confirmAdvancedFilter = function (saveEmptyValue) {
        var _a;
        var _this = this;
        if (saveEmptyValue === void 0) { saveEmptyValue = false; }
        var _b = this.state, filtersArr = _b.filtersArr, caseSensitive = _b.caseSensitive, topN = _b.topN, limitStatus = _b.limitStatus;
        var _c = this.props, name = _c.name, store = _c.store, handleSaveData = _c.handleSaveData;
        if (!name)
            return;
        var dataArr = [];
        //与高级查询一样,只是字段名不一样,后端需要做区分
        var advancedFilterSub = [];
        filtersArr.forEach(function (item) {
            var _a, _b, _c, _d, _e;
            var filterFields = (_b = ((0, lodash_1.isArray)(_this.props.body) ? _this.props.body.find(function (col) { return col.name === 'advancedFilter'; }) :
                (_a = _this.props.body) === null || _a === void 0 ? void 0 : _a['advancedFilter'])) === null || _b === void 0 ? void 0 : _b.body;
            var storeData = (item.field.includes('advancedFilterSub') ? store.data['advancedFilterSub'] : store.data[name]) || {};
            var itemName = item.field.split('.').pop();
            if (!itemName)
                return;
            if ((0, lodash_1.isNil)(_this.filterObj[item.field]) && !item.field.includes('--'))
                return;
            var temp = tslib_1.__assign(tslib_1.__assign({}, item), { field: itemName });
            if (item.op === RangeOptionsEnum.Between) {
                if (_this.filterObj[item.field].type === TagTypeEnum.InputNumber || ((_c = _this.filterObj[item.field]) === null || _c === void 0 ? void 0 : _c.isNumber)) {
                    var v1 = storeData["".concat(itemName, "-a8")];
                    var v2 = storeData["".concat(itemName, "-b8")];
                    if (((0, lodash_1.isNil)(v1) || (0, lodash_1.isNil)(v2)) && !saveEmptyValue)
                        return;
                    var values = [v1, v2].join(',');
                    temp.values = values === ',' ? '' : values;
                }
                else if (_this.filterObj[item.field].type === TagTypeEnum.InputDatetime || _this.filterObj[item.field].type === TagTypeEnum.InputDate) {
                    var values = storeData[itemName];
                    if (!values && values !== 0 && !saveEmptyValue)
                        return;
                    temp.values = values;
                }
                else
                    return;
            }
            else if (item.op !== RangeOptionsEnum.IsEmpty) {
                var values_1 = storeData[itemName];
                if (!values_1 && values_1 !== 0 && !saveEmptyValue)
                    return;
                if (typeof values_1 == 'string' && values_1.includes('[') && values_1.includes(']')) {
                    var list_1 = (_e = (_d = values_1.match(/\[(.*?)\]/g)) === null || _d === void 0 ? void 0 : _d.map(function (str) { var _a, _b; return (_b = (_a = filterFields.find(function (fcol) { return fcol.label === str.replace('[', '').replace(']', ''); })) === null || _a === void 0 ? void 0 : _a.name.split('.')) === null || _b === void 0 ? void 0 : _b[1]; })) !== null && _e !== void 0 ? _e : [];
                    temp.compareField = list_1;
                    var result = values_1.replace(/\[(.*?)\]/g, function (match) {
                        var _a;
                        var index = (_a = values_1.match(/\[([^\]]*)\]/g)) === null || _a === void 0 ? void 0 : _a.indexOf(match);
                        if (!index && index !== 0)
                            return '';
                        if (!isNaN(index) && index >= 0 && index < list_1.length) {
                            return "".concat(list_1[index]);
                        }
                        return match;
                    });
                    temp.values = "(".concat(result, ")");
                    temp.useFieldCompare = +(list_1 === null || list_1 === void 0 ? void 0 : list_1.length) > 0;
                }
                else {
                    if (temp.compareField) {
                        delete temp.compareField;
                    }
                    temp.values = values_1;
                }
            }
            else if (item.op === RangeOptionsEnum.IsEmpty) {
                if (temp.values != null) {
                    delete temp.values;
                }
            }
            // caseSensitive 区分大小写敏感 1区分 0不区分
            // 因为在需求中这个操作是单个按钮完成
            // 但是后端接口中这个字段实际上是每个字段都需要的字段
            // 故写成这样 需求原型http://172.28.40.72:7080/zentao/task-view-1027.html
            temp.caseSensitive = Number(caseSensitive);
            temp.field.includes('--') && (temp.field = temp.field.split('--')[0]);
            // 同步一下valuesAlia 防止展示与查询不同步的问题
            temp.valuesAlia = temp.value;
            // 配置分隔符,如果没有配置则默认为逗号
            var matchItem = filterFields.filter(function (item) { var _a, _b, _c; return ((_c = (_b = (_a = item.name).split) === null || _b === void 0 ? void 0 : _b.call(_a, 'advancedFilter.')) === null || _c === void 0 ? void 0 : _c[1]) === temp.field; }).filter(Boolean);
            temp.delimiter = matchItem.map(function (field) { var _a; return (_a = field.delimiter) !== null && _a !== void 0 ? _a : ','; }).filter(Boolean).join('') || ',';
            item.field.includes('advancedFilterSub') ? advancedFilterSub.push(temp) : dataArr.push(temp);
        });
        var dataHeader = {};
        this.filterNorma && this.filterNorma.forEach(function (item) {
            _this.circulation(item, dataHeader);
        });
        var data = (0, helper_1.isMobile)() ? store.data.filterParam : this.props.filterOptions.filterParam;
        store.items.forEach(function (item) {
            if (item.options.length > 0) {
                handleSaveData && handleSaveData(item.name, item.options);
            }
        });
        var query = (_a = {},
            _a[name] = dataArr,
            _a.advancedHeader = dataHeader,
            _a.filterParam = data,
            _a.advancedFilterSub = advancedFilterSub,
            _a.filterOptionData = this.filterOptionData,
            _a.limitParam = { topN: topN, limitStatus: limitStatus },
            _a);
        if (this.props.target)
            this.reloadTarget(this.props.target, query);
        return query;
    };
    Form.prototype.circulation = function (Current, data) {
        var _this = this;
        var _a;
        if (Current.body) {
            (_a = Current.body) === null || _a === void 0 ? void 0 : _a.map(function (item) {
                if (item === null || item === void 0 ? void 0 : item.body)
                    _this.circulation(item, data);
                else
                    _this.multiplexing(item, data);
            });
        }
        else
            this.multiplexing(Current, data);
    };
    // 复用
    Form.prototype.multiplexing = function (Current, data) {
        var _a, _b;
        var store = this.props.store;
        var itemName = (_a = Current === null || Current === void 0 ? void 0 : Current.name) === null || _a === void 0 ? void 0 : _a.split('.').pop();
        var header = (_b = store.data) === null || _b === void 0 ? void 0 : _b.advancedHeader;
        var empty = header === null || header === void 0 ? void 0 : header[itemName];
        if (!itemName && empty == undefined && empty == null)
            return;
        if (typeof empty == "number") {
            data[itemName] = empty;
        }
        else if (empty === null || empty === void 0 ? void 0 : empty.replace(/\s+/g, "").length) {
            data[itemName] = empty;
        }
    };
    Form.prototype.resetAdvancedFilter = function () {
        var _a, _b, _c, _d;
        var _e = this.props, store = _e.store, name = _e.name, filtercont = _e.filtercont;
        if (filtercont === null || filtercont === void 0 ? void 0 : filtercont.limitParam) {
            this.setState({
                topN: filtercont.limitParam.topN,
                limitStatus: filtercont.limitParam.limitStatus
            });
        }
        if (!((_a = this.filterOptions) === null || _a === void 0 ? void 0 : _a.length) && !((_b = this.filterNorma) === null || _b === void 0 ? void 0 : _b.length))
            return;
        if ((_c = this.filterOptions) === null || _c === void 0 ? void 0 : _c.length) {
            name && store.changeValue(name, undefined);
            var list = this.getDefaultFilterArrs();
            this.setState({
                filtersArr: list
            });
        }
        if ((_d = this.filterNorma) === null || _d === void 0 ? void 0 : _d.length) {
            store.changeValue("advancedHeader", undefined);
            this.setState({
                filtersHeader: this.filterNorma
            });
        }
    };
    Form.prototype.resetAdvancedOptionsFilter = function (optionsParam) {
        var _a, _b;
        if (optionsParam) {
            (_a = this.filterOptionRef.current) === null || _a === void 0 ? void 0 : _a.handleReset(optionsParam);
        }
        else {
            (_b = this.filterOptionRef.current) === null || _b === void 0 ? void 0 : _b.handleClear();
        }
    };
    Form.prototype.resetIsModleFilter = function (e) {
        var _this = this;
        var _a, _b, _c;
        var store = this.props.store;
        store.reset(undefined, false);
        // 如果自己本身没有 filterParam 参数 进行参数初始化 防止取到父级的 filterParam
        if ((((_a = store === null || store === void 0 ? void 0 : store.data) === null || _a === void 0 ? void 0 : _a.filterParam) || ((_c = (_b = store === null || store === void 0 ? void 0 : store.data) === null || _b === void 0 ? void 0 : _b['__prev']) === null || _c === void 0 ? void 0 : _c.filterParam)) && !store.data.hasOwnProperty('filterParam') && ['filterParam', 'advancedFilter'].some(function (item) { var _a; return (_a = _this.props.name) === null || _a === void 0 ? void 0 : _a.includes(item); }) || e) {
            store.changeValue('filterParam', {});
        }
        this.resetAdvancedFilter();
    };
    Form.prototype.handlerenew = function (arr, val, keyName) {
        var store = this.props.store;
        var _a = this.state, filtersArr = _a.filtersArr, filtersHeader = _a.filtersHeader;
        var list = this.getDefaultFilterArrs();
        if (arr) {
            filtersArr.forEach(function (item) { return store.changeValue(item.field, ""); });
            filtersHeader === null || filtersHeader === void 0 ? void 0 : filtersHeader.forEach(function (Item) {
                if (Item === null || Item === void 0 ? void 0 : Item.body) {
                    Item.body.forEach(function (item) { return store.changeValue(item.name, ""); });
                }
                else {
                    store.changeValue(Item.name, "");
                }
            });
            this.setState({ filtersArr: list });
        }
        else {
            if (val.includes('advancedFilter')) {
                var targetIndex = filtersArr.findIndex(function (item) { return item.field == (keyName || val); });
                if (filtersArr[targetIndex].dateLine) {
                    store.changeValue(keyName || val, undefined);
                    this.setState({ filtersArr: tslib_1.__spreadArray([], filtersArr, true) });
                }
                else {
                    this.deleteFilter(targetIndex);
                }
                if (filtersArr.length == 0) {
                    this.setState({ filtersArr: list });
                }
            }
            store.changeValue(keyName || val, "");
        }
    };
    Form.prototype.handleFiltersArr = function (body) {
        var _this = this;
        var _a;
        var _b = this.props, store = _b.store, FilterBody = _b.body, filtercont = _b.filtercont;
        // 根据查询条件去columns
        var columns = [];
        (_a = FilterBody === null || FilterBody === void 0 ? void 0 : FilterBody.find(function (item) { return item.name == 'advancedFilter'; })) === null || _a === void 0 ? void 0 : _a.body.map(function (column) { if (column.label)
            columns.push(tslib_1.__assign(tslib_1.__assign({}, column), { name: column.name.replace(/advancedFilter(Sub)?./, '') })); });
        if (filtercont === null || filtercont === void 0 ? void 0 : filtercont.limitParam) {
            this.setState({
                topN: filtercont.limitParam.topN,
                limitStatus: filtercont.limitParam.limitStatus
            });
        }
        if (Object.keys(body.advancedHeader).length) {
            var data = body.advancedHeader;
            for (var key in data) {
                store.changeValue(key, data[key], false);
            }
        }
        var CompareFiledsDeal = function (conditions) { return conditions.map(function (item) {
            var val = item;
            var values = item.values;
            var compareField = (0, lodash_1.cloneDeep)(item.compareField);
            if (values && typeof values == 'string' && values.includes('(') && values.includes(')') && columns && compareField) {
                var result_2 = values.substring(1, values.length - 1);
                compareField.forEach(function (item) {
                    var match = item;
                    var regex = new RegExp(match, 'g');
                    var content = columns.find(function (item) { return item.name == match; });
                    if (content) {
                        result_2 = result_2.replace(regex, "[".concat(content.label, "]"));
                    }
                });
                if (!!result_2) {
                    val.compareField = compareField;
                    val.values = result_2;
                    return val;
                }
            }
            return item;
        }); };
        var advancedFilterArr = CompareFiledsDeal(body.advancedFilter);
        // sub也做下处理
        var advancedFilterSubArr = CompareFiledsDeal(body.advancedFilterSub);
        var filter = tslib_1.__spreadArray(tslib_1.__spreadArray([], advancedFilterArr, true), advancedFilterSubArr, true);
        if (filter.length)
            store.changeValue('advancedFilter', "");
        filter.forEach(function (element) {
            if (element.field.includes('--')) {
                var originField = element.field.split('--')[0];
                _this.dealFilterOptions(originField, element.field);
            }
            store.changeValue(element.field, element === null || element === void 0 ? void 0 : element.values, false);
        });
        if (!filter.length) {
            store.changeValue('advancedFilter', "");
            var list = this.getDefaultFilterArrs();
            this.setState({
                filtersArr: list
            });
        }
        if (!Object.keys(body.advancedHeader).length) {
            store.changeValue("advancedHeader", {});
            this.setState({
                filtersHeader: this.filterNorma
            });
        }
        this.setState({ filtersArr: filter, caseSensitive: filter[0].caseSensitive == 0 ? false : true });
    };
    // 当前过滤条件是否展示输入的判断
    Form.prototype.isShowInputItem = function (item, type, isPc) {
        if (isPc === void 0) { isPc = false; }
        // 操作符不为空 并且 不是文件类型的渲染
        if (isPc) {
            return item.op !== RangeOptionsEnum.IsEmpty && type !== TagTypeEnum.file;
        }
        return item.op !== RangeOptionsEnum.IsEmpty && type !== TagTypeEnum.file && item.op !== RangeOptionsEnum.DataTag;
    };
    Form.prototype.getFiltersOptions = function () {
        var _this = this;
        var _a = this.props, body = _a.body, advancedQueryFields = _a.advancedQueryFields, handlePrefix = _a.handlePrefix, filtercont = _a.filtercont;
        var filters = Array.isArray(body) ? body : body
            ? [body] : [];
        var queryFields = advancedQueryFields && advancedQueryFields.split(",");
        var data = handlePrefix === null || handlePrefix === void 0 ? void 0 : handlePrefix(filtercont)['advancedHeader'];
        filters.forEach(function (item) {
            var _a, _b, _c;
            if ((_a = item.name) === null || _a === void 0 ? void 0 : _a.includes("advancedFilter")) {
                _this.filterOptions = (_b = (advancedQueryFields ? _this.getSameEle(item === null || item === void 0 ? void 0 : item.body, queryFields) : item === null || item === void 0 ? void 0 : item.body)) === null || _b === void 0 ? void 0 : _b.map(function (items) {
                    _this.filterObj[items.name] = items;
                    return { label: (items.groupName ? "".concat(items.groupName, " \u00B7 ") : '') + (items.label || items.placeholder), value: items.name, type: items.type, isNumber: items.isNumber || null };
                });
            }
            else if (item.name == "advancedHeader") {
                _this.filterNorma = (_c = item === null || item === void 0 ? void 0 : item.body) === null || _c === void 0 ? void 0 : _c.map(function (items) {
                    if (items === null || items === void 0 ? void 0 : items.body) {
                        return tslib_1.__assign(tslib_1.__assign({}, items), { body: _this.handlesetHeader(items.body, data), label: (items.groupName ? "".concat(items.groupName, " \u00B7 ") : '') + (items.label || items.placeholder), type: items.type, name: items.name });
                    }
                    return tslib_1.__assign(tslib_1.__assign({}, items), { label: (items.groupName ? "".concat(items.groupName, " \u00B7 ") : '') + (items.label || items.placeholder), type: items.type, name: items.name });
                });
            }
        });
    };
    Form.prototype.handlesetHeader = function (body, data) {
        var _this = this;
        return body.map(function (item) {
            var _a;
            if (item === null || item === void 0 ? void 0 : item.body) {
                _this.handlesetHeader(body, data);
            }
            return tslib_1.__assign(tslib_1.__assign({}, item), { value: (_a = data === null || data === void 0 ? void 0 : data[item.name]) !== null && _a !== void 0 ? _a : '' });
        });
    };
    // 范围生成
    Form.prototype.rangeGenerator = function (item) {
        var _a, _b, _c, _d, _e, _f, _g;
        // 2等于// 3大于// 4大于等于//5 小于// 6小于等于// 7介于// 8包含于// 9包含// 10为空// 11模糊
        var options = this.rangeOptios();
        var options1 = this.rangeOptios([RangeOptionsEnum.Equal, RangeOptionsEnum.Contain, RangeOptionsEnum.IsEmpty].concat(((_a = this.filterObj[item.field]) === null || _a === void 0 ? void 0 : _a.dataTag) ? RangeOptionsEnum.DataTag : []));
        var options2 = this.rangeOptios([RangeOptionsEnum.Between, RangeOptionsEnum.Equal, RangeOptionsEnum.GreaterThan, RangeOptionsEnum.GreaterThanOrEqual, RangeOptionsEnum.LessThan, RangeOptionsEnum.LessThanOrEqual, RangeOptionsEnum.IsEmpty].concat(((_b = this.filterObj[item.field]) === null || _b === void 0 ? void 0 : _b.dataTag) ? RangeOptionsEnum.DataTag : []));
        var options3 = this.rangeOptios([RangeOptionsEnum.Equal, RangeOptionsEnum.IsEmpty, RangeOptionsEnum.Fuzzy]);
        var options4 = this.rangeOptios([RangeOptionsEnum.Equal, RangeOptionsEnum.IsEmpty]);
        var options5 = this.rangeOptios([RangeOptionsEnum.IsEmpty]);
        // // 文件类型只有为空
        if ([TagTypeEnum.file].includes((_c = this.filterObj[item.field]) === null || _c === void 0 ? void 0 : _c.type)) {
            if ((0, helper_1.isMobile)()) {
                return options5;
            }
            return onlyEmptyRangeOptions;
        }
        // // 如果是数字类型
        // if (this.filterObj[item.field]?.isNumber) return rangeOptions1
        // // 如果是数字类型 或者 inputNumber类型并且不是 inputText类型的 都展示为 rangeOptions1
        // if ([TagTypeEnum.inputNumber].includes(this.filterObj[item.field].type) || this.filterObj[item.field].type !== TagTypeEnum.inputText) return rangeOptions1
        if ((_d = this.filterObj[item.field]) === null || _d === void 0 ? void 0 : _d.isNumber)
            return options2;
        if ([TagTypeEnum.InputText].includes((_e = this.filterObj[item.field]) === null || _e === void 0 ? void 0 : _e.type))
            return options1;
        if ([TagTypeEnum.InputDate, TagTypeEnum.InputMonth, TagTypeEnum.InputDatetime].includes((_f = this.filterObj[item.field]) === null || _f === void 0 ? void 0 : _f.type))
            return options2;
        if ([TagTypeEnum.Select, TagTypeEnum.TransferPicker].includes((_g = this.filterObj[item.field]) === null || _g === void 0 ? void 0 : _g.type))
            return options4;
        // 默认范围2
        return options3;
    };
    Form.prototype.rangeOptios = function (val) {
        if (val && val.length) {
            return rangeOptions.filter(function (item) {
                return val.some(function (items) {
                    return (0, helper_1.isMobile)() ? (item.value == items) :
                        (item.value == items && !(item === null || item === void 0 ? void 0 : item.not));
                });
            });
        }
        return rangeOptions;
    };
    // Jay 渲染高级查询
    Form.prototype.renderAdvancedFilter = function () {
        var _this = this;
        var _a = this.props, classnames = _a.classnames, env = _a.env, hideAdvancedFilter = _a.hideAdvancedFilter, filter = _a.filter, handleActionDisplay = _a.handleActionDisplay, advancedFilterVisible = _a.advancedFilterVisible, filtercont = _a.filtercont, showAdvancedOption = _a.showAdvancedOption, translate = _a.translate, queryStatus = _a.queryStatus;
        if (!advancedFilterVisible)
            return;
        var _b = this.state, filtersArr = _b.filtersArr, filtersHeader = _b.filtersHeader, caseSensitive = _b.caseSensitive, topN = _b.topN, limitStatus = _b.limitStatus;
        var options = this.filterPropsArr().map(function (item) { return (tslib_1.__assign(tslib_1.__assign({}, item), { value: item.value.split('--')[0] })); });
        var Modle = (0, helper_1.isMobile)();
        var selectList = [];
        options.forEach(function (item) {
            if (!selectList.some(function (i) { return i.value === item.value; })) {
                selectList.push(item);
            }
        });
        var dateList = this.getDateArr();
        var dateOptions = dateList.map(function (item) { return selectList.find(function (sel) { return sel.value === item.name; }); });
        if (dateOptions.length) {
            dateOptions.unshift({
                label: translate('Select.emptyItem'),
                value: 'advancedFilter.noneData'
            });
        }
        var downCont = selectList.filter(function (val) { return (val.type && ['input-number', 'input-text', 'input-date', 'input-datetime'].includes(val.type)) || val.isNumber; });
        return react_1.default.createElement(react_1.default.Fragment, null, Modle ? react_1.default.createElement(react_1.default.Fragment, null,
            react_1.default.createElement(AdvancedModlePopup_1.default, { env: env, filtersArr: filtersArr, filtersHeader: filtersHeader, filterOptions: this.filterOptions, filterObj: this.filterObj, hideAdvancedFilter: hideAdvancedFilter, filter: filter, notRange: notRange, caseSensitive: caseSensitive, onCheckbox: function () { _this.setState({ caseSensitive: !_this.state.caseSensitive }); }, rangeGenerator: this.rangeGenerator.bind(this), addFilter: this.addFilter.bind(this), handleChange: this.handleChange, handleOptionTransfer: this.handleOptionTransfer, renderChild: this.renderChild.bind(this), changeRange: this.changeRange.bind(this), changeField: this.changeField.bind(this), changeNot: this.changeNot.bind(this), deleteFilter: this.deleteFilter.bind(this), isShowInputItem: this.isShowInputItem.bind(this), handleActionDisplay: handleActionDisplay, filtercont: filtercont, showAdvancedOption: showAdvancedOption, topN: topN, limitStatus: limitStatus, changeTopN: function (num) { return _this.setState({ topN: num }); }, changeLimitStatus: function (check) { return _this.setState({ limitStatus: check }); }, selectEmptyTime: this.selectEmptyTime, emptyTimeSelected: this.state.emptyTimeSelected, translate: translate })) :
            react_1.default.createElement("div", { className: 'Modal-advanced-body' },
                filtersHeader && (filtersHeader === null || filtersHeader === void 0 ? void 0 : filtersHeader.length) !== 0 && react_1.default.createElement(react_1.default.Fragment, null,
                    react_1.default.createElement("div", { className: 'Modal-advanced-body-condition' },
                        react_1.default.createElement(row_1.default, { className: 'filter-row', gutter: 24, style: { margin: 0 } }, filtersHeader.map(function (item) {
                            return (
                            //
                            react_1.default.createElement(col_1.default, { style: { padding: 0 }, span: 12 }, _this.renderChild(item))
                            //
                            );
                        })))),
                Array.isArray(filtersArr) && filtersArr.length > 0 ? (react_1.default.createElement(divider_1.default, { orientation: "left", orientationMargin: 0, className: "fold-query-text" },
                    "\u6761\u4EF6\u67E5\u8BE2 ",
                    react_1.default.createElement(icons_2.DownOutlined, { rotate: this.state.unfoldParam ? 270 : 0, onClick: function () { return _this.setState({ unfoldParam: !_this.state.unfoldParam }); } }))) : null,
                !this.state.unfoldParam ? (react_1.default.createElement(react_1.default.Fragment, null,
                    filtersArr.map(function (item, index) {
                        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
                        if ((0, lodash_1.isNil)(_this.filterObj[item.field]) && !item.field.includes('--'))
                            return null;
                        //是否时间类型
                        var isTimeType = ['input-date', 'input-datetime', 'input-time'].includes((_a = _this.filterObj[item.field]) === null || _a === void 0 ? void 0 : _a.type);
                        return (react_1.default.createElement(row_1.default, { className: 'advanced-filter-row', gutter: 24, key: item.field + index },
                            react_1.default.createElement(col_1.default, { span: 1, style: { paddingRight: 0, } }, !item.dateLine ? react_1.default.createElement("div", { className: classnames('condition', {
                                    'or': item.condition === (dateList.length ? 1 : 0),
                                    'not': index === (dateList.length ? 1 : 0)
                                }), onClick: function () {
                                    if (index === (dateList.length ? 1 : 0))
                                        return;
                                    _this.changeCondition(item.condition, index);
                                } }, item.condition === 0 ? '或' : '且') : react_1.default.createElement("div", { style: { width: 20 } })),
                            react_1.default.createElement(col_1.default, { span: 5, className: 'advanced-filter-row-select', style: { paddingLeft: 0 } }, item.dateLine && _this.state.emptyTimeSelected ? react_1.default.createElement(antd_1.Select, { value: 'advancedFilter.noneData', options: dateOptions, showSearch: true, dropdownClassName: "dropdown-select-style", allowClear: false, filterOption: function (input, option) { var _a, _b; return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : '').includes(input.toLowerCase()) || ((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : '').toLowerCase().includes(input.toLowerCase()); }, getPopupContainer: env.getModalContainer, onChange: function (val) {
                                    _this.changeRange(_this.filterObj[val].type === TagTypeEnum.file ? RangeOptionsEnum.IsEmpty : [TagTypeEnum.InputDate, TagTypeEnum.InputMonth, TagTypeEnum.InputDatetime].includes(_this.filterObj[val].type) ? RangeOptionsEnum.Between : RangeOptionsEnum.Equal, index);
                                    _this.changeField(val, index);
                                }, suffixIcon: react_1.default.createElement(icons_1.Icon, { symbol: true, icon: '#icon-tooltool_down', className: "icon" }) }) : react_1.default.createElement(antd_1.Select, { value: (_b = _this.filterOptions.find(function (idx) { return idx.value == item.field; })) === null || _b === void 0 ? void 0 : _b.label, showSearch: true, dropdownClassName: "dropdown-select-style", allowClear: false, filterOption: function (input, option) { var _a, _b; return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : '').includes(input.toLowerCase()) || ((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : '').toLowerCase().includes(input.toLowerCase()); }, options: item.dateLine ? dateOptions : selectList, getPopupContainer: env.getModalContainer, onChange: function (val) {
                                    if (val === 'advancedFilter.noneData') {
                                        _this.selectEmptyTime(index);
                                    }
                                    else {
                                        _this.changeRange(_this.filterObj[val].type === TagTypeEnum.file ? RangeOptionsEnum.IsEmpty : [TagTypeEnum.InputDate, TagTypeEnum.InputMonth, TagTypeEnum.InputDatetime].includes(_this.filterObj[val].type) ? RangeOptionsEnum.Between : RangeOptionsEnum.Equal, index);
                                        _this.changeField(val, index);
                                    }
                                }, suffixIcon: react_1.default.createElement(icons_1.Icon, { symbol: true, icon: '#icon-tooltool_down', className: "icon" }) })),
                            react_1.default.createElement(col_1.default, { span: 1, className: 'condition-not', style: { padding: 0 } },
                                react_1.default.createElement(antd_1.Checkbox, { disabled: item.dateLine && _this.state.emptyTimeSelected, checked: item.not, onChange: function (e) { _this.changeNot(e.target.checked, index); } }, "\u4E0D")),
                            react_1.default.createElement(col_1.default, { span: 4, className: 'advanced-filter-row-select', style: { paddingLeft: 0 } },
                                react_1.default.createElement(antd_1.Select, { dropdownClassName: "dropdown-select-style", disabled: notRange.includes(_this.filterObj[item.field].type) ||
                                        (item.dateLine && _this.state.emptyTimeSelected), value: item.op, allowClear: false, getPopupContainer: env.getModalContainer, options: _this.rangeGenerator(item), onChange: function (val) {
                                        _this.changeRange(val, index);
                                    }, suffixIcon: react_1.default.createElement(icons_1.Icon, { symbol: true, icon: '#icon-tooltool_down', className: "icon" }) })),
                            _this.isShowInputItem(item, _this.filterObj[item.field].type, true) ? react_1.default.createElement(react_1.default.Fragment, null,
                                react_1.default.createElement(antd_1.Dropdown, { menu: {
                                        items: downCont.map(function (val, idx) { return ({
                                            key: idx, valKey: index, label: val.label, type: val.type, value: val,
                                            name: item.field, data: item, items: downCont
                                        }); }),
                                        onClick: _this.handleMenuClick
                                    }, trigger: ['contextMenu'], overlayStyle: { overflow: 'hidden' }, disabled: !(['input-number', 'input-text', 'input-date', 'input-datetime', 'input-time'].includes((_c = _this.filterObj[item.field]) === null || _c === void 0 ? void 0 : _c.type) || ((_d = _this.filterObj[item.field]) === null || _d === void 0 ? void 0 : _d.isNumber)) || item.op == 7, dropdownRender: function (menu) { return (react_1.default.createElement("div", { style: {
                                            backgroundColor: '#fff',
                                            boxShadow: 'rgba(0, 0, 0, 0.08) 0px 6px 16px 0px, rgba(0, 0, 0, 0.12) 0px 3px 6px -4px, rgba(0, 0, 0, 0.05) 0px 9px 28px 8px',
                                            maxHeight: 300, overflow: 'hidden', display: 'flex', flexDirection: 'column'
                                        } },
                                        react_1.default.createElement("div", { style: { flex: 1, overflow: 'auto' } }, react_1.default.cloneElement(menu, { style: { boxShadow: 'none' } })))); } },
                                    react_1.default.createElement(col_1.default, { span: 12, style: { paddingRight: 0, paddingLeft: 0 } }, item.op == RangeOptionsEnum.DataTag ?
                                        _this.renderChild(tslib_1.__assign(tslib_1.__assign({}, (_e = _this.filterObj[item.field]) === null || _e === void 0 ? void 0 : _e.dataTag), { name: item.field }), 'dataTag')
                                        : item.op === RangeOptionsEnum.Between && (_this.filterObj[item.field].type === TagTypeEnum.InputNumber || ((_f = _this.filterObj[item.field]) === null || _f === void 0 ? void 0 : _f.isNumber))
                                            ?
                                                react_1.default.createElement("div", { className: "double" },
                                                    _this.renderChild(tslib_1.__assign(tslib_1.__assign({}, _this.filterObj[item.field]), { name: _this.filterObj[item.field].name + '-a8', isMultipleValues: false, label: undefined }), 'a'),
                                                    react_1.default.createElement("span", { style: { margin: '0 4px' } }),
                                                    _this.renderChild(tslib_1.__assign(tslib_1.__assign({}, _this.filterObj[item.field]), { name: _this.filterObj[item.field].name + '-b8', isMultipleValues: false, label: undefined }), 'b'))
                                            :
                                                item.op !== RangeOptionsEnum.IsEmpty && item.op === RangeOptionsEnum.Between && (_this.filterObj[item.field].type === TagTypeEnum.InputDatetime || _this.filterObj[item.field].type === TagTypeEnum.InputDate || _this.filterObj[item.field].type === TagTypeEnum.InputMonth)
                                                    ?
                                                        _this.renderChild(tslib_1.__assign(tslib_1.__assign({}, _this.filterObj[item.field]), { ranges: (_g = _this.filterObj[item.field].ranges) !== null && _g !== void 0 ? _g : _this.filterObj[item.field].shortcuts, type: _this.filterObj[item.field].type + "-range", label: undefined }), undefined)
                                                    :
                                                        _this.renderChild(tslib_1.__assign(tslib_1.__assign({}, _this.filterObj[item.field]), { "validations": (function () {
                                                                var _a;
                                                                if ((_a = _this.filterObj[item.field]) === null || _a === void 0 ? void 0 : _a.isNumber)
                                                                    return {
                                                                        "isExprOrNumeric": true
                                                                    };
                                                                if (isTimeType)
                                                                    return {
                                                                        "isExprOrDate": true
                                                                    };
                                                                return null;
                                                            })(), value: ((_k = (_j = (_h = _this.filterObj) === null || _h === void 0 ? void 0 : _h[item.field]) === null || _j === void 0 ? void 0 : _j.value) === null || _k === void 0 ? void 0 : _k.includes(',')) && isTimeType ? _this.filterObj[item.field].value.split(',')[0] : _this.filterObj[item.field].value, label: undefined, isNumber: (_l = _this.filterObj[item.field]) === null || _l === void 0 ? void 0 : _l.isNumber, disabled: item.dateLine && _this.state.emptyTimeSelected }), undefined, { inputFocusShowPicker: false, inputBlurCheckValue: false }))))
                                : react_1.default.createElement(col_1.default, { span: 12 }),
                            !item.dateLine && react_1.default.createElement(col_1.default, { span: 1, className: 'del-icon' },
                                react_1.default.createElement(icons_1.Icon, { role: "delete", icon: "#icon-tooltool_minus-o", onClick: function () { _this.deleteFilter(index); } }))));
                    }),
                    react_1.default.createElement("div", { className: 'Modal-advanced-body-but' },
                        react_1.default.createElement(Button_1.default, { block: true, onClick: this.addFilter.bind(this) }, "\u65B0\u589E+")),
                    react_1.default.createElement(row_1.default, { className: 'Modal-advanced-body-caseSensitive' },
                        react_1.default.createElement(col_1.default, { span: 4 },
                            react_1.default.createElement("label", { onChange: function (e) { return _this.setState({ caseSensitive: !_this.state.caseSensitive }); }, style: { cursor: "pointer" } },
                                " ",
                                react_1.default.createElement(antd_1.Checkbox, { className: 'condition-case-sensitive', checked: this.state.caseSensitive }),
                                "\u00A0\u00A0\u533A\u5206\u5927\u5C0F\u5199")),
                        react_1.default.createElement(col_1.default, { span: 20, className: 'condition-topN-box' },
                            react_1.default.createElement("label", { onChange: function (e) {
                                    _this.setState({ limitStatus: !limitStatus }, function () {
                                        var _a;
                                        _this.state.limitStatus && ((_a = _this.limitInputRef.current) === null || _a === void 0 ? void 0 : _a.focus());
                                    });
                                }, style: { cursor: "pointer" } },
                                react_1.default.createElement(antd_1.Checkbox, { checked: limitStatus, className: 'condition-topN' }),
                                "\u4EC5\u67E5\u524D"),
                            react_1.default.createElement(antd_1.InputNumber, { ref: this.limitInputRef, size: 'small', min: 1, precision: 0, onChange: function (value) { return _this.setState({ topN: value || 0 }); }, style: { margin: '0 8px', width: '110px', fontSize: 12 }, value: topN }),
                            "\u9879")))) : null,
                this.props.showAdvancedOption && react_1.default.createElement(divider_1.default, { orientation: "left", orientationMargin: "0", className: 'fold-query-text' },
                    "\u9009\u9879\u67E5\u8BE2 ",
                    react_1.default.createElement(icons_2.DownOutlined, { rotate: this.state.unfoldQuery ? 270 : 0, onClick: function () { return _this.setState({ unfoldQuery: !_this.state.unfoldQuery }); } })),
                this.props.showAdvancedOption && this.handleOptionTransfer()));
    };
    Form.prototype.renderHeader = function () {
        var _this = this;
        var _a;
        var _b = this.props, showHeader = _b.showHeader, store = _b.store, cx = _b.classnames, body = _b.body, advancedFilters = _b.advancedFilters, globalFilters = _b.globalFilters, onAdvancedFilterRemove = _b.onAdvancedFilterRemove, onGlobalFilterChange = _b.onGlobalFilterChange, env = _b.env;
        var filters = (0, lodash_1.flatMap)(store.items, function (formItem) {
            var _a, _b;
            if (formItem.name == 'filterParam.caseSensitive')
                return [];
            if (formItem.value == undefined)
                return [];
            if (typeof formItem.value == 'string' && !formItem.value.length)
                return [];
            var options = (_a = formItem.options) !== null && _a !== void 0 ? _a : [];
            var label = formItem.labelName || formItem.name;
            var delimiter = formItem.delimiter;
            var tmpValue = String(formItem.value).split(delimiter);
            var value = (_b = tmpValue.map(function (key) { var _a, _b; return (_b = (_a = (0, helper_1.findTree)(options, (function (item) { return item.value == key; }))) === null || _a === void 0 ? void 0 : _a[formItem.labelField]) !== null && _b !== void 0 ? _b : key; })) === null || _b === void 0 ? void 0 : _b.join(delimiter);
            return { key: formItem.name, name: formItem.name, label: label, value: value };
        });
        return showHeader ? (react_1.default.createElement(CrudFilter_1.default, { filters: filters, onFilterRemove: function (name) { _this.handleChange(undefined, name, false, undefined, undefined); }, advancedFilters: advancedFilters, onAdvancedFilterRemove: onAdvancedFilterRemove, globalFilters: globalFilters, onGlobalFilterChange: onGlobalFilterChange, buttonGroup: Array.isArray(body) ? this.renderFormItems({ body: (_a = body.find(function (item) { return item.type == 'group'; })) === null || _a === void 0 ? void 0 : _a.body }) : undefined, cx: cx, env: env })) : null;
    };
    Form.prototype.renderBody = function () {
        var _this = this;
        var _a = this.props, body = _a.body, mode = _a.mode, className = _a.className, cx = _a.classnames, __ = _a.translate, debug = _a.debug, $path = _a.$path, store = _a.store, columnCount = _a.columnCount, render = _a.render, formatSize = _a.formatSize, inModal = _a.inModal, quickEditForm = _a.quickEditForm, initApi = _a.initApi, isDetail = _a.isDetail, flowProcess = _a.flowProcess, flowSpinning = _a.flowSpinning, maxFilterCount = _a.maxFilterCount, sortable = _a.sortable, crudName = _a.crudName;
        var expanded = this.state.expanded;
        var restError = store.restError;
        if (sortable && crudName && Array.isArray(body)) {
            var value = localStorage.getItem("filter_".concat(crudName));
            if (value) {
                var names_1 = JSON.parse(value);
                body.sort(function (a, b) {
                    var aIdx = names_1.findIndex(function (name) { return a.name == name; });
                    var bIdx = names_1.findIndex(function (name) { return b.name == name; });
                    if (aIdx == -1 || bIdx == -1)
                        return 0;
                    return aIdx - bIdx;
                });
            }
        }
        var WrapperComponent = this.props.wrapperComponent ||
            (/(?:\/|^)form\//.test($path) ? 'div' : 'form');
        var hasFieldSet = false;
        try {
            if ((0, lodash_1.isArray)(body)) {
                hasFieldSet = body.some(function (item) { return item.type === 'fieldSet'; });
            }
        }
        catch (_b) { }
        var warpNode = this.showBody ? (react_1.default.createElement(WrapperComponent, { className: cx("Form", "Form--".concat(maxFilterCount ? (expanded ? 'grid' : 'inline') : (mode || 'normal')), hasFieldSet ? 'hasFieldSet' : '', (inModal == true && (0, helper_1.isMobile)()) ? 'inModal' : '', columnCount ? "Form--column Form--column-".concat(columnCount) : null, formatSize ? "Form--format-".concat(formatSize) : null, className), onSubmit: this.handleFormSubmit, onKeyDown: function (e) {
                if (e.key == 'Enter') {
                    if (_this.props.advancedFilterVisible) {
                        setTimeout(function () {
                            var _a;
                            (_a = _this.props) === null || _a === void 0 ? void 0 : _a.handleAdvanceSearch();
                        }, 200);
                    }
                    else
                        _this.handleFormSubmit(e);
                }
            }, noValidate: true, ref: this.contentRef },
            this.showMoreBtn && !(0, helper_1.isMobile)() && (react_1.default.createElement("div", { className: cx('Form-moreBtn'), onClick: function (e) {
                    e.stopPropagation();
                    _this.setState({ expanded: !expanded }, function () {
                        var _a, _b;
                        document.body.dispatchEvent(new Event(types_1.ResizeEvent.DRAGCONTENTRESIZE));
                        if (!expanded) {
                            (_b = (_a = _this.contentRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.show-divider')) === null || _b === void 0 ? void 0 : _b.classList.remove('show-divider');
                        }
                    });
                } },
                react_1.default.createElement(icons_2.DownOutlined, { rotate: expanded ? 180 : 0 }),
                expanded ? __('Form.simpleCondition') : __('Form.moreCondition'))),
            debug ? (react_1.default.createElement("pre", null,
                react_1.default.createElement("code", null, JSON.stringify(store.data, null, 2)))) : null,
            !flowSpinning && react_1.default.createElement(Spinner_1.default, { show: store.loading || this.context.getComponents().filter(function (item) { return ['service', 'form'].includes(item.props.type); }).some(function (item) { return item.props.store.loading; }), overlay: true }),
            restError && restError.length ? (react_1.default.createElement("ul", { className: cx('Form-restError', 'Form-feedback') }, restError.map(function (item, idx) { return (react_1.default.createElement("li", { key: idx }, item)); }))) : null,
            this.props.advancedFilterVisible ? this.renderAdvancedFilter() : ((0, helper_1.isMobile)() ? this.renderAdvancedFilter() : null),
            !this.props.advancedFilterVisible && this.renderFormItems({ body: (this.showMoreBtn && !expanded) ? body.map(function (item, index) { return index + 1 > maxFilterCount ? tslib_1.__assign(tslib_1.__assign({}, item), { className: cx('Form-item--hidden') }) : item; }) : body }),
            (!quickEditForm && store.dialogOpen) ?
                render('modal', tslib_1.__assign(tslib_1.__assign({}, (store.action &&
                    store.action.dialog)), { type: 'dialog' }), {
                    key: 'dialog',
                    data: store.dialogData,
                    onConfirm: this.handleDialogConfirm,
                    onClose: this.handleDialogClose,
                    show: store.dialogOpen
                }) : null,
            (!quickEditForm && store.drawerOpen) ?
                render('modal', tslib_1.__assign(tslib_1.__assign({}, (store.action &&
                    store.action.drawer)), { type: 'drawer' }), {
                    key: 'drawer',
                    data: store.drawerData,
                    onConfirm: this.handleDrawerConfirm,
                    onClose: this.handleDrawerClose,
                    show: store.drawerOpen,
                    hide: store.drawerHidden
                }) : null)) : react_1.default.createElement(react_1.default.Fragment, null);
        return !!initApi && isDetail && !flowProcess && (0, helper_1.isMobile)() ? (react_1.default.createElement(ScrollMB_1.default, { scrollConfig: { pullDownRefresh: true, }, onPullingDown: this.pullDown }, warpNode)) : (react_1.default.createElement(react_1.default.Fragment, null,
            !(0, helper_1.isMobile)() && this.renderHeader(),
            warpNode));
    };
    Form.prototype.renderPrintModal = function () {
        var _this = this;
        if (!this.state.printVisible) {
            return null;
        }
        return (react_1.default.createElement(LabelPrint_1.ModalPrint, tslib_1.__assign({}, this.props, { show: this.state.printVisible, printType: 'detail', actionType: this.printActionData.actionType, printInfo: this.printActionData.printInfo, callbackApi: this.printActionData.callbackApi, type: 'lion-print', columns: [], defValEditApi: '', defValAddApi: '', defValDelApi: '', defValGetApi: '', labelDataApi: '', templateApi: '', ctx: { items: [], rows: [], selectedItems: [], unSelectedItems: [], ids: '', primaryField: undefined }, onHide: function () {
                var _a, _b;
                _this.setState({ printVisible: false });
                if (_this.props.hasFlowPrintAction) {
                    (_b = (_a = _this.props).onDialogClose) === null || _b === void 0 ? void 0 : _b.call(_a);
                }
            } })));
    };
    Form.prototype.renderFlowModal = function () {
        var _this = this;
        if (!this.state.flowModalVisible || this.flowDetail == undefined) {
            return null;
        }
        return react_1.default.createElement(Workflow_1.default, { visible: this.state.flowModalVisible, onClose: function (reload) { _this.flowDetail = undefined; _this.setState({ flowModalVisible: false }); }, env: this.props.env, render: this.props.render, onImageEnlarge: this.props.onImageEnlarge, language: (0, locale_1.makeTranslator)(), classnames: this.props.classnames, flowDetail: this.flowDetail });
    };
    Form.prototype.render = function () {
        var _a = this.props, $path = _a.$path, $schema = _a.$schema, wrapWithPanel = _a.wrapWithPanel, render = _a.render, title = _a.title, store = _a.store, panelClassName = _a.panelClassName, headerClassName = _a.headerClassName, footerClassName = _a.footerClassName, footerWrapClassName = _a.footerWrapClassName, actionsClassName = _a.actionsClassName, bodyClassName = _a.bodyClassName, cx = _a.classnames, affixFooter = _a.affixFooter, lazyLoad = _a.lazyLoad, __ = _a.translate, footer = _a.footer, isDialogMode = _a.isDialogMode, 
        // formStore,
        isDetail = _a.isDetail;
        var body = this.renderBody();
        if (wrapWithPanel) {
            body = render('body', {
                type: 'panel',
                title: __(title)
            }, {
                className: cx(panelClassName, 'Panel--form'),
                formStore: this.props.store,
                children: body,
                actions: this.buildActions(),
                onAction: this.handleAction,
                onQuery: this.handleQuery,
                disabled: store.loading,
                btnDisabled: store.loading || store.validating,
                headerClassName: headerClassName,
                footer: footer,
                footerClassName: footerClassName,
                footerWrapClassName: footerWrapClassName,
                actionsClassName: actionsClassName,
                bodyClassName: bodyClassName,
                affixFooter: affixFooter,
                isDialogMode: isDialogMode,
                wrapWithPanel: wrapWithPanel,
                btnMapdisable: this.state.disabled,
                isDetail: isDetail
            });
        }
        if (lazyLoad) {
            body = react_1.default.createElement(components_1.LazyComponent, null, body);
        }
        return react_1.default.createElement(react_1.default.Fragment, null,
            body,
            this.renderPrintModal(),
            this.renderFlowModal());
    };
    Form.defaultProps = {
        title: 'Form.title',
        submitText: 'Form.submit',
        initFetch: true,
        wrapWithPanel: true,
        mode: 'normal',
        collapsable: false,
        controlWidth: 'full',
        horizontal: {
            left: 2,
            right: 10,
            offset: 2
        },
        columnCount: 0,
        panelClassName: 'Panel--default',
        messages: {
            fetchFailed: 'fetchFailed',
            saveSuccess: 'saveSuccess',
            saveFailed: 'saveFailed'
        },
        wrapperComponent: '',
        finishedField: 'finished',
        initFinishedField: 'finished',
        flowProcess: false
    };
    Form.propsList = [
        'title',
        'header',
        'controls',
        'submitText',
        'initFetch',
        'wrapWithPanel',
        'mode',
        'columnCount',
        'collapsable',
        'horizontal',
        'panelClassName',
        'messages',
        'wrapperComponent',
        'resetAfterSubmit',
        'clearAfterSubmit',
        'submitOnInit',
        'submitOnChange',
        'onInit',
        'onReset',
        'onSubmit',
        'onChange',
        'onFailed',
        'onFinished',
        'onSaved',
        'canAccessSuperData',
        'lazyChange',
        'formLazyChange',
        'lazyLoad',
        'formInited',
        'simpleMode',
        'inputOnly',
        'value',
        'actions',
        'multiple'
    ];
    return Form;
}(react_1.default.Component));
exports.default = Form;
var FormRenderer = /** @class */ (function (_super) {
    tslib_1.__extends(FormRenderer, _super);
    function FormRenderer(props, context) {
        var _this = _super.call(this, props) || this;
        var scoped = context;
        scoped.registerComponent(_this);
        return _this;
    }
    FormRenderer.prototype.componentDidMount = function () {
        _super.prototype.componentDidMount.call(this);
        this.is_edit = false;
        if (this.props.autoFocus) {
            var scoped = this.context;
            var inputs = scoped.getComponents();
            var focuableInput_1 = (0, find_1.default)(inputs, function (input) { return input.focus; });
            focuableInput_1 && setTimeout(function () { return focuableInput_1.focus(); }, 200);
        }
    };
    FormRenderer.prototype.componentWillUnmount = function () {
        var scoped = this.context;
        this.is_edit = false;
        this.valueChanged = false;
        scoped.unRegisterComponent(this);
        _super.prototype.componentWillUnmount.call(this);
    };
    FormRenderer.prototype.doAction = function (action, data, throwErrors) {
        if (data === void 0) { data = this.props.store.data; }
        if (throwErrors === void 0) { throwErrors = false; }
        return this.handleAction(undefined, action, data, throwErrors);
    };
    FormRenderer.prototype.handleAction = function (e, action, ctx, throwErrors, delegate) {
        // 禁用了不要做任何动作。@先注释掉,会引起其他问题
        // if (this.props.disabled) {
        //   return;
        // }
        if (throwErrors === void 0) { throwErrors = false; }
        if (action.target && action.actionType !== 'reload') {
            var scoped_1 = this.context;
            return Promise.all(action.target.split(',').map(function (name) {
                var target = scoped_1.getComponentByName(name);
                return (target &&
                    target.doAction &&
                    target.doAction(tslib_1.__assign(tslib_1.__assign({}, action), { target: undefined }), ctx, throwErrors));
            }));
        }
        else {
            return _super.prototype.handleAction.call(this, e, action, ctx, throwErrors, delegate);
        }
    };
    FormRenderer.prototype.handleDialogConfirm = function (values, action, ctx, targets) {
        _super.prototype.handleDialogConfirm.call(this, values, action, ctx, targets);
        var store = this.props.store;
        var scoped = this.context;
        if (action.reload) {
            scoped.reload(action.reload, ctx);
        }
        else if (store.action && store.action.reload) {
            scoped.reload(store.action.reload, ctx);
        }
    };
    FormRenderer.prototype.submitToTarget = function (target, values, withTarget) {
        var scoped = this.context;
        scoped.send(target, values, undefined, withTarget);
    };
    FormRenderer.prototype.reloadTarget = function (target, data) {
        var scoped = this.context;
        scoped.reload(target, data);
    };
    FormRenderer.prototype.closeTarget = function (target) {
        var scoped = this.context;
        scoped.close(target);
    };
    FormRenderer.prototype.reload = function (target, query, ctx, silent) {
        var _a, _b;
        if (ctx === null) {
            return (_b = (_a = this.props.store) === null || _a === void 0 ? void 0 : _a.clear) === null || _b === void 0 ? void 0 : _b.call(_a);
        }
        if (query) {
            return this.receive(query);
        }
        // Jay
        if (!this.received) {
            this.received = false;
            var _c = this.props, initOneApi = _c.initOneApi, initFetch = _c.initFetch, initFetchOn = _c.initFetchOn, store_2 = _c.store, _d = _c.messages, fetchSuccess = _d.fetchSuccess, fetchFailed = _d.fetchFailed;
            if ((0, api_1.isEffectiveApi)(initOneApi, store_2.data, initFetch, initFetchOn)) {
                store_2
                    .fetchInitData(initOneApi, store_2.data, {
                    successMessage: fetchSuccess,
                    errorMessage: fetchFailed,
                    onSuccess: function () {
                        store_2 === null || store_2 === void 0 ? void 0 : store_2.setUpdateType('reload');
                    }
                })
                    .then(this.initInterval)
                    .then(this.onInit);
            }
        }
        var scoped = this.context;
        var subPath = '';
        var idx;
        var subQuery = null;
        if (target && ~(idx = target.indexOf('.'))) {
            subPath = target.substring(idx + 1);
            target = target.substring(0, idx);
        }
        var idx2 = target ? target.indexOf('?') : -1;
        if (~idx2) {
            subQuery = (0, tpl_builtin_1.dataMapping)((0, helper_1.qsparse)(target.substring(idx2 + 1)), ctx);
            target = target.substring(0, idx2);
        }
        var component;
        if (target &&
            (component = scoped.getComponentByName(target)) &&
            component.reload) {
            component.reload(subPath, subQuery, ctx);
        }
        else if (target === '*') {
            _super.prototype.reload.call(this, target, query, ctx, silent);
            var components = scoped.getComponents();
            components.forEach(function (component) {
                return component.reload && component.reload('', subQuery, ctx);
            });
        }
        else {
            _super.prototype.reload.call(this, target, query, ctx, silent);
        }
    };
    FormRenderer.prototype.receive = function (values, name) {
        if (name) {
            var scoped = this.context;
            var idx = name.indexOf('.');
            var subPath = '';
            if (~idx) {
                subPath = name.substring(1 + idx);
                name = name.substring(0, idx);
            }
            var component = scoped.getComponentByName(name);
            component && component.receive && component.receive(values, subPath);
            return;
        }
        return _super.prototype.receive.call(this, values);
    };
    var _a;
    FormRenderer.contextType = Scoped_1.ScopedContext;
    FormRenderer = tslib_1.__decorate([
        (0, factory_1.Renderer)({
            type: 'form',
            storeType: form_1.FormStore.name,
            isolateScope: true,
            shouldSyncSuperStore: function (store, props, prevProps) {
                var _a, _b;
                // 如果是 QuickEdit,让 store 同步 __super 数据。
                if (props.quickEditFormRef &&
                    props.onQuickChange &&
                    ((0, helper_1.isObjectShallowModified)(prevProps.data, props.data) ||
                        (0, helper_1.isObjectShallowModified)(prevProps.data.__super, props.data.__super) ||
                        (0, helper_1.isObjectShallowModified)((_a = prevProps.data.__super) === null || _a === void 0 ? void 0 : _a.__super, (_b = props.data.__super) === null || _b === void 0 ? void 0 : _b.__super))) {
                    return true;
                }
                return undefined;
            }
        }),
        tslib_1.__metadata("design:paramtypes", [Object, typeof (_a = typeof Scoped_1.IScopedContext !== "undefined" && Scoped_1.IScopedContext) === "function" ? _a : Object])
    ], FormRenderer);
    return FormRenderer;
}(Form));
exports.FormRenderer = FormRenderer;
//# sourceMappingURL=./renderers/Form/index.js.map