tor-univer-sheet 1.0.18 → 1.1.0
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.
|
@@ -180,7 +180,7 @@ async function et(t) {
|
|
|
180
180
|
const { cellType: Y } = y;
|
|
181
181
|
if (Y === "indicator") {
|
|
182
182
|
const d = b(e, i, v);
|
|
183
|
-
d.custom = y, d.
|
|
183
|
+
d.custom = y, d.s = m, d.t = N, d.v = f;
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
return e;
|
|
@@ -318,9 +318,9 @@ async function rt(t, o) {
|
|
|
318
318
|
indicatorId: d.indicatorId,
|
|
319
319
|
indicatorDimensionName: d.indicatorDimensionName,
|
|
320
320
|
indicatorDimensionConfig: d.indicatorDimensionConfig,
|
|
321
|
-
required: d
|
|
321
|
+
required: d?.required || !1,
|
|
322
322
|
cellType: d.cellType,
|
|
323
|
-
defaultShift: d
|
|
323
|
+
defaultShift: d?.defaultShift || !1
|
|
324
324
|
};
|
|
325
325
|
let x = 0;
|
|
326
326
|
switch (g) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(d,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("dayjs"),require("@univerjs/presets"),require("decimal.js")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/presets","decimal.js"],l):(d=typeof globalThis<"u"?globalThis:d||self,l(d.TorUniverSheet={},d.dayjs,d.presets,d.Decimal))})(this,(function(d,l,P,U){"use strict";const z=(e,n)=>{for(const t of n)e[t]=null},G=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const t=r=>{const i=Number(r);return(i^crypto.getRandomValues(new Uint8Array(1))[0]&15>>i/4).toString(16)};return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t)}}let e=new Date().getTime(),n=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16;return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(n+r)%16|0,n=Math.floor(n/16)),(t==="x"?r:r&3|8).toString(16)})};function Z(e){return{...e?.workbookData,id:e?.id||G(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const _=Object.prototype.toString,A=(e,n)=>_.call(e)===`[object ${n}]`,B=e=>e!==null&&A(e,"Object"),E=e=>e==null||typeof e>"u"?!0:V(e)||K(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:B(e)?Object.keys(e).length===0:!1,K=e=>A(e,"String"),V=e=>e&&Array.isArray(e);class L{value;constructor(n){this.value=new U(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 t=new U(n);if(t.isZero())throw new Error("除数是0");return this.value=this.value.div(t),this}toFixed(n,t){return this.value=new U(this.value.toFixed(n,t)),this}valueOf(){return this.value}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}}function O(e=0){return new L(e)}var q=(e=>(e.无="no",e.年="year",e.月="month",e.周="week",e.天="day",e.班组="shift",e.小时="hour",e.半小时="half_hour",e))(q||{}),F=(e=>(e.view="view",e.edit="edit",e))(F||{});async function Q(e,n){if(!n)return Promise.reject("日期不能为空");switch(e){case"year":if(V(n))return Promise.resolve(n);const t=l(n);if(!t.isValid())return Promise.reject("无效的日期格式");const r=t.year(),i=`${r}-01`,s=`${r}-12`;return Promise.resolve([i,s]);case"month":if(V(n))return Promise.resolve(n);const p=l(n);if(!p.isValid())return Promise.reject("无效的日期格式");const h=p.startOf("month").format("YYYY-MM-DD"),y=p.endOf("month").format("YYYY-MM-DD");return Promise.resolve([h,y]);case"day":if(V(n))return Promise.resolve(n);const
|
|
1
|
+
(function(d,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("dayjs"),require("@univerjs/presets"),require("decimal.js")):typeof define=="function"&&define.amd?define(["exports","dayjs","@univerjs/presets","decimal.js"],l):(d=typeof globalThis<"u"?globalThis:d||self,l(d.TorUniverSheet={},d.dayjs,d.presets,d.Decimal))})(this,(function(d,l,P,U){"use strict";const z=(e,n)=>{for(const t of n)e[t]=null},G=()=>{if(typeof crypto=="object"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"&&typeof Uint8Array=="function"){const t=r=>{const i=Number(r);return(i^crypto.getRandomValues(new Uint8Array(1))[0]&15>>i/4).toString(16)};return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t)}}let e=new Date().getTime(),n=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let r=Math.random()*16;return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(n+r)%16|0,n=Math.floor(n/16)),(t==="x"?r:r&3|8).toString(16)})};function Z(e){return{...e?.workbookData,id:e?.id||G(),name:e?.name||"未命名",appVersion:e?.appVersion||"1.0.0"}}const _=Object.prototype.toString,A=(e,n)=>_.call(e)===`[object ${n}]`,B=e=>e!==null&&A(e,"Object"),E=e=>e==null||typeof e>"u"?!0:V(e)||K(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:B(e)?Object.keys(e).length===0:!1,K=e=>A(e,"String"),V=e=>e&&Array.isArray(e);class L{value;constructor(n){this.value=new U(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 t=new U(n);if(t.isZero())throw new Error("除数是0");return this.value=this.value.div(t),this}toFixed(n,t){return this.value=new U(this.value.toFixed(n,t)),this}valueOf(){return this.value}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}}function O(e=0){return new L(e)}var q=(e=>(e.无="no",e.年="year",e.月="month",e.周="week",e.天="day",e.班组="shift",e.小时="hour",e.半小时="half_hour",e))(q||{}),F=(e=>(e.view="view",e.edit="edit",e))(F||{});async function Q(e,n){if(!n)return Promise.reject("日期不能为空");switch(e){case"year":if(V(n))return Promise.resolve(n);const t=l(n);if(!t.isValid())return Promise.reject("无效的日期格式");const r=t.year(),i=`${r}-01`,s=`${r}-12`;return Promise.resolve([i,s]);case"month":if(V(n))return Promise.resolve(n);const p=l(n);if(!p.isValid())return Promise.reject("无效的日期格式");const h=p.startOf("month").format("YYYY-MM-DD"),y=p.endOf("month").format("YYYY-MM-DD");return Promise.resolve([h,y]);case"day":if(V(n))return Promise.resolve(n);const m=l(n);if(!m.isValid())return Promise.reject("无效的日期格式");const S=m.startOf("day").format("YYYY-MM-DD HH:mm:ss"),f=m.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([S,f]);default:return Promise.reject("不支持的周期类型")}}function I(e,n,t){if(!t)return 0;const r={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[t];return["day","hour"].includes(t)?l(n,r).diff(l(e,r),t)+1:l(n,r).diff(l(e,r),t)}function $(e,n,t){const r={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[t];return l(e).subtract(n,t).format(r)}function N(e,n,t,r){const i={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"YYYY-MM-DD HH:mm:ss"}[n];return l(e,i).add(t*r,n).format(i)}function b(e,n,t){return e[n]||(e[n]={}),e[n][t]||(e[n][t]={}),e[n][t]}async function W(e){if(!e)throw new Error("cellData is required");const n=Object.entries(e).reduce((t,r)=>{const[i,s]=r;for(const[p,h]of Object.entries(s)){const{custom:y,v:m,t:S,s:f}=h;if(!y)continue;const{cellType:g}=y;if(g==="indicator"){const D=b(t,i,p);D.custom=y,D.s=f,D.t=S,D.v=m}}return t},{});return!n||E(n)?Promise.reject(new Error("No data found")):Promise.resolve(n)}function X({acc:e,params:n,initRowNum:t,initColNum:r,cellData:i}){const{rangeData:s,currentDay:p,extraArgs:h}=n,y=h?.teamData||{},{cycleType:m,timeIncrement:S,forwardPush:f,copyType:g,copyInterval:D,defaultShift:j}=i.custom;let M=0;switch(m){case"day":{let o="";if(f&&(o=$(s[0],6,"day")),!g){let c="";f?c=o:c=s[0];const u=b(e,t,r);u.v=c,u.t=P.CellValueType.STRING;break}f?M=I(o,s[0],"day"):M=I(s[0],s[1],"day");for(let c=0;c<=Math.abs(M===0?1:M);c++){const u=c*(D+1);let x="";f?x=N(o,"day",c,S):x=N(s[0],"day",c,S);const w=g==="right"?t:t+u,C=g==="right"?r+u:r,v=b(e,w,C);v.v=x,v.t=P.CellValueType.STRING}break}case"month":{if(!g){const o=b(e,t,r);o.v=s[0],o.t=P.CellValueType.STRING;break}M=I(s[0],s[1],"month");for(let o=0;o<=Math.abs(M===0?1:M);o++){const c=o*(D+1),u=g==="right"?t:t+c,x=g==="right"?r+c:r,w=b(e,u,x);w.v=N(s[0],"month",o,S),w.t=P.CellValueType.STRING}break}case"year":{if(!g){const o=b(e,t,r);o.v=s[0],o.t=P.CellValueType.STRING;break}M=I(s[0],s[1],"year");for(let o=0;o<=Math.abs(M===0?1:M);o++){const c=o*(D+1),u=g==="right"?t:t+c,x=g==="right"?r+c:r,w=b(e,u,x);w.v=N(s[0],"year",o,S),w.t=P.CellValueType.STRING}break}case"hour":{if(!g){const o=b(e,t,r);if(o.t=P.CellValueType.STRING,j){o.v=l(y?.startDatetime).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}o.v=l(p).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");break}M=I(y?.startDatetime,y?.endDatetime,"hour");for(let o=0;o<Math.abs(M===0?1:M);o++){const c=o*(D+1),u=g==="right"?t:t+c,x=g==="right"?r+c:r,w=b(e,u,x);if(w.t=P.CellValueType.STRING,j){const C=l(y?.startDatetime).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");w.v=N(C,"hour",o,S);continue}w.v=N(l(p).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",o,S)}}}}async function ee(e,n){if(!e)return Promise.reject("没有可用的单元格数据");const{extraArgs:t,rangeData:r}=n;if(!r.length)return Promise.reject("处理时间范围失败, rangeData不能为空");const i=t?.teamData||{},s=n?.currentDay||l().format("YYYY-MM-DD"),p=Object.entries(e).reduce((h,y)=>{const[m,S]=y;for(const[f,g]of Object.entries(S)){const{custom:D}=g;if(!D)continue;const{cellType:j,cycleType:M,timeIncrement:o,forwardPush:c,copyType:u,copyInterval:x,defaultShift:w}=D;if(j==="time"){X({acc:h,params:n,initRowNum:Number(m),initColNum:Number(f),cellData:g});continue}const C={cycleType:M,indicatorName:D.indicatorName,indicatorCode:D.indicatorCode,indicatorId:D.indicatorId,indicatorDimensionName:D.indicatorDimensionName,indicatorDimensionConfig:D.indicatorDimensionConfig,required:D?.required||!1,cellType:D.cellType,defaultShift:D?.defaultShift||!1};let v=0;switch(M){case"day":{let a="";if(c&&(a=$(r[0],6,"day")),!u){let Y="";c?Y=a:Y=r[0];const H=b(h,m,f);H.custom={...C,businessDate:Y},w&&(H.custom.teamData=i);break}c?v=I(a,r[0],"day"):v=I(r[0],r[1],"day");for(let Y=0;Y<Math.abs(v===0?1:v);Y++){const H=Y*(x+1);let k="";c?k=N(a,"day",Y,o):k=N(r[0],"day",Y,o);const T=u==="right"?m:O(m).add(H).toNumber(),R=u==="right"?O(f).add(H).toNumber():f,J=b(h,T,R);J.custom={...C,businessDate:k},w&&(J.custom.teamData=i)}break}case"month":{if(!u){const a=b(h,m,f);a.custom={...C,businessDate:r[0]};break}v=I(r[0],r[1],"month");for(let a=0;a<=Math.abs(v===0?1:v);a++){const Y=a*(x+1),H=u==="right"?m:O(m).add(Y).toNumber(),k=u==="right"?O(f).add(Y).toNumber():f,T=b(h,H,k);T.custom={...C,businessDate:N(r[0],"month",a,o)}}break}case"year":{if(!u){const a=b(h,m,f);a.custom={...C,businessDate:r[0]};break}v=I(r[0],r[1],"year");for(let a=0;a<Math.abs(v===0?1:v);a++){const Y=a*(x+1),H=u==="right"?m:O(m).add(Y).toNumber(),k=u==="right"?O(f).add(Y).toNumber():f,T=b(h,H,k);T.custom={...C,businessDate:N(r[0],"year",a,o)}}break}case"hour":{if(!u){const a=b(h,m,f);if(w){a.custom={...C,teamData:i,businessDate:l(i?.startDatetime).add(1,"hour").format("YYYY-MM-DD HH:mm:ss")};break}a.custom={...C,businessDate:l(s).add(1,"hour").format("YYYY-MM-DD HH:mm:ss")};break}v=I(i?.startDatetime,i?.endDatetime,"hour");for(let a=0;a<Math.abs(v===0?1:v);a++){const Y=a*(x+1),H=u==="right"?m:O(m).add(Y).toNumber(),k=u==="right"?O(f).add(Y).toNumber():f,T=b(h,H,k);if(w){const R=l(i?.startDatetime).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");T.custom={...C,teamData:i,businessDate:N(R,"hour",a,o)};continue}T.custom={...C,businessDate:N(l(s).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",a,o)}}break}}}return h},{});return Promise.resolve(p)}function te(e){return Object.entries(e).reduce((t,[r,i])=>{const s=Math.max(...Object.keys(i).map(Number));return s>t?t=Number(s):t=Number(t)||0,t},0)}function re(e,n){const t=JSON.parse(JSON.stringify(e||{}));for(const[r,i]of Object.entries(n)){t[r]||(t[r]={});for(const[s,p]of Object.entries(i)){const h=p,y=t[r]?.[s];y?t[r][s]={...y,...h,custom:{...y.custom,...h.custom||{}}}:t[r][s]=h}}return t}const ne="./style.css";d.CycleTypeEnum=q,d.ModeEnum=F,d.decimal=O,d.filterIndicatorsCell=W,d.generateIndicatorsCells=ee,d.generateUUID=G,d.getNumColumns=te,d.handleClearInput=z,d.initDateRange=Q,d.mergeCellData=re,d.stylePath=ne,d.useData=Z,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
|