@chenchaolong/plugin-trade-compliance-workbench 1.0.33 → 1.0.35
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.
- package/dist/lib/remote-components/trade-compliance-workbench/app.css +1 -1
- package/dist/lib/remote-components/trade-compliance-workbench/app.js +4 -4
- package/dist/lib/remote-components/trade-compliance-workbench/editor-source.mjs +84 -2
- package/dist/lib/remote-components/trade-compliance-workbench/editor.js +101 -101
- package/dist/lib/remote-ui/pages/catalogs.css +2 -2
- package/dist/lib/remote-ui/pages/contracts.js +1 -1
- package/dist/lib/remote-ui/pages/contracts.js.map +1 -1
- package/dist/lib/remote-ui/pages/files-prototype.css +12 -2
- package/dist/lib/remote-ui/pages/home.d.ts.map +1 -1
- package/dist/lib/remote-ui/pages/home.js +8 -8
- package/dist/lib/remote-ui/pages/home.js.map +1 -1
- package/dist/lib/remote-ui/pages/procurement-contracts.css +6 -10
- package/dist/lib/remote-ui/pages/settings.css +7 -1
- package/dist/lib/remote-ui/pages/settings.d.ts.map +1 -1
- package/dist/lib/remote-ui/pages/settings.js +1 -1
- package/dist/lib/remote-ui/pages/settings.js.map +1 -1
- package/dist/lib/remote-ui/styles.css +31 -23
- package/dist/lib/sales-file.service.js +3 -3
- package/dist/lib/sales-file.service.js.map +1 -1
- package/package.json +21 -21
|
@@ -32,13 +32,95 @@ function toUniverSnapshot(workbook) {
|
|
|
32
32
|
const rowIndex = rowNumber - 1; const columnIndex = columnNumber - 1
|
|
33
33
|
cellData[rowIndex] ||= {}
|
|
34
34
|
const raw = cell.value && typeof cell.value === 'object' && 'result' in cell.value ? cell.value.result : cell.value
|
|
35
|
-
cellData[rowIndex][columnIndex] = { v: raw instanceof Date ? raw.toISOString().slice(0, 10) : raw == null ? '' : String(raw), t: typeof raw === 'number' ? 2 : 1 }
|
|
35
|
+
cellData[rowIndex][columnIndex] = { v: raw instanceof Date ? raw.toISOString().slice(0, 10) : raw == null ? '' : String(raw), t: typeof raw === 'number' ? 2 : 1, s: cellStyle(cell) }
|
|
36
36
|
}))
|
|
37
|
-
sheets[id] = { id, name: worksheet.name, rowCount: Math.max(worksheet.rowCount + 20, 100), columnCount: Math.max(worksheet.columnCount + 5, 26), cellData, mergeData:
|
|
37
|
+
sheets[id] = { id, name: worksheet.name, rowCount: Math.max(worksheet.rowCount + 20, 100), columnCount: Math.max(worksheet.columnCount + 5, 26), cellData, mergeData: mergeData(worksheet), rowData: rowData(worksheet), columnData: columnData(worksheet) }
|
|
38
38
|
})
|
|
39
39
|
return { id: `trade-${Date.now()}`, name: '销售文件审核', appVersion: '1.0.0', locale: 'zhCN', sheetOrder, sheets }
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
function mergeData(worksheet) {
|
|
43
|
+
return Object.values(worksheet._merges || {}).map(merge => {
|
|
44
|
+
const model = merge.model || merge
|
|
45
|
+
return { startRow: model.top - 1, endRow: model.bottom - 1, startColumn: model.left - 1, endColumn: model.right - 1 }
|
|
46
|
+
}).filter(range => range.endRow >= range.startRow && range.endColumn >= range.startColumn)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function rowData(worksheet) {
|
|
50
|
+
const rows = {}
|
|
51
|
+
worksheet.eachRow({ includeEmpty: true }, row => {
|
|
52
|
+
if (row.height) rows[row.number - 1] = { h: row.height * 96 / 72 }
|
|
53
|
+
})
|
|
54
|
+
return rows
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function columnData(worksheet) {
|
|
58
|
+
const columns = {}
|
|
59
|
+
worksheet.columns.forEach((column, index) => {
|
|
60
|
+
if (column.width) columns[index] = { w: Math.max(1, Math.floor(column.width * 7 + 5)) }
|
|
61
|
+
})
|
|
62
|
+
return columns
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function cellStyle(cell) {
|
|
66
|
+
const style = {}
|
|
67
|
+
const font = cell.font || {}
|
|
68
|
+
const alignment = cell.alignment || {}
|
|
69
|
+
const fill = cell.fill || {}
|
|
70
|
+
const border = cell.border || {}
|
|
71
|
+
if (font.name) style.ff = font.name
|
|
72
|
+
if (font.size) style.fs = font.size
|
|
73
|
+
if (font.bold) style.bl = 1
|
|
74
|
+
if (font.italic) style.it = 1
|
|
75
|
+
if (font.underline) style.ul = { s: 1 }
|
|
76
|
+
if (font.strike) style.st = { s: 1 }
|
|
77
|
+
const fontColor = color(font.color)
|
|
78
|
+
if (fontColor) style.cl = { rgb: fontColor }
|
|
79
|
+
const fillColorValue = fillColor(fill)
|
|
80
|
+
if (fillColorValue) style.bg = { rgb: fillColorValue }
|
|
81
|
+
const horizontal = horizontalAlign(alignment.horizontal)
|
|
82
|
+
if (horizontal) style.ht = horizontal
|
|
83
|
+
const vertical = verticalAlign(alignment.vertical)
|
|
84
|
+
if (vertical) style.vt = vertical
|
|
85
|
+
if (alignment.wrapText) style.tb = 2
|
|
86
|
+
const borders = borderStyle(border)
|
|
87
|
+
if (borders) style.bd = borders
|
|
88
|
+
return Object.keys(style).length ? style : undefined
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function color(value) {
|
|
92
|
+
const argb = typeof value?.argb === 'string' ? value.argb : ''
|
|
93
|
+
const raw = argb.length === 8 ? argb.substring(2) : argb
|
|
94
|
+
const rgb = raw.trim().replace(/^#/, '').toUpperCase()
|
|
95
|
+
if (!/^[0-9A-F]{6}$/.test(rgb)) return undefined
|
|
96
|
+
return `#${rgb}`
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function fillColor(fill) {
|
|
100
|
+
if (!fill || fill.type !== 'pattern' || fill.pattern === 'none') return undefined
|
|
101
|
+
const normalized = color(fill.fgColor || fill.bgColor)
|
|
102
|
+
if (normalized === '#FFFFFF') return undefined
|
|
103
|
+
return normalized
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function horizontalAlign(value) {
|
|
107
|
+
return { left: 1, center: 2, right: 3, justify: 4 }[value] || undefined
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function verticalAlign(value) {
|
|
111
|
+
return { top: 1, middle: 2, bottom: 3 }[value] || undefined
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function borderStyle(border) {
|
|
115
|
+
const result = {}
|
|
116
|
+
const map = { top: 't', right: 'r', bottom: 'b', left: 'l' }
|
|
117
|
+
for (const [excelKey, univerKey] of Object.entries(map)) {
|
|
118
|
+
const side = border[excelKey]
|
|
119
|
+
if (side?.style) result[univerKey] = { s: side.style === 'medium' || side.style === 'thick' ? 2 : 1, cl: { rgb: color(side.color) || '#000000' } }
|
|
120
|
+
}
|
|
121
|
+
return Object.keys(result).length ? result : undefined
|
|
122
|
+
}
|
|
123
|
+
|
|
42
124
|
function applyUniverSnapshot(workbook, snapshot) {
|
|
43
125
|
for (const id of snapshot.sheetOrder || Object.keys(snapshot.sheets || {})) {
|
|
44
126
|
const source = snapshot.sheets[id]; const target = workbook.getWorksheet(source.name)
|