Renxy 1 жил өмнө
parent
commit
ed18867e95

+ 22 - 4
.umirc.ts

@@ -34,13 +34,19 @@ export default defineConfig({
   //   },
   // ],
   // scripts: [
-  //   { src: 'http://localhost:3000/plugins/js/plugin.js' },
-  //   { src: 'http://localhost:3000/luckysheet.umd.js' },
+  //   { src: '/ZwCloud2DSDK/ZwCloud2D.js' },
+  //   { src: '/ZwCloud2DSDK/ZwWasmJs.js' },
+  //   { src: '/ZwCloud2DSDK/ZwCloud2DAPI.js' },
   // ],
+  headScripts: [
+    '/ZwCloud2DSDK/ZwCloud2D.js',
+    '/ZwCloud2DSDK/ZwWasmJs.js',
+    '/ZwCloud2DSDK/ZwCloud2DPrivateAPI.js',
+  ],
   proxy: {
     '/api': {
-      // target: 'http://47.96.12.136:8888/',
-      target: 'http://47.96.12.136:8895/',
+      target: 'http://192.168.20.232:1007/',
+      // target: 'http://47.96.12.136:8895/',
       // target: 'https://work.greentech.com.cn/',
       changeOrigin: true,
     },
@@ -206,6 +212,18 @@ export default defineConfig({
       component: './PSRManage/detail',
       hideInMenu: true,
     },
+    {
+      name: 'CAD实例',
+      path: '/cad',
+      component: './Cad',
+      icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/manufacturerIcon.png',
+    },
+    {
+      name: 'CAD详情',
+      path: '/cad/detail',
+      component: './Cad/detail',
+      hideInMenu: true,
+    },
   ],
   npmClient: 'yarn',
 });

+ 0 - 0
src/assets/ZwCloud2DSDK/ZwCloud2D.d.ts → public/ZwCloud2DSDK/ZwCloud2D.d.ts


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 1 - 0
public/ZwCloud2DSDK/ZwCloud2D.js


+ 465 - 0
public/ZwCloud2DSDK/ZwCloud2DPrivateAPI.js

@@ -0,0 +1,465 @@
+let baseUrl = 'http://192.168.51.174:5199';
+let wsUrl = '';
+let dwgPath = '';
+let javaUrl = '';
+
+class Request {
+  constructor() {}
+
+  get(url, params, resType, type) {
+    return new Promise((res, rej) => {
+      let paramsArr = [];
+      for (let k in params) {
+        paramsArr.push(
+          encodeURIComponent(k) + '=' + encodeURIComponent(params[k]),
+        );
+      }
+      url = url + '?' + paramsArr.join('&');
+      let ajax = new XMLHttpRequest();
+      let checkUrl = type === 'java' ? javaUrl + url : baseUrl + url;
+      ajax.open('GET', checkUrl);
+      resType && (ajax.responseType = resType);
+      ajax.send();
+      ajax.onload = function () {
+        if (resType) res(ajax.response);
+        else {
+          let data = JSON.parse(ajax.response);
+          if (data.code === 0) {
+            res(data.data);
+          } else {
+            rej(data.msg);
+          }
+        }
+      };
+    });
+  }
+
+  post(url, params, resType, type) {
+    return new Promise((res, rej) => {
+      let ajax = new XMLHttpRequest();
+      let checkUrl = type === 'java' ? javaUrl + url : baseUrl + url;
+      ajax.open('POST', checkUrl);
+      resType && (ajax.responseType = resType);
+      if (!(params instanceof FormData)) {
+        ajax.setRequestHeader('content-type', 'application/json');
+      }
+      ajax.send(params);
+      ajax.onreadystatechange = function () {
+        if (ajax.readyState === 4) {
+          if (ajax.status === 200) {
+            res(ajax.response);
+          } else {
+            rej();
+          }
+        }
+      };
+    });
+  }
+
+  arrayBufferToBase64(buffer) {
+    let binary = '';
+    let bytes = new Uint8Array(buffer);
+    let len = bytes.byteLength;
+    for (let i = 0; i < len; i++) {
+      binary += String.fromCharCode(bytes[i]);
+    }
+    return btoa(binary);
+  }
+
+  fontDownload(fontName) {
+    return this.get('/sdk/font/download', { fontName }, 'blob');
+  }
+
+  transferDoc() {
+    return this.get('/sdk/transfer', {
+      projectId: 0,
+      dwgPath: dwgPath,
+      type: 1,
+    });
+  }
+
+  getDisplayData(handleId = 34) {
+    return this.get(
+      '/sdk/layout/lmf',
+      { projectId: 0, handleId, dwgPath: dwgPath },
+      'arraybuffer',
+    );
+  }
+
+  getXrefData(handleId, xrefIds) {
+    let params = { handleId: handleId, xrefIds: xrefIds, dwgPath: dwgPath };
+    params = JSON.stringify(params);
+    return this.post('/sdk/xref', params, 'arraybuffer');
+  }
+
+  getXrefRelation() {
+    return this.get('/sdk/xref/list', { dwgPath: dwgPath });
+  }
+
+  getXrefThumb(filePath) {
+    return this.get(
+      '/sdk/xref/thumb',
+      { filePath: filePath },
+      'arraybuffer',
+    ).then((res) => {
+      let url = this.arrayBufferToBase64(res);
+      return 'data:image/jpeg;base64,' + url;
+    });
+  }
+  getPlotData(params) {
+    let data = JSON.stringify(params);
+    return this.post('/sdk/print', data, 'arraybuffer');
+  }
+  getImageSrc(filePath) {
+    return this.get(
+      '/sdk/image/download',
+      { filePath: filePath },
+      'arraybuffer',
+    ).then((res) => {
+      let url = this.arrayBufferToBase64(res);
+      return 'data:image/jpeg;base64,' + url;
+    });
+  }
+  getImageData(filePath) {
+    return this.get(
+      '/sdk/image/download',
+      { filePath: filePath },
+      'arraybuffer',
+    );
+  }
+  getImageList() {
+    return this.get('/sdk/image/list');
+  }
+  getPermissionList() {
+    return this.get('/sdk/getStatus');
+  }
+  getRegenData(params) {
+    Object.assign(params, { dwgPath: dwgPath });
+    let data = JSON.stringify(params);
+    return this.post('/sdk/regen', data, 'arraybuffer');
+  }
+  getDwgFile() {
+    return this.get(
+      '/sdk/doc/download',
+      { dwgPath: dwgPath },
+      'arrayBuffer',
+      'java',
+    );
+  }
+  uploadFile(file) {
+    let formData = new FormData();
+    formData.append('file', file);
+    return this.post('/sdk/doc/upload', formData, 'json', 'java');
+  }
+}
+
+function resizeCheck() {
+  if (Date.now() - timer > 400) {
+    const windowInfo = {
+      width: window.innerWidth,
+      height: window.innerHeight,
+    };
+    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';
+    }
+    timer = Date.now();
+  }
+}
+
+ZwCloud2D.ZwDataProcessor.ZwSetConnectUrl = (url1, url2, url3) => {
+  javaUrl = url1;
+  baseUrl = url2;
+  wsUrl = 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 => {
+  //     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"
+  // })
+};
+
+ZwCloud2D.ZwDataProcessor.uploadFont = (file) => {
+  let req = new Request();
+  let pArray = new Array();
+  for (let i = 0; i < file.length; i++) {
+    pArray.push(
+      new Promise((resolve, reject) => {
+        req.uploadFile(file[i]).then((res) => {
+          if (res.code === 200) {
+            resolve();
+          } else {
+            reject();
+          }
+        });
+      }),
+    );
+  }
+  Promise.all(pArray)
+    .then(() => {
+      alert('上传成功');
+    })
+    .catch(() => {
+      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.ZwMessageCallback.ZwEvtDrawEnd = () => {};
+
+  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);
+            });
+        }),
+      );
+    });
+    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;
+        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 });
+    req
+      .getPlotData(params)
+      .then((res) => {
+        ZwCloud2D.ZwDataManager.ZwSetPlotData(data, res);
+        ZwCloud2D.ZwEditor.ZwSetLoadingState(false);
+      })
+      .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.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);
+              }
+            });
+          })
+          .catch((error) => {
+            console.error(error);
+          });
+      });
+    })
+    .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);
+    });
+};

