This commit is contained in:
gyq
2025-10-24 14:19:01 +08:00
parent 99881f4d97
commit f518d3d76a
8 changed files with 331 additions and 79 deletions

View File

@@ -1,6 +1,6 @@
<template>
<div>
<el-dialog title="充值兑换码" top="5vh" width="800px" v-model="visible" @closed="closedHandle">
<el-dialog title="兑换码" top="5vh" width="800px" v-model="visible" @closed="closedHandle">
<el-form label-width="80px" label-position="right">
<el-form-item label="名称">
{{ form.name }}
@@ -15,7 +15,7 @@
{{ form.stock }}
</el-form-item>
<el-form-item label="优惠券">
{{form.couponInfoList.map(item => item.title).join('、')}}
{{form.couponInfoList.map(item => `${item.title}x${item.num}`).join('、')}}
</el-form-item>
<el-form-item v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">
<el-button type="primary" @click="addRef.show({ ...form })">编辑</el-button>
@@ -37,9 +37,16 @@
</el-form-item>
</el-form>
</div>
<div class="row mt14">
<div class="row">
<el-table :data="tableData.list" border stripe v-loading="tableData.loading" height="300px">
<el-table-column label="兑换码" prop="code" />
<el-table-column label="兑换码" prop="code">
<template #default="scope">
<div class="center" @click="copyHandle(scope.row.code)">
<el-text>{{ scope.row.code }}</el-text>
<el-link type="primary">复制</el-link>
</div>
</template>
</el-table-column>
<el-table-column label="状态" prop="status" width="100">
<template #default="scope">
<el-tag disable-transitions :type="statusList.find(item => item.value === scope.row.status).type">
@@ -48,7 +55,14 @@
</template>
</el-table-column>
<el-table-column label="兑换时间" prop="redemptionTime" />
<el-table-column label="兑换用户" prop="nickName" />
<el-table-column label="兑换用户" prop="nickName">
<template #default="scope">
<div class="column">
<span>{{ scope.row.nickName }}</span>
<span>{{ scope.row.phone }}</span>
</div>
</template>
</el-table-column>
</el-table>
</div>
<div class="row mt14">
@@ -66,6 +80,9 @@ import { ref } from "vue";
import add from "./add.vue";
import { couponRedemptionCodeList, couponRedemptionDetail, couponRedemptionCodeExport } from "@/api/coupon/index.js";
import { downloadFile } from "@/utils/index";
import { ElNotification } from 'element-plus'
import useClipboard from "vue-clipboard3";
const { toClipboard } = useClipboard();
const emit = defineEmits(['update']);
const addRef = ref(null);
@@ -96,6 +113,21 @@ const resetForm = () => {
};
};
// 复制
async function copyHandle(text) {
try {
await toClipboard(text);
ElNotification({
title: "成功",
message: `复制成功`,
type: "success",
});
console.log("Copied to clipboard");
} catch (e) {
console.error(e);
}
}
// 关闭
function closedHandle() {
resetForm();
@@ -223,4 +255,15 @@ defineExpose({
margin-top: 14px;
}
}
.center {
display: flex;
align-items: center;
gap: 10px;
}
.column {
display: flex;
flex-direction: column;
}
</style>

View File

@@ -75,13 +75,13 @@
<el-radio label="优先使用会员价/会员折扣" value="vip-price"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="参与商品" prop="goodsType">
<el-form-item label="参与商品">
<el-radio-group v-model="form.foodType" @change="goodRadioChnage">
<el-radio label="全部商品可用" :value="1"></el-radio>
<el-radio label="部分商品可用" :value="2"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-if="form.foodType == 2">
<el-form-item v-if="form.foodType == 2" prop="goodsType">
<el-cascader v-model="goodsTypeCascaderValue" :options="goodsList" :props="cascaderProps"
:show-all-levels="false" :max-collapse-tags="3" collapse-tags clearable style="width: 300px"
@change="selectFoodsConfirm"></el-cascader>
@@ -215,7 +215,7 @@ const useShopTypeValidate = (rule, value, callback) => {
// 自定义校验参与商品(用于模板中 goodsType 判断)
const goodsTypeValidate = (rule, value, callback) => {
if (goodsType.value == 2 && form.value.foods === "") {
if (form.value.foodType == 2 && form.value.foods === "") {
callback(new Error("请选择商品"));
} else {
callback();
@@ -266,7 +266,7 @@ const formRules = reactive({
},
trigger: "change",
},
],
]
});
// 开始提交
@@ -278,7 +278,11 @@ function submitHandle() {
if (valid) {
loading.value = true;
const data = { ...form.value };
data.shopId = shopInfo.value.shopId;
if (form.value.id) {
data.shopId = form.value.shopId;
} else {
data.shopId = shopInfo.value.shopId;
}
data.useDays = form.value.useDays.join(",");
data.useType = form.value.useType.join(",");
await limitTimeDiscount(data, form.value.id ? "put" : "post");
@@ -315,7 +319,7 @@ async function getBranchPageAjax() {
// 获取商品列表
const goodsList = ref([]);
async function getProductListAjax() {
async function getProductListAjax(shopId) {
try {
const categorys = await getCategoryList();
const products = await getProductList();
@@ -365,6 +369,8 @@ function show(obj = null) {
});
if (obj && obj.id) {
getProductListAjax(form.value.shopId);
form.value = { ...obj };
form.value.useDays = form.value.useDays.split(",");
@@ -403,6 +409,7 @@ function show(obj = null) {
console.log(useTimeScope.value);
}
} else {
getProductListAjax(shopInfo.value.shopId);
reset();
}
dialogVisible.value = true;
@@ -468,7 +475,6 @@ onMounted(() => {
resetForm.value = { ...form.value };
getLocalShopInfo();
getBranchPageAjax();
getProductListAjax();
});
</script>

View File

@@ -8,7 +8,7 @@
<div class="row mt14">
<div class="center">
<el-button type="primary" @click="addRef.show()">添加</el-button>
<el-button type="primary" plain @click="visible = true">首次弹窗触发事件</el-button>
<el-button type="primary" plain :loading="showDialogLoading" @click="showDialogHandle">首次弹窗触发事件</el-button>
<span class="tips">多个弹窗时每个弹窗之间关闭和弹出间隔为30秒</span>
</div>
</div>
@@ -23,13 +23,13 @@
<div v-else>{{ scope.row.useStartTime }} - {{ scope.row.useEndTime }}</div>
</template>
</el-table-column>
<el-table-column label="启用状态" prop="status">
<el-table-column label="启用状态" prop="status" width="150">
<template #default="scope">
<el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0"
@change="statusChange($event, scope.row)" />
</template>
</el-table-column>
<el-table-column label="操作">
<el-table-column label="操作" width="120" fixed="right">
<template #default="scope">
<el-button link type="primary" @click="addRef.show(scope.row)">编辑</el-button>
<el-popconfirm title="确认要删除吗?" @confirm="deleteHandle(scope.row)">
@@ -140,6 +140,15 @@ async function shopInfoGetAjax() {
}
}
// 限时弹窗
const showDialogLoading = ref(false)
async function showDialogHandle() {
showDialogLoading.value = true
await shopInfoGetAjax()
showDialogLoading.value = false
visible.value = true
}
const visible = ref(false)
const confirmLoading = ref(false)
const formRef = ref(null)

View File

@@ -39,7 +39,14 @@
</div>
<div class="row mt14">
<el-table :data="tableData.list" border stripe v-loading="tableData.loading" height="300px">
<el-table-column label="兑换码" prop="code" />
<el-table-column label="兑换码" prop="code">
<template #default="scope">
<div class="center" @click="copyHandle(scope.row.code)">
<el-text>{{ scope.row.code }}</el-text>
<el-link type="primary">复制</el-link>
</div>
</template>
</el-table-column>
<el-table-column label="状态" prop="status" width="100">
<template #default="scope">
<el-tag disable-transitions :type="statusList.find(item => item.value === scope.row.status).type">
@@ -48,7 +55,14 @@
</template>
</el-table-column>
<el-table-column label="兑换时间" prop="redemptionTime" />
<el-table-column label="兑换用户" prop="nickName" />
<el-table-column label="兑换用户" prop="nickName">
<template #default="scope">
<div class="column">
<span>{{ scope.row.nickName }}</span>
<span>{{ scope.row.phone }}</span>
</div>
</template>
</el-table-column>
</el-table>
</div>
<div class="row mt14">
@@ -66,6 +80,8 @@ import { ref } from "vue";
import add from "./add.vue";
import { rechargeRedemptionCodeList, rechargeRedemptionDetail, rechargeRedemptionExport } from "@/api/coupon/index.js";
import { downloadFile } from "@/utils/index";
import useClipboard from "vue-clipboard3";
const { toClipboard } = useClipboard();
const emit = defineEmits(['update']);
const addRef = ref(null);
@@ -94,6 +110,21 @@ const resetForm = () => {
};
};
// 复制
async function copyHandle(text) {
try {
await toClipboard(text);
ElNotification({
title: "成功",
message: `复制成功`,
type: "success",
});
console.log("Copied to clipboard");
} catch (e) {
console.error(e);
}
}
// 关闭
function closedHandle() {
resetForm();
@@ -220,4 +251,15 @@ defineExpose({
margin-top: 14px;
}
}
.center {
display: flex;
align-items: center;
gap: 10px;
}
.column {
display: flex;
flex-direction: column;
}
</style>