Renxy 1 рік тому
батько
коміт
4851121dc2

+ 1 - 1
src/app.tsx

@@ -62,7 +62,7 @@ export const layout: RunTimeLayoutConfig = (initialState) => {
     logo: logo,
   };
 };
-//修改交给 react-dom 渲染时的根组件
+//修改交给 react-dom 渲染时的根组件 修改antd样式前缀
 export function rootContainer(container) {
   return React.createElement(ConfigProvider, { prefixCls: 'antd5' }, container);
 }

+ 7 - 5
src/pages/Cad/components/CadOADetail.js

@@ -7,14 +7,14 @@ const CadOADetail = (props) => {
   const { data, fileList } = props;
 
   const cadData = data?.cad_path?.split(',').map((item) => {
-    return { name: item };
+    return { path: item };
   });
 
   const columns = [
     {
-      title: '名称',
-      dataIndex: 'name',
-      key: 'name',
+      title: '图纸',
+      dataIndex: 'path',
+      key: 'path',
     },
     {
       title: '操作',
@@ -36,11 +36,13 @@ const CadOADetail = (props) => {
 
   return (
     <Card title="图纸信息">
+      <div>所属项目:{data.project_name}</div>
+      <div>图纸名称:{data.name}</div>
+      <div>版本:{data.version}</div>
       <Row gutter={20}>
         <Col span={12}>
           <Table dataSource={cadData} columns={columns} />
         </Col>
-
         <Col span={12}>
           <AttachmentTable excelFileList={fileList} />
         </Col>

+ 94 - 0
src/pages/Cad/components/CreateChildrenModal.js

@@ -0,0 +1,94 @@
+import { CloudUploadOutlined } from '@ant-design/icons';
+import { Modal, Form, Input, Button } from 'antd';
+import { useEffect, useState } from 'react';
+
+const CreateChildrenModal = ({
+  loading,
+  parentId,
+  open,
+  onOk,
+  handleCancel,
+}) => {
+  const [form] = Form.useForm();
+  const layout = {
+    labelCol: { span: 6 },
+    wrapperCol: { span: 16 },
+  };
+  const [upLoading, setUpLoading] = useState([]);
+
+  useEffect(() => {
+    if (!open) return;
+    form.resetFields();
+  }, [open]);
+
+  function dwgUpload() {
+    let uploadDwg = document.getElementById('uploadDwg');
+    uploadDwg.click();
+  }
+
+  function uploadDwg(event) {
+    const selectedFile = event.target.files[0];
+    if (selectedFile) {
+      setUpLoading(true);
+      ZwCloud2D.ZwDataProcessor.uploadDwg(selectedFile).then((res) => {
+        if (res.code == 200) {
+          const oldPath = form.getFieldValue('cad_path');
+          const cad_path = oldPath
+            ? oldPath + ',' + res.data.path
+            : res.data.path;
+          form.setFieldsValue({ cad_path });
+        }
+        setUpLoading(false);
+      });
+    }
+  }
+
+  const handleOk = () => {
+    form.validateFields().then((values) => {
+      if (!values.cad_path) values.cad_path = 'test';
+      values.parent_id = parentId;
+      console.log(values);
+      onOk(values);
+    });
+  };
+
+  return (
+    <Modal
+      title="新建版本"
+      width={800}
+      open={open}
+      confirmLoading={loading}
+      onOk={handleOk}
+      onCancel={handleCancel}
+    >
+      <Form {...layout} name="basic" form={form}>
+        <Form.Item name="version" label="版本:" rules={[{ required: true }]}>
+          <Input />
+        </Form.Item>
+        <Form.Item name="cad_path" label="上传:">
+          <Button
+            loading={upLoading}
+            icon={<CloudUploadOutlined />}
+            onClick={dwgUpload}
+          >
+            上传
+          </Button>
+          {form.getFieldValue('cad_path')}
+        </Form.Item>
+        <Form.Item name="remark" label="备注:">
+          <Input.TextArea />
+        </Form.Item>
+      </Form>
+
+      <input
+        // multiple
+        style={{ display: 'none' }}
+        id="uploadDwg"
+        type="file"
+        onChange={uploadDwg}
+        accept=".dwg, .dxf"
+      />
+    </Modal>
+  );
+};
+export default CreateChildrenModal;

+ 1 - 4
src/pages/Cad/components/CreateModal.js

@@ -216,12 +216,9 @@ const CreateModal = ({
                 icon={<CloudUploadOutlined />}
                 onClick={dwgUpload}
               >
-                Upload
+                上传
               </Button>
               {form.getFieldValue('cad_path')}
-              {/* <Upload {...UploadProps}>
-            <Button icon={<CloudUploadOutlined />}>Upload</Button>
-          </Upload> */}
             </Form.Item>
             <Form.Item name="remark" label="备注:">
               <Input.TextArea />

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

@@ -10,7 +10,6 @@ const CadDeTail = () => {
   } = location;
 
   useEffect(() => {
-    console.log(window);
     const content = document.getElementById('container');
     window.ZwCloud2D.ZwEditor.ZwInit(content);
 
@@ -19,7 +18,7 @@ const CadDeTail = () => {
       'http://47.111.24.13:5121',
       'ws://47.111.24.13:5121',
     );
-    ZwCloud2D.ZwDataProcessor.ZwSetLoadDwg('SDK-TC-001x.dwg');
+    ZwCloud2D.ZwDataProcessor.ZwSetLoadDwg(path);
     window.ZwCloud2D.ZwDataProcessor.ZwLoad();
   }, []);
   return (

+ 69 - 33
src/pages/Cad/index.js

@@ -10,11 +10,15 @@ import { useRequest, useNavigate } from '@umijs/max';
 import { Table, Button, message, Space, Select, Input } from 'antd';
 import CreateModal from './components/CreateModal';
 import { createAduit } from '@/services/boom';
+import CreateChildrenModal from './components/CreateChildrenModal';
+import { queryCreateCadVer } from '../../services/cad';
 
 const CadDemo = () => {
   let navigate = useNavigate();
   const [createLoading, setCreateLoading] = useState(false);
   const [visible, setVisible] = useState(false);
+  const [childrenVisible, setChildrenVisible] = useState(false);
+  const [parentId, setParentId] = useState();
   const [params, setParams] = useState({
     // project_name: '',
     // name: '',
@@ -39,49 +43,58 @@ const CadDemo = () => {
     },
     {
       title: '状态',
-      dataIndex: 'status',
-      key: 'status',
+      // dataIndex: 'cad_status',
+      // key: 'cad_status',
       width: 100,
-      render: (status) => {
+      render: (record) => {
         let str = '';
         let color = 'black';
-        switch (status) {
+        switch (record.cad_status) {
           case 1:
-            str = '待审核';
-            color = 'blue';
+            str = '已归档';
+            color = 'green';
             break;
           case 2:
-            str = '审核通过';
-            color = 'red';
-            break;
-          case 3:
             str = '审核拒绝';
-            color = 'green';
+            color = 'red';
             break;
+          case 0:
+            str = '待审核';
+            color = 'blue';
         }
-        return <div style={{ color }}>{str}</div>;
+        return record.parent_id ? <div style={{ color }}>{str}</div> : '';
       },
     },
     {
       title: '操作',
       width: '10%',
       render: (record) => {
-        return record.canShow ? (
+        return (
           <Space>
-            <a
-              onClick={() =>
-                navigate('/cad/detail', {
-                  state: {
-                    path: record.name,
-                  },
-                })
-              }
-            >
-              查看
-            </a>
+            {record.canShow && (
+              <a
+                onClick={() =>
+                  navigate('/cad/detail', {
+                    state: {
+                      path: record.name,
+                    },
+                  })
+                }
+              >
+                查看
+              </a>
+            )}
+            {record.showCreate && (
+              <a
+                onClick={() => {
+                  setParentId(record.id);
+                  setChildrenVisible(true);
+                }}
+              >
+                新建
+              </a>
+            )}
           </Space>
-        ) : (
-          ''
         );
       },
     },
@@ -99,9 +112,6 @@ const CadDemo = () => {
   const { data: dirList } = useRequest(queryCadDirList, {
     formatResult: (res) => {
       return res.data;
-      // return res?.data?.list?.map((item) => {
-      //   return { label: item.Name, value: item.ID };
-      // });
     },
   });
 
@@ -112,12 +122,14 @@ const CadDemo = () => {
       res.data?.list?.forEach((item) => {
         item.children?.forEach((cur) => {
           cur.name = item.name + cur.version;
+          item.showCreate = cur.cad_status == 2 ? true : false;
           if (cur.cad_path) {
             const pathList = cur.cad_path.split(',');
             cur.children = pathList.map((item) => {
               return {
                 name: item,
                 canShow: true,
+                parent_id: cur.parent_id,
               };
             });
           }
@@ -127,7 +139,7 @@ const CadDemo = () => {
     },
   });
 
-  //上传
+  //创建审批
   const { run: runCreate } = useRequest(queryCreateCad, {
     manual: true,
     onSuccess: (data) => {
@@ -139,6 +151,23 @@ const CadDemo = () => {
     },
   });
 
+  //创建子审批
+  const { run: runCreateVer, loading: loadingCreateVer } = useRequest(
+    queryCreateCadVer,
+    {
+      manual: true,
+      onSuccess: (data) => {
+        message.success('新建成功');
+        setChildrenVisible(false);
+        // createOARun({
+        //   ...auditListRef.current,
+        //   extend_code: data.cad_id + '',
+        //   extend_type: 2, //2图纸
+        // });
+      },
+    },
+  );
+
   //发起OA审批
   const { run: createOARun } = useRequest(
     (data) => createAduit({ ...data, flow_id: 67, files: '' }),
@@ -155,9 +184,9 @@ const CadDemo = () => {
 
   useEffect(() => {
     ZwCloud2D.ZwDataProcessor.ZwSetConnectUrl(
-      'http://172.16.69.195:9080', //47.111.24.13
-      'http://172.16.69.195:5121',
-      'ws://172.16.69.195:5121',
+      'http://47.111.24.13:5121', //47.111.24.13
+      'http://47.111.24.13:5121',
+      'ws://47.111.24.13:5121',
     );
   }, []);
 
@@ -216,6 +245,13 @@ const CadDemo = () => {
         onOk={handleCreate}
         handleCancel={() => setVisible(false)}
       />
+      <CreateChildrenModal
+        parentId={parentId}
+        loading={loadingCreateVer}
+        open={childrenVisible}
+        onOk={runCreateVer}
+        handleCancel={() => setChildrenVisible(false)}
+      />
     </PageContent>
   );
 };

+ 1 - 0
src/pages/Home/index.js

@@ -110,6 +110,7 @@ function HomePage(props) {
       id: 11,
       name: 'cad管理',
       active: true,
+      permission: true,
       click: () => {
         navigate('/cad');
       },

+ 11 - 0
src/services/cad.js

@@ -5,12 +5,21 @@ export const queryCadList = async (data) => {
     data,
   });
 };
+//创建审批
 export async function queryCreateCad(data) {
   return request(`/api/archive/v1/cad/create`, {
     method: 'POST',
     data,
   });
 }
+
+//创建子审批
+export async function queryCreateCadVer(data) {
+  return request(`/api/archive/v1/cad/create/ver`, {
+    method: 'POST',
+    data,
+  });
+}
 export const queryProject = async () => {
   return await request('/api/v2/project');
 };
@@ -21,12 +30,14 @@ export async function queryCreateCadOld(data) {
     data,
   });
 }
+//请求审批详情
 export async function queryCadInfo(data) {
   return request(`/api/archive/v1/cad/info`, {
     method: 'POST',
     data,
   });
 }
+//请求归档目录列表
 export async function queryCadDirList(data) {
   return request(`/api/archive/v1/cad/dir-list`, {
     method: 'POST',