fix: 修改订单计算逻辑
This commit is contained in:
113
src/views/user/list/components/give-coupon.vue
Normal file
113
src/views/user/list/components/give-coupon.vue
Normal file
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog title="赠送优惠券" v-model="show" @close="reset" width="400px">
|
||||
<el-form :model="form" label-width="120px">
|
||||
<el-form-item label="赠送用户">
|
||||
<div class="flex" v-if="user">
|
||||
<el-avatar :src="form.name" :size="60" shape="square" />
|
||||
<div class="ml-[18px]">
|
||||
<p class="text-size-lg">{{ user.nickName }}</p>
|
||||
<p class="color-999 mt-1">id:{{ user.userId }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号:">
|
||||
<span>{{ user.phone }}</span>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="选择优惠券" required>
|
||||
<el-select v-model="form.couponId" placeholder="请选择优惠券">
|
||||
<el-option
|
||||
v-for="coupon in couponList"
|
||||
:key="coupon.id"
|
||||
:label="coupon.title"
|
||||
:value="coupon.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数量" required>
|
||||
<el-input-number
|
||||
style="width: 160px"
|
||||
v-model="form.num"
|
||||
:min="1"
|
||||
:step="1"
|
||||
placeholder="请输入数量"
|
||||
></el-input-number>
|
||||
<span class="ml-2">张</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="text-align: right; margin-top: 20px">
|
||||
<el-button @click="close">取消</el-button>
|
||||
<el-button type="primary" @click="submit">{{ isedit ? "更新" : "提交" }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import couponApi from "@/api/market/coupon";
|
||||
|
||||
import { ref, toRaw } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
// 控制主弹窗显示
|
||||
const show = ref(false);
|
||||
|
||||
// 表单数据
|
||||
const form = ref({
|
||||
userId: "",
|
||||
couponId: "",
|
||||
num: 1,
|
||||
});
|
||||
|
||||
// 优惠券列表
|
||||
const couponList = ref([]);
|
||||
|
||||
// 重置表单
|
||||
function reset() {
|
||||
form.value = {
|
||||
userId: "",
|
||||
couponId: "",
|
||||
num: 1,
|
||||
};
|
||||
}
|
||||
|
||||
const emits = defineEmits(["submitSuccess"]);
|
||||
// 提交表单
|
||||
function submit() {
|
||||
console.log("提交表单数据:", form.value);
|
||||
if (!form.value.couponId) {
|
||||
return ElMessage.error("请选择优惠券");
|
||||
}
|
||||
if (form.value.num <= 0) {
|
||||
return ElMessage.error("请输入数量");
|
||||
}
|
||||
couponApi.giveCoupon(form.value).then((res) => {
|
||||
if (res) {
|
||||
ElMessage.success("优惠券发放成功");
|
||||
emits("submitSuccess", form.value);
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const user = ref("");
|
||||
function open(data) {
|
||||
console.log("打开表单:", data);
|
||||
user.value = data;
|
||||
form.value.userId = data.userId;
|
||||
show.value = true;
|
||||
}
|
||||
function close() {
|
||||
show.value = false;
|
||||
reset();
|
||||
}
|
||||
defineExpose({ open, close, reset, submit });
|
||||
|
||||
onMounted(() => {
|
||||
couponApi.getList({ size: 999 }).then((res) => {
|
||||
if (res) {
|
||||
couponList.value = res.records || [];
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -47,14 +47,21 @@
|
||||
<el-table-column label="操作">
|
||||
<template #default="scope">
|
||||
<el-link :underline="false" type="primary" size="mini">查看</el-link>
|
||||
<el-button :underline="false" type="danger" size="mini">删除</el-button>
|
||||
<el-link
|
||||
:underline="false"
|
||||
type="danger"
|
||||
class="ml-4"
|
||||
@click="deleteCoupon(scope.row)"
|
||||
size="mini"
|
||||
>
|
||||
删除
|
||||
</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.currentPage"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.size"
|
||||
:total="pagination.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@current-change="getList"
|
||||
@@ -82,11 +89,16 @@ const form = reactive({
|
||||
userId: "",
|
||||
page: 1,
|
||||
});
|
||||
|
||||
const tableData = ref([]);
|
||||
const pagination = reactive({
|
||||
total: 0,
|
||||
size: 10,
|
||||
page: 1,
|
||||
});
|
||||
function open(data) {
|
||||
console.log(data);
|
||||
data.userId = form.userId;
|
||||
form.page = 1;
|
||||
form.userId = data.userId;
|
||||
pagination.page = 1;
|
||||
visible.value = true;
|
||||
getList();
|
||||
}
|
||||
@@ -94,19 +106,25 @@ function close() {
|
||||
visible.value = false;
|
||||
}
|
||||
function getList() {
|
||||
couponApi.getDetail(form).then((res) => {
|
||||
couponApi.getDetail({ ...form, ...pagination }).then((res) => {
|
||||
console.log(res);
|
||||
tableData.value = res.records;
|
||||
pagination.total = res.totalRow;
|
||||
});
|
||||
}
|
||||
|
||||
const tableData = ref([]);
|
||||
const pagination = ref({
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
});
|
||||
function deleteCoupon(row) {
|
||||
couponApi
|
||||
.delete({
|
||||
id: row.id,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
ElMessage.success("删除成功");
|
||||
getList();
|
||||
}
|
||||
});
|
||||
}
|
||||
defineExpose({
|
||||
open,
|
||||
close,
|
||||
|
||||
@@ -106,6 +106,7 @@ const contentConfig: IContentConfig<any> = {
|
||||
options: [
|
||||
{ label: '增减余额', command: 'change-money' },
|
||||
{ label: '充值记录', command: 'charge-list' },
|
||||
{ label: '赠送券', command: 'give-coupon' },
|
||||
]
|
||||
},
|
||||
],
|
||||
|
||||
@@ -120,11 +120,14 @@
|
||||
|
||||
<!-- 用户优惠券详情 -->
|
||||
<UserCouponDialog ref="userCouponDialogRef"></UserCouponDialog>
|
||||
<!-- 赠送券 -->
|
||||
<GiveCoupon ref="GiveCouponRef"></GiveCoupon>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup >
|
||||
import UserCouponDialog from "./components/user-coupon-dialog.vue";
|
||||
import GiveCoupon from "./components/give-coupon.vue";
|
||||
import usePage from "@/components/CURD/usePage";
|
||||
import addModalConfig from "./config/add";
|
||||
import contentConfig from "./config/content";
|
||||
@@ -135,7 +138,7 @@ import { returnOptionsLabel } from "./config/config";
|
||||
import shopUserApi from "@/api/account/shopUser";
|
||||
const editMoneyModalRef = ref(null);
|
||||
const userCouponDialogRef = ref(null);
|
||||
|
||||
const GiveCouponRef = ref(null);
|
||||
//查看用户优惠券
|
||||
function handleViewCoupon(row) {
|
||||
userCouponDialogRef.value.open(row);
|
||||
@@ -214,6 +217,8 @@ function handleToolbarClick(name) {
|
||||
}
|
||||
}
|
||||
|
||||
// 赠送券
|
||||
function toGiveCoupon() {}
|
||||
// 其他操作列
|
||||
async function handleOperatClick(data) {
|
||||
const row = data.row;
|
||||
@@ -228,6 +233,10 @@ async function handleOperatClick(data) {
|
||||
toCharge({ userId: data.row.userId });
|
||||
return;
|
||||
}
|
||||
if (data.command === "give-coupon") {
|
||||
GiveCouponRef.value.open(row);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user