瀏覽代碼

上传图纸添加path字段

Renxy 1 年之前
父節點
當前提交
8957b0fefd

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

@@ -7,14 +7,17 @@ const CadOADetail = (props) => {
   const { data, fileList } = props;
 
   const cadData = data?.cad_path?.split(',').map((item) => {
-    return { path: item };
+    //item是 地址/图纸名称
+    const names = item.split('/');
+    const name = names?.length > 1 ? names[1] : names[0];
+    return { path: item, name };
   });
 
   const columns = [
     {
       title: '图纸',
-      dataIndex: 'path',
-      key: 'path',
+      dataIndex: 'name',
+      key: 'name',
     },
     {
       title: '操作',

+ 2 - 5
src/pages/Cad/components/CreateModal.js

@@ -1,4 +1,3 @@
-import ModuleTitle from '@/components/ModuleTitle/moduleTitle';
 import { advanceSubmitNextNode } from '@/services/boom';
 import { CloudUploadOutlined } from '@ant-design/icons';
 import { useModel, useRequest } from '@umijs/max';
@@ -15,9 +14,8 @@ import {
   Cascader,
 } from 'antd';
 import { useEffect, useState } from 'react';
-import styles from './index.less';
 import ApprovalProcess from '@/pages/Flow/components/ApprovalProcess';
-
+import { getRandomString } from '@/utils/utils';
 //计算审批流数据
 const advance = {
   flow_id: 67,
@@ -108,11 +106,10 @@ const CreateModal = ({
       });
     }
   }
-
   const UploadProps = {
     action: `http://47.111.24.13:5121/sdk/doc/upload`,
     multiple: true,
-    // data: { path: '1' },
+    data: { path: getRandomString() },
     headers: {
       'JWT-TOKEN': localStorage.getItem('JWT-TOKEN'),
     },

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

@@ -9,6 +9,8 @@ const CadDeTail = () => {
     state: { path },
   } = location;
 
+  console.log('-----path-------', path);
+
   useEffect(() => {
     const content = document.getElementById('container');
     ZwCloud2D.ZwEditor.ZwInit(content);

+ 5 - 2
src/pages/Cad/index.js

@@ -76,7 +76,7 @@ const CadDemo = () => {
                 onClick={() =>
                   navigate('/cad/detail', {
                     state: {
-                      path: record.name,
+                      path: record.path,
                     },
                   })
                 }
@@ -126,8 +126,11 @@ const CadDemo = () => {
           if (cur.cad_path) {
             const pathList = cur.cad_path.split(',');
             cur.children = pathList.map((item) => {
+              const names = item.split('/');
+              const name = names?.length > 1 ? names[1] : names[0];
               return {
-                name: item,
+                name: name,
+                path: item,
                 canShow: true,
                 parent_id: cur.parent_id,
               };

+ 14 - 5
src/utils/utils.js

@@ -4,7 +4,7 @@ export const clearToken = () => {
   localStorage.setItem('JWT-TOKEN', '');
 };
 
-export const storeToken = token => {
+export const storeToken = (token) => {
   localStorage.setItem('JWT-TOKEN', token);
 };
 
@@ -20,7 +20,6 @@ export const getToken = () => {
  * <a href="url" download/>
  */
 export const downloadFile = (url, fileName, encode = true) => {
-  
   const downloadLink = document.createElement('a');
   const body = document.documentElement || document.body;
   body.appendChild(downloadLink);
@@ -49,7 +48,9 @@ export function IsImageFile(fileName) {
 }
 
 export function IsVedio(fileName) {
-  return fileName.lastIndexOf('.mp4') !== -1 || fileName.lastIndexOf('.avi') !== -1;
+  return (
+    fileName.lastIndexOf('.mp4') !== -1 || fileName.lastIndexOf('.avi') !== -1
+  );
 }
 
 export function GetTokenFromUrl() {
@@ -96,7 +97,7 @@ export function getUser(params) {
     return;
   } else {
     return (arr = params
-      .map(item => {
+      .map((item) => {
         return item.Operator?.CName;
       })
       .join(','));
@@ -124,7 +125,7 @@ export const UnityAction = {
   emit(type, e) {
     if (!UnityAction.event[type]) return;
     console.log('emit====== type:', type, '====== event:', e);
-    UnityAction.event[type].forEach(item => {
+    UnityAction.event[type].forEach((item) => {
       item && item(e);
     });
   },
@@ -215,3 +216,11 @@ export function getData(key) {
 export function clearData(key) {
   localStorage.setItem(key, '');
 }
+
+export function getRandomString(length = 6) {
+  var str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+  var result = '';
+  for (var i = length; i > 0; --i)
+    result += str[Math.floor(Math.random() * str.length)];
+  return result;
+}