Przeglądaj źródła

增加公众号搜索

jihuaqiang 1 miesiąc temu
rodzic
commit
c4351301ac
1 zmienionych plików z 31 dodań i 9 usunięć
  1. 31 9
      src/views/cooperationAccount/gzh/index.tsx

+ 31 - 9
src/views/cooperationAccount/gzh/index.tsx

@@ -1,4 +1,4 @@
-import { Button, Table, Image, Modal, message, Select, Popconfirm } from "antd";
+import { Button, Table, Image, Modal, message, Select, Popconfirm, Input } from "antd";
 import type { TableProps } from 'antd';
 import { useState, useEffect, useRef } from "react";
 import { InfoCircleFilled, CheckCircleFilled } from "@ant-design/icons";
@@ -323,12 +323,14 @@ const Gzh: React.FC = () => {
   const [title, setTitle] = useState('');
   const [authFailed, setAuthFailed] = useState(false);
   const [loading, setLoading] = useState(false);
-  const [data, setData] = useState<DataType[]>([]);
+	const [data, setData] = useState<DataType[]>([]);
+	const [queryName, setQueryName] = useState('');
+	const [isSearch, setIsSearch] = useState(false);
   const [pagination, setPagination] = useState({
     current: 1,
     pageSize: 10,
     total: 0
-  });
+	});
 
   const columns: TableProps<DataType>['columns'] = [
     {
@@ -376,10 +378,15 @@ const Gzh: React.FC = () => {
   ]
 
   // 获取账号列表数据
-  const fetchAccountList = async (pageNum = 1, pageSize = 10) => {
+	const fetchAccountList = async (pageNum = 1, pageSize = 10, _queryName = '') => {
+		setIsSearch(_queryName.trim() !== '');
     setLoading(true);
     try {
-      const res = await http.post<AccountListResponse>(accountList, { pageNum, pageSize });
+			const res = await http.post<AccountListResponse>(accountList, {
+				pageNum,
+				pageSize,
+				name: (_queryName || isSearch) ? (_queryName || queryName) : '',
+			});
       if (res.code === 0 && res.data) {
         setData(res.data.objs || []);
         setPagination({
@@ -468,20 +475,35 @@ const Gzh: React.FC = () => {
     setIsOpen(false);
     // 重置当前选中的账号数据
     setCurrentAccount(undefined);
-  }
+	}
+	
+	const handleSearch = () => {
+		fetchAccountList(1, pagination.pageSize, queryName);
+	}
 
   // 当前选中的账号数据
   const [currentAccount, setCurrentAccount] = useState<DataType | undefined>(undefined);
 
   return (
-    <>
+		<>
+			<div className={"text-[20px] font-medium mb-[10px]"}>公众号管理</div>
       <div className={"flex mb-[10px]"}>
-        <div className={"flex-1 leading-[32px]"}>公众号管理</div>
+				<div className={"flex-1 flex gap-[10px]"}>
+					<Input
+						className={"!w-[200px]"}
+						allowClear
+						placeholder="请输入账号名称"
+						value={queryName}
+						onChange={(e) => setQueryName(e.target.value)}
+					/>
+					<Button type="primary" onClick={handleSearch}>搜索</Button>
+				</div>
         <div>
           <Button type="primary" onClick={addAccount} className={"mr-[10px]"}>+ 新建账号</Button>
         </div>
       </div>
-      <Table 
+			<Table 
+				
         columns={columns} 
         dataSource={data} 
         rowKey="id"