UNPKG

@angular-jz/jz

Version:

jim jz

90 lines 4.18 kB
"use strict"; 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_page_component_1 = require("./jz-page.component"); var utility_1 = require("../../utility"); var config_1 = require("../../config"); var JZListPageComponentConfig = /** @class */ (function (_super) { __extends(JZListPageComponentConfig, _super); function JZListPageComponentConfig() { return _super !== null && _super.apply(this, arguments) || this; } return JZListPageComponentConfig; }(jz_page_component_1.JZPageComponentConfig)); exports.JZListPageComponentConfig = JZListPageComponentConfig; var JZListPageComponent = /** @class */ (function (_super) { __extends(JZListPageComponent, _super); ///配置了分页查询功能 function JZListPageComponent(injector, config) { var _this = _super.call(this, injector, config) || this; _this.injector = injector; ///配置页面使用的服务pageService以及页面加载时是否自动调用loadPage方法来加载页面初始化数据 _this.config = new JZListPageComponentConfig(); ///列表项数据,通常数据通过loadPage从服务器端加载 _this.items = []; ///列表数据总数,用于分页 _this.totalCount = 0; _this.config = __assign({}, _this.config, config); _this.criteria = { keyword: null, page: { pageNo: 1, pageSize: config_1.SettingConfig.pageSize } }; return _this; } ///页面与服务器端访问数据进行初始化,设置了items和totalCount的值 JZListPageComponent.prototype.loadPage = function () { var _this = this; if (this.config.needLoadPage) { if (this.onBeforeLoadList) this.onBeforeLoadList.call(this); this.pageService.loadItemListPage(this.criteria).then(function (data) { utility_1.PageUtility.fillDics(data, _this.dics); _this.items = data.items.items; _this.totalCount = data.items.totalCount; if (_this.onAfterLoadPage) _this.onAfterLoadPage.call(_this, data); }); } }; JZListPageComponent.prototype.loadList = function () { var _this = this; this.pageService.searchList(this.criteria).then(function (data) { _this.items = data.items.items; _this.totalCount = data.items.totalCount; if (_this.onAfterLoadList) _this.onAfterLoadList.call(_this, data); }); }; ///加载列表数据后执行,需要子类重写 编辑删除 JZListPageComponent.prototype.onAfterLoadList = function (data) { }; JZListPageComponent.prototype.onBeforeLoadList = function () { }; ///查询列表时调用 JZListPageComponent.prototype.searchItems = function () { this.criteria.page.pageNo = 1; this.loadList(); }; ///切换分页时调用 JZListPageComponent.prototype.pageChange = function (pageNo) { if (pageNo != this.criteria.page.pageNo) { this.criteria.page.pageNo = pageNo; this.loadList(); } }; return JZListPageComponent; }(jz_page_component_1.JZPageComponent)); exports.JZListPageComponent = JZListPageComponent; //# sourceMappingURL=jz-list-page.component.js.map