wzyyy 3 лет назад
Родитель
Сommit
d628ad4688

+ 4 - 4
config/proxy.ts

@@ -12,11 +12,11 @@ export default {
       // target: 'http://192.168.32.28:8844/',
       // ws: 'ws://192.168.32.28:8844/',
       // 开发环境
-      // target: 'http://120.79.18.123:8844/',
-      // ws: 'ws://120.79.18.123:8844/',
+      target: 'http://120.79.18.123:8844/',
+      ws: 'ws://120.79.18.123:8844/',
       // 测试环境
-      target: 'http://120.77.179.54:8844/',
-      ws: 'ws://120.77.179.54:8844/',
+      // target: 'http://120.77.179.54:8844/',
+      // ws: 'ws://120.77.179.54:8844/',
       // target: 'http://192.168.66.5:8844/',
       // ws: 'ws://192.168.66.5:8844/',
       // ws: 'ws://demo.jetlinks.cn/jetlinks',

+ 1 - 1
src/pages/device/Instance/Detail/Modbus/index.tsx

@@ -505,7 +505,7 @@ export default (props: Props) => {
   return (
     <Card className="modbus" style={{ minHeight }}>
       {empty ? (
-        <Empty description={'暂无数据,请配置物模型'} />
+        <Empty description={'暂无数据,请配置物模型'} style={{ marginTop: '10%' }} />
       ) : (
         <>
           <div className="edit-top">

+ 5 - 1
src/pages/link/Channel/Modbus/Export/index.tsx

@@ -11,7 +11,7 @@ import { downloadFile } from '@/utils/util';
 interface Props {
   visible: boolean;
   close: () => void;
-  masterId?: any;
+  data: any;
 }
 
 const Export = (props: Props) => {
@@ -94,9 +94,13 @@ const Export = (props: Props) => {
   };
   const downloadTemplate = async () => {
     const values = (await form.submit()) as any;
+    const masterName = props.data.find((item: any) => item.id === values.masterId)?.name;
     if (values) {
       downloadFile(
         `/${SystemConst.API_BASE}/modbus/point/${values.masterId}/export.${values.fileType}`,
+        {
+          masterName: masterName,
+        },
       );
       close();
     }

+ 23 - 3
src/pages/link/Channel/Modbus/import/index.tsx

@@ -15,10 +15,10 @@ interface Props {
   masterId: any;
 }
 const FileFormat = (props: any) => {
-  const [data, setData] = useState<{ autoDeploy: boolean; fileType: 'xlsx' | 'csv' }>({
-    autoDeploy: false,
+  const [data, setData] = useState<{ fileType: 'xlsx' | 'csv' }>({
     fileType: 'xlsx',
   });
+
   return (
     <Space>
       <Radio.Group
@@ -47,6 +47,7 @@ const NormalUpload = (props: any) => {
   const [count, setCount] = useState<number>(0);
   const [errMessage, setErrMessage] = useState<string>('');
   const [errorUrl, setErrorUrl] = useState<string>('');
+  const [fileName, setFileName] = useState<any>('');
 
   const submitData = async (fileUrl: string) => {
     setErrorUrl(fileUrl);
@@ -92,6 +93,10 @@ const NormalUpload = (props: any) => {
           }}
           onChange={async (info) => {
             if (info.file.status === 'done') {
+              console.log(info.file);
+              const name = info.file.name.split('.')?.[0];
+              setFileName(name);
+              console.log(name);
               const resp: any = info.file.response || { result: '' };
               await submitData(resp?.result || '');
             }
@@ -135,7 +140,22 @@ const NormalUpload = (props: any) => {
               <>
                 <Badge status="error" text="失败" />
                 <span style={{ marginLeft: 15 }}>{errMessage}</span>
-                <a href={errorUrl} style={{ marginLeft: 15 }}>
+                <a
+                  style={{ marginLeft: 15 }}
+                  onClick={() => {
+                    const parms = new XMLHttpRequest();
+                    parms.open('GET', errorUrl, true);
+                    parms.responseType = 'blob';
+                    parms.onload = () => {
+                      const url = window.URL.createObjectURL(parms.response);
+                      const a = document.createElement('a');
+                      a.href = url;
+                      a.download = `${fileName}-${errMessage}`;
+                      a.click();
+                    };
+                    parms.send();
+                  }}
+                >
                   下载
                 </a>
               </>

+ 5 - 7
src/pages/link/Channel/Modbus/index.tsx

@@ -136,7 +136,7 @@ const NewModbus = () => {
             }
           }}
         >
-          <Ellipsis title={currentData[record?.id] || '-'} />
+          <Ellipsis title={currentData[record?.id] || ''} />
         </a>
       ),
     },
@@ -146,7 +146,7 @@ const NewModbus = () => {
       render: (record: any) => (
         <>
           {record.state.value === 'disabled' ? (
-            '-'
+            ''
           ) : (
             <>
               <Badge
@@ -304,7 +304,6 @@ const NewModbus = () => {
           setFilterList(res.result);
           setActiveKey(res.result?.[0]?.id);
           masterId.current = res.result?.[0]?.id;
-          console.log(masterId.current);
         }
       });
   };
@@ -348,7 +347,6 @@ const NewModbus = () => {
         const { pointId, hex } = payload;
         current[pointId] = hex;
         setCurrentData({ ...current });
-        console.log(current);
       });
     return () => wsRef.current && wsRef.current?.unsubscribe();
   }, [pointList]);
@@ -381,7 +379,7 @@ const NewModbus = () => {
                 isPermission={permission.add}
                 key="add"
                 icon={<PlusOutlined />}
-                type="default"
+                type="primary"
                 style={{ width: '100%', marginTop: 16, marginBottom: 16 }}
               >
                 新增
@@ -480,7 +478,7 @@ const NewModbus = () => {
               columns={columns}
               rowKey="id"
               // dataSource={dataSoure}
-              scroll={{ x: 200 }}
+              // scroll={{ x: 200 }}
               search={false}
               headerTitle={
                 <>
@@ -568,7 +566,7 @@ const NewModbus = () => {
         visible={importVisible}
       />
       <Export
-        masterId={activeKey}
+        data={masterList}
         close={() => {
           setExportVisible(false);
           actionRef.current?.reload();

+ 0 - 5
src/pages/link/Channel/Modbus/saveChannel.tsx

@@ -4,9 +4,7 @@ import { Form, FormGrid, FormItem, Input, NumberPicker, Select } from '@formily/
 import type { ISchema } from '@formily/json-schema';
 import { service } from '@/pages/link/Channel/Modbus';
 import { Modal } from '@/components';
-import { useEffect } from 'react';
 import { onlyMessage } from '@/utils/util';
-// import { onlyMessage } from '@/utils/util';
 
 interface Props {
   data: any;
@@ -143,9 +141,6 @@ const SaveChannel = (props: Props) => {
     }
   };
 
-  useEffect(() => {
-    console.log(props.data.id);
-  }, []);
   return (
     <Modal
       title={props.data.id ? '编辑通道' : '新增通道'}

+ 7 - 4
src/pages/link/Channel/Modbus/savePoint.tsx

@@ -44,7 +44,7 @@ const SavePoint = (props: Props) => {
 
   return (
     <Modal
-      title={props.data.id ? '编辑点' : '新增点'}
+      title={props.data.id ? '编辑数据点' : '新增数据点'}
       visible
       width="40vw"
       destroyOnClose
@@ -66,7 +66,10 @@ const SavePoint = (props: Props) => {
               label="名称"
               name="name"
               required
-              rules={[{ required: true, message: '名称必填' }]}
+              rules={[
+                { required: true, message: '名称必填' },
+                { max: 64, message: '最多可输入64个字符' },
+              ]}
             >
               <Input placeholder="请输入名称" />
             </Form.Item>
@@ -93,7 +96,7 @@ const SavePoint = (props: Props) => {
               name="unitId"
               required
               rules={[
-                { required: true, message: '从站ID' },
+                { required: true, message: '从站ID必填' },
                 ({}) => ({
                   validator(_, value) {
                     if (value !== 0 || /(^[1-9]\d*$)/.test(value)) {
@@ -134,7 +137,7 @@ const SavePoint = (props: Props) => {
             <Form.Item
               label="地址"
               name="address"
-              tooltip="要获取的对象地址"
+              tooltip="范围在0x0-0xFFFF"
               rules={[
                 { required: true, message: '请输入读取长度' },
                 ({}) => ({