Kaynağa Gözat

fix(instance): fix instance

Lind 3 yıl önce
ebeveyn
işleme
93d4d4842e

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

@@ -120,8 +120,8 @@ const Config = () => {
                             configuration: { ...values },
                           };
                         }
-                        setState(!state);
                       }
+                      setState(!state);
                     }}
                   >
                     {state ? '编辑' : '保存'}

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

@@ -5,7 +5,7 @@ import Property from '@/pages/device/Instance/Detail/Running/Property';
 import Event from '@/pages/device/Instance/Detail/Running/Event';
 
 const Running = () => {
-  const metadata = JSON.parse(InstanceModel.detail.metadata as string) as DeviceMetadata;
+  const metadata = JSON.parse((InstanceModel.detail?.metadata || '{}') as string) as DeviceMetadata;
 
   return (
     <Card>

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

@@ -29,7 +29,7 @@ const InstanceDetail = observer(() => {
     service.detail(id).then((response) => {
       InstanceModel.detail = response?.result;
       // 写入物模型数据
-      const metadata: DeviceMetadata = JSON.parse(response.result?.metadata);
+      const metadata: DeviceMetadata = JSON.parse(response.result?.metadata || '{}');
       MetadataAction.insert(metadata);
     });
   };

+ 1 - 1
src/pages/device/Product/Detail/BaseInfo/index.tsx

@@ -112,8 +112,8 @@ const BaseInfo = () => {
                         message.success('操作成功!');
                         getDetailInfo();
                       }
-                      setState(!state);
                     }
+                    setState(!state);
                   }}
                 >
                   {state ? (

+ 12 - 10
src/pages/link/AccessConfig/Detail/Access/index.tsx

@@ -498,16 +498,18 @@ const Access = (props: Props) => {
 
   return (
     <Card>
-      <Button
-        type="link"
-        onClick={() => {
-          props.change();
-          setNetworkCurrent('');
-          setProcotolCurrent('');
-        }}
-      >
-        返回
-      </Button>
+      {props.data?.id && (
+        <Button
+          type="link"
+          onClick={() => {
+            props.change();
+            setNetworkCurrent('');
+            setProcotolCurrent('');
+          }}
+        >
+          返回
+        </Button>
+      )}
       <div className={styles.box}>
         <div className={styles.steps}>
           <Steps size="small" current={current}>

+ 2 - 1
src/pages/link/Protocol/FileUpload/index.tsx

@@ -2,7 +2,7 @@ import SystemConst from '@/utils/const';
 import Token from '@/utils/token';
 import { useState } from 'react';
 import { connect } from '@formily/react';
-import { Button, Input, Upload } from 'antd';
+import { Button, Input, message, Upload } from 'antd';
 import type { UploadChangeParam } from 'antd/lib/upload/interface';
 
 interface Props {
@@ -16,6 +16,7 @@ const FileUpload = connect((props: Props) => {
 
   const handleChange = (info: UploadChangeParam) => {
     if (info.file.status === 'done') {
+      message.success('上传成功!');
       info.file.url = info.file.response?.result;
       setUrl(info.file.response?.result);
       props.onChange(info.file.response?.result);

+ 2 - 2
src/pages/link/Protocol/index.tsx

@@ -106,7 +106,7 @@ const Protocol = () => {
             </Popconfirm>
           </a>
         ),
-        <a key="delete">
+        <Button key="delete" type="link" disabled={record.state !== 1}>
           <Popconfirm
             title={intl.formatMessage({
               id: 'pages.data.option.remove.tips',
@@ -132,7 +132,7 @@ const Protocol = () => {
               <DeleteOutlined />
             </Tooltip>
           </Popconfirm>
-        </a>,
+        </Button>,
       ],
     },
   ];

+ 6 - 2
src/pages/link/Type/Save/index.tsx

@@ -704,8 +704,12 @@ const Save = observer(() => {
       message.success('保存成功');
       history.back();
       if ((window as any).onTabSaveSuccess) {
-        (window as any).onTabSaveSuccess(response);
-        setTimeout(() => window.close(), 300);
+        if (response.result?.id) {
+          service.changeState(response.result?.id, 'start').then(() => {
+            (window as any).onTabSaveSuccess(response);
+            setTimeout(() => window.close(), 300);
+          });
+        }
       }
     }
   };

+ 73 - 67
src/pages/system/Role/Edit/Permission/Allocate/MenuPermission.tsx

@@ -73,78 +73,84 @@ const MenuPermission = (props: Props) => {
         </div>
         <div
           style={{
+            display: 'flex',
+            alignItems: 'center',
             width: `calc(50% - ${(props?.level || 0) * 5}px)`,
             borderRight: '1px solid #f0f0f0',
           }}
         >
-          <Checkbox
-            indeterminate={indeterminate}
-            checked={checkAll}
-            style={{
-              padding: '10px 0',
-              width: 250 - (props?.level || 0) * 10,
-              borderRight: '1px solid #f0f0f0',
-              marginRight: 20,
-              fontWeight: value.id === 'menu-permission' ? 600 : 400,
-            }}
-            onChange={(e) => {
-              setCheckAll(e.target.checked);
-              setIndeterminate(false);
-              const buttons = (value?.buttons || []).map((i: any) => {
-                return {
-                  ...i,
-                  enabled: e.target.checked,
-                };
-              });
-              console.log(e.target.checked);
-              props.change({
-                ...value,
-                check: e.target.checked ? 1 : 3, // 1: 全选 2: 只选了部分 3: 一个都没选
-                buttons: [...buttons],
-                children: checkAllData(value.children || [], e.target.checked),
-              });
-            }}
-          >
-            {value?.name}
-          </Checkbox>
-          <Checkbox.Group
-            name={value?.id}
-            value={_.map(
-              (value?.buttons || []).filter((i: any) => i?.enabled),
-              'id',
-            )}
-            onChange={(data: CheckboxValueType[]) => {
-              const buttons = value.buttons.map((i: any) => {
-                return {
-                  ...i,
-                  enabled: data.includes(i.id),
+          <div>
+            <Checkbox
+              indeterminate={indeterminate}
+              checked={checkAll}
+              style={{
+                padding: '10px 0',
+                width: 250 - (props?.level || 0) * 10,
+                borderRight: '1px solid #f0f0f0',
+                marginRight: 20,
+                fontWeight: value.id === 'menu-permission' ? 600 : 400,
+              }}
+              onChange={(e) => {
+                setCheckAll(e.target.checked);
+                setIndeterminate(false);
+                const buttons = (value?.buttons || []).map((i: any) => {
+                  return {
+                    ...i,
+                    enabled: e.target.checked,
+                  };
+                });
+                console.log(e.target.checked);
+                props.change({
+                  ...value,
+                  check: e.target.checked ? 1 : 3, // 1: 全选 2: 只选了部分 3: 一个都没选
+                  buttons: [...buttons],
+                  children: checkAllData(value.children || [], e.target.checked),
+                });
+              }}
+            >
+              {value?.name}
+            </Checkbox>
+          </div>
+          <div>
+            <Checkbox.Group
+              name={value?.id}
+              value={_.map(
+                (value?.buttons || []).filter((i: any) => i?.enabled),
+                'id',
+              )}
+              onChange={(data: CheckboxValueType[]) => {
+                const buttons = value.buttons.map((i: any) => {
+                  return {
+                    ...i,
+                    enabled: data.includes(i.id),
+                  };
+                });
+                const clen = (value?.children || []).filter((i: any) => i.check !== 3).length;
+                let check: number = 3;
+                if (data.length + clen === 0) {
+                  check = 3;
+                } else if (
+                  data.length + clen <
+                  value?.buttons.length + (value?.children.length || 0)
+                ) {
+                  check = 2;
+                } else {
+                  check = 1;
+                }
+                const d = {
+                  ...value,
+                  check,
+                  buttons: [...buttons],
                 };
-              });
-              const clen = (value?.children || []).filter((i: any) => i.check !== 3).length;
-              let check: number = 3;
-              if (data.length + clen === 0) {
-                check = 3;
-              } else if (
-                data.length + clen <
-                value?.buttons.length + (value?.children.length || 0)
-              ) {
-                check = 2;
-              } else {
-                check = 1;
-              }
-              const d = {
-                ...value,
-                check,
-                buttons: [...buttons],
-              };
-              props.change(d);
-            }}
-            options={(value?.buttons || []).map((i: any) => ({
-              label: i.name,
-              value: i.id,
-              key: i.id,
-            }))}
-          />
+                props.change(d);
+              }}
+              options={(value?.buttons || []).map((i: any) => ({
+                label: i.name,
+                value: i.id,
+                key: i.id,
+              }))}
+            />
+          </div>
         </div>
         <div
           style={{