raise-common-lib 0.0.1 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/bundles/raise-common-lib.umd.js +1130 -0
  2. package/bundles/raise-common-lib.umd.js.map +1 -0
  3. package/bundles/raise-common-lib.umd.min.js +16 -0
  4. package/bundles/raise-common-lib.umd.min.js.map +1 -0
  5. package/esm2015/lib/common-grid/index.component.js +716 -0
  6. package/esm2015/lib/constant/index.js +107 -0
  7. package/esm2015/lib/raise-common-lib.module.js +38 -0
  8. package/esm2015/public-api.js +11 -0
  9. package/esm2015/raise-common-lib.js +10 -0
  10. package/esm5/lib/common-grid/index.component.js +865 -0
  11. package/esm5/lib/constant/index.js +107 -0
  12. package/esm5/lib/raise-common-lib.module.js +42 -0
  13. package/esm5/public-api.js +11 -0
  14. package/esm5/raise-common-lib.js +10 -0
  15. package/fesm2015/raise-common-lib.js +766 -0
  16. package/fesm2015/raise-common-lib.js.map +1 -0
  17. package/fesm5/raise-common-lib.js +917 -0
  18. package/fesm5/raise-common-lib.js.map +1 -0
  19. package/lib/common-grid/index.component.d.ts +116 -0
  20. package/lib/constant/index.d.ts +54 -0
  21. package/lib/raise-common-lib.module.d.ts +2 -0
  22. package/package.json +17 -4
  23. package/{src/public-api.ts → public-api.d.ts} +2 -5
  24. package/raise-common-lib.d.ts +4 -0
  25. package/raise-common-lib.metadata.json +1 -0
  26. package/karma.conf.js +0 -32
  27. package/ng-package.json +0 -7
  28. package/src/lib/common-grid/grid-utils.ts +0 -26
  29. package/src/lib/common-grid/index.component.html +0 -80
  30. package/src/lib/common-grid/index.component.scss +0 -230
  31. package/src/lib/common-grid/index.component.ts +0 -420
  32. package/src/lib/constant/index.ts +0 -59
  33. package/src/lib/raise-common-lib.module.ts +0 -48
  34. package/tsconfig.lib.json +0 -26
  35. package/tsconfig.spec.json +0 -17
  36. package/tslint.json +0 -17
