Просмотр исходного кода

fix(bug): bug#5487、5349、5203、5160、5066、5012、5000、5541、5232

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

+ 20 - 5
src/components/DashBoard/header.tsx

@@ -4,6 +4,11 @@ import { Col, Form, Radio, Row } from 'antd';
 import type { TimeType } from './timePicker';
 import RangePicker, { TimeKey } from './timePicker';
 
+interface timeToolOptions {
+  label: string;
+  value: string;
+}
+
 export interface HeaderProps {
   title: string;
   /**
@@ -20,9 +25,10 @@ export interface HeaderProps {
    * true 关闭初始化时触发onParamsChange
    */
   closeInitialParams?: boolean;
-  defaultTime?: TimeType;
+  defaultTime?: TimeType & string;
   showTime?: boolean;
   showTimeTool?: boolean;
+  timeToolOptions?: timeToolOptions[];
 }
 
 export default forwardRef((props: HeaderProps, ref) => {
@@ -83,16 +89,25 @@ export default forwardRef((props: HeaderProps, ref) => {
                       }
                     }}
                   >
-                    <Radio.Button value={TimeKey.today}>当天</Radio.Button>
-                    <Radio.Button value={TimeKey.week}>近一周</Radio.Button>
-                    <Radio.Button value={TimeKey.month}>近一月</Radio.Button>
-                    <Radio.Button value={TimeKey.year}>近一年</Radio.Button>
+                    {props.timeToolOptions && Array.isArray(props.timeToolOptions) ? (
+                      props.timeToolOptions.map((item) => (
+                        <Radio.Button value={item.value}>{item.label}</Radio.Button>
+                      ))
+                    ) : (
+                      <>
+                        <Radio.Button value={TimeKey.today}>当天</Radio.Button>
+                        <Radio.Button value={TimeKey.week}>近一周</Radio.Button>
+                        <Radio.Button value={TimeKey.month}>近一月</Radio.Button>
+                        <Radio.Button value={TimeKey.year}>近一年</Radio.Button>
+                      </>
+                    )}
                   </Radio.Group>
                 ) : null}
                 <Form.Item noStyle name={'time'}>
                   <RangePicker
                     ref={pickerRef}
                     defaultTime={props.defaultTime}
