fastlion-amis
Version:
一种MIS页面生成工具
687 lines (686 loc) • 32.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DialogRenderer = void 0;
var tslib_1 = require("tslib");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var Scoped_1 = require("../Scoped");
var factory_1 = require("../factory");
var tpl_1 = require("../utils/tpl");
var Modal_1 = (0, tslib_1.__importDefault)(require("../components/Modal"));
var helper_1 = require("../utils/helper");
var mobx_1 = require("mobx");
var icons_1 = require("../components/icons");
var modal_1 = require("../store/modal");
var react_dom_1 = require("react-dom");
var components_1 = require("../components");
var mobx_state_tree_1 = require("mobx-state-tree");
var tpl_builtin_1 = require("../utils/tpl-builtin");
var Dialog = /** @class */ (function (_super) {
(0, tslib_1.__extends)(Dialog, _super);
function Dialog(props) {
var _a;
var _this = _super.call(this, props) || this;
_this.isDead = false;
_this.$$id = (0, helper_1.guid)();
_this.state = {
minWin: false
};
_this.handleSelfMin = function (e, confirmed) {
_this.setState({ minWin: true });
};
if (window['localDialgoData']) {
_this.topDialog = !window['localDialgoData'].hasUse && ((_a = window['localDialgoData'].scheme) === null || _a === void 0 ? void 0 : _a.type) === 'dialog';
// 保证只有第一个弹窗打开的才有这个属性并且能获取到
window['localDialgoData'].hasUse = true;
}
_this.state = {
minWin: false
};
if (_this.topDialog && _this.props.title) {
document.title = (0, tpl_1.filter)(_this.props.translate(_this.props.title), _this.props.data);
}
props.store.setEntered(!!props.show);
_this.handleSelfClose = _this.handleSelfClose.bind(_this);
_this.handleAction = _this.handleAction.bind(_this);
_this.handleDialogConfirm = _this.handleDialogConfirm.bind(_this);
_this.handleDialogClose = _this.handleDialogClose.bind(_this);
_this.handleDrawerConfirm = _this.handleDrawerConfirm.bind(_this);
_this.handleDrawerClose = _this.handleDrawerClose.bind(_this);
_this.handleEntered = _this.handleEntered.bind(_this);
_this.handleExited = _this.handleExited.bind(_this);
_this.handleFormInit = _this.handleFormInit.bind(_this);
_this.handleFormSaved = _this.handleFormSaved.bind(_this);
_this.handleFormChange = _this.handleFormChange.bind(_this);
_this.handleChildFinished = _this.handleChildFinished.bind(_this);
var store = props.store;
_this.reaction = (0, mobx_1.reaction)(function () { return "" + store.loading + store.error; }, function () { return _this.forceUpdate(); });
return _this;
}
// shouldComponentUpdate(nextProps:DialogProps, nextState:DialogState) {
// const props = this.props;
// if (this.state.entered !== nextState.entered) {
// return true;
// } else if (props.show === nextProps.show && !nextProps.show) {
// return false;
// }
// return isObjectShallowModified(this.props, nextProps);
// }
Dialog.prototype.componentWillUnmount = function () {
delete this.formInstance;
delete this.tableInstance;
delete this.formStoreInputData;
this.reaction && this.reaction();
this.isDead = true;
};
Dialog.prototype.buildActions = function () {
var _a = this.props, actions = _a.actions, confirm = _a.confirm, __ = _a.translate;
if (typeof actions !== 'undefined') {
return actions;
}
var ret = [];
ret.push({
type: 'button',
actionType: 'cancel',
label: __('cancel')
});
if (confirm) {
ret.push({
type: 'button',
actionType: 'confirm',
label: __('confirm'),
primary: true
});
}
return ret;
};
Dialog.prototype.handleSelfClose = function (e, confirmed) {
var _a = this.props, onClose = _a.onClose, store = _a.store;
var _formInstance = this.formInstance;
var _tableInstance = this.tableInstance;
delete this.formInstance;
delete this.tableInstance;
delete this.formStoreInputData;
// clear error
store.updateMessage();
if (onClose) {
onClose(confirmed, _formInstance, _tableInstance); // Jay
// 如果是顶层弹窗 关闭直接把页码关闭
}
else if (location.hash.includes('blank/dialogView') && this.topDialog) {
window.close();
}
};
Dialog.prototype.handleAction = function (e, action, data) {
var _a = this.props, store = _a.store, onAction = _a.onAction;
if (action.type === 'reset') {
store.reset();
}
else if (action.actionType === 'cancel') {
this.handleSelfClose();
}
else if (onAction) {
onAction(e, action, data);
}
};
Dialog.prototype.handleDialogConfirm = function (values, action) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
var store = this.props.store;
if (action.mergeData && values.length === 1 && values[0]) {
store.updateData(values[0]);
}
var dialog = store.action.dialog;
if (dialog &&
dialog.onConfirm &&
dialog.onConfirm.apply(dialog, (0, tslib_1.__spreadArray)([values, action], args, false)) === false) {
return;
}
store.closeDialog(true);
};
Dialog.prototype.handleDialogClose = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var store = this.props.store;
var action = store.action;
var dialog = action.dialog;
if (dialog.onClose && dialog.onClose.apply(dialog, args) === false) {
return;
}
store.closeDialog(args[1]);
};
Dialog.prototype.handleDrawerConfirm = function (values, action) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
var store = this.props.store;
if (action.mergeData && values.length === 1 && values[0]) {
store.updateData(values[0]);
}
var drawer = store.action.drawer;
if (drawer &&
drawer.onConfirm &&
drawer.onConfirm.apply(drawer, (0, tslib_1.__spreadArray)([values, action], args, false)) === false) {
return;
}
store.closeDrawer();
};
Dialog.prototype.handleDrawerClose = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var store = this.props.store;
var action = store.action;
var drawer = action.drawer;
if (drawer.onClose && drawer.onClose.apply(drawer, args) === false) {
return;
}
store.closeDrawer();
};
Dialog.prototype.handleEntered = function () {
var _a = this.props, lazySchema = _a.lazySchema, store = _a.store;
store.setEntered(true);
if (typeof lazySchema === 'function') {
store.setSchema(lazySchema(this.props));
}
var activeElem = document.activeElement;
if (activeElem) {
var dom = (0, react_dom_1.findDOMNode)(this);
dom && !dom.contains(activeElem) && activeElem.blur();
}
};
Dialog.prototype.handleExited = function () {
var _a = this.props, lazySchema = _a.lazySchema, store = _a.store;
if ((0, mobx_state_tree_1.isAlive)(store)) {
store.reset();
store.setEntered(false);
if (typeof lazySchema === 'function') {
store.setSchema('');
}
}
};
Dialog.prototype.handleFormInit = function (data) {
var store = this.props.store;
store.setFormData(data);
};
Dialog.prototype.handleFormChange = function (data, name) {
var _a;
var store = this.props.store;
// 如果 dialog 里面不放 form,而是直接放表单项就会进到这里来。
if (typeof name === 'string') {
data = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, store.formData), (_a = {}, _a[name] = data, _a));
}
if (this.formStoreInputData) {
data = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, data), this.formStoreInputData);
}
store.setFormData(data);
};
Dialog.prototype.handleFormSaved = function (data, response) {
var store = this.props.store;
store.setFormData((0, tslib_1.__assign)((0, tslib_1.__assign)({}, data), response));
};
Dialog.prototype.handleChildFinished = function (value, action) {
// 下面会覆盖
};
Dialog.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);
});
});
};
Dialog.prototype.getPopOverContainer = function () {
return (0, react_dom_1.findDOMNode)(this).querySelector("." + this.props.classPrefix + "Modal-content");
};
Dialog.prototype.renderBody = function (body, key) {
var _this = this;
var _a = this.props, render = _a.render, store = _a.store, actions = _a.actions, data = _a.data;
var dialogTitle = (0, tpl_builtin_1.tokenize)(typeof this.props.title == 'string' ? this.props.title : '', data);
if (Array.isArray(body)) {
return body.map(function (body, key) { return _this.renderBody(body, key); });
}
var subProps = {
key: key,
disabled: (body && body.disabled) || store.loading,
onAction: this.handleAction,
onFinished: this.handleChildFinished,
popOverContainer: this.getPopOverContainer,
affixOffsetTop: 0,
onChange: this.handleFormChange,
onInit: this.handleFormInit,
onSaved: this.handleFormSaved,
syncLocation: false,
// Jay 将dialog关闭方法下发
onDialogClose: this.props.onClose,
getFormInstance: function (form) {
if (!_this.formInstance)
_this.formInstance = form;
},
getTableInstance: function (store) { _this.tableInstance = store; },
getFormStore: function (data) {
_this.formStoreInputData = data;
},
onFormChange: (actions === null || actions === void 0 ? void 0 : actions.some(function (action) { return action.confirmApi != undefined; })) ? this.handleFormChange : undefined,
inModal: true,
dialogTitle: dialogTitle
};
if (!body.type) {
return render("body" + (key ? "/" + key : ''), body, subProps);
}
var schema = body;
if (schema.type === 'form') {
schema = (0, tslib_1.__assign)({ mode: 'horizontal', wrapWithPanel: false, submitText: null }, schema);
}
return render("body" + (key ? "/" + key : ''), schema, subProps);
};
Dialog.prototype.setLoading = function (loading) {
this.props.store.markFetching(loading);
};
Dialog.prototype.renderFooter = function () {
var _this = this;
var actions = this.buildActions();
if (!actions || !actions.length) {
return null;
}
var _a = this.props, store = _a.store, render = _a.render, cx = _a.classnames, showErrorMsg = _a.showErrorMsg, replace = _a.replace;
return (react_1.default.createElement("div", { className: cx('Modal-footer') },
(0, helper_1.isMobile)() && (store.loading || store.error) ? (react_1.default.createElement("div", { className: cx('Dialog-info'), key: "info" },
react_1.default.createElement(components_1.Spinner, { size: "sm", key: "info", show: store.loading }),
store.error && showErrorMsg !== false ? (react_1.default.createElement("span", { className: cx('Dialog-error') }, store.msg)) : null)) : null,
actions.map(function (action, key) {
var _a;
return render("action/" + key, action, {
replace: replace,
handleSendAction: (_a = _this.formInstance) === null || _a === void 0 ? void 0 : _a.handleSendAction,
data: store.formData,
onAction: _this.handleAction,
key: key,
disabled: action.disabled || store.loading,
setLoading: _this.setLoading.bind(_this)
});
})));
};
Dialog.prototype.render = function () {
var _a;
var store = this.props.store;
var _b = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, this.props), store.schema), className = _b.className, size = _b.size, closeOnEsc = _b.closeOnEsc, closeOnOutside = _b.closeOnOutside, title = _b.title, render = _b.render, header = _b.header, body = _b.body, bodyClassName = _b.bodyClassName, headerClassName = _b.headerClassName, show = _b.show, lazyRender = _b.lazyRender, lazySchema = _b.lazySchema, wrapperComponent = _b.wrapperComponent, showCloseButton = _b.showCloseButton, outContainer = _b.outContainer, env = _b.env, cx = _b.classnames, classPrefix = _b.classPrefix, __ = _b.translate, overlay = _b.overlay;
var Wrapper = wrapperComponent || Modal_1.default;
// {this.state.minWin ? <div onClick={() => this.setState({ minWin: false })} style={{ border: '1px solid', position: 'fixed', top: 0, right: 0 }}>{filter(this.props.translate(this.props.title), this.props.data)} <span>最大化</span></div> : null}
return (react_1.default.createElement(Wrapper, { fullScreen: this.topDialog, classPrefix: classPrefix, className: cx(className), size: size, backdrop: "static", onHide: this.handleSelfClose, keyboard: closeOnEsc && !store.loading, closeOnEsc: closeOnEsc, closeOnOutside: !store.dialogOpen && closeOnOutside, show: show, onEntered: this.handleEntered, onExited: this.handleExited, overlay: overlay,
// style={{
// display: this.state.minWin ? 'none' : '',
// }}
container: outContainer ?
outContainer === null || outContainer === void 0 ? void 0 : outContainer()
: (((_a = env === null || env === void 0 ? void 0 : env.getModalContainer) === null || _a === void 0 ? void 0 : _a.call(env)) || document.body), enforceFocus: false, disabled: store.loading },
react_1.default.createElement(components_1.Spinner, { overlay: true, show: store.loading }),
this.topDialog ? null :
react_1.default.createElement(react_1.default.Fragment, null, title && typeof title === 'string' ? (react_1.default.createElement("div", { className: cx('Modal-header', headerClassName) },
showCloseButton !== false && !store.loading ? (react_1.default.createElement("a", { "data-tooltip": __('Dialog.close'), "data-position": "left", onClick: this.handleSelfClose, className: cx('Modal-close') },
react_1.default.createElement(icons_1.Icon, { icon: "close", className: "icon" }))) : null,
react_1.default.createElement("div", { className: cx('Modal-title') }, (0, tpl_1.filter)(__(title), store.data, '| raw')))) : title ? (react_1.default.createElement("div", { className: cx('Modal-header', headerClassName) },
showCloseButton !== false && !store.loading ? (react_1.default.createElement("a", { "data-tooltip": __('Dialog.close'), onClick: this.handleSelfClose, className: cx('Modal-close') },
react_1.default.createElement(icons_1.Icon, { icon: "close", className: "icon" }))) : null,
render('title', title, {
data: store.formData
}))) : showCloseButton !== false && !store.loading ? (react_1.default.createElement("a", { "data-tooltip": __('Dialog.close'), onClick: this.handleSelfClose, className: cx('Modal-close') },
react_1.default.createElement(icons_1.Icon, { icon: "close", className: "icon" }))) : null),
header
? render('header', header, {
data: store.formData
})
: null,
(!store.entered && lazyRender) || (lazySchema && !body) ? (react_1.default.createElement("div", { className: cx('Modal-body', bodyClassName) },
react_1.default.createElement(components_1.Spinner, { overlay: true, show: true, size: "lg" }))) : body ? (react_1.default.createElement("div", { className: cx('Modal-body', bodyClassName) }, this.renderBody(body, 'body'))) : null,
this.renderFooter(),
(body && store.drawerOpen)
? render('drawer', (0, tslib_1.__assign)((0, tslib_1.__assign)({}, (store.action &&
store.action.drawer)), { type: 'drawer' }), {
key: 'drawer',
data: store.drawerData,
onConfirm: this.handleDrawerConfirm,
onClose: this.handleDrawerClose,
show: store.drawerOpen,
onAction: this.handleAction
})
: null,
(body && store.dialogOpen)
? render('dialog', (0, tslib_1.__assign)((0, tslib_1.__assign)({}, (store.action &&
store.action.dialog)), { type: 'dialog' }), {
key: 'dialog',
data: store.dialogData,
onConfirm: this.handleDialogConfirm,
onClose: this.handleDialogClose,
show: store.dialogOpen,
onAction: this.handleAction
})
: null));
};
Dialog.propsList = [
'title',
'size',
'closeOnEsc',
'closeOnOutside',
'children',
'bodyClassName',
'headerClassName',
'confirm',
'onClose',
'onConfirm',
'show',
'body',
'showCloseButton',
'showErrorMsg',
'actions',
'popOverContainer'
];
Dialog.defaultProps = {
title: '弹框',
bodyClassName: '',
confirm: true,
show: true,
lazyRender: false,
showCloseButton: true,
wrapperComponent: Modal_1.default,
closeOnEsc: false,
closeOnOutside: false,
showErrorMsg: true,
overlay: true,
};
(0, tslib_1.__decorate)([
helper_1.autobind,
(0, tslib_1.__metadata)("design:type", Function),
(0, tslib_1.__metadata)("design:paramtypes", []),
(0, tslib_1.__metadata)("design:returntype", void 0)
], Dialog.prototype, "getPopOverContainer", null);
return Dialog;
}(react_1.default.Component));
exports.default = Dialog;
var DialogRenderer = /** @class */ (function (_super) {
(0, tslib_1.__extends)(DialogRenderer, _super);
function DialogRenderer(props, context) {
var _this = _super.call(this, props) || this;
var scoped = context;
scoped.registerComponent(_this);
return _this;
}
DialogRenderer.prototype.componentWillUnmount = function () {
var scoped = this.context;
scoped.unRegisterComponent(this);
_super.prototype.componentWillUnmount.call(this);
};
DialogRenderer.prototype.tryChildrenToHandle = function (action, ctx, rawAction) {
var _this = this;
var scoped = this.context;
if (action.fromDialog) {
return false;
}
var targets = [];
var _a = this.props, onConfirm = _a.onConfirm, store = _a.store;
if (action.target) {
targets.push.apply(targets, action.target
.split(',')
.map(function (name) { return scoped.getComponentByName(name); })
.filter(function (item) { return item && item.doAction; }));
}
if (!targets.length) {
var components = scoped
.getComponents()
.filter(function (item) { return !~['drawer', 'dialog'].indexOf(item.props.type); });
var pool = components.concat();
while (pool.length) {
var item = pool.pop();
if (~['crud', 'form', 'wizard'].indexOf(item.props.type)) {
targets.push(item);
break;
}
else if (~['drawer', 'dialog'].indexOf(item.props.type)) {
continue;
}
else if (~['page', 'service'].indexOf(item.props.type)) {
pool.unshift.apply(pool, item.context.getComponents());
}
}
}
if (targets.length) {
store.markBusying(true);
store.updateMessage();
Promise.all(targets.map(function (target) {
return target.doAction((0, tslib_1.__assign)((0, tslib_1.__assign)({}, action), { from: _this.$$id }), ctx, true);
}))
.then(function (values) {
var _a;
if ((action.type === 'submit' ||
action.actionType === 'submit' ||
action.actionType === 'confirm') &&
action.close !== false) {
onConfirm && onConfirm(values, rawAction || action, ctx, targets);
}
else if (action.close) {
action.close === true
? action.actionType === 'form-print' ? undefined : _this.handleSelfClose()
: _this.closeTarget(action.close);
}
else if ((action.type === 'submit' ||
action.actionType === 'submit' ||
action.actionType === 'confirm') &&
action.close === false) {
var serviceSchema = _this.props.$schema.body;
if (serviceSchema.type === 'service') {
var targetComponent = serviceSchema.name && scoped.getComponentByName(serviceSchema.name);
(_a = targetComponent === null || targetComponent === void 0 ? void 0 : targetComponent.reload) === null || _a === void 0 ? void 0 : _a.call(targetComponent);
}
}
store.markBusying(false);
})
.catch(function (reason) {
if (_this.isDead) {
return;
}
store.updateMessage(reason.message, true);
store.markBusying(false);
});
return true;
}
return false;
};
DialogRenderer.prototype.handleAction = function (e, action, data, throwErrors, delegate, currentName, isItemAction) {
var _this = this;
if (throwErrors === void 0) { throwErrors = false; }
var _a = this.props, onAction = _a.onAction, store = _a.store, onConfirm = _a.onConfirm, env = _a.env;
if (action.from === this.$$id) {
return onAction
? onAction(e, action, data, throwErrors, delegate || this.context)
: false;
}
var scoped = this.context;
if (action.type === 'reset') {
store.setCurrentAction(action);
store.reset();
}
else if (action.actionType === 'close' ||
action.actionType === 'cancel') {
store.setCurrentAction(action);
this.handleSelfClose();
action.close && this.closeTarget(action.close);
}
else if (action.actionType === 'confirm') {
store.setCurrentAction(action);
this.tryChildrenToHandle((0, tslib_1.__assign)((0, tslib_1.__assign)({}, action), { actionType: 'submit' }), data, action) || this.handleSelfClose(undefined, true);
}
else if (action.actionType === 'next' || action.actionType === 'prev') {
store.setCurrentAction(action);
if (action.type === 'submit') {
this.tryChildrenToHandle((0, tslib_1.__assign)((0, tslib_1.__assign)({}, action), { actionType: 'submit', close: true }), data, action) || this.handleSelfClose(undefined, true);
}
else {
onConfirm([data], action, data, [], this.tableInstance);
}
}
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 === 'reload') {
store.setCurrentAction(action);
action.target && scoped.reload(action.target, data, currentName, isItemAction);
if (action.close || action.type === 'submit') {
this.handleSelfClose(undefined, action.type === 'submit');
this.closeTarget(action.close);
}
}
else if (this.tryChildrenToHandle(action, data)) {
// do nothing
}
else if (action.actionType === 'ajax') {
store.setCurrentAction(action);
store
.saveRemote(action.api, data, {
successMessage: action.messages && action.messages.success,
errorMessage: action.messages && action.messages.failed
})
.then(function () { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
var reidrect;
return (0, tslib_1.__generator)(this, function (_a) {
switch (_a.label) {
case 0:
if (!(action.feedback && (0, helper_1.isVisible)(action.feedback, store.data))) return [3 /*break*/, 2];
return [4 /*yield*/, this.openFeedback(action.feedback, store.data)];
case 1:
_a.sent();
_a.label = 2;
case 2:
reidrect = action.redirect && (0, tpl_1.filter)(action.redirect, store.data);
reidrect && env.jumpTo(reidrect, action);
action.reload && this.reloadTarget(action.reload, store.data);
if (action.close) {
this.handleSelfClose();
this.closeTarget(action.close);
}
return [2 /*return*/];
}
});
}); })
.catch(function () { });
}
else if (onAction) {
var ret = onAction(e, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, action), { close: false }), data, throwErrors, delegate || this.context);
action.close &&
(ret && ret.then
? ret.then(this.handleSelfClose)
: setTimeout(this.handleSelfClose, 200));
}
};
DialogRenderer.prototype.handleChildFinished = function (value, action) {
if ((action && action.from === this.$$id) || action.close === false) {
return;
}
var scoped = this.context;
var components = scoped
.getComponents()
.filter(function (item) { return !~['drawer', 'dialog'].indexOf(item.props.type); });
var onConfirm = this.props.onConfirm;
var onClose = this.props.onClose;
if (components.length === 1 &&
(components[0].props.type === 'form' ||
components[0].props.type === 'wizard') &&
(action.close === true ||
components[0].props.closeDialogOnSubmit !== false)) {
onConfirm && onConfirm([value], action, {}, components);
}
else if (action.close === true) {
onClose();
}
};
DialogRenderer.prototype.handleDialogConfirm = function (values, action) {
var _a;
var rest = [];
for (var _i = 2; _i < arguments.length; _i++) {
rest[_i - 2] = arguments[_i];
}
_super.prototype.handleDialogConfirm.apply(this, (0, tslib_1.__spreadArray)([values, action], rest, false));
var scoped = this.context;
var store = this.props.store;
var dialogAction = store.action;
var reload = (_a = action.reload) !== null && _a !== void 0 ? _a : dialogAction.reload;
if (reload) {
scoped.reload(reload, store.data);
}
else {
// 没有设置,则自动让页面中 crud 刷新。
scoped
.getComponents()
.filter(function (item) { return item.props.type === 'crud'; })
.forEach(function (item) { return item.reload && item.reload(); });
}
};
DialogRenderer.prototype.handleDrawerConfirm = function (values, action) {
var rest = [];
for (var _i = 2; _i < arguments.length; _i++) {
rest[_i - 2] = arguments[_i];
}
_super.prototype.handleDrawerConfirm.call(this, values, action);
var scoped = this.context;
var store = this.props.store;
var drawerAction = store.action;
// 稍等会,等动画结束。
setTimeout(function () {
if (drawerAction.reload) {
scoped.reload(drawerAction.reload, store.data);
}
else if (action.reload) {
scoped.reload(action.reload, store.data);
}
else {
// 没有设置,则自动让页面中 crud 刷新。
scoped
.getComponents()
.filter(function (item) { return item.props.type === 'crud'; })
.forEach(function (item) { return item.reload && item.reload(); });
}
}, 300);
};
DialogRenderer.prototype.reloadTarget = function (target, data) {
var scoped = this.context;
scoped.reload(target, data);
};
DialogRenderer.prototype.closeTarget = function (target) {
var scoped = this.context;
scoped.close(target);
};
var _a;
DialogRenderer.contextType = Scoped_1.ScopedContext;
DialogRenderer = (0, tslib_1.__decorate)([
(0, factory_1.Renderer)({
type: 'dialog',
storeType: modal_1.ModalStore.name,
storeExtendsData: false,
isolateScope: true,
shouldSyncSuperStore: function (store, props, prevProps) {
return !!((store.dialogOpen || props.show) &&
(props.show !== prevProps.show ||
(0, helper_1.isObjectShallowModified)(prevProps.data, props.data)));
}
}),
(0, tslib_1.__metadata)("design:paramtypes", [Object, typeof (_a = typeof Scoped_1.IScopedContext !== "undefined" && Scoped_1.IScopedContext) === "function" ? _a : Object])
], DialogRenderer);
return DialogRenderer;
}(Dialog));
exports.DialogRenderer = DialogRenderer;
//# sourceMappingURL=./renderers/Dialog.js.map