Переглянути джерело

fix(部门管理): 添加重置查询重新查询列表

xieyonghong 3 роки тому
батько
коміт
e145b4a6b5

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

@@ -13,24 +13,26 @@ const Functions = () => {
       <Tabs>
         <Tabs.TabPane tab={'精简模式'} key={1}>
           <Tabs tabPosition="left">
-            {functionList.map((fn) => {
-              return (
-                <Tabs.TabPane tab={fn.name} key={fn.id}>
-                  <FnForm data={fn} />
-                </Tabs.TabPane>
-              );
-            })}
+            {functionList &&
+              functionList.map((fn) => {
+                return (
+                  <Tabs.TabPane tab={fn.name} key={fn.id}>
+                    <FnForm data={fn} />
+                  </Tabs.TabPane>
+                );
+              })}
           </Tabs>
         </Tabs.TabPane>
         <Tabs.TabPane tab={'高级模式'} key={2}>
           <Tabs tabPosition="left">
-            {functionList.map((fn) => {
-              return (
-                <Tabs.TabPane tab={fn.name} key={fn.id}>
-                  <AModel data={fn} />
-                </Tabs.TabPane>
-              );
-            })}
+            {functionList &&
+              functionList.map((fn) => {
+                return (
+                  <Tabs.TabPane tab={fn.name} key={fn.id}>
+                    <AModel data={fn} />
+                  </Tabs.TabPane>
+                );
+              })}
           </Tabs>
         </Tabs.TabPane>
       </Tabs>

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

@@ -112,8 +112,7 @@ const Info = observer(() => {
           if (data) {
             InstanceModel.detail = {
               ...InstanceModel.detail,
-              name: data?.name,
-              description: data?.describe,
+              ...data,
             };
           }
         }}

+ 35 - 19
src/pages/device/Instance/Detail/index.tsx

@@ -1,9 +1,8 @@
 import { PageContainer } from '@ant-design/pro-layout';
 import { InstanceModel, service } from '@/pages/device/Instance';
 import { history, useParams } from 'umi';
-import { Badge, Button, Card, Divider, message, Tooltip } from 'antd';
+import { Badge, Button, Card, Descriptions, Divider, message, Tooltip } from 'antd';
 import { useEffect, useState } from 'react';
-import { statusMap } from '@/pages/device/Product';
 import { observer } from '@formily/react';
 import Log from '@/pages/device/Instance/Detail/Log';
 import Alarm from '@/pages/device/components/Alarm';
@@ -17,6 +16,7 @@ import type { DeviceMetadata } from '@/pages/device/Product/typings';
 import MetadataAction from '@/pages/device/components/Metadata/DataBaseAction';
 import { Store } from 'jetlinks-store';
 import SystemConst from '@/utils/const';
+import { getMenuPathByCode, MENUS_CODE } from '@/utils/menu';
 
 export const deviceStatus = new Map();
 deviceStatus.set('online', <Badge status="success" text={'在线'} />);
@@ -29,7 +29,7 @@ const InstanceDetail = observer(() => {
     service.detail(id).then((response) => {
       InstanceModel.detail = response?.result;
       // 写入物模型数据
-      const metadata: DeviceMetadata = JSON.parse(response.result?.metadata);
+      const metadata: DeviceMetadata = JSON.parse(response.result?.metadata || '{}');
       MetadataAction.insert(metadata);
     });
   };
@@ -151,7 +151,23 @@ const InstanceDetail = observer(() => {
       onBack={history.goBack}
       onTabChange={setTab}
       tabList={list}
-      // content={<Info />}
+      content={
+        <Descriptions size="small" column={4}>
+          <Descriptions.Item label={'ID'}>{InstanceModel.detail.id}</Descriptions.Item>
+          <Descriptions.Item label={'所属产品'}>
+            <Button
+              type={'link'}
+              size={'small'}
+              onClick={() => {
+                const url = getMenuPathByCode(MENUS_CODE['device/Product']);
+                history.push(`${url}?id=${InstanceModel.detail.productId}`);
+              }}
+            >
+              {InstanceModel.detail.productName}
+            </Button>
+          </Descriptions.Item>
+        </Descriptions>
+      }
       title={
         <>
           {InstanceModel.detail.name}
@@ -159,21 +175,21 @@ const InstanceDetail = observer(() => {
           {deviceStatus.get(InstanceModel.detail.state?.value)}
         </>
       }
-      extra={[
-        statusMap[0],
-        <Button key="2">
-          {intl.formatMessage({
-            id: 'pages.device.productDetail.disable',
-            defaultMessage: '停用',
-          })}
-        </Button>,
-        <Button key="1" type="primary">
-          {intl.formatMessage({
-            id: 'pages.device.productDetail.setting',
-            defaultMessage: '应用配置',
-          })}
-        </Button>,
-      ]}
+      // extra={[
+      //   statusMap[0],
+      //   <Button key="2">
+      //     {intl.formatMessage({
+      //       id: 'pages.device.productDetail.disable',
+      //       defaultMessage: '停用',
+      //     })}
+      //   </Button>,
+      //   <Button key="1" type="primary">
+      //     {intl.formatMessage({
+      //       id: 'pages.device.productDetail.setting',
+      //       defaultMessage: '应用配置',
+      //     })}
+      //   </Button>,
+      // ]}
     >
       {list.find((k) => k.key === tab)?.component}
     </PageContainer>

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

@@ -74,7 +74,7 @@ const Save = (props: Props) => {
         if (props.reload) {
           props.reload();
         }
-        props.close(resp.result);
+        props.close(values);
         form.resetFields();
       }
     }
@@ -202,7 +202,7 @@ const Save = (props: Props) => {
                 options={productList}
                 onSelect={(_: any, node: any) => {
                   form.setFieldsValue({
-                    productName: node.name,
+                    productName: node.label,
                   });
                 }}
               />

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

@@ -77,6 +77,7 @@ const Instance = () => {
     >
       <Button
         type={'link'}
+        style={{ padding: 0 }}
         onClick={() => {
           InstanceModel.current = record;
           const url = getMenuPathByParams(MENUS_CODE['device/Instance/Detail'], record.id);
@@ -112,7 +113,7 @@ const Instance = () => {
           defaultMessage: record.state.value !== 'notActive' ? '禁用' : '启用',
         })}
       >
-        <Button type={'link'}>
+        <Button type={'link'} style={{ padding: 0 }}>
           {record.state.value !== 'notActive' ? <StopOutlined /> : <CheckCircleOutlined />}
         </Button>
       </Tooltip>
@@ -145,7 +146,7 @@ const Instance = () => {
           defaultMessage: '删除',
         })}
       >
-        <Button type={'link'}>
+        <Button type={'link'} style={{ padding: 0 }}>
           <DeleteOutlined />
         </Button>
       </Tooltip>
@@ -345,6 +346,7 @@ const Instance = () => {
         field={columns}
         target="device-instance"
         onSearch={(data) => {
+          console.log(data);
           // 重置分页数据
           actionRef.current?.reset?.();
           setSearchParams(data);

+ 1 - 8
src/pages/device/Product/Detail/BaseInfo/index.tsx

@@ -144,14 +144,7 @@ const BaseInfo = () => {
         ]}
         bordered
       >
-        <Descriptions.Item
-          label={intl.formatMessage({
-            id: 'pages.device.category',
-            defaultMessage: '产品ID',
-          })}
-        >
-          {productModel.current?.id}
-        </Descriptions.Item>
+        <Descriptions.Item label={'ID'}>{productModel.current?.id}</Descriptions.Item>
         <Descriptions.Item
           label={intl.formatMessage({
             id: 'pages.device.productDetail.classifiedName',

+ 20 - 7
src/pages/device/Product/index.tsx

@@ -92,9 +92,7 @@ const Product = observer(() => {
    * @param data
    */
   const searchFn = (data: any) => {
-    setQueryParam({
-      terms: data,
-    });
+    setQueryParam(data);
   };
 
   const changeDeploy = (id: string, state: 'deploy' | 'undeploy') => {
@@ -119,6 +117,7 @@ const Product = observer(() => {
           productModel.current = record;
           history.push(`${getMenuPathByParams(MENUS_CODE['device/Product/Detail'], record.id)}`);
         }}
+        style={{ padding: 0 }}
       >
         <EyeOutlined />
       </Button>
@@ -137,6 +136,7 @@ const Product = observer(() => {
           setVisible(true);
         }}
         type={'link'}
+        style={{ padding: 0 }}
       >
         <EditOutlined />
       </Button>
@@ -148,7 +148,7 @@ const Product = observer(() => {
       })}
       key={'download'}
     >
-      <Button type={'link'}>
+      <Button type={'link'} style={{ padding: 0 }}>
         <DownloadOutlined
           onClick={async () => {
             await message.success(
@@ -177,7 +177,9 @@ const Product = observer(() => {
           defaultMessage: record.state ? '禁用' : '启用',
         })}
       >
-        <Button type={'link'}>{record.state ? <StopOutlined /> : <PlayCircleOutlined />}</Button>
+        <Button style={{ padding: 0 }} type={'link'}>
+          {record.state ? <StopOutlined /> : <PlayCircleOutlined />}
+        </Button>
       </Tooltip>
     </Popconfirm>,
     <Popconfirm
@@ -201,7 +203,7 @@ const Product = observer(() => {
         })}
         key={'remove'}
       >
-        <Button type={'link'}>
+        <Button type={'link'} style={{ padding: 0 }}>
           <DeleteOutlined />
         </Button>
       </Tooltip>
@@ -240,7 +242,15 @@ const Product = observer(() => {
 
   return (
     <PageContainer>
-      <SearchComponent field={columns} onSearch={searchFn} />
+      <SearchComponent
+        field={columns}
+        onSearch={searchFn}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          searchFn({});
+        }}
+      />
       <ProTableCard<ProductItem>
         columns={columns}
         actionRef={actionRef}
@@ -280,6 +290,9 @@ const Product = observer(() => {
               defaultMessage: '新增',
             })}
           </Button>,
+          <Button onClick={() => {}} key={'import'} type={'primary'}>
+            导入
+          </Button>,
         ]}
         cardRender={(record) => <ProductCard {...record} actions={tools(record)} />}
       />

+ 5 - 0
src/pages/system/Department/Assets/deivce/bind.tsx

@@ -122,6 +122,11 @@ const Bind = observer((props: Props) => {
           actionRef.current?.reset?.();
           setSearchParam(data);
         }}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          setSearchParam({});
+        }}
         target="department-assets-device"
       />
       <ProTable<DeviceItem>

+ 5 - 0
src/pages/system/Department/Assets/deivce/index.tsx

@@ -201,6 +201,11 @@ export default observer(() => {
           actionRef.current?.reset?.();
           setSearchParam(data);
         }}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          setSearchParam({});
+        }}
         target="department-assets-device"
       />
       <ProTable<DeviceItem>

+ 5 - 0
src/pages/system/Department/Assets/product/bind.tsx

@@ -110,6 +110,11 @@ const Bind = observer((props: Props) => {
           actionRef.current?.reset?.();
           setSearchParam(data);
         }}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          setSearchParam({});
+        }}
         target="department-assets-product"
       />
       <ProTable<ProductItem>

+ 5 - 0
src/pages/system/Department/Assets/product/index.tsx

@@ -142,6 +142,11 @@ export default observer(() => {
           actionRef.current?.reset?.();
           setSearchParam(data);
         }}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          setSearchParam({});
+        }}
         target="department-assets-product"
       />
       <ProTable<ProductItem>

+ 5 - 0
src/pages/system/Department/Assets/productCategory/bind.tsx

@@ -109,6 +109,11 @@ const Bind = observer((props: Props) => {
           actionRef.current?.reset?.();
           setSearchParam(data);
         }}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          setSearchParam({});
+        }}
         target="department-assets-category"
       />
       <ProTable<ProductCategoryItem>

+ 5 - 0
src/pages/system/Department/Assets/productCategory/index.tsx

@@ -162,6 +162,11 @@ export default observer(() => {
           actionRef.current?.reset?.();
           setSearchParam(data);
         }}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          setSearchParam({});
+        }}
         target="department-assets-category"
       />
       <ProTable<ProductCategoryItem>

