fastlion-amis
Version:
一种MIS页面生成工具
115 lines (114 loc) • 5.21 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.HeadCellBatchEditDropdown = void 0;
var tslib_1 = require("tslib");
//Aug input-table批量修改
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var Overlay_1 = (0, tslib_1.__importDefault)(require("../../components/Overlay"));
var react_dom_1 = require("react-dom");
var PopOver_1 = (0, tslib_1.__importDefault)(require("../../components/PopOver"));
var HeadCellBatchEditDropdown = /** @class */ (function (_super) {
(0, tslib_1.__extends)(HeadCellBatchEditDropdown, _super);
function HeadCellBatchEditDropdown(props) {
var _this = _super.call(this, props) || this;
_this.state = {
isOpened: false
};
_this.formItems = [];
_this.open = _this.open.bind(_this);
_this.close = _this.close.bind(_this);
_this.handleSubmit = _this.handleSubmit.bind(_this);
_this.handleAction = _this.handleAction.bind(_this);
return _this;
}
HeadCellBatchEditDropdown.prototype.buildSchema = function () {
var _a = this.props, batchEdit = _a.batchEdit, name = _a.name, label = _a.label, __ = _a.translate;
var schema;
if (batchEdit === true) {
schema = {
type: 'form',
title: '',
autoFocus: true,
body: [
{
type: 'input-text',
name: name,
placeholder: label,
label: false
}
]
};
}
else if (batchEdit) {
schema = {
title: '',
type: 'form',
autoFocus: true,
mode: 'normal',
body: [
(0, tslib_1.__assign)((0, tslib_1.__assign)({ type: batchEdit.type || 'input-text', name: batchEdit.name || name }, batchEdit), { mode: undefined })
]
};
}
if (schema) {
schema = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, schema), { wrapWithPanel: true, actions: [
{
type: 'button',
label: __('cancel'),
actionType: 'cancel'
},
{
label: __('confirm'),
type: 'submit',
primary: true
}
] });
}
return schema || 'error';
};
HeadCellBatchEditDropdown.prototype.handleClickOutside = function () {
this.close();
};
HeadCellBatchEditDropdown.prototype.open = function () {
this.setState({
isOpened: true
});
};
HeadCellBatchEditDropdown.prototype.close = function () {
this.setState({
isOpened: false
});
};
HeadCellBatchEditDropdown.prototype.handleAction = function (e, action, ctx) {
if (action.actionType === 'cancel' || action.actionType === 'close') {
this.close();
return;
}
};
HeadCellBatchEditDropdown.prototype.handleSubmit = function (values) {
var onBatchEdit = this.props.onBatchEdit;
this.close();
onBatchEdit(values);
};
HeadCellBatchEditDropdown.prototype.render = function () {
var _this = this;
var _a = this.props, render = _a.render, popOverContainer = _a.popOverContainer, ns = _a.classPrefix, cx = _a.classnames, canAccessSuperData = _a.canAccessSuperData;
return (react_1.default.createElement("span", { className: cx(ns + "TableCell-batchEditBtn") },
react_1.default.createElement("span", { onClick: this.open, style: { marginLeft: 5, fontSize: 13, color: '#3ea8ff', cursor: 'pointer' } }, "\u6279\u91CF"),
this.state.isOpened ? (react_1.default.createElement(Overlay_1.default, { container: function () { return (0, react_dom_1.findDOMNode)(_this); }, placement: "left-bottom-left-top right-bottom-right-top", target: function () { return (0, react_dom_1.findDOMNode)(_this).parentNode; }, show: true },
react_1.default.createElement(PopOver_1.default, { classPrefix: ns, onHide: this.close, className: cx(ns + "TableCell-batchEidtPopOver"), overlay: true }, render('inline-form', this.buildSchema(), {
value: undefined,
wrapperComponent: 'div',
className: cx('Form--batchEdit'),
simpleMode: true,
onChange: null,
onAction: this.handleAction,
onSubmit: this.handleSubmit,
formLazyChange: false,
canAccessSuperData: canAccessSuperData
})))) : null));
};
return HeadCellBatchEditDropdown;
}(react_1.default.Component));
exports.HeadCellBatchEditDropdown = HeadCellBatchEditDropdown;
//# sourceMappingURL=./renderers/FieldTableHorizontal/HeadCellBatchEditDropdown.js.map
;