tor-univer-sheet 1.1.18 → 1.1.20
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 +233 -226
- package/dist/tor-univer-sheet.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import d from "dayjs";
|
|
2
|
-
import { CellValueType as
|
|
3
|
-
import
|
|
2
|
+
import { CellValueType as E } from "@univerjs/presets";
|
|
3
|
+
import z from "decimal.js";
|
|
4
4
|
const dt = (t, r) => {
|
|
5
5
|
for (const o of r)
|
|
6
6
|
t[o] = null;
|
|
7
|
-
},
|
|
7
|
+
}, Q = () => {
|
|
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
12
|
const o = (e) => {
|
|
13
|
-
const
|
|
14
|
-
return (
|
|
13
|
+
const c = Number(e);
|
|
14
|
+
return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
|
|
15
15
|
};
|
|
16
16
|
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, o);
|
|
17
17
|
}
|
|
@@ -25,16 +25,16 @@ const dt = (t, r) => {
|
|
|
25
25
|
function ht(t) {
|
|
26
26
|
return {
|
|
27
27
|
...t?.workbookData,
|
|
28
|
-
id: t?.id ||
|
|
28
|
+
id: t?.id || Q(),
|
|
29
29
|
name: t?.name || "未命名",
|
|
30
30
|
appVersion: t?.appVersion || "1.0.0"
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
const X = Object.prototype.toString,
|
|
33
|
+
const X = Object.prototype.toString, Z = (t, r) => X.call(t) === `[object ${r}]`, tt = (t) => typeof t < "u", et = (t) => !tt(t), rt = (t) => t !== null && Z(t, "Object"), G = (t) => t == null || typeof t > "u" ? !0 : K(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) => Z(t, "String"), K = (t) => t && Array.isArray(t);
|
|
34
34
|
class at {
|
|
35
35
|
value;
|
|
36
36
|
constructor(r) {
|
|
37
|
-
this.value = new
|
|
37
|
+
this.value = new z(r);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* 加法运算
|
|
@@ -67,7 +67,7 @@ class at {
|
|
|
67
67
|
* @throws 当除数为0时抛出错误
|
|
68
68
|
*/
|
|
69
69
|
divide(r) {
|
|
70
|
-
const o = new
|
|
70
|
+
const o = new z(r);
|
|
71
71
|
if (o.isZero())
|
|
72
72
|
throw new Error("除数是0");
|
|
73
73
|
return this.value = this.value.div(o), this;
|
|
@@ -79,7 +79,7 @@ class at {
|
|
|
79
79
|
* @returns DecimalChain 实例,支持链式调用
|
|
80
80
|
*/
|
|
81
81
|
toFixed(r, o) {
|
|
82
|
-
return this.value = new
|
|
82
|
+
return this.value = new z(this.value.toFixed(r, o)), this;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* 返回当前值
|
|
@@ -103,37 +103,37 @@ class at {
|
|
|
103
103
|
return this.value.toNumber();
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function I(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
|
|
110
|
+
async function yt(t, r) {
|
|
111
111
|
if (!r) return Promise.reject("日期不能为空");
|
|
112
112
|
switch (t) {
|
|
113
113
|
case "year":
|
|
114
|
-
if (
|
|
114
|
+
if (K(r))
|
|
115
115
|
return Promise.resolve(r);
|
|
116
116
|
const o = d(r);
|
|
117
117
|
if (!o.isValid())
|
|
118
118
|
return Promise.reject("无效的日期格式");
|
|
119
|
-
const e = o.year(),
|
|
120
|
-
return Promise.resolve([
|
|
119
|
+
const e = o.year(), c = `${e}-01`, n = `${e}-12`;
|
|
120
|
+
return Promise.resolve([c, n]);
|
|
121
121
|
case "month":
|
|
122
|
-
if (
|
|
122
|
+
if (K(r))
|
|
123
123
|
return Promise.resolve(r);
|
|
124
124
|
const h = d(r);
|
|
125
125
|
if (!h.isValid())
|
|
126
126
|
return Promise.reject("无效的日期格式");
|
|
127
|
-
const
|
|
128
|
-
return Promise.resolve([
|
|
127
|
+
const x = h.startOf("month").format("YYYY-MM-DD"), a = h.endOf("month").format("YYYY-MM-DD");
|
|
128
|
+
return Promise.resolve([x, a]);
|
|
129
129
|
case "day":
|
|
130
|
-
if (
|
|
130
|
+
if (K(r))
|
|
131
131
|
return Promise.resolve(r);
|
|
132
|
-
const
|
|
133
|
-
if (!
|
|
132
|
+
const y = d(r);
|
|
133
|
+
if (!y.isValid())
|
|
134
134
|
return Promise.reject("无效的日期格式");
|
|
135
|
-
const
|
|
136
|
-
return Promise.resolve([
|
|
135
|
+
const Y = y.startOf("day").format("YYYY-MM-DD HH:mm:ss"), f = y.endOf("day").format("YYYY-MM-DD HH:mm:ss");
|
|
136
|
+
return Promise.resolve([Y, f]);
|
|
137
137
|
default:
|
|
138
138
|
return Promise.reject("不支持的周期类型");
|
|
139
139
|
}
|
|
@@ -141,7 +141,7 @@ async function Yt(t, r) {
|
|
|
141
141
|
function H(t, r, o) {
|
|
142
142
|
return o ? d(r).diff(d(t), o) : 0;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function L(t, r, o) {
|
|
145
145
|
if (!o)
|
|
146
146
|
throw new Error("日期类型不能为空");
|
|
147
147
|
const e = {
|
|
@@ -152,61 +152,61 @@ function K(t, r, o) {
|
|
|
152
152
|
}[o];
|
|
153
153
|
return d(t).subtract(r, o).format(e);
|
|
154
154
|
}
|
|
155
|
-
function
|
|
156
|
-
const
|
|
155
|
+
function O(t, r, o, e) {
|
|
156
|
+
const c = "YYYY-MM-DD HH:mm:ss", n = A(t, r, o, e), h = d(n);
|
|
157
157
|
if (r === "month") {
|
|
158
158
|
const a = h.month();
|
|
159
|
-
return a === 0 ? [h.startOf("month").format(
|
|
159
|
+
return a === 0 ? [h.startOf("month").format(c), h.date(25).endOf("day").format(c)] : a === 11 ? [h.subtract(1, "month").date(26).startOf("day").format(c), h.endOf("month").format(c)] : [h.subtract(1, "month").date(26).startOf("day").format(c), h.date(25).endOf("day").format(c)];
|
|
160
160
|
}
|
|
161
|
-
const
|
|
162
|
-
return [h.startOf(
|
|
161
|
+
const x = { year: "year", day: "day", hour: "hour" };
|
|
162
|
+
return [h.startOf(x[r]).format(c), h.endOf(x[r]).format(c)];
|
|
163
163
|
}
|
|
164
164
|
function A(t, r, o, e) {
|
|
165
|
-
const
|
|
165
|
+
const c = {
|
|
166
166
|
year: "YYYY",
|
|
167
167
|
month: "YYYY-MM",
|
|
168
168
|
day: "YYYY-MM-DD",
|
|
169
169
|
hour: "YYYY-MM-DD HH:mm:ss"
|
|
170
170
|
}[r];
|
|
171
|
-
return d(t,
|
|
171
|
+
return d(t, c).add(o * e, r).format(c);
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function T(t, r, o) {
|
|
174
174
|
return t[r] || (t[r] = {}), t[r][o] || (t[r][o] = {}), t[r][o];
|
|
175
175
|
}
|
|
176
|
-
async function
|
|
176
|
+
async function Yt(t) {
|
|
177
177
|
if (!t)
|
|
178
178
|
throw new Error("cellData is required");
|
|
179
179
|
const r = Object.entries(t).reduce((o, e) => {
|
|
180
|
-
const [
|
|
181
|
-
for (const [h,
|
|
182
|
-
const { custom: a, v:
|
|
180
|
+
const [c, n] = e;
|
|
181
|
+
for (const [h, x] of Object.entries(n)) {
|
|
182
|
+
const { custom: a, v: y, t: Y, s: f } = x;
|
|
183
183
|
if (!a) continue;
|
|
184
|
-
const { cellType: q } = a, u = !a.hasOwnProperty("writeBack") ||
|
|
184
|
+
const { cellType: q } = a, u = !a.hasOwnProperty("writeBack") || G(a?.writeBack) ? !0 : a.writeBack;
|
|
185
185
|
if (q === "indicator") {
|
|
186
|
-
const P =
|
|
186
|
+
const P = T(o, c, h);
|
|
187
187
|
P.custom = {
|
|
188
188
|
...a,
|
|
189
|
-
required:
|
|
190
|
-
defaultShift:
|
|
191
|
-
forwardPush:
|
|
192
|
-
forwardPushTimes:
|
|
193
|
-
useDefaultEndDate:
|
|
194
|
-
copyType:
|
|
189
|
+
required: G(a?.required) ? !1 : a?.required,
|
|
190
|
+
defaultShift: G(a?.defaultShift) ? !1 : a?.defaultShift,
|
|
191
|
+
forwardPush: G(a?.forwardPush) ? !1 : a?.forwardPush,
|
|
192
|
+
forwardPushTimes: G(a?.useDefaultEndDate) ? 0 : a?.forwardPushTimes,
|
|
193
|
+
useDefaultEndDate: G(a?.useDefaultEndDate) ? !1 : a?.useDefaultEndDate,
|
|
194
|
+
copyType: G(a?.copyType) ? "" : a?.copyType,
|
|
195
195
|
writeBack: u
|
|
196
|
-
}, P.s =
|
|
196
|
+
}, P.s = f, P.t = Y, P.v = y || "";
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
return o;
|
|
200
200
|
}, {});
|
|
201
|
-
return !r ||
|
|
201
|
+
return !r || G(r) ? Promise.reject(new Error("No data found")) : Promise.resolve(r);
|
|
202
202
|
}
|
|
203
203
|
function F(t, r) {
|
|
204
204
|
return t.replace(/\$\{([^}]+)\}/g, (o, e) => {
|
|
205
205
|
try {
|
|
206
|
-
const
|
|
207
|
-
return new Function(...
|
|
208
|
-
} catch (
|
|
209
|
-
return console.error(`表达式执行失败: ${e}`,
|
|
206
|
+
const c = Object.keys(r), n = Object.values(r);
|
|
207
|
+
return new Function(...c, `return ${e};`)(...n);
|
|
208
|
+
} catch (c) {
|
|
209
|
+
return console.error(`表达式执行失败: ${e}`, c), o;
|
|
210
210
|
}
|
|
211
211
|
});
|
|
212
212
|
}
|
|
@@ -215,133 +215,133 @@ function ut({
|
|
|
215
215
|
params: r,
|
|
216
216
|
initRowNum: o,
|
|
217
217
|
initColNum: e,
|
|
218
|
-
cellData:
|
|
218
|
+
cellData: c
|
|
219
219
|
}) {
|
|
220
|
-
const { rangeData: n, currentDay: h, extraArgs:
|
|
221
|
-
let
|
|
222
|
-
switch (
|
|
220
|
+
const { rangeData: n, currentDay: h, extraArgs: x } = r, a = x?.teamData || {}, { cycleType: y, timeIncrement: Y, forwardPush: f, forwardPushTimes: q, copyType: u, copyInterval: P, defaultShift: p, templateStr: C, useDefaultEndDate: W } = c.custom;
|
|
221
|
+
let w = 0;
|
|
222
|
+
switch (y) {
|
|
223
223
|
case "day": {
|
|
224
224
|
let s = "";
|
|
225
|
-
if (
|
|
225
|
+
if (f && (s = L(
|
|
226
226
|
n[0],
|
|
227
227
|
q,
|
|
228
228
|
"day"
|
|
229
229
|
/* day */
|
|
230
230
|
)), !u) {
|
|
231
|
-
let
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
231
|
+
let l = "";
|
|
232
|
+
f ? l = s : l = n[0];
|
|
233
|
+
const i = T(t, o, e);
|
|
234
|
+
i.v = C ? F(C, { businessDate: l, dayjs: d }) : d(l).format("YYYY-MM-DD"), i.t = E.STRING, i.s = "tor-time-cell-style";
|
|
235
235
|
break;
|
|
236
236
|
}
|
|
237
|
-
|
|
237
|
+
f ? w = H(
|
|
238
238
|
s,
|
|
239
239
|
n[0],
|
|
240
240
|
"day"
|
|
241
241
|
/* day */
|
|
242
|
-
) : (
|
|
242
|
+
) : (w = H(
|
|
243
243
|
n[0],
|
|
244
244
|
n[1],
|
|
245
245
|
"day"
|
|
246
246
|
/* day */
|
|
247
|
-
), console.log("copyNum",
|
|
248
|
-
for (let
|
|
249
|
-
const
|
|
250
|
-
let
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
|
|
247
|
+
), console.log("copyNum", w));
|
|
248
|
+
for (let l = 0; l <= Math.abs(w === 0 ? 1 : w); l++) {
|
|
249
|
+
const i = l * (P + 1);
|
|
250
|
+
let N = "";
|
|
251
|
+
f ? N = A(s, "day", l, Y) : N = A(n[0], "day", l, Y);
|
|
252
|
+
const g = u === "right" ? o : o + i, B = u === "right" ? e + i : e, $ = T(t, g, B);
|
|
253
|
+
$.v = C ? F(C, { businessDate: N, dayjs: d }) : d(N).format("YYYY-MM-DD"), $.t = E.STRING, $.s = "tor-time-cell-style";
|
|
254
254
|
}
|
|
255
255
|
break;
|
|
256
256
|
}
|
|
257
257
|
case "month": {
|
|
258
258
|
if (!u) {
|
|
259
|
-
const [s,
|
|
260
|
-
|
|
259
|
+
const [s, l] = O(n[1], "month", 0, 1), i = T(t, o, e);
|
|
260
|
+
i.v = d(l).format("YYYY-MM"), i.t = E.STRING, i.s = "tor-time-cell-style";
|
|
261
261
|
break;
|
|
262
262
|
}
|
|
263
|
-
|
|
263
|
+
w = H(
|
|
264
264
|
n[0],
|
|
265
265
|
n[1],
|
|
266
266
|
"month"
|
|
267
267
|
/* month */
|
|
268
268
|
);
|
|
269
|
-
for (let s = 0; s <= Math.abs(
|
|
270
|
-
const
|
|
271
|
-
|
|
269
|
+
for (let s = 0; s <= Math.abs(w === 0 ? 1 : w); s++) {
|
|
270
|
+
const l = s * (P + 1), i = u === "right" ? o : o + l, N = u === "right" ? e + l : e, g = T(t, i, N);
|
|
271
|
+
g.v = A(n[0], "month", s, Y), g.t = E.STRING, g.s = "tor-time-cell-style";
|
|
272
272
|
}
|
|
273
273
|
break;
|
|
274
274
|
}
|
|
275
275
|
case "year": {
|
|
276
276
|
let s = "";
|
|
277
|
-
if (
|
|
277
|
+
if (f && (s = L(
|
|
278
278
|
n[0],
|
|
279
279
|
q || 0,
|
|
280
280
|
"year"
|
|
281
281
|
/* year */
|
|
282
282
|
)), !u) {
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
startTime:
|
|
286
|
-
endTime:
|
|
283
|
+
const l = f ? s : n[0], [i, N] = O(l, "year", 0, 1), g = T(t, o, e), [, B] = O(n[1], "month", 0, 1);
|
|
284
|
+
g.v = C ? F(C, {
|
|
285
|
+
startTime: i,
|
|
286
|
+
endTime: N,
|
|
287
287
|
rangeData: n,
|
|
288
288
|
dayjs: d
|
|
289
|
-
}) :
|
|
289
|
+
}) : l, g.t = E.STRING, g.s = "tor-time-cell-style";
|
|
290
290
|
break;
|
|
291
291
|
}
|
|
292
|
-
|
|
292
|
+
f ? w = H(
|
|
293
293
|
s,
|
|
294
294
|
n[0],
|
|
295
295
|
"year"
|
|
296
296
|
/* year */
|
|
297
|
-
) :
|
|
297
|
+
) : w = H(
|
|
298
298
|
n[0],
|
|
299
299
|
n[1],
|
|
300
300
|
"year"
|
|
301
301
|
/* year */
|
|
302
302
|
);
|
|
303
|
-
for (let
|
|
304
|
-
const
|
|
305
|
-
|
|
303
|
+
for (let l = 0; l <= Math.abs(w === 0 ? 1 : w); l++) {
|
|
304
|
+
const i = l * (P + 1), N = u === "right" ? o : o + i, g = u === "right" ? e + i : e, [B, $] = O(n[0], "year", l, Y), S = T(t, N, g), k = A(n[0], "year", l, Y);
|
|
305
|
+
S.v = C ? F(C, {
|
|
306
306
|
startTime: B,
|
|
307
|
-
endTime:
|
|
307
|
+
endTime: $,
|
|
308
308
|
rangeData: n,
|
|
309
309
|
dayjs: d
|
|
310
|
-
}) :
|
|
310
|
+
}) : k, S.t = E.STRING, S.s = "tor-time-cell-style";
|
|
311
311
|
}
|
|
312
312
|
break;
|
|
313
313
|
}
|
|
314
314
|
case "hour": {
|
|
315
315
|
if (!u) {
|
|
316
|
-
const s =
|
|
317
|
-
if (s.t =
|
|
316
|
+
const s = T(t, o, e);
|
|
317
|
+
if (s.t = E.STRING, s.s = "tor-time-cell-style", p) {
|
|
318
318
|
s.v = d(n[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
319
319
|
break;
|
|
320
320
|
}
|
|
321
321
|
s.v = d(h).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
322
322
|
break;
|
|
323
323
|
}
|
|
324
|
-
|
|
324
|
+
w = H(
|
|
325
325
|
n[0],
|
|
326
326
|
n[1],
|
|
327
327
|
"hour"
|
|
328
328
|
/* hour */
|
|
329
329
|
);
|
|
330
|
-
for (let s = 0; s <= Math.abs(
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
330
|
+
for (let s = 0; s <= Math.abs(w === 0 ? 1 : w); s++) {
|
|
331
|
+
const l = s * (P + 1), i = u === "right" ? o : o + l, N = u === "right" ? e + l : e, g = T(t, i, N);
|
|
332
|
+
if (g.t = E.STRING, g.s = "tor-time-cell-style", p) {
|
|
333
333
|
const B = d(n[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
334
|
-
|
|
334
|
+
g.v = A(B, "hour", s, Y);
|
|
335
335
|
continue;
|
|
336
336
|
}
|
|
337
|
-
|
|
337
|
+
g.v = A(d(h).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), "hour", s, Y);
|
|
338
338
|
}
|
|
339
339
|
break;
|
|
340
340
|
}
|
|
341
341
|
case "shift": {
|
|
342
342
|
if (!u) {
|
|
343
|
-
const s =
|
|
344
|
-
s.t =
|
|
343
|
+
const s = T(t, o, e);
|
|
344
|
+
s.t = E.STRING, s.s = "tor-time-cell-style", s.v = C ? F(C, {
|
|
345
345
|
rangeData: n,
|
|
346
346
|
dayjs: d
|
|
347
347
|
}) : n[0];
|
|
@@ -350,155 +350,162 @@ function ut({
|
|
|
350
350
|
if (!a.length)
|
|
351
351
|
throw new Error("没有获取到当班数据");
|
|
352
352
|
for (let s = 0; s < a.length; s++) {
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
team:
|
|
356
|
-
}) :
|
|
353
|
+
const l = a[s], { startDatetime: i, endDatetime: N } = l, g = s * (P + 1), B = u === "right" ? o : I(o).add(g).toNumber(), $ = u === "right" ? I(e).add(g).toNumber() : e, S = T(t, B, $);
|
|
354
|
+
S.s = "tor-time-cell-style", S.v = C ? F(C, {
|
|
355
|
+
team: l
|
|
356
|
+
}) : i;
|
|
357
357
|
}
|
|
358
358
|
break;
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
|
-
async function
|
|
362
|
+
async function Dt(t, r) {
|
|
363
363
|
if (!t)
|
|
364
364
|
return Promise.reject("没有可用的单元格数据");
|
|
365
365
|
const { extraArgs: o, rangeData: e } = r;
|
|
366
366
|
if (!e.length)
|
|
367
367
|
return Promise.reject("处理时间范围失败, rangeData不能为空");
|
|
368
|
-
const
|
|
369
|
-
const [
|
|
368
|
+
const c = o?.teamData || [], { periodicityTime: n } = r, h = r?.currentDay || d().format("YYYY-MM-DD"), x = (y, Y) => n ? parseInt(n.split(":")[0], 10) < 12 ? [d(y).format("YYYY-MM-DD") + " " + n, d(Y).add(1, "day").format("YYYY-MM-DD") + " " + n] : [d(y).subtract(1, "day").format("YYYY-MM-DD") + " " + n, d(Y).format("YYYY-MM-DD") + " " + n] : [y, Y], a = Object.entries(t).reduce((y, Y) => {
|
|
369
|
+
const [f, q] = Y;
|
|
370
370
|
for (const [u, P] of Object.entries(q)) {
|
|
371
|
-
const { custom:
|
|
372
|
-
if (!
|
|
371
|
+
const { custom: p } = P;
|
|
372
|
+
if (!p) continue;
|
|
373
373
|
const {
|
|
374
374
|
cellType: C,
|
|
375
|
-
cycleType:
|
|
376
|
-
timeIncrement:
|
|
375
|
+
cycleType: W,
|
|
376
|
+
timeIncrement: w,
|
|
377
377
|
forwardPush: s,
|
|
378
|
-
forwardPushTimes:
|
|
379
|
-
copyType:
|
|
380
|
-
copyInterval:
|
|
381
|
-
defaultShift:
|
|
378
|
+
forwardPushTimes: l,
|
|
379
|
+
copyType: i,
|
|
380
|
+
copyInterval: N,
|
|
381
|
+
defaultShift: g,
|
|
382
382
|
useDefaultStartDate: B,
|
|
383
|
-
useDefaultEndDate:
|
|
384
|
-
} =
|
|
383
|
+
useDefaultEndDate: $
|
|
384
|
+
} = p;
|
|
385
385
|
if (C === "time") {
|
|
386
|
-
ut({ acc:
|
|
386
|
+
ut({ acc: y, params: r, initRowNum: Number(f), initColNum: Number(u), cellData: P });
|
|
387
387
|
continue;
|
|
388
388
|
}
|
|
389
|
-
const
|
|
390
|
-
cycleType:
|
|
391
|
-
indicatorName:
|
|
392
|
-
indicatorCode:
|
|
393
|
-
indicatorId:
|
|
394
|
-
indicatorDimensionName:
|
|
395
|
-
indicatorDimensionConfig:
|
|
396
|
-
required: nt(
|
|
397
|
-
cellType:
|
|
398
|
-
defaultShift:
|
|
399
|
-
writeBack:
|
|
389
|
+
const S = {
|
|
390
|
+
cycleType: W,
|
|
391
|
+
indicatorName: p.indicatorName,
|
|
392
|
+
indicatorCode: p.indicatorCode,
|
|
393
|
+
indicatorId: p.indicatorId,
|
|
394
|
+
indicatorDimensionName: p.indicatorDimensionName,
|
|
395
|
+
indicatorDimensionConfig: p.indicatorDimensionConfig,
|
|
396
|
+
required: nt(p?.required) ?? !1,
|
|
397
|
+
cellType: p.cellType,
|
|
398
|
+
defaultShift: p?.defaultShift || !1,
|
|
399
|
+
writeBack: G(p?.writeBack) ? !0 : p.writeBack,
|
|
400
|
+
dimensionJson: p?.dimensionJson || "",
|
|
401
|
+
unit: p?.unit || "",
|
|
402
|
+
innerSyncWay: p?.innerSyncWay || "",
|
|
403
|
+
outSyncConfigId: p?.outSyncConfigId || "",
|
|
404
|
+
innerSyncStatus: p?.innerSyncStatus || ""
|
|
400
405
|
};
|
|
401
|
-
let
|
|
402
|
-
switch (
|
|
406
|
+
let k = 0;
|
|
407
|
+
switch (W) {
|
|
403
408
|
case "day": {
|
|
404
|
-
let
|
|
405
|
-
if (s && (
|
|
409
|
+
let m = "";
|
|
410
|
+
if (s && (m = L(
|
|
406
411
|
e[0],
|
|
407
|
-
|
|
412
|
+
l || 0,
|
|
408
413
|
"day"
|
|
409
414
|
/* day */
|
|
410
|
-
)), !
|
|
411
|
-
const
|
|
412
|
-
|
|
413
|
-
...
|
|
414
|
-
startTime:
|
|
415
|
+
)), !i) {
|
|
416
|
+
const D = s ? m : e[0], [M, b] = x(...O(D, "day", 0, 1)), v = T(y, f, u);
|
|
417
|
+
v.s = "tor-indicator-cell-style", v.custom = {
|
|
418
|
+
...S,
|
|
419
|
+
startTime: M,
|
|
415
420
|
endTime: b
|
|
416
421
|
};
|
|
417
422
|
break;
|
|
418
423
|
}
|
|
419
|
-
s ?
|
|
420
|
-
|
|
424
|
+
s ? k = H(
|
|
425
|
+
m,
|
|
421
426
|
e[0],
|
|
422
427
|
"day"
|
|
423
428
|
/* day */
|
|
424
|
-
) :
|
|
429
|
+
) : k = H(
|
|
425
430
|
e[0],
|
|
426
431
|
e[1],
|
|
427
432
|
"day"
|
|
428
433
|
/* day */
|
|
429
434
|
);
|
|
430
|
-
for (let
|
|
431
|
-
const
|
|
432
|
-
V.custom = {
|
|
433
|
-
...
|
|
434
|
-
startTime:
|
|
435
|
-
endTime:
|
|
435
|
+
for (let D = 0; D <= Math.abs(k === 0 ? 1 : k); D++) {
|
|
436
|
+
const M = D * (N + 1), b = s ? m : e[0], [v, R] = x(...O(b, "day", D, w)), j = i === "right" ? f : I(f).add(M).toNumber(), U = i === "right" ? I(u).add(M).toNumber() : u, V = T(y, j, U);
|
|
437
|
+
V.s = "tor-indicator-cell-style", V.custom = {
|
|
438
|
+
...S,
|
|
439
|
+
startTime: v,
|
|
440
|
+
endTime: R
|
|
436
441
|
};
|
|
437
442
|
}
|
|
438
443
|
break;
|
|
439
444
|
}
|
|
440
445
|
case "month": {
|
|
441
|
-
if (!
|
|
442
|
-
const [
|
|
443
|
-
|
|
444
|
-
...
|
|
445
|
-
startTime:
|
|
446
|
-
endTime:
|
|
446
|
+
if (!i) {
|
|
447
|
+
const [m, D] = O(e[1], "month", 0, 1), M = T(y, f, u);
|
|
448
|
+
M.s = "tor-indicator-cell-style", M.custom = {
|
|
449
|
+
...S,
|
|
450
|
+
startTime: m,
|
|
451
|
+
endTime: D
|
|
447
452
|
};
|
|
448
453
|
break;
|
|
449
454
|
}
|
|
450
|
-
|
|
455
|
+
k = H(
|
|
451
456
|
e[0],
|
|
452
457
|
e[1],
|
|
453
458
|
"month"
|
|
454
459
|
/* month */
|
|
455
460
|
);
|
|
456
|
-
for (let
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
...
|
|
460
|
-
startTime:
|
|
461
|
-
endTime:
|
|
461
|
+
for (let m = 0; m <= Math.abs(k === 0 ? 1 : k); m++) {
|
|
462
|
+
const D = m * (N + 1), M = i === "right" ? f : I(f).add(D).toNumber(), b = i === "right" ? I(u).add(D).toNumber() : u, [v, R] = O(e[0], "month", m, w), j = T(y, M, b);
|
|
463
|
+
j.s = "tor-indicator-cell-style", j.custom = {
|
|
464
|
+
...S,
|
|
465
|
+
startTime: v,
|
|
466
|
+
endTime: R
|
|
462
467
|
};
|
|
463
468
|
}
|
|
464
469
|
break;
|
|
465
470
|
}
|
|
466
471
|
case "year": {
|
|
467
|
-
let
|
|
472
|
+
let m = "", D = "", M = "";
|
|
468
473
|
if (s) {
|
|
469
|
-
|
|
474
|
+
m = L(
|
|
470
475
|
e[0],
|
|
471
|
-
|
|
476
|
+
l || 0,
|
|
472
477
|
"year"
|
|
473
478
|
/* year */
|
|
474
479
|
);
|
|
475
480
|
const b = d(e[1]).format("MM");
|
|
476
|
-
|
|
481
|
+
D = d(`${m}-${b + 1}`).format("YYYY-MM"), M = d(`${m}-${b + 2}`).format("YYYY-MM");
|
|
477
482
|
}
|
|
478
|
-
if (!
|
|
479
|
-
const b = s ?
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
483
|
+
if (!i) {
|
|
484
|
+
const b = s ? m : e[0], [v, R] = O(b, "year", 0, 1), j = T(y, f, u);
|
|
485
|
+
j.s = "tor-indicator-cell-style";
|
|
486
|
+
const [, U] = O(D, "month", 0, 1), [V] = O(M, "month", 0, 1);
|
|
487
|
+
j.custom = {
|
|
488
|
+
...S,
|
|
489
|
+
startTime: B ? V : v,
|
|
490
|
+
endTime: $ ? U : R
|
|
484
491
|
};
|
|
485
492
|
break;
|
|
486
493
|
}
|
|
487
|
-
s ?
|
|
488
|
-
|
|
494
|
+
s ? k = H(
|
|
495
|
+
m,
|
|
489
496
|
e[0],
|
|
490
497
|
"year"
|
|
491
498
|
/* year */
|
|
492
|
-
) :
|
|
499
|
+
) : k = H(
|
|
493
500
|
e[0],
|
|
494
501
|
e[1],
|
|
495
502
|
"year"
|
|
496
503
|
/* year */
|
|
497
504
|
);
|
|
498
|
-
for (let b = 0; b <= Math.abs(
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
...
|
|
505
|
+
for (let b = 0; b <= Math.abs(k === 0 ? 1 : k); b++) {
|
|
506
|
+
const v = b * (N + 1), R = i === "right" ? f : I(f).add(v).toNumber(), j = i === "right" ? I(u).add(v).toNumber() : u, [U, V] = O(e[0], "year", b, w), J = T(y, R, j);
|
|
507
|
+
J.s = "tor-indicator-cell-style", J.custom = {
|
|
508
|
+
...S,
|
|
502
509
|
startTime: U,
|
|
503
510
|
endTime: V
|
|
504
511
|
};
|
|
@@ -506,58 +513,58 @@ async function yt(t, r) {
|
|
|
506
513
|
break;
|
|
507
514
|
}
|
|
508
515
|
case "hour": {
|
|
509
|
-
if (!
|
|
510
|
-
const
|
|
511
|
-
b.custom = {
|
|
512
|
-
...
|
|
513
|
-
startTime:
|
|
514
|
-
endTime:
|
|
516
|
+
if (!i) {
|
|
517
|
+
const m = g ? e[0] : e[0] ?? h, [D, M] = O(m, "hour", 1, 1), b = T(y, f, u);
|
|
518
|
+
b.s = "tor-indicator-cell-style", b.custom = {
|
|
519
|
+
...S,
|
|
520
|
+
startTime: D,
|
|
521
|
+
endTime: M
|
|
515
522
|
};
|
|
516
523
|
break;
|
|
517
524
|
}
|
|
518
|
-
|
|
525
|
+
k = H(
|
|
519
526
|
e[0],
|
|
520
527
|
e[1],
|
|
521
528
|
"hour"
|
|
522
529
|
/* hour */
|
|
523
530
|
);
|
|
524
|
-
for (let
|
|
525
|
-
const
|
|
526
|
-
if (
|
|
527
|
-
const V = d(e[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [
|
|
528
|
-
|
|
529
|
-
...
|
|
530
|
-
startTime:
|
|
531
|
-
endTime:
|
|
531
|
+
for (let m = 0; m <= Math.abs(k === 0 ? 1 : k); m++) {
|
|
532
|
+
const D = m * (N + 1), M = i === "right" ? f : I(f).add(D).toNumber(), b = i === "right" ? I(u).add(D).toNumber() : u, v = T(y, M, b);
|
|
533
|
+
if (v.s = "tor-indicator-cell-style", g) {
|
|
534
|
+
const V = d(e[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [J, _] = O(V, "hour", m, w);
|
|
535
|
+
v.custom = {
|
|
536
|
+
...S,
|
|
537
|
+
startTime: J,
|
|
538
|
+
endTime: _
|
|
532
539
|
};
|
|
533
540
|
continue;
|
|
534
541
|
}
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
...
|
|
538
|
-
startTime:
|
|
542
|
+
const R = d(h).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [j, U] = O(R, "hour", m, w);
|
|
543
|
+
v.custom = {
|
|
544
|
+
...S,
|
|
545
|
+
startTime: j,
|
|
539
546
|
endTime: U
|
|
540
547
|
};
|
|
541
548
|
}
|
|
542
549
|
break;
|
|
543
550
|
}
|
|
544
551
|
case "shift": {
|
|
545
|
-
if (!
|
|
546
|
-
const [
|
|
547
|
-
|
|
548
|
-
...
|
|
549
|
-
startTime:
|
|
550
|
-
endTime:
|
|
552
|
+
if (!i) {
|
|
553
|
+
const [m, D] = e, M = T(y, f, u);
|
|
554
|
+
M.s = "tor-indicator-cell-style", M.custom = {
|
|
555
|
+
...S,
|
|
556
|
+
startTime: m,
|
|
557
|
+
endTime: D
|
|
551
558
|
};
|
|
552
559
|
break;
|
|
553
560
|
}
|
|
554
|
-
if (!
|
|
561
|
+
if (!c.length)
|
|
555
562
|
throw new Error("没有获取到当班数据");
|
|
556
|
-
for (let
|
|
557
|
-
const
|
|
558
|
-
U.custom = {
|
|
559
|
-
...
|
|
560
|
-
startTime:
|
|
563
|
+
for (let m = 0; m < c.length; m++) {
|
|
564
|
+
const D = c[m], { startDatetime: M, endDatetime: b } = D, v = m * (N + 1), R = i === "right" ? f : I(f).add(v).toNumber(), j = i === "right" ? I(u).add(v).toNumber() : u, U = T(y, R, j);
|
|
565
|
+
U.s = "tor-indicator-cell-style", U.custom = {
|
|
566
|
+
...S,
|
|
567
|
+
startTime: M,
|
|
561
568
|
endTime: b
|
|
562
569
|
};
|
|
563
570
|
}
|
|
@@ -565,30 +572,30 @@ async function yt(t, r) {
|
|
|
565
572
|
}
|
|
566
573
|
}
|
|
567
574
|
}
|
|
568
|
-
return
|
|
575
|
+
return y;
|
|
569
576
|
}, {});
|
|
570
577
|
return Promise.resolve(a);
|
|
571
578
|
}
|
|
572
579
|
function gt(t) {
|
|
573
|
-
return Object.entries(t).reduce((o, [e,
|
|
574
|
-
const n = Math.max(...Object.keys(
|
|
580
|
+
return Object.entries(t).reduce((o, [e, c]) => {
|
|
581
|
+
const n = Math.max(...Object.keys(c).map(Number));
|
|
575
582
|
return n > o ? o = Number(n) : o = Number(o) || 0, o;
|
|
576
583
|
}, 0);
|
|
577
584
|
}
|
|
578
585
|
function bt(t, r) {
|
|
579
586
|
const o = JSON.parse(JSON.stringify(t || {}));
|
|
580
|
-
for (const [e,
|
|
587
|
+
for (const [e, c] of Object.entries(r)) {
|
|
581
588
|
o[e] || (o[e] = {});
|
|
582
|
-
for (const [n, h] of Object.entries(
|
|
583
|
-
const
|
|
589
|
+
for (const [n, h] of Object.entries(c)) {
|
|
590
|
+
const x = h, a = o[e]?.[n];
|
|
584
591
|
a ? o[e][n] = {
|
|
585
592
|
...a,
|
|
586
|
-
...
|
|
593
|
+
...x,
|
|
587
594
|
custom: {
|
|
588
595
|
...a.custom,
|
|
589
|
-
...
|
|
596
|
+
...x.custom
|
|
590
597
|
}
|
|
591
|
-
} : o[e][n] =
|
|
598
|
+
} : o[e][n] = x;
|
|
592
599
|
}
|
|
593
600
|
}
|
|
594
601
|
return o;
|
|
@@ -597,15 +604,15 @@ function wt(t, r) {
|
|
|
597
604
|
if (!r?.length || !t) return t;
|
|
598
605
|
const o = {};
|
|
599
606
|
for (const e in t) {
|
|
600
|
-
const
|
|
601
|
-
for (const n in
|
|
602
|
-
const h =
|
|
607
|
+
const c = t[e];
|
|
608
|
+
for (const n in c) {
|
|
609
|
+
const h = c[n];
|
|
603
610
|
if (h?.custom?.cellType === "indicator") {
|
|
604
|
-
const
|
|
611
|
+
const x = Number(e), a = Number(n);
|
|
605
612
|
if (r.some(
|
|
606
|
-
(
|
|
613
|
+
(Y) => x >= Y.startRow && x <= Y.endRow && a >= Y.startColumn && a <= Y.endColumn
|
|
607
614
|
) && !r.some(
|
|
608
|
-
(
|
|
615
|
+
(f) => x === f.startRow && a === f.startColumn
|
|
609
616
|
))
|
|
610
617
|
continue;
|
|
611
618
|
}
|
|
@@ -618,14 +625,14 @@ const Mt = "./style.css";
|
|
|
618
625
|
export {
|
|
619
626
|
it as CycleTypeEnum,
|
|
620
627
|
ct as ModeEnum,
|
|
621
|
-
|
|
622
|
-
|
|
628
|
+
I as decimal,
|
|
629
|
+
Yt as filterIndicatorsCell,
|
|
623
630
|
wt as filterMergedIndicatorCells,
|
|
624
|
-
|
|
625
|
-
|
|
631
|
+
Dt as generateIndicatorsCells,
|
|
632
|
+
Q as generateUUID,
|
|
626
633
|
gt as getNumColumns,
|
|
627
634
|
dt as handleClearInput,
|
|
628
|
-
|
|
635
|
+
yt as initDateRange,
|
|
629
636
|
bt as mergeCellData,
|
|
630
637
|
Mt as stylePath,
|
|
631
638
|
ht as useData
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(y,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):(y=typeof globalThis<"u"?globalThis:y||self,c(y.TorUniverSheet={},y.dayjs,y.presets,y.Decimal))})(this,(function(y,c,E,z){"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 i=Number(t);return(i^crypto.getRandomValues(new Uint8Array(1))[0]&15>>i/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:K(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"),K=e=>e&&Array.isArray(e);class fe{value;constructor(r){this.value=new z(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 z(r);if(n.isZero())throw new Error("除数是0");return this.value=this.value.div(n),this}toFixed(r,n){return this.value=new z(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(K(r))return Promise.resolve(r);const n=c(r);if(!n.isValid())return Promise.reject("无效的日期格式");const t=n.year(),i=`${t}-01`,o=`${t}-12`;return Promise.resolve([i,o]);case"month":if(K(r))return Promise.resolve(r);const h=c(r);if(!h.isValid())return Promise.reject("无效的日期格式");const T=h.startOf("month").format("YYYY-MM-DD"),a=h.endOf("month").format("YYYY-MM-DD");return Promise.resolve([T,a]);case"day":if(K(r))return Promise.resolve(r);const Y=c(r);if(!Y.isValid())return Promise.reject("无效的日期格式");const D=Y.startOf("day").format("YYYY-MM-DD HH:mm:ss"),m=Y.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([D,m]);default:return Promise.reject("不支持的周期类型")}}function R(e,r,n){return n?c(r).diff(c(e),n):0}function L(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 O(e,r,n,t){const i="YYYY-MM-DD HH:mm:ss",o=A(e,r,n,t),h=c(o);if(r==="month"){const a=h.month();return a===0?[h.startOf("month").format(i),h.date(25).endOf("day").format(i)]:a===11?[h.subtract(1,"month").date(26).startOf("day").format(i),h.endOf("month").format(i)]:[h.subtract(1,"month").date(26).startOf("day").format(i),h.date(25).endOf("day").format(i)]}const T={year:"year",day:"day",hour:"hour"};return[h.startOf(T[r]).format(i),h.endOf(T[r]).format(i)]}function A(e,r,n,t){const i={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[r];return c(e,i).add(n*t,r).format(i)}function b(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[i,o]=t;for(const[h,T]of Object.entries(o)){const{custom:a,v:Y,t:D,s:m}=T;if(!a)continue;const{cellType:J}=a,f=!a.hasOwnProperty("writeBack")||$(a?.writeBack)?!0:a.writeBack;if(J==="indicator"){const H=b(n,i,h);H.custom={...a,required:$(a?.required)?!1:a?.required,defaultShift:$(a?.defaultShift)?!1:a?.defaultShift,forwardPush:$(a?.forwardPush)?!1:a?.forwardPush,forwardPushTimes:$(a?.useDefaultEndDate)?0:a?.forwardPushTimes,useDefaultEndDate:$(a?.useDefaultEndDate)?!1:a?.useDefaultEndDate,copyType:$(a?.copyType)?"":a?.copyType,writeBack:f},H.s=m,H.t=D,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 i=Object.keys(r),o=Object.values(r);return new Function(...i,`return ${t};`)(...o)}catch(i){return console.error(`表达式执行失败: ${t}`,i),n}})}function de({acc:e,params:r,initRowNum:n,initColNum:t,cellData:i}){const{rangeData:o,currentDay:h,extraArgs:T}=r,a=T?.teamData||{},{cycleType:Y,timeIncrement:D,forwardPush:m,forwardPushTimes:J,copyType:f,copyInterval:H,defaultShift:S,templateStr:P,useDefaultEndDate:Z}=i.custom;let M=0;switch(Y){case"day":{let s="";if(m&&(s=L(o[0],J,"day")),!f){let l="";m?l=s:l=o[0];const u=b(e,n,t);u.v=P?F(P,{businessDate:l,dayjs:c}):c(l).format("YYYY-MM-DD"),u.t=E.CellValueType.STRING;break}m?M=R(s,o[0],"day"):(M=R(o[0],o[1],"day"),console.log("copyNum",M));for(let l=0;l<=Math.abs(M===0?1:M);l++){const u=l*(H+1);let p="";m?p=A(s,"day",l,D):p=A(o[0],"day",l,D);const C=f==="right"?n:n+u,U=f==="right"?t+u:t,G=b(e,C,U);G.v=P?F(P,{businessDate:p,dayjs:c}):c(p).format("YYYY-MM-DD"),G.t=E.CellValueType.STRING}break}case"month":{if(!f){const[s,l]=O(o[1],"month",0,1),u=b(e,n,t);u.v=c(l).format("YYYY-MM"),u.t=E.CellValueType.STRING;break}M=R(o[0],o[1],"month");for(let s=0;s<=Math.abs(M===0?1:M);s++){const l=s*(H+1),u=f==="right"?n:n+l,p=f==="right"?t+l:t,C=b(e,u,p);C.v=A(o[0],"month",s,D),C.t=E.CellValueType.STRING}break}case"year":{let s="";if(m&&(s=L(o[0],J||0,"year")),!f){const l=m?s:o[0],[u,p]=O(l,"year",0,1),C=b(e,n,t),[,U]=O(o[1],"month",0,1);C.v=P?F(P,{startTime:u,endTime:p,rangeData:o,dayjs:c}):l,C.t=E.CellValueType.STRING;break}m?M=R(s,o[0],"year"):M=R(o[0],o[1],"year");for(let l=0;l<=Math.abs(M===0?1:M);l++){const u=l*(H+1),p=f==="right"?n:n+u,C=f==="right"?t+u:t,[U,G]=O(o[0],"year",l,D),v=b(e,p,C),x=A(o[0],"year",l,D);v.v=P?F(P,{startTime:U,endTime:G,rangeData:o,dayjs:c}):x,v.t=E.CellValueType.STRING}break}case"hour":{if(!f){const s=b(e,n,t);if(s.t=E.CellValueType.STRING,S){s.v=c(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}s.v=c(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}M=R(o[0],o[1],"hour");for(let s=0;s<=Math.abs(M===0?1:M);s++){const l=s*(H+1),u=f==="right"?n:n+l,p=f==="right"?t+l:t,C=b(e,u,p);if(C.t=E.CellValueType.STRING,S){const U=c(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");C.v=A(U,"hour",s,D);continue}C.v=A(c(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",s,D)}break}case"shift":{if(!f){const s=b(e,n,t);s.t=E.CellValueType.STRING,s.v=P?F(P,{rangeData:o,dayjs:c}):o[0];break}if(!a.length)throw new Error("没有获取到当班数据");for(let s=0;s<a.length;s++){const l=a[s],{startDatetime:u,endDatetime:p}=l,C=s*(H+1),U=f==="right"?n:I(n).add(C).toNumber(),G=f==="right"?I(t).add(C).toNumber():t,v=b(e,U,G);v.v=P?F(P,{team:l}):u}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 i=n?.teamData||[],{periodicityTime:o}=r,h=r?.currentDay||c().format("YYYY-MM-DD"),T=(Y,D)=>o?parseInt(o.split(":")[0],10)<12?[c(Y).format("YYYY-MM-DD")+" "+o,c(D).add(1,"day").format("YYYY-MM-DD")+" "+o]:[c(Y).subtract(1,"day").format("YYYY-MM-DD")+" "+o,c(D).format("YYYY-MM-DD")+" "+o]:[Y,D],a=Object.entries(e).reduce((Y,D)=>{const[m,J]=D;for(const[f,H]of Object.entries(J)){const{custom:S}=H;if(!S)continue;const{cellType:P,cycleType:Z,timeIncrement:M,forwardPush:s,forwardPushTimes:l,copyType:u,copyInterval:p,defaultShift:C,useDefaultStartDate:U,useDefaultEndDate:G}=S;if(P==="time"){de({acc:Y,params:r,initRowNum:Number(m),initColNum:Number(f),cellData:H});continue}const v={cycleType:Z,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 x=0;switch(Z){case"day":{let d="";if(s&&(d=L(t[0],l||0,"day")),!u){const g=s?d:t[0],[N,w]=T(...O(g,"day",0,1)),k=b(Y,m,f);k.custom={...v,startTime:N,endTime:w};break}s?x=R(d,t[0],"day"):x=R(t[0],t[1],"day");for(let g=0;g<=Math.abs(x===0?1:x);g++){const N=g*(p+1),w=s?d:t[0],[k,V]=T(...O(w,"day",g,M)),B=u==="right"?m:I(m).add(N).toNumber(),q=u==="right"?I(f).add(N).toNumber():f,j=b(Y,B,q);j.custom={...v,startTime:k,endTime:V}}break}case"month":{if(!u){const[d,g]=O(t[1],"month",0,1),N=b(Y,m,f);N.custom={...v,startTime:d,endTime:g};break}x=R(t[0],t[1],"month");for(let d=0;d<=Math.abs(x===0?1:x);d++){const g=d*(p+1),N=u==="right"?m:I(m).add(g).toNumber(),w=u==="right"?I(f).add(g).toNumber():f,[k,V]=O(t[0],"month",d,M),B=b(Y,N,w);B.custom={...v,startTime:k,endTime:V}}break}case"year":{let d="",g="",N="";if(s){d=L(t[0],l||0,"year");const w=c(t[1]).format("MM");g=c(`${d}-${w+1}`).format("YYYY-MM"),N=c(`${d}-${w+2}`).format("YYYY-MM")}if(!u){const w=s?d:t[0],[k,V]=O(w,"year",0,1),B=b(Y,m,f),[,q]=O(g,"month",0,1),[j]=O(N,"month",0,1);B.custom={...v,startTime:U?j:k,endTime:G?q:V};break}s?x=R(d,t[0],"year"):x=R(t[0],t[1],"year");for(let w=0;w<=Math.abs(x===0?1:x);w++){const k=w*(p+1),V=u==="right"?m:I(m).add(k).toNumber(),B=u==="right"?I(f).add(k).toNumber():f,[q,j]=O(t[0],"year",w,M),_=b(Y,V,B);_.custom={...v,startTime:q,endTime:j}}break}case"hour":{if(!u){const d=C?t[0]:t[0]??h,[g,N]=O(d,"hour",1,1),w=b(Y,m,f);w.custom={...v,startTime:g,endTime:N};break}x=R(t[0],t[1],"hour");for(let d=0;d<=Math.abs(x===0?1:x);d++){const g=d*(p+1),N=u==="right"?m:I(m).add(g).toNumber(),w=u==="right"?I(f).add(g).toNumber():f,k=b(Y,N,w);if(C){const j=c(t[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[_,be]=O(j,"hour",d,M);k.custom={...v,startTime:_,endTime:be};continue}const V=c(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[B,q]=O(V,"hour",d,M);k.custom={...v,startTime:B,endTime:q}}break}case"shift":{if(!u){const[d,g]=t,N=b(Y,m,f);N.custom={...v,startTime:d,endTime:g};break}if(!i.length)throw new Error("没有获取到当班数据");for(let d=0;d<i.length;d++){const g=i[d],{startDatetime:N,endDatetime:w}=g,k=d*(p+1),V=u==="right"?m:I(m).add(k).toNumber(),B=u==="right"?I(f).add(k).toNumber():f,q=b(Y,V,B);q.custom={...v,startTime:N,endTime:w}}break}}}return Y},{});return Promise.resolve(a)}function Ye(e){return Object.entries(e).reduce((n,[t,i])=>{const o=Math.max(...Object.keys(i).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,i]of Object.entries(r)){n[t]||(n[t]={});for(const[o,h]of Object.entries(i)){const T=h,a=n[t]?.[o];a?n[t][o]={...a,...T,custom:{...a.custom,...T.custom}}:n[t][o]=T}}return n}function ge(e,r){if(!r?.length||!e)return e;const n={};for(const t in e){const i=e[t];for(const o in i){const h=i[o];if(h?.custom?.cellType==="indicator"){const T=Number(t),a=Number(o);if(r.some(D=>T>=D.startRow&&T<=D.endRow&&a>=D.startColumn&&a<=D.endColumn)&&!r.some(m=>T===m.startRow&&a===m.startColumn))continue}n[t]||(n[t]={}),n[t][o]=h}}return n}const ye="./style.css";y.CycleTypeEnum=X,y.ModeEnum=ee,y.decimal=I,y.filterIndicatorsCell=me,y.filterMergedIndicatorCells=ge,y.generateIndicatorsCells=he,y.generateUUID=Q,y.getNumColumns=Ye,y.handleClearInput=te,y.initDateRange=le,y.mergeCellData=De,y.stylePath=ye,y.useData=re,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(M,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("dayjs"),require("@univerjs/presets"),require("decimal.js")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/presets","decimal.js"],l):(M=typeof globalThis<"u"?globalThis:M||self,l(M.TorUniverSheet={},M.dayjs,M.presets,M.Decimal))})(this,(function(M,l,$,z){"use strict";const te=(e,r)=>{for(const n of r)e[n]=null},_=()=>{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 re(e){return{...e?.workbookData,id:e?.id||_(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const ne=Object.prototype.toString,Q=(e,r)=>ne.call(e)===`[object ${r}]`,oe=e=>typeof e<"u",se=e=>!oe(e),ae=e=>e!==null&&Q(e,"Object"),q=e=>e==null||typeof e>"u"?!0:K(e)||le(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,ce=e=>se(e)||ie(e),le=e=>Q(e,"String"),K=e=>e&&Array.isArray(e);class ue{value;constructor(r){this.value=new z(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 z(r);if(n.isZero())throw new Error("除数是0");return this.value=this.value.div(n),this}toFixed(r,n){return this.value=new z(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 ue(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 fe(e,r){if(!r)return Promise.reject("日期不能为空");switch(e){case"year":if(K(r))return Promise.resolve(r);const n=l(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(K(r))return Promise.resolve(r);const h=l(r);if(!h.isValid())return Promise.reject("无效的日期格式");const N=h.startOf("month").format("YYYY-MM-DD"),a=h.endOf("month").format("YYYY-MM-DD");return Promise.resolve([N,a]);case"day":if(K(r))return Promise.resolve(r);const y=l(r);if(!y.isValid())return Promise.reject("无效的日期格式");const Y=y.startOf("day").format("YYYY-MM-DD HH:mm:ss"),m=y.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([Y,m]);default:return Promise.reject("不支持的周期类型")}}function V(e,r,n){return n?l(r).diff(l(e),n):0}function L(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 l(e).subtract(r,n).format(t)}function O(e,r,n,t){const c="YYYY-MM-DD HH:mm:ss",o=j(e,r,n,t),h=l(o);if(r==="month"){const a=h.month();return a===0?[h.startOf("month").format(c),h.date(25).endOf("day").format(c)]:a===11?[h.subtract(1,"month").date(26).startOf("day").format(c),h.endOf("month").format(c)]:[h.subtract(1,"month").date(26).startOf("day").format(c),h.date(25).endOf("day").format(c)]}const N={year:"year",day:"day",hour:"hour"};return[h.startOf(N[r]).format(c),h.endOf(N[r]).format(c)]}function j(e,r,n,t){const c={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[r];return l(e,c).add(n*t,r).format(c)}function w(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[c,o]=t;for(const[h,N]of Object.entries(o)){const{custom:a,v:y,t:Y,s:m}=N;if(!a)continue;const{cellType:J}=a,u=!a.hasOwnProperty("writeBack")||q(a?.writeBack)?!0:a.writeBack;if(J==="indicator"){const H=w(n,c,h);H.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,copyType:q(a?.copyType)?"":a?.copyType,writeBack:u},H.s=m,H.t=Y,H.v=y||""}}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 de({acc:e,params:r,initRowNum:n,initColNum:t,cellData:c}){const{rangeData:o,currentDay:h,extraArgs:N}=r,a=N?.teamData||{},{cycleType:y,timeIncrement:Y,forwardPush:m,forwardPushTimes:J,copyType:u,copyInterval:H,defaultShift:C,templateStr:P,useDefaultEndDate:Z}=c.custom;let T=0;switch(y){case"day":{let s="";if(m&&(s=L(o[0],J,"day")),!u){let f="";m?f=s:f=o[0];const i=w(e,n,t);i.v=P?F(P,{businessDate:f,dayjs:l}):l(f).format("YYYY-MM-DD"),i.t=$.CellValueType.STRING,i.s="tor-time-cell-style";break}m?T=V(s,o[0],"day"):(T=V(o[0],o[1],"day"),console.log("copyNum",T));for(let f=0;f<=Math.abs(T===0?1:T);f++){const i=f*(H+1);let S="";m?S=j(s,"day",f,Y):S=j(o[0],"day",f,Y);const g=u==="right"?n:n+i,U=u==="right"?t+i:t,G=w(e,g,U);G.v=P?F(P,{businessDate:S,dayjs:l}):l(S).format("YYYY-MM-DD"),G.t=$.CellValueType.STRING,G.s="tor-time-cell-style"}break}case"month":{if(!u){const[s,f]=O(o[1],"month",0,1),i=w(e,n,t);i.v=l(f).format("YYYY-MM"),i.t=$.CellValueType.STRING,i.s="tor-time-cell-style";break}T=V(o[0],o[1],"month");for(let s=0;s<=Math.abs(T===0?1:T);s++){const f=s*(H+1),i=u==="right"?n:n+f,S=u==="right"?t+f:t,g=w(e,i,S);g.v=j(o[0],"month",s,Y),g.t=$.CellValueType.STRING,g.s="tor-time-cell-style"}break}case"year":{let s="";if(m&&(s=L(o[0],J||0,"year")),!u){const f=m?s:o[0],[i,S]=O(f,"year",0,1),g=w(e,n,t),[,U]=O(o[1],"month",0,1);g.v=P?F(P,{startTime:i,endTime:S,rangeData:o,dayjs:l}):f,g.t=$.CellValueType.STRING,g.s="tor-time-cell-style";break}m?T=V(s,o[0],"year"):T=V(o[0],o[1],"year");for(let f=0;f<=Math.abs(T===0?1:T);f++){const i=f*(H+1),S=u==="right"?n:n+i,g=u==="right"?t+i:t,[U,G]=O(o[0],"year",f,Y),v=w(e,S,g),k=j(o[0],"year",f,Y);v.v=P?F(P,{startTime:U,endTime:G,rangeData:o,dayjs:l}):k,v.t=$.CellValueType.STRING,v.s="tor-time-cell-style"}break}case"hour":{if(!u){const s=w(e,n,t);if(s.t=$.CellValueType.STRING,s.s="tor-time-cell-style",C){s.v=l(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}s.v=l(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}T=V(o[0],o[1],"hour");for(let s=0;s<=Math.abs(T===0?1:T);s++){const f=s*(H+1),i=u==="right"?n:n+f,S=u==="right"?t+f:t,g=w(e,i,S);if(g.t=$.CellValueType.STRING,g.s="tor-time-cell-style",C){const U=l(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");g.v=j(U,"hour",s,Y);continue}g.v=j(l(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",s,Y)}break}case"shift":{if(!u){const s=w(e,n,t);s.t=$.CellValueType.STRING,s.s="tor-time-cell-style",s.v=P?F(P,{rangeData:o,dayjs:l}):o[0];break}if(!a.length)throw new Error("没有获取到当班数据");for(let s=0;s<a.length;s++){const f=a[s],{startDatetime:i,endDatetime:S}=f,g=s*(H+1),U=u==="right"?n:I(n).add(g).toNumber(),G=u==="right"?I(t).add(g).toNumber():t,v=w(e,U,G);v.s="tor-time-cell-style",v.v=P?F(P,{team:f}):i}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 c=n?.teamData||[],{periodicityTime:o}=r,h=r?.currentDay||l().format("YYYY-MM-DD"),N=(y,Y)=>o?parseInt(o.split(":")[0],10)<12?[l(y).format("YYYY-MM-DD")+" "+o,l(Y).add(1,"day").format("YYYY-MM-DD")+" "+o]:[l(y).subtract(1,"day").format("YYYY-MM-DD")+" "+o,l(Y).format("YYYY-MM-DD")+" "+o]:[y,Y],a=Object.entries(e).reduce((y,Y)=>{const[m,J]=Y;for(const[u,H]of Object.entries(J)){const{custom:C}=H;if(!C)continue;const{cellType:P,cycleType:Z,timeIncrement:T,forwardPush:s,forwardPushTimes:f,copyType:i,copyInterval:S,defaultShift:g,useDefaultStartDate:U,useDefaultEndDate:G}=C;if(P==="time"){de({acc:y,params:r,initRowNum:Number(m),initColNum:Number(u),cellData:H});continue}const v={cycleType:Z,indicatorName:C.indicatorName,indicatorCode:C.indicatorCode,indicatorId:C.indicatorId,indicatorDimensionName:C.indicatorDimensionName,indicatorDimensionConfig:C.indicatorDimensionConfig,required:ce(C?.required)??!1,cellType:C.cellType,defaultShift:C?.defaultShift||!1,writeBack:q(C?.writeBack)?!0:C.writeBack,dimensionJson:C?.dimensionJson||"",unit:C?.unit||"",innerSyncWay:C?.innerSyncWay||"",outSyncConfigId:C?.outSyncConfigId||"",innerSyncStatus:C?.innerSyncStatus||""};let k=0;switch(Z){case"day":{let d="";if(s&&(d=L(t[0],f||0,"day")),!i){const D=s?d:t[0],[p,b]=N(...O(D,"day",0,1)),x=w(y,m,u);x.s="tor-indicator-cell-style",x.custom={...v,startTime:p,endTime:b};break}s?k=V(d,t[0],"day"):k=V(t[0],t[1],"day");for(let D=0;D<=Math.abs(k===0?1:k);D++){const p=D*(S+1),b=s?d:t[0],[x,B]=N(...O(b,"day",D,T)),R=i==="right"?m:I(m).add(p).toNumber(),E=i==="right"?I(u).add(p).toNumber():u,A=w(y,R,E);A.s="tor-indicator-cell-style",A.custom={...v,startTime:x,endTime:B}}break}case"month":{if(!i){const[d,D]=O(t[1],"month",0,1),p=w(y,m,u);p.s="tor-indicator-cell-style",p.custom={...v,startTime:d,endTime:D};break}k=V(t[0],t[1],"month");for(let d=0;d<=Math.abs(k===0?1:k);d++){const D=d*(S+1),p=i==="right"?m:I(m).add(D).toNumber(),b=i==="right"?I(u).add(D).toNumber():u,[x,B]=O(t[0],"month",d,T),R=w(y,p,b);R.s="tor-indicator-cell-style",R.custom={...v,startTime:x,endTime:B}}break}case"year":{let d="",D="",p="";if(s){d=L(t[0],f||0,"year");const b=l(t[1]).format("MM");D=l(`${d}-${b+1}`).format("YYYY-MM"),p=l(`${d}-${b+2}`).format("YYYY-MM")}if(!i){const b=s?d:t[0],[x,B]=O(b,"year",0,1),R=w(y,m,u);R.s="tor-indicator-cell-style";const[,E]=O(D,"month",0,1),[A]=O(p,"month",0,1);R.custom={...v,startTime:U?A:x,endTime:G?E:B};break}s?k=V(d,t[0],"year"):k=V(t[0],t[1],"year");for(let b=0;b<=Math.abs(k===0?1:k);b++){const x=b*(S+1),B=i==="right"?m:I(m).add(x).toNumber(),R=i==="right"?I(u).add(x).toNumber():u,[E,A]=O(t[0],"year",b,T),W=w(y,B,R);W.s="tor-indicator-cell-style",W.custom={...v,startTime:E,endTime:A}}break}case"hour":{if(!i){const d=g?t[0]:t[0]??h,[D,p]=O(d,"hour",1,1),b=w(y,m,u);b.s="tor-indicator-cell-style",b.custom={...v,startTime:D,endTime:p};break}k=V(t[0],t[1],"hour");for(let d=0;d<=Math.abs(k===0?1:k);d++){const D=d*(S+1),p=i==="right"?m:I(m).add(D).toNumber(),b=i==="right"?I(u).add(D).toNumber():u,x=w(y,p,b);if(x.s="tor-indicator-cell-style",g){const A=l(t[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[W,be]=O(A,"hour",d,T);x.custom={...v,startTime:W,endTime:be};continue}const B=l(h).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[R,E]=O(B,"hour",d,T);x.custom={...v,startTime:R,endTime:E}}break}case"shift":{if(!i){const[d,D]=t,p=w(y,m,u);p.s="tor-indicator-cell-style",p.custom={...v,startTime:d,endTime:D};break}if(!c.length)throw new Error("没有获取到当班数据");for(let d=0;d<c.length;d++){const D=c[d],{startDatetime:p,endDatetime:b}=D,x=d*(S+1),B=i==="right"?m:I(m).add(x).toNumber(),R=i==="right"?I(u).add(x).toNumber():u,E=w(y,B,R);E.s="tor-indicator-cell-style",E.custom={...v,startTime:p,endTime:b}}break}}}return y},{});return Promise.resolve(a)}function ye(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 Ye(e,r){const n=JSON.parse(JSON.stringify(e||{}));for(const[t,c]of Object.entries(r)){n[t]||(n[t]={});for(const[o,h]of Object.entries(c)){const N=h,a=n[t]?.[o];a?n[t][o]={...a,...N,custom:{...a.custom,...N.custom}}:n[t][o]=N}}return n}function De(e,r){if(!r?.length||!e)return e;const n={};for(const t in e){const c=e[t];for(const o in c){const h=c[o];if(h?.custom?.cellType==="indicator"){const N=Number(t),a=Number(o);if(r.some(Y=>N>=Y.startRow&&N<=Y.endRow&&a>=Y.startColumn&&a<=Y.endColumn)&&!r.some(m=>N===m.startRow&&a===m.startColumn))continue}n[t]||(n[t]={}),n[t][o]=h}}return n}const ge="./style.css";M.CycleTypeEnum=X,M.ModeEnum=ee,M.decimal=I,M.filterIndicatorsCell=me,M.filterMergedIndicatorCells=De,M.generateIndicatorsCells=he,M.generateUUID=_,M.getNumColumns=ye,M.handleClearInput=te,M.initDateRange=fe,M.mergeCellData=Ye,M.stylePath=ge,M.useData=re,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})}));
|