@lambo-design/shared 1.0.0-beta.316 → 1.0.0-beta.318

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.
@@ -207,4 +207,20 @@
207
207
 
208
208
  .column-highlight {
209
209
  background: var(--ag-selected-row-background-color);
210
- }
210
+ }
211
+ .heard-highlight {
212
+ background: var(--ag-selected-row-background-color) !important;
213
+ border-bottom: 2px solid rgb(120, 180, 99) !important;
214
+ color: #000 !important;
215
+ }
216
+ .cellClick-highlight {
217
+ background: rgb(120, 180, 99) !important;
218
+ font-weight: 700 !important;
219
+ color: #000 !important;
220
+ }
221
+ .cellClick-index-highlight {
222
+ border-left: 2px solid rgb(120, 180, 99) !important;
223
+ background: var(--ag-selected-row-background-color) !important;
224
+ font-weight: 700 !important;
225
+ color: #000 !important;
226
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design/shared",
3
- "version": "1.0.0-beta.316",
3
+ "version": "1.0.0-beta.318",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
package/utils/excel.js CHANGED
@@ -85,6 +85,14 @@ let bodyStyle = {
85
85
  alignment: {vertical: "center"}
86
86
  }
87
87
 
88
+ /**
89
+ * 表格底部扩展行样式
90
+ * @type {alignment: {vertical: string}}
91
+ */
92
+ let footerStyle = {
93
+ alignment: {vertical: "center"}
94
+ }
95
+
88
96
  /**
89
97
  * 过滤掉filterData中titleRules、typeRules相关的列
90
98
  * @param filterData
@@ -304,7 +312,7 @@ export const enums_to_value = (enums,jsonData)=>{
304
312
  }
305
313
  }
306
314
 
307
- function auto_width(ws, data) {
315
+ function auto_width(ws, data, startRow=0) {
308
316
  /*set worksheet max width per col*/
309
317
  const colWidth = data.map(row => row.map(val => {
310
318
  /*if null/undefined*/
@@ -320,7 +328,12 @@ function auto_width(ws, data) {
320
328
  }))
321
329
  /*start in the first row*/
322
330
  let result = colWidth[0];
323
- for (let i = 1; i < colWidth.length; i++) {
331
+ if (startRow > 0) {
332
+ // 排除header中title和search数据
333
+ result = colWidth[startRow];
334
+ }
335
+ // 计算列宽时,查询条件行数据不参与计算
336
+ for (let i = startRow > 0 ? startRow : 1; i < colWidth.length; i++) {
324
337
  for (let j = 0; j < colWidth[i].length; j++) {
325
338
  if (result[j]['wch'] < colWidth[i][j]['wch']) {
326
339
  result[j]['wch'] = colWidth[i][j]['wch'] > 7 ? colWidth[i][j]['wch'] : 7;
@@ -451,7 +464,7 @@ function merge_content({ws, tableData, spanColumnKeys, startRow}) {
451
464
  ws['!merges'] = ws['!merges'].concat(mergeData)
452
465
  }
453
466
 
454
- function add_style({ws, title, startRow}) {
467
+ function add_style({ws, title, startRow, footerRow}) {
455
468
 
456
469
  // 补充空白数据
457
470
  let rangs = ws['!ref'].split(":");
@@ -475,9 +488,16 @@ function add_style({ws, title, startRow}) {
475
488
  })
476
489
 
477
490
  let titleReg = new RegExp("^[A-Z]1$", "im");
478
- let titleExtReg = new RegExp("^[A-Z][2-" + parseInt(startRow>0?startRow:2) + "]$", "im");
491
+ let titleExtReg = new RegExp("^[A-Z][1-" + parseInt(startRow>0?startRow:2) + "]$", "im");
479
492
  let headReg = new RegExp("^[A-Z]+[" + parseInt(startRow + 1) + "-" + parseInt(startRow + title.length) + "]$", "im");
480
493
  let bodyReg = new RegExp("^[A-Z]+([" + parseInt(startRow + title.length) + "-9]|[1-9]\\d+)$", "im");
494
+ let footerExtReg = null
495
+
496
+ if (footerRow === 1) {
497
+ // 底部扩展最后一行正则表达式 该行样式需要无边框
498
+ footerExtReg = new RegExp("^[A-Z]+" + rowSum + "$", "im");
499
+ }
500
+
481
501
  Object.keys(ws).forEach(item => {
482
502
  if(titleReg.test(item)&&startRow>0){
483
503
  /**
@@ -494,6 +514,11 @@ function add_style({ws, title, startRow}) {
494
514
  * 加载表头样式:蓝色背景,水平垂直居中,边框
495
515
  */
496
516
  ws[item].s = headStyle
517
+ } else if (footerExtReg && footerExtReg.test(item)) {
518
+ /**
519
+ * 加载表尾样式:无边框,垂直居中
520
+ */
521
+ ws[item].s = footerStyle
497
522
  } else if (bodyReg.test(item)) {
498
523
  /**
499
524
  * 表体样式: 垂直居中,边框
@@ -561,7 +586,8 @@ export const export_array_to_excel = ({key, data, title, header = [], footer = [
561
586
 
562
587
  const ws = XLSX.utils.aoa_to_sheet(arr);
563
588
  if (autoWidth) {
564
- auto_width(ws, arr);
589
+ // 计算列宽时,查询条件行数据不参与计算
590
+ auto_width(ws, arr, header.length);
565
591
  }
566
592
  // 合并表头
567
593
  if (!ws['!merges']) ws['!merges'] = [];
@@ -569,9 +595,8 @@ export const export_array_to_excel = ({key, data, title, header = [], footer = [
569
595
  merge_cell({ws, data:title, startRow: header.length})
570
596
  }
571
597
  merge_cell({ws,data:header,startRow: 0 })
572
- console.log(data)
573
598
  merge_content(ws, data, spanColumns, title.length + header.length)
574
- add_style({ws, title, startRow: header.length})
599
+ add_style({ws, title, startRow: header.length, footerRow: footer.length})
575
600
  XLSX.utils.book_append_sheet(wb, ws, '');
576
601
  if(format === 'csv'){
577
602
  XLSX.writeFile(wb, filename + '.' + format,{
package/utils/style.js CHANGED
@@ -1,24 +1,24 @@
1
- const SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g
2
- const MOZ_HACK_REGEXP = /^moz([A-Z])/
3
-
4
- function camelCase(name) {
5
- return name
6
- .replace(SPECIAL_CHARS_REGEXP, function (_, separator, letter, offset) {
7
- return offset ? letter.toUpperCase() : letter
8
- })
9
- .replace(MOZ_HACK_REGEXP, 'Moz$1')
10
- }
11
- // getStyle
12
- export function getStyle(element, styleName) {
13
- if (!element || !styleName) return null
14
- styleName = camelCase(styleName)
15
- if (styleName === 'float') {
16
- styleName = 'cssFloat'
17
- }
18
- try {
19
- const computed = document.defaultView.getComputedStyle(element, '')
20
- return element.style[styleName] || computed ? computed[styleName] : null
21
- } catch (e) {
22
- return element.style[styleName]
23
- }
24
- }
1
+ const SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g
2
+ const MOZ_HACK_REGEXP = /^moz([A-Z])/
3
+
4
+ function camelCase(name) {
5
+ return name
6
+ .replace(SPECIAL_CHARS_REGEXP, function (_, separator, letter, offset) {
7
+ return offset ? letter.toUpperCase() : letter
8
+ })
9
+ .replace(MOZ_HACK_REGEXP, 'Moz$1')
10
+ }
11
+ // getStyle
12
+ export function getStyle(element, styleName) {
13
+ if (!element || !styleName) return null
14
+ styleName = camelCase(styleName)
15
+ if (styleName === 'float') {
16
+ styleName = 'cssFloat'
17
+ }
18
+ try {
19
+ const computed = document.defaultView.getComputedStyle(element, '')
20
+ return element.style[styleName] || computed ? computed[styleName] : null
21
+ } catch (e) {
22
+ return element.style[styleName]
23
+ }
24
+ }
@@ -1,7 +1,7 @@
1
- let transferIndex = 1000
2
-
3
- function transferIncrease() {
4
- transferIndex++
5
- }
6
-
7
- export { transferIndex, transferIncrease }
1
+ let transferIndex = 1000
2
+
3
+ function transferIncrease() {
4
+ transferIndex++
5
+ }
6
+
7
+ export { transferIndex, transferIncrease }