流量分发筛选状态功能

This commit is contained in:
wong
2025-12-11 17:31:33 +08:00
parent 84a51b8f91
commit 61926503cf
4 changed files with 97 additions and 8 deletions

View File

@@ -38,6 +38,7 @@ export function fetchTransferFriends(params: {
limit?: number;
keyword?: string;
workbenchId: number;
isRecycle?: number; // 0=未回收, 1=已回收, undefined=全部
}) {
return request("/v1/workbench/transfer-friends", params, "GET");
}

View File

@@ -35,10 +35,11 @@ const SendRcrodModal: React.FC<SendRcrodModalProps> = ({
const [searchKeyword, setSearchKeyword] = useState("");
const [currentPage, setCurrentPage] = useState(1);
const [total, setTotal] = useState(0);
const [recycleFilter, setRecycleFilter] = useState<number | undefined>(undefined); // undefined=全部, 0=未回收, 1=已回收
const pageSize = 20;
// 获取分发记录数据
const fetchSendRecords = async (page = 1, keyword = "") => {
const fetchSendRecords = async (page = 1, keyword = "", isRecycle?: number) => {
if (!ruleId) return;
setLoading(true);
@@ -48,6 +49,7 @@ const SendRcrodModal: React.FC<SendRcrodModalProps> = ({
page,
limit: pageSize,
keyword,
isRecycle,
});
console.log(detailRes);
@@ -68,21 +70,29 @@ const SendRcrodModal: React.FC<SendRcrodModalProps> = ({
setCurrentPage(1);
setSearchQuery("");
setSearchKeyword("");
fetchSendRecords(1, "");
setRecycleFilter(undefined);
fetchSendRecords(1, "", undefined);
}
}, [visible, ruleId]);
// 搜索关键词变化时触发搜索
useEffect(() => {
if (!visible || !ruleId || searchKeyword === "") return;
if (!visible || !ruleId) return;
setCurrentPage(1);
fetchSendRecords(1, searchKeyword);
fetchSendRecords(1, searchKeyword, recycleFilter);
}, [searchKeyword]);
// 筛选条件变化时触发搜索
useEffect(() => {
if (!visible || !ruleId) return;
setCurrentPage(1);
fetchSendRecords(1, searchKeyword, recycleFilter);
}, [recycleFilter]);
// 页码变化
useEffect(() => {
if (!visible || !ruleId) return;
fetchSendRecords(currentPage, searchKeyword);
fetchSendRecords(currentPage, searchKeyword, recycleFilter);
}, [currentPage]);
// 处理页码变化
@@ -160,6 +170,37 @@ const SendRcrodModal: React.FC<SendRcrodModalProps> = ({
</div>
</div>
{/* 回收状态筛选 */}
<div className={style.filterBar}>
<div className={style.filterLabel}></div>
<div className={style.filterOptions}>
<div
className={`${style.filterOption} ${
recycleFilter === undefined ? style.active : ""
}`}
onClick={() => setRecycleFilter(undefined)}
>
</div>
<div
className={`${style.filterOption} ${
recycleFilter === 0 ? style.active : ""
}`}
onClick={() => setRecycleFilter(0)}
>
</div>
<div
className={`${style.filterOption} ${
recycleFilter === 1 ? style.active : ""
}`}
onClick={() => setRecycleFilter(1)}
>
</div>
</div>
</div>
{/* 分发记录列表 */}
<div className={style.accountList}>
{loading ? (

View File

@@ -251,6 +251,52 @@
font-weight: 500;
}
.filterBar {
display: flex;
align-items: center;
padding: 12px 16px;
background: white;
border-bottom: 1px solid #f0f0f0;
.filterLabel {
font-size: 14px;
font-weight: 500;
color: #333;
margin-right: 12px;
white-space: nowrap;
}
.filterOptions {
display: flex;
gap: 8px;
flex: 1;
.filterOption {
flex: 1;
padding: 8px 16px;
border: 1px solid #e0e0e0;
border-radius: 8px;
font-size: 14px;
color: #666;
cursor: pointer;
transition: all 0.2s;
background: white;
text-align: center;
&:hover {
border-color: #1677ff;
color: #1677ff;
}
&.active {
background: #1677ff;
border-color: #1677ff;
color: white;
}
}
}
}
.accountModalFooter {
padding: 16px 20px;
border-top: 1px solid #f0f0f0;

View File

@@ -174,7 +174,8 @@ class AutomaticAssign extends BaseController
public function allotWechatFriend($data = [],$isInner = false,$errorNum = 0)
{
// 获取授权token
$authorization = trim($this->request->header('authorization', $this->authorization));
$authorization = $this->authorization;
if (empty($authorization)) {
if($isInner){
return json_encode(['code'=>500,'msg'=>'缺少授权信息']);
@@ -209,8 +210,8 @@ class AutomaticAssign extends BaseController
// 发送请求
$url = $this->baseUrl . 'api/WechatFriend/allot?wechatFriendId='.$wechatFriendId.'&notifyReceiver='.$notifyReceiver.'&comment='.$comment.'&toAccountId='.$toAccountId.'&optFrom='.$optFrom;
$result = requestCurl($url, [], 'PUT', $header, 'json');
if (empty($result)) {
$response = handleApiResponse($result);
if (empty($response)) {
if($isInner){
return json_encode(['code'=>200,'msg'=>'微信好友分配成功']);
}else{