Browse Source

fix(product): fix search option

Lind 3 years ago
parent
commit
51d6d6018f
2 changed files with 20 additions and 9 deletions
  1. 10 8
      src/pages/device/Instance/index.tsx
  2. 10 1
      src/pages/device/Product/index.tsx

+ 10 - 8
src/pages/device/Instance/index.tsx

@@ -177,6 +177,7 @@ const Instance = () => {
       }),
       dataIndex: 'registryTime',
       width: '200px',
+      valueType: 'dateTime',
       render: (text: any) => (text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '/'),
       sorter: true,
     },
@@ -187,31 +188,32 @@ const Instance = () => {
       }),
       dataIndex: 'state',
       width: '90px',
+      valueType: 'select',
       renderText: (record) =>
         record ? <Badge status={statusMap.get(record.value)} text={record.text} /> : '',
-      filters: [
-        {
+      valueEnum: {
+        notActive: {
           text: intl.formatMessage({
             id: 'pages.device.instance.status.notActive',
             defaultMessage: '未启用',
           }),
-          value: 'notActive',
+          status: 'notActive',
         },
-        {
+        offline: {
           text: intl.formatMessage({
             id: 'pages.device.instance.status.offLine',
             defaultMessage: '离线',
           }),
-          value: 'offline',
+          status: 'offline',
         },
-        {
+        online: {
           text: intl.formatMessage({
             id: 'pages.device.instance.status.onLine',
             defaultMessage: '在线',
           }),
-          value: 'online',
+          status: 'online',
         },
-      ],
+      },
       filterMultiple: false,
     },
     {

+ 10 - 1
src/pages/device/Product/index.tsx

@@ -92,6 +92,7 @@ const Product = observer(() => {
    * @param data
    */
   const searchFn = (data: any) => {
+    actionRef.current?.reset?.();
     setQueryParam(data);
   };
 
@@ -253,7 +254,15 @@ const Product = observer(() => {
 
   return (
     <PageContainer>
-      <SearchComponent field={columns} onSearch={searchFn} />
+      <SearchComponent
+        field={columns}
+        onSearch={searchFn}
+        onReset={() => {
+          // 重置分页及搜索参数
+          actionRef.current?.reset?.();
+          setQueryParam({});
+        }}
+      />
       <ProTableCard<ProductItem>
         columns={columns}
         actionRef={actionRef}