+ 0 - 0
src/assets/ZwCloud2DSDK/ZwCloud2DRestfulAPI.js → public/ZwCloud2DSDK/ZwCloud2DRestfulAPI.js


+ 0 - 0
src/assets/ZwCloud2DSDK/ZwWasmJs.js → public/ZwCloud2DSDK/ZwWasmJs.js


BIN
src/assets/ZwCloud2DSDK/ZwWasmJs.wasm → public/ZwCloud2DSDK/ZwWasmJs.wasm


+ 0 - 0
src/assets/ZwCloud2DSDK/adinit.dat → public/ZwCloud2DSDK/adinit.dat


BIN
public/ZwCloud2DSDK/home_m.png


BIN
public/ZwCloud2DSDK/image1.png


BIN
public/ZwCloud2DSDK/image2.png


+ 0 - 0
src/assets/ZwCloud2DSDK/readLMFData.js → public/ZwCloud2DSDK/readLMFData.js


BIN
public/ZwCloud2DSDK/text.png


+ 0 - 0
src/assets/ZwCloud2DSDK/textGlyph/SimSun-01.ttf → public/ZwCloud2DSDK/textGlyph/SimSun-01.ttf


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 1
src/assets/ZwCloud2DSDK/ZwCloud2D.js


+ 0 - 281
src/assets/ZwCloud2DSDK/ZwCloud2DPrivateAPI.js

