소스 검색

fix: 修改bug

100011797 3 년 전
부모
커밋
47061a1139

+ 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(['basePath']);
+      const api = await service.querySystemApi(['paths']);
       const f = {
         ...result,
-        url: `${api?.result[0]?.properties?.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);

+ 184 - 251
src/pages/device/Firmware/Task/Save/index.tsx

@@ -1,87 +1,40 @@
-import { Modal } from 'antd';
+import { Col, Form, Input, InputNumber, message, Modal, Radio, Row, Select } from 'antd';
 import type { FirmwareItem } from '@/pages/device/Firmware/typings';
-import { createSchemaField } from '@formily/react';
-import { Form, FormGrid, FormItem, Input, Select, NumberPicker, Radio } from '@formily/antd';
-import { createForm, onFieldValueChange } from '@formily/core';
-import type { ISchema } from '@formily/json-schema';
+import FSelectDevices from '@/components/FSelectDevices';
+import { useEffect, useRef, useState } from 'react';
+import type { DeviceInstance } from '@/pages/device/Instance/typings';
 import { service } from '@/pages/device/Firmware';
-import { useEffect, useMemo } from 'react';
 import { onlyMessage } from '@/utils/util';
-import FSelectDevices from '@/components/FSelectDevices';
 
 interface Props {
   ids: { id: string; productId: string };
   data?: FirmwareItem;
   close: () => void;
   save: () => void;
-  visible: boolean;
 }
 
 const Save = (props: Props) => {
-  const { data, close, visible, ids } = props;
-
-  const form = useMemo(
-    () =>
-      createForm({
-        validateFirst: true,
-        initialValues: {},
-        effects() {
-          // onFormInit(async (form1) => {
-          //   if (!data?.id) return;
-          //   form1.setInitialValues({ ...data, upload: { url: data?.url } });
-          // });
-          onFieldValueChange('mode', async (field) => {
-            field
-              .query('timeoutSeconds')
-              .take()
-              .setDecoratorProps({
-                gridSpan: field.value === 'push' ? 1 : 2,
-              });
-            field
-              .query('responseTimeoutSeconds')
-              .take()
-              .setDecoratorProps({
-                gridSpan: field.value === 'push' ? 1 : 2,
-              });
-          });
-          onFieldValueChange('releaseType', async (field) => {
-            field.setDecoratorProps({
-              gridSpan: field.value === 'all' ? 2 : 1,
-            });
-          });
-        },
-      }),
-    [],
-  );
+  const { data, close, ids } = props;
+  const [mode, setMode] = useState<'push' | 'pull' | undefined>(undefined);
+  const [releaseType, setReleaseType] = useState<'all' | 'part' | undefined>(undefined);
 
-  // const devices = useRef<DeviceInstance[]>([]);
+  const [form] = Form.useForm();
 
-  const SchemaField = createSchemaField({
-    components: {
-      FormItem,
-      FormGrid,
-      Input,
-      Select,
-      NumberPicker,
-      Radio,
-      FSelectDevices,
-    },
-  });
+  const devices = useRef<DeviceInstance[]>([]);
 
   useEffect(() => {
-    // if (visible) {
-    //   service.queryDevice().then((resp) => {
-    //     if (resp.status === 200) {
-    //       devices.current = resp.result;
-    //     }
-    //   });
-    // }
-  }, [visible]);
+    service.queryDevice().then((resp) => {
+      if (resp.status === 200) {
+        devices.current = resp.result;
+      }
+    });
+  }, []);
 
   const save = async () => {
-    const values: any = await form.submit();
+    const values = await form.validateFields();
+    console.log(values);
     if (values?.releaseType !== 'all') {
-      // values.deviceId = devices.current.map((item) => item.id);
+      values.deviceId = (values?.deviceId || []).map((item: any) => item.id);
     } else {
       values.deviceId = undefined;
     }
@@ -93,203 +46,183 @@ const Save = (props: Props) => {
     if (resp.status === 200) {
       onlyMessage('保存成功!');
       props.save();
+      form.resetFields();
+      setMode(undefined);
+      setReleaseType(undefined);
     } else {
-      onlyMessage('保存失败!', 'error');
+      message.error('保存失败!');
     }
   };
 
-  const schema: ISchema = {
-    type: 'object',
-    properties: {
-      grid: {
-        type: 'void',
-        'x-component': 'FormGrid',
-        'x-component-props': {
-          minColumns: 2,
-          maxColumns: 2,
-        },
-        properties: {
-          name: {
-            title: '任务名称',
-            'x-decorator': 'FormItem',
-            'x-component': 'Input',
-            'x-component-props': {
-              placeholder: '请输入任务名称',
-            },
-            required: true,
-            'x-decorator-props': {
-              gridSpan: 2,
-            },
-            'x-validator': [
-              {
-                required: true,
-                message: '请输入任务名称',
-              },
-              {
-                max: 64,
-                message: '最多可输入64个字符',
-              },
-            ],
-          },
-          mode: {
-            title: '推送方式',
-            'x-component': 'Select',
-            'x-decorator': 'FormItem',
-            enum: [
-              { label: '平台推送', value: 'push' },
-              { label: '设备拉取', value: 'pull' },
-            ],
-            'x-component-props': {
-              placeholder: '请选择推送方式',
-            },
-            'x-decorator-props': {
-              gridSpan: 2,
-            },
-            required: true,
-            'x-validator': [
-              {
-                required: true,
-                message: '请选择推送方式',
-              },
-            ],
-          },
-          responseTimeoutSeconds: {
-            title: '响应超时时间',
-            'x-decorator': 'FormItem',
-            'x-component': 'NumberPicker',
-            'x-component-props': {
-              placeholder: '请输入响应超时时间(秒)',
-            },
-            'x-visible': false,
-            required: true,
-            'x-validator': [
-              {
-                required: true,
-                message: '请输入响应超时时间',
-              },
-              {
-                maximum: 99999,
-                minimum: 1,
-              },
-            ],
-            'x-reactions': {
-              dependencies: ['.mode'],
-              fulfill: {
-                state: {
-                  visible: '{{$deps[0]==="push"}}',
-                },
-              },
-            },
-          },
-          timeoutSeconds: {
-            title: '升级超时时间',
-            'x-decorator': 'FormItem',
-            'x-component': 'NumberPicker',
-            'x-component-props': {
-              placeholder: '请输入升级超时时间(秒)',
-            },
-            'x-visible': false,
-            required: true,
-            'x-validator': [
-              {
-                required: true,
-                message: '请输入升级超时时间',
-              },
-              {
-                maximum: 99999,
-                minimum: 1,
-              },
-            ],
-            'x-reactions': {
-              dependencies: ['.mode'],
-              fulfill: {
-                state: {
-                  visible: '{{!!$deps[0]}}',
-                },
-              },
-            },
-          },
-          releaseType: {
-            type: 'string',
-            title: '升级设备',
-            default: 'all',
-            'x-visible': false,
-            enum: [
-              { label: '所有设备', value: 'all' },
-              { label: '选择设备', value: 'part' },
-            ],
-            'x-decorator': 'FormItem',
-            'x-component': 'Radio.Group',
-            required: true,
-            'x-validator': [
-              {
-                required: true,
-                message: '请选择升级设备',
-              },
-            ],
-            'x-reactions': {
-              dependencies: ['.mode'],
-              fulfill: {
-                state: {
-                  visible: '{{!!$deps[0]}}',
-                },
-              },
-            },
-          },
-          deviceId: {
-            title: '选择设备',
-            'x-decorator': 'FormItem',
-            'x-component': 'FSelectDevices',
-            'x-component-props': {
-              productId: ids?.productId || '',
-            },
-            'x-visible': false,
-            required: true,
-            'x-reactions': {
-              dependencies: ['.releaseType'],
-              fulfill: {
-                state: {
-                  visible: '{{$deps[0]==="part"}}',
-                },
-              },
-            },
-            'x-validator': [
-              {
-                required: true,
-                message: '请选择设备',
-              },
-            ],
-          },
-          description: {
-            title: '说明',
-            'x-decorator': 'FormItem',
-            'x-component': 'Input.TextArea',
-            'x-decorator-props': {
-              gridSpan: 2,
-            },
-            'x-component-props': {
-              rows: 3,
-              showCount: true,
-              maxLength: 200,
-              placeholder: '请输入说明',
-            },
-          },
-        },
-      },
-    },
-  };
-
   return (
     <Modal
       maskClosable={false}
       width="50vw"
       title={data?.id ? '编辑任务' : '新增任务'}
-      onCancel={() => close()}
+      onCancel={() => {
+        form.resetFields();
+        close();
+        setMode(undefined);
+        setReleaseType(undefined);
+      }}
       onOk={() => save()}
-      visible={visible}
+      visible
     >
-      <Form form={form} labelCol={5} wrapperCol={16} layout="vertical">
-        <SchemaField schema={schema} />
+      <Form form={form} name="basic" layout="vertical">
+        <Row gutter={24}>
+          <Col span={24}>
+            <Form.Item
+              label="任务名称"
+              name="name"
+              rules={[
+                {
+                  required: true,
+                  message: '请输入任务名称',
+                },
+                {
+                  max: 64,
+                  message: '最多可输入64个字符',
+                },
+              ]}
+            >
+              <Input placeholder="请输入任务名称" />
+            </Form.Item>
+          </Col>
+          <Col span={24}>
+            <Form.Item
+              label="推送方式"
+              name="mode"
+              rules={[
+                {
+                  required: true,
+                  message: '请选择推送方式',
+                },
+              ]}
+            >
+              <Select
+                placeholder="请选择推送方式"
+                onChange={(value) => {
+                  setMode(value);
+                }}
+              >
+                <Select.Option value="push">平台推送</Select.Option>
+                <Select.Option value="pull">设备拉取</Select.Option>
+              </Select>
+            </Form.Item>
+          </Col>
+          {mode === 'push' && (
+            <>
+              <Col span={12}>
+                <Form.Item
+                  label="响应超时时间"
+                  name="responseTimeoutSeconds"
+                  rules={[
+                    {
+                      required: true,
+                      message: '请输入响应超时时间',
+                    },
+                    {
+                      type: 'number',
+                      max: 99999,
+                      min: 1,
+                      message: '请输入1~99999之间的数字',
+                    },
+                  ]}
+                >
+                  <InputNumber style={{ width: '100%' }} placeholder="请输入响应超时时间(秒)" />
+                </Form.Item>
+              </Col>
+              <Col span={12}>
+                <Form.Item
+                  label="升级超时时间"
+                  name="timeoutSeconds"
+                  rules={[
+                    {
+                      required: true,
+                      message: '请输入升级超时时间',
+                    },
+                    {
+                      type: 'number',
+                      max: 99999,
+                      min: 1,
+                      message: '请输入1~99999之间的数字',
+                    },
+                  ]}
+                >
+                  <InputNumber style={{ width: '100%' }} placeholder="请请输入升级超时时间(秒)" />
+                </Form.Item>
+              </Col>
+            </>
+          )}
+          {mode === 'pull' && (
+            <Col span={24}>
+              <Form.Item
+                label="升级超时时间"
+                name="timeoutSeconds"
+                rules={[
+                  {
+                    required: true,
+                    message: '请输入升级超时时间',
+                  },
+                  {
+                    type: 'number',
+                    max: 99999,
+                    min: 1,
+                    message: '请输入1~99999之间的数字',
+                  },
+                ]}
+              >
+                <InputNumber style={{ width: '100%' }} placeholder="请请输入升级超时时间(秒)" />
+              </Form.Item>
+            </Col>
+          )}
+          {!!mode && (
+            <>
+              <Col span={12}>
+                <Form.Item
+                  label="升级设备"
+                  name="releaseType"
+                  rules={[
+                    {
+                      required: true,
+                      message: '请选择升级设备',
+                    },
+                  ]}
+                >
+                  <Radio.Group
+                    onChange={(e) => {
+                      setReleaseType(e.target.value);
+                    }}
+                  >
+                    <Radio value="all"> 所有设备 </Radio>
+                    <Radio value="part"> 选择设备 </Radio>
+                  </Radio.Group>
+                </Form.Item>
+              </Col>
+              {releaseType === 'part' && (
+                <Col span={12}>
+                  <Form.Item
+                    label="选择设备"
+                    name="deviceId"
+                    rules={[
+                      {
+                        required: true,
+                        message: '请选择设备',
+                      },
+                    ]}
+                  >
+                    <FSelectDevices productId={ids?.productId || ''} />
+                  </Form.Item>
+                </Col>
+              )}
+            </>
+          )}
+          <Col span={24}>
+            <Form.Item label="说明" name="description">
+              <Input.TextArea rows={3} maxLength={200} showCount={true} placeholder="请输入说明" />
+            </Form.Item>
+          </Col>
+        </Row>
       </Form>
     </Modal>
   );

+ 251 - 184
src/pages/device/Firmware/Task/Save/index1.tsx

@@ -1,40 +1,87 @@
-import { Col, Form, Input, InputNumber, message, Modal, Radio, Row, Select } from 'antd';
+import { Modal } from 'antd';
 import type { FirmwareItem } from '@/pages/device/Firmware/typings';
-import FSelectDevices from '@/components/FSelectDevices';
-import { useEffect, useRef, useState } from 'react';
-import type { DeviceInstance } from '@/pages/device/Instance/typings';
+import { createSchemaField } from '@formily/react';
+import { Form, FormGrid, FormItem, Input, Select, NumberPicker, Radio } from '@formily/antd';
+import { createForm, onFieldValueChange } from '@formily/core';
+import type { ISchema } from '@formily/json-schema';
 import { service } from '@/pages/device/Firmware';
+import { useEffect, useMemo } from 'react';
 import { onlyMessage } from '@/utils/util';
+import FSelectDevices from '@/components/FSelectDevices';
 
 interface Props {
   ids: { id: string; productId: string };
   data?: FirmwareItem;
   close: () => void;
   save: () => void;
+  visible: boolean;
 }
 
 const Save = (props: Props) => {
-  const { data, close, ids } = props;
-  const [mode, setMode] = useState<'push' | 'pull' | undefined>(undefined);
-  const [releaseType, setReleaseType] = useState<'all' | 'part' | undefined>(undefined);
+  const { data, close, visible, ids } = props;
+
+  const form = useMemo(
+    () =>
+      createForm({
+        validateFirst: true,
+        initialValues: {},
+        effects() {
+          // onFormInit(async (form1) => {
+          //   if (!data?.id) return;
+          //   form1.setInitialValues({ ...data, upload: { url: data?.url } });
+          // });
+          onFieldValueChange('mode', async (field) => {
+            field
+              .query('timeoutSeconds')
+              .take()
+              .setDecoratorProps({
+                gridSpan: field.value === 'push' ? 1 : 2,
+              });
+            field
+              .query('responseTimeoutSeconds')
+              .take()
+              .setDecoratorProps({
+                gridSpan: field.value === 'push' ? 1 : 2,
+              });
+          });
+          onFieldValueChange('releaseType', async (field) => {
+            field.setDecoratorProps({
+              gridSpan: field.value === 'all' ? 2 : 1,
+            });
+          });
+        },
+      }),
+    [],
+  );
 
-  const [form] = Form.useForm();
+  // const devices = useRef<DeviceInstance[]>([]);
 
-  const devices = useRef<DeviceInstance[]>([]);
+  const SchemaField = createSchemaField({
+    components: {
+      FormItem,
+      FormGrid,
+      Input,
+      Select,
+      NumberPicker,
+      Radio,
+      FSelectDevices,
+    },
+  });
 
   useEffect(() => {
-    service.queryDevice().then((resp) => {
-      if (resp.status === 200) {
-        devices.current = resp.result;
-      }
-    });
-  }, []);
+    // if (visible) {
+    //   service.queryDevice().then((resp) => {
+    //     if (resp.status === 200) {
+    //       devices.current = resp.result;
+    //     }
+    //   });
+    // }
+  }, [visible]);
 
   const save = async () => {
-    const values = await form.validateFields();
-    console.log(values);
+    const values: any = await form.submit();
     if (values?.releaseType !== 'all') {
-      values.deviceId = (values?.deviceId || []).map((item: any) => item.id);
+      // values.deviceId = devices.current.map((item) => item.id);
     } else {
       values.deviceId = undefined;
     }
@@ -46,183 +93,203 @@ const Save = (props: Props) => {
     if (resp.status === 200) {
       onlyMessage('保存成功!');
       props.save();
-      form.resetFields();
-      setMode(undefined);
-      setReleaseType(undefined);
     } else {
-      message.error('保存失败!');
+      onlyMessage('保存失败!', 'error');
     }
   };
 
+  const schema: ISchema = {
+    type: 'object',
+    properties: {
+      grid: {
+        type: 'void',
+        'x-component': 'FormGrid',
+        'x-component-props': {
+          minColumns: 2,
+          maxColumns: 2,
+        },
+        properties: {
+          name: {
+            title: '任务名称',
+            'x-decorator': 'FormItem',
+            'x-component': 'Input',
+            'x-component-props': {
+              placeholder: '请输入任务名称',
+            },
+            required: true,
+            'x-decorator-props': {
+              gridSpan: 2,
+            },
+            'x-validator': [
+              {
+                required: true,
+                message: '请输入任务名称',
+              },
+              {
+                max: 64,
+                message: '最多可输入64个字符',
+              },
+            ],
+          },
+          mode: {
+            title: '推送方式',
+            'x-component': 'Select',
+            'x-decorator': 'FormItem',
+            enum: [
+              { label: '平台推送', value: 'push' },
+              { label: '设备拉取', value: 'pull' },
+            ],
+            'x-component-props': {
+              placeholder: '请选择推送方式',
+            },
+            'x-decorator-props': {
+              gridSpan: 2,
+            },
+            required: true,
+            'x-validator': [
+              {
+                required: true,
+                message: '请选择推送方式',
+              },
+            ],
+          },
+          responseTimeoutSeconds: {
+            title: '响应超时时间',
+            'x-decorator': 'FormItem',
+            'x-component': 'NumberPicker',
+            'x-component-props': {
+              placeholder: '请输入响应超时时间(秒)',
+            },
+            'x-visible': false,
+            required: true,
+            'x-validator': [
+              {
+                required: true,
+                message: '请输入响应超时时间',
+              },
+              {
+                maximum: 99999,
+                minimum: 1,
+              },
+            ],
+            'x-reactions': {
+              dependencies: ['.mode'],
+              fulfill: {
+                state: {
+                  visible: '{{$deps[0]==="push"}}',
+                },
+              },
+            },
+          },
+          timeoutSeconds: {
+            title: '升级超时时间',
+            'x-decorator': 'FormItem',
+            'x-component': 'NumberPicker',
+            'x-component-props': {
+              placeholder: '请输入升级超时时间(秒)',
+            },
+            'x-visible': false,
+            required: true,
+            'x-validator': [
+              {
+                required: true,
+                message: '请输入升级超时时间',
+              },
+              {
+                maximum: 99999,
+                minimum: 1,
+              },
+            ],
+            'x-reactions': {
+              dependencies: ['.mode'],
+              fulfill: {
+                state: {
+                  visible: '{{!!$deps[0]}}',
+                },
+              },
+            },
+          },
+          releaseType: {
+            type: 'string',
+            title: '升级设备',
+            default: 'all',
+            'x-visible': false,
+            enum: [
+              { label: '所有设备', value: 'all' },
+              { label: '选择设备', value: 'part' },
+            ],
+            'x-decorator': 'FormItem',
+            'x-component': 'Radio.Group',
+            required: true,
+            'x-validator': [
+              {
+                required: true,
+                message: '请选择升级设备',
+              },
+            ],
+            'x-reactions': {
+              dependencies: ['.mode'],
+              fulfill: {
+                state: {
+                  visible: '{{!!$deps[0]}}',
+                },
+              },
+            },
+          },
+          deviceId: {
+            title: '选择设备',
+            'x-decorator': 'FormItem',
+            'x-component': 'FSelectDevices',
+            'x-component-props': {
+              productId: ids?.productId || '',
+            },
+            'x-visible': false,
+            required: true,
+            'x-reactions': {
+              dependencies: ['.releaseType'],
+              fulfill: {
+                state: {
+                  visible: '{{$deps[0]==="part"}}',
+                },
+              },
+            },
+            'x-validator': [
+              {
+                required: true,
+                message: '请选择设备',
+              },
+            ],
+          },
+          description: {
+            title: '说明',
+            'x-decorator': 'FormItem',
+            'x-component': 'Input.TextArea',
+            'x-decorator-props': {
+              gridSpan: 2,
+            },
+            'x-component-props': {
+              rows: 3,
+              showCount: true,
+              maxLength: 200,
+              placeholder: '请输入说明',
+            },
+          },
+        },
+      },
+    },
+  };
+
   return (
     <Modal
       maskClosable={false}
       width="50vw"
       title={data?.id ? '编辑任务' : '新增任务'}
-      onCancel={() => {
-        form.resetFields();
-        close();
-        setMode(undefined);
-        setReleaseType(undefined);
-      }}
+      onCancel={() => close()}
       onOk={() => save()}
-      visible
+      visible={visible}
     >
-      <Form form={form} name="basic" layout="vertical">
-        <Row gutter={24}>
-          <Col span={24}>
-            <Form.Item
-              label="任务名称"
-              name="name"
-              rules={[
-                {
-                  required: true,
-                  message: '请输入任务名称',
-                },
-                {
-                  max: 64,
-                  message: '最多可输入64个字符',
-                },
-              ]}
-            >
-              <Input placeholder="请输入任务名称" />
-            </Form.Item>
-          </Col>
-          <Col span={24}>
-            <Form.Item
-              label="推送方式"
-              name="mode"
-              rules={[
-                {
-                  required: true,
-                  message: '请选择推送方式',
-                },
-              ]}
-            >
-              <Select
-                placeholder="请选择推送方式"
-                onChange={(value) => {
-                  setMode(value);
-                }}
-              >
-                <Select.Option value="push">平台推送</Select.Option>
-                <Select.Option value="pull">设备拉取</Select.Option>
-              </Select>
-            </Form.Item>
-          </Col>
-          {mode === 'push' && (
-            <>
-              <Col span={12}>
-                <Form.Item
-                  label="响应超时时间"
-                  name="responseTimeoutSeconds"
-                  rules={[
-                    {
-                      required: true,
-                      message: '请输入响应超时时间',
-                    },
-                    {
-                      type: 'number',
-                      max: 99999,
-                      min: 1,
-                      message: '请输入1~99999之间的数字',
-                    },
-                  ]}
-                >
-                  <InputNumber style={{ width: '100%' }} placeholder="请输入响应超时时间(秒)" />
-                </Form.Item>
-              </Col>
-              <Col span={12}>
-                <Form.Item
-                  label="升级超时时间"
-                  name="timeoutSeconds"
-                  rules={[
-                    {
-                      required: true,
-                      message: '请输入升级超时时间',
-                    },
-                    {
-                      type: 'number',
-                      max: 99999,
-                      min: 1,
-                      message: '请输入1~99999之间的数字',
-                    },
-                  ]}
-                >
-                  <InputNumber style={{ width: '100%' }} placeholder="请请输入升级超时时间(秒)" />
-                </Form.Item>
-              </Col>
-            </>
-          )}
-          {mode === 'pull' && (
-            <Col span={24}>
-              <Form.Item
-                label="升级超时时间"
-                name="timeoutSeconds"
-                rules={[
-                  {
-                    required: true,
-                    message: '请输入升级超时时间',
-                  },
-                  {
-                    type: 'number',
-                    max: 99999,
-                    min: 1,
-                    message: '请输入1~99999之间的数字',
-                  },
-                ]}
-              >
-                <InputNumber style={{ width: '100%' }} placeholder="请请输入升级超时时间(秒)" />
-              </Form.Item>
-            </Col>
-          )}
-          {!!mode && (
-            <>
-              <Col span={12}>
-                <Form.Item
-                  label="升级设备"
-                  name="releaseType"
-                  rules={[
-                    {
-                      required: true,
-                      message: '请选择升级设备',
-                    },
-                  ]}
-                >
-                  <Radio.Group
-                    onChange={(e) => {
-                      setReleaseType(e.target.value);
-                    }}
-                  >
-                    <Radio value="all"> 所有设备 </Radio>
-                    <Radio value="part"> 选择设备 </Radio>
-                  </Radio.Group>
-                </Form.Item>
-              </Col>
-              {releaseType === 'part' && (
-                <Col span={12}>
-                  <Form.Item
-                    label="选择设备"
-                    name="deviceId"
-                    rules={[
-                      {
-                        required: true,
-                        message: '请选择设备',
-                      },
-                    ]}
-                  >
-                    <FSelectDevices productId={ids?.productId || ''} />
-                  </Form.Item>
-                </Col>
-              )}
-            </>
-          )}
-          <Col span={24}>
-            <Form.Item label="说明" name="description">
-              <Input.TextArea rows={3} maxLength={200} showCount={true} placeholder="请输入说明" />
-            </Form.Item>
-          </Col>
-        </Row>
+      <Form form={form} labelCol={5} wrapperCol={16} layout="vertical">
+        <SchemaField schema={schema} />
       </Form>
     </Modal>
   );

+ 1 - 1
src/pages/device/Firmware/Task/index.tsx

@@ -15,7 +15,7 @@ import { useHistory, useLocation } from 'umi';
 import { model } from '@formily/reactive';
 import { observer } from '@formily/react';
 import type { FirmwareItem } from '@/pages/device/Firmware/typings';
-import Save from './Save/index1';
+import Save from './Save';
 import { onlyMessage } from '@/utils/util';
 import { PermissionButton } from '@/components';
 import useDomFullHeight from '@/hooks/document/useDomFullHeight';

+ 2 - 2
src/pages/device/Instance/Detail/MetadataMap/index.tsx

@@ -1,11 +1,11 @@
-import { Button, Card, Empty } from 'antd';
+import { Button, Card } from 'antd';
 import { useEffect, useState } from 'react';
 import { InstanceModel, service } from '@/pages/device/Instance';
 import EditableTable from './EditableTable';
 import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
 import type { ProductItem } from '@/pages/device/Product/typings';
 import { useParams } from 'umi';
-import { PermissionButton } from '@/components';
+import { Empty, PermissionButton } from '@/components';
 import { useDomFullHeight } from '@/hooks';
 
 interface Props {

+ 8 - 6
src/pages/link/Protocol/FileUpload/index.tsx

@@ -5,7 +5,7 @@ import { connect } from '@formily/react';
 import { Button, Input, Spin, Upload } from 'antd';
 import type { UploadChangeParam } from 'antd/lib/upload/interface';
 import { onlyMessage } from '@/utils/util';
-
+import { service } from '@/pages/link/Protocol';
 interface Props {
   value: string;
   onChange: (value: string) => void;
@@ -17,14 +17,16 @@ const FileUpload = connect((props: Props) => {
   const [url, setUrl] = useState<string>(props?.value);
   const [loading, setLoading] = useState<boolean>(false);
 
-  const handleChange = (info: UploadChangeParam) => {
+  const handleChange = async (info: UploadChangeParam) => {
     setLoading(true);
     if (info.file.status === 'done') {
       onlyMessage('上传成功!');
-      info.file.url = info.file.response?.result;
-      setUrl(info.file.response?.result);
+      const result = info.file.response?.result;
+      const api = await service.querySystemApi(['paths']);
+      const f = `${api?.result[0]?.properties?.basePath}/file/${result?.id}?accessKey=${result?.others?.accessKey}`;
+      setUrl(f);
       setLoading(false);
-      props.onChange(info.file.response?.result);
+      props.onChange(f);
     }
   };
 
@@ -34,7 +36,7 @@ const FileUpload = connect((props: Props) => {
         accept={props?.accept || '*'}
         listType={'text'}
         disabled={props?.disabled}
-        action={`/${SystemConst.API_BASE}/file/static`}
+        action={`/${SystemConst.API_BASE}/file/upload`}
         headers={{
           'X-Access-Token': Token.get(),
         }}

+ 6 - 0
src/pages/link/Protocol/service.ts

@@ -19,6 +19,12 @@ class Service extends BaseService<ProtocolItem> {
 
   public productCount = (data: Record<string, unknown>) =>
     request(`${SystemConst.API_BASE}/device-product/_count`, { method: 'POST', data });
+
+  public querySystemApi = (data?: any) =>
+    request(`/${SystemConst.API_BASE}/system/config/scopes`, {
+      method: 'POST',
+      data,
+    });
 }
 
 export default Service;

+ 9 - 1
src/pages/link/Type/Detail/index.tsx

@@ -535,7 +535,7 @@ const Save = observer(() => {
         },
       },
       secure: {
-        title: '开启DTLS',
+        // title: '开启DTLS',
         'x-decorator': 'FormItem',
         'x-component': 'Radio.Group',
         'x-decorator-props': {
@@ -549,6 +549,14 @@ const Save = observer(() => {
           { label: '是', value: true },
           { label: '否', value: false },
         ],
+        'x-reactions': {
+          dependencies: ['type'],
+          fulfill: {
+            state: {
+              title: '{{$deps[0] === "TCP_SERVER" ? "开启TLS" : "开启DTLS"}}',
+            },
+          },
+        },
       },
       certId: {
         title: '证书',

+ 12 - 11
src/pages/media/Cascade/Publish/index.tsx

@@ -25,7 +25,7 @@ const Publish = (props: Props) => {
     const source = new EventSourcePolyfill(activeAPI);
     source.onmessage = (e: any) => {
       const res = JSON.parse(e.data);
-      console.log(res);
+      // console.log(res);
       if (res.successful) {
         dt += 1;
         setCount(dt);
@@ -36,8 +36,7 @@ const Publish = (props: Props) => {
         setErrMessage(res.message);
       }
     };
-    source.onerror = (e: any) => {
-      console.log(e, 'error');
+    source.onerror = () => {
       source.close();
     };
     source.onopen = () => {};
@@ -61,14 +60,16 @@ const Publish = (props: Props) => {
           <div>成功: {count}</div>
           <div>
             失败: {countErr}
-            <a
-              style={{ marginLeft: 20 }}
-              onClick={() => {
-                downloadObject(JSON.parse(errMessage || '{}'), props.data.name + '-推送失败');
-              }}
-            >
-              下载
-            </a>
+            {!!errMessage && (
+              <a
+                style={{ marginLeft: 20 }}
+                onClick={() => {
+                  downloadObject(JSON.parse(errMessage || '{}'), props.data.name + '-推送失败');
+                }}
+              >
+                下载
+              </a>
+            )}
           </div>
         </Col>
         <Col span={8}>推送通道数量: {props.data?.count || 0}</Col>