Renxy 1 anno fa
parent
commit
b4798de286

File diff suppressed because it is too large
+ 0 - 0
public/ZwCloud2DSDK/ZwCloud2D.js


+ 1048 - 263
public/ZwCloud2DSDK/ZwCloud2DPrivateAPI.js

@@ -1,7 +1,69 @@
 let baseUrl = 'http://192.168.51.174:5199';
 let wsUrl = '';
 let dwgPath = '';
+let docId = '';
 let javaUrl = '';
+let curHandleId = '';
+// 用户自定义:成员列表,用于评论图纸时@人员,其中memberId和memberName字段名称不能修改
+let memberList = {
+  code: 0,
+  data: {
+    rows: [
+      {
+        memberId: '12',
+        memberName: '张三',
+        email: '',
+        phone: '',
+        role: '',
+        avatarUrl: '/assets/ZwCloud2DSDK/text.png',
+      },
+      {
+        memberId: '32',
+        memberName: '李四',
+        email: '',
+        phone: '',
+        role: '',
+        avatarUrl: '/assets/ZwCloud2DSDK/image1.png',
+      },
+      {
+        memberId: '34',
+        memberName: '王五',
+        email: '',
+        phone: '',
+        role: '',
+        avatarUrl: '/assets/ZwCloud2DSDK/image2.png',
+      },
+    ],
+  },
+};
+// 用户自定义:当前用户,指定当前评论图纸的用户,其中userId和userName字段名称不能修改
+let user = {
+  userId: '12',
+  userName: '张三',
+  email: '',
+  phone: '',
+  role: '',
+};
+
+let req = null;
+
+let sourcePath = '';
+let compareFilePath = '';
+
+const enableSign = true;
+
+const signBlockOper = {
+  GetBlockData: 0,
+  UploadSign: 1,
+  UploadCert: 2,
+  UploadDwg: 3,
+  ConFirmEdit: 4,
+};
+
+const refType = {
+  plotMsg: 1,
+  signaturePic: 2,
+};
 
 class Request {
   constructor() {}
@@ -31,6 +93,14 @@ class Request {
           }
         }
       };
+      ajax.onreadystatechange = function () {
+        if (ajax.readyState === 4 && ajax.status !== 200) {
+          rej(ajax.status);
+        }
+      };
+      ajax.onerror = function (error) {
+        rej(error);
+      };
     });
   }
 
@@ -49,10 +119,13 @@ class Request {
           if (ajax.status === 200) {
             res(ajax.response);
           } else {
-            rej();
+            rej(ajax.status);
           }
         }
       };
+      ajax.onerror = function (error) {
+        rej(error);
+      };
     });
   }
 
@@ -70,18 +143,56 @@ class Request {
     return this.get('/sdk/font/download', { fontName }, 'blob');
   }
 
