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

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

@@ -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>