拼团记录:优化页面布局,添加日期快捷选项

This commit is contained in:
puhui999 2023-10-07 11:10:26 +08:00
parent 8c347e5990
commit 5b4983a3e9
2 changed files with 114 additions and 70 deletions

View File

@ -181,5 +181,6 @@ export enum DICT_TYPE {
PROMOTION_COUPON_TAKE_TYPE = 'promotion_coupon_take_type', // 优惠劵的领取方式 PROMOTION_COUPON_TAKE_TYPE = 'promotion_coupon_take_type', // 优惠劵的领取方式
PROMOTION_ACTIVITY_STATUS = 'promotion_activity_status', // 优惠活动的状态 PROMOTION_ACTIVITY_STATUS = 'promotion_activity_status', // 优惠活动的状态
PROMOTION_CONDITION_TYPE = 'promotion_condition_type', // 营销的条件类型枚举 PROMOTION_CONDITION_TYPE = 'promotion_condition_type', // 营销的条件类型枚举
PROMOTION_BARGAIN_RECORD_STATUS = 'promotion_bargain_record_status' // 砍价记录的状态 PROMOTION_BARGAIN_RECORD_STATUS = 'promotion_bargain_record_status', // 砍价记录的状态
PROMOTION_COMBINATION_RECORD_STATUS = 'promotion_combination_record_status' // 拼团记录的状态
} }

View File

