dpot-ui 0.5.12 → 0.5.14

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 (2) hide show
  1. package/dist/index.es.js +47 -42
  2. 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
- let i = [];
25426
- const e = new rp.Workbook(), t = 20;
25427
- this.ComputResult.map((n) => {
25428
- 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 }] });
25429
- 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 || {})));
25430
- const o = n.head.map((a) => Math.max(...a.map((r) => r.map((c) => (c._mergeX_ || 0) + 1).reduce((c, d) => c + d, 0))));
25431
- if ([...Array(n.headRow).keys()].forEach((a) => {
25432
- let r = [];
25433
- n.head.map((d, h) => {
25434
- d[a] && d[a].forEach((f, m) => {
25435
- 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;
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.addRow(r.map((d) => "")).eachCell({ includeEmpty: !0 }, (d, h) => {
25438
- if (r[h]) {
25439
- (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));
25440
- const f = s.getCell(r[h]._gps_);
25441
- 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);
25442
- }
25443
- });
25444
- }), s.views[0].ySplit = s.views[0].ySplit || n.headRow + (n.title ? 1 : 0), n.body.forEach((a) => {
25445
- const r = Math.max(...a.map((c) => c.length));
25446
- [...Array(r).keys()].forEach((c, d) => {
25447
- s.addRow(a.map((f) => "")).eachCell({ includeEmpty: !0 }, (f, m) => {
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
- const b = s.getCell(a[m - 1][d]._gps_);
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
- }), s.columns = n.columnResult.map((a) => ({ width: (a.style || {}).width || 20 })), s.eachRow({ includeEmpty: !0 }, (a) => {
25459
- n.title && a === 1 ? a.height = Math.max((n.style || {}).fontSize * 1.5 || 24, t) : a.height = n.rowHeight || t;
25460
- }), n.waterText) {
25461
- const a = document.createElement("canvas");
25462
- a.width = Math.max(n.waterText.length, 5) * (parseInt((n.waterStyle || {}).font) || 24) * 1.5, a.height = a.width;
25463
- const r = a.getContext("2d"), c = n.waterStyle || { font: "24px Arial", fillStyle: "rgba(0, 0, 0, 0.1)", textAlign: "center", textBaseline: "middle" };
25464
- 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);
25465
- const d = a.toDataURL("image/png").replace(/^data:image\/[a-z]+;base64,/, ""), h = e.addImage({ base64: d, extension: "png" });
25466
- s.addBackgroundImage(h);
25467
- }
25468
- }), e.xlsx.writeBuffer().then((n) => {
25469
- ip.saveAs(new Blob([n], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }), this.fileName);
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}.xlsx`);
25474
+ });
25470
25475
  });
25471
25476
  },
25472
25477
  // 转换样式
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dpot-ui",
3
3
  "private": false,
4
- "version": "0.5.12",
4
+ "version": "0.5.14",
5
5
  "author": "Jeesn",
6
6
  "main": "./dist/index.es.js",
7
7
  "module": "./dist/index.es.js",