dpot-ui 0.5.12 → 0.5.13
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/index.es.js +47 -42
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -25352,6 +25352,8 @@ const ap = {
|
|
|
25352
25352
|
isDownload: Boolean,
|
|
25353
25353
|
// 空字段填充
|
|
25354
25354
|
emptyText: String,
|
|
25355
|
+
// 实时拉取数据
|
|
25356
|
+
loadData: Function,
|
|
25355
25357
|
// 工作表
|
|
25356
25358
|
sheetData: {
|
|
25357
25359
|
type: Array,
|
|
@@ -25422,51 +25424,54 @@ const ap = {
|
|
|
25422
25424
|
methods: {
|
|
25423
25425
|
// 导出
|
|
25424
25426
|
handleExport() {
|
|
25425
|
-
|
|
25426
|
-
|
|
25427
|
-
|
|
25428
|
-
const
|
|
25429
|
-
|
|
25430
|
-
|
|
25431
|
-
|
|
25432
|
-
|
|
25433
|
-
n.
|
|
25434
|
-
|
|
25435
|
-
|
|
25427
|
+
return ce(this, null, function* () {
|
|
25428
|
+
!this.sheetData.length && this.loadData && (yield this.loadData());
|
|
25429
|
+
let i = [];
|
|
25430
|
+
const e = new rp.Workbook(), t = 20;
|
|
25431
|
+
this.ComputResult.map((n) => {
|
|
25432
|
+
const u = i.filter((a) => a === n.name).length, l = u ? `_${u}` : "", s = e.addWorksheet(`${n.name || "-"}${l}`, { views: [{ state: "frozen", xSplit: n.xSplit || 0, ySplit: n.ySplit || 0 }] });
|
|
25433
|
+
i.push(n.name || "-"), n.title && (s.addRow([n.title]), s.mergeCells(1, 1, 1, n.head.map((a) => a[0].map((r) => (r._mergeX_ || 0) + 1)).flat().reduce((a, r) => a + r, 0)), this.handleComputStyle(s.getCell("A1"), n, Zt({ fontSize: 16 }, n.style || {})));
|
|
25434
|
+
const o = n.head.map((a) => Math.max(...a.map((r) => r.map((c) => (c._mergeX_ || 0) + 1).reduce((c, d) => c + d, 0))));
|
|
25435
|
+
if ([...Array(n.headRow).keys()].forEach((a) => {
|
|
25436
|
+
let r = [];
|
|
25437
|
+
n.head.map((d, h) => {
|
|
25438
|
+
d[a] && d[a].forEach((f, m) => {
|
|
25439
|
+
r[o.slice(0, h).reduce((b, p) => b + p, 0) + d[a].slice(0, m).map((b) => (b._mergeX_ || 0) + 1).reduce((b, p) => b + p, 0) + 1] = f;
|
|
25440
|
+
});
|
|
25441
|
+
}), s.addRow(r.map((d) => "")).eachCell({ includeEmpty: !0 }, (d, h) => {
|
|
25442
|
+
if (r[h]) {
|
|
25443
|
+
(r[h]._mergeX_ || r[h]._mergeY_) && s.mergeCells(a + (n.title ? 1 : 0) + 1, h, a + (n.title ? 1 : 0) + 1 + (r[h]._mergeY_ || 0), h + (r[h]._mergeX_ || 0));
|
|
25444
|
+
const f = s.getCell(r[h]._gps_);
|
|
25445
|
+
f.value = r[h].value, this.handleComputStyle(f, Me(Zt({}, r[h]), { style: Zt(Zt({}, n.columnResult[h - 1].style || {}), r[h].style || {}) }), n.style);
|
|
25446
|
+
}
|
|
25436
25447
|
});
|
|
25437
|
-
}), s.
|
|
25438
|
-
|
|
25439
|
-
|
|
25440
|
-
|
|
25441
|
-
|
|
25442
|
-
|
|
25443
|
-
|
|
25444
|
-
|
|
25445
|
-
|
|
25446
|
-
|
|
25447
|
-
|
|
25448
|
-
if (a[m - 1][d]) {
|
|
25449
|
-
if (a[m - 1][d]._mergeY_) {
|
|
25450
|
-
const [p, g] = [a[m - 1][d]._gps_[0], Number(a[m - 1][d]._gps_.slice(1))];
|
|
25451
|
-
s.mergeCells(a[m - 1][d]._gps_, `${p}${g + a[m - 1][d]._mergeY_}`);
|
|
25448
|
+
}), s.views[0].ySplit = s.views[0].ySplit || n.headRow + (n.title ? 1 : 0), n.body.forEach((a) => {
|
|
25449
|
+
const r = Math.max(...a.map((c) => c.length));
|
|
25450
|
+
[...Array(r).keys()].forEach((c, d) => {
|
|
25451
|
+
s.addRow(a.map((f) => "")).eachCell({ includeEmpty: !0 }, (f, m) => {
|
|
25452
|
+
if (a[m - 1][d]) {
|
|
25453
|
+
if (a[m - 1][d]._mergeY_) {
|
|
25454
|
+
const [p, g] = [a[m - 1][d]._gps_[0], Number(a[m - 1][d]._gps_.slice(1))];
|
|
25455
|
+
s.mergeCells(a[m - 1][d]._gps_, `${p}${g + a[m - 1][d]._mergeY_}`);
|
|
25456
|
+
}
|
|
25457
|
+
const b = s.getCell(a[m - 1][d]._gps_);
|
|
25458
|
+
b.value = a[m - 1][d].value ? a[m - 1][d].value : [void 0, null].includes(a[m - 1][d].value) ? this.emptyText : a[m - 1][d].value, this.handleComputStyle(b, Me(Zt({}, a[m - 1][d]), { style: Zt(Zt({}, n.columnResult[m - 1].style || {}), a[m - 1][d].style || {}) }), n.style);
|
|
25452
25459
|
}
|
|
25453
|
-
|
|
25454
|
-
b.value = a[m - 1][d].value ? a[m - 1][d].value : [void 0, null].includes(a[m - 1][d].value) ? this.emptyText : a[m - 1][d].value, this.handleComputStyle(b, Me(Zt({}, a[m - 1][d]), { style: Zt(Zt({}, n.columnResult[m - 1].style || {}), a[m - 1][d].style || {}) }), n.style);
|
|
25455
|
-
}
|
|
25460
|
+
});
|
|
25456
25461
|
});
|
|
25457
|
-
})
|
|
25458
|
-
|
|
25459
|
-
|
|
25460
|
-
|
|
25461
|
-
|
|
25462
|
-
|
|
25463
|
-
|
|
25464
|
-
|
|
25465
|
-
|
|
25466
|
-
|
|
25467
|
-
}
|
|
25468
|
-
|
|
25469
|
-
|
|
25462
|
+
}), s.columns = n.columnResult.map((a) => ({ width: (a.style || {}).width || 20 })), s.eachRow({ includeEmpty: !0 }, (a) => {
|
|
25463
|
+
n.title && a === 1 ? a.height = Math.max((n.style || {}).fontSize * 1.5 || 24, t) : a.height = n.rowHeight || t;
|
|
25464
|
+
}), n.waterText) {
|
|
25465
|
+
const a = document.createElement("canvas");
|
|
25466
|
+
a.width = Math.max(n.waterText.length, 5) * (parseInt((n.waterStyle || {}).font) || 24) * 1.5, a.height = a.width;
|
|
25467
|
+
const r = a.getContext("2d"), c = n.waterStyle || { font: "24px Arial", fillStyle: "rgba(0, 0, 0, 0.1)", textAlign: "center", textBaseline: "middle" };
|
|
25468
|
+
r.font = c.font, r.fillStyle = c.fillStyle, r.textAlign = c.textAlign, r.textBaseline = c.textBaseline, r.translate(0, 0), r.rotate(-45 * Math.PI / 180), r.fillText(n.waterText, 10, a.height - 10);
|
|
25469
|
+
const d = a.toDataURL("image/png").replace(/^data:image\/[a-z]+;base64,/, ""), h = e.addImage({ base64: d, extension: "png" });
|
|
25470
|
+
s.addBackgroundImage(h);
|
|
25471
|
+
}
|
|
25472
|
+
}), e.xlsx.writeBuffer().then((n) => {
|
|
25473
|
+
ip.saveAs(new Blob([n], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }), this.fileName);
|
|
25474
|
+
});
|
|
25470
25475
|
});
|
|
25471
25476
|
},
|
|
25472
25477
|
// 转换样式
|