增加券兑换码

This commit is contained in:
gyq 2025-10-22 11:49:04 +08:00
parent 695898484e
commit 71c852fcaa
4 changed files with 68 additions and 39 deletions

View File

@ -548,6 +548,34 @@ export function couponRedemption(data, method = 'post') {
}); });
} }
// 券兑换码 券兑换码码列表
export function couponRedemptionCodeList(params) {
return request({
url: `${Market_BaseUrl}/admin/couponRedemption/code/list`,
method: 'get',
params
});
}
// 券兑换码 配置信息详情
export function couponRedemptionDetail(params) {
return request({
url: `${Market_BaseUrl}/admin/couponRedemption`,
method: 'get',
params
});
}
// 券兑换码 配置信息详情
export function couponRedemptionCodeExport(params) {
return request({
url: `${Market_BaseUrl}/admin/couponRedemption/code/export`,
method: 'get',
params,
responseType: "blob",
});
}

View File

@ -1,5 +1,5 @@
<template> <template>
<el-dialog title="添加兑换码" width="500px" v-model="visible" @closed="onClosed"> <el-dialog title="添加兑换码" width="500px" v-model="visible" @closed="onClosedHandle">
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" label-position="right"> <el-form ref="formRef" :model="form" :rules="rules" label-width="100px" label-position="right">
<el-form-item label="名称" prop="name"> <el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入" :maxlength="50" show-word-limit <el-input v-model="form.name" placeholder="请输入" :maxlength="50" show-word-limit
@ -18,6 +18,10 @@
<template #append></template> <template #append></template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item label="库存" prop="stock" v-if="form.id">
<el-input v-model="form.stock" placeholder="请输入" :maxlength="4" show-word-limit style="width: 350px;"
@input="e => form.stock = filterNumberInput(e, true)"></el-input>
</el-form-item>
<el-form-item label="赠送优惠券" style="margin-top: 14px;" prop="coupon"> <el-form-item label="赠送优惠券" style="margin-top: 14px;" prop="coupon">
<div class="center" v-for="(item, index) in selectCoupons" :key="item.id"> <div class="center" v-for="(item, index) in selectCoupons" :key="item.id">
<el-select v-model="item.id" @change="selectCouponChnge($event, index)"> <el-select v-model="item.id" @change="selectCouponChnge($event, index)">
@ -48,7 +52,7 @@
<script setup> <script setup>
import _ from 'lodash' import _ from 'lodash'
import { ref } from "vue"; import { ref, nextTick, onMounted } from "vue";
import { filterNumberInput } from '@/utils' import { filterNumberInput } from '@/utils'
import { couponRedemption, couponPage } from "@/api/coupon/index.js"; import { couponRedemption, couponPage } from "@/api/coupon/index.js";
@ -67,18 +71,19 @@ const form = ref({
endTime: '', endTime: '',
}); });
const resetForm = () => { const resetForm = ref({})
form.value = {
id: '', //
stock: '', function onClosedHandle() {
name: '', form.value = { ...resetForm.value };
timeScope: [], selectCoupons.value = [];
amount: '',
total: 0, nextTick(() => {
startTime: '', setTimeout(() => {
endTime: '', formRef.value.resetFields();
}; }, 100);
}; });
}
const rules = { const rules = {
name: [ name: [
@ -187,11 +192,6 @@ const handleOk = () => {
}); });
}; };
const onClosed = () => {
visible.value = false;
resetForm();
};
// //
const couponList = ref([]) const couponList = ref([])
const selectCoupons = ref([]); const selectCoupons = ref([]);
@ -229,21 +229,15 @@ const stockFlagNum = ref(0)
function show(obj) { function show(obj) {
couponPageAjax() couponPageAjax()
console.log(obj);
if (obj && obj.id) { if (obj && obj.id) {
form.value = { form.value = { ...obj }
id: obj.id || '', form.value.timeScope = obj.startTime && obj.endTime ? [obj.startTime, obj.endTime] : []
stock: obj.stock || '',
name: obj.name || '', selectCoupons.value = obj.couponInfoList
timeScope: obj.startTime && obj.endTime ? [obj.startTime, obj.endTime] : [],
amount: obj.amount || '',
total: obj.total || 0,
startTime: '',
endTime: '',
};
stockFlagNum.value = obj.stock || 0 stockFlagNum.value = obj.stock || 0
} else { } else {
resetForm(); onClosedHandle();
} }
visible.value = true; visible.value = true;
} }
@ -251,6 +245,10 @@ function show(obj) {
defineExpose({ defineExpose({
show, show,
}); });
onMounted(() => {
resetForm.value = { ...form.value }
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@ -8,15 +8,15 @@
<el-form-item label="活动日期"> <el-form-item label="活动日期">
{{ form.startTime }} ~ {{ form.endTime }} {{ form.startTime }} ~ {{ form.endTime }}
</el-form-item> </el-form-item>
<el-form-item label="金额">
{{ form.amount }}
</el-form-item>
<el-form-item label="总数"> <el-form-item label="总数">
{{ form.total }} {{ form.total }}
</el-form-item> </el-form-item>
<el-form-item label="库存"> <el-form-item label="库存">
{{ form.stock }} {{ form.stock }}
</el-form-item> </el-form-item>
<el-form-item label="优惠券">
{{form.couponInfoList.map(item => item.title).join('、')}}
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="addRef.show({ ...form })">编辑</el-button> <el-button type="primary" @click="addRef.show({ ...form })">编辑</el-button>
</el-form-item> </el-form-item>
@ -64,7 +64,7 @@
<script setup> <script setup>
import { ref } from "vue"; import { ref } from "vue";
import add from "./add.vue"; import add from "./add.vue";
import { rechargeRedemptionCodeList, rechargeRedemptionDetail, rechargeRedemptionExport } from "@/api/coupon/index.js"; import { couponRedemptionCodeList, couponRedemptionDetail, couponRedemptionCodeExport } from "@/api/coupon/index.js";
import { downloadFile } from "@/utils/index"; import { downloadFile } from "@/utils/index";
const emit = defineEmits(['update']); const emit = defineEmits(['update']);
@ -81,6 +81,7 @@ const form = ref({
amount: '', amount: '',
total: 0, total: 0,
stock: 0, stock: 0,
couponInfoList: []
}); });
const resetForm = () => { const resetForm = () => {
@ -92,6 +93,7 @@ const resetForm = () => {
amount: '', amount: '',
total: 0, total: 0,
stock: 0, stock: 0,
couponInfoList: []
}; };
}; };
@ -150,7 +152,7 @@ async function getTableData(id) {
// //
try { try {
tableData.loading = true tableData.loading = true
const res = await rechargeRedemptionCodeList({ const res = await couponRedemptionCodeList({
redemptionId: redemptionId.value, redemptionId: redemptionId.value,
...queryForm.value, ...queryForm.value,
page: tableData.page, page: tableData.page,
@ -172,7 +174,7 @@ const exportLoading = ref(false)
async function exportHandle() { async function exportHandle() {
try { try {
exportLoading.value = true exportLoading.value = true
const file = await rechargeRedemptionExport({ const file = await couponRedemptionCodeExport({
redemptionId: redemptionId.value, redemptionId: redemptionId.value,
...queryForm.value, ...queryForm.value,
}); });
@ -188,7 +190,7 @@ async function exportHandle() {
// //
async function rechargeRedemptionDetailAjax() { async function rechargeRedemptionDetailAjax() {
try { try {
const res = await rechargeRedemptionDetail({ id: redemptionId.value }); const res = await couponRedemptionDetail({ id: redemptionId.value });
form.value = { form.value = {
id: res.id || '', id: res.id || '',
name: res.name || '', name: res.name || '',
@ -197,6 +199,7 @@ async function rechargeRedemptionDetailAjax() {
amount: res.amount || '', amount: res.amount || '',
total: res.total || 0, total: res.total || 0,
stock: res.stock || 0, stock: res.stock || 0,
couponInfoList: res.couponInfoList || []
}; };
} catch (error) { } catch (error) {
console.log(error); console.log(error);

View File

@ -45,7 +45,7 @@
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="120"> <el-table-column label="操作" width="120" fixed="right">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" @click="addRef.show(scope.row)">编辑</el-button> <el-button link type="primary" @click="addRef.show(scope.row)">编辑</el-button>
<el-button link type="primary" @click="recordRef.show(scope.row)">查看</el-button> <el-button link type="primary" @click="recordRef.show(scope.row)">查看</el-button>