Kaynağa Gözat

fix: 修改bug

100011797 3 yıl önce
ebeveyn
işleme
0f370bf8d0

BIN
public/images/diagnose copy/back.png


BIN
public/images/diagnose copy/message-error.png


BIN
public/images/diagnose copy/status-error.png


BIN
public/images/diagnose copy/status-success-active.png


BIN
public/images/diagnose copy/status-success.png


BIN
public/images/diagnose copy/status/error.png


BIN
public/images/diagnose copy/status/loading.png


BIN
public/images/diagnose copy/status/success.png


BIN
public/images/diagnose copy/status/warning.png


BIN
public/images/diagnose copy/waiting.png


+ 2 - 2
src/components/FUpload/index.tsx

@@ -20,10 +20,10 @@ const FUpload = connect((props: Props) => {
   const handleChange = async (info: UploadChangeParam) => {
     if (info.file.status === 'done') {
       const result = info.file.response?.result;
-      const api = await service.querySystemApi();
+      const api = await service.querySystemApi(['basePath']);
       const f = {
         ...result,
-        url: `${api?.result?.basePath}file/${result?.id}?accessKey=${result?.others?.accessKey}`,
+        url: `${api?.result[0]?.properties?.basePath}file/${result?.id}?accessKey=${result?.others?.accessKey}`,
       };
       setUrl(f.url);
       props.onChange(f);

+ 31 - 20
src/pages/device/Firmware/Task/Detail/index.tsx

@@ -29,12 +29,14 @@ const state = model<{
   finish: number;
   error: number;
   canceled: number;
+  info: any;
 }>({
   waiting: 0,
   loading: 0,
   finish: 0,
   error: 0,
   canceled: 0,
+  info: {},
 });
 
 const Detail = observer(() => {
@@ -173,6 +175,11 @@ const Detail = observer(() => {
   };
 
   useEffect(() => {
+    service.taskById(params.id).then((resp) => {
+      if (resp.status === 200) {
+        state.info = resp.result;
+      }
+    });
     handleSearch();
   }, [params.id]);
 
@@ -248,7 +255,7 @@ const Detail = observer(() => {
           status: 'success',
         },
         canceled: {
-          text: '已取消',
+          text: '已停止',
           status: 'canceled',
         },
       },
@@ -281,24 +288,28 @@ const Detail = observer(() => {
                   <SearchOutlined />
                 </Tooltip>
               </a>,
-              <Popconfirm
-                key="refresh"
-                onConfirm={async () => {
-                  const resp = await service.startOneTask([record.id]);
-                  if (resp.status === 200) {
-                    message.success('操作成功!');
-                    handleSearch();
-                    actionRef.current?.reload?.();
-                  }
-                }}
-                title={'确认重试'}
-              >
-                <a>
-                  <Tooltip title={'重试'} key={'refresh'}>
-                    <RedoOutlined />
-                  </Tooltip>
-                </a>
-              </Popconfirm>,
+              <>
+                {state.info?.mode?.value === 'push' ? (
+                  <Popconfirm
+                    key="refresh"
+                    onConfirm={async () => {
+                      const resp = await service.startOneTask([record.id]);
+                      if (resp.status === 200) {
+                        message.success('操作成功!');
+                        handleSearch();
+                        actionRef.current?.reload?.();
+                      }
+                    }}
+                    title={'确认重试'}
+                  >
+                    <a>
+                      <Tooltip title={'重试'} key={'refresh'}>
+                        <RedoOutlined />
+                      </Tooltip>
+                    </a>
+                  </Popconfirm>
+                ) : null}
+              </>,
             ]
           : [],
     },
@@ -317,7 +328,7 @@ const Detail = observer(() => {
                     {item.name}
                   </div>
                   <div className={styles.firmwareDetailCardRight}>
-                    {item.key === 'error' && (
+                    {item.key === 'error' && state.info?.mode?.value === 'push' && (
                       <Popconfirm
                         title="确认批量重试"
                         onConfirm={async () => {

+ 16 - 12
src/pages/device/Firmware/Task/index.tsx

@@ -26,13 +26,10 @@ import { service } from '@/pages/device/Firmware';
 
 const UpgradeBtn = (props: { data: any; actions: any }) => {
   const { data, actions } = props;
-  if (data.progress === 100) {
-    return null;
-  }
-  return (
-    <a>
-      <Tooltip title={data.waiting ? '停止' : '继续升级'}>
-        {data.waiting ? (
+  if (data.waiting && data?.state?.value === 'processing') {
+    return (
+      <a>
+        <Tooltip title={'停止'}>
           <StopOutlined
             onClick={async () => {
               const resp = await service.stopTask(data.id);
@@ -42,7 +39,13 @@ const UpgradeBtn = (props: { data: any; actions: any }) => {
               }
             }}
           />
-        ) : (
+        </Tooltip>
+      </a>
+    );
+  } else if (data?.state?.value === 'canceled') {
+    return (
+      <a>
+        <Tooltip title={'继续升级'}>
           <ControlOutlined
             onClick={async () => {
               const resp = await service.startTask(data.id, ['canceled']);
@@ -52,10 +55,11 @@ const UpgradeBtn = (props: { data: any; actions: any }) => {
               }
             }}
           />
-        )}
-      </Tooltip>
-    </a>
-  );
+        </Tooltip>
+      </a>
+    );
+  }
+  return null;
 };
 
 export const state = model<{

+ 9 - 3
src/pages/device/Firmware/service.ts

@@ -4,9 +4,10 @@ import SystemConst from '@/utils/const';
 import type { FirmwareItem } from '@/pages/device/Firmware/typings';
 
 class Service extends BaseService<FirmwareItem> {
-  querySystemApi = () =>
-    request(`/${SystemConst.API_BASE}/system/apis`, {
-      method: 'GET',
+  querySystemApi = (data?: any) =>
+    request(`/${SystemConst.API_BASE}/system/config/scopes`, {
+      method: 'POST',
+      data,
     });
 
   task = (params: Record<string, unknown>) =>
@@ -15,6 +16,11 @@ class Service extends BaseService<FirmwareItem> {
       data: params,
     });
 
+  taskById = (id: string) =>
+    request(`/${SystemConst.API_BASE}/firmware/upgrade/task/${id}`, {
+      method: 'GET',
+    });
+
   saveTask = (data: Record<string, unknown>) =>
     request(`/${SystemConst.API_BASE}/firmware/upgrade/task`, {
       method: 'POST',

+ 6 - 6
src/pages/device/Instance/Detail/Diagnose/Status/index.tsx

@@ -285,7 +285,7 @@ const Status = observer((props: Props) => {
                     key: 'gateway',
                     name: '设备接入网关',
                     desc: desc,
-                    status: 'error',
+                    status: 'warning',
                     text: '可能存在异常',
                     info: (
                       <div>
@@ -416,7 +416,7 @@ const Status = observer((props: Props) => {
                 key: 'gateway',
                 name: '设备接入网关',
                 desc: desc,
-                status: 'error',
+                status: 'warning',
                 text: '可能存在异常',
                 info: (
                   <div>
@@ -965,7 +965,7 @@ const Status = observer((props: Props) => {
                   key: `product-auth${i}`,
                   name: `产品-${item?.name}`,
                   desc: '诊断产品MQTT认证配置是否正确,错误的配置将导致连接失败',
-                  status: 'error',
+                  status: 'warning',
                   text: '可能存在异常',
                   info: (
                     <div>
@@ -1129,7 +1129,7 @@ const Status = observer((props: Props) => {
                   key: `device-auth${i}`,
                   name: `设备-${item?.name}`,
                   desc: '诊断设备MQTT认证配置是否正确,错误的配置将导致连接失败',
-                  status: 'error',
+                  status: 'warning',
                   text: '可能存在异常',
                   info: (
                     <div>
@@ -1409,7 +1409,7 @@ const Status = observer((props: Props) => {
             key: `onenet`,
             name: `设备-OneNet配置`,
             desc: '诊断设备OneNet是否已配置,未配置将导致连接失败',
-            status: 'error',
+            status: 'warning',
             text: '可能存在异常',
             info: (
               <div>
@@ -1524,7 +1524,7 @@ const Status = observer((props: Props) => {
             key: `ctwing`,
             name: `设备-CTWing配置`,
             desc: '诊断设备CTWing是否已配置,未配置将导致连接失败',
-            status: 'error',
+            status: 'warning',
             text: '可能存在异常',
             info: (
               <div>

+ 1 - 1
src/pages/device/Instance/Detail/Diagnose/Status/model.ts

@@ -13,7 +13,7 @@ export const TextColorMap = new Map();
 TextColorMap.set('loading', 'black');
 TextColorMap.set('error', 'red');
 TextColorMap.set('success', 'green');
-TextColorMap.set('warning', 'red');
+TextColorMap.set('warning', '#FAB247');
 
 export type ListProps = {
   key: string;

+ 8 - 13
src/pages/link/Type/Detail/index.tsx

@@ -14,8 +14,9 @@ import {
   Select,
 } from '@formily/antd';
 import type { ISchema } from '@formily/json-schema';
-import { useEffect, useMemo, useRef } from 'react';
-import { Field, FieldDataSource, onFormInit } from '@formily/core';
+import { useMemo, useRef } from 'react';
+import type { Field, FieldDataSource } from '@formily/core';
+import { onFormInit } from '@formily/core';
 import { createForm, onFieldReact, onFieldValueChange } from '@formily/core';
 import { Card, Col, Row } from 'antd';
 import styles from './index.less';
@@ -58,16 +59,6 @@ const Save = observer(() => {
 
   const configRef = useRef([]);
 
-  useEffect(() => {
-    service.getResourcesCurrent().then((resp) => {
-      if (resp.status === 200) {
-        // setConfig(resp.result);
-        // console.log('test', resp);
-        configRef.current = resp.result;
-      }
-    });
-  }, []);
-
   const useAsyncData = (services: (arg0: Field) => Promise<FieldDataSource>) => (field: Field) => {
     field.loading = true;
     services(field).then(
@@ -122,6 +113,10 @@ const Save = observer(() => {
         // initialValues: {},
         effects() {
           onFormInit(async (form1) => {
+            const response = await service.getResourcesCurrent();
+            if (response.status === 200) {
+              configRef.current = response.result;
+            }
             if (param?.id && param.id !== ':id') {
               const resp = await service.detail(param.id);
               const data = resp?.result || {};
@@ -156,7 +151,7 @@ const Save = observer(() => {
             f.setFieldState('grid.configuration.panel1.layout2.host', (state) => {
               state.dataSource = _host.map((item) => ({ label: item.host, value: item.host }));
             });
-            f.setFieldState('cluster.config.*.host', (state) => {
+            f.setFieldState('grid.cluster.cluster.*.layout2.host', (state) => {
               state.dataSource = _host.map((item) => ({ label: item.host, value: item.host }));
             });
           });