tor-univer-sheet 1.1.16 → 1.1.17
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,25 +1,25 @@
|
|
|
1
1
|
import l from "dayjs";
|
|
2
2
|
import { CellValueType as $ } from "@univerjs/presets";
|
|
3
3
|
import K from "decimal.js";
|
|
4
|
-
const dt = (t,
|
|
5
|
-
for (const
|
|
6
|
-
t[
|
|
4
|
+
const dt = (t, r) => {
|
|
5
|
+
for (const o of r)
|
|
6
|
+
t[o] = null;
|
|
7
7
|
}, W = () => {
|
|
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 o = (e) => {
|
|
13
13
|
const f = Number(e);
|
|
14
14
|
return (f ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> f / 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, o);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
let t = (/* @__PURE__ */ new Date()).getTime(),
|
|
20
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (
|
|
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, (o) => {
|
|
21
21
|
let e = Math.random() * 16;
|
|
22
|
-
return t > 0 ? (e = (t + e) % 16 | 0, t = Math.floor(t / 16)) : (e = (
|
|
22
|
+
return t > 0 ? (e = (t + e) % 16 | 0, t = Math.floor(t / 16)) : (e = (r + e) % 16 | 0, r = Math.floor(r / 16)), (o === "x" ? e : e & 3 | 8).toString(16);
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
function ht(t) {
|
|
@@ -30,35 +30,35 @@ function ht(t) {
|
|
|
30
30
|
appVersion: t?.appVersion || "1.0.0"
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
const X = Object.prototype.toString, L = (t,
|
|
33
|
+
const X = Object.prototype.toString, L = (t, r) => X.call(t) === `[object ${r}]`, tt = (t) => typeof t < "u", et = (t) => !tt(t), rt = (t) => t !== null && L(t, "Object"), E = (t) => t == null || typeof t > "u" ? !0 : J(t) || st(t) ? t.length === 0 : t instanceof Map || t instanceof Set ? t.size === 0 : rt(t) ? Object.keys(t).length === 0 : !1, ot = (t) => t === null, nt = (t) => et(t) || ot(t), st = (t) => L(t, "String"), J = (t) => t && Array.isArray(t);
|
|
34
34
|
class at {
|
|
35
35
|
value;
|
|
36
|
-
constructor(
|
|
37
|
-
this.value = new K(
|
|
36
|
+
constructor(r) {
|
|
37
|
+
this.value = new K(r);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* 加法运算
|
|
41
41
|
* @param num 要加的数
|
|
42
42
|
* @returns DecimalChain 实例,支持链式调用
|
|
43
43
|
*/
|
|
44
|
-
add(
|
|
45
|
-
return this.value = this.value.add(
|
|
44
|
+
add(r) {
|
|
45
|
+
return this.value = this.value.add(r || 0), this;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* 减法运算
|
|
49
49
|
* @param num 要减的数
|
|
50
50
|
* @returns DecimalChain 实例,支持链式调用
|
|
51
51
|
*/
|
|
52
|
-
subtract(
|
|
53
|
-
return this.value = this.value.sub(
|
|
52
|
+
subtract(r) {
|
|
53
|
+
return this.value = this.value.sub(r || 0), this;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* 乘法运算
|
|
57
57
|
* @param num 要乘的数
|
|
58
58
|
* @returns DecimalChain 实例,支持链式调用
|
|
59
59
|
*/
|
|
60
|
-
multiply(
|
|
61
|
-
return this.value = this.value.mul(
|
|
60
|
+
multiply(r) {
|
|
61
|
+
return this.value = this.value.mul(r || 0), this;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* 除法运算
|
|
@@ -66,11 +66,11 @@ class at {
|
|
|
66
66
|
* @returns DecimalChain 实例,支持链式调用
|
|
67
67
|
* @throws 当除数为0时抛出错误
|
|
68
68
|
*/
|
|
69
|
-
divide(
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
69
|
+
divide(r) {
|
|
70
|
+
const o = new K(r);
|
|
71
|
+
if (o.isZero())
|
|
72
72
|
throw new Error("除数是0");
|
|
73
|
-
return this.value = this.value.div(
|
|
73
|
+
return this.value = this.value.div(o), this;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* 保留小数位数
|
|
@@ -78,8 +78,8 @@ class at {
|
|
|
78
78
|
* @param rounding 舍入模式,默认为四舍五入
|
|
79
79
|
* @returns DecimalChain 实例,支持链式调用
|
|
80
80
|
*/
|
|
81
|
-
toFixed(
|
|
82
|
-
return this.value = new K(this.value.toFixed(
|
|
81
|
+
toFixed(r, o) {
|
|
82
|
+
return this.value = new K(this.value.toFixed(r, o)), this;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* 返回当前值
|
|
@@ -107,29 +107,29 @@ function C(t = 0) {
|
|
|
107
107
|
return new at(t);
|
|
108
108
|
}
|
|
109
109
|
var it = /* @__PURE__ */ ((t) => (t.无 = "no", t.年 = "year", t.月 = "month", t.周 = "week", t.天 = "day", t.班组 = "shift", t.小时 = "hour", t.半小时 = "half_hour", t))(it || {}), ct = /* @__PURE__ */ ((t) => (t.view = "view", t.edit = "edit", t))(ct || {});
|
|
110
|
-
async function Yt(t,
|
|
111
|
-
if (!
|
|
110
|
+
async function Yt(t, r) {
|
|
111
|
+
if (!r) return Promise.reject("日期不能为空");
|
|
112
112
|
switch (t) {
|
|
113
113
|
case "year":
|
|
114
|
-
if (J(
|
|
115
|
-
return Promise.resolve(
|
|
116
|
-
const
|
|
117
|
-
if (!
|
|
114
|
+
if (J(r))
|
|
115
|
+
return Promise.resolve(r);
|
|
116
|
+
const o = l(r);
|
|
117
|
+
if (!o.isValid())
|
|
118
118
|
return Promise.reject("无效的日期格式");
|
|
119
|
-
const e =
|
|
119
|
+
const e = o.year(), f = `${e}-01`, n = `${e}-12`;
|
|
120
120
|
return Promise.resolve([f, n]);
|
|
121
121
|
case "month":
|
|
122
|
-
if (J(
|
|
123
|
-
return Promise.resolve(
|
|
124
|
-
const h = l(
|
|
122
|
+
if (J(r))
|
|
123
|
+
return Promise.resolve(r);
|
|
124
|
+
const h = l(r);
|
|
125
125
|
if (!h.isValid())
|
|
126
126
|
return Promise.reject("无效的日期格式");
|
|
127
127
|
const k = h.startOf("month").format("YYYY-MM-DD"), c = h.endOf("month").format("YYYY-MM-DD");
|
|
128
128
|
return Promise.resolve([k, c]);
|
|
129
129
|
case "day":
|
|
130
|
-
if (J(
|
|
131
|
-
return Promise.resolve(
|
|
132
|
-
const Y = l(
|
|
130
|
+
if (J(r))
|
|
131
|
+
return Promise.resolve(r);
|
|
132
|
+
const Y = l(r);
|
|
133
133
|
if (!Y.isValid())
|
|
134
134
|
return Promise.reject("无效的日期格式");
|
|
135
135
|
const p = Y.startOf("day").format("YYYY-MM-DD HH:mm:ss"), d = Y.endOf("day").format("YYYY-MM-DD HH:mm:ss");
|
|
@@ -138,59 +138,52 @@ async function Yt(t, o) {
|
|
|
138
138
|
return Promise.reject("不支持的周期类型");
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function H(t,
|
|
142
|
-
|
|
143
|
-
const e = {
|
|
144
|
-
year: "YYYY",
|
|
145
|
-
month: "YYYY-MM",
|
|
146
|
-
day: "YYYY-MM-DD",
|
|
147
|
-
hour: "HH:mm:ss"
|
|
148
|
-
}[r];
|
|
149
|
-
return ["day", "hour"].includes(r) ? l(o, e).diff(l(t, e), r) : l(o, e).diff(l(t, e), r);
|
|
141
|
+
function H(t, r, o) {
|
|
142
|
+
return o ? l(r).diff(l(t), o) : 0;
|
|
150
143
|
}
|
|
151
|
-
function z(t,
|
|
152
|
-
if (!
|
|
144
|
+
function z(t, r, o) {
|
|
145
|
+
if (!o)
|
|
153
146
|
throw new Error("日期类型不能为空");
|
|
154
147
|
const e = {
|
|
155
148
|
year: "YYYY",
|
|
156
149
|
month: "YYYY-MM",
|
|
157
150
|
day: "YYYY-MM-DD",
|
|
158
151
|
hour: "HH:mm:ss"
|
|
159
|
-
}[
|
|
160
|
-
return l(t).subtract(
|
|
152
|
+
}[o];
|
|
153
|
+
return l(t).subtract(r, o).format(e);
|
|
161
154
|
}
|
|
162
|
-
function S(t,
|
|
163
|
-
const f = "YYYY-MM-DD HH:mm:ss", n = A(t,
|
|
164
|
-
if (
|
|
155
|
+
function S(t, r, o, e) {
|
|
156
|
+
const f = "YYYY-MM-DD HH:mm:ss", n = A(t, r, o, e), h = l(n);
|
|
157
|
+
if (r === "month") {
|
|
165
158
|
const c = h.month();
|
|
166
159
|
return c === 0 ? [h.startOf("month").format(f), h.date(25).endOf("day").format(f)] : c === 11 ? [h.subtract(1, "month").date(26).startOf("day").format(f), h.endOf("month").format(f)] : [h.subtract(1, "month").date(26).startOf("day").format(f), h.date(25).endOf("day").format(f)];
|
|
167
160
|
}
|
|
168
161
|
const k = { year: "year", day: "day", hour: "hour" };
|
|
169
|
-
return [h.startOf(k[
|
|
162
|
+
return [h.startOf(k[r]).format(f), h.endOf(k[r]).format(f)];
|
|
170
163
|
}
|
|
171
|
-
function A(t,
|
|
164
|
+
function A(t, r, o, e) {
|
|
172
165
|
const f = {
|
|
173
166
|
year: "YYYY",
|
|
174
167
|
month: "YYYY-MM",
|
|
175
168
|
day: "YYYY-MM-DD",
|
|
176
169
|
hour: "YYYY-MM-DD HH:mm:ss"
|
|
177
|
-
}[
|
|
178
|
-
return l(t, f).add(
|
|
170
|
+
}[r];
|
|
171
|
+
return l(t, f).add(o * e, r).format(f);
|
|
179
172
|
}
|
|
180
|
-
function g(t,
|
|
181
|
-
return t[
|
|
173
|
+
function g(t, r, o) {
|
|
174
|
+
return t[r] || (t[r] = {}), t[r][o] || (t[r][o] = {}), t[r][o];
|
|
182
175
|
}
|
|
183
176
|
async function Dt(t) {
|
|
184
177
|
if (!t)
|
|
185
178
|
throw new Error("cellData is required");
|
|
186
|
-
const
|
|
179
|
+
const r = Object.entries(t).reduce((o, e) => {
|
|
187
180
|
const [f, n] = e;
|
|
188
181
|
for (const [h, k] of Object.entries(n)) {
|
|
189
182
|
const { custom: c, v: Y, t: p, s: d } = k;
|
|
190
183
|
if (!c) continue;
|
|
191
184
|
const { cellType: q } = c, i = !c.hasOwnProperty("writeBack") || E(c?.writeBack) ? !0 : c.writeBack;
|
|
192
185
|
if (q === "indicator") {
|
|
193
|
-
const j = g(
|
|
186
|
+
const j = g(o, f, h);
|
|
194
187
|
j.custom = {
|
|
195
188
|
...c,
|
|
196
189
|
required: E(c?.required) ? !1 : c?.required,
|
|
@@ -200,31 +193,31 @@ async function Dt(t) {
|
|
|
200
193
|
useDefaultEndDate: E(c?.useDefaultEndDate) ? !1 : c?.useDefaultEndDate,
|
|
201
194
|
copyType: E(c?.copyType) ? "" : c?.copyType,
|
|
202
195
|
writeBack: i
|
|
203
|
-
}, j.s = d, j.t = p, j.v = Y;
|
|
196
|
+
}, j.s = d, j.t = p, j.v = Y || "";
|
|
204
197
|
}
|
|
205
198
|
}
|
|
206
|
-
return
|
|
199
|
+
return o;
|
|
207
200
|
}, {});
|
|
208
|
-
return !
|
|
201
|
+
return !r || E(r) ? Promise.reject(new Error("No data found")) : Promise.resolve(r);
|
|
209
202
|
}
|
|
210
|
-
function F(t,
|
|
211
|
-
return t.replace(/\$\{([^}]+)\}/g, (
|
|
203
|
+
function F(t, r) {
|
|
204
|
+
return t.replace(/\$\{([^}]+)\}/g, (o, e) => {
|
|
212
205
|
try {
|
|
213
|
-
const f = Object.keys(
|
|
206
|
+
const f = Object.keys(r), n = Object.values(r);
|
|
214
207
|
return new Function(...f, `return ${e};`)(...n);
|
|
215
208
|
} catch (f) {
|
|
216
|
-
return console.error(`表达式执行失败: ${e}`, f),
|
|
209
|
+
return console.error(`表达式执行失败: ${e}`, f), o;
|
|
217
210
|
}
|
|
218
211
|
});
|
|
219
212
|
}
|
|
220
213
|
function ut({
|
|
221
214
|
acc: t,
|
|
222
|
-
params:
|
|
223
|
-
initRowNum:
|
|
215
|
+
params: r,
|
|
216
|
+
initRowNum: o,
|
|
224
217
|
initColNum: e,
|
|
225
218
|
cellData: f
|
|
226
219
|
}) {
|
|
227
|
-
const { rangeData: n, currentDay: h, extraArgs: k } =
|
|
220
|
+
const { rangeData: n, currentDay: h, extraArgs: k } = r, c = k?.teamData || {}, { cycleType: Y, timeIncrement: p, forwardPush: d, forwardPushTimes: q, copyType: i, copyInterval: j, defaultShift: O, templateStr: P, useDefaultEndDate: Z } = f.custom;
|
|
228
221
|
let y = 0;
|
|
229
222
|
switch (Y) {
|
|
230
223
|
case "day": {
|
|
@@ -237,7 +230,7 @@ function ut({
|
|
|
237
230
|
)), !i) {
|
|
238
231
|
let u = "";
|
|
239
232
|
d ? u = s : u = n[0];
|
|
240
|
-
const a = g(t,
|
|
233
|
+
const a = g(t, o, e);
|
|
241
234
|
a.v = P ? F(P, { businessDate: u, dayjs: l }) : l(u).format("YYYY-MM-DD"), a.t = $.STRING;
|
|
242
235
|
break;
|
|
243
236
|
}
|
|
@@ -256,14 +249,14 @@ function ut({
|
|
|
256
249
|
const a = u * (j + 1);
|
|
257
250
|
let M = "";
|
|
258
251
|
d ? M = A(s, "day", u, p) : M = A(n[0], "day", u, p);
|
|
259
|
-
const w = i === "right" ?
|
|
252
|
+
const w = i === "right" ? o : o + a, R = i === "right" ? e + a : e, G = g(t, w, R);
|
|
260
253
|
G.v = P ? F(P, { businessDate: M, dayjs: l }) : l(M).format("YYYY-MM-DD"), G.t = $.STRING;
|
|
261
254
|
}
|
|
262
255
|
break;
|
|
263
256
|
}
|
|
264
257
|
case "month": {
|
|
265
258
|
if (!i) {
|
|
266
|
-
const [s, u] = S(n[1], "month", 0, 1), a = g(t,
|
|
259
|
+
const [s, u] = S(n[1], "month", 0, 1), a = g(t, o, e);
|
|
267
260
|
a.v = l(u).format("YYYY-MM"), a.t = $.STRING;
|
|
268
261
|
break;
|
|
269
262
|
}
|
|
@@ -274,7 +267,7 @@ function ut({
|
|
|
274
267
|
/* month */
|
|
275
268
|
);
|
|
276
269
|
for (let s = 0; s <= Math.abs(y === 0 ? 1 : y); s++) {
|
|
277
|
-
const u = s * (j + 1), a = i === "right" ?
|
|
270
|
+
const u = s * (j + 1), a = i === "right" ? o : o + u, M = i === "right" ? e + u : e, w = g(t, a, M);
|
|
278
271
|
w.v = A(n[0], "month", s, p), w.t = $.STRING;
|
|
279
272
|
}
|
|
280
273
|
break;
|
|
@@ -287,7 +280,7 @@ function ut({
|
|
|
287
280
|
"year"
|
|
288
281
|
/* year */
|
|
289
282
|
)), !i) {
|
|
290
|
-
const u = d ? s : n[0], [a, M] = S(u, "year", 0, 1), w = g(t,
|
|
283
|
+
const u = d ? s : n[0], [a, M] = S(u, "year", 0, 1), w = g(t, o, e), [, R] = S(n[1], "month", 0, 1);
|
|
291
284
|
w.v = P ? F(P, {
|
|
292
285
|
startTime: a,
|
|
293
286
|
endTime: M,
|
|
@@ -308,7 +301,7 @@ function ut({
|
|
|
308
301
|
/* year */
|
|
309
302
|
);
|
|
310
303
|
for (let u = 0; u <= Math.abs(y === 0 ? 1 : y); u++) {
|
|
311
|
-
const a = u * (j + 1), M = i === "right" ?
|
|
304
|
+
const a = u * (j + 1), M = i === "right" ? o : o + a, w = i === "right" ? e + a : e, [R, G] = S(n[0], "year", u, p), x = g(t, M, w), N = A(n[0], "year", u, p);
|
|
312
305
|
x.v = P ? F(P, {
|
|
313
306
|
startTime: R,
|
|
314
307
|
endTime: G,
|
|
@@ -320,7 +313,7 @@ function ut({
|
|
|
320
313
|
}
|
|
321
314
|
case "hour": {
|
|
322
315
|
if (!i) {
|
|
323
|
-
const s = g(t,
|
|
316
|
+
const s = g(t, o, e);
|
|
324
317
|
if (s.t = $.STRING, O) {
|
|
325
318
|
s.v = l(n[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
326
319
|
break;
|
|
@@ -335,7 +328,7 @@ function ut({
|
|
|
335
328
|
/* hour */
|
|
336
329
|
);
|
|
337
330
|
for (let s = 0; s <= Math.abs(y === 0 ? 1 : y); s++) {
|
|
338
|
-
const u = s * (j + 1), a = i === "right" ?
|
|
331
|
+
const u = s * (j + 1), a = i === "right" ? o : o + u, M = i === "right" ? e + u : e, w = g(t, a, M);
|
|
339
332
|
if (w.t = $.STRING, O) {
|
|
340
333
|
const R = l(n[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
341
334
|
w.v = A(R, "hour", s, p);
|
|
@@ -347,7 +340,7 @@ function ut({
|
|
|
347
340
|
}
|
|
348
341
|
case "shift": {
|
|
349
342
|
if (!i) {
|
|
350
|
-
const s = g(t,
|
|
343
|
+
const s = g(t, o, e);
|
|
351
344
|
s.t = $.STRING, s.v = P ? F(P, {
|
|
352
345
|
rangeData: n,
|
|
353
346
|
dayjs: l
|
|
@@ -357,7 +350,7 @@ function ut({
|
|
|
357
350
|
if (!c.length)
|
|
358
351
|
throw new Error("没有获取到当班数据");
|
|
359
352
|
for (let s = 0; s < c.length; s++) {
|
|
360
|
-
const u = c[s], { startDatetime: a, endDatetime: M } = u, w = s * (j + 1), R = i === "right" ?
|
|
353
|
+
const u = c[s], { startDatetime: a, endDatetime: M } = u, w = s * (j + 1), R = i === "right" ? o : C(o).add(w).toNumber(), G = i === "right" ? C(e).add(w).toNumber() : e, x = g(t, R, G);
|
|
361
354
|
x.v = P ? F(P, {
|
|
362
355
|
team: u
|
|
363
356
|
}) : a;
|
|
@@ -366,13 +359,13 @@ function ut({
|
|
|
366
359
|
}
|
|
367
360
|
}
|
|
368
361
|
}
|
|
369
|
-
async function yt(t,
|
|
362
|
+
async function yt(t, r) {
|
|
370
363
|
if (!t)
|
|
371
364
|
return Promise.reject("没有可用的单元格数据");
|
|
372
|
-
const { extraArgs:
|
|
365
|
+
const { extraArgs: o, rangeData: e } = r;
|
|
373
366
|
if (!e.length)
|
|
374
367
|
return Promise.reject("处理时间范围失败, rangeData不能为空");
|
|
375
|
-
const f =
|
|
368
|
+
const f = o?.teamData || [], { periodicityTime: n } = r, h = r?.currentDay || l().format("YYYY-MM-DD"), k = (Y, p) => n ? parseInt(n.split(":")[0], 10) < 12 ? [l(Y).format("YYYY-MM-DD") + " " + n, l(p).add(1, "day").format("YYYY-MM-DD") + " " + n] : [l(Y).subtract(1, "day").format("YYYY-MM-DD") + " " + n, l(p).format("YYYY-MM-DD") + " " + n] : [Y, p], c = Object.entries(t).reduce((Y, p) => {
|
|
376
369
|
const [d, q] = p;
|
|
377
370
|
for (const [i, j] of Object.entries(q)) {
|
|
378
371
|
const { custom: O } = j;
|
|
@@ -390,7 +383,7 @@ async function yt(t, o) {
|
|
|
390
383
|
useDefaultEndDate: G
|
|
391
384
|
} = O;
|
|
392
385
|
if (P === "time") {
|
|
393
|
-
ut({ acc: Y, params:
|
|
386
|
+
ut({ acc: Y, params: r, initRowNum: Number(d), initColNum: Number(i), cellData: j });
|
|
394
387
|
continue;
|
|
395
388
|
}
|
|
396
389
|
const x = {
|
|
@@ -577,28 +570,28 @@ async function yt(t, o) {
|
|
|
577
570
|
return Promise.resolve(c);
|
|
578
571
|
}
|
|
579
572
|
function bt(t) {
|
|
580
|
-
return Object.entries(t).reduce((
|
|
573
|
+
return Object.entries(t).reduce((o, [e, f]) => {
|
|
581
574
|
const n = Math.max(...Object.keys(f).map(Number));
|
|
582
|
-
return n >
|
|
575
|
+
return n > o ? o = Number(n) : o = Number(o) || 0, o;
|
|
583
576
|
}, 0);
|
|
584
577
|
}
|
|
585
|
-
function gt(t,
|
|
586
|
-
const
|
|
587
|
-
for (const [e, f] of Object.entries(
|
|
588
|
-
|
|
578
|
+
function gt(t, r) {
|
|
579
|
+
const o = JSON.parse(JSON.stringify(t || {}));
|
|
580
|
+
for (const [e, f] of Object.entries(r)) {
|
|
581
|
+
o[e] || (o[e] = {});
|
|
589
582
|
for (const [n, h] of Object.entries(f)) {
|
|
590
|
-
const k = h, c =
|
|
591
|
-
c ?
|
|
583
|
+
const k = h, c = o[e]?.[n];
|
|
584
|
+
c ? o[e][n] = {
|
|
592
585
|
...c,
|
|
593
586
|
...k,
|
|
594
587
|
custom: {
|
|
595
588
|
...c.custom,
|
|
596
589
|
...k.custom
|
|
597
590
|
}
|
|
598
|
-
} :
|
|
591
|
+
} : o[e][n] = k;
|
|
599
592
|
}
|
|
600
593
|
}
|
|
601
|
-
return
|
|
594
|
+
return o;
|
|
602
595
|
}
|
|
603
596
|
const Mt = "./style.css";
|
|
604
597
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(M,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("dayjs"),require("@univerjs/presets"),require("decimal.js")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/presets","decimal.js"],a):(M=typeof globalThis<"u"?globalThis:M||self,a(M.TorUniverSheet={},M.dayjs,M.presets,M.Decimal))})(this,(function(M,a,E,_){"use strict";const te=(e,n)=>{for(const r of n)e[r]=null},Q=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const r=t=>{const l=Number(t);return(l^crypto.getRandomValues(new Uint8Array(1))[0]&15>>l/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 re(e){return{...e?.workbookData,id:e?.id||Q(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const ne=Object.prototype.toString,W=(e,n)=>ne.call(e)===`[object ${n}]`,oe=e=>typeof e<"u",se=e=>!oe(e),ae=e=>e!==null&&W(e,"Object"),$=e=>e==null||typeof e>"u"?!0:z(e)||ce(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:ae(e)?Object.keys(e).length===0:!1,ie=e=>e===null,ue=e=>se(e)||ie(e),ce=e=>W(e,"String"),z=e=>e&&Array.isArray(e);class fe{value;constructor(n){this.value=new _(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 _(n);if(r.isZero())throw new Error("除数是0");return this.value=this.value.div(r),this}toFixed(n,r){return this.value=new _(this.value.toFixed(n,r)),this}valueOf(){return this.value}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}}function H(e=0){return new fe(e)}var X=(e=>(e.无="no",e.年="year",e.月="month",e.周="week",e.天="day",e.班组="shift",e.小时="hour",e.半小时="half_hour",e))(X||{}),ee=(e=>(e.view="view",e.edit="edit",e))(ee||{});async function le(e,n){if(!n)return Promise.reject("日期不能为空");switch(e){case"year":if(z(n))return Promise.resolve(n);const r=a(n);if(!r.isValid())return Promise.reject("无效的日期格式");const t=r.year(),l=`${t}-01`,o=`${t}-12`;return Promise.resolve([l,o]);case"month":if(z(n))return Promise.resolve(n);const h=a(n);if(!h.isValid())return Promise.reject("无效的日期格式");const O=h.startOf("month").format("YYYY-MM-DD"),c=h.endOf("month").format("YYYY-MM-DD");return Promise.resolve([O,c]);case"day":if(z(n))return Promise.resolve(n);const Y=a(n);if(!Y.isValid())return Promise.reject("无效的日期格式");const N=Y.startOf("day").format("YYYY-MM-DD HH:mm:ss"),d=Y.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([N,d]);default:return Promise.reject("不支持的周期类型")}}function V(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),a(n,t).diff(a(e,t),r)}function Z(e,n,r){if(!r)throw new Error("日期类型不能为空");const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[r];return a(e).subtract(n,r).format(t)}function k(e,n,r,t){const l="YYYY-MM-DD HH:mm:ss",o=A(e,n,r,t),h=a(o);if(n==="month"){const c=h.month();return c===0?[h.startOf("month").format(l),h.date(25).endOf("day").format(l)]:c===11?[h.subtract(1,"month").date(26).startOf("day").format(l),h.endOf("month").format(l)]:[h.subtract(1,"month").date(26).startOf("day").format(l),h.date(25).endOf("day").format(l)]}const O={year:"year",day:"day",hour:"hour"};return[h.startOf(O[n]).format(l),h.endOf(O[n]).format(l)]}function A(e,n,r,t){const l={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[n];return a(e,l).add(r*t,n).format(l)}function g(e,n,r){return e[n]||(e[n]={}),e[n][r]||(e[n][r]={}),e[n][r]}async function me(e){if(!e)throw new Error("cellData is required");const n=Object.entries(e).reduce((r,t)=>{const[l,o]=t;for(const[h,O]of Object.entries(o)){const{custom:c,v:Y,t:N,s:d}=O;if(!c)continue;const{cellType:J}=c,u=!c.hasOwnProperty("writeBack")||$(c?.writeBack)?!0:c.writeBack;if(J==="indicator"){const I=g(r,l,h);I.custom={...c,required:$(c?.required)?!1:c?.required,defaultShift:$(c?.defaultShift)?!1:c?.defaultShift,forwardPush:$(c?.forwardPush)?!1:c?.forwardPush,forwardPushTimes:$(c?.useDefaultEndDate)?0:c?.forwardPushTimes,useDefaultEndDate:$(c?.useDefaultEndDate)?!1:c?.useDefaultEndDate,copyType:$(c?.copyType)?"":c?.copyType,writeBack:u},I.s=d,I.t=N,I.v=Y}}return r},{});return!n||$(n)?Promise.reject(new Error("No data found")):Promise.resolve(n)}function j(e,n){return e.replace(/\$\{([^}]+)\}/g,(r,t)=>{try{const l=Object.keys(n),o=Object.values(n);return new Function(...l,`return ${t};`)(...o)}catch(l){return console.error(`表达式执行失败: ${t}`,l),r}})}function de({acc:e,params:n,initRowNum:r,initColNum:t,cellData:l}){const{rangeData:o,currentDay:h,extraArgs:O}=n,c=O?.teamData||{},{cycleType:Y,timeIncrement:N,forwardPush:d,forwardPushTimes:J,copyType:u,copyInterval:I,defaultShift:S,templateStr:P,useDefaultEndDate:K}=l.custom;let b=0;switch(Y){case"day":{let s="";if(d&&(s=Z(o[0],J,"day")),!u){let f="";d?f=s:f=o[0];const i=g(e,r,t);i.v=P?j(P,{businessDate:f,dayjs:a}):a(f).format("YYYY-MM-DD"),i.t=E.CellValueType.STRING;break}d?b=V(s,o[0],"day"):(b=V(o[0],o[1],"day"),console.log("copyNum",b));for(let f=0;f<=Math.abs(b===0?1:b);f++){const i=f*(I+1);let w="";d?w=A(s,"day",f,N):w=A(o[0],"day",f,N);const T=u==="right"?r:r+i,R=u==="right"?t+i:t,G=g(e,T,R);G.v=P?j(P,{businessDate:w,dayjs:a}):a(w).format("YYYY-MM-DD"),G.t=E.CellValueType.STRING}break}case"month":{if(!u){const[s,f]=k(o[1],"month",0,1),i=g(e,r,t);i.v=a(f).format("YYYY-MM"),i.t=E.CellValueType.STRING;break}b=V(o[0],o[1],"month");for(let s=0;s<=Math.abs(b===0?1:b);s++){const f=s*(I+1),i=u==="right"?r:r+f,w=u==="right"?t+f:t,T=g(e,i,w);T.v=A(o[0],"month",s,N),T.t=E.CellValueType.STRING}break}case"year":{let s="";if(d&&(s=Z(o[0],J||0,"year")),!u){const f=d?s:o[0],[i,w]=k(f,"year",0,1),T=g(e,r,t),[,R]=k(o[1],"month",0,1);T.v=P?j(P,{startTime:i,endTime:w,rangeData:o,dayjs:a}):f,T.t=E.CellValueType.STRING;break}d?b=V(s,o[0],"year"):b=V(o[0],o[1],"year");for(let f=0;f<=Math.abs(b===0?1:b);f++){const i=f*(I+1),w=u==="right"?r:r+i,T=u==="right"?t+i:t,[R,G]=k(o[0],"year",f,N),v=g(e,w,T),C=A(o[0],"year",f,N);v.v=P?j(P,{startTime:R,endTime:G,rangeData:o,dayjs:a}):C,v.t=E.CellValueType.STRING}break}case"hour":{if(!u){const s=g(e,r,t);if(s.t=E.CellValueType.STRING,S){s.v=a(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}s.v=a(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}b=V(o[0],o[1],"hour");for(let s=0;s<=Math.abs(b===0?1:b);s++){const f=s*(I+1),i=u==="right"?r:r+f,w=u==="right"?t+f:t,T=g(e,i,w);if(T.t=E.CellValueType.STRING,S){const R=a(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");T.v=A(R,"hour",s,N);continue}T.v=A(a(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",s,N)}break}case"shift":{if(!u){const s=g(e,r,t);s.t=E.CellValueType.STRING,s.v=P?j(P,{rangeData:o,dayjs:a}):o[0];break}if(!c.length)throw new Error("没有获取到当班数据");for(let s=0;s<c.length;s++){const f=c[s],{startDatetime:i,endDatetime:w}=f,T=s*(I+1),R=u==="right"?r:H(r).add(T).toNumber(),G=u==="right"?H(t).add(T).toNumber():t,v=g(e,R,G);v.v=P?j(P,{team:f}):i}break}}}async function he(e,n){if(!e)return Promise.reject("没有可用的单元格数据");const{extraArgs:r,rangeData:t}=n;if(!t.length)return Promise.reject("处理时间范围失败, rangeData不能为空");const l=r?.teamData||[],{periodicityTime:o}=n,h=n?.currentDay||a().format("YYYY-MM-DD"),O=(Y,N)=>o?parseInt(o.split(":")[0],10)<12?[a(Y).format("YYYY-MM-DD")+" "+o,a(N).add(1,"day").format("YYYY-MM-DD")+" "+o]:[a(Y).subtract(1,"day").format("YYYY-MM-DD")+" "+o,a(N).format("YYYY-MM-DD")+" "+o]:[Y,N],c=Object.entries(e).reduce((Y,N)=>{const[d,J]=N;for(const[u,I]of Object.entries(J)){const{custom:S}=I;if(!S)continue;const{cellType:P,cycleType:K,timeIncrement:b,forwardPush:s,forwardPushTimes:f,copyType:i,copyInterval:w,defaultShift:T,useDefaultStartDate:R,useDefaultEndDate:G}=S;if(P==="time"){de({acc:Y,params:n,initRowNum:Number(d),initColNum:Number(u),cellData:I});continue}const v={cycleType:K,indicatorName:S.indicatorName,indicatorCode:S.indicatorCode,indicatorId:S.indicatorId,indicatorDimensionName:S.indicatorDimensionName,indicatorDimensionConfig:S.indicatorDimensionConfig,required:ue(S?.required)??!1,cellType:S.cellType,defaultShift:S?.defaultShift||!1,writeBack:$(S?.writeBack)?!0:S.writeBack};let C=0;switch(K){case"day":{let m="";if(s&&(m=Z(t[0],f||0,"day")),!i){const D=s?m:t[0],[p,y]=O(...k(D,"day",0,1)),x=g(Y,d,u);x.custom={...v,startTime:p,endTime:y};break}s?C=V(m,t[0],"day"):C=V(t[0],t[1],"day");for(let D=0;D<=Math.abs(C===0?1:C);D++){const p=D*(w+1),y=s?m:t[0],[x,B]=O(...k(y,"day",D,b)),U=i==="right"?d:H(d).add(p).toNumber(),q=i==="right"?H(u).add(p).toNumber():u,F=g(Y,U,q);F.custom={...v,startTime:x,endTime:B}}break}case"month":{if(!i){const[m,D]=k(t[1],"month",0,1),p=g(Y,d,u);p.custom={...v,startTime:m,endTime:D};break}C=V(t[0],t[1],"month");for(let m=0;m<=Math.abs(C===0?1:C);m++){const D=m*(w+1),p=i==="right"?d:H(d).add(D).toNumber(),y=i==="right"?H(u).add(D).toNumber():u,[x,B]=k(t[0],"month",m,b),U=g(Y,p,y);U.custom={...v,startTime:x,endTime:B}}break}case"year":{let m="",D="",p="";if(s){m=Z(t[0],f||0,"year");const y=a(t[1]).format("MM");D=a(`${m}-${y+1}`).format("YYYY-MM"),p=a(`${m}-${y+2}`).format("YYYY-MM")}if(!i){const y=s?m:t[0],[x,B]=k(y,"year",0,1),U=g(Y,d,u),[,q]=k(D,"month",0,1),[F]=k(p,"month",0,1);U.custom={...v,startTime:R?F:x,endTime:G?q:B};break}s?C=V(m,t[0],"year"):C=V(t[0],t[1],"year");for(let y=0;y<=Math.abs(C===0?1:C);y++){const x=y*(w+1),B=i==="right"?d:H(d).add(x).toNumber(),U=i==="right"?H(u).add(x).toNumber():u,[q,F]=k(t[0],"year",y,b),L=g(Y,B,U);L.custom={...v,startTime:q,endTime:F}}break}case"hour":{if(!i){const m=T?t[0]:t[0]??h,[D,p]=k(m,"hour",1,1),y=g(Y,d,u);y.custom={...v,startTime:D,endTime:p};break}C=V(t[0],t[1],"hour");for(let m=0;m<=Math.abs(C===0?1:C);m++){const D=m*(w+1),p=i==="right"?d:H(d).add(D).toNumber(),y=i==="right"?H(u).add(D).toNumber():u,x=g(Y,p,y);if(T){const F=a(t[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[L,be]=k(F,"hour",m,b);x.custom={...v,startTime:L,endTime:be};continue}const B=a(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[U,q]=k(B,"hour",m,b);x.custom={...v,startTime:U,endTime:q}}break}case"shift":{if(!i){const[m,D]=t,p=g(Y,d,u);p.custom={...v,startTime:m,endTime:D};break}if(!l.length)throw new Error("没有获取到当班数据");for(let m=0;m<l.length;m++){const D=l[m],{startDatetime:p,endDatetime:y}=D,x=m*(w+1),B=i==="right"?d:H(d).add(x).toNumber(),U=i==="right"?H(u).add(x).toNumber():u,q=g(Y,B,U);q.custom={...v,startTime:p,endTime:y}}break}}}return Y},{});return Promise.resolve(c)}function Ye(e){return Object.entries(e).reduce((r,[t,l])=>{const o=Math.max(...Object.keys(l).map(Number));return o>r?r=Number(o):r=Number(r)||0,r},0)}function De(e,n){const r=JSON.parse(JSON.stringify(e||{}));for(const[t,l]of Object.entries(n)){r[t]||(r[t]={});for(const[o,h]of Object.entries(l)){const O=h,c=r[t]?.[o];c?r[t][o]={...c,...O,custom:{...c.custom,...O.custom}}:r[t][o]=O}}return r}const ge="./style.css";M.CycleTypeEnum=X,M.ModeEnum=ee,M.decimal=H,M.filterIndicatorsCell=me,M.generateIndicatorsCells=he,M.generateUUID=Q,M.getNumColumns=Ye,M.handleClearInput=te,M.initDateRange=le,M.mergeCellData=De,M.stylePath=ge,M.useData=re,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(M,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("dayjs"),require("@univerjs/presets"),require("decimal.js")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/presets","decimal.js"],i):(M=typeof globalThis<"u"?globalThis:M||self,i(M.TorUniverSheet={},M.dayjs,M.presets,M.Decimal))})(this,(function(M,i,E,_){"use strict";const te=(e,r)=>{for(const n of r)e[n]=null},Q=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const n=t=>{const l=Number(t);return(l^crypto.getRandomValues(new Uint8Array(1))[0]&15>>l/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 re(e){return{...e?.workbookData,id:e?.id||Q(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const ne=Object.prototype.toString,W=(e,r)=>ne.call(e)===`[object ${r}]`,oe=e=>typeof e<"u",se=e=>!oe(e),ae=e=>e!==null&&W(e,"Object"),$=e=>e==null||typeof e>"u"?!0:z(e)||ce(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:ae(e)?Object.keys(e).length===0:!1,ie=e=>e===null,ue=e=>se(e)||ie(e),ce=e=>W(e,"String"),z=e=>e&&Array.isArray(e);class fe{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 I(e=0){return new fe(e)}var X=(e=>(e.无="no",e.年="year",e.月="month",e.周="week",e.天="day",e.班组="shift",e.小时="hour",e.半小时="half_hour",e))(X||{}),ee=(e=>(e.view="view",e.edit="edit",e))(ee||{});async function le(e,r){if(!r)return Promise.reject("日期不能为空");switch(e){case"year":if(z(r))return Promise.resolve(r);const n=i(r);if(!n.isValid())return Promise.reject("无效的日期格式");const t=n.year(),l=`${t}-01`,o=`${t}-12`;return Promise.resolve([l,o]);case"month":if(z(r))return Promise.resolve(r);const h=i(r);if(!h.isValid())return Promise.reject("无效的日期格式");const O=h.startOf("month").format("YYYY-MM-DD"),c=h.endOf("month").format("YYYY-MM-DD");return Promise.resolve([O,c]);case"day":if(z(r))return Promise.resolve(r);const Y=i(r);if(!Y.isValid())return Promise.reject("无效的日期格式");const N=Y.startOf("day").format("YYYY-MM-DD HH:mm:ss"),d=Y.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([N,d]);default:return Promise.reject("不支持的周期类型")}}function V(e,r,n){return n?i(r).diff(i(e),n):0}function Z(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 i(e).subtract(r,n).format(t)}function k(e,r,n,t){const l="YYYY-MM-DD HH:mm:ss",o=A(e,r,n,t),h=i(o);if(r==="month"){const c=h.month();return c===0?[h.startOf("month").format(l),h.date(25).endOf("day").format(l)]:c===11?[h.subtract(1,"month").date(26).startOf("day").format(l),h.endOf("month").format(l)]:[h.subtract(1,"month").date(26).startOf("day").format(l),h.date(25).endOf("day").format(l)]}const O={year:"year",day:"day",hour:"hour"};return[h.startOf(O[r]).format(l),h.endOf(O[r]).format(l)]}function A(e,r,n,t){const l={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[r];return i(e,l).add(n*t,r).format(l)}function g(e,r,n){return e[r]||(e[r]={}),e[r][n]||(e[r][n]={}),e[r][n]}async function me(e){if(!e)throw new Error("cellData is required");const r=Object.entries(e).reduce((n,t)=>{const[l,o]=t;for(const[h,O]of Object.entries(o)){const{custom:c,v:Y,t:N,s:d}=O;if(!c)continue;const{cellType:J}=c,u=!c.hasOwnProperty("writeBack")||$(c?.writeBack)?!0:c.writeBack;if(J==="indicator"){const H=g(n,l,h);H.custom={...c,required:$(c?.required)?!1:c?.required,defaultShift:$(c?.defaultShift)?!1:c?.defaultShift,forwardPush:$(c?.forwardPush)?!1:c?.forwardPush,forwardPushTimes:$(c?.useDefaultEndDate)?0:c?.forwardPushTimes,useDefaultEndDate:$(c?.useDefaultEndDate)?!1:c?.useDefaultEndDate,copyType:$(c?.copyType)?"":c?.copyType,writeBack:u},H.s=d,H.t=N,H.v=Y||""}}return n},{});return!r||$(r)?Promise.reject(new Error("No data found")):Promise.resolve(r)}function F(e,r){return e.replace(/\$\{([^}]+)\}/g,(n,t)=>{try{const l=Object.keys(r),o=Object.values(r);return new Function(...l,`return ${t};`)(...o)}catch(l){return console.error(`表达式执行失败: ${t}`,l),n}})}function de({acc:e,params:r,initRowNum:n,initColNum:t,cellData:l}){const{rangeData:o,currentDay:h,extraArgs:O}=r,c=O?.teamData||{},{cycleType:Y,timeIncrement:N,forwardPush:d,forwardPushTimes:J,copyType:u,copyInterval:H,defaultShift:S,templateStr:P,useDefaultEndDate:K}=l.custom;let y=0;switch(Y){case"day":{let s="";if(d&&(s=Z(o[0],J,"day")),!u){let f="";d?f=s:f=o[0];const a=g(e,n,t);a.v=P?F(P,{businessDate:f,dayjs:i}):i(f).format("YYYY-MM-DD"),a.t=E.CellValueType.STRING;break}d?y=V(s,o[0],"day"):(y=V(o[0],o[1],"day"),console.log("copyNum",y));for(let f=0;f<=Math.abs(y===0?1:y);f++){const a=f*(H+1);let w="";d?w=A(s,"day",f,N):w=A(o[0],"day",f,N);const T=u==="right"?n:n+a,R=u==="right"?t+a:t,G=g(e,T,R);G.v=P?F(P,{businessDate:w,dayjs:i}):i(w).format("YYYY-MM-DD"),G.t=E.CellValueType.STRING}break}case"month":{if(!u){const[s,f]=k(o[1],"month",0,1),a=g(e,n,t);a.v=i(f).format("YYYY-MM"),a.t=E.CellValueType.STRING;break}y=V(o[0],o[1],"month");for(let s=0;s<=Math.abs(y===0?1:y);s++){const f=s*(H+1),a=u==="right"?n:n+f,w=u==="right"?t+f:t,T=g(e,a,w);T.v=A(o[0],"month",s,N),T.t=E.CellValueType.STRING}break}case"year":{let s="";if(d&&(s=Z(o[0],J||0,"year")),!u){const f=d?s:o[0],[a,w]=k(f,"year",0,1),T=g(e,n,t),[,R]=k(o[1],"month",0,1);T.v=P?F(P,{startTime:a,endTime:w,rangeData:o,dayjs:i}):f,T.t=E.CellValueType.STRING;break}d?y=V(s,o[0],"year"):y=V(o[0],o[1],"year");for(let f=0;f<=Math.abs(y===0?1:y);f++){const a=f*(H+1),w=u==="right"?n:n+a,T=u==="right"?t+a:t,[R,G]=k(o[0],"year",f,N),v=g(e,w,T),C=A(o[0],"year",f,N);v.v=P?F(P,{startTime:R,endTime:G,rangeData:o,dayjs:i}):C,v.t=E.CellValueType.STRING}break}case"hour":{if(!u){const s=g(e,n,t);if(s.t=E.CellValueType.STRING,S){s.v=i(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}s.v=i(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}y=V(o[0],o[1],"hour");for(let s=0;s<=Math.abs(y===0?1:y);s++){const f=s*(H+1),a=u==="right"?n:n+f,w=u==="right"?t+f:t,T=g(e,a,w);if(T.t=E.CellValueType.STRING,S){const R=i(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");T.v=A(R,"hour",s,N);continue}T.v=A(i(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",s,N)}break}case"shift":{if(!u){const s=g(e,n,t);s.t=E.CellValueType.STRING,s.v=P?F(P,{rangeData:o,dayjs:i}):o[0];break}if(!c.length)throw new Error("没有获取到当班数据");for(let s=0;s<c.length;s++){const f=c[s],{startDatetime:a,endDatetime:w}=f,T=s*(H+1),R=u==="right"?n:I(n).add(T).toNumber(),G=u==="right"?I(t).add(T).toNumber():t,v=g(e,R,G);v.v=P?F(P,{team:f}):a}break}}}async function he(e,r){if(!e)return Promise.reject("没有可用的单元格数据");const{extraArgs:n,rangeData:t}=r;if(!t.length)return Promise.reject("处理时间范围失败, rangeData不能为空");const l=n?.teamData||[],{periodicityTime:o}=r,h=r?.currentDay||i().format("YYYY-MM-DD"),O=(Y,N)=>o?parseInt(o.split(":")[0],10)<12?[i(Y).format("YYYY-MM-DD")+" "+o,i(N).add(1,"day").format("YYYY-MM-DD")+" "+o]:[i(Y).subtract(1,"day").format("YYYY-MM-DD")+" "+o,i(N).format("YYYY-MM-DD")+" "+o]:[Y,N],c=Object.entries(e).reduce((Y,N)=>{const[d,J]=N;for(const[u,H]of Object.entries(J)){const{custom:S}=H;if(!S)continue;const{cellType:P,cycleType:K,timeIncrement:y,forwardPush:s,forwardPushTimes:f,copyType:a,copyInterval:w,defaultShift:T,useDefaultStartDate:R,useDefaultEndDate:G}=S;if(P==="time"){de({acc:Y,params:r,initRowNum:Number(d),initColNum:Number(u),cellData:H});continue}const v={cycleType:K,indicatorName:S.indicatorName,indicatorCode:S.indicatorCode,indicatorId:S.indicatorId,indicatorDimensionName:S.indicatorDimensionName,indicatorDimensionConfig:S.indicatorDimensionConfig,required:ue(S?.required)??!1,cellType:S.cellType,defaultShift:S?.defaultShift||!1,writeBack:$(S?.writeBack)?!0:S.writeBack};let C=0;switch(K){case"day":{let m="";if(s&&(m=Z(t[0],f||0,"day")),!a){const D=s?m:t[0],[p,b]=O(...k(D,"day",0,1)),x=g(Y,d,u);x.custom={...v,startTime:p,endTime:b};break}s?C=V(m,t[0],"day"):C=V(t[0],t[1],"day");for(let D=0;D<=Math.abs(C===0?1:C);D++){const p=D*(w+1),b=s?m:t[0],[x,B]=O(...k(b,"day",D,y)),U=a==="right"?d:I(d).add(p).toNumber(),q=a==="right"?I(u).add(p).toNumber():u,j=g(Y,U,q);j.custom={...v,startTime:x,endTime:B}}break}case"month":{if(!a){const[m,D]=k(t[1],"month",0,1),p=g(Y,d,u);p.custom={...v,startTime:m,endTime:D};break}C=V(t[0],t[1],"month");for(let m=0;m<=Math.abs(C===0?1:C);m++){const D=m*(w+1),p=a==="right"?d:I(d).add(D).toNumber(),b=a==="right"?I(u).add(D).toNumber():u,[x,B]=k(t[0],"month",m,y),U=g(Y,p,b);U.custom={...v,startTime:x,endTime:B}}break}case"year":{let m="",D="",p="";if(s){m=Z(t[0],f||0,"year");const b=i(t[1]).format("MM");D=i(`${m}-${b+1}`).format("YYYY-MM"),p=i(`${m}-${b+2}`).format("YYYY-MM")}if(!a){const b=s?m:t[0],[x,B]=k(b,"year",0,1),U=g(Y,d,u),[,q]=k(D,"month",0,1),[j]=k(p,"month",0,1);U.custom={...v,startTime:R?j:x,endTime:G?q:B};break}s?C=V(m,t[0],"year"):C=V(t[0],t[1],"year");for(let b=0;b<=Math.abs(C===0?1:C);b++){const x=b*(w+1),B=a==="right"?d:I(d).add(x).toNumber(),U=a==="right"?I(u).add(x).toNumber():u,[q,j]=k(t[0],"year",b,y),L=g(Y,B,U);L.custom={...v,startTime:q,endTime:j}}break}case"hour":{if(!a){const m=T?t[0]:t[0]??h,[D,p]=k(m,"hour",1,1),b=g(Y,d,u);b.custom={...v,startTime:D,endTime:p};break}C=V(t[0],t[1],"hour");for(let m=0;m<=Math.abs(C===0?1:C);m++){const D=m*(w+1),p=a==="right"?d:I(d).add(D).toNumber(),b=a==="right"?I(u).add(D).toNumber():u,x=g(Y,p,b);if(T){const j=i(t[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[L,ye]=k(j,"hour",m,y);x.custom={...v,startTime:L,endTime:ye};continue}const B=i(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[U,q]=k(B,"hour",m,y);x.custom={...v,startTime:U,endTime:q}}break}case"shift":{if(!a){const[m,D]=t,p=g(Y,d,u);p.custom={...v,startTime:m,endTime:D};break}if(!l.length)throw new Error("没有获取到当班数据");for(let m=0;m<l.length;m++){const D=l[m],{startDatetime:p,endDatetime:b}=D,x=m*(w+1),B=a==="right"?d:I(d).add(x).toNumber(),U=a==="right"?I(u).add(x).toNumber():u,q=g(Y,B,U);q.custom={...v,startTime:p,endTime:b}}break}}}return Y},{});return Promise.resolve(c)}function Ye(e){return Object.entries(e).reduce((n,[t,l])=>{const o=Math.max(...Object.keys(l).map(Number));return o>n?n=Number(o):n=Number(n)||0,n},0)}function De(e,r){const n=JSON.parse(JSON.stringify(e||{}));for(const[t,l]of Object.entries(r)){n[t]||(n[t]={});for(const[o,h]of Object.entries(l)){const O=h,c=n[t]?.[o];c?n[t][o]={...c,...O,custom:{...c.custom,...O.custom}}:n[t][o]=O}}return n}const ge="./style.css";M.CycleTypeEnum=X,M.ModeEnum=ee,M.decimal=I,M.filterIndicatorsCell=me,M.generateIndicatorsCells=he,M.generateUUID=Q,M.getNumColumns=Ye,M.handleClearInput=te,M.initDateRange=le,M.mergeCellData=De,M.stylePath=ge,M.useData=re,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})}));
|