tor-univer-sheet 1.1.17 → 1.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import l from "dayjs";
1
+ import d from "dayjs";
2
2
  import { CellValueType as $ } from "@univerjs/presets";
3
- import K from "decimal.js";
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 f = Number(e);
14
- return (f ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> f / 4).toString(16);
13
+ const i = Number(e);
14
+ return (i ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> i / 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, L = (t, r) => X.call(t) === `[object ${r}]`, tt = (t) => typeof t < "u", et = (t) => !tt(t), rt = (t) => t !== null && L(t, "Object"), E = (t) => t == null || typeof t > "u" ? !0 : J(t) || st(t) ? t.length === 0 : t instanceof Map || t instanceof Set ? t.size === 0 : rt(t) ? Object.keys(t).length === 0 : !1, ot = (t) => t === null, nt = (t) => et(t) || ot(t), st = (t) => L(t, "String"), J = (t) => t && Array.isArray(t);
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"), E = (t) => t == null || typeof t > "u" ? !0 : J(t) || st(t) ? t.length === 0 : t instanceof Map || t instanceof Set ? t.size === 0 : rt(t) ? Object.keys(t).length === 0 : !1, ot = (t) => t === null, nt = (t) => et(t) || ot(t), st = (t) => _(t, "String"), J = (t) => t && Array.isArray(t);
34
34
  class at {
35
35
  value;
36
36
  constructor(r) {
37
- this.value = new K(r);
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 K(r);
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 K(this.value.toFixed(r, o)), this;
82
+ return this.value = new Z(this.value.toFixed(r, o)), this;
83
83
  }
84
84
  /**
85
85
  * 返回当前值
@@ -103,7 +103,7 @@ class at {
103
103
  return this.value.toNumber();
104
104
  }
105
105
  }
106
- function C(t = 0) {
106
+ function j(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 || {});
@@ -113,35 +113,35 @@ async function Yt(t, r) {
113
113
  case "year":
114
114
  if (J(r))
115
115
  return Promise.resolve(r);
116
- const o = l(r);
116
+ const o = d(r);
117
117
  if (!o.isValid())
118
118
  return Promise.reject("无效的日期格式");
119
- const e = o.year(), f = `${e}-01`, n = `${e}-12`;
120
- return Promise.resolve([f, n]);
119
+ const e = o.year(), i = `${e}-01`, n = `${e}-12`;
120
+ return Promise.resolve([i, n]);
121
121
  case "month":
122
122
  if (J(r))
123
123
  return Promise.resolve(r);
124
- const h = l(r);
124
+ const h = d(r);
125
125
  if (!h.isValid())
126
126
  return Promise.reject("无效的日期格式");
127
- const k = h.startOf("month").format("YYYY-MM-DD"), c = h.endOf("month").format("YYYY-MM-DD");
128
- return Promise.resolve([k, c]);
127
+ const M = h.startOf("month").format("YYYY-MM-DD"), a = h.endOf("month").format("YYYY-MM-DD");
128
+ return Promise.resolve([M, a]);
129
129
  case "day":
130
130
  if (J(r))
131
131
  return Promise.resolve(r);
132
- const Y = l(r);
132
+ const Y = d(r);
133
133
  if (!Y.isValid())
134
134
  return Promise.reject("无效的日期格式");
135
- const p = Y.startOf("day").format("YYYY-MM-DD HH:mm:ss"), d = Y.endOf("day").format("YYYY-MM-DD HH:mm:ss");
136
- return Promise.resolve([p, d]);
135
+ const D = Y.startOf("day").format("YYYY-MM-DD HH:mm:ss"), m = Y.endOf("day").format("YYYY-MM-DD HH:mm:ss");
136
+ return Promise.resolve([D, m]);
137
137
  default:
138
138
  return Promise.reject("不支持的周期类型");
139
139
  }
140
140
  }
141
141
  function H(t, r, o) {
142
- return o ? l(r).diff(l(t), o) : 0;
142
+ return o ? d(r).diff(d(t), o) : 0;
143
143
  }
144
- function z(t, r, o) {
144
+ function K(t, r, o) {
145
145
  if (!o)
146
146
  throw new Error("日期类型不能为空");
147
147
  const e = {
@@ -150,50 +150,50 @@ function z(t, r, o) {
150
150
  day: "YYYY-MM-DD",
151
151
  hour: "HH:mm:ss"
152
152
  }[o];
153
- return l(t).subtract(r, o).format(e);
153
+ return d(t).subtract(r, o).format(e);
154
154
  }
155
155
  function S(t, r, o, e) {
156
- const f = "YYYY-MM-DD HH:mm:ss", n = A(t, r, o, e), h = l(n);
156
+ const i = "YYYY-MM-DD HH:mm:ss", n = A(t, r, o, e), h = d(n);
157
157
  if (r === "month") {
158
- const c = h.month();
159
- return c === 0 ? [h.startOf("month").format(f), h.date(25).endOf("day").format(f)] : c === 11 ? [h.subtract(1, "month").date(26).startOf("day").format(f), h.endOf("month").format(f)] : [h.subtract(1, "month").date(26).startOf("day").format(f), h.date(25).endOf("day").format(f)];
158
+ const a = h.month();
159
+ 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)];
160
160
  }
161
- const k = { year: "year", day: "day", hour: "hour" };
162
- return [h.startOf(k[r]).format(f), h.endOf(k[r]).format(f)];
161
+ const M = { year: "year", day: "day", hour: "hour" };
162
+ return [h.startOf(M[r]).format(i), h.endOf(M[r]).format(i)];
163
163
  }
164
164
  function A(t, r, o, e) {
165
- const f = {
165
+ const i = {
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 l(t, f).add(o * e, r).format(f);
171
+ return d(t, i).add(o * e, r).format(i);
172
172
  }
173
- function g(t, r, o) {
173
+ function w(t, r, o) {
174
174
  return t[r] || (t[r] = {}), t[r][o] || (t[r][o] = {}), t[r][o];
175
175
  }
176
176
  async function Dt(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 [f, n] = e;
181
- for (const [h, k] of Object.entries(n)) {
182
- const { custom: c, v: Y, t: p, s: d } = k;
183
- if (!c) continue;
184
- const { cellType: q } = c, i = !c.hasOwnProperty("writeBack") || E(c?.writeBack) ? !0 : c.writeBack;
180
+ const [i, n] = e;
181
+ for (const [h, M] of Object.entries(n)) {
182
+ const { custom: a, v: Y, t: D, s: m } = M;
183
+ if (!a) continue;
184
+ const { cellType: q } = a, u = !a.hasOwnProperty("writeBack") || E(a?.writeBack) ? !0 : a.writeBack;
185
185
  if (q === "indicator") {
186
- const j = g(o, f, h);
187
- j.custom = {
188
- ...c,
189
- required: E(c?.required) ? !1 : c?.required,
190
- defaultShift: E(c?.defaultShift) ? !1 : c?.defaultShift,
191
- forwardPush: E(c?.forwardPush) ? !1 : c?.forwardPush,
192
- forwardPushTimes: E(c?.useDefaultEndDate) ? 0 : c?.forwardPushTimes,
193
- useDefaultEndDate: E(c?.useDefaultEndDate) ? !1 : c?.useDefaultEndDate,
194
- copyType: E(c?.copyType) ? "" : c?.copyType,
195
- writeBack: i
196
- }, j.s = d, j.t = p, j.v = Y || "";
186
+ const P = w(o, i, h);
187
+ P.custom = {
188
+ ...a,
189
+ required: E(a?.required) ? !1 : a?.required,
190
+ defaultShift: E(a?.defaultShift) ? !1 : a?.defaultShift,
191
+ forwardPush: E(a?.forwardPush) ? !1 : a?.forwardPush,
192
+ forwardPushTimes: E(a?.useDefaultEndDate) ? 0 : a?.forwardPushTimes,
193
+ useDefaultEndDate: E(a?.useDefaultEndDate) ? !1 : a?.useDefaultEndDate,
194
+ copyType: E(a?.copyType) ? "" : a?.copyType,
195
+ writeBack: u
196
+ }, P.s = m, P.t = D, P.v = Y || "";
197
197
  }
198
198
  }
199
199
  return o;
@@ -203,10 +203,10 @@ async function Dt(t) {
203
203
  function F(t, r) {
204
204
  return t.replace(/\$\{([^}]+)\}/g, (o, e) => {
205
205
  try {
206
- const f = Object.keys(r), n = Object.values(r);
207
- return new Function(...f, `return ${e};`)(...n);
208
- } catch (f) {
209
- return console.error(`表达式执行失败: ${e}`, f), o;
206
+ const i = Object.keys(r), n = Object.values(r);
207
+ return new Function(...i, `return ${e};`)(...n);
208
+ } catch (i) {
209
+ return console.error(`表达式执行失败: ${e}`, i), o;
210
210
  }
211
211
  });
212
212
  }
@@ -215,145 +215,145 @@ function ut({
215
215
  params: r,
216
216
  initRowNum: o,
217
217
  initColNum: e,
218
- cellData: f
218
+ cellData: i
219
219
  }) {
220
- const { rangeData: n, currentDay: h, extraArgs: k } = r, c = k?.teamData || {}, { cycleType: Y, timeIncrement: p, forwardPush: d, forwardPushTimes: q, copyType: i, copyInterval: j, defaultShift: O, templateStr: P, useDefaultEndDate: Z } = f.custom;
221
- let y = 0;
220
+ const { rangeData: n, currentDay: h, extraArgs: M } = r, a = M?.teamData || {}, { cycleType: Y, timeIncrement: D, forwardPush: m, forwardPushTimes: q, copyType: u, copyInterval: P, defaultShift: O, templateStr: C, useDefaultEndDate: L } = i.custom;
221
+ let g = 0;
222
222
  switch (Y) {
223
223
  case "day": {
224
224
  let s = "";
225
- if (d && (s = z(
225
+ if (m && (s = K(
226
226
  n[0],
227
227
  q,
228
228
  "day"
229
229
  /* day */
230
- )), !i) {
231
- let u = "";
232
- d ? u = s : u = n[0];
233
- const a = g(t, o, e);
234
- a.v = P ? F(P, { businessDate: u, dayjs: l }) : l(u).format("YYYY-MM-DD"), a.t = $.STRING;
230
+ )), !u) {
231
+ let f = "";
232
+ m ? f = s : f = n[0];
233
+ const c = w(t, o, e);
234
+ c.v = C ? F(C, { businessDate: f, dayjs: d }) : d(f).format("YYYY-MM-DD"), c.t = $.STRING;
235
235
  break;
236
236
  }