@@ -1,230 +0,0 @@
1
- .e-grid.e-gridhover
2
- tr[role="row"]:hover
3
- .e-rowcell:not(.e-cellselectionbackground):not(.e-active):not(
4
- .e-updatedtd
5
- ):not(.e-indentcell) {
6
- background: rgba(31, 123, 255, 0.04) !important;
7
- }
8
- .e-summaryrow {
9
- .e-summarycell {
10
- &:nth-child(2) {
11
- padding-left: 0 !important;
12
- }
13
- }
14
- }
15
- .e-footerpadding {
16
- padding-right: 0 !important;
17
- .e-summaryrow {
18
- margin-right: 5px !important;
19
- .e-indentcell {
20
- background-color: unset !important;
21
- }
22
- }
23
- }
24
- kt-common-grid {
25
- display: flex;
26
- flex: 1;
27
- height: 100%;
28
- .e-grid {
29
- height: 100%;
30
- .e-headercontent {
31
- margin-right: 0px !important;
32
- }
33
- }
34
- }
35
- .e-grid td.e-active {
36
- // SMP2-17564 不能带透明度,否则滚动时重叠左侧表头区域会颜色叠加
37
- // background: rgba(31, 123, 255, 0.08) !important;
38
- background: #edf5ff !important;
39
- }
40
-
41
- .grid-tools {
42
- height: 32px;
43
- min-height: 32px;
44
- display: flex;
45
- align-items: center;
46
- justify-content: space-between;
47
- padding-left: 7px;
48
- .right-opt-group {
49
- display: flex;
50
- align-items: center;
51
- margin-right: 6px;
52
- }
53
- .tools-button {
54
- border: none;
55
- font-family: Arial;
56
- font-size: 12px;
57
- color: #43566c;
58
- background: none;
59
- display: flex;
60
- align-items: center;
61
- padding: 0;
62
- margin-right: 16px;
63
- &.disabled-button {
64
- pointer-events: none;
65
- opacity: 0.5;
66
- }
67
- img {
68
- margin-right: 4px;
69
- height: 16px !important;
70
- width: 16px !important;
71
- }
72
- .tools-font {
73
- transform: translateY(1px);
74
- display: inline-block;
75
- }
76
- }
77
- .select-num {
78
- font-size: 12px;
79
- color: #43566c;
80
- margin-right: 24px;
81
- white-space: nowrap;
82
- }
83
- }
84
-
85
- .e-rowcell {
86
- padding: 0 8px 0 12px;
87
- &.e-gridchkbox {
88
- padding: 0 0 0 8px !important;
89
- }
90
- }
91
- .e-headercell {
92
- padding: 0;
93
- &:first-child {
94
- &.e-defaultcursor {
95
- & + .e-headercell {
96
- .e-headercelldiv {
97
- padding-left: 0;
98
- }
99
- }
100
- }
101
- }
102
-
103
- .e-headercelldiv {
104
- margin: 0;
105
- padding: 0 20px 0 12px;
106
- }
107
- .e-headerchkcelldiv {
108
- padding: 0 0 0 8px !important;
109
- }
110
- .e-columnmenu {
111
- position: absolute;
112
- right: 0;
113
- float: unset;
114
- margin: 0;
115
- padding: 0;
116
- top: 8px;
117
- }
118
- .e-sortfilterdiv {
119
- padding-top: 11px;
120
- }
121
- &.e-rightalign {
122
- .e-sortfilterdiv {
123
- padding-left: 5px;
124
- }
125
- }
126
- }
127
- .e-detailheadercell {
128
- height: 28px !important;
129
- }
130
-
131
- .e-grid {
132
- font-family: Arial !important;
133
- display: flex;
134
- flex-direction: column;
135
- flex: 1;
136
- border: none;
137
- overflow: hidden;
138
- .e-gridcontent {
139
- flex: 1;
140
- }
141
- .e-content {
142
- overflow: scroll !important;
143
- &::-webkit-scrollbar {
144
- // 滚动条样式
145
- width: 5px;
146
- height: 5px;
147
- background: #ffffff;
148
- position: static;
149
- z-index: 999;
150
- border-radius: 10px;
151
- }
152
- &::-webkit-scrollbar-thumb {
153
- // 滚动条滑块颜色
154
- background: #eaedf0;
155
- border-radius: 10px;
156
- }
157
- }
158
- .e-gridheader {
159
- margin-right: 5px !important;
160
- padding-right: 0 !important;
161
- }
162
- .e-gridcontent,
163
- .e-content {
164
- display: flex;
165
- flex-direction: column;
166
- flex: 1;
167
- }
168
- .e-gridheader {
169
- height: 30px !important;
170
- }
171
-
172
- .e-columnheader,
173
- .e-headercell,
174
- .e-rhandler {
175
- height: 28px !important;
176
- }
177
- .e-headertext {
178
- font-size: 10px !important;
179
- }
180
- .e-headercell .e-columnmenu {
181
- color: #929dab;
182
- }
183
- .e-row {
184
- height: 26px !important;
185
- line-height: 26px !important;
186
- }
187
-
188
- .e-rowcell {
189
- font-size: 11px !important;
190
- color: #43566c !important;
191
- padding-top: 0;
192
- padding-bottom: 0;
193
- padding-right: 7px;
194
- .mat-icon-button {
195
- height: 26px;
196
- width: 26px;
197
- line-height: 26px;
198
- }
199
- &:empty {
200
- height: 26px !important;
201
- }
202
- &.e-gridchkbox {
203
- & + .e-rowcell {
204
- padding-left: 0 !important;
205
- }
206
- }
207
- }
208
- .e-gridpager {
209
- border: none;
210
- .e-gridcontent {
211
- transform: unset;
212
- }
213
- }
214
- .e-summaryrow {
215
- height: 24px !important;
216
- .e-indentcell,
217
- .e-summarycell {
218
- background-color: #fff;
219
- border: none;
220
- font-family: Arial;
221
- font-size: 11px !important;
222
- font-weight: bold;
223
- color: #43566c;
224
- padding: 0 12px;
225
- }
226
- }
227
- .e-row:last-child .e-rowcell {
228
- border-bottom: 1px solid #dee2e6;
229
- }
230
- }
@@ -1,420 +0,0 @@
1
- import {
2
- Component,
3
- EventEmitter,
4
- Input,
5
- OnInit,
6
- Output,
7
- TemplateRef,
8
- OnChanges,
9
- ViewChild,
10
- SimpleChanges,
11
- ChangeDetectorRef,
12
- } from '@angular/core';
13
- import { GridComponent } from '@syncfusion/ej2-angular-grids';
14
-
15
- import { BeforeOpenCloseEventArgs } from '@syncfusion/ej2-angular-inputs';
16
- import { IActionMenuItem, IColumnField } from '../constant';
17
-
18
- @Component({
19
- selector: 'kt-common-grid',
20
- templateUrl: './index.component.html',
21
- styleUrls: ['./index.component.scss'],
22
- })
23
- export class CommonGridComponent implements OnInit, OnChanges {
24
- @ViewChild('grid', { static: false })
25
- public grid: GridComponent;
26
- @Input() showCheckBox = true;
27
- @Input() loaded = true;
28
- @Input() hiddenLoaded = false;
29
- @Input() authorized = true; // Dataset是否授权,未授权则显示权限错误提示
30
- // only use for local data pagination
31
- @Input() selectedDiffKey = '';
32
- @Input() gridHeight = '';
33
- // 这玩意必填,不然filter columnChooser都会报错
34
- @Input() gridId = 'grid';
35
- @Input() resizeSettings = { mode: 'Auto' };
36
- @Input() filterSettings = { type: 'Menu' };
37
- @Input() template: any;
38
- @Input() fields: IColumnField[] = [];
39
- @Input() dataSource = [];
40
- @Input() editSettings;
41
- @Input() columnTemplate: TemplateRef<any>;
42
- @Input() pageSettings;
43
- @Input() allowPaging = true;
44
- @Input() clipMode = 'EllipsisWithTooltip';
45
- @Input() checkBoxWidth = 32; // col 数量过少的时候,check宽度会拉伸,这时候设置null
46
- @Input() childGrid;
47
-
48
- /**
49
- * Sample: [
50
- {
51
- text: "Preview",
52
- target: ".e-content",
53
- id: "preview-icon",
54
- iconCss: "preview",
55
- },
56
- {
57
- text: "Download",
58
- target: ".e-content",
59
- id: "download-icon",
60
- iconCss: "download",
61
- }
62
- ]
63
- 用于定义row中 点击事件
64
- */
65
- @Input() contextMenuItems: IActionMenuItem[] = [];
66
- // @Input() selectionSettings = { checkboxOnly: true, type: "Multiple" };
67
- @Input() selectionSettings = {
68
- type: 'Multiple',
69
- // persistSelection: true,
70
- checkboxOnly: true,
71
- };
72
- @Input() alwaysShowCheckbox: boolean = false;
73
- @Input() defaultRecord: any;
74
- @Input() disableSystemRow: boolean = false; // 禁用IsSytem = true的整行
75
-
76
- @Output() recordDoubleClick = new EventEmitter();
77
- @Output() actionComplete = new EventEmitter();
78
- @Output() rowSelected = new EventEmitter();
79
- @Output() rowDeselected = new EventEmitter();
80
- @Output() onContextMenu = new EventEmitter();
81
- @Output() actionHandler = new EventEmitter();
82
- @Output() queryCellInfo = new EventEmitter();
83
- @Output() recordClick = new EventEmitter();
84
- @Output() actionBegin = new EventEmitter();
85
- @Output() rowDataBound = new EventEmitter();
86
- @Output() dataBound = new EventEmitter();
87
- @Output() exportQueryCellInfo = new EventEmitter();
88
- @Output() rowSelecting = new EventEmitter();
89
-
90
- selectId = [];
91
- startPaging = false;
92
- indexList = [];
93
- className = 'grid-loading';
94
-
95
- public translation;
96
-
97
- constructor(private ref: ChangeDetectorRef) {
98
- this.translation = JSON.parse(localStorage.getItem('translation'));
99
- }
100
-
101
- ngOnInit(): void {
102
- if (this.hiddenLoaded) this.className = '';
103
- this.ref && this.ref.markForCheck();
104
- }
105
-
106
- trackByFn(index, item) {
107
- return index; // or a unique identifier in your object
108
- }
109
- ngOnChanges(changes: SimpleChanges) {
110
- if (changes.dataSource && changes.dataSource.currentValue) {
111
- if (
112
- this.allowPaging &&
113
- changes.dataSource.currentValue.length &&
114
- !this.pageSettings
115
- ) {
116
- this.pageSettings =
117
- changes.dataSource.currentValue.length > 9
118
- ? {
119
- pageSizes: ['All', '25', '50', '100'],
120
- pageSize: 50,
121
- }
122
- : null;
123
- }
124
- }
125
- }
126
-
127
- _load() {
128
- if (!this.authorized) {
129
- (this.grid.localeObj as any).localeStrings.EmptyRecord =
130
- this.translation.YOU_DO_NOT_HAVE_THE_DATASET_PERMISSION ||
131
- "You don't have the dataset permission to view the record.";
132
- }
133
- }
134
-
135
- _dataBound(args: any) {
136
- // 整个组件加载完成时的回调函数
137
- var pagerContainer = document.querySelector('.e-pagercontainer');
138
- if (pagerContainer) {
139
- var linkElements = pagerContainer.querySelectorAll('.e-link');
140
- linkElements.forEach(function (element) {
141
- element.removeAttribute('href'); // SMP2-10310 删除分页器的href属性
142
- });
143
- }
144
- if (this.selectedDiffKey) {
145
- setTimeout(() => {
146
- this.chooseRecords();
147
- });
148
- }
149
- this.dataBound.emit(args);
150
- }
151
-
152
- _exportQueryCellInfo(args) {
153
- this.exportQueryCellInfo.emit(args);
154
- }
155
-
156
- _recordDoubleClick($event) {
157
- this.recordDoubleClick.emit($event);
158
- }
159
- /**
160
- * [selectionSettings]="{ checkboxOnly: true }"
161
- [showCheckBox]="true"
162
- 控件使用时,必须配置上面两个属性,否则,全选会失效
163
- */
164
- _rowSelected($event) {
165
- if (this.selectedDiffKey) {
166
- if ($event.isHeaderCheckboxClicked && Array.isArray($event.data)) {
167
- if ($event.data && $event.data.length) {
168
- $event.data.forEach((item) => {
169
- item.isSelected = true;
170
- this.selectId.push(item);
171
- });
172
- this.dataSource.forEach((data) => {
173
- $event.data.forEach((_data) => {
174
- if (_data[this.selectedDiffKey] === data[this.selectedDiffKey]) {
175
- data.isSelected = true;
176
- }
177
- });
178
- });
179
- }
180
- } else {
181
- $event.data.isSelected = true;
182
- this.selectId.push($event.data);
183
- this.dataSource.forEach((data) => {
184
- if (
185
- data[this.selectedDiffKey] === $event.data[this.selectedDiffKey]
186
- ) {
187
- data.isSelected = true;
188
- }
189
- });
190
- }
191
- this.ref && this.ref.markForCheck();
192
- }
193
- this.rowSelected.emit($event);
194
- }
195
-
196
- _rowDeselected($event) {
197
- if (this.selectedDiffKey) {
198
- if (this.startPaging) {
199
- return;
200
- }
201
- if ($event.isHeaderCheckboxClicked && Array.isArray($event.data)) {
202
- $event.data.forEach((item) => {
203
- item.isSelected = false;
204
- });
205
- this.selectId = [];
206
- this.dataSource.forEach((data) => {
207
- $event.data.forEach((_data) => {
208
- if (_data[this.selectedDiffKey] === data[this.selectedDiffKey]) {
209
- data.isSelected = false;
210
- }
211
- });
212
- });
213
- } else {
214
- $event.data.isSelected = false;
215
- this.selectId = this.selectId.filter(
216
- (item) =>
217
- item[this.selectedDiffKey] !== $event.data[this.selectedDiffKey]
218
- );
219
- this.dataSource.forEach((data) => {
220
- if (
221
- data[this.selectedDiffKey] === $event.data[this.selectedDiffKey]
222
- ) {
223
- data.isSelected = false;
224
- }
225
- });
226
- }
227
- this.ref && this.ref.markForCheck();
228
- }
229
- this.rowDeselected.emit($event);
230
- }
231
-
232
- _onContextMenu(args) {
233
- this.onContextMenu.emit(args);
234
- }
235
-
236
- _actionBegin(args) {
237
- if (
238
- this.selectedDiffKey &&
239
- (args.requestType === 'paging' ||
240
- args.requestType === 'searching' ||
241
- args.requestType === 'filtering' ||
242
- args.requestType === 'sorting')
243
- ) {
244
- this.startPaging = true;
245
- }
246
- this.actionBegin.emit(args);
247
- }
248
-
249
- search(keywords) {
250
- this.grid.search(keywords);
251
- }
252
- selectRows(indexList: number[]) {
253
- this.grid.selectRows(indexList);
254
- }
255
- selectRow(index) {
256
- this.grid.selectRow(index);
257
- }
258
- getCurrentViewRecords() {
259
- return this.grid.getCurrentViewRecords();
260
- }
261
-
262
- customiseCell($event) {
263
- this.queryCellInfo.emit($event);
264
- }
265
-
266
- contextMenuOpen(args?: BeforeOpenCloseEventArgs): void {
267
- const data = (args as BeforeOpenCloseEventArgs | any).rowInfo.rowData;
268
- if (!data) {
269
- args.cancel = true;
270
- return;
271
- }
272
- let enableItems = [];
273
- let hideItems = [];
274
- this.grid.contextMenuModule.contextMenu.refresh(); // 每次点击按钮弹窗前需再次初始化状态 否则不更新;
275
- this.contextMenuItems.forEach((item: IActionMenuItem) => {
276
- // 用于处理部分按钮disabled的情况
277
- if (
278
- item.disabled ||
279
- (data.disableItem && data.disableItem.includes(item.iconCss))
280
- ) {
281
- enableItems.push(item.text);
282
- // this.grid.contextMenuModule.contextMenu.enableItems(
283
- // [item.text],
284
- // false
285
- // );
286
- }
287
- // 用于处理部分按钮需要hide的情况
288
- if (
289
- item.isHide ||
290
- (data.hideItem && data.hideItem.includes(item.iconCss))
291
- ) {
292
- hideItems.push(item.text);
293
- // this.grid.contextMenuModule.contextMenu.hideItems(
294
- // [item.text],
295
- // false
296
- // );
297
- }
298
- });
299
- this.grid.contextMenuModule.contextMenu.enableItems(enableItems, false);
300
- this.grid.contextMenuModule.contextMenu.hideItems(hideItems, false);
301
- }
302
-
303
- _actionHandler($event) {
304
- if (
305
- this.selectedDiffKey &&
306
- ($event.requestType === 'paging' ||
307
- $event.requestType === 'searching' ||
308
- $event.requestType === 'filtering' ||
309
- $event.requestType === 'sorting')
310
- ) {
311
- this.indexList = [];
312
- setTimeout(() => {
313
- this.chooseRecords();
314
- this.startPaging = false;
315
- this.ref && this.ref.detectChanges();
316
- this.ref && this.ref.markForCheck();
317
- });
318
- }
319
- this.actionHandler.emit($event);
320
- this.actionComplete.emit($event);
321
- }
322
-
323
- private chooseRecords() {
324
- this.indexList = [];
325
- this.dataSource.forEach((data) => {
326
- this.grid.getCurrentViewRecords().forEach((row: any, i) => {
327
- if (
328
- row &&
329
- data[this.selectedDiffKey] === row[this.selectedDiffKey] &&
330
- data.isSelected
331
- ) {
332
- this.indexList.push(i);
333
- }
334
- });
335
- });
336
-
337
- this.grid.selectRows(this.indexList);
338
- }
339
-
340
- _recordClick($event) {
341
- this.recordClick.emit($event);
342
- }
343
- refresh() {
344
- this.grid.refresh();
345
- }
346
- _rowSelecting(e) {
347
- this.rowSelecting.emit(e);
348
- }
349
- refreshColumns() {
350
- this.grid.refreshColumns();
351
- }
352
- refreshHeader() {
353
- this.grid.refreshHeader();
354
- }
355
-
356
- export(excelExportProperties?) {
357
- this.grid.excelExport(excelExportProperties);
358
- }
359
-
360
- getSelectedRecords() {
361
- return this.grid.getSelectedRecords();
362
- }
363
-
364
- _rowDataBound($event) {
365
- if (this.disableSystemRow && $event.data && $event.data.IsSystem) {
366
- $event.row.classList.add('e-disabled');
367
- }
368
- this.rowDataBound.emit($event);
369
- }
370
-
371
- clearSelection() {
372
- this.grid.clearSelection();
373
- }
374
-
375
- excelExport() {
376
- this.grid.excelExport();
377
- }
378
-
379
- addItem() {
380
- this.grid.addRecord({ ...this.defaultRecord, isNew: true }, 0);
381
- setTimeout(() => {
382
- this.grid.selectRow(0);
383
- this.grid.startEdit();
384
- }, 30);
385
- }
386
-
387
- saveItem() {
388
- this.grid.endEdit();
389
- }
390
-
391
- editItem(index) {
392
- setTimeout(() => {
393
- this.grid.selectRow(Number(index));
394
- this.grid.startEdit();
395
- }, 30);
396
- }
397
-
398
- deleteItem(index) {
399
- this.grid.selectRow(Number(index));
400
- var selectedRecord = this.grid.getSelectedRecords()[0] as any;
401
- this.grid.deleteRecord(selectedRecord as string);
402
- }
403
-
404
- cancelItem(index) {
405
- this.grid.closeEdit();
406
- this.deleteItem(index);
407
- }
408
-
409
- public showLoading() {
410
- this.className = 'grid-loading';
411
- this.ref && this.ref.markForCheck();
412
- this.ref && this.ref.detectChanges();
413
- }
414
-
415
- public hideLoading() {
416
- this.className = '';
417
- this.ref && this.ref.markForCheck();
418
- this.ref && this.ref.detectChanges();
419
- }
420
- }
@@ -1,59 +0,0 @@
1
- import { ContextMenuItemModel } from "@syncfusion/ej2-angular-grids";
2
-
3
- export interface IColumnField {
4
- columnName: string;
5
- columnDisplayName: string;
6
- visible: boolean;
7
- /**
8
- * sample: { class: 'hideColumnFilterClass' }
9
- * 可以考虑在部分情况下给column增加class等attribute
10
- */
11
- customAttributes?: string;
12
- // 不填默认是Left
13
- textAlign?: "Left" | "Right" | "Center";
14
- width?: number;
15
- dataType?: string;
16
- format?: string;
17
- translationCode?: string;
18
- showColumnMenu?: boolean;
19
- showTemplate?: boolean;
20
- allowFiltering?: boolean;
21
- allowSorting?: boolean;
22
- allowEditing?: boolean;
23
- minWidth?: number | string;
24
- editType?: string;
25
- dropdownParams?: any;
26
- dateComparer?: any;
27
- sortComparer?: any;
28
- clipMode?: string;
29
- filter?: any;
30
- colName?: string;
31
- validationRules?: any;
32
- }
33
-
34
- export interface IActionMenuItem extends ContextMenuItemModel {
35
- disabled?: boolean;
36
- isHide?: boolean;
37
- }
38
-
39
- export enum ButtonColorType {
40
- PRIMARY = "primary",
41
- CANCEL = "cancel",
42
- }
43
-
44
- enum IconPosition {
45
- FRONT = "front",
46
- BEHIND = "behind",
47
- }
48
-
49
- export interface BaseButton {
50
- label: string;
51
- type?: ButtonColorType;
52
- icon?: string;
53
- iconPosition?: IconPosition;
54
- callMethod?: string;
55
- translationCode?: string;
56
- value?: any;
57
- }
58
-
59
- export interface DrawerButton extends BaseButton {}