+ 5 - 0
src/pages/system/Department/Member/bind.tsx

@@ -84,6 +84,11 @@ const Bind = observer((props: Props) => {
           actionRef.current?.reset?.();
           setSearchParam(data);
         }}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          setSearchParam({});
+        }}
         target="department-user"
       />
       <ProTable

+ 5 - 0
src/pages/system/Department/Member/index.tsx

@@ -162,6 +162,11 @@ const Member = observer(() => {
           actionRef.current?.reset?.();
           setSearchParam(data);
         }}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          setSearchParam({});
+        }}
         target="department-user"
       />
       <ProTable<MemberItem>

+ 10 - 4
src/pages/system/Menu/index.tsx

@@ -191,9 +191,7 @@ export default observer(() => {
    * @param data
    */
   const searchFn = (data: any) => {
-    setParam({
-      terms: data,
-    });
+    setParam(data);
   };
 
   // const modalCancel = () => {
@@ -222,7 +220,15 @@ export default observer(() => {
 
   return (
     <PageContainer>
-      <SearchComponent field={columns} onSearch={searchFn} />
+      <SearchComponent
+        field={columns}
+        onSearch={searchFn}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          searchFn({});
+        }}
+      />
       <ProTable<MenuItem>
         columns={columns}
         actionRef={actionRef}

+ 0 - 1
src/utils/menu.ts

@@ -211,7 +211,6 @@ export const saveMenusCache = (routes: MenuItem[]) => {
 export const getMenuPathByCode = (code: string): string => {
   const menusStr = localStorage.getItem(MENUS_DATA_CACHE) || '{}';
   const menusData = JSON.parse(menusStr);
-  console.log(code, menusData);
   return menusData[code];
 };