@ -65,44 +65,63 @@
</ContentWrap> </ContentWrap>
</el-col> </el-col>
</el-row> </el-row>
<ContentWrap> <ContentWrap>
<!-- 检索条件 --> <!-- 搜索工作栏 -->
<div class="mb-[10px]"> <el-form
<span class="font-size-[14px]" style="font-weight: bold; color: #606266">时间段</span> ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker <el-date-picker
v-model="queryParams.createTime" v-model="queryParams.createTime"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" :shortcuts="shortcuts"
class="!w-240px" class="!w-240px"
end-placeholder="结束日期" end-placeholder="结束日期"
start-placeholder="开始日期" start-placeholder="开始日期"
type="daterange" type="daterange"
value-format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss"
/> />
<span class="ml-[10px] font-size-[14px] font-bold" style="color: #606266">拼团状态</span> </el-form-item>
<el-form-item label="拼团状态" prop="status">
<el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="全部"> <el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="全部">
<el-option <el-option
v-for="(dict, index) in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" v-for="(dict, index) in getIntDictOptions(
DICT_TYPE.PROMOTION_COMBINATION_RECORD_STATUS
)"
:key="index" :key="index"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"
/> />
</el-select> </el-select>
</div> </el-form-item>
<el-form-item>
<el-button @click="handleQuery">
<Icon class="mr-5px" icon="ep:search" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<!-- 分页列表数据展示 --> <!-- 分页列表数据展示 -->
<el-tabs v-model="queryParams.dateType" @tab-click="handleTabClick">
<el-tab-pane
v-for="item in tabsData"
:key="item.type"
:label="item.name + '(' + item.count + ')'"
:name="item.value"
/>
</el-tabs>
<el-table v-loading="loading" :data="pageList"> <el-table v-loading="loading" :data="pageList">
<el-table-column align="center" label="编号" prop="id" /> <el-table-column align="center" label="编号" prop="id" />
<!-- TODO 是否需要做一个点击用户头像跳转或查看用户信息的功能 --> <!-- TODO 是否需要做一个点击用户头像跳转或查看用户信息的功能 -->
<el-table-column align="center" label="头像" prop="avatars" /> <el-table-column align="center" label="头像" prop="avatar" />
<el-table-column align="center" label="开团团长" prop="avatar" /> <el-table-column align="center" label="开团团长" prop="headId">
<template #default="{ row }: { row: CombinationRecordApi.CombinationRecordVO }">
{{
row.headId ? pageList.find((item) => item.id === row.headId)?.nickname : row.nickname
}}
</template>
</el-table-column>
<el-table-column <el-table-column
:formatter="dateFormatter" :formatter="dateFormatter"
align="center" align="center"
@ -137,10 +156,13 @@
/> />
<el-table-column align="center" label="拼团状态" prop="status"> <el-table-column align="center" label="拼团状态" prop="status">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> <dict-tag
:type="DICT_TYPE.PROMOTION_COMBINATION_RECORD_STATUS"
:value="scope.row.status"
/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作"> <el-table-column align="center" fixed="right" label="操作">
<template #default></template> <template #default></template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -159,7 +181,6 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import { createImageViewer } from '@/components/ImageViewer' import { createImageViewer } from '@/components/ImageViewer'
import * as CombinationRecordApi from '@/api/mall/promotion/combination/combinationRecord' import * as CombinationRecordApi from '@/api/mall/promotion/combination/combinationRecord'
import { TabsPaneContext } from 'element-plus'
defineOptions({ name: 'CombinationRecord' }) defineOptions({ name: 'CombinationRecord' })
const queryParams = ref({ const queryParams = ref({
@ -169,15 +190,16 @@ const queryParams = ref({
pageSize: 10, pageSize: 10,
pageNo: 1 pageNo: 1
}) })
const queryFormRef = ref() //
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) // const total = ref(0) //
const pageList = ref([]) // const pageList = ref<CombinationRecordApi.CombinationRecordVO[]>([]) //
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
const data = await CombinationRecordApi.getCombinationRecordPage(queryParams.value) const data = await CombinationRecordApi.getCombinationRecordPage(queryParams.value)
pageList.value = data.list pageList.value = data.list as CombinationRecordApi.CombinationRecordVO[]
total.value = data.total total.value = data.total
} finally { } finally {
loading.value = false loading.value = false
@ -193,64 +215,85 @@ const recordSummary = ref({
const getSummary = async () => { const getSummary = async () => {
recordSummary.value = await CombinationRecordApi.getCombinationRecordSummary() recordSummary.value = await CombinationRecordApi.getCombinationRecordSummary()
} }
//
// tabs const shortcuts = ref([
const tabsData = ref([
{ {
count: 0, text: '今天',
name: '全部',
type: 'all',
value: 0
},
{
count: 0,
name: '今天',
type: 'toDay', type: 'toDay',
value: 1 value: () => {
queryParams.value.dateType = 1
return new Date()
}
}, },
{ {
count: 0, text: '昨天',
name: '昨天',
type: 'yesterday', type: 'yesterday',
value: 2 value: () => {
const date = new Date()
date.setTime(date.getTime() - 3600 * 1000 * 24)
queryParams.value.dateType = 2
return [date, date]
}
}, },
{ {
count: 0, text: '最近七天',
name: '最近七天',
type: 'lastSevenDays', type: 'lastSevenDays',
value: 3 value: () => {
const date = new Date()
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
queryParams.value.dateType = 3
return [date, new Date()]
}
}, },
{ {
count: 0, text: '最近30天',
name: '最近30天',
type: 'last30Days', type: 'last30Days',
value: 4 value: () => {
const date = new Date()
date.setTime(date.getTime() - 3600 * 1000 * 24 * 30)
queryParams.value.dateType = 4
return [date, new Date()]
}
}, },
{ {
count: 0, text: '本月',
name: '本月',
type: 'thisMonth', type: 'thisMonth',
value: 5 value: () => {
const date = new Date()
date.setDate(1) //
queryParams.value.dateType = 5
return [date, new Date()]
}
}, },
{ {
count: 0, text: '今年',
name: '今年',
type: 'thisYear', type: 'thisYear',
value: 6 value: () => {
const date = new Date()
queryParams.value.dateType = 6
return [new Date(`${date.getFullYear()}-01-01`), date]
}
} }
]) ])
/** 获得每个 Tab 的数量 */ /** 获得每个 Tab 的数量 */
const getTabsCount = async () => { const getTabsCount = async () => {
const res = await CombinationRecordApi.getCombinationRecordCount() const res = await CombinationRecordApi.getCombinationRecordCount()
tabsData.value.forEach((tab) => { shortcuts.value.forEach((tab) => {
tab.count = res[tab.type] tab.text += `(${res[tab.type]})`
}) })
} }
const handleTabClick = async (tab: TabsPaneContext) => { /** 搜索按钮操作 */
queryParams.value.dateType = tab.paneName as number const handleQuery = () => {
await getList() queryParams.value.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
} }
/** 商品图预览 */ /** 商品图预览 */