@@ -1,281 +0,0 @@
-let baseUrl = 'http://192.168.51.174:5199'
-let wsUrl = ''
-let dwgPath = ''
-
-class Request {
-    constructor() {
-    }
-
-    get(url, params, resType) {
-        return new Promise((res, rej) => {
-            let paramsArr = []
-            for (let k in params) {
-                paramsArr.push(encodeURIComponent(k) + '=' + encodeURIComponent(params[k]))
-            }
-            url = url + '?' + paramsArr.join('&')
-            let ajax = new XMLHttpRequest()
-            ajax.open('GET', baseUrl + url)
-            resType && (ajax.responseType = resType)
-            ajax.send()
-            ajax.onload = function () {
-                if (resType) res(ajax.response)
-                else {
-                    let data = JSON.parse(ajax.response)
-                    if (data.code === 0) {
-                        res(data.data)
-                    }else{
-                        rej(data.msg)
-                    }
-                }
-            }
-        })
-    }
-
-    post(url, params, resType) {
-        return new Promise((res, rej) => {
-            let ajax = new XMLHttpRequest()
-            ajax.open('POST', baseUrl + url)
-            resType && (ajax.responseType = resType)
-            ajax.setRequestHeader('content-type', 'application/json')
-            ajax.send(params)
-            ajax.onreadystatechange = function () {
-                if (ajax.readyState === 4) {
-                    if (ajax.status === 200) {
-                        res(ajax.response)
-                    } else {
-                        rej()
-                    }
-                }
-            }
-        })
-    }
-
-    arrayBufferToBase64(buffer) {
-        let binary = '';
-        let bytes = new Uint8Array(buffer);
-        let len = bytes.byteLength;
-        for (let i = 0; i < len; i++) {
-            binary += String.fromCharCode(bytes[i]);
-        }
-        return btoa(binary);
-    }
-
-    fontDownload(fontName) {
-        return this.get('/sdk/font/download', { fontName }, 'blob')
-    }
-
-    transferDoc() {
-        return this.get('/sdk/transfer', { projectId: 0, dwgPath: dwgPath })
-    }
-
-    getDisplayData(handleId = 34) {
-        return this.get('/sdk/layout/lmf', { projectId: 0, handleId, dwgPath: dwgPath }, 'arraybuffer')
-    }
-
-    getXrefData(handleId, xrefIds) {
-        let params = { handleId: handleId, xrefIds: xrefIds, dwgPath: dwgPath }
-        params = JSON.stringify(params)
-        return this.post('/sdk/xref', params, 'arraybuffer')
-    }
-
-    getXrefRelation() {
-        return this.get('/sdk/xref/list', { dwgPath: dwgPath })
-    }
-
-    getXrefThumb(filePath) {
-        return this.get('/sdk/xref/thumb', { filePath: filePath }, 'arraybuffer').then(res => {
-            let url = this.arrayBufferToBase64(res);
-            return 'data:image/jpeg;base64,' + url;
-        })
-    }
-    getPlotData(params) {
-        let data = JSON.stringify(params)
-        return this.post('/sdk/print', data, 'arraybuffer')
-    }
-    getImageSrc(filePath) {
-        return this.get('/sdk/image/download', { filePath: filePath }, 'arraybuffer').then(res => {
-            let url = this.arrayBufferToBase64(res);
-            return 'data:image/jpeg;base64,' + url;
-        })
-    }
-    getImageData(filePath) {
-        return this.get('/sdk/image/download', { filePath: filePath }, 'arraybuffer')
-    }
-    getImageList() {
-        return this.get('/sdk/image/list')
-    }
-    getPermissionList() {
-        return this.get('/sdk/getStatus')
-    }
-    getRegenData(params) {
-        Object.assign(params, { dwgPath: dwgPath })
-        let data = JSON.stringify(params)
-        return this.post('/sdk/regen', data, 'arraybuffer')
-    }
-}
-
-ZwCloud2D.ZwDataProcessor.ZwSetConnectUrl = (url1, url2) => {
-    baseUrl = url1;
-    wsUrl = url2
-}
-ZwCloud2D.ZwDataProcessor.ZwSetLoadDwg = (path) => {
-    dwgPath = path;
-}
-
-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.ZwMessageCallback.ZwEvtDrawEnd = () => {
-    };
-
-    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);
-                });
-            }));
-        });
-        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
-                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 })
-        req.getPlotData(params).then(res => {
-            ZwCloud2D.ZwDataManager.ZwSetPlotData(data, res);
-            ZwCloud2D.ZwEditor.ZwSetLoadingState(false);
-        }).catch(error=>{
-            console.error(error)
-        })
-    };
-    req.getPermissionList().then(data => {
-        ZwCloud2D.ZwDataManager.ZwSetSdkPermission(data);
-    }).catch(error=>{
-        console.error(error)
-    })
-    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.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);
-                    }
-                })
-            }).catch(error=>{
-                console.error(error)
-            })
-        });
-    }).catch(error=>{
-        console.error(error)
-    });
-}

