tor-univer-sheet 1.1.2 → 1.1.3
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,5 +1,5 @@
|
|
|
1
1
|
import b from "dayjs";
|
|
2
|
-
import { CellValueType as
|
|
2
|
+
import { CellValueType as j } from "@univerjs/presets";
|
|
3
3
|
import V from "decimal.js";
|
|
4
4
|
const re = (e, o) => {
|
|
5
5
|
for (const r of o)
|
|
@@ -10,8 +10,8 @@ const re = (e, o) => {
|
|
|
10
10
|
return crypto.randomUUID();
|
|
11
11
|
if (typeof crypto.getRandomValues == "function" && typeof Uint8Array == "function") {
|
|
12
12
|
const r = (t) => {
|
|
13
|
-
const
|
|
14
|
-
return (
|
|
13
|
+
const l = Number(t);
|
|
14
|
+
return (l ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> l / 4).toString(16);
|
|
15
15
|
};
|
|
16
16
|
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, r);
|
|
17
17
|
}
|
|
@@ -103,7 +103,7 @@ class L {
|
|
|
103
103
|
return this.value.toNumber();
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function k(e = 0) {
|
|
107
107
|
return new L(e);
|
|
108
108
|
}
|
|
109
109
|
var Q = /* @__PURE__ */ ((e) => (e.无 = "no", e.年 = "year", e.月 = "month", e.周 = "week", e.天 = "day", e.班组 = "shift", e.小时 = "hour", e.半小时 = "half_hour", e))(Q || {}), W = /* @__PURE__ */ ((e) => (e.view = "view", e.edit = "edit", e))(W || {});
|
|
@@ -116,29 +116,29 @@ async function ne(e, o) {
|
|
|
116
116
|
const r = b(o);
|
|
117
117
|
if (!r.isValid())
|
|
118
118
|
return Promise.reject("无效的日期格式");
|
|
119
|
-
const t = r.year(),
|
|
120
|
-
return Promise.resolve([
|
|
119
|
+
const t = r.year(), l = `${t}-01`, a = `${t}-12`;
|
|
120
|
+
return Promise.resolve([l, a]);
|
|
121
121
|
case "month":
|
|
122
122
|
if (G(o))
|
|
123
123
|
return Promise.resolve(o);
|
|
124
124
|
const d = b(o);
|
|
125
125
|
if (!d.isValid())
|
|
126
126
|
return Promise.reject("无效的日期格式");
|
|
127
|
-
const
|
|
128
|
-
return Promise.resolve([
|
|
127
|
+
const T = d.startOf("month").format("YYYY-MM-DD"), i = d.endOf("month").format("YYYY-MM-DD");
|
|
128
|
+
return Promise.resolve([T, i]);
|
|
129
129
|
case "day":
|
|
130
130
|
if (G(o))
|
|
131
131
|
return Promise.resolve(o);
|
|
132
132
|
const x = b(o);
|
|
133
133
|
if (!x.isValid())
|
|
134
134
|
return Promise.reject("无效的日期格式");
|
|
135
|
-
const
|
|
136
|
-
return Promise.resolve([
|
|
135
|
+
const m = x.startOf("day").format("YYYY-MM-DD HH:mm:ss"), h = x.endOf("day").format("YYYY-MM-DD HH:mm:ss");
|
|
136
|
+
return Promise.resolve([m, h]);
|
|
137
137
|
default:
|
|
138
138
|
return Promise.reject("不支持的周期类型");
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function H(e, o, r) {
|
|
142
142
|
if (!r) return 0;
|
|
143
143
|
const t = {
|
|
144
144
|
year: "YYYY",
|
|
@@ -158,22 +158,22 @@ function q(e, o, r) {
|
|
|
158
158
|
return b(e).subtract(o, r).format(t);
|
|
159
159
|
}
|
|
160
160
|
function N(e, o, r, t) {
|
|
161
|
-
const
|
|
161
|
+
const l = {
|
|
162
162
|
year: "YYYY",
|
|
163
163
|
month: "YYYY-MM",
|
|
164
164
|
day: "YYYY-MM-DD",
|
|
165
165
|
hour: "YYYY-MM-DD HH:mm:ss"
|
|
166
166
|
}[o];
|
|
167
|
-
return b(e,
|
|
167
|
+
return b(e, l).add(r * t, o).format(l);
|
|
168
168
|
}
|
|
169
169
|
function I(e, o, r, t) {
|
|
170
|
-
const
|
|
170
|
+
const l = {
|
|
171
171
|
year: "YYYY",
|
|
172
172
|
month: "YYYY-MM",
|
|
173
173
|
day: "YYYY-MM-DD",
|
|
174
174
|
hour: "YYYY-MM-DD HH:mm:ss"
|
|
175
175
|
}[o];
|
|
176
|
-
return b(e,
|
|
176
|
+
return b(e, l).subtract(r * t, o).format(l);
|
|
177
177
|
}
|
|
178
178
|
function D(e, o, r) {
|
|
179
179
|
return e[o] || (e[o] = {}), e[o][r] || (e[o][r] = {}), e[o][r];
|
|
@@ -182,19 +182,19 @@ async function se(e) {
|
|
|
182
182
|
if (!e)
|
|
183
183
|
throw new Error("cellData is required");
|
|
184
184
|
const o = Object.entries(e).reduce((r, t) => {
|
|
185
|
-
const [
|
|
186
|
-
for (const [d,
|
|
187
|
-
const { custom: i, v: x, t:
|
|
185
|
+
const [l, a] = t;
|
|
186
|
+
for (const [d, T] of Object.entries(a)) {
|
|
187
|
+
const { custom: i, v: x, t: m, s: h } = T;
|
|
188
188
|
if (!i) continue;
|
|
189
189
|
const { cellType: Y } = i;
|
|
190
190
|
if (Y === "indicator") {
|
|
191
|
-
const
|
|
192
|
-
|
|
191
|
+
const O = D(r, l, d);
|
|
192
|
+
O.custom = {
|
|
193
193
|
...i,
|
|
194
194
|
required: R(i?.required) ? !1 : i?.required,
|
|
195
195
|
defaultShift: R(i?.defaultShift) ? !1 : i?.defaultShift,
|
|
196
196
|
forwardPush: R(i?.forwardPush) ? !1 : i?.forwardPush
|
|
197
|
-
},
|
|
197
|
+
}, O.s = h, O.t = m, O.v = x;
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
return r;
|
|
@@ -206,33 +206,33 @@ function X({
|
|
|
206
206
|
params: o,
|
|
207
207
|
initRowNum: r,
|
|
208
208
|
initColNum: t,
|
|
209
|
-
cellData:
|
|
209
|
+
cellData: l
|
|
210
210
|
}) {
|
|
211
|
-
const { rangeData: a, currentDay: d, extraArgs:
|
|
212
|
-
|
|
213
|
-
const { cycleType: i, timeIncrement: x, forwardPush:
|
|
211
|
+
const { rangeData: a, currentDay: d, extraArgs: T } = o;
|
|
212
|
+
T?.teamData;
|
|
213
|
+
const { cycleType: i, timeIncrement: x, forwardPush: m, copyType: h, copyInterval: Y, defaultShift: O } = l.custom;
|
|
214
214
|
let y = 0;
|
|
215
215
|
switch (i) {
|
|
216
216
|
case "day": {
|
|
217
217
|
let n = "";
|
|
218
|
-
if (
|
|
218
|
+
if (m && (n = q(
|
|
219
219
|
a[0],
|
|
220
220
|
6,
|
|
221
221
|
"day"
|
|
222
222
|
/* day */
|
|
223
223
|
)), !h) {
|
|
224
224
|
let f = "";
|
|
225
|
-
|
|
225
|
+
m ? f = n : f = a[0];
|
|
226
226
|
const c = D(e, r, t);
|
|
227
|
-
c.v = f, c.t =
|
|
227
|
+
c.v = f, c.t = j.STRING;
|
|
228
228
|
break;
|
|
229
229
|
}
|
|
230
|
-
|
|
230
|
+
m ? y = H(
|
|
231
231
|
n,
|
|
232
232
|
a[0],
|
|
233
233
|
"day"
|
|
234
234
|
/* day */
|
|
235
|
-
) : y =
|
|
235
|
+
) : y = H(
|
|
236
236
|
a[0],
|
|
237
237
|
a[1],
|
|
238
238
|
"day"
|
|
@@ -241,19 +241,19 @@ function X({
|
|
|
241
241
|
for (let f = 0; f <= Math.abs(y === 0 ? 1 : y); f++) {
|
|
242
242
|
const c = f * (Y + 1);
|
|
243
243
|
let w = "";
|
|
244
|
-
|
|
244
|
+
m ? w = N(n, "day", f, x) : w = N(a[0], "day", f, x);
|
|
245
245
|
const g = h === "right" ? r : r + c, p = h === "right" ? t + c : t, M = D(e, g, p);
|
|
246
|
-
M.v = w, M.t =
|
|
246
|
+
M.v = w, M.t = j.STRING;
|
|
247
247
|
}
|
|
248
248
|
break;
|
|
249
249
|
}
|
|
250
250
|
case "month": {
|
|
251
251
|
if (!h) {
|
|
252
252
|
const n = D(e, r, t);
|
|
253
|
-
n.v = a[0], n.t =
|
|
253
|
+
n.v = a[0], n.t = j.STRING;
|
|
254
254
|
break;
|
|
255
255
|
}
|
|
256
|
-
y =
|
|
256
|
+
y = H(
|
|
257
257
|
a[0],
|
|
258
258
|
a[1],
|
|
259
259
|
"month"
|
|
@@ -261,17 +261,17 @@ function X({
|
|
|
261
261
|
);
|
|
262
262
|
for (let n = 0; n <= Math.abs(y === 0 ? 1 : y); n++) {
|
|
263
263
|
const f = n * (Y + 1), c = h === "right" ? r : r + f, w = h === "right" ? t + f : t, g = D(e, c, w);
|
|
264
|
-
g.v = N(a[0], "month", n, x), g.t =
|
|
264
|
+
g.v = N(a[0], "month", n, x), g.t = j.STRING;
|
|
265
265
|
}
|
|
266
266
|
break;
|
|
267
267
|
}
|
|
268
268
|
case "year": {
|
|
269
269
|
if (!h) {
|
|
270
270
|
const n = D(e, r, t);
|
|
271
|
-
n.v = a[0], n.t =
|
|
271
|
+
n.v = a[0], n.t = j.STRING;
|
|
272
272
|
break;
|
|
273
273
|
}
|
|
274
|
-
y =
|
|
274
|
+
y = H(
|
|
275
275
|
a[0],
|
|
276
276
|
a[1],
|
|
277
277
|
"year"
|
|
@@ -279,21 +279,21 @@ function X({
|
|
|
279
279
|
);
|
|
280
280
|
for (let n = 0; n <= Math.abs(y === 0 ? 1 : y); n++) {
|
|
281
281
|
const f = n * (Y + 1), c = h === "right" ? r : r + f, w = h === "right" ? t + f : t, g = D(e, c, w);
|
|
282
|
-
g.v = N(a[0], "year", n, x), g.t =
|
|
282
|
+
g.v = N(a[0], "year", n, x), g.t = j.STRING;
|
|
283
283
|
}
|
|
284
284
|
break;
|
|
285
285
|
}
|
|
286
286
|
case "hour": {
|
|
287
287
|
if (!h) {
|
|
288
288
|
const n = D(e, r, t);
|
|
289
|
-
if (n.t =
|
|
289
|
+
if (n.t = j.STRING, O) {
|
|
290
290
|
n.v = b(a[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
291
291
|
break;
|
|
292
292
|
}
|
|
293
293
|
n.v = b(d).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
294
294
|
break;
|
|
295
295
|
}
|
|
296
|
-
y =
|
|
296
|
+
y = H(
|
|
297
297
|
a[0],
|
|
298
298
|
a[1],
|
|
299
299
|
"hour"
|
|
@@ -301,7 +301,7 @@ function X({
|
|
|
301
301
|
);
|
|
302
302
|
for (let n = 0; n < Math.abs(y === 0 ? 1 : y); n++) {
|
|
303
303
|
const f = n * (Y + 1), c = h === "right" ? r : r + f, w = h === "right" ? t + f : t, g = D(e, c, w);
|
|
304
|
-
if (g.t =
|
|
304
|
+
if (g.t = j.STRING, O) {
|
|
305
305
|
const p = b(a[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
306
306
|
g.v = N(p, "hour", n, x);
|
|
307
307
|
continue;
|
|
@@ -318,14 +318,14 @@ async function ae(e, o) {
|
|
|
318
318
|
if (!t.length)
|
|
319
319
|
return Promise.reject("处理时间范围失败, rangeData不能为空");
|
|
320
320
|
r?.teamData;
|
|
321
|
-
const
|
|
322
|
-
const [i, x] =
|
|
323
|
-
for (const [
|
|
321
|
+
const l = o?.currentDay || b().format("YYYY-MM-DD"), a = Object.entries(e).reduce((d, T) => {
|
|
322
|
+
const [i, x] = T;
|
|
323
|
+
for (const [m, h] of Object.entries(x)) {
|
|
324
324
|
const { custom: Y } = h;
|
|
325
325
|
if (!Y) continue;
|
|
326
|
-
const { cellType:
|
|
327
|
-
if (
|
|
328
|
-
X({ acc: d, params: o, initRowNum: Number(i), initColNum: Number(
|
|
326
|
+
const { cellType: O, cycleType: y, timeIncrement: n, forwardPush: f, copyType: c, copyInterval: w, defaultShift: g } = Y;
|
|
327
|
+
if (O === "time") {
|
|
328
|
+
X({ acc: d, params: o, initRowNum: Number(i), initColNum: Number(m), cellData: h });
|
|
329
329
|
continue;
|
|
330
330
|
}
|
|
331
331
|
const p = {
|
|
@@ -351,19 +351,21 @@ async function ae(e, o) {
|
|
|
351
351
|
)), !c) {
|
|
352
352
|
let u = "";
|
|
353
353
|
f ? u = s : u = t[0];
|
|
354
|
-
const v = D(d, i,
|
|
354
|
+
const v = D(d, i, m);
|
|
355
355
|
v.custom = {
|
|
356
356
|
...p,
|
|
357
|
-
businessDate: u
|
|
357
|
+
businessDate: u,
|
|
358
|
+
startTime: "",
|
|
359
|
+
endTime: ""
|
|
358
360
|
}, g && (v.custom.startTime = t[0], v.custom.endTime = t[1]);
|
|
359
361
|
break;
|
|
360
362
|
}
|
|
361
|
-
f ? M =
|
|
363
|
+
f ? M = H(
|
|
362
364
|
s,
|
|
363
365
|
t[0],
|
|
364
366
|
"day"
|
|
365
367
|
/* day */
|
|
366
|
-
) : M =
|
|
368
|
+
) : M = H(
|
|
367
369
|
t[0],
|
|
368
370
|
t[1],
|
|
369
371
|
"day"
|
|
@@ -371,34 +373,38 @@ async function ae(e, o) {
|
|
|
371
373
|
);
|
|
372
374
|
for (let u = 0; u < Math.abs(M === 0 ? 1 : M); u++) {
|
|
373
375
|
const v = u * (w + 1);
|
|
374
|
-
let
|
|
375
|
-
f ?
|
|
376
|
-
const
|
|
377
|
-
|
|
376
|
+
let S = "";
|
|
377
|
+
f ? S = N(s, "day", u, n) : S = N(t[0], "day", u, n);
|
|
378
|
+
const C = c === "right" ? i : k(i).add(v).toNumber(), U = c === "right" ? k(m).add(v).toNumber() : m, P = D(d, C, U);
|
|
379
|
+
P.custom = {
|
|
378
380
|
...p,
|
|
379
|
-
businessDate:
|
|
380
|
-
|
|
381
|
+
businessDate: S,
|
|
382
|
+
startTime: "",
|
|
383
|
+
endTime: ""
|
|
384
|
+
}, g && (P.custom.startTime = I(S, "day", u, n), P.custom.endTime = S);
|
|
381
385
|
}
|
|
382
386
|
break;
|
|
383
387
|
}
|
|
384
388
|
case "month": {
|
|
385
389
|
if (!c) {
|
|
386
|
-
const s = D(d, i,
|
|
390
|
+
const s = D(d, i, m);
|
|
387
391
|
s.custom = {
|
|
388
392
|
...p,
|
|
389
|
-
businessDate: t[0]
|
|
393
|
+
businessDate: t[0],
|
|
394
|
+
startTime: "",
|
|
395
|
+
endTime: ""
|
|
390
396
|
};
|
|
391
397
|
break;
|
|
392
398
|
}
|
|
393
|
-
M =
|
|
399
|
+
M = H(
|
|
394
400
|
t[0],
|
|
395
401
|
t[1],
|
|
396
402
|
"month"
|
|
397
403
|
/* month */
|
|
398
404
|
);
|
|
399
405
|
for (let s = 0; s <= Math.abs(M === 0 ? 1 : M); s++) {
|
|
400
|
-
const u = s * (w + 1), v = c === "right" ? i :
|
|
401
|
-
|
|
406
|
+
const u = s * (w + 1), v = c === "right" ? i : k(i).add(u).toNumber(), S = c === "right" ? k(m).add(u).toNumber() : m, C = D(d, v, S);
|
|
407
|
+
C.custom = {
|
|
402
408
|
...p,
|
|
403
409
|
businessDate: N(t[0], "month", s, n)
|
|
404
410
|
};
|
|
@@ -407,22 +413,24 @@ async function ae(e, o) {
|
|
|
407
413
|
}
|
|
408
414
|
case "year": {
|
|
409
415
|
if (!c) {
|
|
410
|
-
const s = D(d, i,
|
|
416
|
+
const s = D(d, i, m);
|
|
411
417
|
s.custom = {
|
|
412
418
|
...p,
|
|
413
|
-
businessDate: t[0]
|
|
419
|
+
businessDate: t[0],
|
|
420
|
+
startTime: "",
|
|
421
|
+
endTime: ""
|
|
414
422
|
};
|
|
415
423
|
break;
|
|
416
424
|
}
|
|
417
|
-
M =
|
|
425
|
+
M = H(
|
|
418
426
|
t[0],
|
|
419
427
|
t[1],
|
|
420
428
|
"year"
|
|
421
429
|
/* year */
|
|
422
430
|
);
|
|
423
431
|
for (let s = 0; s < Math.abs(M === 0 ? 1 : M); s++) {
|
|
424
|
-
const u = s * (w + 1), v = c === "right" ? i :
|
|
425
|
-
|
|
432
|
+
const u = s * (w + 1), v = c === "right" ? i : k(i).add(u).toNumber(), S = c === "right" ? k(m).add(u).toNumber() : m, C = D(d, v, S);
|
|
433
|
+
C.custom = {
|
|
426
434
|
...p,
|
|
427
435
|
businessDate: N(t[0], "year", s, n)
|
|
428
436
|
};
|
|
@@ -432,7 +440,7 @@ async function ae(e, o) {
|
|
|
432
440
|
case "hour": {
|
|
433
441
|
if (!c) {
|
|
434
442
|
let s = "";
|
|
435
|
-
const u = D(d, i,
|
|
443
|
+
const u = D(d, i, m);
|
|
436
444
|
if (g) {
|
|
437
445
|
s = N(t[0], "hour", 1, 1), u.custom = {
|
|
438
446
|
...p,
|
|
@@ -442,7 +450,7 @@ async function ae(e, o) {
|
|
|
442
450
|
};
|
|
443
451
|
break;
|
|
444
452
|
}
|
|
445
|
-
s = N(t[0] ??
|
|
453
|
+
s = N(t[0] ?? l, "hour", 1, 1), u.custom = {
|
|
446
454
|
...p,
|
|
447
455
|
businessDate: s,
|
|
448
456
|
startTime: I(s, "hour", 1, 1),
|
|
@@ -451,7 +459,7 @@ async function ae(e, o) {
|
|
|
451
459
|
};
|
|
452
460
|
break;
|
|
453
461
|
}
|
|
454
|
-
M =
|
|
462
|
+
M = H(
|
|
455
463
|
t[0],
|
|
456
464
|
t[1],
|
|
457
465
|
"hour"
|
|
@@ -459,10 +467,10 @@ async function ae(e, o) {
|
|
|
459
467
|
);
|
|
460
468
|
for (let s = 0; s < Math.abs(M === 0 ? 1 : M); s++) {
|
|
461
469
|
let u = "";
|
|
462
|
-
const v = s * (w + 1),
|
|
470
|
+
const v = s * (w + 1), S = c === "right" ? i : k(i).add(v).toNumber(), C = c === "right" ? k(m).add(v).toNumber() : m, U = D(d, S, C);
|
|
463
471
|
if (g) {
|
|
464
|
-
const
|
|
465
|
-
u = N(
|
|
472
|
+
const P = b(t[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
473
|
+
u = N(P, "hour", s, n), U.custom = {
|
|
466
474
|
...p,
|
|
467
475
|
businessDate: u,
|
|
468
476
|
startTime: I(u, "hour", s, n),
|
|
@@ -472,7 +480,7 @@ async function ae(e, o) {
|
|
|
472
480
|
continue;
|
|
473
481
|
}
|
|
474
482
|
u = N(
|
|
475
|
-
b(
|
|
483
|
+
b(l).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"),
|
|
476
484
|
"hour",
|
|
477
485
|
s,
|
|
478
486
|
n
|
|
@@ -497,25 +505,25 @@ async function ae(e, o) {
|
|
|
497
505
|
return Promise.resolve(a);
|
|
498
506
|
}
|
|
499
507
|
function ie(e) {
|
|
500
|
-
return Object.entries(e).reduce((r, [t,
|
|
501
|
-
const a = Math.max(...Object.keys(
|
|
508
|
+
return Object.entries(e).reduce((r, [t, l]) => {
|
|
509
|
+
const a = Math.max(...Object.keys(l).map(Number));
|
|
502
510
|
return a > r ? r = Number(a) : r = Number(r) || 0, r;
|
|
503
511
|
}, 0);
|
|
504
512
|
}
|
|
505
513
|
function ue(e, o) {
|
|
506
514
|
const r = JSON.parse(JSON.stringify(e || {}));
|
|
507
|
-
for (const [t,
|
|
515
|
+
for (const [t, l] of Object.entries(o)) {
|
|
508
516
|
r[t] || (r[t] = {});
|
|
509
|
-
for (const [a, d] of Object.entries(
|
|
510
|
-
const
|
|
517
|
+
for (const [a, d] of Object.entries(l)) {
|
|
518
|
+
const T = d, i = r[t]?.[a];
|
|
511
519
|
i ? r[t][a] = {
|
|
512
520
|
...i,
|
|
513
|
-
...
|
|
521
|
+
...T,
|
|
514
522
|
custom: {
|
|
515
523
|
...i.custom,
|
|
516
|
-
...
|
|
524
|
+
...T.custom || {}
|
|
517
525
|
}
|
|
518
|
-
} : r[t][a] =
|
|
526
|
+
} : r[t][a] = T;
|
|
519
527
|
}
|
|
520
528
|
}
|
|
521
529
|
return r;
|
|
@@ -524,7 +532,7 @@ const ce = "./style.css";
|
|
|
524
532
|
export {
|
|
525
533
|
Q as CycleTypeEnum,
|
|
526
534
|
W as ModeEnum,
|
|
527
|
-
|
|
535
|
+
k as decimal,
|
|
528
536
|
se as filterIndicatorsCell,
|
|
529
537
|
ae as generateIndicatorsCells,
|
|
530
538
|
F as generateUUID,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(Y,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):(Y=typeof globalThis<"u"?globalThis:Y||self,m(Y.TorUniverSheet={},Y.dayjs,Y.presets,Y.Decimal))})(this,(function(Y,m,I,G){"use strict";const B=(e,n)=>{for(const r of n)e[r]=null},A=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const r=t=>{const d=Number(t);return(d^crypto.getRandomValues(new Uint8Array(1))[0]&15>>d/4).toString(16)};return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r)}}let e=new Date().getTime(),n=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let t=Math.random()*16;return e>0?(t=(e+t)%16|0,e=Math.floor(e/16)):(t=(n+t)%16|0,n=Math.floor(n/16)),(r==="x"?t:t&3|8).toString(16)})};function Z(e){return{...e?.workbookData,id:e?.id||A(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const _=Object.prototype.toString,F=(e,n)=>_.call(e)===`[object ${n}]`,E=e=>typeof e<"u",K=e=>!E(e),L=e=>e!==null&&F(e,"Object"),U=e=>e==null||typeof e>"u"?!0:R(e)||X(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:L(e)?Object.keys(e).length===0:!1,Q=e=>e===null,W=e=>K(e)||Q(e),X=e=>F(e,"String"),R=e=>e&&Array.isArray(e);class ee{value;constructor(n){this.value=new G(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 r=new G(n);if(r.isZero())throw new Error("除数是0");return this.value=this.value.div(r),this}toFixed(n,r){return this.value=new G(this.value.toFixed(n,r)),this}valueOf(){return this.value}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}}function O(e=0){return new ee(e)}var $=(e=>(e.无="no",e.年="year",e.月="month",e.周="week",e.天="day",e.班组="shift",e.小时="hour",e.半小时="half_hour",e))($||{}),J=(e=>(e.view="view",e.edit="edit",e))(J||{});async function te(e,n){if(!n)return Promise.reject("日期不能为空");switch(e){case"year":if(R(n))return Promise.resolve(n);const r=m(n);if(!r.isValid())return Promise.reject("无效的日期格式");const t=r.year(),d=`${t}-01`,i=`${t}-12`;return Promise.resolve([d,i]);case"month":if(R(n))return Promise.resolve(n);const h=m(n);if(!h.isValid())return Promise.reject("无效的日期格式");const
|
|
1
|
+
(function(Y,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):(Y=typeof globalThis<"u"?globalThis:Y||self,m(Y.TorUniverSheet={},Y.dayjs,Y.presets,Y.Decimal))})(this,(function(Y,m,I,G){"use strict";const B=(e,n)=>{for(const r of n)e[r]=null},A=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const r=t=>{const d=Number(t);return(d^crypto.getRandomValues(new Uint8Array(1))[0]&15>>d/4).toString(16)};return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r)}}let e=new Date().getTime(),n=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let t=Math.random()*16;return e>0?(t=(e+t)%16|0,e=Math.floor(e/16)):(t=(n+t)%16|0,n=Math.floor(n/16)),(r==="x"?t:t&3|8).toString(16)})};function Z(e){return{...e?.workbookData,id:e?.id||A(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const _=Object.prototype.toString,F=(e,n)=>_.call(e)===`[object ${n}]`,E=e=>typeof e<"u",K=e=>!E(e),L=e=>e!==null&&F(e,"Object"),U=e=>e==null||typeof e>"u"?!0:R(e)||X(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:L(e)?Object.keys(e).length===0:!1,Q=e=>e===null,W=e=>K(e)||Q(e),X=e=>F(e,"String"),R=e=>e&&Array.isArray(e);class ee{value;constructor(n){this.value=new G(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 r=new G(n);if(r.isZero())throw new Error("除数是0");return this.value=this.value.div(r),this}toFixed(n,r){return this.value=new G(this.value.toFixed(n,r)),this}valueOf(){return this.value}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}}function O(e=0){return new ee(e)}var $=(e=>(e.无="no",e.年="year",e.月="month",e.周="week",e.天="day",e.班组="shift",e.小时="hour",e.半小时="half_hour",e))($||{}),J=(e=>(e.view="view",e.edit="edit",e))(J||{});async function te(e,n){if(!n)return Promise.reject("日期不能为空");switch(e){case"year":if(R(n))return Promise.resolve(n);const r=m(n);if(!r.isValid())return Promise.reject("无效的日期格式");const t=r.year(),d=`${t}-01`,i=`${t}-12`;return Promise.resolve([d,i]);case"month":if(R(n))return Promise.resolve(n);const h=m(n);if(!h.isValid())return Promise.reject("无效的日期格式");const p=h.startOf("month").format("YYYY-MM-DD"),a=h.endOf("month").format("YYYY-MM-DD");return Promise.resolve([p,a]);case"day":if(R(n))return Promise.resolve(n);const v=m(n);if(!v.isValid())return Promise.reject("无效的日期格式");const f=v.startOf("day").format("YYYY-MM-DD HH:mm:ss"),D=v.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([f,D]);default:return Promise.reject("不支持的周期类型")}}function H(e,n,r){if(!r)return 0;const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[r];return["day","hour"].includes(r)?m(n,t).diff(m(e,t),r)+1:m(n,t).diff(m(e,t),r)}function z(e,n,r){const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[r];return m(e).subtract(n,r).format(t)}function T(e,n,r,t){const d={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[n];return m(e,d).add(r*t,n).format(d)}function j(e,n,r,t){const d={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[n];return m(e,d).subtract(r*t,n).format(d)}function b(e,n,r){return e[n]||(e[n]={}),e[n][r]||(e[n][r]={}),e[n][r]}async function re(e){if(!e)throw new Error("cellData is required");const n=Object.entries(e).reduce((r,t)=>{const[d,i]=t;for(const[h,p]of Object.entries(i)){const{custom:a,v,t:f,s:D}=p;if(!a)continue;const{cellType:g}=a;if(g==="indicator"){const P=b(r,d,h);P.custom={...a,required:U(a?.required)?!1:a?.required,defaultShift:U(a?.defaultShift)?!1:a?.defaultShift,forwardPush:U(a?.forwardPush)?!1:a?.forwardPush},P.s=D,P.t=f,P.v=v}}return r},{});return!n||U(n)?Promise.reject(new Error("No data found")):Promise.resolve(n)}function ne({acc:e,params:n,initRowNum:r,initColNum:t,cellData:d}){const{rangeData:i,currentDay:h,extraArgs:p}=n;p?.teamData;const{cycleType:a,timeIncrement:v,forwardPush:f,copyType:D,copyInterval:g,defaultShift:P}=d.custom;let y=0;switch(a){case"day":{let o="";if(f&&(o=z(i[0],6,"day")),!D){let c="";f?c=o:c=i[0];const l=b(e,r,t);l.v=c,l.t=I.CellValueType.STRING;break}f?y=H(o,i[0],"day"):y=H(i[0],i[1],"day");for(let c=0;c<=Math.abs(y===0?1:y);c++){const l=c*(g+1);let x="";f?x=T(o,"day",c,v):x=T(i[0],"day",c,v);const M=D==="right"?r:r+l,N=D==="right"?t+l:t,w=b(e,M,N);w.v=x,w.t=I.CellValueType.STRING}break}case"month":{if(!D){const o=b(e,r,t);o.v=i[0],o.t=I.CellValueType.STRING;break}y=H(i[0],i[1],"month");for(let o=0;o<=Math.abs(y===0?1:y);o++){const c=o*(g+1),l=D==="right"?r:r+c,x=D==="right"?t+c:t,M=b(e,l,x);M.v=T(i[0],"month",o,v),M.t=I.CellValueType.STRING}break}case"year":{if(!D){const o=b(e,r,t);o.v=i[0],o.t=I.CellValueType.STRING;break}y=H(i[0],i[1],"year");for(let o=0;o<=Math.abs(y===0?1:y);o++){const c=o*(g+1),l=D==="right"?r:r+c,x=D==="right"?t+c:t,M=b(e,l,x);M.v=T(i[0],"year",o,v),M.t=I.CellValueType.STRING}break}case"hour":{if(!D){const o=b(e,r,t);if(o.t=I.CellValueType.STRING,P){o.v=m(i[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}o.v=m(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}y=H(i[0],i[1],"hour");for(let o=0;o<Math.abs(y===0?1:y);o++){const c=o*(g+1),l=D==="right"?r:r+c,x=D==="right"?t+c:t,M=b(e,l,x);if(M.t=I.CellValueType.STRING,P){const N=m(i[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");M.v=T(N,"hour",o,v);continue}M.v=T(m(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",o,v)}}}}async function oe(e,n){if(!e)return Promise.reject("没有可用的单元格数据");const{extraArgs:r,rangeData:t}=n;if(!t.length)return Promise.reject("处理时间范围失败, rangeData不能为空");r?.teamData;const d=n?.currentDay||m().format("YYYY-MM-DD"),i=Object.entries(e).reduce((h,p)=>{const[a,v]=p;for(const[f,D]of Object.entries(v)){const{custom:g}=D;if(!g)continue;const{cellType:P,cycleType:y,timeIncrement:o,forwardPush:c,copyType:l,copyInterval:x,defaultShift:M}=g;if(P==="time"){ne({acc:h,params:n,initRowNum:Number(a),initColNum:Number(f),cellData:D});continue}const N={cycleType:y,indicatorName:g.indicatorName,indicatorCode:g.indicatorCode,indicatorId:g.indicatorId,indicatorDimensionName:g.indicatorDimensionName,indicatorDimensionConfig:g.indicatorDimensionConfig,required:W(g?.required)??!1,cellType:g.cellType,defaultShift:g?.defaultShift||!1};let w=0;switch(y){case"day":{let s="";if(c&&(s=z(t[0],6,"day")),!l){let u="";c?u=s:u=t[0];const C=b(h,a,f);C.custom={...N,businessDate:u,startTime:"",endTime:""},M&&(C.custom.startTime=t[0],C.custom.endTime=t[1]);break}c?w=H(s,t[0],"day"):w=H(t[0],t[1],"day");for(let u=0;u<Math.abs(w===0?1:w);u++){const C=u*(x+1);let S="";c?S=T(s,"day",u,o):S=T(t[0],"day",u,o);const k=l==="right"?a:O(a).add(C).toNumber(),q=l==="right"?O(f).add(C).toNumber():f,V=b(h,k,q);V.custom={...N,businessDate:S,startTime:"",endTime:""},M&&(V.custom.startTime=j(S,"day",u,o),V.custom.endTime=S)}break}case"month":{if(!l){const s=b(h,a,f);s.custom={...N,businessDate:t[0],startTime:"",endTime:""};break}w=H(t[0],t[1],"month");for(let s=0;s<=Math.abs(w===0?1:w);s++){const u=s*(x+1),C=l==="right"?a:O(a).add(u).toNumber(),S=l==="right"?O(f).add(u).toNumber():f,k=b(h,C,S);k.custom={...N,businessDate:T(t[0],"month",s,o)}}break}case"year":{if(!l){const s=b(h,a,f);s.custom={...N,businessDate:t[0],startTime:"",endTime:""};break}w=H(t[0],t[1],"year");for(let s=0;s<Math.abs(w===0?1:w);s++){const u=s*(x+1),C=l==="right"?a:O(a).add(u).toNumber(),S=l==="right"?O(f).add(u).toNumber():f,k=b(h,C,S);k.custom={...N,businessDate:T(t[0],"year",s,o)}}break}case"hour":{if(!l){let s="";const u=b(h,a,f);if(M){s=T(t[0],"hour",1,1),u.custom={...N,businessDate:s,startTime:j(s,"hour",1,1),endTime:s};break}s=T(t[0]??d,"hour",1,1),u.custom={...N,businessDate:s,startTime:j(s,"hour",1,1),endTime:s};break}w=H(t[0],t[1],"hour");for(let s=0;s<Math.abs(w===0?1:w);s++){let u="";const C=s*(x+1),S=l==="right"?a:O(a).add(C).toNumber(),k=l==="right"?O(f).add(C).toNumber():f,q=b(h,S,k);if(M){const V=m(t[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");u=T(V,"hour",s,o),q.custom={...N,businessDate:u,startTime:j(u,"hour",s,o),endTime:u};continue}u=T(m(d).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",s,o),q.custom={...N,startTime:j(u,"hour",s,o),endTime:u}}break}}}return h},{});return Promise.resolve(i)}function se(e){return Object.entries(e).reduce((r,[t,d])=>{const i=Math.max(...Object.keys(d).map(Number));return i>r?r=Number(i):r=Number(r)||0,r},0)}function ie(e,n){const r=JSON.parse(JSON.stringify(e||{}));for(const[t,d]of Object.entries(n)){r[t]||(r[t]={});for(const[i,h]of Object.entries(d)){const p=h,a=r[t]?.[i];a?r[t][i]={...a,...p,custom:{...a.custom,...p.custom||{}}}:r[t][i]=p}}return r}const ae="./style.css";Y.CycleTypeEnum=$,Y.ModeEnum=J,Y.decimal=O,Y.filterIndicatorsCell=re,Y.generateIndicatorsCells=oe,Y.generateUUID=A,Y.getNumColumns=se,Y.handleClearInput=B,Y.initDateRange=te,Y.mergeCellData=ie,Y.stylePath=ae,Y.useData=Z,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
|