Explorar o código

fix(查询组件替换): 替换查询组件

xieyonghong %!s(int64=3) %!d(string=hai) anos
pai
achega
922b306545

+ 28 - 20
src/pages/system/Department/Assets/deivce/bind.tsx

@@ -10,6 +10,7 @@ import { observer } from '@formily/react';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import type { DeviceItem } from '@/pages/system/Department/typings';
 import PermissionModal from '@/pages/system/Department/Assets/permissionModal';
+import SearchComponent from '@/components/SearchComponent';
 
 interface Props {
   reload: () => void;
@@ -22,6 +23,7 @@ const Bind = observer((props: Props) => {
   const param = useParams<{ id: string }>();
   const actionRef = useRef<ActionType>();
   const [perVisible, setPerVisible] = useState(false);
+  const [searchParam, setSearchParam] = useState({});
 
   const columns: ProColumns<DeviceItem>[] = [
     {
@@ -98,13 +100,35 @@ const Bind = observer((props: Props) => {
           }
         }}
       />
+      <SearchComponent<DeviceItem>
+        field={columns}
+        pattern={'simple'}
+        defaultParam={[
+          {
+            column: 'id',
+            termType: 'dim-assets$not',
+            value: {
+              assetType: 'device',
+              targets: [
+                {
+                  type: 'org',
+                  id: param.id,
+                },
+              ],
+            },
+          },
+        ]}
+        onSearch={async (data) => {
+          actionRef.current?.reset?.();
+          setSearchParam(data);
+        }}
+        target="department-assets-device"
+      />
       <ProTable<DeviceItem>
         actionRef={actionRef}
         columns={columns}
         rowKey="id"
-        pagination={{
-          pageSize: 5,
-        }}
+        search={false}
         rowSelection={{
           selectedRowKeys: Models.bindKeys,
           onChange: (selectedRowKeys, selectedRows) => {
@@ -112,23 +136,7 @@ const Bind = observer((props: Props) => {
           },
         }}
         request={(params) => service.queryDeviceList(params)}
-        params={{
-          terms: [
-            {
-              column: 'id',
-              termType: 'dim-assets$not',
-              value: {
-                assetType: 'device',
-                targets: [
-                  {
-                    type: 'org',
-                    id: param.id,
-                  },
-                ],
-              },
-            },
-          ],
-        }}
+        params={searchParam}
       />
     </Modal>
   );

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

@@ -182,7 +182,6 @@ export default observer(() => {
       />
       <SearchComponent<DeviceItem>
         field={columns}
-        pattern={'simple'}
         defaultParam={[
           {
             column: 'id',

+ 31 - 20
src/pages/system/Department/Assets/product/bind.tsx

@@ -8,8 +8,9 @@ import Models from './model';
 import { useEffect, useRef, useState } from 'react';
 import { observer } from '@formily/react';
 import { useIntl } from '@@/plugin-locale/localeExports';
-import type { ProductCategoryItem } from '@/pages/system/Department/typings';
 import PermissionModal from '@/pages/system/Department/Assets/permissionModal';
+import type { ProductItem } from '@/pages/system/Department/typings';
+import SearchComponent from '@/components/SearchComponent';
 
 interface Props {
   reload: () => void;
@@ -22,8 +23,9 @@ const Bind = observer((props: Props) => {
   const param = useParams<{ id: string }>();
   const actionRef = useRef<ActionType>();
   const [perVisible, setPerVisible] = useState(false);
+  const [searchParam, setSearchParam] = useState({});
 
-  const columns: ProColumns<ProductCategoryItem>[] = [
+  const columns: ProColumns<ProductItem>[] = [
     {
       dataIndex: 'id',
       title: 'ID',
@@ -86,10 +88,35 @@ const Bind = observer((props: Props) => {
           }
         }}
       />
-      <ProTable<ProductCategoryItem>
+      <SearchComponent<ProductItem>
+        field={columns}
+        pattern={'simple'}
+        defaultParam={[
+          {
+            column: 'id',
+            termType: 'dim-assets$not',
+            value: {
+              assetType: 'product',
+              targets: [
+                {
+                  type: 'org',
+                  id: param.id,
+                },
+              ],
+            },
+          },
+        ]}
+        onSearch={async (data) => {
+          actionRef.current?.reset?.();
+          setSearchParam(data);
+        }}
+        target="department-assets-product"
+      />
+      <ProTable<ProductItem>
         actionRef={actionRef}
         columns={columns}
         rowKey="id"
+        search={false}
         pagination={{
           pageSize: 5,
         }}
@@ -100,23 +127,7 @@ const Bind = observer((props: Props) => {
           },
         }}
         request={(params) => service.queryProductList(params)}
-        params={{
-          terms: [
-            {
-              column: 'id',
-              termType: 'dim-assets$not',
-              value: {
-                assetType: 'product',
-                targets: [
-                  {
-                    type: 'org',
-                    id: param.id,
-                  },
-                ],
-              },
-            },
-          ],
-        }}
+        params={searchParam}
       />
     </Modal>
   );

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

@@ -123,7 +123,6 @@ export default observer(() => {
       />
       <SearchComponent<ProductItem>
         field={columns}
-        pattern={'simple'}
         defaultParam={[
           {
             column: 'id',

+ 28 - 17
src/pages/system/Department/Assets/productCategory/bind.tsx

@@ -10,6 +10,7 @@ import { observer } from '@formily/react';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import type { ProductCategoryItem } from '@/pages/system/Department/typings';
 import PermissionModal from '@/pages/system/Department/Assets/permissionModal';
+import SearchComponent from '@/components/SearchComponent';
 
 interface Props {
   reload: () => void;
@@ -22,6 +23,7 @@ const Bind = observer((props: Props) => {
   const param = useParams<{ id: string }>();
   const actionRef = useRef<ActionType>();
   const [perVisible, setPerVisible] = useState(false);
+  const [searchParam, setSearchParam] = useState({});
 
   const columns: ProColumns<ProductCategoryItem>[] = [
     {
@@ -84,10 +86,35 @@ const Bind = observer((props: Props) => {
           }
         }}
       />
+      <SearchComponent<ProductCategoryItem>
+        field={columns}
+        pattern="simple"
+        defaultParam={[
+          {
+            column: 'id',
+            termType: 'dim-assets$not',
+            value: {
+              assetType: 'deviceCategory',
+              targets: [
+                {
+                  type: 'org',
+                  id: param.id,
+                },
+              ],
+            },
+          },
+        ]}
+        onSearch={async (data) => {
+          actionRef.current?.reset?.();
+          setSearchParam(data);
+        }}
+        target="department-assets-category"
+      />
       <ProTable<ProductCategoryItem>
         actionRef={actionRef}
         columns={columns}
         rowKey="id"
+        search={false}
         pagination={false}
         rowSelection={{
           selectedRowKeys: Models.bindKeys,
@@ -95,23 +122,7 @@ const Bind = observer((props: Props) => {
             Models.bindKeys = getTableKeys(selectedRows);
           },
         }}
-        params={{
-          terms: [
-            {
-              column: 'id',
-              termType: 'dim-assets$not',
-              value: {
-                assetType: 'deviceCategory',
-                targets: [
-                  {
-                    type: 'org',
-                    id: param.id,
-                  },
-                ],
-              },
-            },
-          ],
-        }}
+        params={searchParam}
         request={async (params) => {
           const response = await service.queryProductCategoryList(params);
           return {

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

@@ -141,7 +141,6 @@ export default observer(() => {
       />
       <SearchComponent<ProductCategoryItem>
         field={columns}
-        pattern="simple"
         defaultParam={[
           {
             column: 'id',

+ 15 - 12
src/pages/system/Department/Member/bind.tsx

@@ -6,8 +6,9 @@ import { message, Modal } from 'antd';
 import { useParams } from 'umi';
 import MemberModel from '@/pages/system/Department/Member/model';
 import { observer } from '@formily/react';
-import { useEffect, useRef } from 'react';
+import { useEffect, useRef, useState } from 'react';
 import { useIntl } from '@@/plugin-locale/localeExports';
+import SearchComponent from '@/components/SearchComponent';
 
 interface Props {
   reload: () => void;
@@ -18,6 +19,7 @@ interface Props {
 const Bind = observer((props: Props) => {
   const intl = useIntl();
   const param = useParams<{ id: string }>();
+  const [searchParam, setSearchParam] = useState({});
   const actionRef = useRef<ActionType>();
 
   useEffect(() => {
@@ -74,21 +76,22 @@ const Bind = observer((props: Props) => {
       width={990}
       title="绑定"
     >
+      <SearchComponent<UserItem>
+        pattern={'simple'}
+        field={columns}
+        defaultParam={[{ column: 'id$in-dimension$org$not', value: param.id }]}
+        onSearch={async (data) => {
+          actionRef.current?.reset?.();
+          setSearchParam(data);
+        }}
+        target="department-user"
+      />
       <ProTable
         actionRef={actionRef}
         columns={columns}
         rowKey="id"
-        pagination={{
-          pageSize: 5,
-        }}
-        params={{
-          terms: [
-            {
-              column: 'id$in-dimension$org$not',
-              value: param.id,
-            },
-          ],
-        }}
+        search={false}
+        params={searchParam}
         rowSelection={{
           selectedRowKeys: MemberModel.bindUsers,
           onChange: (selectedRowKeys, selectedRows) => {

+ 2 - 2
src/pages/system/Department/Member/index.tsx

@@ -155,9 +155,9 @@ const Member = observer(() => {
         reload={() => actionRef.current?.reload()}
       />
       <SearchComponent<MemberItem>
-        pattern={'simple'}
+        // pattern={'simple'}
         field={columns}
-        defaultParam={[{ column: 'id$in-dimension$org', value: param.id, termType: 'eq' }]}
+        defaultParam={[{ column: 'id$in-dimension$org', value: param.id }]}
         onSearch={async (data) => {
           actionRef.current?.reset?.();
           setSearchParam(data);