增加台桌管理页面,活动管理页面

This commit is contained in:
2025-02-19 15:38:27 +08:00
parent 0758aef0fb
commit e08a2eb4b7
12 changed files with 1832 additions and 394 deletions

View File

@@ -0,0 +1,327 @@
<template>
<div>
<el-dialog :title="form.id ? '编辑活动' : '添加活动'" v-model="dialogVisible" @close="reset">
<el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="left">
<el-form-item label="充值">
<el-input
style="width: 220px"
placeholder="请输入金额"
v-model="form.amount"
@input="(v) => (form.amount = v.replace(/^(0+)|[^\d]+/g, ''))"
>
<template #prepend></template>
<template #append></template>
</el-input>
</el-form-item>
<el-form-item label="赠送">
<div style="display: flex">
<el-input
style="width: 220px"
placeholder="请输入金额"
v-model="form.giftAmount"
@input="(v) => (form.giftAmount = v.replace(/^(0+)|[^\d]+/g, ''))"
>
<template #prepend></template>
<template #append></template>
</el-input>
<el-input
style="margin-left: 20px; width: 220px"
placeholder="请输入金额"
v-model="form.giftPoints"
@input="(v) => (form.giftPoints = v.replace(/^(0+)|[^\d]+/g, ''))"
>
<template #prepend></template>
<template #append>积分</template>
</el-input>
</div>
</el-form-item>
<el-form-item label="是否使用优惠券">
<el-switch v-model="form.isGiftCoupon" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
<el-form-item label="数量">
<el-input-number v-model="form.num" controls-position="right" :min="1"></el-input-number>
</el-form-item>
<el-form-item label="选择优惠劵" v-if="form.isGiftCoupon == 1">
<div>
<el-button
type="primary"
icon="el-icon-plus"
@click="$refs.coupon.show([...productIds])"
>
添加优惠劵
</el-button>
</div>
<div class="shop_list">
<div
class="item_wrap"
style="display: flex; align-items: center; margin-top: 6px"
v-for="(item, index) in productIds"
:key="index"
>
<div class="name">{{ item.title }}</div>
<el-button type="text" @click="productIds = []" style="margin-left: 20px">
删除
</el-button>
</div>
</div>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" :loading="loading" @click="onSubmitHandle"> </el-button>
</span>
</template>
</el-dialog>
<coupon ref="coupon" @success="slectShop" />
</div>
</template>
<script>
import handselTypes from "../handselTypes";
// import { activate, storageupActivate } from '@/api/shop'
import coupon from "@/components/coupon/index.vue";
import activeApi from "@/api/account/activate";
import { ElNotification } from "element-plus";
export default {
components: { coupon },
data() {
return {
dialogVisible: false,
loading: false,
handselTypes: handselTypes,
form: {
id: "",
amount: "",
giftAmount: "",
giftPoints: "",
isGiftCoupon: 0,
couponId: "",
num: 1,
},
productIds: [],
resetForm: "",
rules: {
minNum: [
{
required: true,
message: " ",
trigger: "blur",
},
],
maxNum: [
{
required: true,
message: " ",
trigger: "blur",
},
],
},
};
},
mounted() {
this.resetForm = { ...this.form };
},
methods: {
slectShop(res) {
console.log(res, 11);
// if (this.productIds.length) {
// res.map(async item => {
// if (!await this.checkShop(item.id)) {
// this.productIds.push({ ...item })
// }
// })
// } else {
this.productIds = res;
// }
},
// 判断是否存在重复商品
checkShop(id) {
let falg = false;
this.productIds.map((item) => {
if (item.id == id) {
falg = true;
}
});
return falg;
},
checkIfNum(item) {
item.num = item.num.toString().replace(/\D/g, "");
},
// 确认选择商品分类
classifySuccess(e) {
this.form.config.categoryList = e;
},
onSubmitHandle() {
console.log(this.form);
if (this.form.amount == "") {
this.$message({
message: "充值金额不能为空",
type: "warning",
});
return false;
}
if (this.form.isGiftCoupon == 1) {
if (this.productIds.length == 0) {
this.$message({
message: "请选择优惠劵",
type: "warning",
});
return false;
}
this.form.couponId = this.productIds[0].id;
} else {
this.form.couponId = "";
this.form.couponName = "";
this.productIds = [];
}
// let arr = []
// this.productIds.forEach(ele => {
// arr.push({
// productId: ele.id,
// num: ele.num
// })
// })
this.$refs.form.validate(async (valid) => {
if (valid) {
try {
this.loading = true;
let res = this.form.id
? await activeApi.edit(this.form)
: await activeApi.add(this.form);
this.$emit("success", res);
this.close();
ElNotification({
title: "成功",
message: `${this.form.id ? "编辑" : "添加"}成功`,
type: "success",
});
this.loading = false;
} catch (error) {
this.loading = false;
console.log(error);
}
}
});
},
async show(obj) {
this.productIds = [];
this.dialogVisible = true;
if (obj && obj.id) {
this.form = { ...obj };
// 留着以后说不定多个优惠劵
// let res = await activate(obj.id)
// this.productIds = res
if (obj.couponId) {
this.productIds = [{ title: obj.couponName, id: obj.couponId }];
}
console.log(obj, "调试1");
}
},
close() {
this.dialogVisible = false;
},
reset() {
this.form = { ...this.resetForm };
},
},
};
</script>
<style scoped lang="scss">
.labelbox {
display: flex;
justify-content: flex-start;
align-items: center;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 12px;
color: #666666;
width: 130px;
background: #f7f7fa;
border-radius: 2px 2px 2px 2px;
border: 1px solid #dddfe6;
padding: 0 10px;
input {
border: none !important;
}
}
.labelboxss {
display: flex;
justify-content: flex-start;
align-items: center;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 14px;
color: #666666;
}
.shop_list {
// display: flex;/
// flex-wrap: wrap;
.item_wrap {
$size: 80px;
.item {
$radius: 4px;
width: $size;
height: $size;
border-radius: $radius;
overflow: hidden;
position: relative;
margin-right: 10px;
margin-top: 10px;
&:hover {
cursor: pointer;
}
&::after {
content: attr(data-index);
font-size: 12px;
height: 20px;
display: flex;
padding: 0 10px;
border-radius: 0 0 $radius 0;
align-items: center;
background-color: rgba(0, 0, 0, 0.3);
backdrop-filter: blur(10px);
color: #fff;
position: absolute;
top: 0;
left: 0;
z-index: 10;
}
&::before {
content: "删除";
font-size: 12px;
width: 100%;
height: 20px;
display: flex;
padding: 0 10px;
align-items: center;
justify-content: center;
background-color: rgba(0, 0, 0, 0.3);
backdrop-filter: blur(10px);
color: #fff;
position: absolute;
bottom: 0;
left: 0;
z-index: 10;
transition: all 0.1s ease-in-out;
}
}
.name {
width: $size;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
</style>

View File

@@ -0,0 +1,73 @@
<template>
<div class="downloadQR" v-show="isshow">
<div class="box">
<img :src="imgUrl" style="width: 300px; height: 300px" alt="" />
<div class="btnStyle">
<el-button type="primary" @click="isshow = false">取消</el-button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a :href="imgUrl"><el-button type="primary" @click="downImg">下载</el-button></a>
</div>
</div>
</div>
</template>
<script>
// import { getwxacode } from '@/api/shop'
export default {
data() {
return {
isshow: false,
imgUrl: "",
};
},
mounted() {},
methods: {
show() {
this.getlist();
},
async getlist() {
let res = await getwxacode({
shopId: localStorage.getItem("shopId"),
});
this.isshow = true;
this.imgUrl = res;
},
downImg() {
// window.location.href()
window.URL.revokeObjectURL(this.imgUrl);
},
},
};
</script>
<style scoped lang="scss">
.downloadQR {
display: flex;
justify-content: center;
align-items: center;
background-color: rgba($color: #000000, $alpha: 0.6);
width: 100%;
height: 100%;
position: fixed;
left: 0;
top: 0;
z-index: 9999;
.box {
padding: 20px;
border-radius: 3px;
height: 400px;
width: 340px;
background-color: #fff;
display: flex;
// align-items: center;
// justify-content: center;
flex-direction: column;
}
.btnStyle {
margin-top: 20px;
text-align: center;
}
}
</style>

View File

@@ -0,0 +1,10 @@
export default [
{
label: "固定金额",
value: "GD"
},
{
label: "比例",
value: "RATIO"
}
];

View File

@@ -1,155 +1,147 @@
<template>
<div class="app-container">
<!-- 列表 -->
<!-- 搜索 -->
<page-search
ref="searchRef"
:search-config="searchConfig"
@query-click="handleQueryClick"
@reset-click="handleResetClick"
/>
<!-- 列表 -->
<page-content
ref="contentRef"
:content-config="contentConfig"
@add-click="handleAddClick"
@edit-click="handleEditClick"
@export-click="handleExportClick"
@search-click="handleSearchClick"
@toolbar-click="handleToolbarClick"
@operat-click="handleOperatClick"
@filter-change="handleFilterChange"
>
<template #status="scope">
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
</el-tag>
</template>
<template #options="scope">
{{ returnOptionsLabel(scope.prop, scope.row[scope.prop]) }}
</template>
<template #bol="scope">
{{ scope.row[scope.prop] ? "是" : "否" }}
</template>
<template #gender="scope">
<el-tag
:type="
scope.row[scope.prop] == null
? 'info'
: scope.row[scope.prop] == 1
? 'success'
: 'warning'
"
>
{{ scope.row[scope.prop] === null ? "未知" : scope.row[scope.prop] == 1 ? "男" : "女" }}
</el-tag>
</template>
<template #user="scope">
<div class="flex align-center">
<el-avatar :src="scope.row.headImg" />
<el-tag>{{ scope.row.nickName }}</el-tag>
</div>
</template>
<template #link="scope">
<el-link>{{ scope.row[scope.prop] }}</el-link>
</template>
<template #mobile="scope">
<el-text>{{ scope.row[scope.prop] }}</el-text>
<copy-button
v-if="scope.row[scope.prop]"
:text="scope.row[scope.prop]"
style="margin-left: 2px"
/>
</template>
</page-content>
<!-- 新增 -->
<page-modal
ref="addModalRef"
:modal-config="addModalConfig"
@submit-click="handleSubmitClick"
@formDataChange="formDataChange"
></page-modal>
<!-- 编辑 -->
<page-modal
ref="editModalRef"
:modal-config="editModalConfig"
@submit-click="handleSubmitClick"
@formDataChange="formDataChange"
></page-modal>
<div class="head-container">
<el-button type="primary" icon="plus" @click="$refs.addActive.show()">添加活动</el-button>
<el-button type="primary" icon="download" @click="$refs.downloadQR.show()">
下载会员充值二维码
</el-button>
<div style="margin-top: 35px; font-size: 16px; color: #333">
允许充值自定义金额
<el-switch
v-model="shopInfo.isCustom"
active-value="1"
inactive-value="0"
size="large"
@change="customStatusChange"
></el-switch>
</div>
</div>
<div class="head-container">
<el-table :data="tableData.data" v-loading="tableData.loading">
<el-table-column label="店铺ID" prop="shopId"></el-table-column>
<el-table-column label="充值金额" prop="amount"></el-table-column>
<el-table-column label="赠送金额" prop="giftAmount"></el-table-column>
<el-table-column label="赠送积分" prop="giftPoints"></el-table-column>
<el-table-column label="是否使用优惠券" prop="isUseCoupon">
<template v-slot="scope">
{{ scope.row.isUseCoupon == 1 ? "" : "" }}
</template>
</el-table-column>
<el-table-column label="操作" width="120">
<template v-slot="scope">
<el-button type="text" icon="edit" @click="$refs.addActive.show(scope.row)">
编辑
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="head-container">
<el-pagination
:total="tableData.total"
:current-page="tableData.page + 1"
:page-size="tableData.size"
@current-change="paginationChange"
layout="total"
></el-pagination>
</div>
<addActive ref="addActive" @success="getTableData" />
<QR ref="downloadQR"></QR>
</div>
</template>
<script setup >
import usePage from "@/components/CURD/usePage";
import addModalConfig from "./config/add";
import contentConfig from "./config/content";
import editModalConfig from "./config/edit";
import searchConfig from "./config/search";
import { returnOptionsLabel } from "./config/config";
const editMoneyModalRef = ref(null);
const {
searchRef,
contentRef,
addModalRef,
editModalRef,
handleQueryClick,
handleResetClick,
// handleAddClick,
// handleEditClick,
handleSubmitClick,
handleExportClick,
handleSearchClick,
handleFilterChange,
} = usePage();
// 修改金额表单类型
function formDataChange(type, val) {
console.log(type, val);
}
// 新增
async function handleAddClick() {
addModalRef.value?.setModalVisible();
}
// 获取优惠券
async function getCouponList() {}
// 编辑
async function handleEditClick(row) {
editModalRef.value?.handleDisabled(false);
editModalRef.value?.setModalVisible();
// 根据id获取数据进行填充
// const data = await VersionApi.getFormData(row.id);
editModalRef.value?.setFormData({ ...row, headImg: row.headImg ? [row.headImg] : "" });
}
// 其他工具栏
function handleToolbarClick(name) {
console.log(name);
if (name === "custom1") {
ElMessage.success("点击了自定义1按钮");
}
}
// 其他操作列
async function handleOperatClick(data) {
const row = data.row;
if (data.name == "more") {
if (data.command === "change-money") {
editMoneyModalRef.value.setModalVisible();
editMoneyModalRef.value.setFormData({ ...row, headImg: row.headImg ? [row.headImg] : "" });
return;
}
return;
}
}
// 切换示例
const isA = ref(true);
<script>
import handselTypes from "./handselTypes";
import addActive from "./components/addActive.vue";
import QR from "./components/downloadQR.vue";
import activeApi from "@/api/account/activate";
import dayjs from "dayjs";
export default {
components: {
addActive,
QR,
},
data() {
return {
query: {
shopId: "",
},
tableData: {
data: [],
page: 0,
size: 10,
loading: false,
total: 0,
},
shopInfo: {
isCustom: "0",
},
};
},
filters: {
handselTypeFilter(value) {
return handselTypes.find((item) => item.value == value).label;
},
timeFilter(s) {
return dayjs(s).format("YYYY-MM-DD HH:mm:ss");
},
},
mounted() {
this.getTableData();
},
methods: {
// 切换状态
async statusChange(e, row) {
if (row.couponName) {
try {
this.tableData.loading = true;
const data = { ...row };
data.isUseCoupon = e;
console.log(data.isUseCoupon);
await storageupActivate(data);
this.getTableData();
} catch (error) {
console.log(error);
this.tableData.loading = false;
}
} else {
console.log(22);
this.$message({
message: "请选择优惠劵",
type: "warning",
});
return false;
}
},
// 重置查询
resetHandle() {
this.query.name = "";
this.query.type = "";
this.getTableData();
},
// 分页回调
paginationChange(e) {
this.tableData.page = e - 1;
this.getTableData();
},
// 获取商品列表
async getTableData() {
this.tableData.loading = true;
try {
const res = await activeApi.getList({});
this.tableData.loading = false;
this.tableData.data = res;
this.tableData.total = res.length;
} catch (error) {
console.log(error);
}
},
customStatusChange() {
this.updateShopInfo();
},
async updateShopInfo() {
await tbShopInfoPut(this.shopInfo);
},
},
};
</script>
<style scoped>
.align-center {
align-items: center;
}
</style>