Browse Source

fix: 修复设备 子设备批量解绑未勾选提示

jackhoo_98 3 năm trước cách đây
mục cha
commit
28d09e2db0
1 tập tin đã thay đổi với 14 bổ sung14 xóa
  1. 14 14
      src/pages/device/Instance/Detail/ChildDevice/index.tsx

+ 14 - 14
src/pages/device/Instance/Detail/ChildDevice/index.tsx

@@ -25,7 +25,6 @@ interface Props {
 }
 
 const ChildDevice = (props: Props) => {
-  console.log(props.data);
   const intl = useIntl();
   const [visible, setVisible] = useState<boolean>(false);
   const actionRef = useRef<ActionType>();
@@ -44,6 +43,19 @@ const ChildDevice = (props: Props) => {
     }
   };
 
+  const handleUnBind = async () => {
+    if (bindKeys.length) {
+      const resp = await service.unbindBatchDevice(InstanceModel.detail.id!, bindKeys);
+      if (resp.status === 200) {
+        onlyMessage('操作成功!');
+        setBindKeys([]);
+        actionRef.current?.reset?.();
+      }
+    } else {
+      onlyMessage('请勾选需要解绑的数据', 'warning');
+    }
+  };
+
   const columns: ProColumns<LogItem>[] = [
     {
       title: 'ID',
@@ -238,19 +250,7 @@ const ChildDevice = (props: Props) => {
               >
                 绑定
               </Button>,
-              <Popconfirm
-                key="unbind"
-                onConfirm={async () => {
-                  if (bindKeys.length === 0) return onlyMessage('请先勾选数据!', 'error');
-                  const resp = await service.unbindBatchDevice(InstanceModel.detail.id!, bindKeys);
-                  if (resp.status === 200) {
-                    onlyMessage('操作成功!');
-                    setBindKeys([]);
-                    actionRef.current?.reset?.();
-                  }
-                }}
-                title={'确认解绑吗?'}
-              >
+              <Popconfirm key="unbind" onConfirm={handleUnBind} title={'确认解绑吗?'}>
                 <Button>批量解绑</Button>
               </Popconfirm>,
             ]}