tor-univer-sheet 1.1.3 → 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.
- package/dist/tor-univer-sheet.es.js +327 -327
- package/dist/tor-univer-sheet.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CellValueType as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
for (const
|
|
6
|
-
|
|
7
|
-
},
|
|
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
|
|
13
|
-
const
|
|
14
|
-
return (
|
|
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,
|
|
16
|
+
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, o);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
let
|
|
20
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (
|
|
21
|
-
let
|
|
22
|
-
return
|
|
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
|
|
25
|
+
function ct(t) {
|
|
26
26
|
return {
|
|
27
|
-
...
|
|
28
|
-
id:
|
|
29
|
-
name:
|
|
30
|
-
appVersion:
|
|
27
|
+
...t?.workbookData,
|
|
28
|
+
id: t?.id || _(),
|
|
29
|
+
name: t?.name || "未命名",
|
|
30
|
+
appVersion: t?.appVersion || "1.0.0"
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
const
|
|
34
|
-
class
|
|
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(
|
|
37
|
-
this.value = new
|
|
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(
|
|
45
|
-
return this.value = this.value.add(
|
|
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(
|
|
53
|
-
return this.value = this.value.sub(
|
|
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(
|
|
61
|
-
return this.value = this.value.mul(
|
|
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(
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
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(
|
|
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(
|
|
82
|
-
return this.value = new
|
|
81
|
+
toFixed(r, o) {
|
|
82
|
+
return this.value = new $(this.value.toFixed(r, o)), this;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* 返回当前值
|
|
@@ -103,443 +103,443 @@ class L {
|
|
|
103
103
|
return this.value.toNumber();
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
return new
|
|
106
|
+
function I(t = 0) {
|
|
107
|
+
return new rt(t);
|
|
108
108
|
}
|
|
109
|
-
var
|
|
110
|
-
async function
|
|
111
|
-
if (!
|
|
112
|
-
switch (
|
|
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 (
|
|
115
|
-
return Promise.resolve(
|
|
116
|
-
const
|
|
117
|
-
if (!
|
|
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
|
|
120
|
-
return Promise.resolve([
|
|
119
|
+
const e = o.year(), c = `${e}-01`, s = `${e}-12`;
|
|
120
|
+
return Promise.resolve([c, s]);
|
|
121
121
|
case "month":
|
|
122
|
-
if (
|
|
123
|
-
return Promise.resolve(
|
|
124
|
-
const
|
|
125
|
-
if (!
|
|
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
|
|
128
|
-
return Promise.resolve([
|
|
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 (
|
|
131
|
-
return Promise.resolve(
|
|
132
|
-
const
|
|
133
|
-
if (!
|
|
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
|
|
136
|
-
return Promise.resolve([
|
|
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
|
|
142
|
-
if (!
|
|
143
|
-
const
|
|
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
|
-
}[
|
|
149
|
-
return ["day", "hour"].includes(
|
|
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
|
|
152
|
-
|
|
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
|
|
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
|
|
170
|
-
const
|
|
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
|
-
}[
|
|
176
|
-
return
|
|
180
|
+
}[r];
|
|
181
|
+
return Y(t, c).add(o * e, r).format(c);
|
|
177
182
|
}
|
|
178
|
-
function
|
|
179
|
-
return
|
|
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
|
|
182
|
-
if (!
|
|
186
|
+
async function lt(t) {
|
|
187
|
+
if (!t)
|
|
183
188
|
throw new Error("cellData is required");
|
|
184
|
-
const
|
|
185
|
-
const [
|
|
186
|
-
for (const [
|
|
187
|
-
const { custom:
|
|
188
|
-
if (!
|
|
189
|
-
const { cellType:
|
|
190
|
-
if (
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
...
|
|
194
|
-
required:
|
|
195
|
-
defaultShift:
|
|
196
|
-
forwardPush:
|
|
197
|
-
|
|
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
|
|
207
|
+
return o;
|
|
201
208
|
}, {});
|
|
202
|
-
return !
|
|
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
|
|
205
|
-
acc:
|
|
206
|
-
params:
|
|
207
|
-
initRowNum:
|
|
208
|
-
initColNum:
|
|
209
|
-
cellData:
|
|
214
|
+
function st({
|
|
215
|
+
acc: t,
|
|
216
|
+
params: r,
|
|
217
|
+
initRowNum: o,
|
|
218
|
+
initColNum: e,
|
|
219
|
+
cellData: c
|
|
210
220
|
}) {
|
|
211
|
-
const { rangeData:
|
|
212
|
-
|
|
213
|
-
const { cycleType:
|
|
214
|
-
let
|
|
215
|
-
switch (
|
|
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 (
|
|
219
|
-
|
|
220
|
-
|
|
228
|
+
if (l && (n = F(
|
|
229
|
+
s[0],
|
|
230
|
+
H,
|
|
221
231
|
"day"
|
|
222
232
|
/* day */
|
|
223
|
-
)), !
|
|
224
|
-
let
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
|
|
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
|
-
|
|
240
|
+
l ? b = S(
|
|
231
241
|
n,
|
|
232
|
-
|
|
242
|
+
s[0],
|
|
233
243
|
"day"
|
|
234
244
|
/* day */
|
|
235
|
-
) :
|
|
236
|
-
|
|
237
|
-
|
|
245
|
+
) : b = S(
|
|
246
|
+
s[0],
|
|
247
|
+
s[1],
|
|
238
248
|
"day"
|
|
239
249
|
/* day */
|
|
240
250
|
);
|
|
241
|
-
for (let
|
|
242
|
-
const
|
|
243
|
-
let
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
|
|
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 (!
|
|
252
|
-
const n =
|
|
253
|
-
n.v =
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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(
|
|
263
|
-
const
|
|
264
|
-
|
|
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
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
|
281
|
-
const
|
|
282
|
-
|
|
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 (!
|
|
288
|
-
const n =
|
|
289
|
-
if (n.t =
|
|
290
|
-
n.v =
|
|
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 =
|
|
314
|
+
n.v = Y(i).add(1, "hour").format("YYYY-MM-DD HH:mm:ss");
|
|
294
315
|
break;
|
|
295
316
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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(
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
const
|
|
306
|
-
|
|
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
|
-
|
|
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
|
|
315
|
-
if (!
|
|
335
|
+
async function dt(t, r) {
|
|
336
|
+
if (!t)
|
|
316
337
|
return Promise.reject("没有可用的单元格数据");
|
|
317
|
-
const { extraArgs:
|
|
318
|
-
if (!
|
|
338
|
+
const { extraArgs: o, rangeData: e } = r;
|
|
339
|
+
if (!e.length)
|
|
319
340
|
return Promise.reject("处理时间范围失败, rangeData不能为空");
|
|
320
|
-
|
|
321
|
-
const
|
|
322
|
-
const [
|
|
323
|
-
for (const [
|
|
324
|
-
const { custom:
|
|
325
|
-
if (!
|
|
326
|
-
const { cellType:
|
|
327
|
-
if (
|
|
328
|
-
|
|
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
|
|
332
|
-
cycleType:
|
|
333
|
-
indicatorName:
|
|
334
|
-
indicatorCode:
|
|
335
|
-
indicatorId:
|
|
336
|
-
indicatorDimensionName:
|
|
337
|
-
indicatorDimensionConfig:
|
|
338
|
-
required:
|
|
339
|
-
cellType:
|
|
340
|
-
defaultShift:
|
|
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
|
|
343
|
-
switch (
|
|
363
|
+
let D = 0;
|
|
364
|
+
switch (V) {
|
|
344
365
|
case "day": {
|
|
345
|
-
let
|
|
346
|
-
if (
|
|
347
|
-
|
|
348
|
-
|
|
366
|
+
let f = "";
|
|
367
|
+
if (C && (f = F(
|
|
368
|
+
e[0],
|
|
369
|
+
b || 0,
|
|
349
370
|
"day"
|
|
350
371
|
/* day */
|
|
351
|
-
)), !
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
-
|
|
364
|
-
|
|
365
|
-
|
|
381
|
+
C ? D = S(
|
|
382
|
+
f,
|
|
383
|
+
e[0],
|
|
366
384
|
"day"
|
|
367
385
|
/* day */
|
|
368
|
-
) :
|
|
369
|
-
|
|
370
|
-
|
|
386
|
+
) : D = S(
|
|
387
|
+
e[0],
|
|
388
|
+
e[1],
|
|
371
389
|
"day"
|
|
372
390
|
/* day */
|
|
373
391
|
);
|
|
374
|
-
for (let
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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 (!
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
...
|
|
393
|
-
|
|
394
|
-
|
|
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
|
-
|
|
400
|
-
|
|
401
|
-
|
|
412
|
+
D = S(
|
|
413
|
+
e[0],
|
|
414
|
+
e[1],
|
|
402
415
|
"month"
|
|
403
416
|
/* month */
|
|
404
417
|
);
|
|
405
|
-
for (let
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
...
|
|
409
|
-
|
|
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
|
|
410
424
|
};
|
|
411
425
|
}
|
|
412
426
|
break;
|
|
413
427
|
}
|
|
414
428
|
case "year": {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
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
|
|
422
441
|
};
|
|
423
442
|
break;
|
|
424
443
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
444
|
+
C ? D = S(
|
|
445
|
+
f,
|
|
446
|
+
e[0],
|
|
447
|
+
"year"
|
|
448
|
+
/* year */
|
|
449
|
+
) : D = S(
|
|
450
|
+
e[0],
|
|
451
|
+
e[1],
|
|
428
452
|
"year"
|
|
429
453
|
/* year */
|
|
430
454
|
);
|
|
431
|
-
for (let
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
...
|
|
435
|
-
|
|
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
|
|
436
461
|
};
|
|
437
462
|
}
|
|
438
463
|
break;
|
|
439
464
|
}
|
|
440
465
|
case "hour": {
|
|
441
|
-
if (!
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
businessDate: s,
|
|
448
|
-
startTime: I(s, "hour", 1, 1),
|
|
449
|
-
endTime: s
|
|
450
|
-
};
|
|
451
|
-
break;
|
|
452
|
-
}
|
|
453
|
-
s = N(t[0] ?? l, "hour", 1, 1), u.custom = {
|
|
454
|
-
...p,
|
|
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')
|
|
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
|
|
459
472
|
};
|
|
460
473
|
break;
|
|
461
474
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
475
|
+
D = S(
|
|
476
|
+
e[0],
|
|
477
|
+
e[1],
|
|
465
478
|
"hour"
|
|
466
479
|
/* hour */
|
|
467
480
|
);
|
|
468
|
-
for (let
|
|
469
|
-
|
|
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);
|
|
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);
|
|
471
483
|
if (g) {
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
...
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
endTime: u
|
|
478
|
-
// 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
|
|
479
489
|
};
|
|
480
490
|
continue;
|
|
481
491
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
), U.custom = {
|
|
488
|
-
...p,
|
|
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
|
-
// )
|
|
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
|
|
497
497
|
};
|
|
498
498
|
}
|
|
499
499
|
break;
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
|
-
return
|
|
503
|
+
return i;
|
|
504
504
|
}, {});
|
|
505
|
-
return Promise.resolve(
|
|
505
|
+
return Promise.resolve(s);
|
|
506
506
|
}
|
|
507
|
-
function
|
|
508
|
-
return Object.entries(
|
|
509
|
-
const
|
|
510
|
-
return
|
|
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;
|
|
511
511
|
}, 0);
|
|
512
512
|
}
|
|
513
|
-
function
|
|
514
|
-
const
|
|
515
|
-
for (const [
|
|
516
|
-
|
|
517
|
-
for (const [
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
...
|
|
521
|
-
...
|
|
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,
|
|
522
522
|
custom: {
|
|
523
|
-
...
|
|
524
|
-
...
|
|
523
|
+
...a.custom,
|
|
524
|
+
...x.custom || {}
|
|
525
525
|
}
|
|
526
|
-
} :
|
|
526
|
+
} : o[e][s] = x;
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
|
-
return
|
|
529
|
+
return o;
|
|
530
530
|
}
|
|
531
|
-
const
|
|
531
|
+
const Dt = "./style.css";
|
|
532
532
|
export {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
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
|
|
545
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 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"})}));
|
|
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"})}));
|