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