+                    timeToolOptions={props.timeToolOptions}
                     showTime={props.showTime}
                     showTimeTool={props.showTimeTool}
                     pickerTimeChange={() => {

+ 21 - 4
src/components/DashBoard/timePicker.tsx

@@ -4,6 +4,7 @@ import moment from 'moment';
 import { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
 
 export enum TimeKey {
+  'hour' = 'hour',
   'today' = 'today',
   'week' = 'week',
   'month' = 'month',
@@ -14,6 +15,11 @@ export type TimeType = keyof typeof TimeKey;
 
 type ValueType = { start: number; end: number; type: TimeType };
 
+type timeToolOptions = {
+  label: string;
+  value: string;
+};
+
 interface ExtraTimePickerProps extends Omit<DatePickerProps, 'onChange' | 'value'> {
   onChange?: (data: ValueType) => void;
   value?: ValueType;
@@ -21,10 +27,13 @@ interface ExtraTimePickerProps extends Omit<DatePickerProps, 'onChange' | 'value
   pickerTimeChange?: () => void;
   showTime?: boolean;
   showTimeTool?: boolean;
+  timeToolOptions?: timeToolOptions[];
 }
 
 export const getTimeByType = (type: TimeType) => {
   switch (type) {
+    case TimeKey.hour:
+      return moment().subtract(1, 'hours').valueOf();
     case TimeKey.week:
       return moment().subtract(6, 'days').valueOf();
     case TimeKey.month:
@@ -101,10 +110,18 @@ export default forwardRef((props: ExtraTimePickerProps, ref) => {
                         timeChange(e.target.value);
                       }}
                     >
-                      <Radio.Button value={TimeKey.today}>当天</Radio.Button>
-                      <Radio.Button value={TimeKey.week}>近一周</Radio.Button>
-                      <Radio.Button value={TimeKey.month}>近一月</Radio.Button>
-                      <Radio.Button value={TimeKey.year}>近一年</Radio.Button>
+                      {props.timeToolOptions && Array.isArray(props.timeToolOptions) ? (
+                        props.timeToolOptions.map((item) => (
+                          <Radio.Button value={item.value}>{item.label}</Radio.Button>
+                        ))
+                      ) : (
+                        <>
+                          <Radio.Button value={TimeKey.today}>当天</Radio.Button>
+                          <Radio.Button value={TimeKey.week}>近一周</Radio.Button>
+                          <Radio.Button value={TimeKey.month}>近一月</Radio.Button>
+                          <Radio.Button value={TimeKey.year}>近一年</Radio.Button>
+                        </>
+                      )}
                     </Radio.Group>
                   </div>
                 )

+ 32 - 7
src/components/SearchComponent/index.tsx

@@ -399,7 +399,7 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
 
   const handleForm = (_expand?: boolean) => {
     const value = form.values;
-    const __expand = _expand || expand;
+    const __expand = _expand !== undefined ? _expand : expand;
     // 第一组条件值
     const _terms1 = _.cloneDeep(value.terms1?.[0]);
     const uiParam = uiParamRef.current;
@@ -416,11 +416,12 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
         uiParam?.[1]?.terms?.[2] || defaultTerms(5),
       ];
     } else {
-      value.terms1 = _terms1 ? [_terms1] : [defaultTerms(0)];
+      value.terms1 = [uiParam?.[0]?.terms?.[0] || _terms1 || defaultTerms(0)];
       value.terms2 = [];
     }
     setInitParams(value);
   };
+
   const handleExpand = () => {
     handleForm();
     setExpand(!expand);
@@ -451,7 +452,7 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
     setLogVisible(false);
     uiParamRef.current = ui2Server(log);
     const _expand =
-      (log.terms1 && log.terms1?.length > 1) || (log.terms2 && log.terms2?.length > 1);
+      !!(log.terms1 && log.terms1.length > 1) || !!(log.terms2 && log.terms2.length > 1);
     if (_expand) {
       setExpand(false);
     }
@@ -532,6 +533,17 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
     _terms.terms1 = filterTerms(_terms.terms1);
     _terms.terms2 = filterTerms(_terms.terms2);
     const _temp = formatValue(_terms);
+
+    if (
+      (_terms.terms1 && _terms.terms1.length > 1) ||
+      (_terms.terms2 && _terms.terms2.length > 1)
+    ) {
+      // 展开高级搜索
+      uiParamRef.current = ui2Server(value);
+      setExpand(false);
+      handleForm(true);
+    }
+
     if (type) {
       setUrl({ q: JSON.stringify(value) });
     }
@@ -566,7 +578,8 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
     setAliasVisible(!aliasVisible);
   };
 
-  const resetForm = async () => {
+  const resetForm = async (type: boolean) => {
+    console.log('resetForm', type);
     const value = form.values;
     if (!expand) {
       value.terms1 = [defaultTerms(0), defaultTerms(1), defaultTerms(2)];
@@ -576,7 +589,7 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
       value.terms2 = [];
     }
     setInitParams(value);
-    await handleSearch();
+    await handleSearch(type);
   };
 
   const SearchBtn = {
@@ -584,7 +597,13 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
       <>
         {
           // @ts-ignore
-          <Button icon={<SearchOutlined />} onClick={handleSearch} type="primary">
+          <Button
+            icon={<SearchOutlined />}
+            onClick={() => {
+              handleSearch(false);
+            }}
+            type="primary"
+          >
             搜索
           </Button>
         }
@@ -665,7 +684,13 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
             <Space>
               {enableSave ? SearchBtn.advance : SearchBtn.simple}
               {enableSave && SaveBtn}
-              <Button icon={<ReloadOutlined />} block onClick={resetForm}>
+              <Button
+                icon={<ReloadOutlined />}
+                block
+                onClick={() => {
+                  resetForm(model !== 'simple');
+                }}
+              >
                 重置
               </Button>
             </Space>

+ 3 - 3
src/pages/Northbound/DuerOS/Detail/Doc.tsx

@@ -25,7 +25,7 @@ const Doc = () => {
       </div>
       <h1>2. 操作步骤</h1>
       <div>
-        <h2>1、在百度小度技能平台创建技能,并授权。完成物联网平台与dueros的关联。</h2>
+        <h2>1、在百度小度技能平台创建技能,并授权。完成物联网平台与DuerOS的关联。</h2>
         <div className={'image'}>
           <Image width="100%" src={image} />
         </div>
@@ -59,7 +59,7 @@ const Doc = () => {
         <div></div>
         <h1>WebService</h1>
         <div>请复制并填写:/dueros/product/_query</div>
-        <h2>2、登录物联网平台,进行平台内产品与dueros产品的数据映射。</h2>
+        <h2>2、登录物联网平台,进行平台内产品与DuerOS产品的数据映射。</h2>
         <h2>
           3、智能家居用户通过物联网平台中的用户,登录小度APP,获取平台内当前用户的所属设备。获取后即可进行语音控制。
         </h2>
@@ -67,7 +67,7 @@ const Doc = () => {
       <h1>3. 配置说明</h1>
       <div>
         <h2>
-          1、“设备类型”为dueros平台拟定的标准规范,设备类型将决定【动作映射】中“动作”的下拉选项,以及【属性映射】中“Dueros属性”的下拉选项
+          1、“设备类型”为DuerOS平台拟定的标准规范,设备类型将决定【动作映射】中“动作”的下拉选项,以及【属性映射】中“Dueros属性”的下拉选项
         </h2>
       </div>
     </div>

+ 16 - 5
src/pages/Northbound/DuerOS/Detail/index.tsx

@@ -136,6 +136,13 @@ const Save = () => {
               });
             },
           );
+          onFieldValueChange('id', (field, form1) => {
+            form1.setFieldState(field.query('productName'), (state) => {
+              if (field && field.inputValues && field && field.inputValues[1]) {
+                state.value = field.inputValues[1].label;
+              }
+            });
+          });
           onFieldReact('propertyMappings.*.layout.source', (field, f) => {
             const productType = field.query('applianceType').value();
             const propertiesList = findApplianceType(productType)?.properties;
@@ -292,6 +299,13 @@ const Save = () => {
             'x-reactions': '{{useAsyncDataSource(getTypes)}}',
             required: true,
           },
+          productName: {
+            title: '产品名称',
+            type: 'string',
+            'x-decorator': 'FormItem',
+            'x-component': 'Input',
+            'x-hidden': true,
+          },
         },
       },
       actionMappings: {
@@ -639,14 +653,11 @@ const Save = () => {
 
   const handleSave = async () => {
     const data: any = await form.submit();
-    const productName = Store.get('product-list')?.find((item: any) => item.id === data.id)?.name;
-    const resp: any = await service.savePatch({ ...data, productName });
+    const resp: any = await service.savePatch(data);
     if (resp.status === 200) {
       onlyMessage('保存成功!');
-    } else {
-      onlyMessage('保存失败!', 'error');
+      history.back();
     }
-    history.back();
   };
   return (
     <PageContainer>

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

@@ -659,7 +659,7 @@ const Instance = () => {
                   onConfirm: async () => {
                     if (record.state.value === 'notActive') {
                       const resp: any = await service.remove(record.id);
-                      if (resp.code === 200) {
+                      if (resp.status === 200) {
                         onlyMessage(
                           intl.formatMessage({
                             id: 'pages.data.option.success',

+ 13 - 6
src/pages/link/DashBoard/index.tsx

@@ -151,6 +151,11 @@ export default () => {
   const [cpuOptions, setCpuOptions] = useState<EChartsOption | undefined>(undefined);
   const [jvmOptions, setJvmOptions] = useState<EChartsOption | undefined>(undefined);
   const [serverId, setServerId] = useState(undefined);
+  const [timeToolOptions] = useState([
+    { label: '最近1小时', value: 'hour' },
+    { label: '当天', value: 'today' },
+    { label: '近一周', value: 'week' },
+  ]);
 
   const [topValues, setTopValues] = useState({
     cpu: 0,
@@ -185,6 +190,8 @@ export default () => {
         return 'MM-DD';
       case 'week':
         return 'MM-DD HH';
+      case 'hour':
+        return 'HH:mm';
       default:
         return 'HH';
     }
@@ -389,7 +396,6 @@ export default () => {
           params: {
             from: cpuData.time.start,
             to: cpuData.time.end,
-            interval: getInterval(cpuData.time.type),
           },
         },
         {
@@ -401,7 +407,6 @@ export default () => {
           params: {
             from: jvmData.time.start,
             to: jvmData.time.end,
-            interval: getInterval(jvmData.time.type),
           },
         },
       ])
@@ -438,13 +443,13 @@ export default () => {
                 if (!_jvmOptions[nodeID]) {
                   _jvmOptions[nodeID] = [];
                 }
-                _jvmXAxis.add(moment(value.timestamp).format(getTimeFormat('week')));
+                _jvmXAxis.add(moment(value.timestamp).format(getTimeFormat(jvmData.time.type)));
                 _jvmOptions[nodeID].push(_value);
               } else {
                 if (!_cpuOptions[nodeID]) {
                   _cpuOptions[nodeID] = [];
                 }
-                _cpuXAxis.add(moment(value.timestamp).format(getTimeFormat('week')));
+                _cpuXAxis.add(moment(value.timestamp).format(getTimeFormat(cpuData.time.type)));
                 _cpuOptions[nodeID].push(Number(value.cpuSystemUsage).toFixed(2));
               }
             });
@@ -729,8 +734,9 @@ export default () => {
             closeInitialParams={true}
             ref={CPURef}
             height={400}
-            defaultTime={'week'}
+            defaultTime={'hour'}
             options={cpuOptions}
+            timeToolOptions={timeToolOptions}
             onParamsChange={getCPUEcharts}
           />
           <DashBoard
@@ -738,8 +744,9 @@ export default () => {
             closeInitialParams={true}
             ref={JVMRef}
             height={400}
-            defaultTime={'week'}
+            defaultTime={'hour'}
             options={jvmOptions}
+            timeToolOptions={timeToolOptions}
             onParamsChange={getJVMEcharts}
           />
         </div>

+ 1 - 1
src/pages/media/Device/Channel/Live/index.tsx

@@ -30,7 +30,7 @@ const LiveFC = (props: LiveProps) => {
     if (props.channelId && props.deviceId) {
       //   查询当前视频是否在录像
       service.ptzIsRecord(props.deviceId, props.channelId).then((res) => {
-        if (res.code === 200) {
+        if (res.status === 200) {
           setIsRecord(res.result ? 2 : 0);
         }
       });

+ 1 - 1
src/pages/media/Device/Channel/Save.tsx

@@ -110,7 +110,6 @@ const Save = (props: SaveModalProps) => {
             ],
             'x-decorator-props': {
               gridSpan: 1,
-              tooltip: '不同厂家的RTSP固定地址规则不同,请按对应厂家的规则填写',
             },
           },
           manufacturer: {
@@ -166,6 +165,7 @@ const Save = (props: SaveModalProps) => {
             ],
             'x-decorator-props': {
               gridSpan: 2,
+              tooltip: '不同厂家的RTSP固定地址规则不同,请按对应厂家的规则填写',
             },
           },
           username: {

+ 11 - 12
src/pages/media/Device/index.tsx

@@ -277,7 +277,7 @@ const Device = () => {
         <PermissionButton
           key={'delete'}
           tooltip={{
-            title: '删除',
+            title: record.state.value === 'online' ? '在线设备无法删除' : '删除',
           }}
           popConfirm={{
             title: (
@@ -292,7 +292,7 @@ const Device = () => {
               </div>
             ),
             onConfirm: async () => {
-              if (record.state.value === 'offline') {
+              if (record.state.value !== 'online') {
                 await deleteItem(record.id);
               } else {
                 onlyMessage('在线设备不能进行删除操作', 'error');
@@ -302,7 +302,7 @@ const Device = () => {
           type={'link'}
           style={{ padding: 0 }}
           isPermission={permission.delete}
-          disabled={record.state.value !== 'offline'}
+          disabled={record.state.value === 'online'}
         >
           <DeleteOutlined />
         </PermissionButton>,
@@ -398,9 +398,7 @@ const Device = () => {
                 key={'updateChannel'}
                 isPermission={permission.update}
                 tooltip={
-                  record.state.value === 'offline' ||
-                  record.state.value === 'notActive' ||
-                  record.provider === providerType['fixed-media']
+                  record.state.value !== 'online' || record.provider === providerType['fixed-media']
                     ? {
                         title:
                           record.provider === providerType['fixed-media']
@@ -414,9 +412,7 @@ const Device = () => {
                     : undefined
                 }
                 disabled={
-                  record.state.value === 'offline' ||
-                  record.state.value === 'notActive' ||
-                  record.provider === providerType['fixed-media']
+                  record.state.value !== 'online' || record.provider === providerType['fixed-media']
                 }
                 onClick={() => {
                   updateChannel(record.id);
@@ -430,23 +426,26 @@ const Device = () => {
                 popConfirm={{
                   title: intl.formatMessage({
                     id:
-                      record.state.value === 'online'
+                      record.state.value !== 'online'
                         ? 'page.table.isDelete'
                         : 'pages.device.instance.deleteTip',
                     defaultMessage: '是否删除?',
                   }),
                   onConfirm: async () => {
-                    if (record.state.value === 'offline' || record.state.value === 'notActive') {
+                    if (record.state.value !== 'online') {
                       await deleteItem(record.id);
                     } else {
                       onlyMessage('在线设备不能进行删除操作', 'error');
                     }
                   },
                 }}
+                tooltip={
+                  record.state.value === 'online' ? { title: '在线设备无法删除' } : undefined
+                }
                 type={'link'}
                 style={{ padding: 0 }}
                 isPermission={permission.delete}
-                disabled={record.state.value !== 'offline'}
+                disabled={record.state.value === 'online'}
               >
                 <DeleteOutlined />
               </PermissionButton>,

+ 1 - 0
src/pages/rule-engine/Alarm/Log/SolveLog/index.tsx

@@ -85,6 +85,7 @@ const SolveLog = (props: Props) => {
         field={columns}
         target="bind-channel"
         enableSave={false}
+        model={'simple'}
         onSearch={(data) => {
           actionRef.current?.reload();
           const terms = [