tor-univer-sheet 1.1.4 → 1.1.5

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