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