优化电子凭证操作与测试数据
This commit is contained in:
@@ -24,7 +24,7 @@ import {
|
||||
Typography,
|
||||
} from 'antd'
|
||||
import type { TableColumnsType, TabsProps } from 'antd'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
|
||||
import { AdminRangePicker } from '@/components/admin/AdminDatePicker'
|
||||
import PageHeader from '@/components/admin/PageHeader'
|
||||
@@ -132,6 +132,8 @@ export default function AdminKuaishouIndustryPage() {
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
})
|
||||
// 异步接口返回后刷新列表时,仍使用用户最后一次输入的筛选条件。
|
||||
const voucherFiltersRef = useRef(voucherFilters)
|
||||
const [toolForm, setToolForm] = useState<AdminKuaishouIndustryVoucherToolPayload>({
|
||||
eticketType: '',
|
||||
consumeType: 'consume',
|
||||
@@ -419,8 +421,7 @@ export default function AdminKuaishouIndustryPage() {
|
||||
}
|
||||
|
||||
async function loadVouchers(nextFilters: Partial<VoucherFilterState> = {}) {
|
||||
const filters = { ...voucherFilters, ...nextFilters }
|
||||
setVoucherFilters(filters)
|
||||
const filters = updateVoucherFilters(nextFilters)
|
||||
setVoucherLoading(true)
|
||||
|
||||
try {
|
||||
@@ -449,6 +450,24 @@ export default function AdminKuaishouIndustryPage() {
|
||||
}
|
||||
}
|
||||
|
||||
function updateVoucherFilters(patch: Partial<VoucherFilterState>): VoucherFilterState {
|
||||
const nextFilters = { ...voucherFiltersRef.current, ...patch }
|
||||
voucherFiltersRef.current = nextFilters
|
||||
setVoucherFilters(nextFilters)
|
||||
return nextFilters
|
||||
}
|
||||
|
||||
function clearVoucherFilters() {
|
||||
void loadVouchers({
|
||||
oid: '',
|
||||
voucherCode: '',
|
||||
taskId: '',
|
||||
sellerId: '',
|
||||
status: '',
|
||||
page: 1,
|
||||
})
|
||||
}
|
||||
|
||||
function selectVoucher(row: AdminKuaishouIndustryVoucher) {
|
||||
setSelectedVoucher(row)
|
||||
showSuccess(`已选择券码 ${row.voucherCode}`)
|
||||
@@ -804,8 +823,7 @@ export default function AdminKuaishouIndustryPage() {
|
||||
placeholder="订单号 oid"
|
||||
value={voucherFilters.oid}
|
||||
onChange={(event) =>
|
||||
setVoucherFilters({
|
||||
...voucherFilters,
|
||||
updateVoucherFilters({
|
||||
oid: event.target.value,
|
||||
})
|
||||
}
|
||||
@@ -815,8 +833,7 @@ export default function AdminKuaishouIndustryPage() {
|
||||
placeholder="券码"
|
||||
value={voucherFilters.voucherCode}
|
||||
onChange={(event) =>
|
||||
setVoucherFilters({
|
||||
...voucherFilters,
|
||||
updateVoucherFilters({
|
||||
voucherCode: event.target.value,
|
||||
})
|
||||
}
|
||||
@@ -826,8 +843,7 @@ export default function AdminKuaishouIndustryPage() {
|
||||
placeholder="任务 ID"
|
||||
value={voucherFilters.taskId}
|
||||
onChange={(event) =>
|
||||
setVoucherFilters({
|
||||
...voucherFilters,
|
||||
updateVoucherFilters({
|
||||
taskId: event.target.value,
|
||||
})
|
||||
}
|
||||
@@ -854,8 +870,7 @@ export default function AdminKuaishouIndustryPage() {
|
||||
placeholder="店铺 ID"
|
||||
value={voucherFilters.sellerId}
|
||||
onChange={(event) =>
|
||||
setVoucherFilters({
|
||||
...voucherFilters,
|
||||
updateVoucherFilters({
|
||||
sellerId: event.target.value,
|
||||
})
|
||||
}
|
||||
@@ -871,7 +886,7 @@ export default function AdminKuaishouIndustryPage() {
|
||||
{ label: '已核销', value: 'CONSUMED' },
|
||||
{ label: '已销毁', value: 'DESTROYED' },
|
||||
]}
|
||||
onChange={(value) => setVoucherFilters({ ...voucherFilters, status: value || '' })}
|
||||
onChange={(value) => updateVoucherFilters({ status: value || '' })}
|
||||
/>
|
||||
<Button
|
||||
type="primary"
|
||||
@@ -881,6 +896,7 @@ export default function AdminKuaishouIndustryPage() {
|
||||
>
|
||||
查询
|
||||
</Button>
|
||||
<Button onClick={clearVoucherFilters}>清空筛选</Button>
|
||||
</Space>
|
||||
</Card>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user