ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
export const defaultCellProperties = {
  text: {
    leftParentCellType: 'none',
    leftParentCellCustomRowName: '',
    leftParentCellCustomColName: '',
    topParentCellType: 'none',
    topParentCellCustomRowName: '',
    topParentCellCustomColName: '',
  },
  parameter: {
    field: '',
    leftParentCellType: 'none',
    leftParentCellCustomRowName: '',
    leftParentCellCustomColName: '',
    topParentCellType: 'none',
    topParentCellCustomRowName: '',
    topParentCellCustomColName: '',
  },
  dataSource: {
    field: '',
    polymerizationType: '1',
    summaryType: 'sum',
    groupType: 'default',
    fillDirection: 'portrait',
    leftParentCellType: 'default',
    leftParentCellCustomRowName: '',
    leftParentCellCustomColName: '',
    topParentCellType: 'default',
    topParentCellCustomRowName: '',
    topParentCellCustomColName: '',
    fillEmptyRows: false,
    fillEmptyNum: 1,
    displayType: 'default',
    qrCodeOption: {
      color: {
        dark: '#000000',
        light: '#f4f5f6',
      },
      errorCorrectionLevel: 'L',
    },
    jsbarcodeOption: {
      format: 'code128',
      displayValue: false,
      lineColor: '#000000',
      background: '#f4f5f6',
      width: 4,
      margin: 15,
      font: 'Arial',
      fontSize: 18,
      textAlign: 'center',
      textPosition: 'bottom',
    },
  },
  qrCode: {
    field: '二维码',
    qrCodeOption: {
      type: 'static',
      color: {
        dark: '#000000',
        light: '#f4f5f6',
      },
      errorCorrectionLevel: 'M',
    },
  },
  jsbarcode: {
    field: '10241024',
    jsbarcodeOption: {
      type: 'static', // 这里预留动态
      format: 'code128', // 设置条形码类型为 EAN13
      displayValue: false, // 显示数字
      lineColor: '#000000', // 设置线条为蓝色
      background: '#f4f5f6', // 设置背景色为浅灰色
      width: 4, // 设置条形码宽度
      margin: 15, // 设置条形码四周边距
      font: 'Arial', // 设置字体
      fontSize: 18, // 设置字体大小
      textAlign: 'center', // 设置文本居中
      textPosition: 'bottom', // 设置文本在条形码底部
    },
  },
};
 
// 拼接url
export function getFloatImageUrl(data, url) {
  for (const key in data) {
    const type = data[key].source;
    const src = data[key].option.src;
    if (src && type == 1) data[key].option.src = url + src;
  }
  return data;
}
 
// 拼接快照url
export function getFloatUrl(list, reportApiUrl, floatImages = {}) {
  const item: any = {};
  if (!list.length) return;
 
  for (const [_index, element] of list.entries()) {
    if (element.name === 'SHEET_DRAWING_PLUGIN') {
      element.data = element.data ? JSON.parse(element.data) : {};
      for (const key in element.data) {
        for (const imageKey in element.data[key].data) {
          const componentKey = element.data[key].data[imageKey].componentKey;
          if (componentKey == 'JnpfUniverFloatEchart') continue;
 
          const source = floatImages[imageKey]?.option?.src;
 
          if (source) {
            element.data[key].data[imageKey].source = source;
            element.data[key].data[imageKey].imageSourceType = 'BASE64';
          }
        }
      }
      element.data = JSON.stringify(element.data);
    }
  }
  item.list = list;
  item.floatImages = floatImages;
  return item;
}
 
// 截取url前缀
export function interceptUrl(data, reportApiUrl) {
  for (const key in data) {
    const type = data[key].source;
    let src = data[key].option.src;
    if (src && type == 1) {
      src = src.split(reportApiUrl)[1];
      data[key].option.src = src;
    }
  }
  return data;
}
 
/**
 * 根据索引值获取字母字符串。
 * @param index {number} - 输入的索引值(如 0, 1, 26, 27 等)。
 * @returns {string} - 对应的字母字符串(如 "A", "B", "AA", "AB" 等)。
 */
export const getAlphabetFromIndexRule = (index: number): string => {
  const base = 26; // 字母表的长度
  const charCodeA = 'A'.codePointAt(0);
 
  let result = '';
  index += 1; // 转为从 1 开始的规则
 
  while (index > 0) {
    const remainder = (index - 1) % base;
    result = String.fromCodePoint((charCodeA || 0) + remainder) + result;
    index = Math.floor((index - 1) / base);
  }
 
  return result;
};