237
- d ? y = H(
237
+ m ? g = H(
238
238
  s,
239
239
  n[0],
240
240
  "day"
241
241
  /* day */
242
- ) : (y = H(
242
+ ) : (g = H(
243
243
  n[0],
244
244
  n[1],
245
245
  "day"
246
246
  /* day */
247
- ), console.log("copyNum", y));
248
- for (let u = 0; u <= Math.abs(y === 0 ? 1 : y); u++) {
249
- const a = u * (j + 1);
250
- let M = "";
251
- d ? M = A(s, "day", u, p) : M = A(n[0], "day", u, p);
252
- const w = i === "right" ? o : o + a, R = i === "right" ? e + a : e, G = g(t, w, R);
253
- G.v = P ? F(P, { businessDate: M, dayjs: l }) : l(M).format("YYYY-MM-DD"), G.t = $.STRING;
247
+ ), console.log("copyNum", g));
248
+ for (let f = 0; f <= Math.abs(g === 0 ? 1 : g); f++) {
249
+ const c = f * (P + 1);
250
+ let T = "";
251
+ m ? T = A(s, "day", f, D) : T = A(n[0], "day", f, D);
252
+ const p = u === "right" ? o : o + c, B = u === "right" ? e + c : e, G = w(t, p, B);
253
+ G.v = C ? F(C, { businessDate: T, dayjs: d }) : d(T).format("YYYY-MM-DD"), G.t = $.STRING;
254
254
  }
255
255
  break;
256
256
  }
