瀏覽代碼

fix: merge

wzyyy 3 年之前
父節點
當前提交
d0934f55e8

+ 13 - 8
src/components/FIndicators/index.tsx

@@ -18,13 +18,17 @@ const FIndicators = (props: Props) => {
           <InputNumber
             value={value?.value ? value?.value[0] : ''}
             onChange={(val) => {
-              onChange({
-                ...value,
-                value: [
-                  value?.range && val < value?.value[1] ? val : value?.value[0],
-                  value?.value[1],
-                ],
-              });
+              if (value?.range) {
+                onChange({
+                  ...value,
+                  value: [val > value?.value[1] ? value?.value[0] : val, value?.value[1] || ''],
+                });
+              } else {
+                onChange({
+                  ...value,
+                  value: [val],
+                });
+              }
             }}
           />
           {value.range && (
@@ -35,7 +39,7 @@ const FIndicators = (props: Props) => {
                 onChange={(val) => {
                   onChange({
                     ...value,
-                    value: [value?.value && value?.value[0], val],
+                    value: [value?.value[0], val > value?.value[0] ? val : value?.value[1]],
                   });
                 }}
               />
@@ -117,6 +121,7 @@ const FIndicators = (props: Props) => {
         onChange={(e) => {
           onChange({
             ...value,
+            value: e.target.checked ? [undefined, undefined] : [undefined],
             range: e.target.checked,
           });
         }}

+ 15 - 4
src/components/FUpload/index.tsx

@@ -1,4 +1,4 @@
-import { UploadOutlined } from '@ant-design/icons';
+import { DeleteOutlined, UploadOutlined } from '@ant-design/icons';
 import SystemConst from '@/utils/const';
 import Token from '@/utils/token';
 import { useState } from 'react';
@@ -6,7 +6,7 @@ import { connect } from '@formily/react';
 import { Input, Upload } from 'antd';
 import type { UploadChangeParam } from 'antd/lib/upload/interface';
 import './index.less';
-
+import { service } from '@/pages/device/Firmware';
 interface Props {
   value: any;
   onChange: (value: any) => void;
@@ -17,12 +17,13 @@ interface Props {
 const FUpload = connect((props: Props) => {
   const [url, setUrl] = useState<any>(props?.value?.url);
 
-  const handleChange = (info: UploadChangeParam) => {
+  const handleChange = async (info: UploadChangeParam) => {
     if (info.file.status === 'done') {
       const result = info.file.response?.result;
+      const api = await service.querySystemApi();
       const f = {
         ...result,
-        url: `${location.protocol}//${SystemConst.API_BASE}/file/${result?.id}?accessKey=${result?.others?.accessKey}`,
+        url: `${api?.result?.basePath}file/${result?.id}?accessKey=${result?.others?.accessKey}`,
       };
       setUrl(f.url);
       props.onChange(f);
@@ -39,6 +40,16 @@ const FUpload = connect((props: Props) => {
       multiple={false}
       onChange={handleChange}
       progress={{}}
+      showUploadList={{
+        removeIcon: (
+          <DeleteOutlined
+            onClick={() => {
+              setUrl('');
+              props.onChange(undefined);
+            }}
+          />
+        ),
+      }}
     >
       <Input
         placeholder={props.placeholder}

+ 29 - 0
src/pages/device/Firmware/Save/RemoveData.tsx

@@ -0,0 +1,29 @@
+import { DeleteOutlined } from '@ant-design/icons';
+import { ArrayItems } from '@formily/antd';
+import { Popconfirm } from 'antd';
+import { useField } from '@formily/react';
+
+const RemoveData = () => {
+  const index = ArrayItems.useIndex!();
+  const self = useField();
+  const array = ArrayItems.useArray!();
+  if (!array) return null;
+  if (array.field?.pattern !== 'editable') return null;
+
+  return (
+    <div>
+      <Popconfirm
+        title={'确认删除'}
+        onConfirm={() => {
+          if (self?.disabled) return;
+          array.field?.remove?.(index);
+          array.props?.onRemove?.(index);
+        }}
+      >
+        <DeleteOutlined />
+      </Popconfirm>
+    </div>
+  );
+};
+
+export default RemoveData;

+ 37 - 10
src/pages/device/Firmware/Save/index.tsx

@@ -1,7 +1,7 @@
 import { Modal } from 'antd';
 import type { FirmwareItem } from '@/pages/device/Firmware/typings';
 import { createSchemaField } from '@formily/react';
-import { Form, FormGrid, FormItem, Input, Select, ArrayTable } from '@formily/antd';
+import { Form, FormGrid, FormItem, Input, Select, ArrayTable, NumberPicker } from '@formily/antd';
 import type { Field } from '@formily/core';
 import { onFieldValueChange, onFormInit } from '@formily/core';
 import { createForm } from '@formily/core';
@@ -12,6 +12,8 @@ import { service } from '@/pages/device/Firmware';
 import { useRef } from 'react';
 import type { ProductItem } from '@/pages/device/Product/typings';
 import { onlyMessage } from '@/utils/util';
+import RemoveData from './RemoveData';
+import encodeQuery from '@/utils/encodeQuery';
 
 interface Props {
   data?: FirmwareItem;
@@ -55,7 +57,13 @@ const Save = (props: Props) => {
       }),
     );
   };
-  const loadData = async () => service.queryProduct();
+  const loadData = async () =>
+    service.queryProduct(
+      encodeQuery({
+        terms: { state: 1 },
+        sorts: { createTime: 'desc' },
+      }),
+    );
   const SchemaField = createSchemaField({
     components: {
       FormItem,
@@ -64,6 +72,8 @@ const Save = (props: Props) => {
       FUpload,
       Select,
       ArrayTable,
+      NumberPicker,
+      RemoveData,
     },
   });
 
@@ -83,6 +93,7 @@ const Save = (props: Props) => {
       close();
     }
   };
+
   const schema: ISchema = {
     type: 'object',
     properties: {
@@ -121,9 +132,6 @@ const Save = (props: Props) => {
             'x-decorator': 'FormItem',
             'x-component': 'Select',
             'x-reactions': ['{{useAsyncDataSource(loadData)}}'],
-            'x-component-props': {
-              placeholder: '请选择所属产品',
-            },
             'x-decorator-props': {
               gridSpan: 2,
             },
@@ -134,6 +142,13 @@ const Save = (props: Props) => {
                 message: '请选择所属产品',
               },
             ],
+            'x-component-props': {
+              placeholder: '请选择所属产品',
+              showSearch: true,
+              allowClear: true,
+              filterOption: (input: string, option: any) =>
+                option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
+            },
           },
           version: {
             title: '版本号',
@@ -160,7 +175,7 @@ const Save = (props: Props) => {
           versionOrder: {
             title: '版本序号',
             'x-decorator': 'FormItem',
-            'x-component': 'Input',
+            'x-component': 'NumberPicker',
             'x-component-props': {
               placeholder: '请输入版本序号',
             },
@@ -244,7 +259,7 @@ const Save = (props: Props) => {
             ],
           },
           upload: {
-            title: '件上传',
+            title: '件上传',
             'x-decorator': 'FormItem',
             'x-component': 'FUpload',
             'x-component-props': {
@@ -284,8 +299,14 @@ const Save = (props: Props) => {
                   properties: {
                     id: {
                       type: 'string',
-                      'x-decorator': 'Editable',
+                      'x-decorator': 'FormItem',
                       'x-component': 'Input',
+                      'x-validator': [
+                        {
+                          required: true,
+                          message: '请输入KEY',
+                        },
+                      ],
                     },
                   },
                 },
@@ -298,6 +319,12 @@ const Save = (props: Props) => {
                       type: 'string',
                       'x-decorator': 'FormItem',
                       'x-component': 'Input',
+                      'x-validator': [
+                        {
+                          required: true,
+                          message: '请输入VALUE',
+                        },
+                      ],
                     },
                   },
                 },
@@ -315,7 +342,7 @@ const Save = (props: Props) => {
                       properties: {
                         remove: {
                           type: 'void',
-                          'x-component': 'ArrayTable.Remove',
+                          'x-component': 'RemoveData',
                         },
                       },
                     },
@@ -327,7 +354,7 @@ const Save = (props: Props) => {
               add: {
                 type: 'void',
                 'x-component': 'ArrayTable.Addition',
-                title: '添加条目',
+                title: '添加',
               },
             },
           },

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

@@ -229,7 +229,6 @@ const Detail = observer(() => {
         defaultMessage: '操作',
       }),
       valueType: 'option',
-      align: 'center',
       fixed: 'right',
       width: 200,
       render: (text: any, record: any) =>

+ 0 - 2
src/pages/device/Firmware/Task/index.tsx

@@ -101,7 +101,6 @@ const Task = observer(() => {
         defaultMessage: '说明',
       }),
       ellipsis: true,
-      align: 'center',
       dataIndex: 'description',
     },
     {
@@ -116,7 +115,6 @@ const Task = observer(() => {
         defaultMessage: '操作',
       }),
       valueType: 'option',
-      align: 'center',
       width: 200,
       fixed: 'right',
       render: (text, record) => [

+ 0 - 3
src/pages/device/Firmware/index.tsx

@@ -92,7 +92,6 @@ const Firmware = observer(() => {
       }),
       dataIndex: 'createTime',
       width: '200px',
-      align: 'center',
       ellipsis: true,
       valueType: 'dateTime',
       // render: (text: any) => moment(text).format('YYYY-MM-DD HH:mm:ss'),
@@ -105,7 +104,6 @@ const Firmware = observer(() => {
         defaultMessage: '说明',
       }),
       ellipsis: true,
-      align: 'center',
       dataIndex: 'description',
     },
     {
@@ -114,7 +112,6 @@ const Firmware = observer(() => {
         defaultMessage: '操作',
       }),
       valueType: 'option',
-      align: 'center',
       width: 200,
       fixed: 'right',
       render: (text, record) => [

+ 10 - 2
src/pages/device/Firmware/service.ts

@@ -4,6 +4,11 @@ import SystemConst from '@/utils/const';
 import type { FirmwareItem } from '@/pages/device/Firmware/typings';
 
 class Service extends BaseService<FirmwareItem> {
+  querySystemApi = () =>
+    request(`/${SystemConst.API_BASE}/system/apis`, {
+      method: 'GET',
+    });
+
   task = (params: Record<string, unknown>) =>
     request(`/${SystemConst.API_BASE}/firmware/upgrade/task/detail/_query`, {
       method: 'POST',
@@ -50,8 +55,11 @@ class Service extends BaseService<FirmwareItem> {
       data: params,
     });
 
-  queryProduct = () =>
-    request(`/${SystemConst.API_BASE}/device/product/_query/no-paging?paging=false`);
+  queryProduct = (params?: any) =>
+    request(`/${SystemConst.API_BASE}/device/product/_query/no-paging?paging=false`, {
+      method: 'GET',
+      params,
+    });
 
   queryDevice = () =>
     request(`/${SystemConst.API_BASE}/device/instance/_query/no-paging?paging=false`);

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

@@ -245,7 +245,7 @@ const Instance = () => {
       width: '200px',
       valueType: 'dateTime',
       render: (_: any, row) => {
-        return row.registryTime ? moment(row.registryTime).format('YYYY-MM-DD HH:mm:ss') : '/';
+        return row.registryTime ? moment(row.registryTime).format('YYYY-MM-DD HH:mm:ss') : '';
       },
       sorter: true,
     },

+ 16 - 11
src/pages/media/Cascade/Channel/index.tsx

@@ -4,7 +4,7 @@ import { CloseOutlined, DisconnectOutlined, EditOutlined } from '@ant-design/ico
 import { PageContainer } from '@ant-design/pro-layout';
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import ProTable from '@jetlinks/pro-table';
-import { Button, Input, Popover, Space } from 'antd';
+import { Button, Input, message, Popover, Space } from 'antd';
 import { useRef, useState } from 'react';
 import { useIntl, useLocation } from 'umi';
 import BindChannel from './BindChannel';
@@ -12,6 +12,7 @@ import BadgeStatus, { StatusColorEnum } from '@/components/BadgeStatus';
 import { PermissionButton } from '@/components';
 import { useDomFullHeight } from '@/hooks';
 import { onlyMessage } from '@/utils/util';
+import { Ellipsis } from '@/components';
 
 const Channel = () => {
   const location: any = useLocation();
@@ -55,13 +56,17 @@ const Channel = () => {
           style={{ marginTop: 10, width: '100%' }}
           onClick={async () => {
             if (!!data) {
-              const resp: any = await service.editBindInfo(record.id, {
-                gbChannelId: data,
-              });
-              if (resp.status === 200) {
-                onlyMessage('操作成功');
-                actionRef.current?.reload();
-                setPopvisible('');
+              if (data.length <= 64) {
+                const resp: any = await service.editBindInfo(record.id, {
+                  gbChannelId: data,
+                });
+                if (resp.status === 200) {
+                  onlyMessage('操作成功');
+                  actionRef.current?.reload();
+                  setPopvisible('');
+                }
+              } else {
+                message.error('最多可输入64个字符');
               }
             } else {
               onlyMessage('请输入国标ID', 'error');
@@ -92,8 +97,8 @@ const Channel = () => {
       // ellipsis:true,
       tooltip: '国标级联有18位、20位两种格式。在当前页面修改不会修改视频设备-通道页面中的国标ID',
       render: (text: any, record: any) => (
-        <span>
-          {text}
+        <div style={{ display: 'flex' }}>
+          <Ellipsis title={text || ''} />
           <Popover
             visible={popVisible === record.id}
             trigger="click"
@@ -127,7 +132,7 @@ const Channel = () => {
               <EditOutlined />
             </a>
           </Popover>
-        </span>
+        </div>
       ),
     },
     {

+ 1 - 1
src/pages/media/Cascade/Save/index.tsx

@@ -429,7 +429,7 @@ const Save = () => {
               <div>需与上级平台设置的心跳周期保持一致,通常默认60秒。</div>
               <h2>10、注册间隔</h2>
               <div>
-                若SIP代理通过注册方式校时,其注册过期时间宜设置为小于 SIP代理与 SIP服务器出现1s误
+                若SIP代理通过注册方式校时,其注册间隔时间宜设置为小于 SIP代理与 SIP服务器出现1s误
                 差所经过的运行时间。
               </div>
             </div>