UNPKG

@ohayojp.com/components

Version:

Common business components of ohayojp.

1,947 lines (1,942 loc) 158 kB
import { Injectable, Directive, TemplateRef, Host, Input, ɵɵdefineInjectable, Optional, Inject, EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef, ElementRef, ViewChild, Output, ViewContainerRef, ComponentFactoryResolver, NgModule } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { ACLService, OhayoACLModule } from '@ohayojp.com/acl'; import { OHAYO_I18N_TOKEN, _HttpClient, CNCurrencyPipe, DatePipe, YNPipe, ModalHelper, DrawerHelper, OhayoLocaleService } from '@ohayojp.com/theme'; import { warn, deepCopy, deepGet, deepMergeKey, toBoolean, OhayoConfigService, InputNumber, InputBoolean, OhayoUtilModule } from '@ohayojp.com/util'; import { DecimalPipe, DOCUMENT, CommonModule } from '@angular/common'; import { HttpParams } from '@angular/common/http'; import { of, Subject, from } from 'rxjs'; import { map, takeUntil, filter } from 'rxjs/operators'; import { __awaiter, __decorate, __metadata } from 'tslib'; import { XlsxService } from '@ohayojp.com/components/xlsx'; import { Router } from '@angular/router'; import { NzTableModule } from 'ng-zorro-antd/table'; import { FormsModule } from '@angular/forms'; import { NzBadgeModule } from 'ng-zorro-antd/badge'; import { NzCheckboxModule } from 'ng-zorro-antd/checkbox'; import { NzDividerModule } from 'ng-zorro-antd/divider'; import { NzDropDownModule } from 'ng-zorro-antd/dropdown'; import { NzIconModule } from 'ng-zorro-antd/icon'; import { NzInputModule } from 'ng-zorro-antd/input'; import { NzMenuModule } from 'ng-zorro-antd/menu'; import { NzPopconfirmModule } from 'ng-zorro-antd/popconfirm'; import { NzRadioModule } from 'ng-zorro-antd/radio'; import { NzResizableModule } from 'ng-zorro-antd/resizable'; import { NzTagModule } from 'ng-zorro-antd/tag'; import { NzToolTipModule } from 'ng-zorro-antd/tooltip'; /** * @fileoverview added by tsickle * Generated from: st.interfaces.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function STWidthMode() { } if (false) { /** * 宽度类型 * - `default` 默认行为 * - `strict` 严格模式,即强制按 `width` 指定的宽度呈现,并根据 `strictBehavior` 类型处理 * @type {?|undefined} */ STWidthMode.prototype.type; /** * 严格模式的处理行为 * - `wrap` 强制换行 * - `truncate` 截短 * @type {?|undefined} */ STWidthMode.prototype.strictBehavior; } /** * @record */ function STResetColumnsOption() { } if (false) { /** @type {?|undefined} */ STResetColumnsOption.prototype.pi; /** @type {?|undefined} */ STResetColumnsOption.prototype.ps; /** @type {?|undefined} */ STResetColumnsOption.prototype.columns; /** * Whether to pre-clear data, Default: `false` * @type {?|undefined} */ STResetColumnsOption.prototype.preClearData; /** * Whether to trigger a data load, Default: `true` * @type {?|undefined} */ STResetColumnsOption.prototype.emitReload; } /** * @record */ function STReq() { } if (false) { /** * 分页类型,默认:`page` * - `page` 使用 `pi`,`ps` 组合 * - `skip` 使用 `skip`,`limit` 组合 * @type {?|undefined} */ STReq.prototype.type; /** * 额外请求参数,默认自动附加 `pi`、`ps` 至URL * - `{ status: 'new' }` => `url?pi=1&ps=10&status=new` * @type {?|undefined} */ STReq.prototype.params; /** * 请求方法,默认:`GET` * @type {?|undefined} */ STReq.prototype.method; /** * 请求体 `body` * @type {?|undefined} */ STReq.prototype.body; /** * 请求体 `Header` * @type {?|undefined} */ STReq.prototype.headers; /** * 重命名参数 `pi`、`ps`,默认:`{ pi: 'pi', ps: 'ps' }` * - `{ pi: 'Page' }` => `pi` 会被替换成 Page * @type {?|undefined} */ STReq.prototype.reName; /** * 是否将请求所有参数数据都放入 `body` 当中(`url` 地址本身参数除外),仅当 `method: 'POST'` 时有效,默认:`false` * @type {?|undefined} */ STReq.prototype.allInBody; /** * 是否延迟加载数据,即渲染结束后不会主动发起请求,默认:`false` * @type {?|undefined} */ STReq.prototype.lazyLoad; /** * 请求前数据处理 * @type {?|undefined} */ STReq.prototype.process; } /** * @record */ function STRequestOptions() { } if (false) { /** @type {?|undefined} */ STRequestOptions.prototype.body; /** @type {?|undefined} */ STRequestOptions.prototype.headers; /** @type {?|undefined} */ STRequestOptions.prototype.params; /** @type {?|undefined} */ STRequestOptions.prototype.observe; /** @type {?|undefined} */ STRequestOptions.prototype.reportProgress; /** @type {?|undefined} */ STRequestOptions.prototype.responseType; /** @type {?|undefined} */ STRequestOptions.prototype.withCredentials; } /** * @record */ function STLoadOptions() { } if (false) { /** * 是否合并,默认:`false` * @type {?|undefined} */ STLoadOptions.prototype.merge; /** * 是否跳转至顶部,若不指定由 `page.toTop` 来决定 * @type {?|undefined} */ STLoadOptions.prototype.toTop; } /** * @record */ function STRes() { } if (false) { /** * 重命名返回参数 `total`、`list` * - `{ total: 'Total' }` => Total 会被当作 `total` * @type {?|undefined} */ STRes.prototype.reName; /** * 数据预处理 * @type {?|undefined} */ STRes.prototype.process; } /** * @record */ function STPage() { } if (false) { /** * 前端分页,当 `data` 为`any[]` 或 `Observable<any[]>` 有效,默认:`true` * - `true` 由 `st` 根据 `data` 长度受控分页,包括:排序、过滤等 * - `false` 由用户通过 `total` 和 `data` 参数受控分页,并维护 `(change)` 当分页变更时重新加载数据 * @type {?|undefined} */ STPage.prototype.front; /** * 后端分页是否采用`0`基索引,只在`data`类型为`string`时有效,默认:`false` * @type {?|undefined} */ STPage.prototype.zeroIndexed; /** * 指定分页显示的位置,默认:`bottom` * @type {?|undefined} */ STPage.prototype.position; /** * 指定分页分页方向,默认:`right` * @type {?|undefined} */ STPage.prototype.placement; /** * 是否显示分页器,默认:`true` * @type {?|undefined} */ STPage.prototype.show; /** * 是否显示分页器中改变页数,默认:`false` * @type {?|undefined} */ STPage.prototype.showSize; /** * 分页器中每页显示条目数下拉框值,默认:`[10, 20, 30, 40, 50]` * @type {?|undefined} */ STPage.prototype.pageSizes; /** * 是否显示分页器中快速跳转,默认:`false` * @type {?|undefined} */ STPage.prototype.showQuickJumper; /** * 用于自定义页码的结构,用法参照 Pagination 组件 * @type {?|undefined} */ STPage.prototype.itemRender; /** * 当添加该属性时,显示为简单分页,默认:`false` * @type {?|undefined} */ STPage.prototype.simple; /** * 是否显示总数据量 * - `boolean` 类型显示与否,默认模板:`共 {{total}} 条` * - `string` 自定义模板,模板变量: * - `{{total}}` 表示数据总量 * - `{{range[0]}}` 表示当前页开始数量值 * - `{{range[1]}}` 表示当前页结束数量值 * @type {?|undefined} */ STPage.prototype.total; /** * 切换分页时返回顶部,默认:`true` * @type {?|undefined} */ STPage.prototype.toTop; /** * 返回顶部偏移值,默认:`100` * @type {?|undefined} */ STPage.prototype.toTopOffset; } /** * 数据源 * @record */ function STData() { } if (false) { /** * 选择框或单选框状态值 * @type {?|undefined} */ STData.prototype.checked; /** * 选择框或单选框 `disabled` 值 * @type {?|undefined} */ STData.prototype.disabled; /** * 是否展开状态 * @type {?|undefined} */ STData.prototype.expand; /** * 是否显示展开按钮 * @type {?|undefined} */ STData.prototype.showExpand; /* Skipping unhandled member: [key: string]: any;*/ } /** * 列描述 * @record */ function STColumn() { } if (false) { /** * 用于定义数据源主键,例如:`statistical` * @type {?|undefined} */ STColumn.prototype.key; /** * 列标题 * @type {?|undefined} */ STColumn.prototype.title; /** * 列数据在数据项中对应的 key,支持 `a.b.c` 的嵌套写法,例如: * - `id` * - `price.market` * - `[ 'price', 'market' ]` * @type {?|undefined} */ STColumn.prototype.index; /** * 类型 * - `no` 行号,计算规则:`index + noIndex` * - `checkbox` 多选 * - `radio` 单选 * - `link` 链接,务必指定 `click` * - `badge` [徽标](https://ng.ant.design/components/badge/zh),务必指定 `badge` 参数配置徽标对应值 * - `tag` [标签](https://ng.ant.design/components/tag/zh),务必指定 `tag` 参数配置标签对应值 * - `enum` 枚举转换,务必指定 `enum` 参数配置标签对应值 * - `img` 图片且居中(若 `className` 存在则优先) * - `number` 数字且居右(若 `className` 存在则优先) * - `currency` 货币且居右(若 `className` 存在则优先) * - `date` 日期格式且居中(若 `className` 存在则优先),使用 `dateFormat` 自定义格式 * - `yn` 将`boolean`类型徽章化 [document](https://ohayojp.com/docs/data-render#yn) * - `widget` 使用自定义小部件动态创建 * @type {?|undefined} */ STColumn.prototype.type; /** * 链接回调,若返回一个字符串表示导航URL会自动触发 `router.navigateByUrl` * @type {?|undefined} */ STColumn.prototype.click; /** * 按钮组 * @type {?|undefined} */ STColumn.prototype.buttons; /** * 自定义渲染ID * \@example * <ng-template st-row="custom" let-item let-index="index" let-column="column"> * {{ c.title }} * </ng-template> * @type {?|undefined} */ STColumn.prototype.render; /** * 标题自定义渲染ID * \@example * <ng-template st-row="custom" type="title" let-c> * {{ item | json }} * </ng-template> * @type {?|undefined} */ STColumn.prototype.renderTitle; /** * 列宽(数字型表示 `px` 值),例如:`100`、`10%`、`100px` * * **注意:** 若固定列必须是数字 * @type {?|undefined} */ STColumn.prototype.width; /** * 排序配置项,远程数据配置**优先**规则: * - `true` 表示允许排序,且若数据源为本地时自动生成 `compare: (a, b) => a[index] - b[index]` 方法 * - `string` 表示远程数据排序相对应 `key` 值 * @type {?|undefined} */ STColumn.prototype.sort; /** * 过滤配置项 * @type {?|undefined} */ STColumn.prototype.filter; /** * 格式化列值 * @type {?|undefined} */ STColumn.prototype.format; /** * 自定义全/反选选择项 * @type {?|undefined} */ STColumn.prototype.selections; /** * 列 `class` 属性值(注:无须 `.` 点)多个用空格隔开,例如: * - `text-center` 居中 * - `text-right` 居右 * - `text-success` 成功色 * - `text-error` 异常色 * @type {?|undefined} */ STColumn.prototype.className; /** * 合并列 * @type {?|undefined} */ STColumn.prototype.colSpan; /** * 数字格式,`type=number` 有效 * @type {?|undefined} */ STColumn.prototype.numberDigits; /** * 日期格式,`type=date` 有效,(默认:`yyyy-MM-dd HH:mm`) * @type {?|undefined} */ STColumn.prototype.dateFormat; /** * 当 `type=yn` 有效 * @type {?|undefined} */ STColumn.prototype.yn; /** * 是否允许导出,默认 `true` * @type {?|undefined} */ STColumn.prototype.exported; /** * 权限,等同 [ACLCanType](https://ohayojp.com/acl/getting-started/#ACLCanType) 参数值 * @type {?|undefined} */ STColumn.prototype.acl; /** * 当不存在数据时以默认值替代 * @type {?|undefined} */ STColumn.prototype.default; /** * 固定前后列,当指定时务必指定 `width` 否则视为无效,有若干 **注意:** 项: * * - 若列头与内容不对齐或出现列重复,请指定列的宽度 `width` * - 建议指定 `scroll.x` 为大于表格宽度的固定值或百分比。注意,且非固定列宽度之和不要超过 `scroll.x` * @type {?|undefined} */ STColumn.prototype.fixed; /** * 徽标配置项 * @type {?|undefined} */ STColumn.prototype.badge; /** * 标签配置项 * @type {?|undefined} */ STColumn.prototype.tag; /** * 行号索引,默认:`1` * - 计算规则为:`index + noIndex` * - 支持自定义方法 * @type {?|undefined} */ STColumn.prototype.noIndex; /** * 条件表达式 * - 仅赋值 `columns` 时执行一次 * - 可调用 `resetColumns()` 再一次触发 * @type {?|undefined} */ STColumn.prototype.iif; /** * 统计列数据 * - 若使用自定义统计函数可无须指定 `index` * - 可以根据 `key` 来定义生成后需要的键名,如果未指定 `key` 则使用 `index` 来表示键名 * - 当无法找到有效键名时,使用下标(从 `0` 开始)来代替 * @type {?|undefined} */ STColumn.prototype.statistical; /** @type {?|undefined} */ STColumn.prototype.widget; /** @type {?|undefined} */ STColumn.prototype.enum; /** * 分组表头 * @type {?|undefined} */ STColumn.prototype.children; /** @type {?|undefined} */ STColumn.prototype.rowSpan; /** * 调整表头配置 * - 注意:**不要忘记**在 `src/styles` 下增加 `nz-resizable` Less 样式文件:`\@import '~ng-zorro-antd/resizable/style/entry.less';` * - **不支持多表头** * @type {?|undefined} */ STColumn.prototype.resizable; } /** * @record */ function STWidgetColumn() { } if (false) { /** @type {?} */ STWidgetColumn.prototype.type; /** @type {?|undefined} */ STWidgetColumn.prototype.params; } /** * @record */ function STColumnTitle() { } if (false) { /** * Text of header, can be choose one of `text` or `i18n` * @type {?|undefined} */ STColumnTitle.prototype.text; /** * I18n key of header, can be choose one of `text` or `i18n` * @type {?|undefined} */ STColumnTitle.prototype.i18n; /** * Optional information of header * @type {?|undefined} */ STColumnTitle.prototype.optional; /** * Optional help of header * @type {?|undefined} */ STColumnTitle.prototype.optionalHelp; /* Skipping unhandled member: [key: string]: any;*/ } /** * @record */ function STStatistical() { } if (false) { /** @type {?} */ STStatistical.prototype.type; /** * 保留小数位数,默认:`2` * @type {?|undefined} */ STStatistical.prototype.digits; /** * 是否需要货币格式化,默认以下情况为 `true` * - `type` 为 `STStatisticalFn`、 `sum`、`average`、`max`、`min` * @type {?|undefined} */ STStatistical.prototype.currency; } /** * @record */ function STStatisticalResults() { } /** * @record */ function STStatisticalResult() { } if (false) { /** @type {?} */ STStatisticalResult.prototype.value; /** @type {?|undefined} */ STStatisticalResult.prototype.text; } /** * @record */ function STColumnSort() { } if (false) { /** * 排序的默认受控属性 * @type {?|undefined} */ STColumnSort.prototype.default; /** * 本地数据的排序函数,使用一个函数(参考 [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) 的 compareFunction) * - `null` 忽略本地排序,但保持排序功能 * - 若数据源为本地时自动生成 `(a, b) => a[index] - b[index]` 方法 * @type {?|undefined} */ STColumnSort.prototype.compare; /** * 远程数据的排序时后端相对应的KEY,默认使用 `index` 属性 * - 若 `multiSort: false` 时:`key: 'name' => ?name=1&pi=1` * - 若 `multiSort: true` 允许多个排序 key 存在,或使用 `STMultiSort` 指定多列排序key合并规则 * @type {?|undefined} */ STColumnSort.prototype.key; /** * 远程数据的排序时后端相对应的VALUE * - `{ ascend: '0', descend: '1' }` 结果 `?name=1&pi=1` * - `{ ascend: 'asc', descend: 'desc' }` 结果 `?name=desc&pi=1` * @type {?|undefined} */ STColumnSort.prototype.reName; } /** * @record */ function STSortMap() { } if (false) { /** * 是否启用排序 * @type {?|undefined} */ STSortMap.prototype.enabled; /* Skipping unhandled member: [key: string]: any;*/ } /** * @record */ function STColumnFilter() { } if (false) { /** * 搜索方式 * - `defualt` 默认形式 * - `keyword` 文本框形式 * @type {?|undefined} */ STColumnFilter.prototype.type; /** * 表头的筛选菜单项,至少一项才会生效 * - 当 `type='keyword'` 时可为空 * @type {?|undefined} */ STColumnFilter.prototype.menus; /** * 本地数据的筛选函数 * @type {?|undefined} */ STColumnFilter.prototype.fn; /** * 标识数据是否已过滤,筛选图标会高亮 * @type {?|undefined} */ STColumnFilter.prototype.default; /** * 自定义 filter 图标 * - 当 `type='default'` 默认 `filter` * - 当 `type='keyword'` 默认 `search` * @type {?|undefined} */ STColumnFilter.prototype.icon; /** * 确认按钮文本,默认 `确认` * @type {?|undefined} */ STColumnFilter.prototype.confirmText; /** * 清除按钮文本,默认 `重置` * @type {?|undefined} */ STColumnFilter.prototype.clearText; /** * 是否多选,默认 `true` * @type {?|undefined} */ STColumnFilter.prototype.multiple; /** * 远程数据的过滤时后端相对应的KEY,默认使用 `index` 属性 * `key: 'name'` 结果 `?name=1&pi=1` * @type {?|undefined} */ STColumnFilter.prototype.key; /** * 远程数据的过滤时后端相对应的VALUE * - 默认当 `multiple: true` 时以英文逗号拼接的字符串 * \@return 返回为 Object 对象 * @type {?|undefined} */ STColumnFilter.prototype.reName; } /** * @record */ function STColumnFilterMenu() { } if (false) { /** * 文本 * - 当 `type: 'keyword'` 时表示 `placeholder` * @type {?|undefined} */ STColumnFilterMenu.prototype.text; /** * 值 * @type {?|undefined} */ STColumnFilterMenu.prototype.value; /** * 是否选中 * @type {?|undefined} */ STColumnFilterMenu.prototype.checked; /** * 权限,等同 [ACLCanType](https://ohayojp.com/acl/getting-started/#ACLCanType) 参数值 * @type {?|undefined} */ STColumnFilterMenu.prototype.acl; /* Skipping unhandled member: [key: string]: any;*/ } /** * @record */ function STColumnSelection() { } if (false) { /** * 选择项显示的文字 * @type {?} */ STColumnSelection.prototype.text; /** * 选择项点击回调,允许对参数 `data.checked` 进行操作 * @type {?} */ STColumnSelection.prototype.select; /** * 权限,等同 `can()` 参数值 * @type {?|undefined} */ STColumnSelection.prototype.acl; } /** * 当 `type=yn` 有效 * @record */ function STColumnYn() { } if (false) { /** * 真值条件,(默认:`true`) * @type {?|undefined} */ STColumnYn.prototype.truth; /** * 徽章 `true` 时文本,(默认:`是`) * @type {?|undefined} */ STColumnYn.prototype.yes; /** * 徽章 `false` 时文本,(默认:`否`) * @type {?|undefined} */ STColumnYn.prototype.no; /** * 徽章显示风格 * - `full` 图标和文本 * - `icon` 图标 * - `text` 文本 * @type {?|undefined} */ STColumnYn.prototype.mode; } /** * @record */ function STIcon() { } if (false) { /** * 图标类型 * @type {?} */ STIcon.prototype.type; /** * 图标主题风格,默认:`outline` * @type {?|undefined} */ STIcon.prototype.theme; /** * 是否有旋转动画,默认:`false` * @type {?|undefined} */ STIcon.prototype.spin; /** * 仅适用双色图标,设置双色图标的主要颜色,仅对当前 icon 生效 * @type {?|undefined} */ STIcon.prototype.twoToneColor; /** * 指定来自 IconFont 的图标类型 * @type {?|undefined} */ STIcon.prototype.iconfont; } /** * 按钮配置 * @record */ function STColumnButton() { } if (false) { /** * 文本 * @type {?|undefined} */ STColumnButton.prototype.text; /** * 文本 i18n * @type {?|undefined} */ STColumnButton.prototype.i18n; /** * 图标 * @type {?|undefined} */ STColumnButton.prototype.icon; /** * 按钮类型 * - `none` 无任何互动 * - `del` 删除,默认开启 `pop: true` * - `modal` 对话框,需要指定 `component` 才会生效 * - `static` 静态对话框,需要指定 `component` 才会生效 * - `drawer` 抽屉,需要指定 `component` 才会生效 * - `link` 链接,当 `click` 返回字符串时自动调用 `navigateByUrl` 导航 * - `divider` 分割线 * @type {?|undefined} */ STColumnButton.prototype.type; /** * 点击回调 * - Function * - `type=modal` 只会在当有传回值时才会触发回调 * - reload:重新刷新当前页 * - load:重新加载数据,并重置页码为:`1` * * \@todo Bad parameter design * @type {?|undefined} */ STColumnButton.prototype.click; /** * 气泡确认框参数,若 `string` 类型表示标题 * @type {?|undefined} */ STColumnButton.prototype.pop; /** * 对话框参数 * @type {?|undefined} */ STColumnButton.prototype.modal; /** * 抽屉参数 * @type {?|undefined} */ STColumnButton.prototype.drawer; /** * 下拉菜单,当存在时以 `dropdown` 形式渲染 * - 只支持一级 * @type {?|undefined} */ STColumnButton.prototype.children; /** * 权限,等同 [ACLCanType](https://ohayojp.com/acl/getting-started/#ACLCanType) 参数值 * @type {?|undefined} */ STColumnButton.prototype.acl; /** * Conditional expression * * \@todo Bad parameter design * @type {?|undefined} */ STColumnButton.prototype.iif; /** * Conditional expression rendering behavior, can be set to `hide` (default) or `disabled` * @type {?|undefined} */ STColumnButton.prototype.iifBehavior; /** @type {?|undefined} */ STColumnButton.prototype.tooltip; /** * 按钮 `class` 属性值(注:无须 `.` 点)多个用空格隔开,例如: * - `text-success` 成功色 * - `text-error` 错误色 * @type {?|undefined} */ STColumnButton.prototype.className; /* Skipping unhandled member: [key: string]: any;*/ } /** * @record */ function STColumnButtonOK() { } if (false) { /** @type {?} */ STColumnButtonOK.prototype.record; /** * Modal or drawer return value when trigger confirm. * @type {?|undefined} */ STColumnButtonOK.prototype.ret; /** @type {?|undefined} */ STColumnButtonOK.prototype.instance; /** @type {?} */ STColumnButtonOK.prototype.event; } /** * @record */ function STColumnButtonModal() { } if (false) { /** * 对话框组件对象 * @type {?|undefined} */ STColumnButtonModal.prototype.component; /** * 对话框参数 * @type {?|undefined} */ STColumnButtonModal.prototype.params; /** * 对话框目标组件的接收参数名,默认:`record` * @type {?|undefined} */ STColumnButtonModal.prototype.paramsName; } /** * @record */ function STColumnButtonModalConfig() { } if (false) { /** * 指定模态框目标组件的接收参数名,默认:`record` * @type {?|undefined} */ STColumnButtonModalConfig.prototype.paramsName; /** * 大小;例如:lg、600,默认:`lg` * @type {?|undefined} */ STColumnButtonModalConfig.prototype.size; /** * 对话框 [ModalOptions](https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/components/modal/modal-types.ts) 参数 * @type {?|undefined} */ STColumnButtonModalConfig.prototype.modalOptions; /** * 是否精准(默认:`true`),若返回值非空值(`null`或`undefined`)视为成功,否则视为错误 * @type {?|undefined} */ STColumnButtonModalConfig.prototype.exact; } /** * @record */ function STColumnButtonDrawer() { } if (false) { /** * 标题 * @type {?|undefined} */ STColumnButtonDrawer.prototype.title; /** * 抽屉组件对象 * @type {?|undefined} */ STColumnButtonDrawer.prototype.component; /** * 抽屉参数 * @type {?|undefined} */ STColumnButtonDrawer.prototype.params; /** * 抽屉目标组件的接收参数名,默认:`record` * @type {?|undefined} */ STColumnButtonDrawer.prototype.paramsName; } /** * @record */ function STColumnButtonDrawerConfig() { } if (false) { /** * 抽屉目标组件的接收参数名,默认:`record` * @type {?|undefined} */ STColumnButtonDrawerConfig.prototype.paramsName; /** * 大小;例如:lg、600,默认:`md` * * | 类型 | 默认大小 | * | --- | ------ | * | `sm` | `300` | * | `md` | `600` | * | `lg` | `900` | * | `xl` | `1200` | * * > 以上值,可通过覆盖相应的LESS参数自行调整 * @type {?|undefined} */ STColumnButtonDrawerConfig.prototype.size; /** * 是否包含底部工具条,默认:`true` * @type {?|undefined} */ STColumnButtonDrawerConfig.prototype.footer; /** * 底部工具条高度,默认:`55` * @type {?|undefined} */ STColumnButtonDrawerConfig.prototype.footerHeight; /** * 抽屉 [NzDrawerOptions](https://ng.ant.design/components/drawer/zh#nzdraweroptions) 参数 * @type {?|undefined} */ STColumnButtonDrawerConfig.prototype.drawerOptions; } /** * @record */ function STColumnButtonPop() { } if (false) { /** * Title of the popover, default: `确认删除吗?` * @type {?|undefined} */ STColumnButtonPop.prototype.title; /** * Popover trigger mode, default: `click` * @type {?|undefined} */ STColumnButtonPop.prototype.trigger; /** * The position of the popover relative to the target, default: `top` * @type {?|undefined} */ STColumnButtonPop.prototype.placement; /** * Class name of the popover card * @type {?|undefined} */ STColumnButtonPop.prototype.overlayClassName; /** * Style of the popover card * @type {?|undefined} */ STColumnButtonPop.prototype.overlayStyle; /** * Text of the Cancel button * @type {?|undefined} */ STColumnButtonPop.prototype.cancelText; /** * Text of the Confirm button * @type {?|undefined} */ STColumnButtonPop.prototype.okText; /** * Button `type` of the Confirm button * @type {?|undefined} */ STColumnButtonPop.prototype.okType; /** * Customize icon of confirmation * @type {?|undefined} */ STColumnButtonPop.prototype.icon; /** * Whether to directly emit `onConfirm` without showing Popconfirm, default: `() => false` * @type {?|undefined} */ STColumnButtonPop.prototype.condition; } /** * @record */ function STReqReNameType() { } if (false) { /** @type {?|undefined} */ STReqReNameType.prototype.pi; /** @type {?|undefined} */ STReqReNameType.prototype.ps; /** @type {?|undefined} */ STReqReNameType.prototype.skip; /** @type {?|undefined} */ STReqReNameType.prototype.limit; } /** * @record */ function STResReNameType() { } if (false) { /** @type {?|undefined} */ STResReNameType.prototype.total; /** @type {?|undefined} */ STResReNameType.prototype.list; } /** * @record */ function STExportOptions() { } if (false) { /** * Specify the currently exported data, default the current table data * @type {?|undefined} */ STExportOptions.prototype.data; /** * Specify the currently exported column configuration, default the current table data * @type {?|undefined} */ STExportOptions.prototype.columens; /** * 工作溥名 * @type {?|undefined} */ STExportOptions.prototype.sheetname; /** * 文件名 * @type {?|undefined} */ STExportOptions.prototype.filename; /** * triggers when saveas * @type {?|undefined} */ STExportOptions.prototype.callback; } /** * 单排序规则 * - 若不指定,则返回:`columnName=ascend|descend` * - 若指定,则返回:`sort=columnName.(ascend|descend)` * @record */ function STSingleSort() { } if (false) { /** * 请求参数名,默认:`sort` * @type {?|undefined} */ STSingleSort.prototype.key; /** * 列名与状态间分隔符,默认:`.` * @type {?|undefined} */ STSingleSort.prototype.nameSeparator; } /** * 多排序相同排序 key 时合并规则 * @record */ function STMultiSort() { } if (false) { /** * 请求参数名,默认:`sort` * @type {?|undefined} */ STMultiSort.prototype.key; /** * 不同属性间分隔符,默认:`-` * @type {?|undefined} */ STMultiSort.prototype.separator; /** * 列名与状态间分隔符,默认:`.` * @type {?|undefined} */ STMultiSort.prototype.nameSeparator; /** * 是否以数组的形式传递参数,默认:`false` * - `true` 表示使用 `url?sort=name.asc&sort=age.desc` 形式 * - `false` 表示使用 `url?sort=name.asc-age.desc` 形式 * @type {?|undefined} */ STMultiSort.prototype.arrayParam; /** * 是否保持空值的键名,默认:`true` * - `true` 表示不管是否有排序都会发送 `key` 键名 * - `false` 表示无排序动作时不会发送 `key` 键名 * @type {?|undefined} */ STMultiSort.prototype.keepEmptyKey; /** * ## 仅限全局配置项有效 * * 是否全局多排序模式,默认:`true` * - `true` 表示所有 `st` 默认为多排序 * - `false` 表示需要为每个 `st` 添加 `multiSort` 才会视为多排序模式 * @type {?|undefined} */ STMultiSort.prototype.global; } /** * 徽标信息 * @record */ function STColumnBadge() { } /** * @record */ function STColumnBadgeValue() { } if (false) { /** * 文本 * @type {?|undefined} */ STColumnBadgeValue.prototype.text; /** * 徽标颜色值 * @type {?|undefined} */ STColumnBadgeValue.prototype.color; } /** * 标签信息 * @record */ function STColumnTag() { } /** * @record */ function STColumnTagValue() { } if (false) { /** * 文本 * @type {?|undefined} */ STColumnTagValue.prototype.text; /** * 颜色值,支持预设和色值 * - 预设:geekblue,blue,purple,success,red,volcano,orange,gold,lime,green,cyan * - 色值:#f50,#ff0 * @type {?|undefined} */ STColumnTagValue.prototype.color; } /** * 回调数据 * @record */ function STChange() { } if (false) { /** * 回调类型 * @type {?} */ STChange.prototype.type; /** * 当前页码 * @type {?} */ STChange.prototype.pi; /** * 每页数量 * @type {?} */ STChange.prototype.ps; /** * 数据总量 * @type {?} */ STChange.prototype.total; /** * `loaded` 参数 * @type {?|undefined} */ STChange.prototype.loaded; /** * `checkbox` 参数 * @type {?|undefined} */ STChange.prototype.checkbox; /** * `radio` 参数 * @type {?|undefined} */ STChange.prototype.radio; /** * 排序参数 * @type {?|undefined} */ STChange.prototype.sort; /** * 过滤参数 * @type {?|undefined} */ STChange.prototype.filter; /** * 行点击参数 * @type {?|undefined} */ STChange.prototype.click; /** * 行双击参数 * @type {?|undefined} */ STChange.prototype.dblClick; /** * `expand` 参数 * @type {?|undefined} */ STChange.prototype.expand; /** * `resize` 参数 * @type {?|undefined} */ STChange.prototype.resize; } /** * 行单击参数 * @record */ function STChangeSort() { } if (false) { /** @type {?|undefined} */ STChangeSort.prototype.value; /** @type {?|undefined} */ STChangeSort.prototype.map; /** @type {?|undefined} */ STChangeSort.prototype.column; } /** * 行单击参数 * @record */ function STChangeRowClick() { } if (false) { /** @type {?|undefined} */ STChangeRowClick.prototype.e; /** @type {?|undefined} */ STChangeRowClick.prototype.item; /** @type {?|undefined} */ STChangeRowClick.prototype.index; } /** * @record */ function STError() { } if (false) { /** @type {?|undefined} */ STError.prototype.type; /** @type {?|undefined} */ STError.prototype.error; } /** * @record */ function STColumnGroupType() { } if (false) { /** @type {?} */ STColumnGroupType.prototype.column; /** @type {?} */ STColumnGroupType.prototype.colStart; /** @type {?|undefined} */ STColumnGroupType.prototype.colEnd; /** @type {?|undefined} */ STColumnGroupType.prototype.colSpan; /** @type {?|undefined} */ STColumnGroupType.prototype.rowSpan; /** @type {?|undefined} */ STColumnGroupType.prototype.hasSubColumns; } /** * @record */ function STResizable() { } if (false) { /** * Disable resize, Default: `true` * @type {?|undefined} */ STResizable.prototype.disabled; /** * Specifies resize boundaries, Default: `window` * @type {?|undefined} */ STResizable.prototype.bounds; /** * Maximum width of resizable elemen, Default: `60` * @type {?|undefined} */ STResizable.prototype.maxWidth; /** * Minimum width of resizable element, Default: `360` * @type {?|undefined} */ STResizable.prototype.minWidth; /** * Enable preview when resizing, Default: `true` * @type {?|undefined} */ STResizable.prototype.preview; } /** * @fileoverview added by tsickle * Generated from: st.types.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function _STColumn() { } if (false) { /** @type {?|undefined} */ _STColumn.prototype.children; /** @type {?|undefined} */ _STColumn.prototype.indexKey; /** * 是否有子列 * @type {?|undefined} */ _STColumn.prototype.hasSubColumns; /** * 是否需要截短行为 * - `type: 'img'` 强制非必要 * @type {?|undefined} */ _STColumn.prototype._isTruncate; /** * 校验需要未自定义 `className` 时应检查 `_isTruncate` 是否需要截短行为 * @type {?|undefined} */ _STColumn.prototype._className; /** @type {?|undefined} */ _STColumn.prototype._sort; /** @type {?|undefined} */ _STColumn.prototype._left; /** @type {?|undefined} */ _STColumn.prototype._right; /** @type {?|undefined} */ _STColumn.prototype.__point; /** @type {?|undefined} */ _STColumn.prototype.__renderTitle; /** @type {?|undefined} */ _STColumn.prototype.__render; } /** * @fileoverview added by tsickle * Generated from: st-row.directive.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class STRowSource { constructor() { this.titles = {}; this.rows = {}; } /** * @param {?} type * @param {?} path * @param {?} ref * @return {?} */ add(type, path, ref) { this[type === 'title' ? 'titles' : 'rows'][path] = ref; } /** * @param {?} path * @return {?} */ getTitle(path) { return this.titles[path]; } /** * @param {?} path * @return {?} */ getRow(path) { return this.rows[path]; } } STRowSource.decorators = [ { type: Injectable } ]; if (false) { /** * @type {?} * @private */ STRowSource.prototype.titles; /** * @type {?} * @private */ STRowSource.prototype.rows; } class STRowDirective { /** * @param {?} ref * @param {?} source */ constructor(ref, source) { this.ref = ref; this.source = source; } /** * @return {?} */ ngOnInit() { this.source.add(this.type, this.id, this.ref); } } STRowDirective.decorators = [ { type: Directive, args: [{ selector: '[st-row]' },] } ]; /** @nocollapse */ STRowDirective.ctorParameters = () => [ { type: TemplateRef }, { type: STRowSource, decorators: [{ type: Host }] } ]; STRowDirective.propDecorators = { id: [{ type: Input, args: ['st-row',] }], type: [{ type: Input }] }; if (false) { /** @type {?} */ STRowDirective.prototype.id; /** @type {?} */ STRowDirective.prototype.type; /** * @type {?} * @private */ STRowDirective.prototype.ref; /** * @type {?} * @private */ STRowDirective.prototype.source; } /** * @fileoverview added by tsickle * Generated from: st-widget.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class STWidgetRegistry { constructor() { this._widgets = {}; } /** * @return {?} */ get widgets() { return this._widgets; } /** * @param {?} type * @param {?} widget * @return {?} */ register(type, widget) { this._widgets[type] = widget; } /** * @param {?} type * @return {?} */ has(type) { return this._widgets.hasOwnProperty(type); } /** * @param {?} type * @return {?} */ get(type) { return this._widgets[type]; } } STWidgetRegistry.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ STWidgetRegistry.ɵprov = ɵɵdefineInjectable({ factory: function STWidgetRegistry_Factory() { return new STWidgetRegistry(); }, token: STWidgetRegistry, providedIn: "root" }); if (false) { /** * @type {?} * @private */ STWidgetRegistry.prototype._widgets; } /** * @fileoverview added by tsickle * Generated from: st-column-source.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function STColumnSourceProcessOptions() { } if (false) { /** @type {?} */ STColumnSourceProcessOptions.prototype.widthMode; /** @type {?} */ STColumnSourceProcessOptions.prototype.resizable; } class STColumnSource { /** * @param {?} dom * @param {?} rowSource * @param {?} acl * @param {?} i18nSrv * @param {?} stWidgetRegistry */ constructor(dom, rowSource, acl, i18nSrv, stWidgetRegistry) { this.dom = dom; this.rowSource = rowSource; this.acl = acl; this.i18nSrv = i18nSrv; this.stWidgetRegistry = stWidgetRegistry; } /** * @param {?} val * @return {?} */ setCog(val) { this.cog = val; } /** * @private * @param {?} i * @param {?} def * @return {?} */ fixPop(i, def) { if (i.pop == null || i.pop === false) { i.pop = false; return; } /** @type {?} */ let pop = Object.assign({}, def); if (typeof i.pop === 'string') { pop.title = i.pop; } else if (typeof i.pop === 'object') { pop = Object.assign(Object.assign({}, pop), i.pop); } if (typeof pop.condition !== 'function') { pop.condition = (/** * @return {?} */ () => false); } i.pop = pop; } /** * @private * @param {?} list * @return {?} */ btnCoerce(list) { if (!list) return []; /** @type {?} */ const ret = []; const { modal, drawer, pop, btnIcon } = this.cog; for (const item of list) { if (this.acl && item.acl && !this.acl.can(item.acl)) { continue; } if (item.type === 'modal' || item.type === 'static') { if (item.modal == null || item.modal.component == null) { console.warn(`[st] Should specify modal parameter`); item.type = 'none'; } else { item.modal = Object.assign(Object.assign({ paramsName: 'record', size: 'lg' }, modal), item.modal); } } if (item.type === 'drawer') { if (item.drawer == null || item.drawer.component == null) { console.warn(`[st] Should specify drawer parameter`); item.type = 'none'; } else { item.drawer = Object.assign(Object.assign({ paramsName: 'record', size: 'lg' }, drawer), item.drawer); } } if (item.type === 'del' && typeof item.pop === 'undefined') { item.pop = true; } // pop this.fixPop(item, (/** @type {?} */ (pop))); if (item.icon) { item.icon = Object.assign(Object.assign({}, btnIcon), (typeof item.icon === 'string' ? { type: item.icon } : item.icon)); } item.children = item.children && item.children.length > 0 ? this.btnCoerce(item.children) : []; // i18n if (item.i18n && this.i18nSrv) { item.text = this.i18nSrv.fanyi(item.i18n); } ret.push(item); } this.btnCoerceIf(ret); return ret; } /** * @private * @param {?} list * @return {?} */ btnCoerceIf(list) { for (const item of list) { if (!item.iif) item.iif = (/** * @return {?} */ () => true); item.iifBehavior = item.iifBehavior || this.cog.iifBehavior; if (item.children && item.children.length > 0) { this.btnCoerceIf(item.children); } else { item.children = []; } } } /** * @private * @param {?} list * @return {?} */ fixedCoerce(list) { /** @type {?} */ const countReduce = (/** * @param {?} a * @param {?} b * @return {?} */ (a, b) => a + +(/** @type {?} */ (b.width)).toString().replace('px', '')); // left width list .filter((/** * @param {?} w * @return {?} */ w => w.fixed && w.fixed === 'left' && w.width)) .forEach((/** * @param {?} item * @param {?} idx * @return {?} */ (item, idx) => (item._left = list.slice(0, idx).reduce(countReduce, 0) + 'px'))); // right width list .filter((/** * @param {?} w * @return {?} */ w => w.fixed && w.fixed === 'right' && w.width)) .reverse() .forEach((/** * @param {?} item * @param {?} idx * @return {?} */ (item, idx) => (item._right = (idx > 0 ? list.slice(-idx).reduce(countReduce, 0) : 0) + 'px'))); } /** * @private * @param {?} item * @return {?} */ sortCoerce(item) { /** @type {?} */ const res = this.fixSortCoerce(item); res.reName = Object.assign(Object.assign({}, this.cog.sortReName), res.reName); return res; } /** * @private * @param {?} item * @return {?} */ fixSortCoerce(item) { if (typeof item.sort === 'undefined') { return { enabled: false }; } /** @type {?} */ let res = {}; if (typeof item.sort === 'string') { res.key = item.sort; } else if (typeof item.sort !== 'boolean') { res = item.sort; } else if (typeof item.sort === 'boolean') { res.compare = (/** * @param {?} a * @param {?} b * @return {?} */ (a, b) => a[(/** @type {?} */ (item.indexKey))] - b[(/** @type {?} */ (item.indexKey))]); } if (!res.key) { res.key = item.indexKey; } res.enabled = true; return res; } /** * @private * @param {?} item * @return {?} */ filterCoerce(item) { if (item.filter == null) { return null; } /** @type {?} */ let res = item.filter; res.type = res.type || 'default'; /** @type {?} */ let icon = 'filter'; /** @type {?} */ let iconTheme = 'fill'; if (res.type === 'keyword') { if (res.menus == null || (/** @type {?} */ (res.menus)).length === 0) { res.menus = [{ value: '' }]; } icon = 'search'; iconTheme = 'outline'; } if ((/** @type {?} */ (res.menus)).length === 0) { return null; } if (typeof res.multiple === 'undefined') { res.multiple = true; } res.confirmText = res.confirmText || this.cog.filterConfirmText; res.clearText = res.clearText || this.cog.filterClearText; res.key = res.key || item.indexKey; res.icon = res.icon || icon; /** @type {?} */ const baseIcon = (/** @type {?} */ ({ type: icon, theme: iconTheme })); if (typeof res.icon === 'string') { res.icon = (/** @type {?} */ (Object.assign(Object.assign({}, baseIcon), { type: res.icon }))); } else { res.icon = Object.assign(Object.assign({}, baseIcon), res.icon); } this.updateDefault(res); if (this.acl) { res.menus = (/** @type {?} */ (res.menus)).filter((/** * @param {?} w * @return {?} */ w => this.acl.can((/** @type {?} */ (w.acl))))); } if ((/** @type {?} */ (res.menus)).length <= 0) { res = null; } return res; } /** * @private * @param {?} item * @return {?} */ restoreRender(item) { if (item.renderTitle) { item.__renderTitle = typeof item.renderTitle === 'string' ? this.rowSource.getTitle(item.renderTitle) : ((/** @type {?} */ (item.renderTitle))); } if (item.render) { item.__render = typeof item.render === 'string' ? this.rowSource.getRow(item.render) : ((/** @type {?} */ (item.render))); } } /** * @private * @param {?} item * @return {?} */ widgetCoerce(item) { var _a; if (item.type !== 'widget') return; if (item.widget == null || !this.stWidgetRegistry.has(item.widget.type)) { delete item.type; warn(`st: No widget for type "${(_a = item.widget) === null || _a === void 0 ? void 0 : _a.type}"`); } } /** * @private * @param {?} rootColumns * @return {?} */ genHeaders(rootColumns) { /** @type {?} */ const rows = []; /** @type {?} */ const widths = []; /** @type {?} */ const fillRowCells = (/** * @param {?} columns * @param {?} colIndex * @param {?=} rowIndex * @return {?} */ (columns, colIndex, rowIndex = 0) => { // Init rows rows[rowIndex] = rows[rowIndex] || []; /** @type {?} */ let currentColIndex = colIndex; /** @type {?} */ const colSpans = columns.map((/** * @param {?} column * @return {?} */ column => { /** @type {?} */ const cell = { column, colStart: currentColIndex, hasSubColumns: false, }; /** @type {?} */ let colSpan = 1; /** @type {?} */ const subColumns = column.children; if (Array.isArray(subColumns) && subColumns.length > 0) { colSpan = fillRowCells(subColumns, currentColIndex, rowIndex + 1).reduce((/** * @param {?} total * @param {?} count * @return {?} */ (total, count) => total + count), 0); cell.hasSubColumns = true; } else { widths.push(((/** @type {?} */ (cell.column.width))) || ''); } if ('colSpan' in column) { colSpan = (/** @type {?} */ (column.colSpan)); } if ('rowSpan' in column) { cell.rowSpan = column.rowSpan; } cell.colSpan = colSpan; cell.colEnd = cell.colStart + colSpan - 1; rows[rowIndex].push((/** @type {?} */ (cell))); currentColIndex += colSpan; return colSpan; })); return colSpans; }); fillRowCells(rootColumns, 0); // Handle `rowSpan` /** @type {?} */ const rowCount = rows.length; for (let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) { rows[rowIndex].forEach((/** * @param {?} cell * @return {?} */ cell => { if (!('rowSpan' in cell) && !cell.hasSubColumns) { cell.rowSpan = rowCount - rowIndex; } })); } return { headers: rows, headerWidths: rowCount