+ 17 - 0
src/pages/Cad/components/UploadModal.js

@@ -0,0 +1,17 @@
+import { Checkbox, Modal, message, Space, Divider } from 'antd';
+import { useEffect, useMemo, useRef, useState } from 'react';
+import dayjs from 'dayjs';
+
+const UploadModal = ({ open, onCancel, onOk }) => {
+  useEffect(() => {}, [open]);
+  return (
+    <Modal
+      title="上传"
+      open={open}
+      onCancel={onCancel}
+      onOk={() => onOk(values)}
+      destroyOnClose
+    ></Modal>
+  );
+};
+export default UploadModal;

+ 37 - 0
src/pages/Cad/detail.js

@@ -0,0 +1,37 @@
+import { useRef, useEffect } from 'react';
+import PageContent from '@/components/PageContent';
+import { useLocation, useNavigate } from '@umijs/max';
+
+const CadDeTail = () => {
+  const cadRef = useRef();
+  const location = useLocation();
+  const {
+    state: { path },
+  } = location;
+
+  useEffect(() => {
+    console.log(window);
+    const content = document.getElementById('container');
+    window.ZwCloud2D.ZwEditor.ZwInit(content);
+
+    ZwCloud2D.ZwDataProcessor.ZwSetConnectUrl(
+      'http://222.130.26.205:9080',
+      'http://222.130.26.205:5121',
+      'ws://222.130.26.205:5121',
+    );
+    ZwCloud2D.ZwDataProcessor.ZwSetLoadDwg(path);
+    window.ZwCloud2D.ZwDataProcessor.ZwLoad();
+  }, []);
+  return (
+    <PageContent>
+      <div>CAD在线审批</div>
+      <div
+        id="container"
+        style={{ width: '100%', height: '80vh' }}
+        ref={cadRef}
+      />
+    </PageContent>
+  );
+};
+
+export default CadDeTail;

+ 134 - 24
src/pages/Cad/index.js

@@ -1,35 +1,145 @@
-import { useRef, useEffect } from 'react';
+import { useRef, useEffect, useState } from 'react';
 import PageContent from '@/components/PageContent';
