xieyonghong 3 лет назад
Родитель
Сommit
b275df3281

+ 2 - 2
config/proxy.ts

@@ -9,8 +9,8 @@
 export default {
   dev: {
     '/api': {
-      target: 'http://192.168.32.28:8844/',
-      ws: 'ws://192.168.32.28:8844/',
+      // 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/',

+ 2 - 2
src/app.tsx

@@ -63,7 +63,7 @@ export async function getInitialState(): Promise<{
   };
   const getSettings = async () => {
     try {
-      const res = await Service.settingDetail('basis');
+      const res = await Service.settingDetail('front');
       return res.result;
     } catch (error) {
       history.push(loginPath);
@@ -243,7 +243,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
   // console.log({ ...initialState });
   const ico: any = document.querySelector('link[rel="icon"]');
   if (ico !== null) {
-    Service.settingDetail('basis').then((res) => {
+    Service.settingDetail('front').then((res) => {
       if (res.status === 200) {
         // console.log(res.result.ico)
         ico.href = res.result.ico;

+ 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 {

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

@@ -160,8 +160,8 @@ export default (props: Props) => {
     field.loading = true;
     api(field).then(
       action.bound!((resp: Response<any>) => {
-        const value = resp.result?.[0].parameter.quantity;
-        field.dataSource = [...new Array(value).keys()].map((item: any) => ({
+        const value = resp.result?.[0].parameter.quantity || '';
+        field.dataSource = [...new Array(value * 2).keys()].map((item: any) => ({
           label: item,
           value: item,
         }));
@@ -240,8 +240,15 @@ export default (props: Props) => {
             }
             return x;
           }, metadata);
-          setProperties(array);
-          setFilterList(array);
+          //删除物模型
+          const items = array.filter((item: any) => item.metadataName);
+          setProperties(items);
+          setFilterList(items);
+          const delList = array.filter((a: any) => !a.metadataName).map((b: any) => b.id);
+          //删除后解绑
+          if (delList && delList.length !== 0) {
+            service.removeDevicePoint(data.id, delList);
+          }
         }
       });
     } else {
@@ -307,7 +314,7 @@ export default (props: Props) => {
         );
         if ((field as Field).modified) {
           const readIndex = field.query(path).get('value');
-          const dataLength = field.query(path).get('dataSource')?.length * 2 - 1;
+          const dataLength = field.query(path).get('dataSource')?.length - 1;
           const length = lengthMap.get(value) + readIndex;
           console.log(length, dataLength);
           if (length > dataLength) {

+ 31 - 2
src/pages/device/Instance/index.tsx

@@ -413,6 +413,31 @@ const Instance = () => {
     },
   ];
 
+  const paramsFormat = (config: any, _terms: any, name?: string) => {
+    if (config?.terms && Array.isArray(config.terms) && config?.terms.length > 0) {
+      (config?.terms || []).map((item: any, index: number) => {
+        if (item?.type) {
+          _terms[`${name ? `${name}.` : ''}terms[${index}].type`] = item.type;
+        }
+        paramsFormat(item, _terms, `${name ? `${name}.` : ''}terms[${index}]`);
+      });
+    } else if (!config?.terms && Object.keys(config).length > 0) {
+      Object.keys(config).forEach((key) => {
+        _terms[`${name ? `${name}.` : ''}${key}`] = config[key];
+      });
+    }
+  };
+
+  const handleParams = (config: any) => {
+    const _terms: any = {};
+    paramsFormat(config, _terms);
+    const url = new URLSearchParams();
+    Object.keys(_terms).forEach((key) => {
+      url.append(key, _terms[key]);
+    });
+    return url.toString();
+  };
+
   const menu = (
     <Menu>
       <Menu.Item key="1">
@@ -450,7 +475,9 @@ const Instance = () => {
               setType('active');
               const activeAPI = `/${
                 SystemConst.API_BASE
-              }/device-instance/deploy?:X_Access_Token=${Token.get()}`;
+              }/device-instance/deploy?:X_Access_Token=${Token.get()}&${handleParams(
+                searchParams,
+              )}`;
               setApi(activeAPI);
               setOperationVisible(true);
             },
@@ -468,7 +495,9 @@ const Instance = () => {
             setType('sync');
             const syncAPI = `/${
               SystemConst.API_BASE
-            }/device-instance/state/_sync?:X_Access_Token=${Token.get()}`;
+            }/device-instance/state/_sync?:X_Access_Token=${Token.get()}&${handleParams(
+              searchParams,
+            )}`;
             setApi(syncAPI);
             setOperationVisible(true);
           }}

+ 14 - 0
src/pages/home/index.tsx

@@ -7,10 +7,12 @@ import Ops from './ops';
 import Api from './Api';
 import Service from './service';
 import { Skeleton } from 'antd';
+import { useModel } from '@@/plugin-model/useModel';
 
 export const service = new Service();
 const Home = () => {
   type ViewType = keyof typeof ViewMap;
+  const { initialState, setInitialState } = useModel<any>('@@initialState');
   const [current, setCurrent] = useState<ViewType>('init'); // 默认为初始化
   const [loading, setLoading] = useState(true);
   const [detail, setDetail] = useState<any>({});
@@ -36,6 +38,18 @@ const Home = () => {
   };
 
   useEffect(() => {
+    service.settingDetail(['front']).then((res) => {
+      if (res.status === 200) {
+        setInitialState({
+          ...initialState,
+          settings: {
+            ...res.result[0].properties,
+          },
+        });
+      }
+    });
+  }, []);
+  useEffect(() => {
     service.userDetail().then((res) => {
       if (res.status === 200) {
         //三方用户

+ 5 - 0
src/pages/home/service.ts

@@ -38,6 +38,11 @@ class Service {
       method: 'POST',
       data,
     });
+  settingDetail = (data?: any) =>
+    request(`/${SystemConst.API_BASE}/system/config/scopes`, {
+      method: 'POST',
+      data,
+    });
 }
 
 export default Service;

+ 8 - 5
src/pages/init-home/components/basis.tsx

@@ -20,20 +20,21 @@ const Basis = forwardRef((props: Props, ref) => {
       if (formData) {
         const item = [
           {
-            scope: 'basis',
+            scope: 'front',
             properties: {
               ...formData,
               apikey: '',
+              basePath: '',
             },
           },
           {
-            scope: 'api',
+            scope: 'amap',
             properties: {
               api: formData.apikey,
             },
           },
           {
-            scope: 'basePath',
+            scope: 'paths',
             properties: {
               basePath: formData.basePath,
             },
@@ -47,6 +48,7 @@ const Basis = forwardRef((props: Props, ref) => {
             settings: {
               ...initialState?.settings,
               logo: formData.logo,
+              title: formData.title,
             },
           });
           const ico: any = document.querySelector('link[rel="icon"]');
@@ -109,10 +111,11 @@ const Basis = forwardRef((props: Props, ref) => {
           <Form.Item
             label="base-path"
             name="basePath"
-            tooltip="界面访问后台服务器的URL(统一资源定位符)"
+            tooltip="系统后台访问的url"
             required
+            rules={[{ required: true, message: 'base-path必填' }]}
           >
-            <Input />
+            <Input placeholder="请输入" />
           </Form.Item>
           <Row gutter={[24, 24]}>
             <Col>

+ 1 - 0
src/pages/init-home/index.tsx

@@ -29,6 +29,7 @@ const InitHome = () => {
   };
 
   useEffect(() => {
+    document.title = '';
     service.getInit().then((res) => {
       if (res.status === 200 && res.result.length) {
         // jump()

+ 2 - 3
src/pages/link/Channel/Modbus/Export/index.tsx

@@ -9,13 +9,12 @@ import SystemConst from '@/utils/const';
 import { downloadFile } from '@/utils/util';
 
 interface Props {
-  visible: boolean;
   close: () => void;
   data: any;
 }
 
 const Export = (props: Props) => {
-  const { visible, close } = props;
+  const { close } = props;
   const [list, setList] = useState<any[]>([]);
   const SchemaField = createSchemaField({
     components: {
@@ -108,7 +107,7 @@ const Export = (props: Props) => {
   return (
     <Modal
       maskClosable={false}
-      visible={visible}
+      visible
       onCancel={() => close()}
       width="35vw"
       title="导出"

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

@@ -10,7 +10,6 @@ import { UploadOutlined } from '@ant-design/icons';
 import { EventSourcePolyfill } from 'event-source-polyfill';
 
 interface Props {
-  visible: boolean;
   close: () => void;
   masterId: any;
 }
@@ -167,7 +166,7 @@ const NormalUpload = (props: any) => {
   );
 };
 const Import = (props: Props) => {
-  const { visible, close, masterId } = props;
+  const { close, masterId } = props;
 
   useEffect(() => {
     console.log(masterId);
@@ -220,7 +219,7 @@ const Import = (props: Props) => {
   return (
     <Modal
       maskClosable={false}
-      visible={visible}
+      visible
       onCancel={() => close()}
       width="35vw"
       title="导入"

+ 25 - 17
src/pages/link/Channel/Modbus/index.tsx

@@ -14,7 +14,7 @@ import {
   SearchOutlined,
   StopOutlined,
 } from '@ant-design/icons';
-import { useEffect, useRef, useState } from 'react';
+import { useEffect, useMemo, useRef, useState } from 'react';
 import { useIntl } from 'umi';
 import ChannelCard from '../channelCard';
 import { PageContainer } from '@ant-design/pro-layout';
@@ -354,6 +354,19 @@ const NewModbus = () => {
     return () => wsRef.current && wsRef.current?.unsubscribe();
   }, [pointList]);
 
+  const masterMemo = useMemo(
+    () => (
+      <Export
+        data={masterList}
+        close={() => {
+          setExportVisible(false);
+          actionRef.current?.reload();
+        }}
+      />
+    ),
+    [masterList],
+  );
+
   return (
     <PageContainer>
       <Card className="modbus" style={{ minHeight }}>
@@ -561,22 +574,17 @@ const NewModbus = () => {
           }}
         />
       )}
-      <Import
-        masterId={activeKey}
-        close={() => {
-          setImportVisible(false);
-          actionRef.current?.reload();
-        }}
-        visible={importVisible}
-      />
-      <Export
-        data={masterList}
-        close={() => {
-          setExportVisible(false);
-          actionRef.current?.reload();
-        }}
-        visible={exportVisible}
-      />
+      {importVisible && (
+        <Import
+          masterId={activeKey}
+          close={() => {
+            setImportVisible(false);
+            actionRef.current?.reload();
+          }}
+          // visible={importVisible}
+        />
+      )}
+      {exportVisible && masterMemo}
     </PageContainer>
   );
 };

+ 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>

+ 1 - 0
src/pages/rule-engine/Scene/Save/action/action.tsx

@@ -383,6 +383,7 @@ export default observer((props: ActionProps) => {
                   propertiesChange={setPropertiesId}
                 />
               </Form.Item>
+              l
             </Col>
             {parallelNode}
           </Row>

+ 11 - 11
src/pages/system/Basis/index.tsx

@@ -20,9 +20,9 @@ const Basis = () => {
   const detail = async (data: any) => {
     const res = await service.detail(data);
     if (res.status === 200) {
-      const basis = res.result?.filter((item: any) => item.scope === 'basis');
-      const api = res?.result.filter((item: any) => item.scope === 'api');
-      const basePath = res?.result.filter((item: any) => item.scope === 'basePath');
+      const basis = res.result?.filter((item: any) => item.scope === 'front');
+      const api = res.result?.filter((item: any) => item.scope === 'amap');
+      const basePath = res.result?.filter((item: any) => item.scope === 'paths');
       localStorage.setItem(SystemConst.AMAP_KEY, api[0].properties.api);
       form.setFieldsValue({
         ...basis[0].properties,
@@ -39,11 +39,10 @@ const Basis = () => {
   };
   const save = async () => {
     const formData = await form.validateFields();
-    console.log(formData);
     if (formData) {
       const item = [
         {
-          scope: 'basis',
+          scope: 'front',
           properties: {
             ...formData,
             apikey: '',
@@ -51,13 +50,13 @@ const Basis = () => {
           },
         },
         {
-          scope: 'api',
+          scope: 'amap',
           properties: {
             api: formData.apikey,
           },
         },
         {
-          scope: 'basePath',
+          scope: 'paths',
           properties: {
             basePath: formData.basePath,
           },
@@ -66,13 +65,13 @@ const Basis = () => {
       const res = await service.save(item);
       if (res.status === 200) {
         onlyMessage('保存成功');
-        detail(['basis', 'api', 'basePath']);
+        detail(['front', 'amap', 'paths']);
       }
     }
   };
 
   useEffect(() => {
-    detail(['basis', 'api', 'basePath']);
+    detail(['front', 'amap', 'paths']);
   }, []);
   return (
     <PageContainer>
@@ -111,10 +110,11 @@ const Basis = () => {
               <Form.Item
                 label="base-path"
                 name="basePath"
-                tooltip="界面访问后台服务器的URL(统一资源定位符)"
+                tooltip="访问后台服务器的url"
                 required
+                rules={[{ required: true, message: 'base-path必填' }]}
               >
-                <Input />
+                <Input placeholder="请输入" />
               </Form.Item>
               <Row gutter={[24, 24]}>
                 <Col>

+ 1 - 5
src/pages/system/Role/Detail/UserManage/BindUser.tsx

@@ -100,14 +100,10 @@ const BindUser = (props: Props) => {
             setSelectedRowKeys(key as string[]);
           },
         }}
-        pagination={{
-          pageSize: 10,
-        }}
         columnEmptyText={''}
         request={async (params: any) => {
           const response = await service.query({
-            pageSize: params.pageSize,
-            pageIndex: params.current,
+            ...params,
             terms: [
               ...(param?.terms || []),
               {

+ 1 - 1
src/pages/user/Login/index.tsx

@@ -90,7 +90,7 @@ const Login: React.FC = () => {
         setBindings(res.result);
       }
     });
-    Service.settingDetail('basis').then((res) => {
+    Service.settingDetail('front').then((res) => {
       if (res.status === 200) {
         const ico: any = document.querySelector('link[rel="icon"]');
         ico.href = res.result.ico;