tor-univer-sheet 1.1.2 → 1.1.4
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/tor-univer-sheet.es.js +103 -91
- package/dist/tor-univer-sheet.umd.js +1 -1
- package/package.json +1 -1
|
@@ -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 f = 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([f, 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: f, 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 = f, O.v = x;
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
return r;
|
|
@@ -206,102 +206,102 @@ 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: f, 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 (f && (n = q(
|
|
219
219
|
a[0],
|
|
220
220
|
6,
|
|
221
221
|
"day"
|
|
222
222
|
/* day */
|
|
223
223
|
)), !h) {
|
|
224
|
-
let
|
|
225
|
-
|
|
224
|
+
let m = "";
|
|
225
|
+
f ? m = n : m = a[0];
|
|
226
226
|
const c = D(e, r, t);
|
|
227
|
-
c.v =
|
|
227
|
+
c.v = m, c.t = j.STRING;
|
|
228
228
|
break;
|
|
229
229
|
}
|
|
230
|
-
|
|
230
|
+
f ? 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"
|
|
239
239
|
/* day */
|
|
240
240
|
);
|
|
241
|
-
for (let
|
|
242
|
-
const c =
|
|
241
|
+
for (let m = 0; m <= Math.abs(y === 0 ? 1 : y); m++) {
|
|
242
|
+
const c = m * (Y + 1);
|
|
243
243
|
let w = "";
|
|
244
|
-
|
|
244
|
+
f ? w = N(n, "day", m, x) : w = N(a[0], "day", m, 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"
|
|
260
260
|
/* month */
|
|
261
261
|
);
|
|
262
262
|
for (let n = 0; n <= Math.abs(y === 0 ? 1 : y); n++) {
|
|
263
|
-
const
|
|
264
|
-
g.v = N(a[0], "month", n, x), g.t =
|
|
263
|
+
const m = n * (Y + 1), c = h === "right" ? r : r + m, w = h === "right" ? t + m : t, g = D(e, c, w);
|
|
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"
|
|
278
278
|
/* year */
|
|
279
279
|
);
|
|
280
280
|
for (let n = 0; n <= Math.abs(y === 0 ? 1 : y); n++) {
|
|
281
|
-
const
|
|
282
|
-
g.v = N(a[0], "year", n, x), g.t =
|
|
281
|
+
const m = n * (Y + 1), c = h === "right" ? r : r + m, w = h === "right" ? t + m : t, g = D(e, c, w);
|
|
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"
|
|
300
300
|
/* hour */
|
|
301
301
|
);
|
|
302
302
|
for (let n = 0; n < Math.abs(y === 0 ? 1 : y); n++) {
|
|
303
|
-
const
|
|
304
|
-
if (g.t =
|
|
303
|
+
const m = n * (Y + 1), c = h === "right" ? r : r + m, w = h === "right" ? t + m : t, g = D(e, c, w);
|
|
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 [f, 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: m, copyType: c, copyInterval: w, defaultShift: g } = Y;
|
|
327
|
+
if (O === "time") {
|
|
328
|
+
X({ acc: d, params: o, initRowNum: Number(i), initColNum: Number(f), cellData: h });
|
|
329
329
|
continue;
|
|
330
330
|
}
|
|
331
331
|
const p = {
|
|
@@ -343,27 +343,29 @@ async function ae(e, o) {
|
|
|
343
343
|
switch (y) {
|
|
344
344
|
case "day": {
|
|
345
345
|
let s = "";
|
|
346
|
-
if (
|
|
346
|
+
if (m && (s = q(
|
|
347
347
|
t[0],
|
|
348
348
|
6,
|
|
349
349
|
"day"
|
|
350
350
|
/* day */
|
|
351
351
|
)), !c) {
|
|
352
352
|
let u = "";
|
|
353
|
-
|
|
354
|
-
const v = D(d, i,
|
|
353
|
+
m ? u = s : u = t[0];
|
|
354
|
+
const v = D(d, i, f);
|
|
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
|
-
|
|
363
|
+
m ? 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,35 +373,41 @@ 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
|
-
|
|
376
|
-
const
|
|
377
|
-
|
|
376
|
+
let S = "";
|
|
377
|
+
m ? 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(f).add(v).toNumber() : f, 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, f);
|
|
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(f).add(u).toNumber() : f, C = D(d, v, S);
|
|
407
|
+
C.custom = {
|
|
402
408
|
...p,
|
|
409
|
+
startTime: "",
|
|
410
|
+
endTime: "",
|
|
403
411
|
businessDate: N(t[0], "month", s, n)
|
|
404
412
|
};
|
|
405
413
|
}
|
|
@@ -407,23 +415,27 @@ async function ae(e, o) {
|
|
|
407
415
|
}
|
|
408
416
|
case "year": {
|
|
409
417
|
if (!c) {
|
|
410
|
-
const s = D(d, i,
|
|
418
|
+
const s = D(d, i, f);
|
|
411
419
|
s.custom = {
|
|
412
420
|
...p,
|
|
413
|
-
businessDate: t[0]
|
|
421
|
+
businessDate: t[0],
|
|
422
|
+
startTime: "",
|
|
423
|
+
endTime: ""
|
|
414
424
|
};
|
|
415
425
|
break;
|
|
416
426
|
}
|
|
417
|
-
M =
|
|
427
|
+
M = H(
|
|
418
428
|
t[0],
|
|
419
429
|
t[1],
|
|
420
430
|
"year"
|
|
421
431
|
/* year */
|
|
422
432
|
);
|
|
423
433
|
for (let s = 0; s < Math.abs(M === 0 ? 1 : M); s++) {
|
|
424
|
-
const u = s * (w + 1), v = c === "right" ? i :
|
|
425
|
-
|
|
434
|
+
const u = s * (w + 1), v = c === "right" ? i : k(i).add(u).toNumber(), S = c === "right" ? k(f).add(u).toNumber() : f, C = D(d, v, S);
|
|
435
|
+
C.custom = {
|
|
426
436
|
...p,
|
|
437
|
+
startTime: "",
|
|
438
|
+
endTime: "",
|
|
427
439
|
businessDate: N(t[0], "year", s, n)
|
|
428
440
|
};
|
|
429
441
|
}
|
|
@@ -432,7 +444,7 @@ async function ae(e, o) {
|
|
|
432
444
|
case "hour": {
|
|
433
445
|
if (!c) {
|
|
434
446
|
let s = "";
|
|
435
|
-
const u = D(d, i,
|
|
447
|
+
const u = D(d, i, f);
|
|
436
448
|
if (g) {
|
|
437
449
|
s = N(t[0], "hour", 1, 1), u.custom = {
|
|
438
450
|
...p,
|
|
@@ -442,7 +454,7 @@ async function ae(e, o) {
|
|
|
442
454
|
};
|
|
443
455
|
break;
|
|
444
456
|
}
|
|
445
|
-
s = N(t[0] ??
|
|
457
|
+
s = N(t[0] ?? l, "hour", 1, 1), u.custom = {
|
|
446
458
|
...p,
|
|
447
459
|
businessDate: s,
|
|
448
460
|
startTime: I(s, "hour", 1, 1),
|
|
@@ -451,7 +463,7 @@ async function ae(e, o) {
|
|
|
451
463
|
};
|
|
452
464
|
break;
|
|
453
465
|
}
|
|
454
|
-
M =
|
|
466
|
+
M = H(
|
|
455
467
|
t[0],
|
|
456
468
|
t[1],
|
|
457
469
|
"hour"
|
|
@@ -459,10 +471,10 @@ async function ae(e, o) {
|
|
|
459
471
|
);
|
|
460
472
|
for (let s = 0; s < Math.abs(M === 0 ? 1 : M); s++) {
|
|
461
473
|
let u = "";
|
|
462
|
-
const v = s * (w + 1),
|
|
474
|
+
const v = s * (w + 1), S = c === "right" ? i : k(i).add(v).toNumber(), C = c === "right" ? k(f).add(v).toNumber() : f, U = D(d, S, C);
|
|
463
475
|
if (g) {
|
|
464
|
-
const
|
|
465
|
-
u = N(
|
|
476
|
+
const P = b(t[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
477
|
+
u = N(P, "hour", s, n), U.custom = {
|
|
466
478
|
...p,
|
|
467
479
|
businessDate: u,
|
|
468
480
|
startTime: I(u, "hour", s, n),
|
|
@@ -472,7 +484,7 @@ async function ae(e, o) {
|
|
|
472
484
|
continue;
|
|
473
485
|
}
|
|
474
486
|
u = N(
|
|
475
|
-
b(
|
|
487
|
+
b(l).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"),
|
|
476
488
|
"hour",
|
|
477
489
|
s,
|
|
478
490
|
n
|
|
@@ -497,25 +509,25 @@ async function ae(e, o) {
|
|
|
497
509
|
return Promise.resolve(a);
|
|
498
510
|
}
|
|
499
511
|
function ie(e) {
|
|
500
|
-
return Object.entries(e).reduce((r, [t,
|
|
501
|
-
const a = Math.max(...Object.keys(
|
|
512
|
+
return Object.entries(e).reduce((r, [t, l]) => {
|
|
513
|
+
const a = Math.max(...Object.keys(l).map(Number));
|
|
502
514
|
return a > r ? r = Number(a) : r = Number(r) || 0, r;
|
|
503
515
|
}, 0);
|
|
504
516
|
}
|
|
505
517
|
function ue(e, o) {
|
|
506
518
|
const r = JSON.parse(JSON.stringify(e || {}));
|
|
507
|
-
for (const [t,
|
|
519
|
+
for (const [t, l] of Object.entries(o)) {
|
|
508
520
|
r[t] || (r[t] = {});
|
|
509
|
-
for (const [a, d] of Object.entries(
|
|
510
|
-
const
|
|
521
|
+
for (const [a, d] of Object.entries(l)) {
|
|
522
|
+
const T = d, i = r[t]?.[a];
|
|
511
523
|
i ? r[t][a] = {
|
|
512
524
|
...i,
|
|
513
|
-
...
|
|
525
|
+
...T,
|
|
514
526
|
custom: {
|
|
515
527
|
...i.custom,
|
|
516
|
-
...
|
|
528
|
+
...T.custom || {}
|
|
517
529
|
}
|
|
518
|
-
} : r[t][a] =
|
|
530
|
+
} : r[t][a] = T;
|
|
519
531
|
}
|
|
520
532
|
}
|
|
521
533
|
return r;
|
|
@@ -524,7 +536,7 @@ const ce = "./style.css";
|
|
|
524
536
|
export {
|
|
525
537
|
Q as CycleTypeEnum,
|
|
526
538
|
W as ModeEnum,
|
|
527
|
-
|
|
539
|
+
k as decimal,
|
|
528
540
|
se as filterIndicatorsCell,
|
|
529
541
|
ae as generateIndicatorsCells,
|
|
530
542
|
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 w(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=w(o,"day",c,v):x=w(i[0],"day",c,v);const M=D==="right"?r:r+l,N=D==="right"?t+l:t,T=b(e,M,N);T.v=x,T.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=w(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=w(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=w(N,"hour",o,v);continue}M.v=w(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 T=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?T=H(s,t[0],"day"):T=H(t[0],t[1],"day");for(let u=0;u<Math.abs(T===0?1:T);u++){const C=u*(x+1);let S="";c?S=w(s,"day",u,o):S=w(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}T=H(t[0],t[1],"month");for(let s=0;s<=Math.abs(T===0?1:T);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,startTime:"",endTime:"",businessDate:w(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}T=H(t[0],t[1],"year");for(let s=0;s<Math.abs(T===0?1:T);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,startTime:"",endTime:"",businessDate:w(t[0],"year",s,o)}}break}case"hour":{if(!l){let s="";const u=b(h,a,f);if(M){s=w(t[0],"hour",1,1),u.custom={...N,businessDate:s,startTime:j(s,"hour",1,1),endTime:s};break}s=w(t[0]??d,"hour",1,1),u.custom={...N,businessDate:s,startTime:j(s,"hour",1,1),endTime:s};break}T=H(t[0],t[1],"hour");for(let s=0;s<Math.abs(T===0?1:T);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=w(V,"hour",s,o),q.custom={...N,businessDate:u,startTime:j(u,"hour",s,o),endTime:u};continue}u=w(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"})}));
|