Renxy 1 år sedan
förälder
incheckning
c87407c9d4
1 ändrade filer med 25 tillägg och 9 borttagningar
  1. 25 9
      src/pages/PSRManage/detail.js

+ 25 - 9
src/pages/PSRManage/detail.js

@@ -355,11 +355,26 @@ const PSRDetail = () => {
         setExcelData({ ...data, name });
         setHistoryOpen(false);
         const jsonData = JSON.parse(data.json_data);
-        if (jsonData[0].celldata && typeof jsonData[0].celldata == 'string')
-          jsonData[0].celldata = JSON.parse(jsonData[0].celldata);
-        if (jsonData[0].config && typeof jsonData[0].config == 'string')
-          jsonData[0].config = JSON.parse(jsonData[0].config);
+        console.log(jsonData);
+
+        // if (Array.isArray(data)) {
+        jsonData.map((item) => {
+          if (item.celldata && typeof item.celldata == 'string')
+            item.celldata = JSON.parse(item.celldata);
+          if (item.config && typeof item.celldata == 'string')
+            item.config = JSON.parse(item.config);
+        });
+        // } else {
+        //   if (data.celldata) data.celldata = JSON.parse(data.celldata);
+        //   if (data.config) data.config = JSON.parse(data.config);
+        // }
         renderSheet(jsonData, data.is_edit);
+
+        // if (jsonData[0].celldata && typeof jsonData[0].celldata == 'string')
+        //   jsonData[0].celldata = JSON.parse(jsonData[0].celldata);
+        // if (jsonData[0].config && typeof jsonData[0].config == 'string')
+        //   jsonData[0].config = JSON.parse(jsonData[0].config);
+        // renderSheet(jsonData, data.is_edit);
       } else {
         setExcelData({ name: '' });
         setNoData(true);
@@ -467,8 +482,10 @@ const PSRDetail = () => {
       const canEdit = isOrigin ? 0 : res.data[0].is_edit;
       if (Array.isArray(data)) {
         data.map((item) => {
-          if (item.celldata) item.celldata = JSON.parse(item.celldata);
-          if (item.config) item.config = JSON.parse(item.config);
+          if (item.celldata && typeof item.celldata == 'string')
+            item.celldata = JSON.parse(item.celldata);
+          if (item.config && typeof item.celldata == 'string')
+            item.config = JSON.parse(item.config);
         });
         renderSheet(data, canEdit);
       } else {
@@ -911,23 +928,22 @@ const PSRDetail = () => {
           titleRef.current = '';
         }}
       />
+      {noData && <div className={styles.noData}>暂无数据</div>}
       {compareValues?.length == 2 ? (
         <CompareCom values={compareValues} />
-      ) : noData ? (
-        <div className={styles.noData}>暂无数据</div>
       ) : (
         <iframe
           style={{
             width: '100%',
             height: '80vh',
             overflowX: 'hidden',
+            display: noData ? 'none' : 'block',
           }}
           ref={iframeRef}
           onLoad={handlerLoad}
           src="/luckysheet.html"
         />
       )}
-
       <Drawer
         title="历史版本"
         placement="right"