tor-univer-sheet 1.1.17 → 1.1.19
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 +251 -227
- package/dist/tor-univer-sheet.umd.js +1 -1
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CellValueType as
|
|
3
|
-
import
|
|
1
|
+
import d from "dayjs";
|
|
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;
|
|
@@ -10,8 +10,8 @@ const dt = (t, r) => {
|
|
|
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
|
}
|
|
@@ -30,11 +30,11 @@ function ht(t) {
|
|
|
30
30
|
appVersion: t?.appVersion || "1.0.0"
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
const X = Object.prototype.toString,
|
|
33
|
+
const X = Object.prototype.toString, _ = (t, r) => X.call(t) === `[object ${r}]`, tt = (t) => typeof t < "u", et = (t) => !tt(t), rt = (t) => t !== null && _(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) => _(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,45 +103,45 @@ class at {
|
|
|
103
103
|
return this.value.toNumber();
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function H(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
|
-
const o =
|
|
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
|
-
const h =
|
|
124
|
+
const h = d(r);
|
|
125
125
|
if (!h.isValid())
|
|
126
126
|
return Promise.reject("无效的日期格式");
|
|
127
|
-
const
|
|
128
|
-
return Promise.resolve([
|
|
127
|
+
const p = h.startOf("month").format("YYYY-MM-DD"), a = h.endOf("month").format("YYYY-MM-DD");
|
|
128
|
+
return Promise.resolve([p, 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
|
}
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
return o ?
|
|
141
|
+
function I(t, r, o) {
|
|
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 = {
|
|
@@ -150,244 +150,244 @@ function z(t, r, o) {
|
|
|
150
150
|
day: "YYYY-MM-DD",
|
|
151
151
|
hour: "HH:mm:ss"
|
|
152
152
|
}[o];
|
|
153
|
-
return
|
|
153
|
+
return d(t).subtract(r, o).format(e);
|
|
154
154
|
}
|
|
155
155
|
function S(t, r, o, e) {
|
|
156
|
-
const
|
|
156
|
+
const c = "YYYY-MM-DD HH:mm:ss", n = A(t, r, o, e), h = d(n);
|
|
157
157
|
if (r === "month") {
|
|
158
|
-
const
|
|
159
|
-
return
|
|
158
|
+
const a = h.month();
|
|
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 p = { year: "year", day: "day", hour: "hour" };
|
|
162
|
+
return [h.startOf(p[r]).format(c), h.endOf(p[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
|
|
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:
|
|
183
|
-
if (!
|
|
184
|
-
const { cellType: q } =
|
|
180
|
+
const [c, n] = e;
|
|
181
|
+
for (const [h, p] of Object.entries(n)) {
|
|
182
|
+
const { custom: a, v: y, t: Y, s: f } = p;
|
|
183
|
+
if (!a) continue;
|
|
184
|
+
const { cellType: q } = a, l = !a.hasOwnProperty("writeBack") || G(a?.writeBack) ? !0 : a.writeBack;
|
|
185
185
|
if (q === "indicator") {
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
...
|
|
189
|
-
required:
|
|
190
|
-
defaultShift:
|
|
191
|
-
forwardPush:
|
|
192
|
-
forwardPushTimes:
|
|
193
|
-
useDefaultEndDate:
|
|
194
|
-
copyType:
|
|
195
|
-
writeBack:
|
|
196
|
-
},
|
|
186
|
+
const P = T(o, c, h);
|
|
187
|
+
P.custom = {
|
|
188
|
+
...a,
|
|
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
|
+
writeBack: l
|
|
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
|
}
|
|
213
|
-
function
|
|
213
|
+
function lt({
|
|
214
214
|
acc: t,
|
|
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: p } = r, a = p?.teamData || {}, { cycleType: y, timeIncrement: Y, forwardPush: f, forwardPushTimes: q, copyType: l, copyInterval: P, defaultShift: O, templateStr: C, useDefaultEndDate: z } = 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
|
+
)), !l) {
|
|
231
231
|
let u = "";
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
232
|
+
f ? u = s : u = n[0];
|
|
233
|
+
const i = T(t, o, e);
|
|
234
|
+
i.v = C ? F(C, { businessDate: u, dayjs: d }) : d(u).format("YYYY-MM-DD"), i.t = E.STRING, i.s = "tor-time-cell-style";
|
|
235
235
|
break;
|
|
236
236
|
}
|
|
237
|
-
|
|
237
|
+
f ? w = I(
|
|
238
238
|
s,
|
|
239
239
|
n[0],
|
|
240
240
|
"day"
|
|
241
241
|
/* day */
|
|
242
|
-
) : (
|
|
242
|
+
) : (w = I(
|
|
243
243
|
n[0],
|
|
244
244
|
n[1],
|
|
245
245
|
"day"
|
|
246
246
|
/* day */
|
|
247
|
-
), console.log("copyNum",
|
|
248
|
-
for (let u = 0; u <= Math.abs(
|
|
249
|
-
const
|
|
250
|
-
let
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
|
|
247
|
+
), console.log("copyNum", w));
|
|
248
|
+
for (let u = 0; u <= Math.abs(w === 0 ? 1 : w); u++) {
|
|
249
|
+
const i = u * (P + 1);
|
|
250
|
+
let x = "";
|
|
251
|
+
f ? x = A(s, "day", u, Y) : x = A(n[0], "day", u, Y);
|
|
252
|
+
const g = l === "right" ? o : o + i, B = l === "right" ? e + i : e, $ = T(t, g, B);
|
|
253
|
+
$.v = C ? F(C, { businessDate: x, dayjs: d }) : d(x).format("YYYY-MM-DD"), $.t = E.STRING, $.s = "tor-time-cell-style";
|
|
254
254
|
}
|
|
255
255
|
break;
|
|
256
256
|
}
|
|
257
257
|
case "month": {
|
|
258
|
-
if (!
|
|
259
|
-
const [s, u] = S(n[1], "month", 0, 1),
|
|
260
|
-
|
|
258
|
+
if (!l) {
|
|
259
|
+
const [s, u] = S(n[1], "month", 0, 1), i = T(t, o, e);
|
|
260
|
+
i.v = d(u).format("YYYY-MM"), i.t = E.STRING, i.s = "tor-time-cell-style";
|
|
261
261
|
break;
|
|
262
262
|
}
|
|
263
|
-
|
|
263
|
+
w = I(
|
|
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 u = s * (
|
|
271
|
-
|
|
269
|
+
for (let s = 0; s <= Math.abs(w === 0 ? 1 : w); s++) {
|
|
270
|
+
const u = s * (P + 1), i = l === "right" ? o : o + u, x = l === "right" ? e + u : e, g = T(t, i, x);
|
|
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
|
-
)), !
|
|
283
|
-
const u =
|
|
284
|
-
|
|
285
|
-
startTime:
|
|
286
|
-
endTime:
|
|
282
|
+
)), !l) {
|
|
283
|
+
const u = f ? s : n[0], [i, x] = S(u, "year", 0, 1), g = T(t, o, e), [, B] = S(n[1], "month", 0, 1);
|
|
284
|
+
g.v = C ? F(C, {
|
|
285
|
+
startTime: i,
|
|
286
|
+
endTime: x,
|
|
287
287
|
rangeData: n,
|
|
288
|
-
dayjs:
|
|
289
|
-
}) : u,
|
|
288
|
+
dayjs: d
|
|
289
|
+
}) : u, g.t = E.STRING, g.s = "tor-time-cell-style";
|
|
290
290
|
break;
|
|
291
291
|
}
|
|
292
|
-
|
|
292
|
+
f ? w = I(
|
|
293
293
|
s,
|
|
294
294
|
n[0],
|
|
295
295
|
"year"
|
|
296
296
|
/* year */
|
|
297
|
-
) :
|
|
297
|
+
) : w = I(
|
|
298
298
|
n[0],
|
|
299
299
|
n[1],
|
|
300
300
|
"year"
|
|
301
301
|
/* year */
|
|
302
302
|
);
|
|
303
|
-
for (let u = 0; u <= Math.abs(
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
startTime:
|
|
307
|
-
endTime:
|
|
303
|
+
for (let u = 0; u <= Math.abs(w === 0 ? 1 : w); u++) {
|
|
304
|
+
const i = u * (P + 1), x = l === "right" ? o : o + i, g = l === "right" ? e + i : e, [B, $] = S(n[0], "year", u, Y), N = T(t, x, g), k = A(n[0], "year", u, Y);
|
|
305
|
+
N.v = C ? F(C, {
|
|
306
|
+
startTime: B,
|
|
307
|
+
endTime: $,
|
|
308
308
|
rangeData: n,
|
|
309
|
-
dayjs:
|
|
310
|
-
}) :
|
|
309
|
+
dayjs: d
|
|
310
|
+
}) : k, N.t = E.STRING, N.s = "tor-time-cell-style";
|
|
311
311
|
}
|
|
312
312
|
break;
|
|
313
313
|
}
|
|
314
314
|
case "hour": {
|
|
315
|
-
if (!
|
|
316
|
-
const s =
|
|
317
|
-
if (s.t =
|
|
318
|
-
s.v =
|
|
315
|
+
if (!l) {
|
|
316
|
+
const s = T(t, o, e);
|
|
317
|
+
if (s.t = E.STRING, s.s = "tor-time-cell-style", O) {
|
|
318
|
+
s.v = d(n[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
319
319
|
break;
|
|
320
320
|
}
|
|
321
|
-
s.v =
|
|
321
|
+
s.v = d(h).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
322
322
|
break;
|
|
323
323
|
}
|
|
324
|
-
|
|
324
|
+
w = I(
|
|
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 u = s * (
|
|
332
|
-
if (
|
|
333
|
-
const
|
|
334
|
-
|
|
330
|
+
for (let s = 0; s <= Math.abs(w === 0 ? 1 : w); s++) {
|
|
331
|
+
const u = s * (P + 1), i = l === "right" ? o : o + u, x = l === "right" ? e + u : e, g = T(t, i, x);
|
|
332
|
+
if (g.t = E.STRING, g.s = "tor-time-cell-style", O) {
|
|
333
|
+
const B = d(n[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
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
|
-
if (!
|
|
343
|
-
const s =
|
|
344
|
-
s.t =
|
|
342
|
+
if (!l) {
|
|
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
|
-
dayjs:
|
|
346
|
+
dayjs: d
|
|
347
347
|
}) : n[0];
|
|
348
348
|
break;
|
|
349
349
|
}
|
|
350
|
-
if (!
|
|
350
|
+
if (!a.length)
|
|
351
351
|
throw new Error("没有获取到当班数据");
|
|
352
|
-
for (let s = 0; s <
|
|
353
|
-
const u =
|
|
354
|
-
|
|
352
|
+
for (let s = 0; s < a.length; s++) {
|
|
353
|
+
const u = a[s], { startDatetime: i, endDatetime: x } = u, g = s * (P + 1), B = l === "right" ? o : H(o).add(g).toNumber(), $ = l === "right" ? H(e).add(g).toNumber() : e, N = T(t, B, $);
|
|
354
|
+
N.s = "tor-time-cell-style", N.v = C ? F(C, {
|
|
355
355
|
team: u
|
|
356
|
-
}) :
|
|
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 [
|
|
370
|
-
for (const [
|
|
371
|
-
const { custom: O } =
|
|
368
|
+
const c = o?.teamData || [], { periodicityTime: n } = r, h = r?.currentDay || d().format("YYYY-MM-DD"), p = (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
|
+
for (const [l, P] of Object.entries(q)) {
|
|
371
|
+
const { custom: O } = P;
|
|
372
372
|
if (!O) continue;
|
|
373
373
|
const {
|
|
374
|
-
cellType:
|
|
375
|
-
cycleType:
|
|
376
|
-
timeIncrement:
|
|
374
|
+
cellType: C,
|
|
375
|
+
cycleType: z,
|
|
376
|
+
timeIncrement: w,
|
|
377
377
|
forwardPush: s,
|
|
378
378
|
forwardPushTimes: u,
|
|
379
|
-
copyType:
|
|
380
|
-
copyInterval:
|
|
381
|
-
defaultShift:
|
|
382
|
-
useDefaultStartDate:
|
|
383
|
-
useDefaultEndDate:
|
|
379
|
+
copyType: i,
|
|
380
|
+
copyInterval: x,
|
|
381
|
+
defaultShift: g,
|
|
382
|
+
useDefaultStartDate: B,
|
|
383
|
+
useDefaultEndDate: $
|
|
384
384
|
} = O;
|
|
385
|
-
if (
|
|
386
|
-
|
|
385
|
+
if (C === "time") {
|
|
386
|
+
lt({ acc: y, params: r, initRowNum: Number(f), initColNum: Number(l), cellData: P });
|
|
387
387
|
continue;
|
|
388
388
|
}
|
|
389
|
-
const
|
|
390
|
-
cycleType:
|
|
389
|
+
const N = {
|
|
390
|
+
cycleType: z,
|
|
391
391
|
indicatorName: O.indicatorName,
|
|
392
392
|
indicatorCode: O.indicatorCode,
|
|
393
393
|
indicatorId: O.indicatorId,
|
|
@@ -396,109 +396,111 @@ async function yt(t, r) {
|
|
|
396
396
|
required: nt(O?.required) ?? !1,
|
|
397
397
|
cellType: O.cellType,
|
|
398
398
|
defaultShift: O?.defaultShift || !1,
|
|
399
|
-
writeBack:
|
|
399
|
+
writeBack: G(O?.writeBack) ? !0 : O.writeBack
|
|
400
400
|
};
|
|
401
|
-
let
|
|
402
|
-
switch (
|
|
401
|
+
let k = 0;
|
|
402
|
+
switch (z) {
|
|
403
403
|
case "day": {
|
|
404
404
|
let m = "";
|
|
405
|
-
if (s && (m =
|
|
405
|
+
if (s && (m = L(
|
|
406
406
|
e[0],
|
|
407
407
|
u || 0,
|
|
408
408
|
"day"
|
|
409
409
|
/* day */
|
|
410
|
-
)), !
|
|
411
|
-
const D = s ? m : e[0], [
|
|
412
|
-
v.custom = {
|
|
413
|
-
...
|
|
414
|
-
startTime:
|
|
410
|
+
)), !i) {
|
|
411
|
+
const D = s ? m : e[0], [M, b] = p(...S(D, "day", 0, 1)), v = T(y, f, l);
|
|
412
|
+
v.s = "tor-indicator-cell-style", v.custom = {
|
|
413
|
+
...N,
|
|
414
|
+
startTime: M,
|
|
415
415
|
endTime: b
|
|
416
416
|
};
|
|
417
417
|
break;
|
|
418
418
|
}
|
|
419
|
-
s ?
|
|
419
|
+
s ? k = I(
|
|
420
420
|
m,
|
|
421
421
|
e[0],
|
|
422
422
|
"day"
|
|
423
423
|
/* day */
|
|
424
|
-
) :
|
|
424
|
+
) : k = I(
|
|
425
425
|
e[0],
|
|
426
426
|
e[1],
|
|
427
427
|
"day"
|
|
428
428
|
/* day */
|
|
429
429
|
);
|
|
430
|
-
for (let D = 0; D <= Math.abs(
|
|
431
|
-
const
|
|
432
|
-
V.custom = {
|
|
433
|
-
...
|
|
430
|
+
for (let D = 0; D <= Math.abs(k === 0 ? 1 : k); D++) {
|
|
431
|
+
const M = D * (x + 1), b = s ? m : e[0], [v, R] = p(...S(b, "day", D, w)), j = i === "right" ? f : H(f).add(M).toNumber(), U = i === "right" ? H(l).add(M).toNumber() : l, V = T(y, j, U);
|
|
432
|
+
V.s = "tor-indicator-cell-style", V.custom = {
|
|
433
|
+
...N,
|
|
434
434
|
startTime: v,
|
|
435
|
-
endTime:
|
|
435
|
+
endTime: R
|
|
436
436
|
};
|
|
437
437
|
}
|
|
438
438
|
break;
|
|
439
439
|
}
|
|
440
440
|
case "month": {
|
|
441
|
-
if (!
|
|
442
|
-
const [m, D] = S(e[1], "month", 0, 1),
|
|
443
|
-
|
|
444
|
-
...
|
|
441
|
+
if (!i) {
|
|
442
|
+
const [m, D] = S(e[1], "month", 0, 1), M = T(y, f, l);
|
|
443
|
+
M.s = "tor-indicator-cell-style", M.custom = {
|
|
444
|
+
...N,
|
|
445
445
|
startTime: m,
|
|
446
446
|
endTime: D
|
|
447
447
|
};
|
|
448
448
|
break;
|
|
449
449
|
}
|
|
450
|
-
|
|
450
|
+
k = I(
|
|
451
451
|
e[0],
|
|
452
452
|
e[1],
|
|
453
453
|
"month"
|
|
454
454
|
/* month */
|
|
455
455
|
);
|
|
456
|
-
for (let m = 0; m <= Math.abs(
|
|
457
|
-
const D = m * (
|
|
458
|
-
|
|
459
|
-
...
|
|
456
|
+
for (let m = 0; m <= Math.abs(k === 0 ? 1 : k); m++) {
|
|
457
|
+
const D = m * (x + 1), M = i === "right" ? f : H(f).add(D).toNumber(), b = i === "right" ? H(l).add(D).toNumber() : l, [v, R] = S(e[0], "month", m, w), j = T(y, M, b);
|
|
458
|
+
j.s = "tor-indicator-cell-style", j.custom = {
|
|
459
|
+
...N,
|
|
460
460
|
startTime: v,
|
|
461
|
-
endTime:
|
|
461
|
+
endTime: R
|
|
462
462
|
};
|
|
463
463
|
}
|
|
464
464
|
break;
|
|
465
465
|
}
|
|
466
466
|
case "year": {
|
|
467
|
-
let m = "", D = "",
|
|
467
|
+
let m = "", D = "", M = "";
|
|
468
468
|
if (s) {
|
|
469
|
-
m =
|
|
469
|
+
m = L(
|
|
470
470
|
e[0],
|
|
471
471
|
u || 0,
|
|
472
472
|
"year"
|
|
473
473
|
/* year */
|
|
474
474
|
);
|
|
475
|
-
const b =
|
|
476
|
-
D =
|
|
475
|
+
const b = d(e[1]).format("MM");
|
|
476
|
+
D = d(`${m}-${b + 1}`).format("YYYY-MM"), M = d(`${m}-${b + 2}`).format("YYYY-MM");
|
|
477
477
|
}
|
|
478
|
-
if (!
|
|
479
|
-
const b = s ? m : e[0], [v,
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
478
|
+
if (!i) {
|
|
479
|
+
const b = s ? m : e[0], [v, R] = S(b, "year", 0, 1), j = T(y, f, l);
|
|
480
|
+
j.s = "tor-indicator-cell-style";
|
|
481
|
+
const [, U] = S(D, "month", 0, 1), [V] = S(M, "month", 0, 1);
|
|
482
|
+
j.custom = {
|
|
483
|
+
...N,
|
|
484
|
+
startTime: B ? V : v,
|
|
485
|
+
endTime: $ ? U : R
|
|
484
486
|
};
|
|
485
487
|
break;
|
|
486
488
|
}
|
|
487
|
-
s ?
|
|
489
|
+
s ? k = I(
|
|
488
490
|
m,
|
|
489
491
|
e[0],
|
|
490
492
|
"year"
|
|
491
493
|
/* year */
|
|
492
|
-
) :
|
|
494
|
+
) : k = I(
|
|
493
495
|
e[0],
|
|
494
496
|
e[1],
|
|
495
497
|
"year"
|
|
496
498
|
/* year */
|
|
497
499
|
);
|
|
498
|
-
for (let b = 0; b <= Math.abs(
|
|
499
|
-
const v = b * (
|
|
500
|
-
|
|
501
|
-
...
|
|
500
|
+
for (let b = 0; b <= Math.abs(k === 0 ? 1 : k); b++) {
|
|
501
|
+
const v = b * (x + 1), R = i === "right" ? f : H(f).add(v).toNumber(), j = i === "right" ? H(l).add(v).toNumber() : l, [U, V] = S(e[0], "year", b, w), J = T(y, R, j);
|
|
502
|
+
J.s = "tor-indicator-cell-style", J.custom = {
|
|
503
|
+
...N,
|
|
502
504
|
startTime: U,
|
|
503
505
|
endTime: V
|
|
504
506
|
};
|
|
@@ -506,58 +508,58 @@ async function yt(t, r) {
|
|
|
506
508
|
break;
|
|
507
509
|
}
|
|
508
510
|
case "hour": {
|
|
509
|
-
if (!
|
|
510
|
-
const m =
|
|
511
|
-
b.custom = {
|
|
512
|
-
...
|
|
511
|
+
if (!i) {
|
|
512
|
+
const m = g ? e[0] : e[0] ?? h, [D, M] = S(m, "hour", 1, 1), b = T(y, f, l);
|
|
513
|
+
b.s = "tor-indicator-cell-style", b.custom = {
|
|
514
|
+
...N,
|
|
513
515
|
startTime: D,
|
|
514
|
-
endTime:
|
|
516
|
+
endTime: M
|
|
515
517
|
};
|
|
516
518
|
break;
|
|
517
519
|
}
|
|
518
|
-
|
|
520
|
+
k = I(
|
|
519
521
|
e[0],
|
|
520
522
|
e[1],
|
|
521
523
|
"hour"
|
|
522
524
|
/* hour */
|
|
523
525
|
);
|
|
524
|
-
for (let m = 0; m <= Math.abs(
|
|
525
|
-
const D = m * (
|
|
526
|
-
if (
|
|
527
|
-
const V =
|
|
526
|
+
for (let m = 0; m <= Math.abs(k === 0 ? 1 : k); m++) {
|
|
527
|
+
const D = m * (x + 1), M = i === "right" ? f : H(f).add(D).toNumber(), b = i === "right" ? H(l).add(D).toNumber() : l, v = T(y, M, b);
|
|
528
|
+
if (v.s = "tor-indicator-cell-style", g) {
|
|
529
|
+
const V = d(e[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [J, Q] = S(V, "hour", m, w);
|
|
528
530
|
v.custom = {
|
|
529
|
-
...
|
|
530
|
-
startTime:
|
|
531
|
+
...N,
|
|
532
|
+
startTime: J,
|
|
531
533
|
endTime: Q
|
|
532
534
|
};
|
|
533
535
|
continue;
|
|
534
536
|
}
|
|
535
|
-
const
|
|
537
|
+
const R = d(h).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [j, U] = S(R, "hour", m, w);
|
|
536
538
|
v.custom = {
|
|
537
|
-
...
|
|
538
|
-
startTime:
|
|
539
|
+
...N,
|
|
540
|
+
startTime: j,
|
|
539
541
|
endTime: U
|
|
540
542
|
};
|
|
541
543
|
}
|
|
542
544
|
break;
|
|
543
545
|
}
|
|
544
546
|
case "shift": {
|
|
545
|
-
if (!
|
|
546
|
-
const [m, D] = e,
|
|
547
|
-
|
|
548
|
-
...
|
|
547
|
+
if (!i) {
|
|
548
|
+
const [m, D] = e, M = T(y, f, l);
|
|
549
|
+
M.s = "tor-indicator-cell-style", M.custom = {
|
|
550
|
+
...N,
|
|
549
551
|
startTime: m,
|
|
550
552
|
endTime: D
|
|
551
553
|
};
|
|
552
554
|
break;
|
|
553
555
|
}
|
|
554
|
-
if (!
|
|
556
|
+
if (!c.length)
|
|
555
557
|
throw new Error("没有获取到当班数据");
|
|
556
|
-
for (let m = 0; m <
|
|
557
|
-
const D =
|
|
558
|
-
U.custom = {
|
|
559
|
-
...
|
|
560
|
-
startTime:
|
|
558
|
+
for (let m = 0; m < c.length; m++) {
|
|
559
|
+
const D = c[m], { startDatetime: M, endDatetime: b } = D, v = m * (x + 1), R = i === "right" ? f : H(f).add(v).toNumber(), j = i === "right" ? H(l).add(v).toNumber() : l, U = T(y, R, j);
|
|
560
|
+
U.s = "tor-indicator-cell-style", U.custom = {
|
|
561
|
+
...N,
|
|
562
|
+
startTime: M,
|
|
561
563
|
endTime: b
|
|
562
564
|
};
|
|
563
565
|
}
|
|
@@ -565,30 +567,51 @@ async function yt(t, r) {
|
|
|
565
567
|
}
|
|
566
568
|
}
|
|
567
569
|
}
|
|
568
|
-
return
|
|
570
|
+
return y;
|
|
569
571
|
}, {});
|
|
570
|
-
return Promise.resolve(
|
|
572
|
+
return Promise.resolve(a);
|
|
571
573
|
}
|
|
572
|
-
function
|
|
573
|
-
return Object.entries(t).reduce((o, [e,
|
|
574
|
-
const n = Math.max(...Object.keys(
|
|
574
|
+
function gt(t) {
|
|
575
|
+
return Object.entries(t).reduce((o, [e, c]) => {
|
|
576
|
+
const n = Math.max(...Object.keys(c).map(Number));
|
|
575
577
|
return n > o ? o = Number(n) : o = Number(o) || 0, o;
|
|
576
578
|
}, 0);
|
|
577
579
|
}
|
|
578
|
-
function
|
|
580
|
+
function bt(t, r) {
|
|
579
581
|
const o = JSON.parse(JSON.stringify(t || {}));
|
|
580
|
-
for (const [e,
|
|
582
|
+
for (const [e, c] of Object.entries(r)) {
|
|
581
583
|
o[e] || (o[e] = {});
|
|
582
|
-
for (const [n, h] of Object.entries(
|
|
583
|
-
const
|
|
584
|
-
|
|
585
|
-
...
|
|
586
|
-
...
|
|
584
|
+
for (const [n, h] of Object.entries(c)) {
|
|
585
|
+
const p = h, a = o[e]?.[n];
|
|
586
|
+
a ? o[e][n] = {
|
|
587
|
+
...a,
|
|
588
|
+
...p,
|
|
587
589
|
custom: {
|
|
588
|
-
...
|
|
589
|
-
...
|
|
590
|
+
...a.custom,
|
|
591
|
+
...p.custom
|
|
590
592
|
}
|
|
591
|
-
} : o[e][n] =
|
|
593
|
+
} : o[e][n] = p;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
return o;
|
|
597
|
+
}
|
|
598
|
+
function wt(t, r) {
|
|
599
|
+
if (!r?.length || !t) return t;
|
|
600
|
+
const o = {};
|
|
601
|
+
for (const e in t) {
|
|
602
|
+
const c = t[e];
|
|
603
|
+
for (const n in c) {
|
|
604
|
+
const h = c[n];
|
|
605
|
+
if (h?.custom?.cellType === "indicator") {
|
|
606
|
+
const p = Number(e), a = Number(n);
|
|
607
|
+
if (r.some(
|
|
608
|
+
(Y) => p >= Y.startRow && p <= Y.endRow && a >= Y.startColumn && a <= Y.endColumn
|
|
609
|
+
) && !r.some(
|
|
610
|
+
(f) => p === f.startRow && a === f.startColumn
|
|
611
|
+
))
|
|
612
|
+
continue;
|
|
613
|
+
}
|
|
614
|
+
o[e] || (o[e] = {}), o[e][n] = h;
|
|
592
615
|
}
|
|
593
616
|
}
|
|
594
617
|
return o;
|
|
@@ -597,14 +620,15 @@ const Mt = "./style.css";
|
|
|
597
620
|
export {
|
|
598
621
|
it as CycleTypeEnum,
|
|
599
622
|
ct as ModeEnum,
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
623
|
+
H as decimal,
|
|
624
|
+
Yt as filterIndicatorsCell,
|
|
625
|
+
wt as filterMergedIndicatorCells,
|
|
626
|
+
Dt as generateIndicatorsCells,
|
|
603
627
|
W as generateUUID,
|
|
604
|
-
|
|
628
|
+
gt as getNumColumns,
|
|
605
629
|
dt as handleClearInput,
|
|
606
|
-
|
|
607
|
-
|
|
630
|
+
yt as initDateRange,
|
|
631
|
+
bt as mergeCellData,
|
|
608
632
|
Mt as stylePath,
|
|
609
633
|
ht as useData
|
|
610
634
|
};
|
|
@@ -1 +1 @@
|
|
|
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"})}));
|
|
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 o of r)e[o]=null},Q=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const o=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,o)}}let e=new Date().getTime(),r=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,o=>{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)),(o==="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 oe=Object.prototype.toString,W=(e,r)=>oe.call(e)===`[object ${r}]`,ne=e=>typeof e<"u",se=e=>!ne(e),ae=e=>e!==null&&W(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=>W(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 o=new Z(r);if(o.isZero())throw new Error("除数是0");return this.value=this.value.div(o),this}toFixed(r,o){return this.value=new Z(this.value.toFixed(r,o)),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 o=l(r);if(!o.isValid())return Promise.reject("无效的日期格式");const t=o.year(),c=`${t}-01`,n=`${t}-12`;return Promise.resolve([c,n]);case"month":if(K(r))return Promise.resolve(r);const h=l(r);if(!h.isValid())return Promise.reject("无效的日期格式");const C=h.startOf("month").format("YYYY-MM-DD"),a=h.endOf("month").format("YYYY-MM-DD");return Promise.resolve([C,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,o){return o?l(r).diff(l(e),o):0}function L(e,r,o){if(!o)throw new Error("日期类型不能为空");const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[o];return l(e).subtract(r,o).format(t)}function O(e,r,o,t){const c="YYYY-MM-DD HH:mm:ss",n=j(e,r,o,t),h=l(n);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 C={year:"year",day:"day",hour:"hour"};return[h.startOf(C[r]).format(c),h.endOf(C[r]).format(c)]}function j(e,r,o,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(o*t,r).format(c)}function w(e,r,o){return e[r]||(e[r]={}),e[r][o]||(e[r][o]={}),e[r][o]}async function me(e){if(!e)throw new Error("cellData is required");const r=Object.entries(e).reduce((o,t)=>{const[c,n]=t;for(const[h,C]of Object.entries(n)){const{custom:a,v:Y,t:y,s:m}=C;if(!a)continue;const{cellType:J}=a,u=!a.hasOwnProperty("writeBack")||q(a?.writeBack)?!0:a.writeBack;if(J==="indicator"){const H=w(o,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 o},{});return!r||q(r)?Promise.reject(new Error("No data found")):Promise.resolve(r)}function F(e,r){return e.replace(/\$\{([^}]+)\}/g,(o,t)=>{try{const c=Object.keys(r),n=Object.values(r);return new Function(...c,`return ${t};`)(...n)}catch(c){return console.error(`表达式执行失败: ${t}`,c),o}})}function de({acc:e,params:r,initRowNum:o,initColNum:t,cellData:c}){const{rangeData:n,currentDay:h,extraArgs:C}=r,a=C?.teamData||{},{cycleType:Y,timeIncrement:y,forwardPush:m,forwardPushTimes:J,copyType:u,copyInterval:H,defaultShift:S,templateStr:P,useDefaultEndDate:_}=c.custom;let T=0;switch(Y){case"day":{let s="";if(m&&(s=L(n[0],J,"day")),!u){let f="";m?f=s:f=n[0];const i=w(e,o,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,n[0],"day"):(T=V(n[0],n[1],"day"),console.log("copyNum",T));for(let f=0;f<=Math.abs(T===0?1:T);f++){const i=f*(H+1);let N="";m?N=j(s,"day",f,y):N=j(n[0],"day",f,y);const g=u==="right"?o:o+i,U=u==="right"?t+i:t,G=w(e,g,U);G.v=P?F(P,{businessDate:N,dayjs:l}):l(N).format("YYYY-MM-DD"),G.t=$.CellValueType.STRING,G.s="tor-time-cell-style"}break}case"month":{if(!u){const[s,f]=O(n[1],"month",0,1),i=w(e,o,t);i.v=l(f).format("YYYY-MM"),i.t=$.CellValueType.STRING,i.s="tor-time-cell-style";break}T=V(n[0],n[1],"month");for(let s=0;s<=Math.abs(T===0?1:T);s++){const f=s*(H+1),i=u==="right"?o:o+f,N=u==="right"?t+f:t,g=w(e,i,N);g.v=j(n[0],"month",s,y),g.t=$.CellValueType.STRING,g.s="tor-time-cell-style"}break}case"year":{let s="";if(m&&(s=L(n[0],J||0,"year")),!u){const f=m?s:n[0],[i,N]=O(f,"year",0,1),g=w(e,o,t),[,U]=O(n[1],"month",0,1);g.v=P?F(P,{startTime:i,endTime:N,rangeData:n,dayjs:l}):f,g.t=$.CellValueType.STRING,g.s="tor-time-cell-style";break}m?T=V(s,n[0],"year"):T=V(n[0],n[1],"year");for(let f=0;f<=Math.abs(T===0?1:T);f++){const i=f*(H+1),N=u==="right"?o:o+i,g=u==="right"?t+i:t,[U,G]=O(n[0],"year",f,y),v=w(e,N,g),k=j(n[0],"year",f,y);v.v=P?F(P,{startTime:U,endTime:G,rangeData:n,dayjs:l}):k,v.t=$.CellValueType.STRING,v.s="tor-time-cell-style"}break}case"hour":{if(!u){const s=w(e,o,t);if(s.t=$.CellValueType.STRING,s.s="tor-time-cell-style",S){s.v=l(n[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(n[0],n[1],"hour");for(let s=0;s<=Math.abs(T===0?1:T);s++){const f=s*(H+1),i=u==="right"?o:o+f,N=u==="right"?t+f:t,g=w(e,i,N);if(g.t=$.CellValueType.STRING,g.s="tor-time-cell-style",S){const U=l(n[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,o,t);s.t=$.CellValueType.STRING,s.s="tor-time-cell-style",s.v=P?F(P,{rangeData:n,dayjs:l}):n[0];break}if(!a.length)throw new Error("没有获取到当班数据");for(let s=0;s<a.length;s++){const f=a[s],{startDatetime:i,endDatetime:N}=f,g=s*(H+1),U=u==="right"?o:I(o).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:o,rangeData:t}=r;if(!t.length)return Promise.reject("处理时间范围失败, rangeData不能为空");const c=o?.teamData||[],{periodicityTime:n}=r,h=r?.currentDay||l().format("YYYY-MM-DD"),C=(Y,y)=>n?parseInt(n.split(":")[0],10)<12?[l(Y).format("YYYY-MM-DD")+" "+n,l(y).add(1,"day").format("YYYY-MM-DD")+" "+n]:[l(Y).subtract(1,"day").format("YYYY-MM-DD")+" "+n,l(y).format("YYYY-MM-DD")+" "+n]:[Y,y],a=Object.entries(e).reduce((Y,y)=>{const[m,J]=y;for(const[u,H]of Object.entries(J)){const{custom:S}=H;if(!S)continue;const{cellType:P,cycleType:_,timeIncrement:T,forwardPush:s,forwardPushTimes:f,copyType:i,copyInterval:N,defaultShift:g,useDefaultStartDate:U,useDefaultEndDate:G}=S;if(P==="time"){de({acc:Y,params:r,initRowNum:Number(m),initColNum:Number(u),cellData:H});continue}const v={cycleType:_,indicatorName:S.indicatorName,indicatorCode:S.indicatorCode,indicatorId:S.indicatorId,indicatorDimensionName:S.indicatorDimensionName,indicatorDimensionConfig:S.indicatorDimensionConfig,required:ce(S?.required)??!1,cellType:S.cellType,defaultShift:S?.defaultShift||!1,writeBack:q(S?.writeBack)?!0:S.writeBack};let k=0;switch(_){case"day":{let d="";if(s&&(d=L(t[0],f||0,"day")),!i){const D=s?d:t[0],[p,b]=C(...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*(N+1),b=s?d:t[0],[x,B]=C(...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*(N+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*(N+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),z=w(Y,B,R);z.s="tor-indicator-cell-style",z.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*(N+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"),[z,be]=O(A,"hour",d,T);x.custom={...v,startTime:z,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*(N+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((o,[t,c])=>{const n=Math.max(...Object.keys(c).map(Number));return n>o?o=Number(n):o=Number(o)||0,o},0)}function ye(e,r){const o=JSON.parse(JSON.stringify(e||{}));for(const[t,c]of Object.entries(r)){o[t]||(o[t]={});for(const[n,h]of Object.entries(c)){const C=h,a=o[t]?.[n];a?o[t][n]={...a,...C,custom:{...a.custom,...C.custom}}:o[t][n]=C}}return o}function De(e,r){if(!r?.length||!e)return e;const o={};for(const t in e){const c=e[t];for(const n in c){const h=c[n];if(h?.custom?.cellType==="indicator"){const C=Number(t),a=Number(n);if(r.some(y=>C>=y.startRow&&C<=y.endRow&&a>=y.startColumn&&a<=y.endColumn)&&!r.some(m=>C===m.startRow&&a===m.startColumn))continue}o[t]||(o[t]={}),o[t][n]=h}}return o}const ge="./style.css";M.CycleTypeEnum=X,M.ModeEnum=ee,M.decimal=I,M.filterIndicatorsCell=me,M.filterMergedIndicatorCells=De,M.generateIndicatorsCells=he,M.generateUUID=Q,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"})}));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -78,6 +78,8 @@ declare class DecimalChain {
|
|
|
78
78
|
*/
|
|
79
79
|
export declare function filterIndicatorsCell(cellData: IObjectMatrixPrimitiveType<ICellData>): Promise<{}>;
|
|
80
80
|
|
|
81
|
+
export declare function filterMergedIndicatorCells(cellData: any, mergeData: any[]): any;
|
|
82
|
+
|
|
81
83
|
export declare function generateIndicatorsCells(cells: IObjectMatrixPrimitiveType<ICellData>, params: IGenerateIndicatorsCellsParams): Promise<ICellData>;
|
|
82
84
|
|
|
83
85
|
export declare const generateUUID: () => string;
|