tor-univer-sheet 1.1.8 → 1.1.9
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.
|
@@ -188,7 +188,7 @@ async function dt(t) {
|
|
|
188
188
|
for (const [i, N] of Object.entries(n)) {
|
|
189
189
|
const { custom: s, v: w, t: d, s: H } = N;
|
|
190
190
|
if (!s) continue;
|
|
191
|
-
const { cellType: m } = s, j = $(s?.writeBack) ? !0 : s.writeBack;
|
|
191
|
+
const { cellType: m } = s, j = !s.hasOwnProperty("writeBack") || $(s?.writeBack) ? !0 : s.writeBack;
|
|
192
192
|
if (m === "indicator" && j) {
|
|
193
193
|
const P = g(o, c, i);
|
|
194
194
|
P.custom = {
|
|
@@ -359,7 +359,18 @@ async function ht(t, r) {
|
|
|
359
359
|
for (const [d, H] of Object.entries(w)) {
|
|
360
360
|
const { custom: m } = H;
|
|
361
361
|
if (!m) continue;
|
|
362
|
-
const {
|
|
362
|
+
const {
|
|
363
|
+
cellType: j,
|
|
364
|
+
cycleType: P,
|
|
365
|
+
timeIncrement: v,
|
|
366
|
+
forwardPush: B,
|
|
367
|
+
forwardPushTimes: b,
|
|
368
|
+
copyType: a,
|
|
369
|
+
copyInterval: u,
|
|
370
|
+
defaultShift: Y,
|
|
371
|
+
useDefaultStartDate: O,
|
|
372
|
+
useDefaultEndDate: x
|
|
373
|
+
} = m;
|
|
363
374
|
if (j === "time") {
|
|
364
375
|
at({ acc: i, params: r, initRowNum: Number(s), initColNum: Number(d), cellData: H });
|
|
365
376
|
continue;
|
|
@@ -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"),$=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 H(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`,o=`${t}-12`;return Promise.resolve([f,o]);case"month":if(A(r))return Promise.resolve(r);const i=c(r);if(!i.isValid())return Promise.reject("无效的日期格式");const C=i.startOf("month").format("YYYY-MM-DD"),s=i.endOf("month").format("YYYY-MM-DD");return Promise.resolve([C,s]);case"day":if(A(r))return Promise.resolve(r);const v=c(r);if(!v.isValid())return Promise.reject("无效的日期格式");const d=v.startOf("day").format("YYYY-MM-DD HH:mm:ss"),I=v.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([d,I]);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)+1:c(r,t).diff(c(e,t),n)}function F(e,r,n){if(!n)throw new Error("日期类型不能为空");const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[n];return c(e).subtract(r,n).format(t)}function T(e,r,n,t){const f="YYYY-MM-DD HH:mm:ss",o=E(e,r,n,t),i=c(o);if(r==="month"){const s=i.month();return s===0?[i.startOf("month").format(f),i.date(25).endOf("day").format(f)]:s===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 C={year:"year",day:"day",hour:"hour"};return[i.startOf(C[r]).format(f),i.endOf(C[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 y(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,o]=t;for(const[i,C]of Object.entries(o)){const{custom:s,v,t:d,s:I}=C;if(!s)continue;const{cellType:m}=s,V=$(s?.writeBack)?!0:s.writeBack;if(m==="indicator"&&V){const P=y(n,f,i);P.custom={...s,required:$(s?.required)?!1:s?.required,defaultShift:$(s?.defaultShift)?!1:s?.defaultShift,forwardPush:$(s?.forwardPush)?!1:s?.forwardPush,forwardPushTimes:$(s?.useDefaultEndDate)?0:s?.forwardPushTimes,useDefaultEndDate:$(s?.useDefaultEndDate)?!1:s?.useDefaultEndDate,writeBack:V},P.s=I,P.t=d,P.v=v}}return n},{});return!r||$(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),o=Object.values(r);return new Function(...f,`return ${t};`)(...o)}catch(f){return console.error(`表达式执行失败: ${t}`,f),n}})}function fe({acc:e,params:r,initRowNum:n,initColNum:t,cellData:f}){const{rangeData:o,currentDay:i,extraArgs:C}=r;C?.teamData;const{cycleType:s,timeIncrement:v,forwardPush:d,forwardPushTimes:I,copyType:m,copyInterval:V,defaultShift:P,templateStr:p,useDefaultEndDate:q}=f.custom;let M=0;switch(s){case"day":{let a="";if(d&&(a=F(o[0],I,"day")),!m){let u="";d?u=a:u=o[0];const D=y(e,n,t);D.v=p?J(p,{businessDate:u,dayjs:c}):c(u).format("YYYY-MM-DD"),D.t=R.CellValueType.STRING;break}d?M=k(a,o[0],"day"):M=k(o[0],o[1],"day");for(let u=0;u<=Math.abs(M===0?1:M);u++){const D=u*(V+1);let O="";d?O=E(a,"day",u,v):O=E(o[0],"day",u,v);const N=m==="right"?n:n+D,w=m==="right"?t+D:t,b=y(e,N,w);b.v=p?J(p,{businessDate:O,dayjs:c}):c(O).format("YYYY-MM-DD"),b.t=R.CellValueType.STRING}break}case"month":{if(!m){const[a,u]=T(o[1],"month",0,1),D=y(e,n,t);D.v=c(u).format("YYYY-MM"),D.t=R.CellValueType.STRING;break}M=k(o[0],o[1],"month");for(let a=0;a<=Math.abs(M===0?1:M);a++){const u=a*(V+1),D=m==="right"?n:n+u,O=m==="right"?t+u:t,N=y(e,D,O);N.v=E(o[0],"month",a,v),N.t=R.CellValueType.STRING}break}case"year":{let a="";if(d&&(a=F(o[0],I||0,"year")),!m){const u=d?a:o[0],[D,O]=T(u,"year",0,1),N=y(e,n,t),[,w]=T(o[1],"month",0,1);N.v=p?J(p,{startTime:D,endTime:O,rangeData:o,dayjs:c}):u,N.t=R.CellValueType.STRING;break}d?M=k(a,o[0],"year"):M=k(o[0],o[1],"year");for(let u=0;u<=Math.abs(M===0?1:M);u++){const D=u*(V+1),O=m==="right"?n:n+D,N=m==="right"?t+D:t,[w,b]=T(o[0],"year",u,v),l=y(e,O,N),h=E(o[0],"year",u,v);l.v=p?J(p,{startTime:w,endTime:b,rangeData:o,dayjs:c}):h,l.t=R.CellValueType.STRING}break}case"hour":{if(!m){const a=y(e,n,t);if(a.t=R.CellValueType.STRING,P){a.v=c(o[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}M=k(o[0],o[1],"hour");for(let a=0;a<Math.abs(M===0?1:M);a++){const u=a*(V+1),D=m==="right"?n:n+u,O=m==="right"?t+u:t,N=y(e,D,O);if(N.t=R.CellValueType.STRING,P){const w=c(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");N.v=E(w,"hour",a,v);continue}N.v=E(c(i).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",a,v)}}}}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"),o=Object.entries(e).reduce((i,C)=>{const[s,v]=C;for(const[d,I]of Object.entries(v)){const{custom:m}=I;if(!m)continue;const{cellType:V,cycleType:P,timeIncrement:p,forwardPush:q,forwardPushTimes:M,copyType:a,copyInterval:u,defaultShift:D,useDefaultStartDate:O,useDefaultEndDate:N}=m;if(V==="time"){fe({acc:i,params:r,initRowNum:Number(s),initColNum:Number(d),cellData:I});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:$(m?.writeBack)?!0:m.writeBack};let b=0;switch(P){case"day":{let l="";if(q&&(l=F(t[0],M||0,"day")),!a){const h=q?l:t[0],[x,g]=T(h,"day",0,1),S=y(i,s,d);S.custom={...w,startTime:x,endTime:g};break}q?b=k(l,t[0],"day"):b=k(t[0],t[1],"day");for(let h=0;h<Math.abs(b===0?1:b);h++){const x=h*(u+1),g=q?l:t[0],[S,U]=T(g,"day",h,p),B=a==="right"?s:H(s).add(x).toNumber(),G=a==="right"?H(d).add(x).toNumber():d,j=y(i,B,G);j.custom={...w,startTime:S,endTime:U}}break}case"month":{if(!a){const[l,h]=T(t[1],"month",0,1),x=y(i,s,d);x.custom={...w,startTime:l,endTime:h};break}b=k(t[0],t[1],"month");for(let l=0;l<=Math.abs(b===0?1:b);l++){const h=l*(u+1),x=a==="right"?s:H(s).add(h).toNumber(),g=a==="right"?H(d).add(h).toNumber():d,[S,U]=T(t[0],"month",l,p),B=y(i,x,g);B.custom={...w,startTime:S,endTime:U}}break}case"year":{let l="",h="",x="";if(q){l=F(t[0],M||0,"year");const g=c(t[1]).format("MM");h=c(`${l}-${g+1}`).format("YYYY-MM"),x=c(`${l}-${g+2}`).format("YYYY-MM")}if(!a){const g=q?l:t[0],[S,U]=T(g,"year",0,1),B=y(i,s,d),[,G]=T(h,"month",0,1),[j]=T(x,"month",0,1);B.custom={...w,startTime:O?j:S,endTime:N?G:U};break}q?b=k(l,t[0],"year"):b=k(t[0],t[1],"year");for(let g=0;g<Math.abs(b===0?1:b);g++){const S=g*(u+1),U=a==="right"?s:H(s).add(S).toNumber(),B=a==="right"?H(d).add(S).toNumber():d,[G,j]=T(t[0],"year",g,p),Z=y(i,U,B);Z.custom={...w,startTime:G,endTime:j}}break}case"hour":{if(!a){const l=D?t[0]:t[0]??f,[h,x]=T(l,"hour",1,1),g=y(i,s,d);g.custom={...w,startTime:h,endTime:x};break}b=k(t[0],t[1],"hour");for(let l=0;l<Math.abs(b===0?1:b);l++){const h=l*(u+1),x=a==="right"?s:H(s).add(h).toNumber(),g=a==="right"?H(d).add(h).toNumber():d,S=y(i,x,g);if(D){const j=c(t[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[Z,Ye]=T(j,"hour",l,p);S.custom={...w,startTime:Z,endTime:Ye};continue}const U=c(f).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),[B,G]=T(U,"hour",l,p);S.custom={...w,startTime:B,endTime:G}}break}}}return i},{});return Promise.resolve(o)}function me(e){return Object.entries(e).reduce((n,[t,f])=>{const o=Math.max(...Object.keys(f).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,f]of Object.entries(r)){n[t]||(n[t]={});for(const[o,i]of Object.entries(f)){const C=i,s=n[t]?.[o];s?n[t][o]={...s,...C,custom:{...s.custom,...C.custom}}:n[t][o]=C}}return n}const he="./style.css";Y.CycleTypeEnum=L,Y.ModeEnum=Q,Y.decimal=H,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(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"),$=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 H(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`,o=`${t}-12`;return Promise.resolve([f,o]);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"),s=i.endOf("month").format("YYYY-MM-DD");return Promise.resolve([x,s]);case"day":if(A(r))return Promise.resolve(r);const v=c(r);if(!v.isValid())return Promise.reject("无效的日期格式");const d=v.startOf("day").format("YYYY-MM-DD HH:mm:ss"),I=v.endOf("day").format("YYYY-MM-DD HH:mm:ss");return Promise.resolve([d,I]);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)+1:c(r,t).diff(c(e,t),n)}function F(e,r,n){if(!n)throw new Error("日期类型不能为空");const t={year:"YYYY",month:"YYYY-MM",day:"YYYY-MM-DD",hour:"HH:mm:ss"}[n];return c(e).subtract(r,n).format(t)}function T(e,r,n,t){const f="YYYY-MM-DD HH:mm:ss",o=E(e,r,n,t),i=c(o);if(r==="month"){const s=i.month();return s===0?[i.startOf("month").format(f),i.date(25).endOf("day").format(f)]:s===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 g(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,o]=t;for(const[i,x]of Object.entries(o)){const{custom:s,v,t:d,s:I}=x;if(!s)continue;const{cellType:m}=s,V=!s.hasOwnProperty("writeBack")||$(s?.writeBack)?!0:s.writeBack;if(m==="indicator"&&V){const P=g(n,f,i);P.custom={...s,required:$(s?.required)?!1:s?.required,defaultShift:$(s?.defaultShift)?!1:s?.defaultShift,forwardPush:$(s?.forwardPush)?!1:s?.forwardPush,forwardPushTimes:$(s?.useDefaultEndDate)?0:s?.forwardPushTimes,useDefaultEndDate:$(s?.useDefaultEndDate)?!1:s?.useDefaultEndDate,writeBack:V},P.s=I,P.t=d,P.v=v}}return n},{});return!r||$(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),o=Object.values(r);return new Function(...f,`return ${t};`)(...o)}catch(f){return console.error(`表达式执行失败: ${t}`,f),n}})}function fe({acc:e,params:r,initRowNum:n,initColNum:t,cellData:f}){const{rangeData:o,currentDay:i,extraArgs:x}=r;x?.teamData;const{cycleType:s,timeIncrement:v,forwardPush:d,forwardPushTimes:I,copyType:m,copyInterval:V,defaultShift:P,templateStr:C,useDefaultEndDate:q}=f.custom;let M=0;switch(s){case"day":{let a="";if(d&&(a=F(o[0],I,"day")),!m){let u="";d?u=a:u=o[0];const D=g(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?M=k(a,o[0],"day"):M=k(o[0],o[1],"day");for(let u=0;u<=Math.abs(M===0?1:M);u++){const D=u*(V+1);let O="";d?O=E(a,"day",u,v):O=E(o[0],"day",u,v);const N=m==="right"?n:n+D,w=m==="right"?t+D:t,y=g(e,N,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(o[1],"month",0,1),D=g(e,n,t);D.v=c(u).format("YYYY-MM"),D.t=R.CellValueType.STRING;break}M=k(o[0],o[1],"month");for(let a=0;a<=Math.abs(M===0?1:M);a++){const u=a*(V+1),D=m==="right"?n:n+u,O=m==="right"?t+u:t,N=g(e,D,O);N.v=E(o[0],"month",a,v),N.t=R.CellValueType.STRING}break}case"year":{let a="";if(d&&(a=F(o[0],I||0,"year")),!m){const u=d?a:o[0],[D,O]=T(u,"year",0,1),N=g(e,n,t),[,w]=T(o[1],"month",0,1);N.v=C?J(C,{startTime:D,endTime:O,rangeData:o,dayjs:c}):u,N.t=R.CellValueType.STRING;break}d?M=k(a,o[0],"year"):M=k(o[0],o[1],"year");for(let u=0;u<=Math.abs(M===0?1:M);u++){const D=u*(V+1),O=m==="right"?n:n+D,N=m==="right"?t+D:t,[w,y]=T(o[0],"year",u,v),l=g(e,O,N),h=E(o[0],"year",u,v);l.v=C?J(C,{startTime:w,endTime:y,rangeData:o,dayjs:c}):h,l.t=R.CellValueType.STRING}break}case"hour":{if(!m){const a=g(e,n,t);if(a.t=R.CellValueType.STRING,P){a.v=c(o[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}M=k(o[0],o[1],"hour");for(let a=0;a<Math.abs(M===0?1:M);a++){const u=a*(V+1),D=m==="right"?n:n+u,O=m==="right"?t+u:t,N=g(e,D,O);if(N.t=R.CellValueType.STRING,P){const w=c(o[0]).add(1,"hour").format("YYYY-MM-DD HH:mm:ss");N.v=E(w,"hour",a,v);continue}N.v=E(c(i).add(1,"hour").format("YYYY-MM-DD HH:mm:ss"),"hour",a,v)}}}}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"),o=Object.entries(e).reduce((i,x)=>{const[s,v]=x;for(const[d,I]of Object.entries(v)){const{custom:m}=I;if(!m)continue;const{cellType:V,cycleType:P,timeIncrement:C,forwardPush:q,forwardPushTimes:M,copyType:a,copyInterval:u,defaultShift:D,useDefaultStartDate:O,useDefaultEndDate:N}=m;if(V==="time"){fe({acc:i,params:r,initRowNum:Number(s),initColNum:Number(d),cellData:I});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:$(m?.writeBack)?!0:m.writeBack};let y=0;switch(P){case"day":{let l="";if(q&&(l=F(t[0],M||0,"day")),!a){const h=q?l:t[0],[p,b]=T(h,"day",0,1),S=g(i,s,d);S.custom={...w,startTime:p,endTime:b};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 p=h*(u+1),b=q?l:t[0],[S,B]=T(b,"day",h,C),U=a==="right"?s:H(s).add(p).toNumber(),G=a==="right"?H(d).add(p).toNumber():d,j=g(i,U,G);j.custom={...w,startTime:S,endTime:B}}break}case"month":{if(!a){const[l,h]=T(t[1],"month",0,1),p=g(i,s,d);p.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),p=a==="right"?s:H(s).add(h).toNumber(),b=a==="right"?H(d).add(h).toNumber():d,[S,B]=T(t[0],"month",l,C),U=g(i,p,b);U.custom={...w,startTime:S,endTime:B}}break}case"year":{let l="",h="",p="";if(q){l=F(t[0],M||0,"year");const b=c(t[1]).format("MM");h=c(`${l}-${b+1}`).format("YYYY-MM"),p=c(`${l}-${b+2}`).format("YYYY-MM")}if(!a){const b=q?l:t[0],[S,B]=T(b,"year",0,1),U=g(i,s,d),[,G]=T(h,"month",0,1),[j]=T(p,"month",0,1);U.custom={...w,startTime:O?j:S,endTime:N?G:B};break}q?y=k(l,t[0],"year"):y=k(t[0],t[1],"year");for(let b=0;b<Math.abs(y===0?1:y);b++){const S=b*(u+1),B=a==="right"?s:H(s).add(S).toNumber(),U=a==="right"?H(d).add(S).toNumber():d,[G,j]=T(t[0],"year",b,C),Z=g(i,B,U);Z.custom={...w,startTime:G,endTime:j}}break}case"hour":{if(!a){const l=D?t[0]:t[0]??f,[h,p]=T(l,"hour",1,1),b=g(i,s,d);b.custom={...w,startTime:h,endTime:p};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),p=a==="right"?s:H(s).add(h).toNumber(),b=a==="right"?H(d).add(h).toNumber():d,S=g(i,p,b);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(o)}function me(e){return Object.entries(e).reduce((n,[t,f])=>{const o=Math.max(...Object.keys(f).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,f]of Object.entries(r)){n[t]||(n[t]={});for(const[o,i]of Object.entries(f)){const x=i,s=n[t]?.[o];s?n[t][o]={...s,...x,custom:{...s.custom,...x.custom}}:n[t][o]=x}}return n}const he="./style.css";Y.CycleTypeEnum=L,Y.ModeEnum=Q,Y.decimal=H,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"})}));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -73,6 +73,9 @@ declare class DecimalChain {
|
|
|
73
73
|
toNumber(): number;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* 过滤指标单元格(优化版:更快、更健壮、更易读)
|
|
78
|
+
*/
|
|
76
79
|
export declare function filterIndicatorsCell(cellData: IObjectMatrixPrimitiveType<ICellData>): Promise<{}>;
|
|
77
80
|
|
|
78
81
|
export declare function generateIndicatorsCells(cells: IObjectMatrixPrimitiveType<ICellData>, params: IGenerateIndicatorsCellsParams): Promise<ICellData>;
|