@lxlib/seed
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
1,538 lines • 136 kB
JavaScript
/**
* @fileoverview added by tsickle
* Generated from: st.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import { __assign, __awaiter, __decorate, __generator, __metadata } from "tslib";
import { DecimalPipe, DOCUMENT } from '@angular/common';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, Inject, Input, Optional, Output, Renderer2, TemplateRef, ViewChild, ViewEncapsulation, } from '@angular/core';
import { Router } from '@angular/router';
import { LXLIB_I18N_TOKEN, CNCurrencyPipe, DatePipe, LxlibLocaleService, DrawerHelper, ModalHelper, YNPipe, } from '@lxlib/theme';
import { deepMerge, deepMergeKey, InputBoolean, InputNumber, toBoolean, updateHostClass } from '@lxlib/util';
import { NzTableComponent, NzTableStyleService } from 'ng-zorro-antd/table';
import { from, of, Subject } from 'rxjs';
import { filter, takeUntil } from 'rxjs/operators';
import { STColumnSource } from './st-column-source';
import { STDataSource } from './st-data-source';
import { STExport } from './st-export';
import { STRowSource } from './st-row.directive';
import { STConfig } from './st.config';
var STComponent = /** @class */ (function () {
function STComponent(i18nSrv, cdr, cog, router, el, renderer, exportSrv, modalHelper, drawerHelper, doc, columnSource, dataSource, lxlibI18n) {
var _this = this;
this.cdr = cdr;
this.cog = cog;
this.router = router;
this.el = el;
this.renderer = renderer;
this.exportSrv = exportSrv;
this.modalHelper = modalHelper;
this.drawerHelper = drawerHelper;
this.doc = doc;
this.columnSource = columnSource;
this.dataSource = dataSource;
this.lxlibI18n = lxlibI18n;
this.unsubscribe$ = new Subject();
this.totalTpl = "";
this.rowClickCount = 0;
this.locale = {};
this._data = [];
this._statistical = {};
this._isPagination = true;
this._allChecked = false;
this._allCheckedDisabled = false;
this._indeterminate = false;
this._columns = [];
this.columns = [];
this.ps = 10;
this.pi = 1;
this.total = 0;
this._loading = false;
/**
* 是否显示Loading
*/
this.loading = null;
/**
* 延迟显示加载效果的时间(防止闪烁)
*/
this.loadingDelay = 0;
/**
* 是否显示边框
*/
this.bordered = false;
/**
* 单排序规则
* - 若不指定,则返回:`columnName=ascend|descend`
* - 若指定,则返回:`sort=columnName.(ascend|descend)`
*/
this.singleSort = null;
this.expandRowByClick = false;
this.expandAccordion = false;
/**
* 行单击多少时长之类为双击(单位:毫秒),默认:`200`
*/
this.rowClickTime = 200;
this.responsive = true;
/**
* 请求异常时回调
*/
// tslint:disable-next-line:no-output-native
this.error = new EventEmitter();
/**
* 变化时回调,包括:`pi`、`ps`、`checkbox`、`radio`、`sort`、`filter`、`click`、`dblClick` 变动
*/
// tslint:disable-next-line:no-output-native
this.change = new EventEmitter();
this.virtualScroll = false;
this.virtualItemSize = 54;
this.virtualMaxBufferPx = 200;
this.virtualMinBufferPx = 100;
this.virtualForTrackBy = (/**
* @param {?} index
* @return {?}
*/
function (index) { return index; });
this.lxlibI18n.change.pipe(takeUntil(this.unsubscribe$)).subscribe((/**
* @return {?}
*/
function () {
_this.locale = _this.lxlibI18n.getData('st');
if (_this._columns.length > 0) {
_this.page = _this.clonePage;
_this.cd();
}
}));
this.copyCog = deepMergeKey(new STConfig(), true, cog);
delete this.copyCog.multiSort;
Object.assign(this, this.copyCog);
if (cog.multiSort && cog.multiSort.global !== false) {
this.multiSort = __assign({}, cog.multiSort);
}
i18nSrv.change
.pipe(takeUntil(this.unsubscribe$), filter((/**
* @return {?}
*/
function () { return _this._columns.length > 0; })))
.subscribe((/**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
function () { return _this.refreshColumns(); }));
}
Object.defineProperty(STComponent.prototype, "req", {
/** 请求体配置 */
get: /**
* 请求体配置
* @return {?}
*/
function () {
return this._req;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._req = deepMerge({}, this._req, this.cog.req, value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(STComponent.prototype, "res", {
/** 返回体配置 */
get: /**
* 返回体配置
* @return {?}
*/
function () {
return this._res;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
/** @type {?} */
var item = deepMergeKey({}, true, this.cog.res, value);
/** @type {?} */
var reName = item.reName;
if (!Array.isArray(reName.list))
reName.list = reName.list.split('.');
if (!Array.isArray(reName.total))
reName.total = reName.total.split('.');
this._res = item;
},
enumerable: true,
configurable: true
});
Object.defineProperty(STComponent.prototype, "page", {
/** 分页器配置 */
get: /**
* 分页器配置
* @return {?}
*/
function () {
return this._page;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this.clonePage = value;
/** @type {?} */
var item = deepMergeKey({}, true, new STConfig().page, this.cog.page, value);
var total = item.total;
if (typeof total === 'string' && total.length) {
this.totalTpl = total;
}
else if (toBoolean(total)) {
this.totalTpl = this.locale.total;
}
else {
this.totalTpl = '';
}
this._page = item;
},
enumerable: true,
configurable: true
});
Object.defineProperty(STComponent.prototype, "multiSort", {
/** 是否多排序,当 `sort` 多个相同值时自动合并,建议后端支持时使用 */
get: /**
* 是否多排序,当 `sort` 多个相同值时自动合并,建议后端支持时使用
* @return {?}
*/
function () {
return this._multiSort;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
if (typeof value === 'boolean' && !toBoolean(value)) {
this._multiSort = null;
return;
}
this._multiSort = __assign({}, (typeof value === 'object' ? value : {}));
},
enumerable: true,
configurable: true
});
Object.defineProperty(STComponent.prototype, "widthMode", {
get: /**
* @return {?}
*/
function () {
return this._widthMode;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._widthMode = __assign({ type: 'default', strictBehavior: 'truncate' }, value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(STComponent.prototype, "routerState", {
get: /**
* @private
* @return {?}
*/
function () {
var _a = this, pi = _a.pi, ps = _a.ps, total = _a.total;
return { pi: pi, ps: ps, total: total };
},
enumerable: true,
configurable: true
});
Object.defineProperty(STComponent.prototype, "count", {
/**
* Get the number of the current page
*/
get: /**
* Get the number of the current page
* @return {?}
*/
function () {
return this._data.length;
},
enumerable: true,
configurable: true
});
Object.defineProperty(STComponent.prototype, "list", {
/**
* Get the data of the current page
*/
get: /**
* Get the data of the current page
* @return {?}
*/
function () {
return this._data;
},
enumerable: true,
configurable: true
});
/**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
STComponent.prototype.cd = /**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
function () {
(/** @type {?} */ (this)).cdr.detectChanges();
return (/** @type {?} */ (this));
};
/**
* @param {?} total
* @param {?} range
* @return {?}
*/
STComponent.prototype.renderTotal = /**
* @param {?} total
* @param {?} range
* @return {?}
*/
function (total, range) {
return this.totalTpl
? this.totalTpl.replace('{{total}}', total).replace('{{range[0]}}', range[0]).replace('{{range[1]}}', range[1])
: '';
};
/**
* @param {?} column
* @return {?}
*/
STComponent.prototype.isTruncate = /**
* @param {?} column
* @return {?}
*/
function (column) {
return !!column.width && this.widthMode.strictBehavior === 'truncate' && column.type !== 'img';
};
/**
* @param {?} column
* @return {?}
*/
STComponent.prototype.columnClass = /**
* @param {?} column
* @return {?}
*/
function (column) {
return column.className || (this.isTruncate(column) ? 'text-truncate' : null);
};
/**
* @private
* @param {?} type
* @param {?=} data
* @return {?}
*/
STComponent.prototype.changeEmit = /**
* @private
* @param {?} type
* @param {?=} data
* @return {?}
*/
function (type, data) {
/** @type {?} */
var res = {
type: type,
pi: this.pi,
ps: this.ps,
total: this.total,
};
if (data != null) {
res[type] = data;
}
this.change.emit(res);
};
Object.defineProperty(STComponent.prototype, "filteredData", {
// #region data
/**
* 获取过滤后所有数据
* - 本地数据:包含排序、过滤后不分页数据
* - 远程数据:不传递 `pi`、`ps` 两个参数
*/
get:
// #region data
/**
* 获取过滤后所有数据
* - 本地数据:包含排序、过滤后不分页数据
* - 远程数据:不传递 `pi`、`ps` 两个参数
* @return {?}
*/
function () {
return this.loadData((/** @type {?} */ ({ paginator: false }))).then((/**
* @param {?} res
* @return {?}
*/
function (res) { return res.list; }));
},
enumerable: true,
configurable: true
});
/**
* @private
* @param {?} val
* @return {?}
*/
STComponent.prototype.setLoading = /**
* @private
* @param {?} val
* @return {?}
*/
function (val) {
if (this.loading == null) {
this._loading = val;
}
};
/**
* @private
* @param {?=} options
* @return {?}
*/
STComponent.prototype.loadData = /**
* @private
* @param {?=} options
* @return {?}
*/
function (options) {
var _this = this;
var _a = this, pi = _a.pi, ps = _a.ps, data = _a.data, req = _a.req, res = _a.res, page = _a.page, total = _a.total, singleSort = _a.singleSort, multiSort = _a.multiSort, rowClassName = _a.rowClassName;
return new Promise((/**
* @param {?} resolvePromise
* @param {?} rejectPromise
* @return {?}
*/
function (resolvePromise, rejectPromise) {
if (_this.data$) {
_this.data$.unsubscribe();
}
_this.data$ = _this.dataSource
.process(__assign({ pi: pi,
ps: ps,
total: total,
data: data,
req: req,
res: res,
page: page, columns: _this._columns, singleSort: singleSort,
multiSort: multiSort,
rowClassName: rowClassName, paginator: true }, options))
.pipe(takeUntil(_this.unsubscribe$))
.subscribe((/**
* @param {?} result
* @return {?}
*/
function (result) { return resolvePromise(result); }), (/**
* @param {?} error
* @return {?}
*/
function (error) { return rejectPromise(error); }));
}));
};
/**
* @private
* @return {?}
*/
STComponent.prototype.loadPageData = /**
* @private
* @return {?}
*/
function () {
return __awaiter(this, void 0, void 0, function () {
var result, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.setLoading(true);
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.loadData()];
case 2:
result = _a.sent();
this.setLoading(false);
if (typeof result.pi !== 'undefined') {
this.pi = result.pi;
}
if (typeof result.ps !== 'undefined') {
this.ps = result.ps;
}
if (typeof result.total !== 'undefined') {
this.total = result.total;
}
if (typeof result.pageShow !== 'undefined') {
this._isPagination = result.pageShow;
}
this._data = (/** @type {?} */ (result.list));
this._statistical = (/** @type {?} */ (result.statistical));
this.changeEmit('loaded', result.list);
return [2 /*return*/, this._refCheck()];
case 3:
error_1 = _a.sent();
this.setLoading(false);
if (!this.unsubscribe$.isStopped) {
this.cdr.detectChanges();
this.error.emit({ type: 'req', error: error_1 });
}
return [2 /*return*/, this];
case 4: return [2 /*return*/];
}
});
});
};
/** 清空所有数据 */
/**
* 清空所有数据
* @template THIS
* @this {THIS}
* @param {?=} cleanStatus
* @return {THIS}
*/
STComponent.prototype.clear = /**
* 清空所有数据
* @template THIS
* @this {THIS}
* @param {?=} cleanStatus
* @return {THIS}
*/
function (cleanStatus) {
if (cleanStatus === void 0) { cleanStatus = true; }
if (cleanStatus) {
(/** @type {?} */ (this)).clearStatus();
}
(/** @type {?} */ (this))._data = [];
return (/** @type {?} */ (this)).cd();
};
/** 清空所有状态 */
/**
* 清空所有状态
* @template THIS
* @this {THIS}
* @return {THIS}
*/
STComponent.prototype.clearStatus = /**
* 清空所有状态
* @template THIS
* @this {THIS}
* @return {THIS}
*/
function () {
return (/** @type {?} */ (this)).clearCheck().clearRadio().clearFilter().clearSort();
};
/**
* 根据页码重新加载数据
*
* @param pi 指定当前页码,默认:`1`
* @param extraParams 重新指定 `extraParams` 值
* @param options 选项
*/
/**
* 根据页码重新加载数据
*
* @template THIS
* @this {THIS}
* @param {?=} pi 指定当前页码,默认:`1`
* @param {?=} extraParams 重新指定 `extraParams` 值
* @param {?=} options 选项
* @return {THIS}
*/
STComponent.prototype.load = /**
* 根据页码重新加载数据
*
* @template THIS
* @this {THIS}
* @param {?=} pi 指定当前页码,默认:`1`
* @param {?=} extraParams 重新指定 `extraParams` 值
* @param {?=} options 选项
* @return {THIS}
*/
function (pi, extraParams, options) {
if (pi === void 0) { pi = 1; }
if (pi !== -1)
(/** @type {?} */ (this)).pi = pi;
if (typeof extraParams !== 'undefined') {
(/** @type {?} */ (this))._req.params = options && options.merge ? __assign(__assign({}, (/** @type {?} */ (this))._req.params), extraParams) : extraParams;
}
(/** @type {?} */ (this))._change('pi', options);
return (/** @type {?} */ (this));
};
/**
* 重新刷新当前页
* @param extraParams 重新指定 `extraParams` 值
*/
/**
* 重新刷新当前页
* @template THIS
* @this {THIS}
* @param {?=} extraParams 重新指定 `extraParams` 值
* @param {?=} options
* @return {THIS}
*/
STComponent.prototype.reload = /**
* 重新刷新当前页
* @template THIS
* @this {THIS}
* @param {?=} extraParams 重新指定 `extraParams` 值
* @param {?=} options
* @return {THIS}
*/
function (extraParams, options) {
return (/** @type {?} */ (this)).load(-1, extraParams, options);
};
/**
* 重置且重新设置 `pi` 为 `1`,包含以下值:
* - `check` 数据
* - `radio` 数据
* - `sort` 数据
* - `fileter` 数据
*
* @param extraParams 重新指定 `extraParams` 值
*/
/**
* 重置且重新设置 `pi` 为 `1`,包含以下值:
* - `check` 数据
* - `radio` 数据
* - `sort` 数据
* - `fileter` 数据
*
* @template THIS
* @this {THIS}
* @param {?=} extraParams 重新指定 `extraParams` 值
* @param {?=} options
* @return {THIS}
*/
STComponent.prototype.reset = /**
* 重置且重新设置 `pi` 为 `1`,包含以下值:
* - `check` 数据
* - `radio` 数据
* - `sort` 数据
* - `fileter` 数据
*
* @template THIS
* @this {THIS}
* @param {?=} extraParams 重新指定 `extraParams` 值
* @param {?=} options
* @return {THIS}
*/
function (extraParams, options) {
(/** @type {?} */ (this)).clearStatus().load(1, extraParams, options);
return (/** @type {?} */ (this));
};
/**
* @private
* @param {?=} enforce
* @return {?}
*/
STComponent.prototype._toTop = /**
* @private
* @param {?=} enforce
* @return {?}
*/
function (enforce) {
if (!(enforce == null ? this.page.toTop : enforce))
return;
/** @type {?} */
var el = (/** @type {?} */ (this.el.nativeElement));
if (this.scroll) {
(/** @type {?} */ (el.querySelector('.ant-table-body'))).scrollTo(0, 0);
return;
}
el.scrollIntoView();
// fix header height
this.doc.documentElement.scrollTop -= (/** @type {?} */ (this.page.toTopOffset));
};
/**
* @param {?} type
* @param {?=} options
* @return {?}
*/
STComponent.prototype._change = /**
* @param {?} type
* @param {?=} options
* @return {?}
*/
function (type, options) {
var _this = this;
if (type === 'pi' || (type === 'ps' && this.pi <= Math.ceil(this.total / this.ps))) {
this.loadPageData().then((/**
* @return {?}
*/
function () { return _this._toTop(options === null || options === void 0 ? void 0 : options.toTop); }));
}
this.changeEmit(type);
};
/**
* @param {?} e
* @param {?} item
* @param {?} col
* @return {?}
*/
STComponent.prototype._click = /**
* @param {?} e
* @param {?} item
* @param {?} col
* @return {?}
*/
function (e, item, col) {
e.preventDefault();
e.stopPropagation();
/** @type {?} */
var res = (/** @type {?} */ (col.click))(item, this);
if (typeof res === 'string') {
this.router.navigateByUrl(res, { state: this.routerState });
}
return false;
};
/**
* @private
* @param {?} item
* @return {?}
*/
STComponent.prototype.closeOtherExpand = /**
* @private
* @param {?} item
* @return {?}
*/
function (item) {
if (this.expandAccordion === false)
return;
this._data.filter((/**
* @param {?} i
* @return {?}
*/
function (i) { return i !== item; })).forEach((/**
* @param {?} i
* @return {?}
*/
function (i) { return (i.expand = false); }));
};
/**
* @param {?} e
* @param {?} item
* @param {?} index
* @return {?}
*/
STComponent.prototype._rowClick = /**
* @param {?} e
* @param {?} item
* @param {?} index
* @return {?}
*/
function (e, item, index) {
var _this = this;
if (((/** @type {?} */ (e.target))).nodeName === 'INPUT')
return;
var _a = this, expand = _a.expand, expandRowByClick = _a.expandRowByClick, rowClickTime = _a.rowClickTime;
if (!!expand && item.showExpand !== false && expandRowByClick) {
item.expand = !item.expand;
this.closeOtherExpand(item);
this.changeEmit('expand', item);
return;
}
++this.rowClickCount;
if (this.rowClickCount !== 1)
return;
setTimeout((/**
* @return {?}
*/
function () {
/** @type {?} */
var data = { e: e, item: item, index: index };
if (_this.rowClickCount === 1) {
_this.changeEmit('click', data);
}
else {
_this.changeEmit('dblClick', data);
}
_this.rowClickCount = 0;
}), rowClickTime);
};
/**
* @param {?} item
* @return {?}
*/
STComponent.prototype._expandChange = /**
* @param {?} item
* @return {?}
*/
function (item) {
this.closeOtherExpand(item);
this.changeEmit('expand', item);
};
/**
* Remove a row in the table, like this:
*
* ```
* this.st.removeRow(0)
* this.st.removeRow(stDataItem)
* ```
*/
/**
* Remove a row in the table, like this:
*
* ```
* this.st.removeRow(0)
* this.st.removeRow(stDataItem)
* ```
* @template THIS
* @this {THIS}
* @param {?} data
* @return {THIS}
*/
STComponent.prototype.removeRow = /**
* Remove a row in the table, like this:
*
* ```
* this.st.removeRow(0)
* this.st.removeRow(stDataItem)
* ```
* @template THIS
* @this {THIS}
* @param {?} data
* @return {THIS}
*/
function (data) {
var _this = this;
if (typeof data === 'number') {
(/** @type {?} */ (this))._data.splice(data, 1);
}
else {
if (!Array.isArray(data)) {
data = [data];
}
((/** @type {?} */ (data)))
.map((/**
* @param {?} item
* @return {?}
*/
function (item) { return (/** @type {?} */ (_this))._data.indexOf(item); }))
.filter((/**
* @param {?} pos
* @return {?}
*/
function (pos) { return pos !== -1; }))
.forEach((/**
* @param {?} pos
* @return {?}
*/
function (pos) { return (/** @type {?} */ (_this))._data.splice(pos, 1); }));
}
// recalculate no
(/** @type {?} */ (this))._columns
.filter((/**
* @param {?} w
* @return {?}
*/
function (w) { return w.type === 'no'; }))
.forEach((/**
* @param {?} c
* @return {?}
*/
function (c) { return (/** @type {?} */ (_this))._data.forEach((/**
* @param {?} i
* @param {?} idx
* @return {?}
*/
function (i, idx) { return (i._values[c.__point] = { text: (/** @type {?} */ (_this)).dataSource.getNoIndex(i, c, idx), org: idx }); })); }));
return (/** @type {?} */ (this)).cd();
};
/**
* Sets the row value for the `index` in the table, like this:
*
* ```
* this.st.setRow(0, { price: 100 })
* this.st.setRow(0, { price: 100, name: 'asdf' })
* ```
*/
/**
* Sets the row value for the `index` in the table, like this:
*
* ```
* this.st.setRow(0, { price: 100 })
* this.st.setRow(0, { price: 100, name: 'asdf' })
* ```
* @template THIS
* @this {THIS}
* @param {?} index
* @param {?} item
* @return {THIS}
*/
STComponent.prototype.setRow = /**
* Sets the row value for the `index` in the table, like this:
*
* ```
* this.st.setRow(0, { price: 100 })
* this.st.setRow(0, { price: 100, name: 'asdf' })
* ```
* @template THIS
* @this {THIS}
* @param {?} index
* @param {?} item
* @return {THIS}
*/
function (index, item) {
(/** @type {?} */ (this))._data[index] = deepMergeKey((/** @type {?} */ (this))._data[index], false, item);
(/** @type {?} */ (this))._data = (/** @type {?} */ (this)).dataSource.optimizeData({ columns: (/** @type {?} */ (this))._columns, result: (/** @type {?} */ (this))._data, rowClassName: (/** @type {?} */ (this)).rowClassName });
(/** @type {?} */ (this)).cdr.detectChanges();
return (/** @type {?} */ (this));
};
// #endregion
// #region sort
// #endregion
// #region sort
/**
* @param {?} col
* @param {?} idx
* @param {?} value
* @return {?}
*/
STComponent.prototype.sort =
// #endregion
// #region sort
/**
* @param {?} col
* @param {?} idx
* @param {?} value
* @return {?}
*/
function (col, idx, value) {
if (this.multiSort) {
(/** @type {?} */ (col._sort)).default = value;
(/** @type {?} */ (col._sort)).tick = this.dataSource.nextSortTick;
}
else {
this._columns.forEach((/**
* @param {?} item
* @param {?} index
* @return {?}
*/
function (item, index) { return ((/** @type {?} */ (item._sort)).default = index === idx ? value : null); }));
}
this.loadPageData();
/** @type {?} */
var res = {
value: value,
map: this.dataSource.getReqSortMap(this.singleSort, this.multiSort, this._columns),
column: col,
};
this.changeEmit('sort', res);
};
/**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
STComponent.prototype.clearSort = /**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
function () {
(/** @type {?} */ (this))._columns.forEach((/**
* @param {?} item
* @return {?}
*/
function (item) { return ((/** @type {?} */ (item._sort)).default = null); }));
return (/** @type {?} */ (this));
};
// #endregion
// #region filter
// #endregion
// #region filter
/**
* @private
* @param {?} col
* @return {?}
*/
STComponent.prototype.handleFilter =
// #endregion
// #region filter
/**
* @private
* @param {?} col
* @return {?}
*/
function (col) {
this.columnSource.updateDefault((/** @type {?} */ (col.filter)));
this.loadPageData();
this.changeEmit('filter', col);
};
/**
* @param {?} col
* @return {?}
*/
STComponent.prototype._filterConfirm = /**
* @param {?} col
* @return {?}
*/
function (col) {
this.handleFilter(col);
};
/**
* @param {?} col
* @param {?} item
* @param {?} checked
* @return {?}
*/
STComponent.prototype._filterRadio = /**
* @param {?} col
* @param {?} item
* @param {?} checked
* @return {?}
*/
function (col, item, checked) {
(/** @type {?} */ ((/** @type {?} */ (col.filter)).menus)).forEach((/**
* @param {?} i
* @return {?}
*/
function (i) { return (i.checked = false); }));
item.checked = checked;
};
/**
* @param {?} col
* @return {?}
*/
STComponent.prototype._filterClear = /**
* @param {?} col
* @return {?}
*/
function (col) {
this.columnSource.cleanFilter(col);
this.handleFilter(col);
};
/**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
STComponent.prototype.clearFilter = /**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
function () {
var _this = this;
(/** @type {?} */ (this))._columns.filter((/**
* @param {?} w
* @return {?}
*/
function (w) { return w.filter && w.filter.default === true; })).forEach((/**
* @param {?} col
* @return {?}
*/
function (col) { return (/** @type {?} */ (_this)).columnSource.cleanFilter(col); }));
return (/** @type {?} */ (this));
};
// #endregion
// #region checkbox
/** 清除所有 `checkbox` */
// #endregion
// #region checkbox
/**
* 清除所有 `checkbox`
* @template THIS
* @this {THIS}
* @return {THIS}
*/
STComponent.prototype.clearCheck =
// #endregion
// #region checkbox
/**
* 清除所有 `checkbox`
* @template THIS
* @this {THIS}
* @return {THIS}
*/
function () {
return (/** @type {?} */ (this))._checkAll(false);
};
/**
* @private
* @template THIS
* @this {THIS}
* @return {THIS}
*/
STComponent.prototype._refCheck = /**
* @private
* @template THIS
* @this {THIS}
* @return {THIS}
*/
function () {
/** @type {?} */
var validData = (/** @type {?} */ (this))._data.filter((/**
* @param {?} w
* @return {?}
*/
function (w) { return !w.disabled; }));
/** @type {?} */
var checkedList = validData.filter((/**
* @param {?} w
* @return {?}
*/
function (w) { return w.checked === true; }));
(/** @type {?} */ (this))._allChecked = checkedList.length > 0 && checkedList.length === validData.length;
/** @type {?} */
var allUnChecked = validData.every((/**
* @param {?} value
* @return {?}
*/
function (value) { return !value.checked; }));
(/** @type {?} */ (this))._indeterminate = !(/** @type {?} */ (this))._allChecked && !allUnChecked;
(/** @type {?} */ (this))._allCheckedDisabled = (/** @type {?} */ (this))._data.length === (/** @type {?} */ (this))._data.filter((/**
* @param {?} w
* @return {?}
*/
function (w) { return w.disabled; })).length;
return (/** @type {?} */ (this)).cd();
};
/**
* @template THIS
* @this {THIS}
* @param {?=} checked
* @return {THIS}
*/
STComponent.prototype._checkAll = /**
* @template THIS
* @this {THIS}
* @param {?=} checked
* @return {THIS}
*/
function (checked) {
checked = typeof checked === 'undefined' ? (/** @type {?} */ (this))._allChecked : checked;
(/** @type {?} */ (this))._data.filter((/**
* @param {?} w
* @return {?}
*/
function (w) { return !w.disabled; })).forEach((/**
* @param {?} i
* @return {?}
*/
function (i) { return (i.checked = checked); }));
return (/** @type {?} */ (this))._refCheck()._checkNotify();
};
/**
* @template THIS
* @this {THIS}
* @param {?} i
* @param {?} value
* @return {THIS}
*/
STComponent.prototype._checkSelection = /**
* @template THIS
* @this {THIS}
* @param {?} i
* @param {?} value
* @return {THIS}
*/
function (i, value) {
i.checked = value;
return (/** @type {?} */ (this))._refCheck()._checkNotify();
};
/**
* @template THIS
* @this {THIS}
* @param {?} row
* @return {THIS}
*/
STComponent.prototype._rowSelection = /**
* @template THIS
* @this {THIS}
* @param {?} row
* @return {THIS}
*/
function (row) {
row.select((/** @type {?} */ (this))._data);
return (/** @type {?} */ (this))._refCheck()._checkNotify();
};
/**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
STComponent.prototype._checkNotify = /**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
function () {
/** @type {?} */
var res = (/** @type {?} */ (this))._data.filter((/**
* @param {?} w
* @return {?}
*/
function (w) { return !w.disabled && w.checked === true; }));
(/** @type {?} */ (this)).changeEmit('checkbox', res);
return (/** @type {?} */ (this));
};
// #endregion
// #region radio
/** 清除所有 `radio` */
// #endregion
// #region radio
/**
* 清除所有 `radio`
* @template THIS
* @this {THIS}
* @return {THIS}
*/
STComponent.prototype.clearRadio =
// #endregion
// #region radio
/**
* 清除所有 `radio`
* @template THIS
* @this {THIS}
* @return {THIS}
*/
function () {
(/** @type {?} */ (this))._data.filter((/**
* @param {?} w
* @return {?}
*/
function (w) { return w.checked; })).forEach((/**
* @param {?} item
* @return {?}
*/
function (item) { return (item.checked = false); }));
(/** @type {?} */ (this)).changeEmit('radio', null);
return (/** @type {?} */ (this));
};
/**
* @template THIS
* @this {THIS}
* @param {?} checked
* @param {?} item
* @return {THIS}
*/
STComponent.prototype._refRadio = /**
* @template THIS
* @this {THIS}
* @param {?} checked
* @param {?} item
* @return {THIS}
*/
function (checked, item) {
// if (item.disabled === true) return;
(/** @type {?} */ (this))._data.filter((/**
* @param {?} w
* @return {?}
*/
function (w) { return !w.disabled; })).forEach((/**
* @param {?} i
* @return {?}
*/
function (i) { return (i.checked = false); }));
item.checked = checked;
(/** @type {?} */ (this)).changeEmit('radio', item);
return (/** @type {?} */ (this));
};
// #endregion
// #region buttons
// #endregion
// #region buttons
/**
* @param {?} record
* @param {?} btn
* @param {?=} e
* @return {?}
*/
STComponent.prototype._btnClick =
// #endregion
// #region buttons
/**
* @param {?} record
* @param {?} btn
* @param {?=} e
* @return {?}
*/
function (record, btn, e) {
var _a, _b;
var _this = this;
// should be stop propagation when expandRowByClick is true
if (e && this.expandRowByClick === true) {
e.stopPropagation();
}
if (btn.type === 'modal' || btn.type === 'static') {
var modal = btn.modal;
/** @type {?} */
var obj = (_a = {}, _a[(/** @type {?} */ ((/** @type {?} */ (modal)).paramsName))] = record, _a);
((/** @type {?} */ (this.modalHelper[btn.type === 'modal' ? 'create' : 'createStatic'])))((/** @type {?} */ (modal)).component, __assign(__assign({}, obj), ((/** @type {?} */ (modal)).params && (/** @type {?} */ ((/** @type {?} */ (modal)).params))(record))), deepMergeKey({}, true, this.copyCog.modal, modal))
.pipe(filter((/**
* @param {?} w
* @return {?}
*/
function (w) { return typeof w !== 'undefined'; })))
.subscribe((/**
* @param {?} res
* @return {?}
*/
function (res) { return _this.btnCallback(record, btn, res); }));
return;
}
else if (btn.type === 'drawer') {
var drawer = btn.drawer;
/** @type {?} */
var obj = (_b = {}, _b[(/** @type {?} */ ((/** @type {?} */ (drawer)).paramsName))] = record, _b);
this.drawerHelper
.create((/** @type {?} */ ((/** @type {?} */ (drawer)).title)), (/** @type {?} */ (drawer)).component, __assign(__assign({}, obj), ((/** @type {?} */ (drawer)).params && (/** @type {?} */ ((/** @type {?} */ (drawer)).params))(record))), deepMergeKey({}, true, this.copyCog.drawer, drawer))
.pipe(filter((/**
* @param {?} w
* @return {?}
*/
function (w) { return typeof w !== 'undefined'; })))
.subscribe((/**
* @param {?} res
* @return {?}
*/
function (res) { return _this.btnCallback(record, btn, res); }));
return;
}
else if (btn.type === 'link') {
/** @type {?} */
var clickRes = this.btnCallback(record, btn);
if (typeof clickRes === 'string') {
this.router.navigateByUrl(clickRes, { state: this.routerState });
}
return;
}
this.btnCallback(record, btn);
};
/**
* @private
* @param {?} record
* @param {?} btn
* @param {?=} modal
* @return {?}
*/
STComponent.prototype.btnCallback = /**
* @private
* @param {?} record
* @param {?} btn
* @param {?=} modal
* @return {?}
*/
function (record, btn, modal) {
if (!btn.click)
return;
if (typeof btn.click === 'string') {
switch (btn.click) {
case 'load':
this.load();
break;
case 'reload':
this.reload();
break;
}
}
else {
return btn.click(record, modal, this);
}
};
/**
* @param {?} record
* @param {?} btn
* @return {?}
*/
STComponent.prototype._btnText = /**
* @param {?} record
* @param {?} btn
* @return {?}
*/
function (record, btn) {
return typeof btn.text === 'function' ? btn.text(record, btn) : btn.text || '';
};
/**
* @param {?} btns
* @param {?} item
* @param {?} col
* @return {?}
*/
STComponent.prototype._validBtns = /**
* @param {?} btns
* @param {?} item
* @param {?} col
* @return {?}
*/
function (btns, item, col) {
return btns.filter((/**
* @param {?} btn
* @return {?}
*/
function (btn) {
/** @type {?} */
var result = (/** @type {?} */ (btn.iif))(item, btn, col);
/** @type {?} */
var isRenderDisabled = btn.iifBehavior === 'disabled';
btn._result = result;
btn._disabled = !result && isRenderDisabled;
return result || isRenderDisabled;
}));
};
// #endregion
// #region export
/**
* 导出当前页,确保已经注册 `XlsxModule`
* @param newData 重新指定数据;若为 `true` 表示使用 `filteredData` 数据
* @param opt 额外参数
*/
// #endregion
// #region export
/**
* 导出当前页,确保已经注册 `XlsxModule`
* @param {?=} newData 重新指定数据;若为 `true` 表示使用 `filteredData` 数据
* @param {?=} opt 额外参数
* @return {?}
*/
STComponent.prototype.export =
// #endregion
// #region export
/**
* 导出当前页,确保已经注册 `XlsxModule`
* @param {?=} newData 重新指定数据;若为 `true` 表示使用 `filteredData` 数据
* @param {?=} opt 额外参数
* @return {?}
*/
function (newData, opt) {
var _this = this;
(newData === true ? from(this.filteredData) : of(newData || this._data)).subscribe((/**
* @param {?} res
* @return {?}
*/
function (res) {
return _this.exportSrv.export(__assign(__assign({}, opt), { _d: res, _c: _this._columns }));
}));
};
Object.defineProperty(STComponent.prototype, "cdkVirtualScrollViewport", {
// #endregion
get:
// #endregion
/**
* @return {?}
*/
function () {
return this.orgTable.cdkVirtualScrollViewport;
},
enumerable: true,
configurable: true
});
/**
* @param {?=} options
* @return {?}
*/
STComponent.prototype.resetColumns = /**
* @param {?=} options
* @return {?}
*/
function (options) {
options = __assign({ emitReload: true }, options);
if (typeof options.columns !== 'undefined') {
this.columns = options.columns;
}
if (typeof options.pi !== 'undefined') {
this.pi = options.pi;
}
if (typeof options.ps !== 'undefined') {
this.ps = options.ps;
}
this.refreshColumns();
if (options.emitReload === true) {
return this.loadPageData();
}
else {
this.cd();
return Promise.resolve(this);
}
};
/**
* @private
* @template THIS
* @this {THIS}
* @return {THIS}
*/
STComponent.prototype.refreshColumns = /**
* @private
* @template THIS
* @this {THIS}
* @return {THIS}
*/
function () {
(/** @type {?} */ (this))._columns = (/** @type {?} */ (this)).columnSource.process((/** @type {?} */ (this)).columns);
return (/** @type {?} */ (this));
};
/**
* @private
* @return {?}
*/
STComponent.prototype.setClass = /**
* @private
* @return {?}
*/
function () {
var _a;
var _b = this.widthMode, type = _b.type, strictBehavior = _b.strictBehavior;
updateHostClass(this.el.nativeElement, this.renderer, (_a = {},
_a["st"] = true,
_a["st__p-" + this.page.placement] = this.page.placement,
_a["st__width-" + type] = true,
_a["st__width-strict-" + strictBehavior] = type === 'strict',
_a["ant-table-rep"] = this.responsive,
_a["ant-table-rep__hide-header-footer"] = this.responsiveHideHeaderFooter,
_a));
};
/**
* @return {?}
*/
STComponent.prototype.ngAfterViewInit = /**
* @return {?}
*/
function () {
this.columnSource.restoreAllRender(this._columns);
};
/**
* @param {?} changes
* @return {?}
*/
STComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (changes.columns) {
this.refreshColumns();
}
/** @type {?} */
var changeData = changes.data;
if (changeData && changeData.currentValue && !(this.req.lazyLoad && changeData.firstChange)) {
this.loadPageData();
}
if (changes.loading) {
this._loading = changes.loading.currentValue;
}
this.setClass();
};
/**
* @return {?}
*/
STComponent.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
var unsubscribe$ = this.unsubscribe$;
unsubscribe$.next();
unsubscribe$.complete();
};
STComponent.decorators = [
{ type: Component, args: [{
selector: 'st',
exportAs: 'st',
template: " <ng-template #btnTpl let-i let-btn=\"btn\">\n <ng-container *ngIf=\"!btn.tooltip\">\n <ng-template [ngTemplateOutlet]=\"btnItemTpl\" [ngTemplateOutletContext]=\"{ $implicit: i, btn: btn }\"></ng-template>\n </ng-container>\n <span *ngIf=\"btn.tooltip\" nz-tooltip [nzTooltipTitle]=\"btn.tooltip\">\n <ng-template [ngTemplateOutlet]=\"btnItemTpl\" [ngTemplateOutletContext]=\"{ $implicit: i, btn: btn }\"></ng-template>\n </span>\n</ng-template>\n<ng-template #btnItemTpl let-i let-btn=\"btn\">\n <a *ngIf=\"btn.pop\" nz-popconfirm [nzPopconfirmTitle]=\"btn.pop.title\" [nzIcon]=\"btn.pop.icon\"\n [nzCondition]=\"btn.pop.condition(i)\" [nzCancelText]=\"btn.pop.cancelText\" [nzOkText]=\"btn.pop.okText\"\n [nzOkType]=\"btn.pop.okType\" (nzOnConfirm)=\"_btnClick(i, btn, $event)\" class=\"st__btn-text\">\n <ng-template [ngTemplateOutlet]=\"btnTextTpl\" [ngTemplateOutletContext]=\"{ $implicit: i, btn: btn }\"></ng-template>\n </a>\n <a *ngIf=\"!btn.pop\" (click)=\"_btnClick(i, btn, $event)\" class=\"st__btn-text\">\n <ng-template [ngTemplateOutlet]=\"btnTextTpl\" [ngTemplateOutletContext]=\"{ $implicit: i, btn: btn }\"></ng-template>\n </a>\n</ng-template>\n<ng-template #btnTextTpl let-i let-btn=\"btn\">\n <ng-container *ngIf=\"btn.icon\">\n <i *ngIf=\"!btn.icon.iconfont\" nz-icon [nzType]=\"btn.icon.type\" [nzTheme]=\"btn.icon.theme\" [nzSpin]=\"btn.icon.spin\"\n [nzTwotoneColor]=\"btn.icon.twoToneColor\"></i>\n <i *ngIf=\"btn.icon.iconfont\" nz-icon [nzIconfont]=\"btn.icon.iconfont\"></i>\n </ng-container>\n <span [innerHTML]=\"_btnText(i, btn)\" [ngClass]=\"{'pl-xs': btn.icon}\"></span>\n</ng-template>\n<ng-template #titleTpl let-i>\n <span [innerHTML]=\"i._text\"></span>\n <small *ngIf=\"i.optional\" class=\"st__head-optional\" [innerHTML]=\"i.optional\"></small>\n <i *ngIf=\"i.optionalHelp\" class=\"st__head-tip\" nz-tooltip [nzTooltipTitle]=\"i.optionalHelp\" nz-icon nzType=\"question-circle\"></i>\n</ng-template>\n<ng-template #bodyTpl let-i let-index=\"index\">\n <tr [attr.data-index]=\"index\" (click)=\"_rowClick($event, i, index)\" [class]=\"i._rowClassName\">\n <td *ngIf=\"expand\" [nzShowExpand]=\"expand && i.showExpand !== false\" [(nzExpand)]=\"i.expand\"\n (nzExpandChange)=\"_expandChange(i)\" nzWidth=\"50px\"></td>\n <td *ngFor=\"let c of _columns; let cIdx=index\" [nzLeft]=\"c._left\" [nzRight]=\"c._right\" [ngClass]=\"columnClass(c)\" [attr.colspan]=\"c.colSpan\">\n <span *ngIf=\"responsive\" class=\"ant-table-rep__title\">\n <ng-template [ngTemplateOutlet]=\"titleTpl\" [ngTemplateOutletContext]=\"{$implicit: c.title }\"></ng-template>\n </span>\n <span>\n <ng-template #render [ngTemplateOutlet]=\"c.__render\" [ngTemplateOutletContext]=\"{$implicit: i, index: index, column: c }\"></ng-template>\n <ng-container *ngIf=\"!c.__render; else render\">\n <ng-container [ngSwitch]=\"c.type\">\n <label *ngSwitchCase=\"'checkbox'\" nz-checkbox [nzDisabled]=\"i.disabled\" [ngModel]=\"i.checked\"\n (ngModelChange)=\"_checkSelection(i, $event)\"></label>\n <label *ngSwitchCase=\"'radio'\" nz-radio [nzDisabled]=\"i.disabled\" [ngModel]=\"i.checked\"\n (ngModelChange)=\"_refRadio($event, i)\"></label>\n <a *ngSwitchCase=\"'link'\" (click)=\"_click($event, i, c)\" [innerHTML]=\"i._values[cIdx]._text\"></a>\n <ng-conntainer *ngIf=\"i._values[cIdx].text\">\n <nz-tag *ngSwitchCase=\"'tag'\" [nzColor]=\"i._values[cIdx].color\">\n <span [innerHTML]=\"i._values[cIdx]._text\"></span>\n </nz-tag>\n <nz-badge *ngSwitchCase=\"'badge'\" [nzStatus]=\"i._values[cIdx].color\" [nzText]=\"i._values[cIdx].text\">\n </nz-badge>\n </ng-conntainer>\n <span *ngSwitchDefault [innerHTML]=\"i._values[cIdx]._text\" [attr.title]=\"isTruncate(c) ? i._values[cIdx].text : null\"></span>\n </ng-container>\n <ng-container *ngFor=\"let btn of _validBtns(c.buttons, i, c); let last=last\">\n <a *ngIf=\"btn.children.length > 0\" nz-dropdown [nzDropdownMenu]=\"btnMenu\" nzOverlayClassName=\"st__btn-sub\">\n <span [innerHTML]=\"_btnText(i, btn)\"></span>\n <i nz-icon nzType=\"down\"></i>\n </a>\n <nz-dropdown-menu #btnMenu=\"nzDropdownMenu\">\n <ul nz-menu>\n <ng-container *ngFor=\"let subBtn of _validBtns(btn.children, i, c)\">\n <li *ngIf=\"subBtn.type !== 'divider'\" nz-menu-item [class.st__btn-disabled]=\"subBtn._disabled\">\n <ng-template [ngTemplateOutlet]=\"btnTpl\" [ngTemplateOutletContext]=\"{ $implicit: i, btn: subBtn }\">\n </ng-template>\n </li>\n <li *ngIf=\"subBtn.type === 'divider'\" nz-menu-divider></li>\n </ng-container>\n </ul>\n </nz-dropdown-menu>\n <span *ngIf=\"btn.children.length == 0\" [class.st__btn-disabled]=\"btn._disabled\">\n <ng-template [ngTemplateOutlet]=\"btnTpl\" [ngTemplateOutletContext]=\"{ $implicit: i, btn: btn }\">\n </ng-template>\n </span>\n <nz-divider *ngIf=\"!last\" nzType=\"vertical\"></nz-divider>\n </ng-container>\n <ng-template [ngIf]=\"!c.__re