tor-univer-sheet 1.1.1 → 1.1.3

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