抽奖记录中增加核销功能

This commit is contained in:
qiuyuan 2025-08-25 11:16:37 +08:00
parent 64b30bd348
commit e0cb8f132a
3 changed files with 87 additions and 42 deletions

View File

@ -15,4 +15,6 @@ export const delItem = (id) => request.basic.delete(`/api/v1/raffle-products/${i
//获取抽奖记录
export const getRaffleOrders = (params) => request.basic.get('/api/v1/raffle-orders', params)
// 导出文件
export const exportFile = () => request.basic.get('/api/v1/apps/common/raffle/Atbrw2334D_FVadfyb435zr55q3')
export const exportFile = () => request.basic.get('/api/v1/apps/common/raffle/Atbrw2334D_FVadfyb435zr55q3')
//核销抽奖
export const updateProject = (id,params) => request.basic.put(`/api/v1/raffle-orders/${id}`, params)

View File

@ -1,46 +1,34 @@
<template>
<!-- <x-search-bar class="mb-8-2">
<template #default="{ gutter, colSpan }">
<a-form :model="searchFormData" layout="inline">
<a-row :gutter="gutter">
<a-col v-bind="colSpan">
<a-form-item label="岗位名称" name="name">
<a-input placeholder="请输入岗位名称" v-model:value="searchFormData.name"></a-input>
</a-form-item>
</a-col>
<a-col v-bind="colSpan">
<a-form-item label="状态" name="status">
<a-select v-model:value="searchFormData.status" allowClear>
<a-select-option value="">全部</a-select-option>
<a-select-option value="enabled">启用</a-select-option>
<a-select-option value="disabled">停用</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col class="align-right" v-bind="colSpan">
<a-space>
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
<a-button ghost type="primary" @click="handleSearch">
{{ $t('button.search') }}
</a-button>
</a-space>
</a-col>
</a-row>
</a-form>
</template>
</x-search-bar> -->
<a-row :gutter="8" :wrap="false">
<a-col flex="auto">
<a-card type="flex">
<div class="exportExcel"><a-button type="primary">
<a :href='config("http.apiBasic") + "/api/v1/apps/common/raffle/Atbrw2334D_FVadfyb435zr55q3"'>导出Excel</a></a-button></div>
<a
:href='config("http.apiBasic") + "/api/v1/apps/common/raffle/Atbrw2334D_FVadfyb435zr55q3"'>导出Excel</a></a-button>
</div>
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'createdAt'">
<span>{{ dayjs(record.createdAt).format('YYYY-MM-DD HH:mm') }}</span>
</template>
<template v-if="column.dataIndex === 'status'">
<a-tag :color="getStatusColor(record.status)">
{{ getStatusText(record.status) }}
</a-tag>
</template>
<template v-if="'action' === column.key">
<x-action-button v-if="record.status === 'checking'" @click="handleEdit(record)">
<a-tooltip>
<template #title> {{ '核销' }}</template>
<FormOutlined />
</a-tooltip></x-action-button>
<!-- <x-action-button @click="handleDelete(record)">
<a-tooltip>
<template #title>{{ $t('pages.system.delete') }}</template>
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button> -->
</template>
</template>
</a-table>
</a-card>
@ -55,7 +43,7 @@ import { ref } from 'vue'
import apis from '@/apis'
import { config } from '@/config'
import { usePagination } from '@/hooks'
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import { FormOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n'
import dayjs from 'dayjs'
@ -68,12 +56,43 @@ const columns = [
{ title: '所属规则', dataIndex: 'raffleName', align: 'center' },
{ title: '中奖人', dataIndex: 'customerName', align: 'center' },
{ title: '客户手机号', dataIndex: 'customerPhone', align: 'center' },
{ title: '状态', dataIndex: 'status', align: 'center' },
{ title: '中奖时间', dataIndex: 'createdAt', width: 180, align: 'center' },
{ title: '操作', key: 'action', fixed: 'right', width: 100, align: 'center' },
]
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } = usePagination()
const editDialogRef = ref()
getPageList()
//
const statusMap = {
'success': '未中奖',
'checked': '已核销',
'checking': '待核销'
}
//
const statusColorMap = {
'success': 'default',
'checked': 'green',
'checking': 'orange'
}
/**
* 获取状态显示文本
*/
function getStatusText(status) {
return statusMap[status] || status
}
/**
* 获取状态颜色
*/
function getStatusColor(status) {
return statusColorMap[status] || 'default'
}
/**
* 获取表格数据
* @returns {Promise<void>}
@ -111,7 +130,7 @@ function handleDelete({ id }) {
okText: t('button.confirm'),
onOk: () => {
return new Promise((resolve, reject) => {
; (async () => {
(async () => {
try {
const { success } = await apis.house.delItem(id).catch(() => {
throw new Error()
@ -130,6 +149,30 @@ function handleDelete({ id }) {
})
}
/**
* 核销
*/
async function handleEdit(record = {}) {
try {
const params = {
...record,
status: 'checked',
}
const { success } = await apis.raffleProduct.updateProject(record.id, params)
if (success) {
message.success('核销成功')
await getPageList()
} else {
message.error('核销失败')
}
} catch (error) {
console.error('核销出错:', error)
message.error('核销失败')
}
}
/**
* 分页
*/
@ -162,9 +205,9 @@ async function onOk() {
}
async function exportExcel() {
try {
try {
const response = await apis.raffleProduct.exportFile()
// const url = window.URL.createObjectURL(new Blob([response]))
// const link = document.createElement('a')
// link.href = url
@ -187,4 +230,4 @@ async function exportExcel() {
justify-content: right;
margin: 10px;
}
</style>
</style>

View File

@ -227,15 +227,15 @@ function handleOk() {
switch (modal.value.type) {
case 'create':
result = await apis.raffles.createProject(params).catch((error) => {
console.log(error.message)
throw new Error(error)
console.log("1111",error.message)
// throw new Error(error)
})
break
case 'edit':
result = await apis.raffles.updateItem(formData.value.id, params).catch(() => {
console.log(error.message)
throw new Error(error)
console.log("2222",error.message)
// throw new Error(error)
})
break
}