+import { queryCadList, queryCreateCad } from '@/services/cad';
+import { useRequest, useNavigate } from '@umijs/max';
+import { Table, Button, message, Space } from 'antd';
 
 const CadDemo = () => {
-  const ref = useRef();
+  let navigate = useNavigate();
+  const columns = [
+    {
+      title: '名称',
+      dataIndex: 'name',
+      key: 'name',
+      align: 'center',
+      width: 160,
+    },
+    {
+      title: '创建人',
+      dataIndex: 'created_by',
+      key: 'created_by',
+      align: 'center',
+      width: 120,
+    },
+    {
+      title: '创建时间',
+      dataIndex: 'created_on',
+      key: 'created_on',
+      align: 'center',
+      width: 100,
+    },
+    {
+      title: '状态',
+      dataIndex: 'status',
+      key: 'status',
+      align: 'center',
+      width: 100,
+      render: (status) => {
+        let str = '';
+        let color = 'black';
+        switch (status) {
+          case 1:
+            str = '待审核';
+            color = 'blue';
+            break;
+          case 2:
+            str = '审核通过';
+            color = 'red';
+            break;
+          case 3:
+            str = '审核拒绝';
+            color = 'green';
+            break;
+        }
+        return <div style={{ color }}>{str}</div>;
+      },
+    },
+    {
+      title: '操作',
+      align: 'center',
+      width: '10%',
+      render: (record) => (
+        <Space>
+          <a
+            onClick={() =>
+              navigate('/cad/detail', {
+                state: {
+                  path: record.path,
+                },
+              })
+            }
+          >
+            详情
+          </a>
+          <a onClick={() => {}}>提审</a>
+        </Space>
+      ),
+    },
+  ];
+  const [uploading, setUpLoading] = useState(false);
+
+  //请求列表
+  const { data, run, loading } = useRequest(queryCadList);
+
+  //上传
+  const { run: runCreate } = useRequest((data) => queryCreateCad(data), {
+    manual: true,
+    onSuccess: () => {
+      run();
+      message.success('上传成功');
+      setUpLoading(false);
+    },
+  });
 
   useEffect(() => {
-    // window.Module.onRuntimeInitialized = () => {
-    //   window.ZwCloud2D.ZwEditor.ZwInit(ref.current);
-    //   // PrivateAPI
-    //   window.ZwCloud2D.ZwDataProcessor.ZwSetConnectUrl(
-    //     'http://222.130.26.205:5121/index.html',
-    //   );
-    //   window.ZwCloud2D.ZwDataProcessor.ZwSetLoadDwg('SDK-TC-001x.dwg');
-    //   // RestfulAPI
-    //   // ZwCloud2D.ZwDataProcessor.ZwSetConnectUrl('http://192.168.51.174:9091');
-    //   // ZwCloud2D.ZwDataProcessor.ZwSetLoadDwg('1595655235900768256');
-    //   window.ZwCloud2D.ZwDataProcessor.ZwLoad();
-    // };
+    ZwCloud2D.ZwDataProcessor.ZwSetConnectUrl(
+      'http://222.130.26.205:9080',
+      'http://222.130.26.205:5121',
+      'ws://222.130.26.205:5121',
+    );
   }, []);
+
+  function uploadDwg(event) {
+    const selectedFile = event.target.files[0];
+    if (selectedFile) {
+      // ZwCloud2D.ZwEditor.ZwSetLoadingState(true);
+      setUpLoading(true);
+      ZwCloud2D.ZwDataProcessor.uploadDwg(selectedFile).then((res) => {
+        if (res.code == 200) {
+          runCreate({ name: res.data.name, path: res.data.path });
+        }
+        setUpLoading(false);
+      });
+    }
+  }
+  function dwgUpload() {
+    let uploadDwg = document.getElementById('uploadDwg');
+    uploadDwg.click();
+  }
+
   return (
     <PageContent>
-      <div>CAD在线审批</div>
-      {/* <div style={{ width: '100%', height: '80%' }} ref={ref}></div> */}
-      <iframe
-        style={{
-          width: '100%',
-          height: '80vh',
-        }}
-        ref={ref}
-        onLoad={() => {}}
-        src="http://222.130.26.205:5121/index.html?dwgPath=SDK-TC-001x.dwg"
+      <Button type="primary" onClick={dwgUpload}>
+        上传
+      </Button>
+      <Table
+        loading={loading}
+        columns={columns}
+        dataSource={data?.list}
+        indentSize={70}
+        // pagination={{
+        //   ...pagination,
+        //   showSizeChanger: false,
+        //   onChange: onPageChange,
+        // }}
+      />
+      {/* <div id="container"></div> */}
+      <input
+        style={{ display: 'none' }}
+        id="uploadDwg"
+        type="file"
+        onChange={uploadDwg}
+        accept=".dwg, .dxf"
       />
     </PageContent>
   );

+ 10 - 0
src/services/cad.js

@@ -0,0 +1,10 @@
+import { request } from 'umi';
+export const queryCadList = async () => {
+  return await request('/api/contract/v1/cad');
+};
+export async function queryCreateCad(data) {
+  return request(`/api/contract/v1/cad`, {
+    method: 'POST',
+    data,
+  });
+}

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно