增加券兑换码
This commit is contained in:
parent
695898484e
commit
71c852fcaa
|
|
@ -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",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<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-item label="名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入" :maxlength="50" show-word-limit
|
||||
|
|
@ -18,6 +18,10 @@
|
|||
<template #append>个</template>
|
||||
</el-input>
|
||||
</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">
|
||||
<div class="center" v-for="(item, index) in selectCoupons" :key="item.id">
|
||||
<el-select v-model="item.id" @change="selectCouponChnge($event, index)">
|
||||
|
|
@ -48,7 +52,7 @@
|
|||
|
||||
<script setup>
|
||||
import _ from 'lodash'
|
||||
import { ref } from "vue";
|
||||
import { ref, nextTick, onMounted } from "vue";
|
||||
import { filterNumberInput } from '@/utils'
|
||||
import { couponRedemption, couponPage } from "@/api/coupon/index.js";
|
||||
|
||||
|
|
@ -67,18 +71,19 @@ const form = ref({
|
|||
endTime: '',
|
||||
});
|
||||
|
||||
const resetForm = () => {
|
||||
form.value = {
|
||||
id: '',
|
||||
stock: '',
|
||||
name: '',
|
||||
timeScope: [],
|
||||
amount: '',
|
||||
total: 0,
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
};
|
||||
};
|
||||
const resetForm = ref({})
|
||||
|
||||
// 关闭后重置表单
|
||||
function onClosedHandle() {
|
||||
form.value = { ...resetForm.value };
|
||||
selectCoupons.value = [];
|
||||
|
||||
nextTick(() => {
|
||||
setTimeout(() => {
|
||||
formRef.value.resetFields();
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
const rules = {
|
||||
name: [
|
||||
|
|
@ -187,11 +192,6 @@ const handleOk = () => {
|
|||
});
|
||||
};
|
||||
|
||||
const onClosed = () => {
|
||||
visible.value = false;
|
||||
resetForm();
|
||||
};
|
||||
|
||||
// 选择优惠券开始
|
||||
const couponList = ref([])
|
||||
const selectCoupons = ref([]);
|
||||
|
|
@ -229,21 +229,15 @@ const stockFlagNum = ref(0)
|
|||
|
||||
function show(obj) {
|
||||
couponPageAjax()
|
||||
console.log(obj);
|
||||
if (obj && obj.id) {
|
||||
form.value = {
|
||||
id: obj.id || '',
|
||||
stock: obj.stock || '',
|
||||
name: obj.name || '',
|
||||
timeScope: obj.startTime && obj.endTime ? [obj.startTime, obj.endTime] : [],
|
||||
amount: obj.amount || '',
|
||||
total: obj.total || 0,
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
};
|
||||
form.value = { ...obj }
|
||||
form.value.timeScope = obj.startTime && obj.endTime ? [obj.startTime, obj.endTime] : []
|
||||
|
||||
selectCoupons.value = obj.couponInfoList
|
||||
|
||||
stockFlagNum.value = obj.stock || 0
|
||||
} else {
|
||||
resetForm();
|
||||
onClosedHandle();
|
||||
}
|
||||
visible.value = true;
|
||||
}
|
||||
|
|
@ -251,6 +245,10 @@ function show(obj) {
|
|||
defineExpose({
|
||||
show,
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
resetForm.value = { ...form.value }
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@
|
|||
<el-form-item label="活动日期">
|
||||
{{ form.startTime }} ~ {{ form.endTime }}
|
||||
</el-form-item>
|
||||
<el-form-item label="金额">
|
||||
{{ form.amount }}
|
||||
</el-form-item>
|
||||
<el-form-item label="总数">
|
||||
{{ form.total }}
|
||||
</el-form-item>
|
||||
<el-form-item label="库存">
|
||||
{{ form.stock }}
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠券">
|
||||
{{form.couponInfoList.map(item => item.title).join('、')}}
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="addRef.show({ ...form })">编辑</el-button>
|
||||
</el-form-item>
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
<script setup>
|
||||
import { ref } from "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";
|
||||
|
||||
const emit = defineEmits(['update']);
|
||||
|
|
@ -81,6 +81,7 @@ const form = ref({
|
|||
amount: '',
|
||||
total: 0,
|
||||
stock: 0,
|
||||
couponInfoList: []
|
||||
});
|
||||
|
||||
const resetForm = () => {
|
||||
|
|
@ -92,6 +93,7 @@ const resetForm = () => {
|
|||
amount: '',
|
||||
total: 0,
|
||||
stock: 0,
|
||||
couponInfoList: []
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -150,7 +152,7 @@ async function getTableData(id) {
|
|||
// 获取表格数据
|
||||
try {
|
||||
tableData.loading = true
|
||||
const res = await rechargeRedemptionCodeList({
|
||||
const res = await couponRedemptionCodeList({
|
||||
redemptionId: redemptionId.value,
|
||||
...queryForm.value,
|
||||
page: tableData.page,
|
||||
|
|
@ -172,7 +174,7 @@ const exportLoading = ref(false)
|
|||
async function exportHandle() {
|
||||
try {
|
||||
exportLoading.value = true
|
||||
const file = await rechargeRedemptionExport({
|
||||
const file = await couponRedemptionCodeExport({
|
||||
redemptionId: redemptionId.value,
|
||||
...queryForm.value,
|
||||
});
|
||||
|
|
@ -188,7 +190,7 @@ async function exportHandle() {
|
|||
// 获取配置详情
|
||||
async function rechargeRedemptionDetailAjax() {
|
||||
try {
|
||||
const res = await rechargeRedemptionDetail({ id: redemptionId.value });
|
||||
const res = await couponRedemptionDetail({ id: redemptionId.value });
|
||||
form.value = {
|
||||
id: res.id || '',
|
||||
name: res.name || '',
|
||||
|
|
@ -197,6 +199,7 @@ async function rechargeRedemptionDetailAjax() {
|
|||
amount: res.amount || '',
|
||||
total: res.total || 0,
|
||||
stock: res.stock || 0,
|
||||
couponInfoList: res.couponInfoList || []
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120">
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click="addRef.show(scope.row)">编辑</el-button>
|
||||
<el-button link type="primary" @click="recordRef.show(scope.row)">查看</el-button>
|
||||
|
|
|
|||
Loading…
Reference in New Issue