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