tor-univer-sheet 1.0.16 → 1.0.18

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.
@@ -1,4 +1,4 @@
1
- import h from "dayjs";
1
+ import D from "dayjs";
2
2
  import { CellValueType as O } from "@univerjs/presets";
3
3
  import G from "decimal.js";
4
4
  const X = (t, o) => {
@@ -113,7 +113,7 @@ async function tt(t, o) {
113
113
  case "year":
114
114
  if (R(o))
115
115
  return Promise.resolve(o);
116
- const e = h(o);
116
+ const e = D(o);
117
117
  if (!e.isValid())
118
118
  return Promise.reject("无效的日期格式");
119
119
  const r = e.year(), i = `${r}-01`, n = `${r}-12`;
@@ -121,19 +121,19 @@ async function tt(t, o) {
121
121
  case "month":
122
122
  if (R(o))
123
123
  return Promise.resolve(o);
124
- const v = h(o);
124
+ const v = D(o);
125
125
  if (!v.isValid())
126
126
  return Promise.reject("无效的日期格式");
127
- const l = v.startOf("month").format("YYYY-MM-DD"), Y = v.endOf("month").format("YYYY-MM-DD");
128
- return Promise.resolve([l, Y]);
127
+ const l = v.startOf("month").format("YYYY-MM-DD"), y = v.endOf("month").format("YYYY-MM-DD");
128
+ return Promise.resolve([l, y]);
129
129
  case "day":
130
130
  if (R(o))
131
131
  return Promise.resolve(o);
132
- const f = h(o);
132
+ const f = D(o);
133
133
  if (!f.isValid())
134
134
  return Promise.reject("无效的日期格式");
135
- const N = f.startOf("day").format("YYYY-MM-DD HH:mm:ss"), c = f.endOf("day").format("YYYY-MM-DD HH:mm:ss");
136
- return Promise.resolve([N, c]);
135
+ const N = f.startOf("day").format("YYYY-MM-DD HH:mm:ss"), m = f.endOf("day").format("YYYY-MM-DD HH:mm:ss");
136
+ return Promise.resolve([N, m]);
137
137
  default:
138
138
  return Promise.reject("不支持的周期类型");
139
139
  }
@@ -146,7 +146,7 @@ function j(t, o, e) {
146
146
  day: "YYYY-MM-DD",
147
147
  hour: "HH:mm:ss"
148
148
  }[e];
149
- return ["day", "hour"].includes(e) ? h(o, r).diff(h(t, r), e) + 1 : h(o, r).diff(h(t, r), e);
149
+ return ["day", "hour"].includes(e) ? D(o, r).diff(D(t, r), e) + 1 : D(o, r).diff(D(t, r), e);
150
150
  }
151
151
  function A(t, o, e) {
152
152
  const r = {
@@ -155,7 +155,7 @@ function A(t, o, e) {
155
155
  day: "YYYY-MM-DD",
156
156
  hour: "HH:mm:ss"
157
157
  }[e];
158
- return h(t).subtract(o, e).format(r);
158
+ return D(t).subtract(o, e).format(r);
159
159
  }
160
160
  function H(t, o, e, r) {
161
161
  const i = {
@@ -164,9 +164,9 @@ function H(t, o, e, r) {
164
164
  day: "YYYY-MM-DD",
165
165
  hour: "YYYY-MM-DD HH:mm:ss"
166
166
  }[o];
167
- return h(t, i).add(e * r, o).format(i);
167
+ return D(t, i).add(e * r, o).format(i);
168
168
  }
169
- function D(t, o, e) {
169
+ function b(t, o, e) {
170
170
  return t[o] || (t[o] = {}), t[o][e] || (t[o][e] = {}), t[o][e];
171
171
  }
172
172
  async function et(t) {
@@ -175,12 +175,12 @@ async function et(t) {
175
175
  const o = Object.entries(t).reduce((e, r) => {
176
176
  const [i, n] = r;
177
177
  for (const [v, l] of Object.entries(n)) {
178
- const { custom: Y, v: f } = l;
179
- if (!Y) continue;
180
- const { cellType: N } = Y;
181
- if (N === "indicator") {
182
- const c = D(e, i, v);
183
- c.custom = Y, c.v = f;
178
+ const { custom: y, v: f, t: N, s: m } = l;
179
+ if (!y) continue;
180
+ const { cellType: Y } = y;
181
+ if (Y === "indicator") {
182
+ const d = b(e, i, v);
183
+ d.custom = y, d.v = f, d.t = N, d.s = m;
184
184
  }
185
185
  }
186
186
  return e;
@@ -194,103 +194,103 @@ function K({
194
194
  initColNum: r,
195
195
  cellData: i
196
196
  }) {
197
- const { rangeData: n, currentDay: v, extraArgs: l } = o, Y = l?.teamData || {}, { cycleType: f, timeIncrement: N, forwardPush: c, copyType: M, copyInterval: x, defaultShift: P } = i.custom;
198
- let b = 0;
197
+ const { rangeData: n, currentDay: v, extraArgs: l } = o, y = l?.teamData || {}, { cycleType: f, timeIncrement: N, forwardPush: m, copyType: Y, copyInterval: d, defaultShift: P } = i.custom;
198
+ let g = 0;
199
199
  switch (f) {
200
200
  case "day": {
201
201
  let s = "";
202
- if (c && (s = A(
202
+ if (m && (s = A(
203
203
  n[0],
204
204
  6,
205
205
  "day"
206
206
  /* day */
207
- )), !M) {
208
- let m = "";
209
- c ? m = s : m = n[0];
210
- const u = D(t, e, r);
211
- u.v = m, u.t = O.STRING;
207
+ )), !Y) {
208
+ let c = "";
209
+ m ? c = s : c = n[0];
210
+ const u = b(t, e, r);
211
+ u.v = c, u.t = O.STRING;
212
212
  break;
213
213
  }
214
- c ? b = j(
214
+ m ? g = j(
215
215
  s,
216
216
  n[0],
217
217
  "day"
218
218
  /* day */
219
- ) : b = j(
219
+ ) : g = j(
220
220
  n[0],
221
221
  n[1],
222
222
  "day"
223
223
  /* day */
224
224
  );
225
- for (let m = 0; m <= Math.abs(b === 0 ? 1 : b); m++) {
226
- const u = m * (x + 1);
225
+ for (let c = 0; c <= Math.abs(g === 0 ? 1 : g); c++) {
226
+ const u = c * (d + 1);
227
227
  let w = "";
228
- c ? w = H(s, "day", m, N) : w = H(n[0], "day", m, N);
229
- const y = M === "right" ? e : e + u, p = M === "right" ? r + u : r, g = D(t, y, p);
230
- g.v = w, g.t = O.STRING;
228
+ m ? w = H(s, "day", c, N) : w = H(n[0], "day", c, N);
229
+ const M = Y === "right" ? e : e + u, p = Y === "right" ? r + u : r, x = b(t, M, p);
230
+ x.v = w, x.t = O.STRING;
231
231
  }
232
232
  break;
233
233
  }
234
234
  case "month": {
235
- if (!M) {
236
- const s = D(t, e, r);
235
+ if (!Y) {
236
+ const s = b(t, e, r);
237
237
  s.v = n[0], s.t = O.STRING;
238
238
  break;
239
239
  }
240
- b = j(
240
+ g = j(
241
241
  n[0],
242
242
  n[1],
243
243
  "month"
244
244
  /* month */
245
245
  );
246
- for (let s = 0; s <= Math.abs(b === 0 ? 1 : b); s++) {
247
- const m = s * (x + 1), u = M === "right" ? e : e + m, w = M === "right" ? r + m : r, y = D(t, u, w);
248
- y.v = H(n[0], "month", s, N), y.t = O.STRING;
246
+ for (let s = 0; s <= Math.abs(g === 0 ? 1 : g); s++) {
247
+ const c = s * (d + 1), u = Y === "right" ? e : e + c, w = Y === "right" ? r + c : r, M = b(t, u, w);
248
+ M.v = H(n[0], "month", s, N), M.t = O.STRING;
249
249
  }
250
250
  break;
251
251
  }
252
252
  case "year": {
253
- if (!M) {
254
- const s = D(t, e, r);
253
+ if (!Y) {
254
+ const s = b(t, e, r);
255
255
  s.v = n[0], s.t = O.STRING;
256
256
  break;
257
257
  }
258
- b = j(
258
+ g = j(
259
259
  n[0],
260
260
  n[1],
261
261
  "year"
262
262
  /* year */
263
263
  );
264
- for (let s = 0; s <= Math.abs(b === 0 ? 1 : b); s++) {
265
- const m = s * (x + 1), u = M === "right" ? e : e + m, w = M === "right" ? r + m : r, y = D(t, u, w);
266
- y.v = H(n[0], "year", s, N), y.t = O.STRING;
264
+ for (let s = 0; s <= Math.abs(g === 0 ? 1 : g); s++) {
265
+ const c = s * (d + 1), u = Y === "right" ? e : e + c, w = Y === "right" ? r + c : r, M = b(t, u, w);
266
+ M.v = H(n[0], "year", s, N), M.t = O.STRING;
267
267
  }
268
268
  break;
269
269
  }
270
270
  case "hour": {
271
- if (!M) {
272
- const s = D(t, e, r);
271
+ if (!Y) {
272
+ const s = b(t, e, r);
273
273
  if (s.t = O.STRING, P) {
274
- s.v = h(Y?.startDatetime).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
274
+ s.v = D(y?.startDatetime).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
275
275
  break;
276
276
  }
277
- s.v = h(v).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
277
+ s.v = D(v).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
278
278
  break;
279
279
  }
280
- b = j(
281
- Y?.startDatetime,
282
- Y?.endDatetime,
280
+ g = j(
281
+ y?.startDatetime,
282
+ y?.endDatetime,
283
283
  "hour"
284
284
  /* hour */
285
285
  );
286
- for (let s = 0; s < Math.abs(b === 0 ? 1 : b); s++) {
287
- const m = s * (x + 1), u = M === "right" ? e : e + m, w = M === "right" ? r + m : r, y = D(t, u, w);
288
- if (y.t = O.STRING, P) {
289
- const p = h(Y?.startDatetime).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
290
- y.v = H(p, "hour", s, N);
286
+ for (let s = 0; s < Math.abs(g === 0 ? 1 : g); s++) {
287
+ const c = s * (d + 1), u = Y === "right" ? e : e + c, w = Y === "right" ? r + c : r, M = b(t, u, w);
288
+ if (M.t = O.STRING, P) {
289
+ const p = D(y?.startDatetime).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
290
+ M.v = H(p, "hour", s, N);
291
291
  continue;
292
292
  }
293
- y.v = H(h(v).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), "hour", s, N);
293
+ M.v = H(D(v).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), "hour", s, N);
294
294
  }
295
295
  }
296
296
  }
@@ -301,86 +301,86 @@ async function rt(t, o) {
301
301
  const { extraArgs: e, rangeData: r } = o;
302
302
  if (!r.length)
303
303
  return Promise.reject("处理时间范围失败, rangeData不能为空");
304
- const i = e?.teamData || {}, n = o?.currentDay || h().format("YYYY-MM-DD"), v = Object.entries(t).reduce((l, Y) => {
305
- const [f, N] = Y;
306
- for (const [c, M] of Object.entries(N)) {
307
- const { custom: x } = M;
308
- if (!x) continue;
309
- const { cellType: P, cycleType: b, timeIncrement: s, forwardPush: m, copyType: u, copyInterval: w, defaultShift: y } = x;
304
+ const i = e?.teamData || {}, n = o?.currentDay || D().format("YYYY-MM-DD"), v = Object.entries(t).reduce((l, y) => {
305
+ const [f, N] = y;
306
+ for (const [m, Y] of Object.entries(N)) {
307
+ const { custom: d } = Y;
308
+ if (!d) continue;
309
+ const { cellType: P, cycleType: g, timeIncrement: s, forwardPush: c, copyType: u, copyInterval: w, defaultShift: M } = d;
310
310
  if (P === "time") {
311
- K({ acc: l, params: o, initRowNum: Number(f), initColNum: Number(c), cellData: M });
311
+ K({ acc: l, params: o, initRowNum: Number(f), initColNum: Number(m), cellData: Y });
312
312
  continue;
313
313
  }
314
314
  const p = {
315
- cycleType: b,
316
- indicatorName: x.indicatorName,
317
- indicatorCode: x.indicatorCode,
318
- indicatorId: x.indicatorId,
319
- indicatorDimensionName: x.indicatorDimensionName,
320
- indicatorDimensionConfig: x.indicatorDimensionConfig,
321
- required: x.required,
322
- cellType: x.cellType,
323
- defaultShift: x.defaultShift
315
+ cycleType: g,
316
+ indicatorName: d.indicatorName,
317
+ indicatorCode: d.indicatorCode,
318
+ indicatorId: d.indicatorId,
319
+ indicatorDimensionName: d.indicatorDimensionName,
320
+ indicatorDimensionConfig: d.indicatorDimensionConfig,
321
+ required: d.required,
322
+ cellType: d.cellType,
323
+ defaultShift: d.defaultShift
324
324
  };
325
- let g = 0;
326
- switch (b) {
325
+ let x = 0;
326
+ switch (g) {
327
327
  case "day": {
328
328
  let a = "";
329
- if (m && (a = A(
329
+ if (c && (a = A(
330
330
  r[0],
331
331
  6,
332
332
  "day"
333
333
  /* day */
334
334
  )), !u) {
335
- let d = "";
336
- m ? d = a : d = r[0];
337
- const S = D(l, f, c);
335
+ let h = "";
336
+ c ? h = a : h = r[0];
337
+ const S = b(l, f, m);
338
338
  S.custom = {
339
339
  ...p,
340
- businessDate: d
341
- }, y && (S.custom.teamData = i);
340
+ businessDate: h
341
+ }, M && (S.custom.teamData = i);
342
342
  break;
343
343
  }
344
- m ? g = j(
344
+ c ? x = j(
345
345
  a,
346
346
  r[0],
347
347
  "day"
348
348
  /* day */
349
- ) : g = j(
349
+ ) : x = j(
350
350
  r[0],
351
351
  r[1],
352
352
  "day"
353
353
  /* day */
354
354
  );
355
- for (let d = 0; d < Math.abs(g === 0 ? 1 : g); d++) {
356
- const S = d * (w + 1);
355
+ for (let h = 0; h < Math.abs(x === 0 ? 1 : x); h++) {
356
+ const S = h * (w + 1);
357
357
  let k = "";
358
- m ? k = H(a, "day", d, s) : k = H(r[0], "day", d, s);
359
- const C = u === "right" ? f : I(f).add(S).toNumber(), T = u === "right" ? I(c).add(S).toNumber() : c, U = D(l, C, T);
358
+ c ? k = H(a, "day", h, s) : k = H(r[0], "day", h, s);
359
+ const C = u === "right" ? f : I(f).add(S).toNumber(), T = u === "right" ? I(m).add(S).toNumber() : m, U = b(l, C, T);
360
360
  U.custom = {
361
361
  ...p,
362
362
  businessDate: k
363
- }, y && (U.custom.teamData = i);
363
+ }, M && (U.custom.teamData = i);
364
364
  }
365
365
  break;
366
366
  }
367
367
  case "month": {
368
368
  if (!u) {
369
- const a = D(l, f, c);
369
+ const a = b(l, f, m);
370
370
  a.custom = {
371
371
  ...p,
372
372
  businessDate: r[0]
373
373
  };
374
374
  break;
375
375
  }
376
- g = j(
376
+ x = j(
377
377
  r[0],
378
378
  r[1],
379
379
  "month"
380
380
  /* month */
381
381
  );
382
- for (let a = 0; a <= Math.abs(g === 0 ? 1 : g); a++) {
383
- const d = a * (w + 1), S = u === "right" ? f : I(f).add(d).toNumber(), k = u === "right" ? I(c).add(d).toNumber() : c, C = D(l, S, k);
382
+ for (let a = 0; a <= Math.abs(x === 0 ? 1 : x); a++) {
383
+ const h = a * (w + 1), S = u === "right" ? f : I(f).add(h).toNumber(), k = u === "right" ? I(m).add(h).toNumber() : m, C = b(l, S, k);
384
384
  C.custom = {
385
385
  ...p,
386
386
  businessDate: H(r[0], "month", a, s)
@@ -390,21 +390,21 @@ async function rt(t, o) {
390
390
  }
391
391
  case "year": {
392
392
  if (!u) {
393
- const a = D(l, f, c);
393
+ const a = b(l, f, m);
394
394
  a.custom = {
395
395
  ...p,
396
396
  businessDate: r[0]
397
397
  };
398
398
  break;
399
399
  }
400
- g = j(
400
+ x = j(
401
401
  r[0],
402
402
  r[1],
403
403
  "year"
404
404
  /* year */
405
405
  );
406
- for (let a = 0; a < Math.abs(g === 0 ? 1 : g); a++) {
407
- const d = a * (w + 1), S = u === "right" ? f : I(f).add(d).toNumber(), k = u === "right" ? I(c).add(d).toNumber() : c, C = D(l, S, k);
406
+ for (let a = 0; a < Math.abs(x === 0 ? 1 : x); a++) {
407
+ const h = a * (w + 1), S = u === "right" ? f : I(f).add(h).toNumber(), k = u === "right" ? I(m).add(h).toNumber() : m, C = b(l, S, k);
408
408
  C.custom = {
409
409
  ...p,
410
410
  businessDate: H(r[0], "year", a, s)
@@ -414,31 +414,31 @@ async function rt(t, o) {
414
414
  }
415
415
  case "hour": {
416
416
  if (!u) {
417
- const a = D(l, f, c);
418
- if (y) {
417
+ const a = b(l, f, m);
418
+ if (M) {
419
419
  a.custom = {
420
420
  ...p,
421
421
  teamData: i,
422
- businessDate: h(i?.startDatetime).add(1, "hour").format("YYYY-MM-DD HH:mm:ss")
422
+ businessDate: D(i?.startDatetime).add(1, "hour").format("YYYY-MM-DD HH:mm:ss")
423
423
  };
424
424
  break;
425
425
  }
426
426
  a.custom = {
427
427
  ...p,
428
- businessDate: h(n).add(1, "hour").format("YYYY-MM-DD HH:mm:ss")
428
+ businessDate: D(n).add(1, "hour").format("YYYY-MM-DD HH:mm:ss")
429
429
  };
430
430
  break;
431
431
  }
432
- g = j(
432
+ x = j(
433
433
  i?.startDatetime,
434
434
  i?.endDatetime,
435
435
  "hour"
436
436
  /* hour */
437
437
  );
438
- for (let a = 0; a < Math.abs(g === 0 ? 1 : g); a++) {
439
- const d = a * (w + 1), S = u === "right" ? f : I(f).add(d).toNumber(), k = u === "right" ? I(c).add(d).toNumber() : c, C = D(l, S, k);
440
- if (y) {
441
- const T = h(i?.startDatetime).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
438
+ for (let a = 0; a < Math.abs(x === 0 ? 1 : x); a++) {
439
+ const h = a * (w + 1), S = u === "right" ? f : I(f).add(h).toNumber(), k = u === "right" ? I(m).add(h).toNumber() : m, C = b(l, S, k);
440
+ if (M) {
441
+ const T = D(i?.startDatetime).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
442
442
  C.custom = {
443
443
  ...p,
444
444
  teamData: i,
@@ -449,7 +449,7 @@ async function rt(t, o) {
449
449
  C.custom = {
450
450
  ...p,
451
451
  businessDate: H(
452
- h(n).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"),
452
+ D(n).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"),
453
453
  "hour",
454
454
  a,
455
455
  s
@@ -475,12 +475,12 @@ function st(t, o) {
475
475
  for (const [r, i] of Object.entries(o)) {
476
476
  e[r] || (e[r] = {});
477
477
  for (const [n, v] of Object.entries(i)) {
478
- const l = v, Y = e[r]?.[n];
479
- Y ? e[r][n] = {
480
- ...Y,
478
+ const l = v, y = e[r]?.[n];
479
+ y ? e[r][n] = {
480
+ ...y,
481
481
  ...l,
482
482
  custom: {
483
- ...Y.custom,
483
+ ...y.custom,
484
484
  ...l.custom || {}
485
485
  }
486
486
  } : e[r][n] = l;
@@ -1 +1 @@
1
- (function(d,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("dayjs"),require("@univerjs/presets"),require("decimal.js")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/presets","decimal.js"],m):(d=typeof globalThis<"u"?globalThis:d||self,m(d.TorUniverSheet={},d.dayjs,d.presets,d.Decimal))})(this,(function(d,m,P,U){"use strict";const z=(e,n)=>{for(const t of n)e[t]=null},G=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const t=r=>{const i=Number(r);return(i^crypto.getRandomValues(new Uint8Array(1))[0]&15>>i/4).toString(16)};return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t)}}let e=new Date().getTime(),n=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16;return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(n+r)%16|0,n=Math.floor(n/16)),(t==="x"?r:r&3|8).toString(16)})};function Z(e){return{...e?.workbookData,id:e?.id||G(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const _=Object.prototype.toString,A=(e,n)=>_.call(e)===`[object ${n}]`,B=e=>e!==null&&A(e,"Object"),E=e=>e==null||typeof e>"u"?!0:V(e)||K(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:B(e)?Object.keys(e).length===0:!1,K=e=>A(e,"String"),V=e=>e&&Array.isArray(e);class L{value;constructor(n){this.value=new U(n)}add(n){return this.value=this.value.add(n||0),this}subtract(n){return this.value=this.value.sub(n||0),this}multiply(n){return this.value=this.value.mul(n||0),this}divide(n){const t=new U(n);if(t.isZero())throw new Error("除数是0");return this.value=this.value.div(t),this}toFixed(n,t){return this.value=new U(this.value.toFixed(n,t)),this}valueOf(){return this.value}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}}function O(e=0){return new L(e)}var q=(e=>(e.无="no",e.年="year",e.月="month",e.周="week",e.天="day",e.班组="shift",e.小时="hour",e.半小时="half_hour",e))(q||{}),F=(e=>(e.view="view",e.edit="edit",e))(F||{});async function Q(e,n){if(!n)return Promise.reject("日期不能为空");switch(e){case"year":if(V(n))return Promise.resolve(n);const t=m(n);if(!t.isValid())return Promise.reject("无效的日期格式");const r=t.year(),i=`${r}-01`,s=`${r}-12`;return Promise.resolve([i,s]);case"month":if(V(n))return Promise.resolve(n);const p=m(n);if(!p.isValid())return Promise.reject("无效的日期格式");const h=p.startOf("month").format("YYYY-MM-DD"),b=p.endOf("month").format("YYYY-MM-DD");return Promise.resolve([h,b]);case"day":if(V(n))return Promise.resolve(n);const f=m(n);if(!f.isValid())return Promise.reject("无效的日期格式");const S=f.startOf("day").format("YYYY-MM-DD HH:mm:ss"),c=f.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([S,c]);default:return Promise.reject("不支持的周期类型")}}function I(e,n,t){if(!t)return 0;const r={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[t];return["day","hour"].includes(t)?m(n,r).diff(m(e,r),t)+1:m(n,r).diff(m(e,r),t)}function $(e,n,t){const r={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[t];return m(e).subtract(n,t).format(r)}function N(e,n,t,r){const i={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[n];return m(e,i).add(t*r,n).format(i)}function Y(e,n,t){return e[n]||(e[n]={}),e[n][t]||(e[n][t]={}),e[n][t]}async function W(e){if(!e)throw new Error("cellData is required");const n=Object.entries(e).reduce((t,r)=>{const[i,s]=r;for(const[p,h]of Object.entries(s)){const{custom:b,v:f}=h;if(!b)continue;const{cellType:S}=b;if(S==="indicator"){const c=Y(t,i,p);c.custom=b,c.v=f}}return t},{});return!n||E(n)?Promise.reject(new Error("No data found")):Promise.resolve(n)}function X({acc:e,params:n,initRowNum:t,initColNum:r,cellData:i}){const{rangeData:s,currentDay:p,extraArgs:h}=n,b=h?.teamData||{},{cycleType:f,timeIncrement:S,forwardPush:c,copyType:w,copyInterval:v,defaultShift:j}=i.custom;let g=0;switch(f){case"day":{let o="";if(c&&(o=$(s[0],6,"day")),!w){let l="";c?l=o:l=s[0];const u=Y(e,t,r);u.v=l,u.t=P.CellValueType.STRING;break}c?g=I(o,s[0],"day"):g=I(s[0],s[1],"day");for(let l=0;l<=Math.abs(g===0?1:g);l++){const u=l*(v+1);let x="";c?x=N(o,"day",l,S):x=N(s[0],"day",l,S);const y=w==="right"?t:t+u,C=w==="right"?r+u:r,M=Y(e,y,C);M.v=x,M.t=P.CellValueType.STRING}break}case"month":{if(!w){const o=Y(e,t,r);o.v=s[0],o.t=P.CellValueType.STRING;break}g=I(s[0],s[1],"month");for(let o=0;o<=Math.abs(g===0?1:g);o++){const l=o*(v+1),u=w==="right"?t:t+l,x=w==="right"?r+l:r,y=Y(e,u,x);y.v=N(s[0],"month",o,S),y.t=P.CellValueType.STRING}break}case"year":{if(!w){const o=Y(e,t,r);o.v=s[0],o.t=P.CellValueType.STRING;break}g=I(s[0],s[1],"year");for(let o=0;o<=Math.abs(g===0?1:g);o++){const l=o*(v+1),u=w==="right"?t:t+l,x=w==="right"?r+l:r,y=Y(e,u,x);y.v=N(s[0],"year",o,S),y.t=P.CellValueType.STRING}break}case"hour":{if(!w){const o=Y(e,t,r);if(o.t=P.CellValueType.STRING,j){o.v=m(b?.startDatetime).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}o.v=m(p).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}g=I(b?.startDatetime,b?.endDatetime,"hour");for(let o=0;o<Math.abs(g===0?1:g);o++){const l=o*(v+1),u=w==="right"?t:t+l,x=w==="right"?r+l:r,y=Y(e,u,x);if(y.t=P.CellValueType.STRING,j){const C=m(b?.startDatetime).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");y.v=N(C,"hour",o,S);continue}y.v=N(m(p).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",o,S)}}}}async function ee(e,n){if(!e)return Promise.reject("没有可用的单元格数据");const{extraArgs:t,rangeData:r}=n;if(!r.length)return Promise.reject("处理时间范围失败, rangeData不能为空");const i=t?.teamData||{},s=n?.currentDay||m().format("YYYY-MM-DD"),p=Object.entries(e).reduce((h,b)=>{const[f,S]=b;for(const[c,w]of Object.entries(S)){const{custom:v}=w;if(!v)continue;const{cellType:j,cycleType:g,timeIncrement:o,forwardPush:l,copyType:u,copyInterval:x,defaultShift:y}=v;if(j==="time"){X({acc:h,params:n,initRowNum:Number(f),initColNum:Number(c),cellData:w});continue}const C={cycleType:g,indicatorName:v.indicatorName,indicatorCode:v.indicatorCode,indicatorId:v.indicatorId,indicatorDimensionName:v.indicatorDimensionName,indicatorDimensionConfig:v.indicatorDimensionConfig,required:v.required,cellType:v.cellType,defaultShift:v.defaultShift};let M=0;switch(g){case"day":{let a="";if(l&&(a=$(r[0],6,"day")),!u){let D="";l?D=a:D=r[0];const H=Y(h,f,c);H.custom={...C,businessDate:D},y&&(H.custom.teamData=i);break}l?M=I(a,r[0],"day"):M=I(r[0],r[1],"day");for(let D=0;D<Math.abs(M===0?1:M);D++){const H=D*(x+1);let k="";l?k=N(a,"day",D,o):k=N(r[0],"day",D,o);const T=u==="right"?f:O(f).add(H).toNumber(),R=u==="right"?O(c).add(H).toNumber():c,J=Y(h,T,R);J.custom={...C,businessDate:k},y&&(J.custom.teamData=i)}break}case"month":{if(!u){const a=Y(h,f,c);a.custom={...C,businessDate:r[0]};break}M=I(r[0],r[1],"month");for(let a=0;a<=Math.abs(M===0?1:M);a++){const D=a*(x+1),H=u==="right"?f:O(f).add(D).toNumber(),k=u==="right"?O(c).add(D).toNumber():c,T=Y(h,H,k);T.custom={...C,businessDate:N(r[0],"month",a,o)}}break}case"year":{if(!u){const a=Y(h,f,c);a.custom={...C,businessDate:r[0]};break}M=I(r[0],r[1],"year");for(let a=0;a<Math.abs(M===0?1:M);a++){const D=a*(x+1),H=u==="right"?f:O(f).add(D).toNumber(),k=u==="right"?O(c).add(D).toNumber():c,T=Y(h,H,k);T.custom={...C,businessDate:N(r[0],"year",a,o)}}break}case"hour":{if(!u){const a=Y(h,f,c);if(y){a.custom={...C,teamData:i,businessDate:m(i?.startDatetime).add(1,"hour").format("YYYY-MM-DD HH:mm:ss")};break}a.custom={...C,businessDate:m(s).add(1,"hour").format("YYYY-MM-DD HH:mm:ss")};break}M=I(i?.startDatetime,i?.endDatetime,"hour");for(let a=0;a<Math.abs(M===0?1:M);a++){const D=a*(x+1),H=u==="right"?f:O(f).add(D).toNumber(),k=u==="right"?O(c).add(D).toNumber():c,T=Y(h,H,k);if(y){const R=m(i?.startDatetime).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");T.custom={...C,teamData:i,businessDate:N(R,"hour",a,o)};continue}T.custom={...C,businessDate:N(m(s).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",a,o)}}break}}}return h},{});return Promise.resolve(p)}function te(e){return Object.entries(e).reduce((t,[r,i])=>{const s=Math.max(...Object.keys(i).map(Number));return s>t?t=Number(s):t=Number(t)||0,t},0)}function re(e,n){const t=JSON.parse(JSON.stringify(e||{}));for(const[r,i]of Object.entries(n)){t[r]||(t[r]={});for(const[s,p]of Object.entries(i)){const h=p,b=t[r]?.[s];b?t[r][s]={...b,...h,custom:{...b.custom,...h.custom||{}}}:t[r][s]=h}}return t}const ne="./style.css";d.CycleTypeEnum=q,d.ModeEnum=F,d.decimal=O,d.filterIndicatorsCell=W,d.generateIndicatorsCells=ee,d.generateUUID=G,d.getNumColumns=te,d.handleClearInput=z,d.initDateRange=Q,d.mergeCellData=re,d.stylePath=ne,d.useData=Z,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(d,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("dayjs"),require("@univerjs/presets"),require("decimal.js")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/presets","decimal.js"],l):(d=typeof globalThis<"u"?globalThis:d||self,l(d.TorUniverSheet={},d.dayjs,d.presets,d.Decimal))})(this,(function(d,l,P,U){"use strict";const z=(e,n)=>{for(const t of n)e[t]=null},G=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const t=r=>{const i=Number(r);return(i^crypto.getRandomValues(new Uint8Array(1))[0]&15>>i/4).toString(16)};return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t)}}let e=new Date().getTime(),n=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16;return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(n+r)%16|0,n=Math.floor(n/16)),(t==="x"?r:r&3|8).toString(16)})};function Z(e){return{...e?.workbookData,id:e?.id||G(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const _=Object.prototype.toString,A=(e,n)=>_.call(e)===`[object ${n}]`,B=e=>e!==null&&A(e,"Object"),E=e=>e==null||typeof e>"u"?!0:V(e)||K(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:B(e)?Object.keys(e).length===0:!1,K=e=>A(e,"String"),V=e=>e&&Array.isArray(e);class L{value;constructor(n){this.value=new U(n)}add(n){return this.value=this.value.add(n||0),this}subtract(n){return this.value=this.value.sub(n||0),this}multiply(n){return this.value=this.value.mul(n||0),this}divide(n){const t=new U(n);if(t.isZero())throw new Error("除数是0");return this.value=this.value.div(t),this}toFixed(n,t){return this.value=new U(this.value.toFixed(n,t)),this}valueOf(){return this.value}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}}function O(e=0){return new L(e)}var q=(e=>(e.无="no",e.年="year",e.月="month",e.周="week",e.天="day",e.班组="shift",e.小时="hour",e.半小时="half_hour",e))(q||{}),F=(e=>(e.view="view",e.edit="edit",e))(F||{});async function Q(e,n){if(!n)return Promise.reject("日期不能为空");switch(e){case"year":if(V(n))return Promise.resolve(n);const t=l(n);if(!t.isValid())return Promise.reject("无效的日期格式");const r=t.year(),i=`${r}-01`,s=`${r}-12`;return Promise.resolve([i,s]);case"month":if(V(n))return Promise.resolve(n);const p=l(n);if(!p.isValid())return Promise.reject("无效的日期格式");const h=p.startOf("month").format("YYYY-MM-DD"),y=p.endOf("month").format("YYYY-MM-DD");return Promise.resolve([h,y]);case"day":if(V(n))return Promise.resolve(n);const f=l(n);if(!f.isValid())return Promise.reject("无效的日期格式");const S=f.startOf("day").format("YYYY-MM-DD HH:mm:ss"),m=f.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([S,m]);default:return Promise.reject("不支持的周期类型")}}function I(e,n,t){if(!t)return 0;const r={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[t];return["day","hour"].includes(t)?l(n,r).diff(l(e,r),t)+1:l(n,r).diff(l(e,r),t)}function $(e,n,t){const r={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[t];return l(e).subtract(n,t).format(r)}function N(e,n,t,r){const i={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[n];return l(e,i).add(t*r,n).format(i)}function b(e,n,t){return e[n]||(e[n]={}),e[n][t]||(e[n][t]={}),e[n][t]}async function W(e){if(!e)throw new Error("cellData is required");const n=Object.entries(e).reduce((t,r)=>{const[i,s]=r;for(const[p,h]of Object.entries(s)){const{custom:y,v:f,t:S,s:m}=h;if(!y)continue;const{cellType:g}=y;if(g==="indicator"){const D=b(t,i,p);D.custom=y,D.v=f,D.t=S,D.s=m}}return t},{});return!n||E(n)?Promise.reject(new Error("No data found")):Promise.resolve(n)}function X({acc:e,params:n,initRowNum:t,initColNum:r,cellData:i}){const{rangeData:s,currentDay:p,extraArgs:h}=n,y=h?.teamData||{},{cycleType:f,timeIncrement:S,forwardPush:m,copyType:g,copyInterval:D,defaultShift:j}=i.custom;let M=0;switch(f){case"day":{let o="";if(m&&(o=$(s[0],6,"day")),!g){let c="";m?c=o:c=s[0];const u=b(e,t,r);u.v=c,u.t=P.CellValueType.STRING;break}m?M=I(o,s[0],"day"):M=I(s[0],s[1],"day");for(let c=0;c<=Math.abs(M===0?1:M);c++){const u=c*(D+1);let x="";m?x=N(o,"day",c,S):x=N(s[0],"day",c,S);const w=g==="right"?t:t+u,C=g==="right"?r+u:r,v=b(e,w,C);v.v=x,v.t=P.CellValueType.STRING}break}case"month":{if(!g){const o=b(e,t,r);o.v=s[0],o.t=P.CellValueType.STRING;break}M=I(s[0],s[1],"month");for(let o=0;o<=Math.abs(M===0?1:M);o++){const c=o*(D+1),u=g==="right"?t:t+c,x=g==="right"?r+c:r,w=b(e,u,x);w.v=N(s[0],"month",o,S),w.t=P.CellValueType.STRING}break}case"year":{if(!g){const o=b(e,t,r);o.v=s[0],o.t=P.CellValueType.STRING;break}M=I(s[0],s[1],"year");for(let o=0;o<=Math.abs(M===0?1:M);o++){const c=o*(D+1),u=g==="right"?t:t+c,x=g==="right"?r+c:r,w=b(e,u,x);w.v=N(s[0],"year",o,S),w.t=P.CellValueType.STRING}break}case"hour":{if(!g){const o=b(e,t,r);if(o.t=P.CellValueType.STRING,j){o.v=l(y?.startDatetime).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}o.v=l(p).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}M=I(y?.startDatetime,y?.endDatetime,"hour");for(let o=0;o<Math.abs(M===0?1:M);o++){const c=o*(D+1),u=g==="right"?t:t+c,x=g==="right"?r+c:r,w=b(e,u,x);if(w.t=P.CellValueType.STRING,j){const C=l(y?.startDatetime).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");w.v=N(C,"hour",o,S);continue}w.v=N(l(p).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",o,S)}}}}async function ee(e,n){if(!e)return Promise.reject("没有可用的单元格数据");const{extraArgs:t,rangeData:r}=n;if(!r.length)return Promise.reject("处理时间范围失败, rangeData不能为空");const i=t?.teamData||{},s=n?.currentDay||l().format("YYYY-MM-DD"),p=Object.entries(e).reduce((h,y)=>{const[f,S]=y;for(const[m,g]of Object.entries(S)){const{custom:D}=g;if(!D)continue;const{cellType:j,cycleType:M,timeIncrement:o,forwardPush:c,copyType:u,copyInterval:x,defaultShift:w}=D;if(j==="time"){X({acc:h,params:n,initRowNum:Number(f),initColNum:Number(m),cellData:g});continue}const C={cycleType:M,indicatorName:D.indicatorName,indicatorCode:D.indicatorCode,indicatorId:D.indicatorId,indicatorDimensionName:D.indicatorDimensionName,indicatorDimensionConfig:D.indicatorDimensionConfig,required:D.required,cellType:D.cellType,defaultShift:D.defaultShift};let v=0;switch(M){case"day":{let a="";if(c&&(a=$(r[0],6,"day")),!u){let Y="";c?Y=a:Y=r[0];const H=b(h,f,m);H.custom={...C,businessDate:Y},w&&(H.custom.teamData=i);break}c?v=I(a,r[0],"day"):v=I(r[0],r[1],"day");for(let Y=0;Y<Math.abs(v===0?1:v);Y++){const H=Y*(x+1);let k="";c?k=N(a,"day",Y,o):k=N(r[0],"day",Y,o);const T=u==="right"?f:O(f).add(H).toNumber(),R=u==="right"?O(m).add(H).toNumber():m,J=b(h,T,R);J.custom={...C,businessDate:k},w&&(J.custom.teamData=i)}break}case"month":{if(!u){const a=b(h,f,m);a.custom={...C,businessDate:r[0]};break}v=I(r[0],r[1],"month");for(let a=0;a<=Math.abs(v===0?1:v);a++){const Y=a*(x+1),H=u==="right"?f:O(f).add(Y).toNumber(),k=u==="right"?O(m).add(Y).toNumber():m,T=b(h,H,k);T.custom={...C,businessDate:N(r[0],"month",a,o)}}break}case"year":{if(!u){const a=b(h,f,m);a.custom={...C,businessDate:r[0]};break}v=I(r[0],r[1],"year");for(let a=0;a<Math.abs(v===0?1:v);a++){const Y=a*(x+1),H=u==="right"?f:O(f).add(Y).toNumber(),k=u==="right"?O(m).add(Y).toNumber():m,T=b(h,H,k);T.custom={...C,businessDate:N(r[0],"year",a,o)}}break}case"hour":{if(!u){const a=b(h,f,m);if(w){a.custom={...C,teamData:i,businessDate:l(i?.startDatetime).add(1,"hour").format("YYYY-MM-DD HH:mm:ss")};break}a.custom={...C,businessDate:l(s).add(1,"hour").format("YYYY-MM-DD HH:mm:ss")};break}v=I(i?.startDatetime,i?.endDatetime,"hour");for(let a=0;a<Math.abs(v===0?1:v);a++){const Y=a*(x+1),H=u==="right"?f:O(f).add(Y).toNumber(),k=u==="right"?O(m).add(Y).toNumber():m,T=b(h,H,k);if(w){const R=l(i?.startDatetime).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");T.custom={...C,teamData:i,businessDate:N(R,"hour",a,o)};continue}T.custom={...C,businessDate:N(l(s).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",a,o)}}break}}}return h},{});return Promise.resolve(p)}function te(e){return Object.entries(e).reduce((t,[r,i])=>{const s=Math.max(...Object.keys(i).map(Number));return s>t?t=Number(s):t=Number(t)||0,t},0)}function re(e,n){const t=JSON.parse(JSON.stringify(e||{}));for(const[r,i]of Object.entries(n)){t[r]||(t[r]={});for(const[s,p]of Object.entries(i)){const h=p,y=t[r]?.[s];y?t[r][s]={...y,...h,custom:{...y.custom,...h.custom||{}}}:t[r][s]=h}}return t}const ne="./style.css";d.CycleTypeEnum=q,d.ModeEnum=F,d.decimal=O,d.filterIndicatorsCell=W,d.generateIndicatorsCells=ee,d.generateUUID=G,d.getNumColumns=te,d.handleClearInput=z,d.initDateRange=Q,d.mergeCellData=re,d.stylePath=ne,d.useData=Z,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
@@ -126,7 +126,7 @@ export declare interface UniverSheetsProps {
126
126
  showIndicatorsContextMenuPlugin?: boolean;
127
127
  showSyncContextMenuPlugin?: boolean;
128
128
  showTimeConfigContextMenuPlugin?: boolean;
129
- license: string;
129
+ showIndicatorDetailPlugin?: boolean;
130
130
  }
131
131
 
132
132
  export declare function useData(data: UseDataType): IWorkbookData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tor-univer-sheet",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "style": "./dist/style.css",
5
5
  "description": "基于 Univer 的 Vue3 电子表格组件",
6
6
  "author": "tortormore",
@@ -18,8 +18,7 @@
18
18
  "./style.css": "./dist/style.css"
19
19
  },
20
20
  "files": [
21
- "dist",
22
- "src"
21
+ "dist"
23
22
  ],
24
23
  "scripts": {
25
24
  "dev": "vite",
package/src/App.vue DELETED
@@ -1,14 +0,0 @@
1
- <template>
2
- <div style="width: 100%; height: 100vh"></div>
3
- </template>
4
-
5
- <script setup lang="ts">
6
- import { ref, onMounted } from 'vue'
7
- import { ModeEnum } from './components/UniverSheet/UniverSheet.data'
8
-
9
- const sheetRef = ref()
10
-
11
- onMounted(() => {
12
- sheetRef.value?.createUniverSheets()
13
- })
14
- </script>
@@ -1,59 +0,0 @@
1
- import {
2
- ICellData,
3
- IObjectMatrixPrimitiveType,
4
- } from '@univerjs/presets'
5
-
6
-
7
- export function getNumColumns(cells: IObjectMatrixPrimitiveType<ICellData>) {
8
- const result = Object.entries(cells).reduce((acc, [rowNum, cols]) => {
9
- const colsNum = Math.max(...Object.keys(cols).map(Number))
10
- if (colsNum > acc) {
11
- acc = Number(colsNum)
12
- } else {
13
- acc = Number(acc) || 0
14
- }
15
- return acc
16
- }, 0)
17
- return result
18
- }
19
- /**
20
- * 智能合并单元格数据
21
- * 保留原有单元格的属性(如公式、值等),用新数据进行更新
22
- * @param originalCellData - 原始单元格数据(来自 sheetSnapshot.cellData)
23
- * @param newCells - 新的单元格数据(来自后端或自生成)
24
- * @returns 合并后的单元格数据
25
- */
26
- export function mergeCellData(
27
- originalCellData: IObjectMatrixPrimitiveType<ICellData> | undefined,
28
- newCells: IObjectMatrixPrimitiveType<ICellData>
29
- ): IObjectMatrixPrimitiveType<ICellData> {
30
- const result = JSON.parse(JSON.stringify(originalCellData || {})) as IObjectMatrixPrimitiveType<ICellData>
31
-
32
- for (const [rowNum, cols] of Object.entries(newCells)) {
33
- if (!result[rowNum]) {
34
- result[rowNum] = {}
35
- }
36
-
37
- for (const [colNum, newCellData] of Object.entries(cols)) {
38
- const cellData = newCellData as ICellData
39
- const originalCell = result[rowNum]?.[colNum]
40
-
41
- if (originalCell) {
42
- result[rowNum][colNum] = {
43
- ...originalCell,
44
- ...cellData,
45
- custom: {
46
- ...originalCell.custom,
47
- ...(cellData.custom || {})
48
- }
49
- }
50
- } else {
51
- result[rowNum][colNum] = cellData
52
- }
53
- }
54
- }
55
-
56
- return result
57
- }
58
-
59
-