tor-univer-sheet 1.1.5 → 1.1.6
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 +194 -180
- package/dist/tor-univer-sheet.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CellValueType as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
for (const
|
|
6
|
-
t[
|
|
1
|
+
import h from "dayjs";
|
|
2
|
+
import { CellValueType as C } from "@univerjs/presets";
|
|
3
|
+
import B from "decimal.js";
|
|
4
|
+
const ct = (t, r) => {
|
|
5
|
+
for (const n of r)
|
|
6
|
+
t[n] = null;
|
|
7
7
|
}, _ = () => {
|
|
8
8
|
if (typeof crypto == "object") {
|
|
9
9
|
if (typeof crypto.randomUUID == "function")
|
|
10
10
|
return crypto.randomUUID();
|
|
11
11
|
if (typeof crypto.getRandomValues == "function" && typeof Uint8Array == "function") {
|
|
12
|
-
const
|
|
12
|
+
const n = (e) => {
|
|
13
13
|
const c = Number(e);
|
|
14
14
|
return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
|
|
15
15
|
};
|
|
16
|
-
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g,
|
|
16
|
+
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, n);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
let t = (/* @__PURE__ */ new Date()).getTime(), r = typeof performance < "u" && performance.now && performance.now() * 1e3 || 0;
|
|
20
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (
|
|
20
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (n) => {
|
|
21
21
|
let e = Math.random() * 16;
|
|
22
|
-
return t > 0 ? (e = (t + e) % 16 | 0, t = Math.floor(t / 16)) : (e = (r + e) % 16 | 0, r = Math.floor(r / 16)), (
|
|
22
|
+
return t > 0 ? (e = (t + e) % 16 | 0, t = Math.floor(t / 16)) : (e = (r + e) % 16 | 0, r = Math.floor(r / 16)), (n === "x" ? e : e & 3 | 8).toString(16);
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
|
-
function
|
|
25
|
+
function ft(t) {
|
|
26
26
|
return {
|
|
27
27
|
...t?.workbookData,
|
|
28
28
|
id: t?.id || _(),
|
|
@@ -34,7 +34,7 @@ const K = Object.prototype.toString, J = (t, r) => K.call(t) === `[object ${r}]`
|
|
|
34
34
|
class rt {
|
|
35
35
|
value;
|
|
36
36
|
constructor(r) {
|
|
37
|
-
this.value = new
|
|
37
|
+
this.value = new B(r);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* 加法运算
|
|
@@ -67,10 +67,10 @@ class rt {
|
|
|
67
67
|
* @throws 当除数为0时抛出错误
|
|
68
68
|
*/
|
|
69
69
|
divide(r) {
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
70
|
+
const n = new B(r);
|
|
71
|
+
if (n.isZero())
|
|
72
72
|
throw new Error("除数是0");
|
|
73
|
-
return this.value = this.value.div(
|
|
73
|
+
return this.value = this.value.div(n), this;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* 保留小数位数
|
|
@@ -78,8 +78,8 @@ class rt {
|
|
|
78
78
|
* @param rounding 舍入模式,默认为四舍五入
|
|
79
79
|
* @returns DecimalChain 实例,支持链式调用
|
|
80
80
|
*/
|
|
81
|
-
toFixed(r,
|
|
82
|
-
return this.value = new
|
|
81
|
+
toFixed(r, n) {
|
|
82
|
+
return this.value = new B(this.value.toFixed(r, n)), this;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* 返回当前值
|
|
@@ -106,30 +106,30 @@ class rt {
|
|
|
106
106
|
function I(t = 0) {
|
|
107
107
|
return new rt(t);
|
|
108
108
|
}
|
|
109
|
-
var
|
|
109
|
+
var nt = /* @__PURE__ */ ((t) => (t.无 = "no", t.年 = "year", t.月 = "month", t.周 = "week", t.天 = "day", t.班组 = "shift", t.小时 = "hour", t.半小时 = "half_hour", t))(nt || {}), ot = /* @__PURE__ */ ((t) => (t.view = "view", t.edit = "edit", t))(ot || {});
|
|
110
110
|
async function mt(t, r) {
|
|
111
111
|
if (!r) return Promise.reject("日期不能为空");
|
|
112
112
|
switch (t) {
|
|
113
113
|
case "year":
|
|
114
114
|
if (q(r))
|
|
115
115
|
return Promise.resolve(r);
|
|
116
|
-
const
|
|
117
|
-
if (!
|
|
116
|
+
const n = h(r);
|
|
117
|
+
if (!n.isValid())
|
|
118
118
|
return Promise.reject("无效的日期格式");
|
|
119
|
-
const e =
|
|
120
|
-
return Promise.resolve([c,
|
|
119
|
+
const e = n.year(), c = `${e}-01`, o = `${e}-12`;
|
|
120
|
+
return Promise.resolve([c, o]);
|
|
121
121
|
case "month":
|
|
122
122
|
if (q(r))
|
|
123
123
|
return Promise.resolve(r);
|
|
124
|
-
const i =
|
|
124
|
+
const i = h(r);
|
|
125
125
|
if (!i.isValid())
|
|
126
126
|
return Promise.reject("无效的日期格式");
|
|
127
|
-
const x = i.startOf("month").format("YYYY-MM-DD"),
|
|
128
|
-
return Promise.resolve([x,
|
|
127
|
+
const x = i.startOf("month").format("YYYY-MM-DD"), s = i.endOf("month").format("YYYY-MM-DD");
|
|
128
|
+
return Promise.resolve([x, s]);
|
|
129
129
|
case "day":
|
|
130
130
|
if (q(r))
|
|
131
131
|
return Promise.resolve(r);
|
|
132
|
-
const w =
|
|
132
|
+
const w = h(r);
|
|
133
133
|
if (!w.isValid())
|
|
134
134
|
return Promise.reject("无效的日期格式");
|
|
135
135
|
const l = w.startOf("day").format("YYYY-MM-DD HH:mm:ss"), H = w.endOf("day").format("YYYY-MM-DD HH:mm:ss");
|
|
@@ -138,196 +138,210 @@ async function mt(t, r) {
|
|
|
138
138
|
return Promise.reject("不支持的周期类型");
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function S(t, r,
|
|
142
|
-
if (!
|
|
141
|
+
function S(t, r, n) {
|
|
142
|
+
if (!n) return 0;
|
|
143
143
|
const e = {
|
|
144
144
|
year: "YYYY",
|
|
145
145
|
month: "YYYY-MM",
|
|
146
146
|
day: "YYYY-MM-DD",
|
|
147
147
|
hour: "HH:mm:ss"
|
|
148
|
-
}[
|
|
149
|
-
return ["day", "hour"].includes(
|
|
148
|
+
}[n];
|
|
149
|
+
return ["day", "hour"].includes(n) ? h(r, e).diff(h(t, e), n) + 1 : h(r, e).diff(h(t, e), n);
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
if (!
|
|
151
|
+
function $(t, r, n) {
|
|
152
|
+
if (!n)
|
|
153
153
|
throw new Error("日期类型不能为空");
|
|
154
154
|
const e = {
|
|
155
155
|
year: "YYYY",
|
|
156
156
|
month: "YYYY-MM",
|
|
157
157
|
day: "YYYY-MM-DD",
|
|
158
158
|
hour: "HH:mm:ss"
|
|
159
|
-
}[
|
|
160
|
-
return
|
|
159
|
+
}[n];
|
|
160
|
+
return h(t).subtract(r, n).format(e);
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
const c = "YYYY-MM-DD HH:mm:ss",
|
|
162
|
+
function N(t, r, n, e) {
|
|
163
|
+
const c = "YYYY-MM-DD HH:mm:ss", o = U(t, r, n, e), i = h(o);
|
|
164
164
|
if (r === "month") {
|
|
165
|
-
const
|
|
166
|
-
return
|
|
165
|
+
const s = i.month();
|
|
166
|
+
return s === 0 ? [i.startOf("month").format(c), i.date(25).endOf("day").format(c)] : s === 11 ? [i.subtract(1, "month").date(26).startOf("day").format(c), i.endOf("month").format(c)] : [i.subtract(1, "month").date(26).startOf("day").format(c), i.date(25).endOf("day").format(c)];
|
|
167
167
|
}
|
|
168
168
|
const x = { year: "year", day: "day", hour: "hour" };
|
|
169
|
-
return [
|
|
170
|
-
i.startOf(x[r]).format(c),
|
|
171
|
-
i.endOf(x[r]).format(c)
|
|
172
|
-
];
|
|
169
|
+
return [i.startOf(x[r]).format(c), i.endOf(x[r]).format(c)];
|
|
173
170
|
}
|
|
174
|
-
function U(t, r,
|
|
171
|
+
function U(t, r, n, e) {
|
|
175
172
|
const c = {
|
|
176
173
|
year: "YYYY",
|
|
177
174
|
month: "YYYY-MM",
|
|
178
175
|
day: "YYYY-MM-DD",
|
|
179
176
|
hour: "YYYY-MM-DD HH:mm:ss"
|
|
180
177
|
}[r];
|
|
181
|
-
return
|
|
178
|
+
return h(t, c).add(n * e, r).format(c);
|
|
182
179
|
}
|
|
183
|
-
function M(t, r,
|
|
184
|
-
return t[r] || (t[r] = {}), t[r][
|
|
180
|
+
function M(t, r, n) {
|
|
181
|
+
return t[r] || (t[r] = {}), t[r][n] || (t[r][n] = {}), t[r][n];
|
|
185
182
|
}
|
|
186
183
|
async function lt(t) {
|
|
187
184
|
if (!t)
|
|
188
185
|
throw new Error("cellData is required");
|
|
189
|
-
const r = Object.entries(t).reduce((
|
|
190
|
-
const [c,
|
|
191
|
-
for (const [i, x] of Object.entries(
|
|
192
|
-
const { custom:
|
|
193
|
-
if (!
|
|
194
|
-
const { cellType: d } =
|
|
186
|
+
const r = Object.entries(t).reduce((n, e) => {
|
|
187
|
+
const [c, o] = e;
|
|
188
|
+
for (const [i, x] of Object.entries(o)) {
|
|
189
|
+
const { custom: s, v: w, t: l, s: H } = x;
|
|
190
|
+
if (!s) continue;
|
|
191
|
+
const { cellType: d } = s;
|
|
195
192
|
if (d === "indicator") {
|
|
196
|
-
const P = M(
|
|
193
|
+
const P = M(n, c, i);
|
|
197
194
|
P.custom = {
|
|
198
|
-
...
|
|
199
|
-
required: G(
|
|
200
|
-
defaultShift: G(
|
|
201
|
-
forwardPush: G(
|
|
202
|
-
forwardPushTimes: G(
|
|
203
|
-
useDefaultEndDate: G(
|
|
195
|
+
...s,
|
|
196
|
+
required: G(s?.required) ? !1 : s?.required,
|
|
197
|
+
defaultShift: G(s?.defaultShift) ? !1 : s?.defaultShift,
|
|
198
|
+
forwardPush: G(s?.forwardPush) ? !1 : s?.forwardPush,
|
|
199
|
+
forwardPushTimes: G(s?.useDefaultEndDate) ? 0 : s?.forwardPushTimes,
|
|
200
|
+
useDefaultEndDate: G(s?.useDefaultEndDate) ? !1 : s?.useDefaultEndDate
|
|
204
201
|
}, P.s = H, P.t = l, P.v = w;
|
|
205
202
|
}
|
|
206
203
|
}
|
|
207
|
-
return
|
|
204
|
+
return n;
|
|
208
205
|
}, {});
|
|
209
206
|
return !r || G(r) ? Promise.reject(new Error("No data found")) : Promise.resolve(r);
|
|
210
207
|
}
|
|
211
208
|
function E(t, r) {
|
|
212
|
-
return t.replace(/\$\{(
|
|
209
|
+
return t.replace(/\$\{([^}]+)\}/g, (n, e) => {
|
|
210
|
+
try {
|
|
211
|
+
const c = Object.keys(r), o = Object.values(r);
|
|
212
|
+
return new Function(...c, `return ${e};`)(...o);
|
|
213
|
+
} catch (c) {
|
|
214
|
+
return console.error(`表达式执行失败: ${e}`, c), n;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
213
217
|
}
|
|
214
218
|
function st({
|
|
215
219
|
acc: t,
|
|
216
220
|
params: r,
|
|
217
|
-
initRowNum:
|
|
221
|
+
initRowNum: n,
|
|
218
222
|
initColNum: e,
|
|
219
223
|
cellData: c
|
|
220
224
|
}) {
|
|
221
|
-
const { rangeData:
|
|
225
|
+
const { rangeData: o, currentDay: i, extraArgs: x } = r;
|
|
222
226
|
x?.teamData;
|
|
223
|
-
const { cycleType:
|
|
224
|
-
let
|
|
225
|
-
switch (
|
|
227
|
+
const { cycleType: s, timeIncrement: w, forwardPush: l, forwardPushTimes: H, copyType: d, copyInterval: P, defaultShift: V, templateStr: T, useDefaultEndDate: k } = c.custom;
|
|
228
|
+
let g = 0;
|
|
229
|
+
switch (s) {
|
|
226
230
|
case "day": {
|
|
227
|
-
let
|
|
228
|
-
if (l && (
|
|
229
|
-
|
|
231
|
+
let a = "";
|
|
232
|
+
if (l && (a = $(
|
|
233
|
+
o[0],
|
|
230
234
|
H,
|
|
231
235
|
"day"
|
|
232
236
|
/* day */
|
|
233
237
|
)), !d) {
|
|
234
238
|
let u = "";
|
|
235
|
-
l ? u =
|
|
236
|
-
const
|
|
237
|
-
|
|
239
|
+
l ? u = a : u = o[0];
|
|
240
|
+
const y = M(t, n, e);
|
|
241
|
+
y.v = T ? E(T, { businessDate: u, dayjs: h }) : h(u).format("YYYY-MM-DD"), y.t = C.STRING;
|
|
238
242
|
break;
|
|
239
243
|
}
|
|
240
|
-
l ?
|
|
241
|
-
|
|
242
|
-
|
|
244
|
+
l ? g = S(
|
|
245
|
+
a,
|
|
246
|
+
o[0],
|
|
243
247
|
"day"
|
|
244
248
|
/* day */
|
|
245
|
-
) :
|
|
246
|
-
|
|
247
|
-
|
|
249
|
+
) : g = S(
|
|
250
|
+
o[0],
|
|
251
|
+
o[1],
|
|
248
252
|
"day"
|
|
249
253
|
/* day */
|
|
250
254
|
);
|
|
251
|
-
for (let u = 0; u <= Math.abs(
|
|
252
|
-
const
|
|
255
|
+
for (let u = 0; u <= Math.abs(g === 0 ? 1 : g); u++) {
|
|
256
|
+
const y = u * (P + 1);
|
|
253
257
|
let p = "";
|
|
254
|
-
l ? p = U(
|
|
255
|
-
const
|
|
256
|
-
f.v = T ? E(T, {
|
|
258
|
+
l ? p = U(a, "day", u, w) : p = U(o[0], "day", u, w);
|
|
259
|
+
const Y = d === "right" ? n : n + y, D = d === "right" ? e + y : e, f = M(t, Y, D);
|
|
260
|
+
f.v = T ? E(T, { businessDate: p, dayjs: h }) : h(p).format("YYYY-MM-DD"), f.t = C.STRING;
|
|
257
261
|
}
|
|
258
262
|
break;
|
|
259
263
|
}
|
|
260
264
|
case "month": {
|
|
261
265
|
if (!d) {
|
|
262
|
-
const
|
|
263
|
-
|
|
266
|
+
const [a, u] = N(o[1], "month", 0, 1), y = M(t, n, e);
|
|
267
|
+
y.v = h(u).format("YYYY-MM"), y.t = C.STRING;
|
|
264
268
|
break;
|
|
265
269
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
270
|
+
g = S(
|
|
271
|
+
o[0],
|
|
272
|
+
o[1],
|
|
269
273
|
"month"
|
|
270
274
|
/* month */
|
|
271
275
|
);
|
|
272
|
-
for (let
|
|
273
|
-
const u =
|
|
274
|
-
|
|
276
|
+
for (let a = 0; a <= Math.abs(g === 0 ? 1 : g); a++) {
|
|
277
|
+
const u = a * (P + 1), y = d === "right" ? n : n + u, p = d === "right" ? e + u : e, Y = M(t, y, p);
|
|
278
|
+
Y.v = U(o[0], "month", a, w), Y.t = C.STRING;
|
|
275
279
|
}
|
|
276
280
|
break;
|
|
277
281
|
}
|
|
278
282
|
case "year": {
|
|
279
|
-
let
|
|
280
|
-
if (l && (
|
|
281
|
-
|
|
283
|
+
let a = "";
|
|
284
|
+
if (l && (a = $(
|
|
285
|
+
o[0],
|
|
282
286
|
H || 0,
|
|
283
287
|
"year"
|
|
284
288
|
/* year */
|
|
285
289
|
)), !d) {
|
|
286
|
-
const u = l ?
|
|
287
|
-
|
|
290
|
+
const u = l ? a : o[0], [y, p] = N(u, "year", 0, 1), Y = M(t, n, e), [, D] = N(o[1], "month", 0, 1);
|
|
291
|
+
Y.v = T ? E(T, {
|
|
292
|
+
startTime: y,
|
|
293
|
+
endTime: p,
|
|
294
|
+
rangeData: o,
|
|
295
|
+
dayjs: h
|
|
296
|
+
}) : u, Y.t = C.STRING;
|
|
288
297
|
break;
|
|
289
298
|
}
|
|
290
|
-
l ?
|
|
291
|
-
|
|
292
|
-
|
|
299
|
+
l ? g = S(
|
|
300
|
+
a,
|
|
301
|
+
o[0],
|
|
293
302
|
"year"
|
|
294
303
|
/* year */
|
|
295
|
-
) :
|
|
296
|
-
|
|
297
|
-
|
|
304
|
+
) : g = S(
|
|
305
|
+
o[0],
|
|
306
|
+
o[1],
|
|
298
307
|
"year"
|
|
299
308
|
/* year */
|
|
300
309
|
);
|
|
301
|
-
for (let u = 0; u <= Math.abs(
|
|
302
|
-
const
|
|
303
|
-
m.v = T ? E(T, {
|
|
310
|
+
for (let u = 0; u <= Math.abs(g === 0 ? 1 : g); u++) {
|
|
311
|
+
const y = u * (P + 1), p = d === "right" ? n : n + y, Y = d === "right" ? e + y : e, [D, f] = N(o[0], "year", u, w), m = M(t, p, Y), b = U(o[0], "year", u, w);
|
|
312
|
+
m.v = T ? E(T, {
|
|
313
|
+
startTime: D,
|
|
314
|
+
endTime: f,
|
|
315
|
+
rangeData: o,
|
|
316
|
+
dayjs: h
|
|
317
|
+
}) : b, m.t = C.STRING;
|
|
304
318
|
}
|
|
305
319
|
break;
|
|
306
320
|
}
|
|
307
321
|
case "hour": {
|
|
308
322
|
if (!d) {
|
|
309
|
-
const
|
|
310
|
-
if (
|
|
311
|
-
|
|
323
|
+
const a = M(t, n, e);
|
|
324
|
+
if (a.t = C.STRING, V) {
|
|
325
|
+
a.v = h(o[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
312
326
|
break;
|
|
313
327
|
}
|
|
314
|
-
|
|
328
|
+
a.v = h(i).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
315
329
|
break;
|
|
316
330
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
331
|
+
g = S(
|
|
332
|
+
o[0],
|
|
333
|
+
o[1],
|
|
320
334
|
"hour"
|
|
321
335
|
/* hour */
|
|
322
336
|
);
|
|
323
|
-
for (let
|
|
324
|
-
const u =
|
|
325
|
-
if (
|
|
326
|
-
const D =
|
|
327
|
-
|
|
337
|
+
for (let a = 0; a < Math.abs(g === 0 ? 1 : g); a++) {
|
|
338
|
+
const u = a * (P + 1), y = d === "right" ? n : n + u, p = d === "right" ? e + u : e, Y = M(t, y, p);
|
|
339
|
+
if (Y.t = C.STRING, V) {
|
|
340
|
+
const D = h(o[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
341
|
+
Y.v = U(D, "hour", a, w);
|
|
328
342
|
continue;
|
|
329
343
|
}
|
|
330
|
-
|
|
344
|
+
Y.v = U(h(i).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), "hour", a, w);
|
|
331
345
|
}
|
|
332
346
|
}
|
|
333
347
|
}
|
|
@@ -335,21 +349,21 @@ function st({
|
|
|
335
349
|
async function dt(t, r) {
|
|
336
350
|
if (!t)
|
|
337
351
|
return Promise.reject("没有可用的单元格数据");
|
|
338
|
-
const { extraArgs:
|
|
352
|
+
const { extraArgs: n, rangeData: e } = r;
|
|
339
353
|
if (!e.length)
|
|
340
354
|
return Promise.reject("处理时间范围失败, rangeData不能为空");
|
|
341
|
-
|
|
342
|
-
const c = r?.currentDay ||
|
|
343
|
-
const [
|
|
355
|
+
n?.teamData;
|
|
356
|
+
const c = r?.currentDay || h().format("YYYY-MM-DD"), o = Object.entries(t).reduce((i, x) => {
|
|
357
|
+
const [s, w] = x;
|
|
344
358
|
for (const [l, H] of Object.entries(w)) {
|
|
345
359
|
const { custom: d } = H;
|
|
346
360
|
if (!d) continue;
|
|
347
|
-
const { cellType: P, cycleType: V, timeIncrement: T, forwardPush:
|
|
361
|
+
const { cellType: P, cycleType: V, timeIncrement: T, forwardPush: k, forwardPushTimes: g, copyType: a, copyInterval: u, defaultShift: y, useDefaultEndDate: p } = d;
|
|
348
362
|
if (P === "time") {
|
|
349
|
-
st({ acc: i, params: r, initRowNum: Number(
|
|
363
|
+
st({ acc: i, params: r, initRowNum: Number(s), initColNum: Number(l), cellData: H });
|
|
350
364
|
continue;
|
|
351
365
|
}
|
|
352
|
-
const
|
|
366
|
+
const Y = {
|
|
353
367
|
cycleType: V,
|
|
354
368
|
indicatorName: d.indicatorName,
|
|
355
369
|
indicatorCode: d.indicatorCode,
|
|
@@ -364,21 +378,21 @@ async function dt(t, r) {
|
|
|
364
378
|
switch (V) {
|
|
365
379
|
case "day": {
|
|
366
380
|
let f = "";
|
|
367
|
-
if (
|
|
381
|
+
if (k && (f = $(
|
|
368
382
|
e[0],
|
|
369
|
-
|
|
383
|
+
g || 0,
|
|
370
384
|
"day"
|
|
371
385
|
/* day */
|
|
372
|
-
)), !
|
|
373
|
-
const m =
|
|
386
|
+
)), !a) {
|
|
387
|
+
const m = k ? f : e[0], [b, v] = N(m, "day", 0, 1), O = M(i, s, l);
|
|
374
388
|
O.custom = {
|
|
375
|
-
...
|
|
376
|
-
startTime:
|
|
377
|
-
endTime:
|
|
389
|
+
...Y,
|
|
390
|
+
startTime: b,
|
|
391
|
+
endTime: v
|
|
378
392
|
};
|
|
379
393
|
break;
|
|
380
394
|
}
|
|
381
|
-
|
|
395
|
+
k ? D = S(
|
|
382
396
|
f,
|
|
383
397
|
e[0],
|
|
384
398
|
"day"
|
|
@@ -390,9 +404,9 @@ async function dt(t, r) {
|
|
|
390
404
|
/* day */
|
|
391
405
|
);
|
|
392
406
|
for (let m = 0; m < Math.abs(D === 0 ? 1 : D); m++) {
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
...
|
|
407
|
+
const b = m * (u + 1), v = k ? f : e[0], [O, j] = N(v, "day", m, T), R = a === "right" ? s : I(s).add(b).toNumber(), A = a === "right" ? I(l).add(b).toNumber() : l, F = M(i, R, A);
|
|
408
|
+
F.custom = {
|
|
409
|
+
...Y,
|
|
396
410
|
startTime: O,
|
|
397
411
|
endTime: j
|
|
398
412
|
};
|
|
@@ -400,10 +414,10 @@ async function dt(t, r) {
|
|
|
400
414
|
break;
|
|
401
415
|
}
|
|
402
416
|
case "month": {
|
|
403
|
-
if (!
|
|
404
|
-
const [f, m] =
|
|
405
|
-
|
|
406
|
-
...
|
|
417
|
+
if (!a) {
|
|
418
|
+
const [f, m] = N(e[1], "month", 0, 1), b = M(i, s, l);
|
|
419
|
+
b.custom = {
|
|
420
|
+
...Y,
|
|
407
421
|
startTime: f,
|
|
408
422
|
endTime: m
|
|
409
423
|
};
|
|
@@ -416,9 +430,9 @@ async function dt(t, r) {
|
|
|
416
430
|
/* month */
|
|
417
431
|
);
|
|
418
432
|
for (let f = 0; f <= Math.abs(D === 0 ? 1 : D); f++) {
|
|
419
|
-
const m = f * (u + 1),
|
|
433
|
+
const m = f * (u + 1), b = a === "right" ? s : I(s).add(m).toNumber(), v = a === "right" ? I(l).add(m).toNumber() : l, [O, j] = N(e[0], "month", f, T), R = M(i, b, v);
|
|
420
434
|
R.custom = {
|
|
421
|
-
...
|
|
435
|
+
...Y,
|
|
422
436
|
startTime: O,
|
|
423
437
|
endTime: j
|
|
424
438
|
};
|
|
@@ -427,21 +441,21 @@ async function dt(t, r) {
|
|
|
427
441
|
}
|
|
428
442
|
case "year": {
|
|
429
443
|
let f = "";
|
|
430
|
-
if (
|
|
444
|
+
if (k && (f = $(
|
|
431
445
|
e[0],
|
|
432
|
-
|
|
446
|
+
g || 0,
|
|
433
447
|
"year"
|
|
434
448
|
/* year */
|
|
435
|
-
)), !
|
|
436
|
-
const m =
|
|
449
|
+
)), !a) {
|
|
450
|
+
const m = k ? f : e[0], [b, v] = N(m, "year", 0, 1), O = M(i, s, l), [, j] = N(e[1], "month", 0, 1);
|
|
437
451
|
O.custom = {
|
|
438
|
-
...
|
|
439
|
-
startTime:
|
|
440
|
-
endTime: p ? j :
|
|
452
|
+
...Y,
|
|
453
|
+
startTime: b,
|
|
454
|
+
endTime: p ? j : v
|
|
441
455
|
};
|
|
442
456
|
break;
|
|
443
457
|
}
|
|
444
|
-
|
|
458
|
+
k ? D = S(
|
|
445
459
|
f,
|
|
446
460
|
e[0],
|
|
447
461
|
"year"
|
|
@@ -453,9 +467,9 @@ async function dt(t, r) {
|
|
|
453
467
|
/* year */
|
|
454
468
|
);
|
|
455
469
|
for (let m = 0; m < Math.abs(D === 0 ? 1 : D); m++) {
|
|
456
|
-
const
|
|
470
|
+
const b = m * (u + 1), v = a === "right" ? s : I(s).add(b).toNumber(), O = a === "right" ? I(l).add(b).toNumber() : l, [j, R] = N(e[0], "year", m, T), A = M(i, v, O);
|
|
457
471
|
A.custom = {
|
|
458
|
-
...
|
|
472
|
+
...Y,
|
|
459
473
|
startTime: j,
|
|
460
474
|
endTime: R
|
|
461
475
|
};
|
|
@@ -463,12 +477,12 @@ async function dt(t, r) {
|
|
|
463
477
|
break;
|
|
464
478
|
}
|
|
465
479
|
case "hour": {
|
|
466
|
-
if (!
|
|
467
|
-
const f =
|
|
468
|
-
|
|
469
|
-
...
|
|
480
|
+
if (!a) {
|
|
481
|
+
const f = y ? e[0] : e[0] ?? c, [m, b] = N(f, "hour", 1, 1), v = M(i, s, l);
|
|
482
|
+
v.custom = {
|
|
483
|
+
...Y,
|
|
470
484
|
startTime: m,
|
|
471
|
-
endTime:
|
|
485
|
+
endTime: b
|
|
472
486
|
};
|
|
473
487
|
break;
|
|
474
488
|
}
|
|
@@ -479,19 +493,19 @@ async function dt(t, r) {
|
|
|
479
493
|
/* hour */
|
|
480
494
|
);
|
|
481
495
|
for (let f = 0; f < Math.abs(D === 0 ? 1 : D); f++) {
|
|
482
|
-
const m = f * (u + 1),
|
|
483
|
-
if (
|
|
484
|
-
const
|
|
496
|
+
const m = f * (u + 1), b = a === "right" ? s : I(s).add(m).toNumber(), v = a === "right" ? I(l).add(m).toNumber() : l, O = M(i, b, v);
|
|
497
|
+
if (y) {
|
|
498
|
+
const F = h(e[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [z, Z] = N(F, "hour", f, T);
|
|
485
499
|
O.custom = {
|
|
486
|
-
...
|
|
500
|
+
...Y,
|
|
487
501
|
startTime: z,
|
|
488
502
|
endTime: Z
|
|
489
503
|
};
|
|
490
504
|
continue;
|
|
491
505
|
}
|
|
492
|
-
const j =
|
|
506
|
+
const j = h(c).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [R, A] = N(j, "hour", f, T);
|
|
493
507
|
O.custom = {
|
|
494
|
-
...
|
|
508
|
+
...Y,
|
|
495
509
|
startTime: R,
|
|
496
510
|
endTime: A
|
|
497
511
|
};
|
|
@@ -502,44 +516,44 @@ async function dt(t, r) {
|
|
|
502
516
|
}
|
|
503
517
|
return i;
|
|
504
518
|
}, {});
|
|
505
|
-
return Promise.resolve(
|
|
519
|
+
return Promise.resolve(o);
|
|
506
520
|
}
|
|
507
521
|
function ht(t) {
|
|
508
|
-
return Object.entries(t).reduce((
|
|
509
|
-
const
|
|
510
|
-
return
|
|
522
|
+
return Object.entries(t).reduce((n, [e, c]) => {
|
|
523
|
+
const o = Math.max(...Object.keys(c).map(Number));
|
|
524
|
+
return o > n ? n = Number(o) : n = Number(n) || 0, n;
|
|
511
525
|
}, 0);
|
|
512
526
|
}
|
|
513
527
|
function Yt(t, r) {
|
|
514
|
-
const
|
|
528
|
+
const n = JSON.parse(JSON.stringify(t || {}));
|
|
515
529
|
for (const [e, c] of Object.entries(r)) {
|
|
516
|
-
|
|
517
|
-
for (const [
|
|
518
|
-
const x = i,
|
|
519
|
-
|
|
520
|
-
...
|
|
530
|
+
n[e] || (n[e] = {});
|
|
531
|
+
for (const [o, i] of Object.entries(c)) {
|
|
532
|
+
const x = i, s = n[e]?.[o];
|
|
533
|
+
s ? n[e][o] = {
|
|
534
|
+
...s,
|
|
521
535
|
...x,
|
|
522
536
|
custom: {
|
|
523
|
-
...
|
|
537
|
+
...s.custom,
|
|
524
538
|
...x.custom || {}
|
|
525
539
|
}
|
|
526
|
-
} :
|
|
540
|
+
} : n[e][o] = x;
|
|
527
541
|
}
|
|
528
542
|
}
|
|
529
|
-
return
|
|
543
|
+
return n;
|
|
530
544
|
}
|
|
531
545
|
const Dt = "./style.css";
|
|
532
546
|
export {
|
|
533
|
-
|
|
534
|
-
|
|
547
|
+
nt as CycleTypeEnum,
|
|
548
|
+
ot as ModeEnum,
|
|
535
549
|
I as decimal,
|
|
536
550
|
lt as filterIndicatorsCell,
|
|
537
551
|
dt as generateIndicatorsCells,
|
|
538
552
|
_ as generateUUID,
|
|
539
553
|
ht as getNumColumns,
|
|
540
|
-
|
|
554
|
+
ct as handleClearInput,
|
|
541
555
|
mt as initDateRange,
|
|
542
556
|
Yt as mergeCellData,
|
|
543
557
|
Dt as stylePath,
|
|
544
|
-
|
|
558
|
+
ft as useData
|
|
545
559
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(g,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("dayjs"),require("@univerjs/presets"),require("decimal.js")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/presets","decimal.js"],c):(g=typeof globalThis<"u"?globalThis:g||self,c(g.TorUniverSheet={},g.dayjs,g.presets,g.Decimal))})(this,(function(g,c,V,$){"use strict";const L=(e,r)=>{for(const n of r)e[n]=null},z=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const n=t=>{const m=Number(t);return(m^crypto.getRandomValues(new Uint8Array(1))[0]&15>>m/4).toString(16)};return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n)}}let e=new Date().getTime(),r=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let t=Math.random()*16;return e>0?(t=(e+t)%16|0,e=Math.floor(e/16)):(t=(r+t)%16|0,r=Math.floor(r/16)),(n==="x"?t:t&3|8).toString(16)})};function Q(e){return{...e?.workbookData,id:e?.id||z(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const W=Object.prototype.toString,Z=(e,r)=>W.call(e)===`[object ${r}]`,X=e=>typeof e<"u",ee=e=>!X(e),te=e=>e!==null&&Z(e,"Object"),q=e=>e==null||typeof e>"u"?!0:A(e)||oe(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:te(e)?Object.keys(e).length===0:!1,re=e=>e===null,ne=e=>ee(e)||re(e),oe=e=>Z(e,"String"),A=e=>e&&Array.isArray(e);class se{value;constructor(r){this.value=new $(r)}add(r){return this.value=this.value.add(r||0),this}subtract(r){return this.value=this.value.sub(r||0),this}multiply(r){return this.value=this.value.mul(r||0),this}divide(r){const n=new $(r);if(n.isZero())throw new Error("除数是0");return this.value=this.value.div(n),this}toFixed(r,n){return this.value=new $(this.value.toFixed(r,n)),this}valueOf(){return this.value}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}}function H(e=0){return new se(e)}var _=(e=>(e.无="no",e.年="year",e.月="month",e.周="week",e.天="day",e.班组="shift",e.小时="hour",e.半小时="half_hour",e))(_||{}),K=(e=>(e.view="view",e.edit="edit",e))(K||{});async function ae(e,r){if(!r)return Promise.reject("日期不能为空");switch(e){case"year":if(A(r))return Promise.resolve(r);const n=c(r);if(!n.isValid())return Promise.reject("无效的日期格式");const t=n.year(),m=`${t}-01`,s=`${t}-12`;return Promise.resolve([m,s]);case"month":if(A(r))return Promise.resolve(r);const i=c(r);if(!i.isValid())return Promise.reject("无效的日期格式");const v=i.startOf("month").format("YYYY-MM-DD"),a=i.endOf("month").format("YYYY-MM-DD");return Promise.resolve([v,a]);case"day":if(A(r))return Promise.resolve(r);const w=c(r);if(!w.isValid())return Promise.reject("无效的日期格式");const d=w.startOf("day").format("YYYY-MM-DD HH:mm:ss"),I=w.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([d,I]);default:return Promise.reject("不支持的周期类型")}}function O(e,r,n){if(!n)return 0;const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[n];return["day","hour"].includes(n)?c(r,t).diff(c(e,t),n)+1:c(r,t).diff(c(e,t),n)}function F(e,r,n){if(!n)throw new Error("日期类型不能为空");const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[n];return c(e).subtract(r,n).format(t)}function p(e,r,n,t){const m="YYYY-MM-DD HH:mm:ss",s=R(e,r,n,t),i=c(s);if(r==="month"){const a=i.month();return a===0?[i.startOf("month").format(m),i.date(25).endOf("day").format(m)]:a===11?[i.subtract(1,"month").date(26).startOf("day").format(m),i.endOf("month").format(m)]:[i.subtract(1,"month").date(26).startOf("day").format(m),i.date(25).endOf("day").format(m)]}const v={year:"year",day:"day",hour:"hour"};return[i.startOf(v[r]).format(m),i.endOf(v[r]).format(m)]}function R(e,r,n,t){const m={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[r];return c(e,m).add(n*t,r).format(m)}function b(e,r,n){return e[r]||(e[r]={}),e[r][n]||(e[r][n]={}),e[r][n]}async function ie(e){if(!e)throw new Error("cellData is required");const r=Object.entries(e).reduce((n,t)=>{const[m,s]=t;for(const[i,v]of Object.entries(s)){const{custom:a,v:w,t:d,s:I}=v;if(!a)continue;const{cellType:h}=a;if(h==="indicator"){const P=b(n,m,i);P.custom={...a,required:q(a?.required)?!1:a?.required,defaultShift:q(a?.defaultShift)?!1:a?.defaultShift,forwardPush:q(a?.forwardPush)?!1:a?.forwardPush,forwardPushTimes:q(a?.useDefaultEndDate)?0:a?.forwardPushTimes,useDefaultEndDate:q(a?.useDefaultEndDate)?!1:a?.useDefaultEndDate},P.s=I,P.t=d,P.v=w}}return n},{});return!r||q(r)?Promise.reject(new Error("No data found")):Promise.resolve(r)}function B(e,r){return e.replace(/\$\{(\w+)\}/g,(n,t)=>r[t]!==void 0?r[t]:n)}function ue({acc:e,params:r,initRowNum:n,initColNum:t,cellData:m}){const{rangeData:s,currentDay:i,extraArgs:v}=r;v?.teamData;const{cycleType:a,timeIncrement:w,forwardPush:d,forwardPushTimes:I,copyType:h,copyInterval:P,defaultShift:E,templateStr:x,useDefaultEndDate:U}=m.custom;let M=0;switch(a){case"day":{let o="";if(d&&(o=F(s[0],I,"day")),!h){let u="";d?u=o:u=s[0];const T=b(e,n,t);T.v=x?B(x,{v:u}):u,T.t=V.CellValueType.STRING;break}d?M=O(o,s[0],"day"):M=O(s[0],s[1],"day");for(let u=0;u<=Math.abs(M===0?1:M);u++){const T=u*(P+1);let N="";d?N=R(o,"day",u,w):N=R(s[0],"day",u,w);const Y=h==="right"?n:n+T,D=h==="right"?t+T:t,f=b(e,Y,D);f.v=x?B(x,{v:N}):N,f.t=V.CellValueType.STRING}break}case"month":{if(!h){const o=b(e,n,t);o.v=s[0],o.t=V.CellValueType.STRING;break}M=O(s[0],s[1],"month");for(let o=0;o<=Math.abs(M===0?1:M);o++){const u=o*(P+1),T=h==="right"?n:n+u,N=h==="right"?t+u:t,Y=b(e,T,N);Y.v=R(s[0],"month",o,w),Y.t=V.CellValueType.STRING}break}case"year":{let o="";if(d&&(o=F(s[0],I||0,"year")),!h){const u=d?o:s[0],[T,N]=p(u,"year",0,1),Y=b(e,n,t),[,D]=p(s[1],"month",0,1);Y.v=x?B(x,{startTime:c(T).format("YYYY"),endTime:c(N).format("YYYY"),endFormat:c(D).format("YYYY-MM")}):u,Y.t=V.CellValueType.STRING;break}d?M=O(o,s[0],"year"):M=O(s[0],s[1],"year");for(let u=0;u<=Math.abs(M===0?1:M);u++){const T=u*(P+1),N=h==="right"?n:n+T,Y=h==="right"?t+T:t,[D,f]=p(s[0],"year",u,w),l=b(e,N,Y),y=R(s[0],"year",u,w);l.v=x?B(x,{startTime:c(D).format("YYYY"),endTime:c(f).format("YYYY"),endFormat:c(s[1]).format("YYYY-MM")}):y,l.t=V.CellValueType.STRING}break}case"hour":{if(!h){const o=b(e,n,t);if(o.t=V.CellValueType.STRING,E){o.v=c(s[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}o.v=c(i).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}M=O(s[0],s[1],"hour");for(let o=0;o<Math.abs(M===0?1:M);o++){const u=o*(P+1),T=h==="right"?n:n+u,N=h==="right"?t+u:t,Y=b(e,T,N);if(Y.t=V.CellValueType.STRING,E){const D=c(s[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");Y.v=R(D,"hour",o,w);continue}Y.v=R(c(i).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",o,w)}}}}async function fe(e,r){if(!e)return Promise.reject("没有可用的单元格数据");const{extraArgs:n,rangeData:t}=r;if(!t.length)return Promise.reject("处理时间范围失败, rangeData不能为空");n?.teamData;const m=r?.currentDay||c().format("YYYY-MM-DD"),s=Object.entries(e).reduce((i,v)=>{const[a,w]=v;for(const[d,I]of Object.entries(w)){const{custom:h}=I;if(!h)continue;const{cellType:P,cycleType:E,timeIncrement:x,forwardPush:U,forwardPushTimes:M,copyType:o,copyInterval:u,defaultShift:T,useDefaultEndDate:N}=h;if(P==="time"){ue({acc:i,params:r,initRowNum:Number(a),initColNum:Number(d),cellData:I});continue}const Y={cycleType:E,indicatorName:h.indicatorName,indicatorCode:h.indicatorCode,indicatorId:h.indicatorId,indicatorDimensionName:h.indicatorDimensionName,indicatorDimensionConfig:h.indicatorDimensionConfig,required:ne(h?.required)??!1,cellType:h.cellType,defaultShift:h?.defaultShift||!1};let D=0;switch(E){case"day":{let f="";if(U&&(f=F(t[0],M||0,"day")),!o){const l=U?f:t[0],[y,C]=p(l,"day",0,1),S=b(i,a,d);S.custom={...Y,startTime:y,endTime:C};break}U?D=O(f,t[0],"day"):D=O(t[0],t[1],"day");for(let l=0;l<Math.abs(D===0?1:D);l++){const y=l*(u+1),C=U?f:t[0],[S,k]=p(C,"day",l,x),j=o==="right"?a:H(a).add(y).toNumber(),G=o==="right"?H(d).add(y).toNumber():d,J=b(i,j,G);J.custom={...Y,startTime:S,endTime:k}}break}case"month":{if(!o){const[f,l]=p(t[0],"month",0,1),y=b(i,a,d);y.custom={...Y,startTime:f,endTime:l};break}D=O(t[0],t[1],"month");for(let f=0;f<=Math.abs(D===0?1:D);f++){const l=f*(u+1),y=o==="right"?a:H(a).add(l).toNumber(),C=o==="right"?H(d).add(l).toNumber():d,[S,k]=p(t[0],"month",f,x),j=b(i,y,C);j.custom={...Y,startTime:S,endTime:k}}break}case"year":{let f="";if(U&&(f=F(t[0],M||0,"year")),!o){const l=U?f:t[0],[y,C]=p(l,"year",0,1),S=b(i,a,d),[,k]=p(t[1],"month",0,1);S.custom={...Y,startTime:y,endTime:N?k:C};break}U?D=O(f,t[0],"year"):D=O(t[0],t[1],"year");for(let l=0;l<Math.abs(D===0?1:D);l++){const y=l*(u+1),C=o==="right"?a:H(a).add(y).toNumber(),S=o==="right"?H(d).add(y).toNumber():d,[k,j]=p(t[0],"year",l,x),G=b(i,C,S);G.custom={...Y,startTime:k,endTime:j}}break}case"hour":{if(!o){const f=T?t[0]:t[0]??m,[l,y]=p(f,"hour",1,1),C=b(i,a,d);C.custom={...Y,startTime:l,endTime:y};break}D=O(t[0],t[1],"hour");for(let f=0;f<Math.abs(D===0?1:D);f++){const l=f*(u+1),y=o==="right"?a:H(a).add(l).toNumber(),C=o==="right"?H(d).add(l).toNumber():d,S=b(i,y,C);if(T){const J=c(t[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[de,he]=p(J,"hour",f,x);S.custom={...Y,startTime:de,endTime:he};continue}const k=c(m).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[j,G]=p(k,"hour",f,x);S.custom={...Y,startTime:j,endTime:G}}break}}}return i},{});return Promise.resolve(s)}function ce(e){return Object.entries(e).reduce((n,[t,m])=>{const s=Math.max(...Object.keys(m).map(Number));return s>n?n=Number(s):n=Number(n)||0,n},0)}function me(e,r){const n=JSON.parse(JSON.stringify(e||{}));for(const[t,m]of Object.entries(r)){n[t]||(n[t]={});for(const[s,i]of Object.entries(m)){const v=i,a=n[t]?.[s];a?n[t][s]={...a,...v,custom:{...a.custom,...v.custom||{}}}:n[t][s]=v}}return n}const le="./style.css";g.CycleTypeEnum=_,g.ModeEnum=K,g.decimal=H,g.filterIndicatorsCell=ie,g.generateIndicatorsCells=fe,g.generateUUID=z,g.getNumColumns=ce,g.handleClearInput=L,g.initDateRange=ae,g.mergeCellData=me,g.stylePath=le,g.useData=Q,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(y,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("dayjs"),require("@univerjs/presets"),require("decimal.js")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/presets","decimal.js"],f):(y=typeof globalThis<"u"?globalThis:y||self,f(y.TorUniverSheet={},y.dayjs,y.presets,y.Decimal))})(this,(function(y,f,V,B){"use strict";const L=(e,r)=>{for(const n of r)e[n]=null},z=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const n=t=>{const c=Number(t);return(c^crypto.getRandomValues(new Uint8Array(1))[0]&15>>c/4).toString(16)};return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n)}}let e=new Date().getTime(),r=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let t=Math.random()*16;return e>0?(t=(e+t)%16|0,e=Math.floor(e/16)):(t=(r+t)%16|0,r=Math.floor(r/16)),(n==="x"?t:t&3|8).toString(16)})};function Q(e){return{...e?.workbookData,id:e?.id||z(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const W=Object.prototype.toString,Z=(e,r)=>W.call(e)===`[object ${r}]`,X=e=>typeof e<"u",ee=e=>!X(e),te=e=>e!==null&&Z(e,"Object"),q=e=>e==null||typeof e>"u"?!0:A(e)||oe(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:te(e)?Object.keys(e).length===0:!1,re=e=>e===null,ne=e=>ee(e)||re(e),oe=e=>Z(e,"String"),A=e=>e&&Array.isArray(e);class se{value;constructor(r){this.value=new B(r)}add(r){return this.value=this.value.add(r||0),this}subtract(r){return this.value=this.value.sub(r||0),this}multiply(r){return this.value=this.value.mul(r||0),this}divide(r){const n=new B(r);if(n.isZero())throw new Error("除数是0");return this.value=this.value.div(n),this}toFixed(r,n){return this.value=new B(this.value.toFixed(r,n)),this}valueOf(){return this.value}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}}function H(e=0){return new se(e)}var _=(e=>(e.无="no",e.年="year",e.月="month",e.周="week",e.天="day",e.班组="shift",e.小时="hour",e.半小时="half_hour",e))(_||{}),K=(e=>(e.view="view",e.edit="edit",e))(K||{});async function ae(e,r){if(!r)return Promise.reject("日期不能为空");switch(e){case"year":if(A(r))return Promise.resolve(r);const n=f(r);if(!n.isValid())return Promise.reject("无效的日期格式");const t=n.year(),c=`${t}-01`,o=`${t}-12`;return Promise.resolve([c,o]);case"month":if(A(r))return Promise.resolve(r);const i=f(r);if(!i.isValid())return Promise.reject("无效的日期格式");const N=i.startOf("month").format("YYYY-MM-DD"),s=i.endOf("month").format("YYYY-MM-DD");return Promise.resolve([N,s]);case"day":if(A(r))return Promise.resolve(r);const w=f(r);if(!w.isValid())return Promise.reject("无效的日期格式");const d=w.startOf("day").format("YYYY-MM-DD HH:mm:ss"),k=w.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([d,k]);default:return Promise.reject("不支持的周期类型")}}function O(e,r,n){if(!n)return 0;const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[n];return["day","hour"].includes(n)?f(r,t).diff(f(e,t),n)+1:f(r,t).diff(f(e,t),n)}function $(e,r,n){if(!n)throw new Error("日期类型不能为空");const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[n];return f(e).subtract(r,n).format(t)}function v(e,r,n,t){const c="YYYY-MM-DD HH:mm:ss",o=R(e,r,n,t),i=f(o);if(r==="month"){const s=i.month();return s===0?[i.startOf("month").format(c),i.date(25).endOf("day").format(c)]:s===11?[i.subtract(1,"month").date(26).startOf("day").format(c),i.endOf("month").format(c)]:[i.subtract(1,"month").date(26).startOf("day").format(c),i.date(25).endOf("day").format(c)]}const N={year:"year",day:"day",hour:"hour"};return[i.startOf(N[r]).format(c),i.endOf(N[r]).format(c)]}function R(e,r,n,t){const c={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[r];return f(e,c).add(n*t,r).format(c)}function M(e,r,n){return e[r]||(e[r]={}),e[r][n]||(e[r][n]={}),e[r][n]}async function ie(e){if(!e)throw new Error("cellData is required");const r=Object.entries(e).reduce((n,t)=>{const[c,o]=t;for(const[i,N]of Object.entries(o)){const{custom:s,v:w,t:d,s:k}=N;if(!s)continue;const{cellType:h}=s;if(h==="indicator"){const P=M(n,c,i);P.custom={...s,required:q(s?.required)?!1:s?.required,defaultShift:q(s?.defaultShift)?!1:s?.defaultShift,forwardPush:q(s?.forwardPush)?!1:s?.forwardPush,forwardPushTimes:q(s?.useDefaultEndDate)?0:s?.forwardPushTimes,useDefaultEndDate:q(s?.useDefaultEndDate)?!1:s?.useDefaultEndDate},P.s=k,P.t=d,P.v=w}}return n},{});return!r||q(r)?Promise.reject(new Error("No data found")):Promise.resolve(r)}function F(e,r){return e.replace(/\$\{([^}]+)\}/g,(n,t)=>{try{const c=Object.keys(r),o=Object.values(r);return new Function(...c,`return ${t};`)(...o)}catch(c){return console.error(`表达式执行失败: ${t}`,c),n}})}function ue({acc:e,params:r,initRowNum:n,initColNum:t,cellData:c}){const{rangeData:o,currentDay:i,extraArgs:N}=r;N?.teamData;const{cycleType:s,timeIncrement:w,forwardPush:d,forwardPushTimes:k,copyType:h,copyInterval:P,defaultShift:E,templateStr:C,useDefaultEndDate:U}=c.custom;let T=0;switch(s){case"day":{let a="";if(d&&(a=$(o[0],k,"day")),!h){let u="";d?u=a:u=o[0];const b=M(e,n,t);b.v=C?F(C,{businessDate:u,dayjs:f}):f(u).format("YYYY-MM-DD"),b.t=V.CellValueType.STRING;break}d?T=O(a,o[0],"day"):T=O(o[0],o[1],"day");for(let u=0;u<=Math.abs(T===0?1:T);u++){const b=u*(P+1);let p="";d?p=R(a,"day",u,w):p=R(o[0],"day",u,w);const Y=h==="right"?n:n+b,D=h==="right"?t+b:t,l=M(e,Y,D);l.v=C?F(C,{businessDate:p,dayjs:f}):f(p).format("YYYY-MM-DD"),l.t=V.CellValueType.STRING}break}case"month":{if(!h){const[a,u]=v(o[1],"month",0,1),b=M(e,n,t);b.v=f(u).format("YYYY-MM"),b.t=V.CellValueType.STRING;break}T=O(o[0],o[1],"month");for(let a=0;a<=Math.abs(T===0?1:T);a++){const u=a*(P+1),b=h==="right"?n:n+u,p=h==="right"?t+u:t,Y=M(e,b,p);Y.v=R(o[0],"month",a,w),Y.t=V.CellValueType.STRING}break}case"year":{let a="";if(d&&(a=$(o[0],k||0,"year")),!h){const u=d?a:o[0],[b,p]=v(u,"year",0,1),Y=M(e,n,t),[,D]=v(o[1],"month",0,1);Y.v=C?F(C,{startTime:b,endTime:p,rangeData:o,dayjs:f}):u,Y.t=V.CellValueType.STRING;break}d?T=O(a,o[0],"year"):T=O(o[0],o[1],"year");for(let u=0;u<=Math.abs(T===0?1:T);u++){const b=u*(P+1),p=h==="right"?n:n+b,Y=h==="right"?t+b:t,[D,l]=v(o[0],"year",u,w),m=M(e,p,Y),g=R(o[0],"year",u,w);m.v=C?F(C,{startTime:D,endTime:l,rangeData:o,dayjs:f}):g,m.t=V.CellValueType.STRING}break}case"hour":{if(!h){const a=M(e,n,t);if(a.t=V.CellValueType.STRING,E){a.v=f(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}a.v=f(i).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}T=O(o[0],o[1],"hour");for(let a=0;a<Math.abs(T===0?1:T);a++){const u=a*(P+1),b=h==="right"?n:n+u,p=h==="right"?t+u:t,Y=M(e,b,p);if(Y.t=V.CellValueType.STRING,E){const D=f(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");Y.v=R(D,"hour",a,w);continue}Y.v=R(f(i).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",a,w)}}}}async function ce(e,r){if(!e)return Promise.reject("没有可用的单元格数据");const{extraArgs:n,rangeData:t}=r;if(!t.length)return Promise.reject("处理时间范围失败, rangeData不能为空");n?.teamData;const c=r?.currentDay||f().format("YYYY-MM-DD"),o=Object.entries(e).reduce((i,N)=>{const[s,w]=N;for(const[d,k]of Object.entries(w)){const{custom:h}=k;if(!h)continue;const{cellType:P,cycleType:E,timeIncrement:C,forwardPush:U,forwardPushTimes:T,copyType:a,copyInterval:u,defaultShift:b,useDefaultEndDate:p}=h;if(P==="time"){ue({acc:i,params:r,initRowNum:Number(s),initColNum:Number(d),cellData:k});continue}const Y={cycleType:E,indicatorName:h.indicatorName,indicatorCode:h.indicatorCode,indicatorId:h.indicatorId,indicatorDimensionName:h.indicatorDimensionName,indicatorDimensionConfig:h.indicatorDimensionConfig,required:ne(h?.required)??!1,cellType:h.cellType,defaultShift:h?.defaultShift||!1};let D=0;switch(E){case"day":{let l="";if(U&&(l=$(t[0],T||0,"day")),!a){const m=U?l:t[0],[g,x]=v(m,"day",0,1),S=M(i,s,d);S.custom={...Y,startTime:g,endTime:x};break}U?D=O(l,t[0],"day"):D=O(t[0],t[1],"day");for(let m=0;m<Math.abs(D===0?1:D);m++){const g=m*(u+1),x=U?l:t[0],[S,I]=v(x,"day",m,C),j=a==="right"?s:H(s).add(g).toNumber(),G=a==="right"?H(d).add(g).toNumber():d,J=M(i,j,G);J.custom={...Y,startTime:S,endTime:I}}break}case"month":{if(!a){const[l,m]=v(t[1],"month",0,1),g=M(i,s,d);g.custom={...Y,startTime:l,endTime:m};break}D=O(t[0],t[1],"month");for(let l=0;l<=Math.abs(D===0?1:D);l++){const m=l*(u+1),g=a==="right"?s:H(s).add(m).toNumber(),x=a==="right"?H(d).add(m).toNumber():d,[S,I]=v(t[0],"month",l,C),j=M(i,g,x);j.custom={...Y,startTime:S,endTime:I}}break}case"year":{let l="";if(U&&(l=$(t[0],T||0,"year")),!a){const m=U?l:t[0],[g,x]=v(m,"year",0,1),S=M(i,s,d),[,I]=v(t[1],"month",0,1);S.custom={...Y,startTime:g,endTime:p?I:x};break}U?D=O(l,t[0],"year"):D=O(t[0],t[1],"year");for(let m=0;m<Math.abs(D===0?1:D);m++){const g=m*(u+1),x=a==="right"?s:H(s).add(g).toNumber(),S=a==="right"?H(d).add(g).toNumber():d,[I,j]=v(t[0],"year",m,C),G=M(i,x,S);G.custom={...Y,startTime:I,endTime:j}}break}case"hour":{if(!a){const l=b?t[0]:t[0]??c,[m,g]=v(l,"hour",1,1),x=M(i,s,d);x.custom={...Y,startTime:m,endTime:g};break}D=O(t[0],t[1],"hour");for(let l=0;l<Math.abs(D===0?1:D);l++){const m=l*(u+1),g=a==="right"?s:H(s).add(m).toNumber(),x=a==="right"?H(d).add(m).toNumber():d,S=M(i,g,x);if(b){const J=f(t[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[de,he]=v(J,"hour",l,C);S.custom={...Y,startTime:de,endTime:he};continue}const I=f(c).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[j,G]=v(I,"hour",l,C);S.custom={...Y,startTime:j,endTime:G}}break}}}return i},{});return Promise.resolve(o)}function fe(e){return Object.entries(e).reduce((n,[t,c])=>{const o=Math.max(...Object.keys(c).map(Number));return o>n?n=Number(o):n=Number(n)||0,n},0)}function le(e,r){const n=JSON.parse(JSON.stringify(e||{}));for(const[t,c]of Object.entries(r)){n[t]||(n[t]={});for(const[o,i]of Object.entries(c)){const N=i,s=n[t]?.[o];s?n[t][o]={...s,...N,custom:{...s.custom,...N.custom||{}}}:n[t][o]=N}}return n}const me="./style.css";y.CycleTypeEnum=_,y.ModeEnum=K,y.decimal=H,y.filterIndicatorsCell=ie,y.generateIndicatorsCells=ce,y.generateUUID=z,y.getNumColumns=fe,y.handleClearInput=L,y.initDateRange=ae,y.mergeCellData=le,y.stylePath=me,y.useData=Q,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|