-  transferDoc() {
-    return this.get('/sdk/transfer', {
-      projectId: 0,
-      dwgPath: dwgPath,
-      type: 1,
+  transferDoc(dwgPath) {
+    if (enableSign) {
+      return this.transferDocV2();
+    }
+    return this.get('/sdk/transfer', { projectId: 0, dwgPath: dwgPath });
+  }
+
+  transferDocV2() {
+    // {
+    //     "dwgPath": "sdk-014_rotate.dwg",
+    // "useCache": false,
+    // "showBlock": true,
+    // "search": {
+    //   "blockPre": "",
+    //   "attrSignSuf": "_机打信息",
+    //   "attrImageSuf": "_签章图",
+    //   "officialSignSuf": "_公章"
+    // }
+    //   }
+    let useCache = getParams('useCache');
+    if (useCache === 'false') {
+      useCache = false;
+    } else {
+      useCache = true;
+    }
+    return this.post(
+      '/sdk/v2/transfer',
+      JSON.stringify({
+        dwgPath: dwgPath,
+        useCache: useCache,
+        showBlock: true,
+        search: {
+          blockPre: getParams('blockPre') || '标准图框_',
+          attrSignSuf: getParams('attrSignSuf') || '_机打信息',
+          // attrImageSuf: "_签章图",
+          officialSignSuf: getParams('officialSignSuf') || '_签章图',
+          dwgSignSuf: '_DWG签名',
+        },
+      }),
+    ).then((res) => {
+      let { code, data } = JSON.parse(res);
+      if (code === 0) return data;
     });
   }
 
   getDisplayData(handleId = 34) {
+    //电子签章中下载lmf不使用缓存, 正常开图下载lmf优先使用缓存
     return this.get(
       '/sdk/layout/lmf',
-      { projectId: 0, handleId, dwgPath: dwgPath },
+      { handleId, dwgPath: dwgPath, useCache: !enableSign },
       'arraybuffer',
     );
   }
@@ -92,7 +203,7 @@ class Request {
     return this.post('/sdk/xref', params, 'arraybuffer');
   }
 
-  getXrefRelation() {
+  getXrefRelation(dwgPath) {
     return this.get('/sdk/xref/list', { dwgPath: dwgPath });
   }
 
@@ -110,6 +221,14 @@ class Request {
     let data = JSON.stringify(params);
     return this.post('/sdk/print', data, 'arraybuffer');
   }
+  getSignPlotData(params) {
+    let data = JSON.stringify(params);
+    return this.post('/sdk/api/print', data, 'arraybuffer');
+  }
+  getSignBatchPlotData(params) {
+    let data = JSON.stringify(params);
+    return this.post('/sdk/api/batchPrint', data, 'arraybuffer');
+  }
   getImageSrc(filePath) {
     return this.get(
       '/sdk/image/download',
@@ -121,11 +240,7 @@ class Request {
     });
   }
   getImageData(filePath) {
-    return this.get(
-      '/sdk/image/download',
-      { filePath: filePath },
-      'arraybuffer',
-    );
+    return this.get('/sdk/image/download', { filePath: filePath }, 'blob');
   }
   getImageList() {
     return this.get('/sdk/image/list');
@@ -138,6 +253,58 @@ class Request {
     let data = JSON.stringify(params);
     return this.post('/sdk/regen', data, 'arraybuffer');
   }
+  getBlockData(params) {
+    return this.get('/sdk/api/sign/properties', params);
+  }
+  uploadSign(params) {
+    let url = '/sdk/api/sign/upload';
+    let { signId, file, uploadId } = params;
+    let formData = new FormData();
+    formData.append('dwgPath', dwgPath);
+    formData.append('signId', signId);
+    formData.append('file', file);
+    formData.append('uploadId', uploadId);
+    return this.post(url, formData).then((res) => {
+      let response = JSON.parse(res);
+      let { code, data } = response;
+      if (code === 0) {
+        return { fileId: data.fileId, signId };
+      } else {
+        return { fileId: '', signId };
+      }
+    });
+  }
+  downloadSign(signFileId) {
+    let url = '/sdk/api/sign/download/' + signFileId;
+    return this.get(url, {}, 'arraybuffer').then((res) => {
+      if (res) {
+        let url = this.arrayBufferToBase64(res);
+        return 'data:image/jpeg;base64,' + url;
+      }
+      return '';
+    });
+  }
+  saveBlockData(data) {
+    let params = { dwgPath, data };
+    params = JSON.stringify(params);
+    return this.post('/sdk/api/sign/save', params)
+      .then((res) => {
+        let response = JSON.parse(res);
+        let { code } = response;
+        if (code === 0) {
+          return true;
+        } else {
+          return false;
+        }
+      })
+      .catch(() => false);
+  }
+  deleteSign(signId) {
+    return this.post('/sdk/api/sign/delete?signId=' + signId);
+  }
+  getSignHistoryData(params) {
+    return this.get('/sdk/api/sign/signRecords', params).catch(() => []);
+  }
   getDwgFile() {
     return this.get(
       '/sdk/doc/download',
@@ -149,60 +316,376 @@ class Request {
   uploadFile(file) {
     let formData = new FormData();
     formData.append('file', file);
-    return this.post('/sdk/doc/upload', formData, 'json', 'java');
+    return this.post('/sdk/doc/upload', formData, 'json', 'java').catch(() => {
+      alert('上传接口 /sdk/doc/upload 调用失败 请联系管理员');
+    });
+  }
+  getDwgFile() {
+    return this.get(
+      '/sdk/doc/download',
+      { dwgPath: dwgPath },
+      'arraybuffer',
+      'java',
+    );
+  }
+  getTextStyleFont(path) {
+    let params = { path: path };
+    params = JSON.stringify(params);
+    return this.post('/sdk/font/fetchName', params, 'json', 'java');
+  }
+
+  getAbout() {
+    return this.get('/about');
+  }
+
+  addComment(params) {
+    return this.post(
+      '/sdk/doc/comment/add',
+      JSON.stringify({
+        docId,
+        handleId: curHandleId,
+        ...params,
+      }),
+    ).then((res) => {
+      let { code, data } = JSON.parse(res);
+      if (code === 0) return data;
+    });
   }
-}
 
-function resizeCheck() {
-  if (Date.now() - timer > 400) {
-    const windowInfo = {
-      width: window.innerWidth,
-      height: window.innerHeight,
+  editComment(params) {
+    return this.post(
+      '/sdk/doc/comment/edit',
+      JSON.stringify({
+        docId,
+        handleId: curHandleId,
+        ...params,
+      }),
+    ).then((res) => {
+      let { code, data } = JSON.parse(res);
+      if (code === 0) return data;
+    });
+  }
+
+  deleteComment(params) {
+    return this.post(
+      '/sdk/doc/comment/delete?id=' + params.id,
+      JSON.stringify({}),
+    ).then((res) => {
+      let { code, data } = JSON.parse(res);
+      if (code === 0) return data;
+    });
+  }
+
+  replyComment(params) {
+    return this.post(
+      '/sdk/doc/comment/reply',
+      JSON.stringify({
+        docId,
+        handleId: curHandleId,
+        ...params,
+      }),
+    ).then((res) => {
+      let { code, data } = JSON.parse(res);
+      if (code === 0) return data;
+    });
+  }
+
+  getComment(data) {
+    return this.get('/sdk/doc/comment/listPage', {
+      docId,
+      handleId: curHandleId,
+      pageNum: data.pageNum,
+      pageSize: data.pageSize,
+    });
+  }
+
+  /**
+   * 图纸对比, 调用转换服务
+   * @returns  fcmpInfo
+   */
+  transferFcmp(inputParams) {
+    let params = {
+      sourcePath: inputParams.sourcePath,
+      compareFilePath: inputParams.compareFilePath,
+      data: inputParams.hasOwnProperty('data')
+        ? inputParams.data
+        : {
+            fcmpRcShape: 0,
+            fcmpRcMargin: 5,
+            fcmpHatch: 1,
+            fcmpText: 1,
+          },
+      viewport: inputParams.hasOwnProperty('viewport')
+        ? inputParams.viewport
+        : '',
+      handleId: inputParams.hasOwnProperty('handleId')
+        ? inputParams.handleId
+        : '',
     };
-    console.log(windowInfo);
-    if (windowInfo.width <= 1190 || windowInfo.height <= 620) {
-      mainMobile.style.display = 'unset';
-      main.style.display = 'none';
-    } else {
-      mainMobile.style.display = 'none';
-      main.style.display = 'unset';
+    !params.viewport && delete params.viewport;
+    !params.handleId && delete params.handleId;
+
+    let isTimeout = false;
+    let timerTimeout = setTimeout(() => {
+      isTimeout = true;
+      alert('等待时间已经超过2分钟, 是否退出');
+      ZwCloud2D.ZwEditor.ZwSetLoadingState(true);
+      ZwCloud2D.ZwDataProcessor.ZwLoad();
+    }, 120000);
+
+    return this.post('/sdk/fcmp', JSON.stringify(params), 'json').then(
+      (res) => {
+        clearTimeout(timerTimeout);
+        if (res.code !== 0) {
+          alert(res.msg);
+          resizeCheck();
+          return Promise.reject(res.code);
+        }
+        if (isTimeout) {
+          return Promise.reject('transferFcmp request timeout!');
+        }
+        let data = res.data;
+
+        docId = data.docId || new Date().getTime().toString();
+
+        let layouts = [];
+        (data.layouts || []).forEach((layout) => {
+          let res = {
+            handleId: layout.handleId,
+            isDefault: layout.isDefault === 1 ? 'YES' : 'NO',
+            name: layout.layoutName,
+            tabOrder: layout.order,
+          };
+          layouts.push(res);
+          if (layout.isDefault === 1) {
+            curHandleId = layout.handleId;
+          }
+        });
+        let fcmpInfo = {
+          baseFileName: data.baseFileName,
+          baseFileInfo: [
+            { lable: '名称', value: sourcePath },
+            { lable: '所有者', value: '未知' },
+            { lable: '创建时间', value: '未知' },
+            { lable: '文件路径', value: '未知' },
+          ],
+          compareFileName: data.compareFileName,
+          compareFileInfo: [
+            { lable: '名称', value: compareFilePath },
+            { lable: '所有者', value: '未知' },
+            { lable: '创建时间', value: '未知' },
+            { lable: '文件路径', value: '未知' },
+          ],
+          fcmpDiffExt: data.fcmpDiffExt,
+          fcmpErrorFlag: data.fcmpErrorFlag,
+          fonts: data.fontList || [],
+          layouts: layouts,
+          fcmpRcShape: params.data.fcmpRcShape,
+          fcmpRcMargin: params.data.fcmpRcMargin,
+          fcmpHatch: params.data.fcmpHatch,
+          fcmpText: params.data.fcmpText,
+        };
+        return fcmpInfo;
+      },
+    );
+  }
+
+  /**
+   * 下载图纸转换的显示数据
+   * @param {string} compareFilePath
+   * @param {string} sourcePath
+   * @returns
+   */
+  getFcmpDisplayData(compareFilePath, sourcePath) {
+    return this.get(
+      '/sdk/layout/lmf',
+      {
+        handleId: compareFilePath.replace(/\.dwg/gi, '_fcmp'),
+        dwgPath: sourcePath,
+        useCache: true,
+      },
+      'arraybuffer',
+    );
+  }
+
+  /**
+   * 获取文件列表
+   * @returns
+   */
+  getFileList() {
+    return this.get('/sdk/dwg/list').catch(() => {
+      alert('获取文件列表接口 /sdk/dwg/list 调用失败 请联系管理员');
+    });
+  }
+}
+req = new Request();
+
+// 生成Guid
+function randomFour() {
+  return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
+}
+function guid() {
+  return (
+    randomFour() +
+    randomFour() +
+    '-' +
+    randomFour() +
+    '-' +
+    randomFour() +
+    '-' +
+    randomFour() +
+    '-' +
+    randomFour() +
+    randomFour() +
+    randomFour()
+  );
+}
+function getCommentFunc(data) {
+  // 每次切换布局需要重新获取评论数据
+  let commentList = {
+    code: 0,
+    data: {
+      rows: [],
+    },
+  };
+  req
+    .getComment(data)
+    .then((res) => {
+      if (res) {
+        let data = JSON.parse(JSON.stringify(res));
+        commentList.data.total = data.total;
+        commentList.data.rows = data.rows;
+      }
+      if (data.initial) {
+        ZwCloud2D.ZwDataManager.ZwSetCommentData({
+          commentList: commentList,
+          memberList,
+          user,
+        });
+      } else {
+        ZwCloud2D.ZwDataManager.ZwSetCommentData({
+          commentList: commentList,
+          pageNum: data.pageNum,
+        });
+      }
+    })
+    .catch((error) => {
+      if (data.initial) {
+        ZwCloud2D.ZwDataManager.ZwSetCommentData({
+          commentList: commentList,
+          memberList,
+          user,
+        });
+      } else {
+        ZwCloud2D.ZwDataManager.ZwSetCommentData({
+          commentList: commentList,
+          pageNum: data.pageNum,
+        });
+      }
+      console.error(error);
+    });
+}
+function saveCommentFunc(data) {
+  let params = { pageNum: 1, pageSize: data.data.pageSize };
+  if (data.data) {
+    // 根据不同场景组织数据并保存
+    switch (data.type) {
+      case 'delete':
+        req
+          .deleteComment({
+            id: data.data.id,
+          })
+          .then(() => {
+            this.getCommentFunc(params);
+          });
+        break;
+      case 'edit':
+        // 编辑评论时需要更新数据
+        req
+          .editComment({
+            id: data.data.id,
+            content: data.data.content,
+            realContent: data.data.realContent,
+            mark: data.data.mark,
+            withMark: data.data.withMark,
+            withAt: data.data.withMark,
+            createBy: user.userId,
+            creator: user.userName,
+          })
+          .then(() => {
+            this.getCommentFunc(params);
+          });
+        break;
+      default:
+        {
+          //新增评论、回复评论的场景
+          data.data.id = guid();
+          data.data.createTime = new Date().getTime();
+          data.data.createBy = user.userId;
+          data.data.creator = user.userName;
+          // 有parentId表示是回复评论
+          if (data.data.parentId) {
+            req
+              .replyComment({
+                parentId: data.data.parentId,
+                content: data.data.content,
+                realContent: data.data.realContent,
+                mark: data.data.mark,
+                withMark: data.data.withMark,
+                withAt: data.data.withMark,
+                createBy: user.userId,
+                creator: user.userName,
+              })
+              .then(() => {
+                this.getCommentFunc(params);
+              });
+          } else {
+            // 新增评论
+            req
+              .addComment({
+                content: data.data.content,
+                realContent: data.data.realContent,
+                mark: data.data.mark,
+                withMark: data.data.withMark,
+                withAt: data.data.withMark,
+                createBy: user.userId,
+                creator: user.userName,
+              })
+              .then(() => {
+                this.getCommentFunc(params);
+              });
+          }
+        }
+        break;
     }
-    timer = Date.now();
   }
 }
 
 ZwCloud2D.ZwDataProcessor.ZwSetConnectUrl = (url1, url2, url3) => {
-  javaUrl = url1;
-  baseUrl = url2;
-  wsUrl = url3;
+  baseUrl = url1;
+  wsUrl = url2;
+  javaUrl = url3;
 };
-
 ZwCloud2D.ZwDataProcessor.ZwSetLoadDwg = (path) => {
   dwgPath = path;
 };
-
 ZwCloud2D.ZwDataProcessor.uploadDwg = (file) => {
   let req = new Request();
-  return new Promise((resolve, reject) => {
-    req.uploadFile(file).then((res) => {
-      resolve(res);
-    });
-  });
 
-  // req.uploadFile(file).then(res => {
+  return req.uploadFile(file);
+  //   .then((res) => {
   //     dwgPath = res.data.path;
   //     ZwCloud2D.ZwDataProcessor.ZwLoad();
-  //     let main = document.getElementById('main');
-  //     main.style.display = "none"
-  //     let mainMobile = document.getElementById('main-mobile');
-  //     mainMobile.style.display = "none"
-  //     let showDwgBtn = document.getElementById('showDwgBtn');
-  //     let showFontBtn = document.getElementById('showFontBtn');
-  //     showDwgBtn.style.display = "unset"
-  //     showFontBtn.style.display = "unset"
-  // })
+  // let main = document.getElementById('main');
+  // main.style.display = 'none';
+  // let mainMobile = document.getElementById('main-mobile');
+  // mainMobile.style.display = 'none';
+  // let showDwgBtn = document.getElementById('showDwgBtn');
+  // let showFontBtn = document.getElementById('showFontBtn');
+  // showDwgBtn.style.display = 'unset';
+  // showFontBtn.style.display = 'unset';
+  //   });
 };
-
 ZwCloud2D.ZwDataProcessor.uploadFont = (file) => {
   let req = new Request();
   let pArray = new Array();
@@ -227,88 +710,230 @@ ZwCloud2D.ZwDataProcessor.uploadFont = (file) => {
       alert('上传失败');
     });
 };
-
-ZwCloud2D.ZwDataProcessor.ZwLoad = () => {
-  let docId = new Date().getTime().toString();
-  let req = new Request();
-
-  // 切换布局时候触发回调
-  ZwCloud2D.ZwMessageCallback.ZwEvtChangeLayout = (layout) => {
-    req
-      .getDisplayData(layout.handleId)
-      .then((data) => {
-        let timestamp = new Date().getTime();
-        ZwCloud2D.ZwDataManager.ZwSetDwgData(layout.handleId, data, timestamp);
-      })
-      .catch((error) => {
-        console.error(error);
-      });
-  };
-  ZwCloud2D.ZwMessageCallback.ZwEvtLoadXrefData = (data) => {
-    req
-      .getXrefData(data.handleId, data.xrefIds)
-      .then((res) => {
-        ZwCloud2D.ZwDataManager.ZwSetXrefData(res);
-      })
-      .catch(() => {
-        ZwCloud2D.ZwDataManager.ZwSetXrefData();
+ZwCloud2D.ZwDataProcessor.selectBaseDwgAndCompareDwg = () => {
+  return new Promise((res, rej) => {
+    req.getFileList().then((array) => {
+      new Modal({
+        title: '选择两个进行对比的图纸',
+        fcmpInfoContent: array,
+        onOk: () => {
+          res();
+        },
       });
-  };
-  ZwCloud2D.ZwMessageCallback.ZwEvtDrawEnd = () => {};
+    });
+  });
+};
+ZwCloud2D.ZwDataProcessor.ZwProcessAboutVersionData = () => {
+  return req.getAbout().then((res) => {
+    let aboutVersion = '';
+    aboutVersion +=
+      'Front side VERNUM: ' + ZwCloud2D.version.commitId + '<br/>';
+    aboutVersion +=
+      'Front side COMMIT TIME: ' + ZwCloud2D.version.commitTime + '<br/>';
+    aboutVersion +=
+      'Middleware VERNUM: ' + (res['git.commit.id'] || '') + '<br/>';
+    aboutVersion +=
+      'Middleware COMMIT TIME: ' + (res['git.commit.time'] || '') + '<br/>';
+    aboutVersion +=
+      'Core service VERNUM: ' + (res['cloud2d.server'] || '') + '<br/>';
 
-  ZwCloud2D.ZwMessageCallback.ZwEvtGetRegenData = (data) => {
-    req
-      .getRegenData(data)
-      .then((res) => {
-        ZwCloud2D.ZwDataManager.ZwSetRegenData(res);
-      })
-      .catch(() => {
-        ZwCloud2D.ZwDataManager.ZwSetRegenData(null);
-      });
-  };
-  ZwCloud2D.ZwMessageCallback.ZwEvtLoadImageData = (data) => {
-    let pArr = new Array();
-    let imageMap = new Map();
-    data.forEach((imageUrl) => {
-      pArr.push(
-        new Promise((res, rej) => {
-          req
-            .getImageData(imageUrl)
-            .then((result) => {
-              imageMap.set(imageUrl, result);
-              res(true);
-            })
-            .catch((err) => {
-              res(true);
-            });
-        }),
-      );
+    ZwCloud2D.ZwSetting.ZwSetAbout({ version: aboutVersion });
+  });
+};
+ZwCloud2D.ZwDataProcessor.ZwProcessPermissionData = () => {
+  return req
+    .getPermissionList()
+    .then((data) => {
+      //启用电子签章功能
+      if (enableSign) {
+        ZwCloud2D.ZwEditor.ZwSetUserOptions({
+          panel: { signPanel: true },
+          commandButton: { Sign: true, Fcmp: true },
+          command: { FCMP: true },
+        });
+      } else {
+        //启用文件对比功能
+        ZwCloud2D.ZwEditor.ZwSetUserOptions({
+          commandButton: { Fcmp: true },
+          command: { FCMP: true },
+        });
+      }
+      ZwCloud2D.ZwDataManager.ZwSetSdkPermission(data);
+    })
+    .catch((error) => {
+      console.error(error);
     });
-    Promise.all(pArr)
-      .then(() => {
-        ZwCloud2D.ZwDataManager.ZwSetImageData(imageMap);
-      })
-      .catch((error) => {
-        console.error(error);
+};
+ZwCloud2D.ZwDataProcessor.ZwProcessFontData = (missingFonts) => {
+  let pArr = [];
+  let fontArr = [];
+  missingFonts.forEach((fontName) => {
+    let arr = fontName.split('.');
+    let type = (arr[arr.length - 1] || '').toUpperCase();
+
+    pArr.push(
+      req.fontDownload(fontName).then(async (data) => {
+        if (data.type === 'application/octet-stream') {
+          let arraybuffer = await data.arrayBuffer();
+          fontArr.push({
+            name: fontName,
+            type: type,
+            data: arraybuffer,
+          });
+        }
+      }),
+    );
+  });
+  return Promise.all(pArr).then(() => {
+    return ZwCloud2D.ZwDataManager.ZwSetFontDataList(fontArr);
+  });
+};
+ZwCloud2D.ZwDataProcessor.ZwProcessXrefData = (dwgPath, docName) => {
+  return req
+    .getXrefRelation(dwgPath)
+    .then((xrefRelations) => {
+      let xrefPromises = [];
+      let srcMap = new Map();
+      xrefRelations.forEach((xrefRelation) => {
+        if (xrefRelation.foundPath) {
+          xrefPromises.push(
+            new Promise((res, rej) => {
+              req.getXrefThumb(xrefRelation.foundPath).then((xrefThumb) => {
+                srcMap.set(xrefRelation.foundPath, xrefThumb);
+                res(true);
+              });
+            }),
+          );
+        }
       });
-  };
-  ZwCloud2D.ZwMessageCallback.ZwEvtLoadImageList = () => {
-    req.getImageList().then((res) => {
-      res.forEach((image) => {
-        let path = image.completePath + image.name;
-        req.getImageSrc(path).then((imageData) => {
-          let item = {
-            name: image.name,
-            data: imageData,
-            completePath: image.completePath,
+      return Promise.all(xrefPromises)
+        .then(() => {
+          let params = {
+            docName: docName,
+            xrefRelations: xrefRelations,
+            srcMap: srcMap,
+          };
+          ZwCloud2D.ZwDataManager.ZwSetXrefList(params);
+        })
+        .catch(() => {
+          let params = {
+            docName: docName,
+            xrefRelations: xrefRelations,
+            srcMap: srcMap,
           };
-          ZwCloud2D.ZwDataManager.ZwSetImageList(item);
+          ZwCloud2D.ZwDataManager.ZwSetXrefList(params);
         });
+    })
+    .catch((error) => {
+      console.error(error);
+    });
+};
+
+//ZwCloud SDK 回调
+ZwCloud2D.ZwMessageCallback.ZwEvtChangeLayout = (layout) => {
+  req
+    .getDisplayData(layout.handleId)
+    .then((data) => {
+      let timestamp = new Date().getTime();
+      ZwCloud2D.ZwDataManager.ZwSetDwgData(layout.handleId, data, timestamp);
+    })
+    .catch((error) => {
+      console.error(error);
+    });
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtLoadXrefData = (data) => {
+  req
+    .getXrefData(data.handleId, data.xrefIds)
+    .then((res) => {
+      ZwCloud2D.ZwDataManager.ZwSetXrefData(res);
+    })
+    .catch(() => {
+      ZwCloud2D.ZwDataManager.ZwSetXrefData();
+    });
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtDrawEnd = () => {};
+ZwCloud2D.ZwMessageCallback.ZwEvtGetRegenData = async (data) => {
+  req
+    .getRegenData(data)
+    .then((res) => {
+      ZwCloud2D.ZwDataManager.ZwSetRegenData(res);
+    })
+    .catch(() => {
+      ZwCloud2D.ZwDataManager.ZwSetRegenData(null);
+    });
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtLoadImageData = (data) => {
+  let pArr = new Array();
+  let imageMap = new Map();
+  data.forEach((imageUrl) => {
+    pArr.push(
+      new Promise((res, rej) => {
+        req
+          .getImageData(imageUrl)
+          .then(async (result) => {
+            if (result.type === 'application/octet-stream') {
+              let arraybuffer = await result.arrayBuffer();
+              imageMap.set(imageUrl, arraybuffer);
+            }
+            res(true);
+          })
+          .catch((err) => {
+            res(true);
+          });
+      }),
+    );
+  });
+  Promise.all(pArr)
+    .then(() => {
+      ZwCloud2D.ZwDataManager.ZwSetImageData(imageMap);
+    })
+    .catch((error) => {
+      console.error(error);
+    });
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtLoadImageList = () => {
+  req.getImageList().then((res) => {
+    res.forEach((image) => {
+      let path = image.completePath + image.name;
+      image.completePath = path;
+      req.getImageSrc(path).then((imageData) => {
+        let item = {
+          name: image.name,
+          data: imageData,
+          completePath: image.completePath,
+        };
+        ZwCloud2D.ZwDataManager.ZwSetImageList(item);
       });
     });
-  };
-  ZwCloud2D.ZwMessageCallback.ZwEvtPlotDwg = (data) => {
-    let params = Object.assign(data.params, { dwgPath: dwgPath });
+  });
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtPlotDwg = (data) => {
+  let params = Object.assign(data.params, { dwgPath: dwgPath });
+  if (enableSign) {
+    params.docId = 0;
+    let { isZwPlot } = data.params;
+    if (isZwPlot) {
+      req
+        .getSignBatchPlotData(params)
+        .then((res) => {
+          ZwCloud2D.ZwDataManager.ZwSetPlotData(data, res);
+          ZwCloud2D.ZwEditor.ZwSetLoadingState(false);
+        })
+        .catch((error) => {
+          console.error(error);
+        });
+    } else {
+      req
+        .getSignPlotData(params)
+        .then((res) => {
+          ZwCloud2D.ZwDataManager.ZwSetPlotData(data, res);
+          ZwCloud2D.ZwEditor.ZwSetLoadingState(false);
+        })
+        .catch((error) => {
+          console.error(error);
+        });
+    }
+  } else {
     req
       .getPlotData(params)
       .then((res) => {
@@ -318,148 +943,308 @@ ZwCloud2D.ZwDataProcessor.ZwLoad = () => {
       .catch((error) => {
         console.error(error);
       });
-  };
-  ZwCloud2D.ZwEditor.ZwSetUserOptions({ panel: { commentPanel: false } });
-  req
-    .getPermissionList()
-    .then((data) => {
-      ZwCloud2D.ZwDataManager.ZwSetSdkPermission(data);
-    })
-    .catch((error) => {
-      console.error(error);
-    });
-  if (!dwgPath) return;
-  req
-    .transferDoc()
-    .then((data) => {
-      // 显示当前布局的数据
-      let layouts = [];
-      data.layouts.forEach((layout) => {
-        let res = {
-          handleId: layout.handleId,
-          isDefault: layout.isDefault === 1 ? 'YES' : 'NO',
-          name: layout.layoutName,
-          tabOrder: layout.order,
-        };
-        layouts.push(res);
+  }
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtSignBlockData = (res) => {
+  let { type, data } = res;
+  switch (type) {
+    case signBlockOper.GetBlockData:
+      req.getBlockData({ dwgPath, drawFramePrefix: '' }).then((res) => {
+        ZwCloud2D.ZwDataManager.ZwSignBlockData({ type, data: res });
       });
-      ZwCloud2D.ZwDataManager.ZwSetDwgInfo({
-        id: docId,
-        fonts: data.fontList,
-        layouts: layouts,
-        name: data.name,
-      }).then((res) => {
-        let pArr = [];
-        let fontArr = [];
-        res.missingFonts.forEach((fontName) => {
-          let arr = fontName.split('.');
-          let type = (arr[arr.length - 1] || '').toUpperCase();
-
-          pArr.push(
-            req.fontDownload(fontName).then(async (data) => {
-              if (data.type === 'application/octet-stream') {
-                let arraybuffer = await data.arrayBuffer();
-                fontArr.push({
-                  name: fontName,
-                  type: type,
-                  data: arraybuffer,
-                });
-              }
-            }),
-          );
-        });
-        Promise.all(pArr)
-          .then(() => {
-            ZwCloud2D.ZwDataManager.ZwSetFontDataList(fontArr).then(() => {
-              req
-                .getDisplayData(res.layout.handleId)
-                .then((lmfInfo) => {
-                  if (res.timestamp === '')
-                    res.timestamp = new Date().getTime();
-                  ZwCloud2D.ZwDataManager.ZwSetDwgData(
-                    res.layout.handleId,
-                    lmfInfo,
-                    res.timestamp,
-                  );
-                })
-                .catch((error) => {
-                  console.error(error);
-                });
-
-              req
-                .getXrefRelation()
-                .then((xrefRelations) => {
-                  let xrefPromises = [];
-                  let srcMap = new Map();
-                  xrefRelations.forEach((xrefRelation) => {
-                    if (xrefRelation.foundPath) {
-                      xrefPromises.push(
-                        new Promise((res, rej) => {
-                          req
-                            .getXrefThumb(xrefRelation.foundPath)
-                            .then((xrefThumb) => {
-                              srcMap.set(xrefRelation.foundPath, xrefThumb);
-                              res(true);
-                            });
-                        }),
-                      );
-                    }
-                  });
-                  Promise.all(xrefPromises)
-                    .then(() => {
-                      let params = {
-                        docName: data.name,
-                        xrefRelations: xrefRelations,
-                        srcMap: srcMap,
-                      };
-                      ZwCloud2D.ZwDataManager.ZwSetXrefList(params);
-                    })
-                    .catch(() => {
-                      let params = {
-                        docName: data.name,
-                        xrefRelations: xrefRelations,
-                        srcMap: srcMap,
-                      };
-                      ZwCloud2D.ZwDataManager.ZwSetXrefList(params);
-                    });
-                })
-                .catch((error) => {
-                  console.error(error);
-                });
-
-              if (wsUrl) {
-                let url =
-                  wsUrl +
-                  '/CadService?sub=' +
-                  Math.floor(Math.random() * 1000) +
-                  '&docId=' +
-                  docId +
-                  '&dwgPath=' +
-                  dwgPath;
-                ZwCloud2D.ZwDataManager.ZwEntryEdit(url);
-              }
+      break;
+    case signBlockOper.UploadSign:
+    case signBlockOper.UploadCert:
+    case signBlockOper.UploadDwg:
+      req.uploadSign(data).then((res) => {
+        ZwCloud2D.ZwDataManager.ZwSignBlockData({ type, data: res });
+      });
+      break;
+    case signBlockOper.ConFirmEdit:
+      req.saveBlockData(data).then((res) => {
+        ZwCloud2D.ZwDataManager.ZwSignBlockData({ type, data: res });
+      });
+      break;
+    default:
+      break;
+  }
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtSignPanelOperation = (signId) => {
+  req.deleteSign(signId).then((result) => {
+    ZwCloud2D.ZwDataManager.ZwDeleteSignCallback(result);
+  });
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtLoadSignHistoryData = async (data) => {
+  req.getSignHistoryData({ dwgPath }).then((signHistory) => {
+    if (signHistory.length === 0) {
+      ZwCloud2D.ZwDataManager.ZwSetSignHistoryData([]);
+      return;
+    }
+    let attrs = [];
+    let promiseList = [];
+    for (let i = 0; i < signHistory.length; i++) {
+      let block = signHistory[i];
+      let handleId = block.layoutHandle;
+      for (let j = 0; j < block.blockData.length; j++) {
+        let ref = block.blockData[j];
+        for (let k = 0; k < ref.refData.length; k++) {
+          let attr = ref.refData[k];
+          let vv = attr.attrVvector;
+          let uv = attr.attrUvector;
+          let lb = attr.attrInsertPoint;
+          let lt = [lb[0] + vv[0], lb[1] + vv[1], lb[2] + vv[2]];
+          let rb = [lb[0] + uv[0], lb[1] + uv[1], lb[2] + uv[2]];
+          let preAttr = attrs.find((atr) => atr.signId === attr.signId);
+          if (preAttr) {
+            preAttr.position.push({
+              id: attr.signId + '-' + handleId,
+              ptLeftBottom: lb,
+              ptLeftTop: lt,
+              ptRightBottom: rb,
             });
-          })
-          .catch((error) => {
-            console.error(error);
-          });
+          } else {
+            attrs.push({
+              signId: attr.signId,
+              signTime: attr.signTime,
+              name: attr.attrName,
+              signType: attr.type,
+              creator: '',
+              position: [
+                {
+                  id: attr.signId + '-' + handleId,
+                  ptLeftBottom: lb,
+                  ptLeftTop: lt,
+                  ptRightBottom: rb,
+                },
+              ],
+              signFileId: attr.signFileId,
+            });
+          }
+        }
+      }
+    }
+    promiseList = attrs.map((attr) => {
+      return req.downloadSign(attr.signFileId).then((imageData) => {
+        return {
+          ...attr,
+          signData: imageData,
+        };
       });
-    })
-    .catch((error) => {
-      ZwCloud2D.ZwEditor.ZwSetLoadingState(false);
-
-      alert(error);
-      let main = document.getElementById('main');
-      main.style.display = 'unset';
-      let mainMobile = document.getElementById('main-mobile');
-      mainMobile.style.display = 'unset';
-      let showDwgBtn = document.getElementById('showDwgBtn');
-      let showFontBtn = document.getElementById('showFontBtn');
-      showDwgBtn.style.display = 'none';
-      showFontBtn.style.display = 'none';
-
-      resizeCheck();
-      window.addEventListener('resize', resizeCheck);
-      console.error(error);
     });
+
+    Promise.all(promiseList).then((res) => {
+      ZwCloud2D.ZwDataManager.ZwSetSignHistoryData(res);
+    });
+  });
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtLoadDwgFile = () => {
+  req.getDwgFile().then((dwgFile) => {
+    ZwCloud2D.ZwDataManager.ZwSetDwgFileData(dwgFile);
+  });
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtGetTextStyleFont = (data) => {
+  req.getTextStyleFont(data).then((res) => {
+    ZwCloud2D.ZwDataManager.ZwSetTextStyleFont(res.data.name);
+  });
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtUpdateCommentData = async (data) => {
+  let commentList = {
+    code: 0,
+    data: {
+      rows: [data.data],
+    },
+  };
+  ZwCloud2D.ZwDataManager.ZwSetCommentData({ commentList: commentList });
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtFileOperate = async () => {
+  //模拟在移动端触发文件对比功能
+  ZwCloud2D.ZwMessageCallback.ZwEvtFileCompare({ state: 'enterFcmp' });
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtFileCompare = async (data) => {
+  if (data.state === 'enterFcmp') {
+    await ZwCloud2D.ZwDataProcessor.selectBaseDwgAndCompareDwg();
+
+    ZwCloud2D.ZwEditor.ZwSetLoadingState(true);
+
+    await req.getXrefRelation(sourcePath);
+
+    let fcmpInfo = await req
+      .transferFcmp({ sourcePath, compareFilePath })
+      .catch(() => {
+        ZwCloud2D.ZwMessageCallback.ZwEvtFileCompare({ state: 'exitFcmp' });
+        return Promise.reject('');
+      });
+
+    dwgPath = sourcePath;
+
+    let res = await ZwCloud2D.ZwDataManager.ZwSetFcmpDwgInfo(fcmpInfo);
+
+    await ZwCloud2D.ZwDataProcessor.ZwProcessFontData(res.missingFonts);
+
+    ZwCloud2D.ZwDataProcessor.ZwProcessXrefData(
+      sourcePath,
+      fcmpInfo.baseFileName,
+    );
+
+    let fcmpLmfArrayBuffer = await req.getFcmpDisplayData(
+      compareFilePath,
+      sourcePath,
+    );
+
+    ZwCloud2D.ZwDataManager.ZwSetFcmpDwgData(
+      res.layout.handleId,
+      fcmpLmfArrayBuffer,
+      res.timestamp || new Date().getTime(),
+    );
+  }
+  if (data.state === 'getFcmpRegenData') {
+    let fcmpInfo = await req.transferFcmp({
+      sourcePath,
+      compareFilePath,
+      ...data.params,
+    });
+
+    let fcmpLmfArrayBuffer = await req.getFcmpDisplayData(
+      compareFilePath,
+      sourcePath,
+    );
+
+    ZwCloud2D.ZwDataManager.ZwSetFcmpRegenData({
+      lmfData: fcmpLmfArrayBuffer,
+      ...fcmpInfo,
+      fcmpErrorFlag: 0,
+    });
+  }
+  if (data.state === 'exitFcmp') {
+    ZwCloud2D.ZwEditor.ZwSetLoadingState(true);
+
+    ZwCloud2D.ZwDataProcessor.ZwLoad();
+  }
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtGetLayoutHandle = async (data) => {
+  // 获取布局id
+  curHandleId = data;
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtLoadCommentData = async (data) => {
+  getCommentFunc(data);
+};
+ZwCloud2D.ZwMessageCallback.ZwEvtUpdateCommentData = async (data) => {
+  // 评论数据添加到评论面板样例
+  saveCommentFunc(data);
+};
+
+ZwCloud2D.ZwDataProcessor.ZwLoad = async () => {
+  try {
+    ZwCloud2D.ZwDataProcessor.ZwProcessAboutVersionData();
+
+    ZwCloud2D.ZwDataProcessor.ZwProcessPermissionData();
+
+    if (!dwgPath) return;
+
+    let data = await req.transferDoc(dwgPath);
+
+    docId = new Date().getTime().toString();
+
+    let layouts = [];
+    data.layouts.forEach((layout) => {
+      let res = {
+        handleId: layout.handleId,
+        isDefault: layout.isDefault === 1 ? 'YES' : 'NO',
+        name: layout.layoutName,
+        tabOrder: layout.order,
+      };
+      layouts.push(res);
+      if (layout.isDefault === 1) {
+        curHandleId = layout.handleId;
+      }
+    });
+
+    let res = await ZwCloud2D.ZwDataManager.ZwSetDwgInfo({
+      id: docId,
+      fonts: data.fontList,
+      layouts: layouts,
+      name: data.name,
+    });
+
+    await ZwCloud2D.ZwDataProcessor.ZwProcessFontData(res.missingFonts);
+
+    ZwCloud2D.ZwDataProcessor.ZwProcessXrefData(dwgPath, data.name);
+
+    req
+      .getDisplayData(res.layout.handleId)
+      .then((lmfInfo) => {
+        ZwCloud2D.ZwDataManager.ZwSetDwgData(
+          res.layout.handleId,
+          lmfInfo,
+          res.timestamp || new Date().getTime(),
+        );
+      })
+      .catch((error) => {
+        console.error(error);
+      });
+
+    if (wsUrl) {
+      let url =
+        wsUrl +
+        '/CadService?sub=' +
+        Math.floor(Math.random() * 1000) +
+        '&docId=' +
+        docId +
+        '&dwgPath=' +
+        dwgPath;
+      ZwCloud2D.ZwDataManager.ZwEntryEdit(url);
+    }
+  } catch (error) {
+    ZwCloud2D.ZwEditor.ZwSetLoadingState(false);
+
+    alert(error);
+    let main = document.getElementById('main');
+    main.style.display = 'unset';
+    let mainMobile = document.getElementById('main-mobile');
+    mainMobile.style.display = 'unset';
+    let showDwgBtn = document.getElementById('showDwgBtn');
+    let showFontBtn = document.getElementById('showFontBtn');
+    showDwgBtn.style.display = 'none';
+    showFontBtn.style.display = 'none';
+
+    resizeCheck();
+    window.addEventListener('resize', resizeCheck);
+    console.error(error);
+  }
+};
+ZwCloud2D.ZwDataProcessor.ZwFcmpLoad = async () => {
+  ZwCloud2D.ZwDataProcessor.ZwProcessAboutVersionData();
+
+  ZwCloud2D.ZwDataProcessor.ZwProcessPermissionData();
+
+  await req.getXrefRelation(sourcePath);
+
+  let fcmpInfo = await req
+    .transferFcmp({ sourcePath, compareFilePath })
+    .catch(() => {
+      ZwCloud2D.ZwMessageCallback.ZwEvtFileCompare({ state: 'exitFcmp' });
+      return Promise.reject('');
+    });
+
+  dwgPath = sourcePath;
+
+  let res = await ZwCloud2D.ZwDataManager.ZwSetFcmpDwgInfo(fcmpInfo);
+
+  await ZwCloud2D.ZwDataProcessor.ZwProcessFontData(res.missingFonts);
+
+  ZwCloud2D.ZwDataProcessor.ZwProcessXrefData(
+    sourcePath,
+    fcmpInfo.baseFileName,
+  );
+
+  let fcmpLmfArrayBuffer = await req.getFcmpDisplayData(
+    compareFilePath,
+    sourcePath,
+  );
+
+  ZwCloud2D.ZwDataManager.ZwSetFcmpDwgData(
+    res.layout.handleId,
+    fcmpLmfArrayBuffer,
+    res.timestamp || new Date().getTime(),
+  );
 };

+ 41 - 17
public/ZwCloud2DSDK/ZwCloud2DRestfulAPI.js

@@ -3,6 +3,7 @@ let userUrl = 'http://192.168.51.174:9091'
 let appKey = ''
 
 let docId = ''
+let sourceFileId = ''
 
 let fullVersionPermissions = {
     'productName': 'ZW2D_CLOUD_FULL_2024',
@@ -378,10 +379,10 @@ class Request {
         return this.get('/api/js/v1/font/gzip', { fileId: fileId, projectId: 0 }, 'arraybuffer')
     }
 
-    getTransferStatus(){
+    getTransferStatus() {
         let params = { id: docId }
         params = JSON.stringify(params)
-        return this.post('/api/js/v1/doc/transferStatus', params,'json')
+        return this.post('/api/js/v1/doc/transferStatus', params, 'json')
     }
 
     transferDoc() {
@@ -445,6 +446,10 @@ class Request {
         let data = JSON.stringify(params)
         return this.post('/api/js/v1/layout/regen', data, 'arraybuffer')
     }
+
+    getDwgFile(fileId) {
+        return this.get('/api/js/v1/file/download', { id: fileId }, 'arraybuffer')
+    }
 }
 
 ZwCloud2D.ZwDataProcessor.ZwSetConnectUrl = (url1, url2) => {
@@ -560,20 +565,39 @@ ZwCloud2D.ZwDataProcessor.ZwLoad = () => {
             ZwCloud2D.ZwDataManager.ZwSetRegenData(null);
         });
     };
-    let ZwMain=()=>{
+    ZwCloud2D.ZwMessageCallback.ZwEvtLoadDwgFile = () => {
+        ZwCloud2D.ZwEditor.ZwSetLoadingState(true)
+        
+        req.getDwgFile(sourceFileId).then(dwgFile => {
+            ZwCloud2D.ZwDataManager.ZwSetDwgFileData(dwgFile);
+            ZwCloud2D.ZwEditor.ZwSetLoadingState(false)
+        })
+    };
+    ZwCloud2D.ZwMessageCallback.ZwEvtUpdateCommentData = async(data) => {
+        let commentList = {
+            code: 0,
+            data: {
+                rows: [data.data]
+            }
+        };
+        ZwCloud2D.ZwDataManager.ZwSetCommentData({ commentList: commentList });
+    };
+    let ZwMain = () => {
         req.transferDoc().then(data => {
 
+            sourceFileId = data.sourceFileId
+
             ZwCloud2D.ZwDataManager.ZwSetSdkPermission(fullVersionPermissions);
-    
+
             // 显示当前布局的数据
             ZwCloud2D.ZwDataManager.ZwSetDwgInfo({ fonts: data.fonts, layouts: data.layouts, name: data.name }).then(res => {
                 let pArr = []
                 let fontArr = []
-    
+
                 res.missingFonts.forEach(font => {
                     let arr = font.name.split('.');
                     let type = (arr[arr.length - 1] || '').toUpperCase();
-    
+
                     pArr.push(req.fontDownload(font.fileId).then(data => {
                         if (data.byteLength > 0) {
                             fontArr.push(
@@ -586,12 +610,12 @@ ZwCloud2D.ZwDataProcessor.ZwLoad = () => {
                         }
                     }));
                 });
-    
+
                 Promise.all(pArr).then(() => {
                     ZwCloud2D.ZwDataManager.ZwSetFontDataList(fontArr).then(() => {
-    
+
                         req.getDisplayData(res.layout.handleId).then(result => {
-    
+
                             req.getXrefRelation().then(xrefRelations => {
                                 let xrefPromises = [];
                                 let srcMap = new Map();
@@ -613,7 +637,7 @@ ZwCloud2D.ZwDataProcessor.ZwLoad = () => {
                                     ZwCloud2D.ZwDataManager.ZwSetXrefList(params);
                                 });
                             });
-    
+
                             req.getFileInfo(result.lmfId).then(lmfInfo => {
                                 let curTimestamp = new Date(lmfInfo.updateTime || lmfInfo.createTime).getTime();
                                 if (res.hasCache && res.timestamp === curTimestamp.toString()) {
@@ -626,7 +650,7 @@ ZwCloud2D.ZwDataProcessor.ZwLoad = () => {
                             }).catch(error => {
                                 console.error(error)
                             })
-    
+
                         }).catch(error => {
                             console.error(error)
                         })
@@ -639,20 +663,20 @@ ZwCloud2D.ZwDataProcessor.ZwLoad = () => {
             console.error(error)
         });
     }
-    let getTransferStatus=()=>{
-        req.getTransferStatus().then(fileInfo=>{
-            let status=fileInfo.data.status
+    let getTransferStatus = () => {
+        req.getTransferStatus().then(fileInfo => {
+            let status = fileInfo.data.status
             if (status === 1) {
                 let timer = setTimeout(() => {
                     clearTimeout(timer)
                     getTransferStatus()
                 }, 3000);
-            } else if(status === 2) {
+            } else if (status === 2) {
                 ZwMain()
-            }else if(status === 3){
+            } else if (status === 3) {
                 console.error(fileInfo.failedReason)
             }
-        }).catch(err=>{
+        }).catch(err => {
             console.error(err)
         })
     }

File diff suppressed because it is too large
+ 0 - 0
public/ZwCloud2DSDK/ZwWasmJs.js


BIN
public/ZwCloud2DSDK/ZwWasmJs.wasm


BIN
public/ZwCloud2DSDK/ieHelper/setup.zip


File diff suppressed because it is too large
+ 0 - 0
public/ZwCloud2DSDK/readLMFData.js


+ 3 - 3
src/pages/Cad/components/CadOADetail.js

@@ -36,9 +36,9 @@ const CadOADetail = (props) => {
 
   return (
     <Card title="图纸信息">
-      <div>所属项目:{data.project_name}</div>
-      <div>图纸名称:{data.name}</div>
-      <div>版本:{data.version}</div>
+      <div>所属项目:{data?.project_name}</div>
+      <div>图纸名称:{data?.name}</div>
+      <div>版本:{data?.version}</div>
       <Row gutter={20}>
         <Col span={12}>
           <Table dataSource={cadData} columns={columns} />

+ 24 - 18
src/pages/Cad/components/CreateModal.js

@@ -57,6 +57,7 @@ const CreateModal = ({
   const [auditCheck, setAuditCheck] = useState([]);
   const [approvalProcess, setApprovalProcess] = useState([]);
   const pic_type = Form.useWatch('pic_type', form);
+  const [cadPath, setCadPath] = useState([]);
 
   useEffect(() => {
     if (!open) return;
@@ -108,6 +109,20 @@ const CreateModal = ({
     }
   }
 
+  const UploadProps = {
+    action: `http://47.111.24.13:5121/sdk/doc/upload`,
+    multiple: true,
+    // data: { path: '1' },
+    headers: {
+      'JWT-TOKEN': localStorage.getItem('JWT-TOKEN'),
+    },
+    onChange({ file, fileList }) {
+      if (file.status !== 'uploading') {
+        setCadPath([...cadPath, file.response.data.path]);
+      }
+    },
+  };
+
   const handleOk = () => {
     let audit_list = [];
     let cc_list = [];
@@ -129,7 +144,7 @@ const CreateModal = ({
         )?.label;
       if (values.dir_id) values.dir_name = values.dir_id.join(',');
       values.dir_id = 0;
-      if (!values.cad_path) values.cad_path = 'test';
+      if (!values.cad_path) values.cad_path = cadPath.join(',');
       console.log(values, audit_list);
       onOk(values, { audit_list: audit_list.flat(), cc_list: cc_list.flat() });
     });
@@ -174,18 +189,6 @@ const CreateModal = ({
                   children: 'children',
                 }}
               />
-              {/* <Select
-                options={[
-                  {
-                    label: '工艺',
-                    value: 1,
-                  },
-                  {
-                    label: '电气',
-                    value: 2,
-                  },
-                ]}
-              /> */}
             </Form.Item>
             <Form.Item
               name="pic_type"
@@ -210,14 +213,17 @@ const CreateModal = ({
             >
               <Input />
             </Form.Item>
-            <Form.Item name="cad_path" label="上传:">
-              <Button
+            <Form.Item label="上传:">
+              {/* <Button
                 loading={upLoading}
                 icon={<CloudUploadOutlined />}
                 onClick={dwgUpload}
               >
                 上传
-              </Button>
+              </Button> */}
+              <Upload {...UploadProps}>
+                <Button icon={<CloudUploadOutlined />}>Upload</Button>
+              </Upload>
               {form.getFieldValue('cad_path')}
             </Form.Item>
             <Form.Item name="remark" label="备注:">
@@ -234,14 +240,14 @@ const CreateModal = ({
         </Col>
       </Row>
 
-      <input
+      {/* <input
         // multiple
         style={{ display: 'none' }}
         id="uploadDwg"
         type="file"
         onChange={uploadDwg}
         accept=".dwg, .dxf"
-      />
+      /> */}
     </Modal>
   );
 };

+ 1 - 1
src/pages/Cad/detail.js

@@ -14,9 +14,9 @@ const CadDeTail = () => {
     window.ZwCloud2D.ZwEditor.ZwInit(content);
 
     ZwCloud2D.ZwDataProcessor.ZwSetConnectUrl(
-      'http://47.111.24.13:5121',
       'http://47.111.24.13:5121',
       'ws://47.111.24.13:5121',
+      'http://47.111.24.13:5121',
     );
     ZwCloud2D.ZwDataProcessor.ZwSetLoadDwg(path);
     window.ZwCloud2D.ZwDataProcessor.ZwLoad();

+ 1 - 1
src/pages/Cad/index.js

@@ -185,8 +185,8 @@ const CadDemo = () => {
   useEffect(() => {
     ZwCloud2D.ZwDataProcessor.ZwSetConnectUrl(
       'http://47.111.24.13:5121', //47.111.24.13
-      'http://47.111.24.13:5121',
       'ws://47.111.24.13:5121',
+      'http://47.111.24.13:5121',
     );
   }, []);
 

+ 1 - 1
src/pages/Flow/OaAuditDetail.js

@@ -60,7 +60,7 @@ function OaAuditDetail(props) {
     current_seq,
     form,
     OaAuditList,
-    OaCcs,
+    OaCcs = [],
     Files = [],
     audit_status,
     AuditorInfo,

Some files were not shown because too many files changed in this diff