257
257
  case "month": {
258
- if (!i) {
259
- const [s, u] = S(n[1], "month", 0, 1), a = g(t, o, e);
260
- a.v = l(u).format("YYYY-MM"), a.t = $.STRING;
258
+ if (!u) {
259
+ const [s, f] = S(n[1], "month", 0, 1), c = w(t, o, e);
260
+ c.v = d(f).format("YYYY-MM"), c.t = $.STRING;
261
261
  break;
262
262
  }
263
- y = H(
263
+ g = 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(y === 0 ? 1 : y); s++) {
270
- const u = s * (j + 1), a = i === "right" ? o : o + u, M = i === "right" ? e + u : e, w = g(t, a, M);
271
- w.v = A(n[0], "month", s, p), w.t = $.STRING;
269
+ for (let s = 0; s <= Math.abs(g === 0 ? 1 : g); s++) {
270
+ const f = s * (P + 1), c = u === "right" ? o : o + f, T = u === "right" ? e + f : e, p = w(t, c, T);
271
+ p.v = A(n[0], "month", s, D), p.t = $.STRING;
272
272
  }
273
273
  break;
274
274
  }
275
275
  case "year": {
276
276
  let s = "";
277
- if (d && (s = z(
277
+ if (m && (s = K(
278
278
  n[0],
279
279
  q || 0,
280
280
  "year"
281
281
  /* year */
282
- )), !i) {
283
- const u = d ? s : n[0], [a, M] = S(u, "year", 0, 1), w = g(t, o, e), [, R] = S(n[1], "month", 0, 1);
284
- w.v = P ? F(P, {
285
- startTime: a,
286
- endTime: M,
282
+ )), !u) {
283
+ const f = m ? s : n[0], [c, T] = S(f, "year", 0, 1), p = w(t, o, e), [, B] = S(n[1], "month", 0, 1);
284
+ p.v = C ? F(C, {
285
+ startTime: c,
286
+ endTime: T,
287
287
  rangeData: n,
288
- dayjs: l
289
- }) : u, w.t = $.STRING;
288
+ dayjs: d
289
+ }) : f, p.t = $.STRING;
290
290
  break;
291
291
  }
292
- d ? y = H(
292
+ m ? g = H(
293
293
  s,
294
294
  n[0],
295
295
  "year"
296
296
  /* year */
297
- ) : y = H(
297
+ ) : g = H(
298
298
  n[0],
299
299
  n[1],
300
300
  "year"
301
301
  /* year */
302
302
  );
303
- for (let u = 0; u <= Math.abs(y === 0 ? 1 : y); u++) {
304
- const a = u * (j + 1), M = i === "right" ? o : o + a, w = i === "right" ? e + a : e, [R, G] = S(n[0], "year", u, p), x = g(t, M, w), N = A(n[0], "year", u, p);
305
- x.v = P ? F(P, {
306
- startTime: R,
303
+ for (let f = 0; f <= Math.abs(g === 0 ? 1 : g); f++) {
304
+ const c = f * (P + 1), T = u === "right" ? o : o + c, p = u === "right" ? e + c : e, [B, G] = S(n[0], "year", f, D), N = w(t, T, p), v = A(n[0], "year", f, D);
305
+ N.v = C ? F(C, {
306
+ startTime: B,
307
307
  endTime: G,
308
308
  rangeData: n,
309
- dayjs: l
310
- }) : N, x.t = $.STRING;
309
+ dayjs: d
310
+ }) : v, N.t = $.STRING;
311
311
  }
312
312
  break;
313
313
  }
314
314
  case "hour": {
315
- if (!i) {
316
- const s = g(t, o, e);
315
+ if (!u) {
316
+ const s = w(t, o, e);
317
317
  if (s.t = $.STRING, O) {
318
- s.v = l(n[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
318
+ s.v = d(n[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
319
319
  break;
320
320
  }
321
- s.v = l(h).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
321
+ s.v = d(h).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
322
322
  break;
323
323
  }
324
- y = H(
324
+ g = 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(y === 0 ? 1 : y); s++) {
331
- const u = s * (j + 1), a = i === "right" ? o : o + u, M = i === "right" ? e + u : e, w = g(t, a, M);
332
- if (w.t = $.STRING, O) {
333
- const R = l(n[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
334
- w.v = A(R, "hour", s, p);
330
+ for (let s = 0; s <= Math.abs(g === 0 ? 1 : g); s++) {
331
+ const f = s * (P + 1), c = u === "right" ? o : o + f, T = u === "right" ? e + f : e, p = w(t, c, T);
332
+ if (p.t = $.STRING, O) {
333
+ const B = d(n[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
334
+ p.v = A(B, "hour", s, D);
335
335
  continue;
336
336
  }
337
- w.v = A(l(h).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), "hour", s, p);
337
+ p.v = A(d(h).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), "hour", s, D);
338
338
  }
339
339
  break;
340
340
  }
341
341
  case "shift": {
342
- if (!i) {
343
- const s = g(t, o, e);
344
- s.t = $.STRING, s.v = P ? F(P, {
342
+ if (!u) {
343
+ const s = w(t, o, e);
344
+ s.t = $.STRING, s.v = C ? F(C, {
345
345
  rangeData: n,
346
- dayjs: l
346
+ dayjs: d
347
347
  }) : n[0];
348
348
  break;
349
349
  }
350
- if (!c.length)
350
+ if (!a.length)
351
351
  throw new Error("没有获取到当班数据");
352
- for (let s = 0; s < c.length; s++) {
353
- const u = c[s], { startDatetime: a, endDatetime: M } = u, w = s * (j + 1), R = i === "right" ? o : C(o).add(w).toNumber(), G = i === "right" ? C(e).add(w).toNumber() : e, x = g(t, R, G);
354
- x.v = P ? F(P, {
355
- team: u
356
- }) : a;
352
+ for (let s = 0; s < a.length; s++) {
353
+ const f = a[s], { startDatetime: c, endDatetime: T } = f, p = s * (P + 1), B = u === "right" ? o : j(o).add(p).toNumber(), G = u === "right" ? j(e).add(p).toNumber() : e, N = w(t, B, G);
354
+ N.v = C ? F(C, {
355
+ team: f
356
+ }) : c;
357
357
  }
358
358
  break;
359
359
  }
@@ -365,29 +365,29 @@ async function yt(t, r) {
365
365
  const { extraArgs: o, rangeData: e } = r;
366
366
  if (!e.length)
367
367
  return Promise.reject("处理时间范围失败, rangeData不能为空");
368
- const f = o?.teamData || [], { periodicityTime: n } = r, h = r?.currentDay || l().format("YYYY-MM-DD"), k = (Y, p) => n ? parseInt(n.split(":")[0], 10) < 12 ? [l(Y).format("YYYY-MM-DD") + " " + n, l(p).add(1, "day").format("YYYY-MM-DD") + " " + n] : [l(Y).subtract(1, "day").format("YYYY-MM-DD") + " " + n, l(p).format("YYYY-MM-DD") + " " + n] : [Y, p], c = Object.entries(t).reduce((Y, p) => {
369
- const [d, q] = p;
370
- for (const [i, j] of Object.entries(q)) {
371
- const { custom: O } = j;
368
+ const i = o?.teamData || [], { periodicityTime: n } = r, h = r?.currentDay || d().format("YYYY-MM-DD"), M = (Y, D) => n ? parseInt(n.split(":")[0], 10) < 12 ? [d(Y).format("YYYY-MM-DD") + " " + n, d(D).add(1, "day").format("YYYY-MM-DD") + " " + n] : [d(Y).subtract(1, "day").format("YYYY-MM-DD") + " " + n, d(D).format("YYYY-MM-DD") + " " + n] : [Y, D], a = Object.entries(t).reduce((Y, D) => {
369
+ const [m, q] = D;
370
+ for (const [u, P] of Object.entries(q)) {
371
+ const { custom: O } = P;
372
372
  if (!O) continue;
373
373
  const {
374
- cellType: P,
375
- cycleType: Z,
376
- timeIncrement: y,
374
+ cellType: C,
375
+ cycleType: L,
376
+ timeIncrement: g,
377
377
  forwardPush: s,
378
- forwardPushTimes: u,
379
- copyType: a,
380
- copyInterval: M,
381
- defaultShift: w,
382
- useDefaultStartDate: R,
378
+ forwardPushTimes: f,
379
+ copyType: c,
380
+ copyInterval: T,
381
+ defaultShift: p,
382
+ useDefaultStartDate: B,
383
383
  useDefaultEndDate: G
384
384
  } = O;
385
- if (P === "time") {
386
- ut({ acc: Y, params: r, initRowNum: Number(d), initColNum: Number(i), cellData: j });
385
+ if (C === "time") {
386
+ ut({ acc: Y, params: r, initRowNum: Number(m), initColNum: Number(u), cellData: P });
387
387
  continue;
388
388
  }
389
- const x = {
390
- cycleType: Z,
389
+ const N = {
390
+ cycleType: L,
391
391
  indicatorName: O.indicatorName,
392
392
  indicatorCode: O.indicatorCode,
393
393
  indicatorId: O.indicatorId,
@@ -398,107 +398,107 @@ async function yt(t, r) {
398
398
  defaultShift: O?.defaultShift || !1,
399
399
  writeBack: E(O?.writeBack) ? !0 : O.writeBack
400
400
  };
401
- let N = 0;
402
- switch (Z) {
401
+ let v = 0;
402
+ switch (L) {
403
403
  case "day": {
404
- let m = "";
405
- if (s && (m = z(
404
+ let l = "";
405
+ if (s && (l = K(
406
406
  e[0],
407
- u || 0,
407
+ f || 0,
408
408
  "day"
409
409
  /* day */
410
- )), !a) {
411
- const D = s ? m : e[0], [T, b] = k(...S(D, "day", 0, 1)), v = g(Y, d, i);
412
- v.custom = {
413
- ...x,
414
- startTime: T,
410
+ )), !c) {
411
+ const y = s ? l : e[0], [x, b] = M(...S(y, "day", 0, 1)), k = w(Y, m, u);
412
+ k.custom = {
413
+ ...N,
414
+ startTime: x,
415
415
  endTime: b
416
416
  };
417
417
  break;
418
418
  }
419
- s ? N = H(
420
- m,
419
+ s ? v = H(
420
+ l,
421
421
  e[0],
422
422
  "day"
423
423
  /* day */
424
- ) : N = H(
424
+ ) : v = H(
425
425
  e[0],
426
426
  e[1],
427
427
  "day"
428
428
  /* day */
429
429
  );
430
- for (let D = 0; D <= Math.abs(N === 0 ? 1 : N); D++) {
431
- const T = D * (M + 1), b = s ? m : e[0], [v, I] = k(...S(b, "day", D, y)), B = a === "right" ? d : C(d).add(T).toNumber(), U = a === "right" ? C(i).add(T).toNumber() : i, V = g(Y, B, U);
430
+ for (let y = 0; y <= Math.abs(v === 0 ? 1 : v); y++) {
431
+ const x = y * (T + 1), b = s ? l : e[0], [k, I] = M(...S(b, "day", y, g)), R = c === "right" ? m : j(m).add(x).toNumber(), U = c === "right" ? j(u).add(x).toNumber() : u, V = w(Y, R, U);
432
432
  V.custom = {
433
- ...x,
434
- startTime: v,
433
+ ...N,
434
+ startTime: k,
435
435
  endTime: I
436
436
  };
437
437
  }
438
438
  break;
439
439
  }
440
440
  case "month": {
441
- if (!a) {
442
- const [m, D] = S(e[1], "month", 0, 1), T = g(Y, d, i);
443
- T.custom = {
444
- ...x,
445
- startTime: m,
446
- endTime: D
441
+ if (!c) {
442
+ const [l, y] = S(e[1], "month", 0, 1), x = w(Y, m, u);
443
+ x.custom = {
444
+ ...N,
445
+ startTime: l,
446
+ endTime: y
447
447
  };
448
448
  break;
449
449
  }
450
- N = H(
450
+ v = H(
451
451
  e[0],
452
452
  e[1],
453
453
  "month"
454
454
  /* month */
455
455
  );
456
- for (let m = 0; m <= Math.abs(N === 0 ? 1 : N); m++) {
457
- const D = m * (M + 1), T = a === "right" ? d : C(d).add(D).toNumber(), b = a === "right" ? C(i).add(D).toNumber() : i, [v, I] = S(e[0], "month", m, y), B = g(Y, T, b);
458
- B.custom = {
459
- ...x,
460
- startTime: v,
456
+ for (let l = 0; l <= Math.abs(v === 0 ? 1 : v); l++) {
457
+ const y = l * (T + 1), x = c === "right" ? m : j(m).add(y).toNumber(), b = c === "right" ? j(u).add(y).toNumber() : u, [k, I] = S(e[0], "month", l, g), R = w(Y, x, b);
458
+ R.custom = {
459
+ ...N,
460
+ startTime: k,
461
461
  endTime: I
462
462
  };
463
463
  }
464
464
  break;
465
465
  }
466
466
  case "year": {
467
- let m = "", D = "", T = "";
467
+ let l = "", y = "", x = "";
468
468
  if (s) {
469
- m = z(
469
+ l = K(
470
470
  e[0],
471
- u || 0,
471
+ f || 0,
472
472
  "year"
473
473
  /* year */
474
474
  );
475
- const b = l(e[1]).format("MM");
476
- D = l(`${m}-${b + 1}`).format("YYYY-MM"), T = l(`${m}-${b + 2}`).format("YYYY-MM");
475
+ const b = d(e[1]).format("MM");
476
+ y = d(`${l}-${b + 1}`).format("YYYY-MM"), x = d(`${l}-${b + 2}`).format("YYYY-MM");
477
477
  }
478
- if (!a) {
479
- const b = s ? m : e[0], [v, I] = S(b, "year", 0, 1), B = g(Y, d, i), [, U] = S(D, "month", 0, 1), [V] = S(T, "month", 0, 1);
480
- B.custom = {
481
- ...x,
482
- startTime: R ? V : v,
478
+ if (!c) {
479
+ const b = s ? l : e[0], [k, I] = S(b, "year", 0, 1), R = w(Y, m, u), [, U] = S(y, "month", 0, 1), [V] = S(x, "month", 0, 1);
480
+ R.custom = {
481
+ ...N,
482
+ startTime: B ? V : k,
483
483
  endTime: G ? U : I
484
484
  };
485
485
  break;
486
486
  }
487
- s ? N = H(
488
- m,
487
+ s ? v = H(
488
+ l,
489
489
  e[0],
490
490
  "year"
491
491
  /* year */
492
- ) : N = H(
492
+ ) : v = H(
493
493
  e[0],
494
494
  e[1],
495
495
  "year"
496
496
  /* year */
497
497
  );
498
- for (let b = 0; b <= Math.abs(N === 0 ? 1 : N); b++) {
499
- const v = b * (M + 1), I = a === "right" ? d : C(d).add(v).toNumber(), B = a === "right" ? C(i).add(v).toNumber() : i, [U, V] = S(e[0], "year", b, y), _ = g(Y, I, B);
500
- _.custom = {
501
- ...x,
498
+ for (let b = 0; b <= Math.abs(v === 0 ? 1 : v); b++) {
499
+ const k = b * (T + 1), I = c === "right" ? m : j(m).add(k).toNumber(), R = c === "right" ? j(u).add(k).toNumber() : u, [U, V] = S(e[0], "year", b, g), z = w(Y, I, R);
500
+ z.custom = {
501
+ ...N,
502
502
  startTime: U,
503
503
  endTime: V
504
504
  };
@@ -506,58 +506,58 @@ async function yt(t, r) {
506
506
  break;
507
507
  }
508
508
  case "hour": {
509
- if (!a) {
510
- const m = w ? e[0] : e[0] ?? h, [D, T] = S(m, "hour", 1, 1), b = g(Y, d, i);
509
+ if (!c) {
510
+ const l = p ? e[0] : e[0] ?? h, [y, x] = S(l, "hour", 1, 1), b = w(Y, m, u);
511
511
  b.custom = {
512
- ...x,
513
- startTime: D,
514
- endTime: T
512
+ ...N,
513
+ startTime: y,
514
+ endTime: x
515
515
  };
516
516
  break;
517
517
  }
518
- N = H(
518
+ v = H(
519
519
  e[0],
520
520
  e[1],
521
521
  "hour"
522
522
  /* hour */
523
523
  );
524
- for (let m = 0; m <= Math.abs(N === 0 ? 1 : N); m++) {
525
- const D = m * (M + 1), T = a === "right" ? d : C(d).add(D).toNumber(), b = a === "right" ? C(i).add(D).toNumber() : i, v = g(Y, T, b);
526
- if (w) {
527
- const V = l(e[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [_, Q] = S(V, "hour", m, y);
528
- v.custom = {
529
- ...x,
530
- startTime: _,
524
+ for (let l = 0; l <= Math.abs(v === 0 ? 1 : v); l++) {
525
+ const y = l * (T + 1), x = c === "right" ? m : j(m).add(y).toNumber(), b = c === "right" ? j(u).add(y).toNumber() : u, k = w(Y, x, b);
526
+ if (p) {
527
+ const V = d(e[0]).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [z, Q] = S(V, "hour", l, g);
528
+ k.custom = {
529
+ ...N,
530
+ startTime: z,
531
531
  endTime: Q
532
532
  };
533
533
  continue;
534
534
  }
535
- const I = l(h).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [B, U] = S(I, "hour", m, y);
536
- v.custom = {
537
- ...x,
538
- startTime: B,
535
+ const I = d(h).add(1, "hour").format("YYYY-MM-DD HH:mm:ss"), [R, U] = S(I, "hour", l, g);
536
+ k.custom = {
537
+ ...N,
538
+ startTime: R,
539
539
  endTime: U
540
540
  };
541
541
  }
542
542
  break;
543
543
  }
544
544
  case "shift": {
545
- if (!a) {
546
- const [m, D] = e, T = g(Y, d, i);
547
- T.custom = {
548
- ...x,
549
- startTime: m,
550
- endTime: D
545
+ if (!c) {
546
+ const [l, y] = e, x = w(Y, m, u);
547
+ x.custom = {
548
+ ...N,
549
+ startTime: l,
550
+ endTime: y
551
551
  };
552
552
  break;
553
553
  }
554
- if (!f.length)
554
+ if (!i.length)
555
555
  throw new Error("没有获取到当班数据");
556
- for (let m = 0; m < f.length; m++) {
557
- const D = f[m], { startDatetime: T, endDatetime: b } = D, v = m * (M + 1), I = a === "right" ? d : C(d).add(v).toNumber(), B = a === "right" ? C(i).add(v).toNumber() : i, U = g(Y, I, B);
556
+ for (let l = 0; l < i.length; l++) {
557
+ const y = i[l], { startDatetime: x, endDatetime: b } = y, k = l * (T + 1), I = c === "right" ? m : j(m).add(k).toNumber(), R = c === "right" ? j(u).add(k).toNumber() : u, U = w(Y, I, R);
558
558
  U.custom = {
559
- ...x,
560
- startTime: T,
559
+ ...N,
560
+ startTime: x,
561
561
  endTime: b
562
562
  };
563
563
  }
@@ -567,28 +567,49 @@ async function yt(t, r) {
567
567
  }
568
568
  return Y;
569
569
  }, {});
570
- return Promise.resolve(c);
570
+ return Promise.resolve(a);
571
571
  }
572
- function bt(t) {
573
- return Object.entries(t).reduce((o, [e, f]) => {
574
- const n = Math.max(...Object.keys(f).map(Number));
572
+ function gt(t) {
573
+ return Object.entries(t).reduce((o, [e, i]) => {
574
+ const n = Math.max(...Object.keys(i).map(Number));
575
575
  return n > o ? o = Number(n) : o = Number(o) || 0, o;
576
576
  }, 0);
577
577
  }
578
- function gt(t, r) {
578
+ function bt(t, r) {
579
579
  const o = JSON.parse(JSON.stringify(t || {}));
580
- for (const [e, f] of Object.entries(r)) {
580
+ for (const [e, i] of Object.entries(r)) {
581
581
  o[e] || (o[e] = {});
582
- for (const [n, h] of Object.entries(f)) {
583
- const k = h, c = o[e]?.[n];
584
- c ? o[e][n] = {
585
- ...c,
586
- ...k,
582
+ for (const [n, h] of Object.entries(i)) {
583
+ const M = h, a = o[e]?.[n];
584
+ a ? o[e][n] = {
585
+ ...a,
586
+ ...M,
587
587
  custom: {
588
- ...c.custom,
589
- ...k.custom
588
+ ...a.custom,
589
+ ...M.custom
590
590
  }
591
- } : o[e][n] = k;
591
+ } : o[e][n] = M;
592
+ }
593
+ }
594
+ return o;
595
+ }
596
+ function wt(t, r) {
597
+ if (!r?.length || !t) return t;
598
+ const o = {};
599
+ for (const e in t) {
600
+ const i = t[e];
601
+ for (const n in i) {
602
+ const h = i[n];
603
+ if (h?.custom?.cellType === "indicator") {
604
+ const M = Number(e), a = Number(n);
605
+ if (r.some(
606
+ (D) => M >= D.startRow && M <= D.endRow && a >= D.startColumn && a <= D.endColumn
607
+ ) && !r.some(
608
+ (m) => M === m.startRow && a === m.startColumn
609
+ ))
610
+ continue;
611
+ }
612
+ o[e] || (o[e] = {}), o[e][n] = h;
592
613
  }
593
614
  }
594
615
  return o;
@@ -597,14 +618,15 @@ const Mt = "./style.css";
597
618
  export {
598
619
  it as CycleTypeEnum,
599
620
  ct as ModeEnum,
600
- C as decimal,
621
+ j as decimal,
601
622
  Dt as filterIndicatorsCell,
623
+ wt as filterMergedIndicatorCells,
602
624
  yt as generateIndicatorsCells,
603
625
  W as generateUUID,
604
- bt as getNumColumns,
626
+ gt as getNumColumns,
605
627
  dt as handleClearInput,
606
628
  Yt as initDateRange,
607
- gt as mergeCellData,
629
+ bt as mergeCellData,
608
630
  Mt as stylePath,
609
631
  ht as useData
610
632
  };
@@ -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(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"})}));
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tor-univer-sheet",
3
- "version": "1.1.17",
3
+ "version": "1.1.18",
4
4
  "style": "./dist/style.css",
5
5
  "description": "基于 Univer 的 Vue3 电子表格组件",
6
6
  "author": "tortormore",