feat: add daily task claim record filters
This commit is contained in:
parent
b1bb7a2267
commit
fabe307a22
@ -1,4 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import type { Dayjs } from 'dayjs';
|
||||||
|
|
||||||
import { computed, reactive, ref, watch } from 'vue';
|
import { computed, reactive, ref, watch } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
@ -7,6 +9,7 @@ import { useAccessStore } from '@vben/stores';
|
|||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
|
DatePicker,
|
||||||
Input,
|
Input,
|
||||||
InputNumber,
|
InputNumber,
|
||||||
message,
|
message,
|
||||||
@ -20,6 +23,7 @@ import {
|
|||||||
Tabs,
|
Tabs,
|
||||||
Tag,
|
Tag,
|
||||||
} from 'antdv-next';
|
} from 'antdv-next';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getResidentDailyTaskConfig,
|
getResidentDailyTaskConfig,
|
||||||
@ -175,6 +179,12 @@ const claimQuery = reactive<Record<string, any>>({
|
|||||||
userId: '',
|
userId: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function defaultClaimDateRange(): [Dayjs, Dayjs] {
|
||||||
|
return [dayjs().startOf('day'), dayjs().endOf('day')];
|
||||||
|
}
|
||||||
|
|
||||||
|
const claimDateRange = ref<[Dayjs, Dayjs] | null>(defaultClaimDateRange());
|
||||||
|
|
||||||
const claimPage = reactive<Record<string, any>>({
|
const claimPage = reactive<Record<string, any>>({
|
||||||
current: 1,
|
current: 1,
|
||||||
records: [],
|
records: [],
|
||||||
@ -182,6 +192,12 @@ const claimPage = reactive<Record<string, any>>({
|
|||||||
total: 0,
|
total: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const claimSummary = reactive<Record<string, any>>({
|
||||||
|
selectedTaskRewardGold: 0,
|
||||||
|
taskCode: '',
|
||||||
|
totalRewardGold: 0,
|
||||||
|
});
|
||||||
|
|
||||||
const statusMeta = computed(() => {
|
const statusMeta = computed(() => {
|
||||||
if (!form.configured) {
|
if (!form.configured) {
|
||||||
return { color: 'processing', text: '未配置' };
|
return { color: 'processing', text: '未配置' };
|
||||||
@ -196,6 +212,24 @@ const activeTaskCategoryLabel = computed(() => {
|
|||||||
return taskCategoryOptions.find((item) => item.value === activeTaskCategory.value)?.label || '每日任务';
|
return taskCategoryOptions.find((item) => item.value === activeTaskCategory.value)?.label || '每日任务';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const taskCodeOptions = computed(() => {
|
||||||
|
const seen = new Set<string>();
|
||||||
|
return ((form.tasks || []) as Array<Record<string, any>>)
|
||||||
|
.map((item) => {
|
||||||
|
const value = String(item.taskCode || '').trim();
|
||||||
|
if (!value || seen.has(value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
seen.add(value);
|
||||||
|
const taskName = String(item.taskName || '').trim();
|
||||||
|
return {
|
||||||
|
label: taskName ? `${value} / ${taskName}` : value,
|
||||||
|
value,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter(Boolean) as Array<{ label: string; value: string }>;
|
||||||
|
});
|
||||||
|
|
||||||
function normalizeConditionJumpRows(
|
function normalizeConditionJumpRows(
|
||||||
rows: Array<Record<string, any>>,
|
rows: Array<Record<string, any>>,
|
||||||
tasks: Array<Record<string, any>>,
|
tasks: Array<Record<string, any>>,
|
||||||
@ -543,6 +577,20 @@ function normalizePage(target: Record<string, any>, result: Record<string, any>)
|
|||||||
target.total = Number(result?.total || 0);
|
target.total = Number(result?.total || 0);
|
||||||
target.current = Number(result?.current || 1);
|
target.current = Number(result?.current || 1);
|
||||||
target.size = Number(result?.size || 20);
|
target.size = Number(result?.size || 20);
|
||||||
|
const summary = result?.summary || {};
|
||||||
|
claimSummary.totalRewardGold = Number(summary.totalRewardGold || 0);
|
||||||
|
claimSummary.selectedTaskRewardGold = Number(summary.selectedTaskRewardGold || 0);
|
||||||
|
claimSummary.taskCode = String(summary.taskCode || '');
|
||||||
|
}
|
||||||
|
|
||||||
|
function claimTimeParams() {
|
||||||
|
if (!claimDateRange.value?.[0] || !claimDateRange.value?.[1]) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
endTime: String(claimDateRange.value[1].valueOf()),
|
||||||
|
startTime: String(claimDateRange.value[0].valueOf()),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadClaimRecords() {
|
async function loadClaimRecords() {
|
||||||
@ -553,6 +601,7 @@ async function loadClaimRecords() {
|
|||||||
try {
|
try {
|
||||||
const result = await pageResidentDailyTaskClaimRecords({
|
const result = await pageResidentDailyTaskClaimRecords({
|
||||||
...claimQuery,
|
...claimQuery,
|
||||||
|
...claimTimeParams(),
|
||||||
sysOrigin: selectedSysOrigin.value,
|
sysOrigin: selectedSysOrigin.value,
|
||||||
taskCategory: activeTaskCategory.value,
|
taskCategory: activeTaskCategory.value,
|
||||||
});
|
});
|
||||||
@ -567,6 +616,11 @@ function searchClaimRecords() {
|
|||||||
void loadClaimRecords();
|
void loadClaimRecords();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetClaimDateRange() {
|
||||||
|
claimDateRange.value = defaultClaimDateRange();
|
||||||
|
searchClaimRecords();
|
||||||
|
}
|
||||||
|
|
||||||
function handleClaimTableChange(pagination: Record<string, any>) {
|
function handleClaimTableChange(pagination: Record<string, any>) {
|
||||||
claimQuery.cursor = Number(pagination.current || 1);
|
claimQuery.cursor = Number(pagination.current || 1);
|
||||||
claimQuery.limit = Number(pagination.pageSize || 20);
|
claimQuery.limit = Number(pagination.pageSize || 20);
|
||||||
@ -585,12 +639,13 @@ watch(
|
|||||||
|
|
||||||
watch(
|
watch(
|
||||||
selectedSysOrigin,
|
selectedSysOrigin,
|
||||||
(value) => {
|
(value) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
claimQuery.cursor = 1;
|
claimQuery.cursor = 1;
|
||||||
void loadConfig();
|
claimQuery.taskCode = '';
|
||||||
void loadClaimRecords();
|
void loadConfig();
|
||||||
}
|
void loadClaimRecords();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
@ -600,6 +655,7 @@ watch(activeTaskCategory, () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
claimQuery.cursor = 1;
|
claimQuery.cursor = 1;
|
||||||
|
claimQuery.taskCode = '';
|
||||||
void loadConfig();
|
void loadConfig();
|
||||||
void loadClaimRecords();
|
void loadClaimRecords();
|
||||||
});
|
});
|
||||||
@ -786,11 +842,21 @@ watch(activeTaskCategory, () => {
|
|||||||
placeholder="用户ID"
|
placeholder="用户ID"
|
||||||
style="width: 160px"
|
style="width: 160px"
|
||||||
/>
|
/>
|
||||||
<Input
|
<Select
|
||||||
v-model:value="claimQuery.taskCode"
|
v-model:value="claimQuery.taskCode"
|
||||||
allow-clear
|
allow-clear
|
||||||
|
:options="taskCodeOptions"
|
||||||
|
option-filter-prop="label"
|
||||||
placeholder="任务编码"
|
placeholder="任务编码"
|
||||||
style="width: 220px"
|
show-search
|
||||||
|
style="width: 280px"
|
||||||
|
/>
|
||||||
|
<DatePicker.RangePicker
|
||||||
|
v-model:value="claimDateRange"
|
||||||
|
allow-clear
|
||||||
|
format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
show-time
|
||||||
|
style="width: 390px"
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
v-model:value="claimQuery.status"
|
v-model:value="claimQuery.status"
|
||||||
@ -805,6 +871,17 @@ watch(activeTaskCategory, () => {
|
|||||||
<Button :loading="claimLoading" type="primary" @click="searchClaimRecords">
|
<Button :loading="claimLoading" type="primary" @click="searchClaimRecords">
|
||||||
查询
|
查询
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button @click="resetClaimDateRange">今天</Button>
|
||||||
|
</div>
|
||||||
|
<div class="claim-summary">
|
||||||
|
<Tag color="blue">
|
||||||
|
当前时间总发放金币:{{ claimSummary.totalRewardGold }}
|
||||||
|
</Tag>
|
||||||
|
<Tag v-if="claimQuery.taskCode" color="green">
|
||||||
|
{{ claimQuery.taskCode }} 发放金币:{{
|
||||||
|
claimSummary.selectedTaskRewardGold
|
||||||
|
}}
|
||||||
|
</Tag>
|
||||||
</div>
|
</div>
|
||||||
<Table
|
<Table
|
||||||
:columns="claimColumns"
|
:columns="claimColumns"
|
||||||
@ -850,6 +927,10 @@ watch(activeTaskCategory, () => {
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.claim-summary {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.actions {
|
.actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user