Przeglądaj źródła

fix(report): 新增获取从表数据的方法

lishihao 4 lat temu
rodzic
commit
7baea4c51e
2 zmienionych plików z 17 dodań i 8 usunięć
  1. 15 7
      report/src/core/formulasDataSetter.ts
  2. 2 1
      report/src/core/jpc_ex.ts

+ 15 - 7
report/src/core/formulasDataSetter.ts

@@ -84,6 +84,7 @@ const D = (fieldID: number, valIndex?: number, newValue?: any) => {
             if (!F(fieldID)) P(fieldID);
             if (DData[fieldID]) {
                 if (DData[fieldID].length >= valIndex) {
+                    if (!DData[fieldID][valIndex]) return null;
                     return DData[fieldID][valIndex];
                 } else {
                     console.log(`指标id:${fieldID},${valIndex}>${DData[fieldID].length},请检查`)
@@ -253,11 +254,11 @@ const insertFieldValue = (fieldID: number, valIdx: number, newValue: number) =>
 
 //复制精度
 const copyPrecision = (targetFieldID: number, orgFieldID: number) => {
-    copyProperty(targetFieldID, orgFieldID,'Precision');
+    copyProperty(targetFieldID, orgFieldID, 'Precision');
 }
 
 const copyFixedPrecisionNum = (targetFieldID: number, orgFieldID: number) => {
-    copyProperty(targetFieldID, orgFieldID,'fixedPrecisionNum');
+    copyProperty(targetFieldID, orgFieldID, 'fixedPrecisionNum');
 }
 
 //复制属性
@@ -265,12 +266,12 @@ const copyProperty = (targetFieldID: number, orgFieldID: number, property: strin
     const targetField = <IGroupField>F(targetFieldID);
     const orgField = <IGroupField>F(orgFieldID);
     if (targetField && orgField) {
-        if(orgField[property]){
-            if(!targetField[property]){
-                targetField[property]={};
+        if (orgField[property]) {
+            if (!targetField[property]) {
+                targetField[property] = {};
             }
             Object.assign(targetField[property], orgField[property]);
-        }else{
+        } else {
             console.log(`指标${orgFieldID}不存在${property}属性`);
         }
     } else {
@@ -282,6 +283,12 @@ const setDate = (fieldID: number, format: string) => {
     const date = new ReportDate();
     setData(fieldID, date.Format(format));
 }
+
+const DLength = () => {
+    if (orgData && orgData.detail_data) return orgData.detail_data[0].length
+    return 0;
+}
+
 export default {
     setupData,
     P,
@@ -300,7 +307,8 @@ export default {
     copyPrecision,
     copyFixedPrecisionNum,
     copyProperty,
-    setDate
+    setDate,
+    DLength
 }
 
 

+ 2 - 1
report/src/core/jpc_ex.ts

@@ -144,7 +144,8 @@ class JpcExClass {
             copyPrecision,
             copyFixedPrecisionNum,
             copyProperty,
-            setDate
+            setDate,
+            DLength
         } = formulasDataSetter;
         const {
             isEmptyString,