feat(admin): v3.5.18 用户详情明文手机、任务关联版本与核销快链
HQ 后台:用户/核销记录展示完整手机号;任务列表与编辑可关联版本;账单核销单号与券号/用户可快链;门店账单日标明为出账自然日;技术支持操作按钮右对齐。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import {
|
||||
Button,
|
||||
Descriptions,
|
||||
@@ -111,9 +111,16 @@ type CouponDetail = Row & {
|
||||
|
||||
export default function BenefitCouponsPage() {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const [searchParams] = useSearchParams();
|
||||
const initialCouponNo = searchParams.get('couponNo')?.trim() || '';
|
||||
const [form] = Form.useForm();
|
||||
const [grantForm] = Form.useForm<AdminBenefitGrantRequest>();
|
||||
const [filters, setFilters] = useState<Record<string, string>>({});
|
||||
const [filters, setFilters] = useState<Record<string, string>>(() => {
|
||||
const init: Record<string, string> = {};
|
||||
if (initialCouponNo) init.couponNo = initialCouponNo;
|
||||
return init;
|
||||
});
|
||||
const [grantOpen, setGrantOpen] = useState(false);
|
||||
const [granting, setGranting] = useState(false);
|
||||
const { data, loading, page, pageSize, setPage, setPageSize, reload } = useAdminList<Row>(
|
||||
@@ -132,6 +139,35 @@ export default function BenefitCouponsPage() {
|
||||
const [redeemDetail, setRedeemDetail] = useState<Record<string, unknown> | null>(null);
|
||||
const [redeemDrawerOpen, setRedeemDrawerOpen] = useState(false);
|
||||
const [redeemDetailLoading, setRedeemDetailLoading] = useState(false);
|
||||
const deepLinkOpenedRef = useRef(false);
|
||||
|
||||
async function openCouponDetail(id: string) {
|
||||
setDetail(await request<CouponDetail>(`/admin/benefit/coupons/${id}`));
|
||||
setDrawerOpen(true);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (initialCouponNo) form.setFieldsValue({ couponNo: initialCouponNo });
|
||||
}, [form, initialCouponNo]);
|
||||
|
||||
useEffect(() => {
|
||||
const openCouponId = (location.state as { openCouponId?: string } | null)?.openCouponId;
|
||||
if (openCouponId && !deepLinkOpenedRef.current) {
|
||||
deepLinkOpenedRef.current = true;
|
||||
void openCouponDetail(openCouponId).catch((e) => {
|
||||
message.error(e instanceof Error ? e.message : '加载权益券失败');
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!initialCouponNo || deepLinkOpenedRef.current || loading) return;
|
||||
const first = data?.items?.[0];
|
||||
if (first && String(first.couponNo) === initialCouponNo) {
|
||||
deepLinkOpenedRef.current = true;
|
||||
void openCouponDetail(first.id).catch((e) => {
|
||||
message.error(e instanceof Error ? e.message : '加载权益券失败');
|
||||
});
|
||||
}
|
||||
}, [data, initialCouponNo, loading, location.state]);
|
||||
|
||||
async function openRedeemDetail(redeemId: string) {
|
||||
setRedeemDetailLoading(true);
|
||||
@@ -154,12 +190,7 @@ export default function BenefitCouponsPage() {
|
||||
width: 200,
|
||||
ellipsis: false,
|
||||
render: (v, row) => (
|
||||
<AdminPrimaryLink
|
||||
onClick={async () => {
|
||||
setDetail(await request(`/admin/benefit/coupons/${row.id}`));
|
||||
setDrawerOpen(true);
|
||||
}}
|
||||
>
|
||||
<AdminPrimaryLink onClick={() => void openCouponDetail(row.id)}>
|
||||
{v}
|
||||
</AdminPrimaryLink>
|
||||
),
|
||||
@@ -211,10 +242,7 @@ export default function BenefitCouponsPage() {
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={async () => {
|
||||
setDetail(await request(`/admin/benefit/coupons/${row.id}`));
|
||||
setDrawerOpen(true);
|
||||
}}
|
||||
onClick={() => void openCouponDetail(row.id)}
|
||||
>
|
||||
详情
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user