@angular-jz/jz
Version:
jim jz
100 lines • 4.78 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var jz_list_page_component_1 = require("./jz-list-page.component");
var JZCrudPageComponentConfig = /** @class */ (function (_super) {
__extends(JZCrudPageComponentConfig, _super);
function JZCrudPageComponentConfig() {
return _super !== null && _super.apply(this, arguments) || this;
}
return JZCrudPageComponentConfig;
}(jz_list_page_component_1.JZListPageComponentConfig));
exports.JZCrudPageComponentConfig = JZCrudPageComponentConfig;
var JZCrudPageComponent = /** @class */ (function (_super) {
__extends(JZCrudPageComponent, _super);
function JZCrudPageComponent(injector, config) {
var _this = _super.call(this, injector, config) || this;
_this.injector = injector;
///配置页面使用的服务pageService以及页面加载时是否自动调用loadPage方法来加载页面初始化数据
_this.config = new JZCrudPageComponentConfig();
///删除列表项某条数据成功的回调函数
_this.deleteItemSucess = function (data) {
_this.operating = false;
_this.operationSucess(data);
_this.searchItems();
};
///删除列表项某条数据失败的回调函数
_this.deleteItemFailed = function (error) {
_this.operating = false;
_this.operationFailed(error);
};
_this.config = __assign({}, _this.config, config);
return _this;
}
///以弹出框的形式打开数据查看页
JZCrudPageComponent.prototype.showViewItem = function (item) {
var modalRef = this.modalService.open(this.config.viewItemPageComponent, { backdrop: 'static' });
modalRef.componentInstance.isDialog = true;
if (!modalRef.componentInstance.item)
modalRef.componentInstance.item = {};
if (item)
modalRef.componentInstance.item = __assign({}, item);
modalRef.componentInstance.dics = __assign({}, this.dics);
modalRef.result.then(function (result) { });
};
///以弹出框的形式打开数据创建页
JZCrudPageComponent.prototype.showCreateItem = function (item) {
var _this = this;
var modalRef = this.modalService.open(this.config.createItemPageComponent, { backdrop: 'static' });
modalRef.componentInstance.isDialog = true;
if (!modalRef.componentInstance.item)
modalRef.componentInstance.item = {};
if (item)
modalRef.componentInstance.item = __assign({}, item);
modalRef.componentInstance.dics = __assign({}, this.dics);
modalRef.result.then(function (result) {
if (result && result.success)
_this.searchItems();
});
};
///以弹出框的形式打开数据编辑页
JZCrudPageComponent.prototype.showEditItem = function (item) {
var _this = this;
var modalRef = this.modalService.open(this.config.editItemPageComponent, { backdrop: 'static' });
modalRef.componentInstance.isDialog = true;
if (!modalRef.componentInstance.item)
modalRef.componentInstance.item = {};
if (item)
modalRef.componentInstance.item = __assign({}, item);
modalRef.componentInstance.dics = __assign({}, this.dics);
modalRef.result.then(function (result) {
if (result && result.success)
_this.searchItems();
});
};
///删除列表项某条数据
JZCrudPageComponent.prototype.deleteItem = function (item) {
this.operating = true;
this.pageService.deleteItem({ item: item }).then(this.deleteItemSucess, this.deleteItemFailed);
};
return JZCrudPageComponent;
}(jz_list_page_component_1.JZListPageComponent));
exports.JZCrudPageComponent = JZCrudPageComponent;
//# sourceMappingURL=jz-crud-page.component.js.map