feat 初始化优惠券,添加多选商品的弹窗和接口
This commit is contained in:
parent
f99fd9cb7d
commit
01d7cf332f
@ -18,6 +18,15 @@ export function goodsList(query) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 全部商品查询列表
|
||||||
|
export function allGoodsList(query) {
|
||||||
|
return request({
|
||||||
|
url: '/business/Goods/getAllGoodsList',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 获取商品Sku
|
// 获取商品Sku
|
||||||
export function getGoodsSkuList(query) {
|
export function getGoodsSkuList(query) {
|
||||||
return request({
|
return request({
|
||||||
|
46
src/api/business/Marketing/CouponManage/Coupons/coupon.js
Normal file
46
src/api/business/Marketing/CouponManage/Coupons/coupon.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Descripttion: 优惠券Api接口
|
||||||
|
* @version: (1.0)
|
||||||
|
* @Author: (lwh)
|
||||||
|
* @Date: (2023-07-24)
|
||||||
|
* @LastEditors: (lwh)
|
||||||
|
* @LastEditTime: (2023-07-24)
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 优惠券分页查询列表
|
||||||
|
export function couponList(query) {
|
||||||
|
return request({
|
||||||
|
url: '/business/Coupon/getCouponList',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 优惠券新增或修改
|
||||||
|
export function addOrUpdateCoupon(data) {
|
||||||
|
return request({
|
||||||
|
url: '/business/Coupon/addOrUpdateCoupon',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 优惠券删除
|
||||||
|
export function delCoupon(ids) {
|
||||||
|
return request({
|
||||||
|
url: '/business/Coupon/'+ ids,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 优惠券导出
|
||||||
|
export function exportCoupon(query) {
|
||||||
|
return request({
|
||||||
|
url: 'business/Coupon/exportCoupon',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,273 @@
|
|||||||
|
<!--
|
||||||
|
* @Descripttion: (优惠券/tb_coupon 添加弹窗)
|
||||||
|
* @version: (1.0)
|
||||||
|
* @Author: (lwh)
|
||||||
|
* @Date: (2023-07-24)
|
||||||
|
* @LastEditors: (lwh)
|
||||||
|
* @LastEditTime: (2023-07-24)
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<el-dialog v-model="props.modelValue" title="添加优惠券信息" width="900px" @closed="closeDialog" @open="openDialog">
|
||||||
|
<el-form ref="formRef" :model="formData" :rules="rules">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="优惠劵名称" prop="couponName">
|
||||||
|
<el-input v-model="formData.couponName" placeholder="请输入优惠劵名称" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
|
||||||
|
<el-row>
|
||||||
|
<el-col :lg="24">
|
||||||
|
<el-form-item :label-width="labelWidth" label="优惠劵类型" prop="couponType">
|
||||||
|
<el-radio-group v-model="formData.couponType">
|
||||||
|
<el-radio v-for="item in coupon_type " :key="item.dictValue" :label="parseInt(item.dictValue)">{{
|
||||||
|
item.dictLabel }}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="12" v-if="formData.couponType == 1">
|
||||||
|
<el-form-item :label-width="labelWidth" label="减免金额" prop="couponDeductionMoney">
|
||||||
|
<el-input-number v-model.number="formData.couponDeductionMoney" controls-position="right" :min="0"
|
||||||
|
precision="2" />
|
||||||
|
<span class="number-unit">元</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="12" v-if="formData.couponType == 2">
|
||||||
|
<el-form-item :label-width="labelWidth" label="折扣率" prop="couponDiscountRate">
|
||||||
|
<el-input-number v-model.number="formData.couponDiscountRate" controls-position="right" :min="0"
|
||||||
|
precision="2" />
|
||||||
|
<span class="number-unit">%</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="最低消费金额" prop="couponMinConsumeMoney">
|
||||||
|
<el-input-number v-model.number="formData.couponMinConsumeMoney" controls-position="right" :min="0"
|
||||||
|
precision="2" />
|
||||||
|
<span class="number-unit">元</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="24">
|
||||||
|
<el-form-item :label-width="labelWidth" label="到期类型" prop="couponExpireType">
|
||||||
|
<el-radio-group v-model="formData.couponExpireType">
|
||||||
|
<el-radio v-for="item in coupon_expire_type " :key="item.dictValue" :label="parseInt(item.dictValue)">{{
|
||||||
|
item.dictLabel }}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="12" v-if="formData.couponExpireType == 1">
|
||||||
|
<el-form-item :label-width="labelWidth" label="有效天数" prop="couponEffectiveDays">
|
||||||
|
<el-input-number v-model.number="formData.couponEffectiveDays" controls-position="right" :min="0" />
|
||||||
|
<span class="number-unit">天</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="12" v-if="formData.couponExpireType == 2">
|
||||||
|
<el-form-item :label-width="labelWidth" label="" prop="couponFixedStartTime">
|
||||||
|
<!-- <el-date-picker v-model="formData.couponFixedStartTime" type="datetime" :teleported="false"
|
||||||
|
placeholder="选择日期时间"></el-date-picker> -->
|
||||||
|
<el-date-picker
|
||||||
|
v-model="formData.couponFixedTime"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="24">
|
||||||
|
<el-form-item :label-width="labelWidth" label="适用范围" prop="couponApplicableScope">
|
||||||
|
<el-radio-group v-model="formData.couponApplicableScope">
|
||||||
|
<el-radio v-for="item in applicable_scope " :key="item.dictValue" :label="parseInt(item.dictValue)">{{
|
||||||
|
item.dictLabel }}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="24" v-if="formData.couponApplicableScope == 2">
|
||||||
|
<el-form-item :label-width="labelWidth" label="" prop="">
|
||||||
|
<el-button type="primary" plain @click="handleChooseGoods">+ 指定商品</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="24">
|
||||||
|
<el-form-item :label-width="labelWidth" label="发送数量" prop="couponSendNumber">
|
||||||
|
<div style="display: block;">
|
||||||
|
<el-input-number v-model.number="formData.couponSendNumber" controls-position="right" :min="0" />
|
||||||
|
<div class="input-intro">(-1不限制)</div>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="显示状态" prop="couponDisplayStatus">
|
||||||
|
<el-radio-group v-model="formData.couponDisplayStatus">
|
||||||
|
<el-radio v-for="item in display_status " :key="item.dictValue" :label="parseInt(item.dictValue)">{{
|
||||||
|
item.dictLabel }}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="排序" prop="couponSort">
|
||||||
|
<el-input-number v-model.number="formData.couponSort" controls-position="right" :min="0" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<div key="dialog-footer">
|
||||||
|
<el-button type="primary" @click="handleAddClick(formRef)" :loading="loadingStatus">添加</el-button>
|
||||||
|
<el-button @click="handleResetClick(formRef)">重置</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 选择商品 -->
|
||||||
|
<ChooseMultipleGoodsDialog v-model="ChooseGoodsDialogVisible" :data="ChooseGoodsDialogRow">
|
||||||
|
</ChooseMultipleGoodsDialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { reactive, ref, watch } from "vue";
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import modal from '@/plugins/modal.js'
|
||||||
|
import { addOrUpdateCoupon } from '@/api/business/Marketing/CouponManage/Coupons/coupon.js';
|
||||||
|
import ChooseMultipleGoodsDialog from '@/views/business/components/ChooseMultipleGoodsDialog.vue';
|
||||||
|
|
||||||
|
|
||||||
|
// 打开弹窗时回调
|
||||||
|
const openDialog = async () => {
|
||||||
|
|
||||||
|
await getcoupon_type()
|
||||||
|
await getcoupon_expire_type()
|
||||||
|
await getapplicable_scope()
|
||||||
|
await getdisplay_status()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -业务参数
|
||||||
|
// 优惠劵类型字典选项列表
|
||||||
|
const coupon_type = ref([]);
|
||||||
|
// 到期类型字典选项列表
|
||||||
|
const coupon_expire_type = ref([]);
|
||||||
|
// 适用范围字典选项列表
|
||||||
|
const applicable_scope = ref([]);
|
||||||
|
// 显示状态字典选项列表
|
||||||
|
const display_status = ref([]);
|
||||||
|
// 选择商品弹窗参数
|
||||||
|
const ChooseGoodsDialogVisible = ref(false);
|
||||||
|
const ChooseGoodsDialogRow = ref({});
|
||||||
|
|
||||||
|
// 打开选择商品弹窗
|
||||||
|
const handleChooseGoods = () => {
|
||||||
|
ChooseGoodsDialogVisible.value = true
|
||||||
|
ChooseGoodsDialogRow.value = formData
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -业务方法
|
||||||
|
// 字典获取
|
||||||
|
async function getcoupon_type() {
|
||||||
|
await proxy.getDicts('coupon_type').then((res) => {
|
||||||
|
coupon_type.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 字典获取
|
||||||
|
async function getcoupon_expire_type() {
|
||||||
|
await proxy.getDicts('coupon_expire_type').then((res) => {
|
||||||
|
coupon_expire_type.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 字典获取
|
||||||
|
async function getapplicable_scope() {
|
||||||
|
await proxy.getDicts('applicable_scope').then((res) => {
|
||||||
|
applicable_scope.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 字典获取
|
||||||
|
async function getdisplay_status() {
|
||||||
|
await proxy.getDicts('display_status').then((res) => {
|
||||||
|
display_status.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -基础参数
|
||||||
|
const loadingStatus = ref(false)
|
||||||
|
const labelWidth = 120;
|
||||||
|
const formRef = ref();
|
||||||
|
const { proxy } = getCurrentInstance()
|
||||||
|
const emits = defineEmits(["update:modelValue"]);
|
||||||
|
const formData = reactive({
|
||||||
|
couponType: 1,
|
||||||
|
couponExpireType: 1,
|
||||||
|
couponApplicableScope: 1,
|
||||||
|
couponDisplayStatus: 1,
|
||||||
|
couponSort: 100
|
||||||
|
});
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: Boolean,
|
||||||
|
done: Function,
|
||||||
|
});
|
||||||
|
const imgData = ref({
|
||||||
|
fileDir: "Coupon"
|
||||||
|
})
|
||||||
|
|
||||||
|
// 验证
|
||||||
|
const rules = reactive({
|
||||||
|
couponGuid: [{ required: true, message: "不能为空", trigger: "blur", type: "number" }],
|
||||||
|
couponName: [{ required: true, message: "优惠劵名称不能为空", trigger: "blur" }],
|
||||||
|
couponType: [{ required: true, message: "优惠劵类型不能为空", trigger: "blur", type: "number" }],
|
||||||
|
couponMinConsumeMoney: [{ required: true, message: "最低消费金额不能为空", trigger: "blur" }],
|
||||||
|
couponExpireType: [{ required: true, message: "到期类型不能为空", trigger: "blur", type: "number" }],
|
||||||
|
couponSendNumber: [{ required: true, message: "发送数量(-1不限制)不能为空", trigger: "blur", type: "number" }],
|
||||||
|
couponDisplayStatus: [{ required: true, message: "显示状态不能为空", trigger: "blur", type: "number" }],
|
||||||
|
couponSort: [{ required: true, message: "排序不能为空", trigger: "blur", type: "number" }],
|
||||||
|
});
|
||||||
|
|
||||||
|
// -基础方法
|
||||||
|
|
||||||
|
// 提交
|
||||||
|
const handleAddClick = async (formEl) => {
|
||||||
|
if (!formEl) return;
|
||||||
|
formEl.validate(async (valid) => {
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loadingStatus.value = true
|
||||||
|
|
||||||
|
|
||||||
|
const { code } = await addOrUpdateCoupon(formData);
|
||||||
|
if (code == 200) {
|
||||||
|
modal.msgSuccess('添加成功')
|
||||||
|
closeDialog();
|
||||||
|
loadingStatus.value = false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const closeDialog = () => {
|
||||||
|
handleResetClick(formRef.value);
|
||||||
|
props.done();
|
||||||
|
emits("update:modelValue", false);
|
||||||
|
};
|
||||||
|
const handleResetClick = async (formEl) => {
|
||||||
|
if (!formEl) return;
|
||||||
|
formEl.resetFields();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.number-unit {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
.input-intro {
|
||||||
|
color: #8c8c8c;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
@ -0,0 +1,203 @@
|
|||||||
|
<!--
|
||||||
|
* @Descripttion: (优惠券/tb_coupon 详情弹窗)
|
||||||
|
* @version: (1.0)
|
||||||
|
* @Author: (lwh)
|
||||||
|
* @Date: (2023-07-24)
|
||||||
|
* @LastEditors: (lwh)
|
||||||
|
* @LastEditTime: (2023-07-24)
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<el-dialog v-model="props.modelValue" title="优惠券信息详情" width="900px" @closed="closeDialog" @open="openDialog">
|
||||||
|
<el-form ref="formRef" :model="formData" :disabled="true">
|
||||||
|
|
||||||
|
<el-row :gutter="20">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="优惠劵名称" >
|
||||||
|
<el-input v-model="formData.couponName" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="优惠劵类型" >
|
||||||
|
<el-radio-group v-model="formData.couponType">
|
||||||
|
<el-radio v-for="item in coupon_type " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="减免金额" >
|
||||||
|
<el-input-number v-model.number="formData.couponDeductionMoney" controls-position="right" :precision="2" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="折扣率" >
|
||||||
|
<el-input-number v-model.number="formData.couponDiscountRate" controls-position="right" :precision="2" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="最低消费金额" >
|
||||||
|
<el-input-number v-model.number="formData.couponMinConsumeMoney" controls-position="right" :precision="2" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="到期类型" >
|
||||||
|
<el-radio-group v-model="formData.couponExpireType">
|
||||||
|
<el-radio v-for="item in coupon_expire_type " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="有效天数" >
|
||||||
|
<el-input-number v-model.number="formData.couponEffectiveDays" controls-position="right" :precision="2" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="固定时间-开始时间" >
|
||||||
|
<el-date-picker v-model="formData.couponFixedStartTime" type="datetime" :teleported="false" isabledStr}></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="固定时间-结束时间" >
|
||||||
|
<el-date-picker v-model="formData.couponFixedEndTime" type="datetime" :teleported="false" isabledStr}></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="适用范围" >
|
||||||
|
<el-radio-group v-model="formData.couponApplicableScope">
|
||||||
|
<el-radio v-for="item in applicable_scope " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="适用范围配置(json)" >
|
||||||
|
<el-input v-model="formData.couponApplicableScopeConfig" :disabled="true"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="发送数量(-1不限制)" >
|
||||||
|
<el-input-number v-model.number="formData.couponSendNumber" controls-position="right" :precision="2" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="已领取数量" >
|
||||||
|
<el-input-number v-model.number="formData.couponGetNumber" controls-position="right" :precision="2" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="显示状态" >
|
||||||
|
<el-radio-group v-model="formData.couponDisplayStatus">
|
||||||
|
<el-radio v-for="item in display_status " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="排序" >
|
||||||
|
<el-input-number v-model.number="formData.couponSort" controls-position="right" :precision="2" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { reactive, ref, watch } from "vue";
|
||||||
|
|
||||||
|
|
||||||
|
// 打开弹窗时回调
|
||||||
|
const openDialog = async () => {
|
||||||
|
await getcoupon_type()
|
||||||
|
await getcoupon_expire_type()
|
||||||
|
await getapplicable_scope()
|
||||||
|
await getdisplay_status()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = ref({
|
||||||
|
...props.data,
|
||||||
|
});
|
||||||
|
watch(props, async (v) => {
|
||||||
|
formData.value = v.data;
|
||||||
|
});
|
||||||
|
|
||||||
|
// -业务参数
|
||||||
|
// 优惠劵类型字典选项列表
|
||||||
|
const coupon_type = ref([]);
|
||||||
|
// 到期类型字典选项列表
|
||||||
|
const coupon_expire_type = ref([]);
|
||||||
|
// 适用范围字典选项列表
|
||||||
|
const applicable_scope = ref([]);
|
||||||
|
// 显示状态字典选项列表
|
||||||
|
const display_status = ref([]);
|
||||||
|
|
||||||
|
// -业务方法
|
||||||
|
// 字典获取
|
||||||
|
async function getcoupon_type() {
|
||||||
|
await proxy.getDicts('coupon_type').then((res) => {
|
||||||
|
coupon_type.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 字典获取
|
||||||
|
async function getcoupon_expire_type() {
|
||||||
|
await proxy.getDicts('coupon_expire_type').then((res) => {
|
||||||
|
coupon_expire_type.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 字典获取
|
||||||
|
async function getapplicable_scope() {
|
||||||
|
await proxy.getDicts('applicable_scope').then((res) => {
|
||||||
|
applicable_scope.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 字典获取
|
||||||
|
async function getdisplay_status() {
|
||||||
|
await proxy.getDicts('display_status').then((res) => {
|
||||||
|
display_status.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 基础参数
|
||||||
|
const formRef = ref();
|
||||||
|
const labelWidth = 100;
|
||||||
|
const { proxy } = getCurrentInstance()
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: Boolean,
|
||||||
|
data: Object,
|
||||||
|
done: Function,
|
||||||
|
});
|
||||||
|
const emits = defineEmits(["update:modelValue"]);
|
||||||
|
|
||||||
|
|
||||||
|
// -基础方法
|
||||||
|
const closeDialog = () => {
|
||||||
|
emits("update:modelValue", false);
|
||||||
|
};
|
||||||
|
|
||||||
|
</script>
|
@ -0,0 +1,252 @@
|
|||||||
|
<!--
|
||||||
|
* @Descripttion: (优惠券/tb_coupon 编辑弹窗)
|
||||||
|
* @version: (1.0)
|
||||||
|
* @Author: (lwh)
|
||||||
|
* @Date: (2023-07-24)
|
||||||
|
* @LastEditors: (lwh)
|
||||||
|
* @LastEditTime: (2023-07-24)
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<el-dialog v-model="props.modelValue" title="修改优惠券信息" width="900px" @closed="closeDialog" @open="openDialog">
|
||||||
|
<el-form ref="formRef" :model="formData" :rules="rules">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="优惠劵名称" prop="couponName">
|
||||||
|
<el-input v-model="formData.couponName" placeholder="请输入优惠劵名称" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="优惠劵类型" prop="couponType">
|
||||||
|
<el-radio-group v-model="formData.couponType">
|
||||||
|
<el-radio v-for="item in coupon_type " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="减免金额" prop="couponDeductionMoney">
|
||||||
|
<el-input-number v-model.number="formData.couponDeductionMoney" controls-position="right" :min="0" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="折扣率" prop="couponDiscountRate">
|
||||||
|
<el-input-number v-model.number="formData.couponDiscountRate" controls-position="right" :min="0" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="最低消费金额" prop="couponMinConsumeMoney">
|
||||||
|
<el-input-number v-model.number="formData.couponMinConsumeMoney" controls-position="right" :min="0" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="到期类型" prop="couponExpireType">
|
||||||
|
<el-radio-group v-model="formData.couponExpireType">
|
||||||
|
<el-radio v-for="item in coupon_expire_type " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="有效天数" prop="couponEffectiveDays">
|
||||||
|
<el-input-number v-model.number="formData.couponEffectiveDays" controls-position="right" :min="0" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="固定时间-开始时间" prop="couponFixedStartTime">
|
||||||
|
<el-date-picker v-model="formData.couponFixedStartTime" type="datetime" :teleported="false" placeholder="选择日期时间"></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="固定时间-结束时间" prop="couponFixedEndTime">
|
||||||
|
<el-date-picker v-model="formData.couponFixedEndTime" type="datetime" :teleported="false" placeholder="选择日期时间"></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="适用范围" prop="couponApplicableScope">
|
||||||
|
<el-radio-group v-model="formData.couponApplicableScope">
|
||||||
|
<el-radio v-for="item in applicable_scope " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="适用范围配置(json)" prop="couponApplicableScopeConfig">
|
||||||
|
<el-input v-model="formData.couponApplicableScopeConfig" placeholder="请输入适用范围配置(json)" :disabled="true"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="发送数量(-1不限制)" prop="couponSendNumber">
|
||||||
|
<el-input-number v-model.number="formData.couponSendNumber" controls-position="right" :min="0" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="已领取数量" prop="couponGetNumber">
|
||||||
|
<el-input-number v-model.number="formData.couponGetNumber" controls-position="right" :min="0" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="显示状态" prop="couponDisplayStatus">
|
||||||
|
<el-radio-group v-model="formData.couponDisplayStatus">
|
||||||
|
<el-radio v-for="item in display_status " :key="item.dictValue" :label="parseInt(item.dictValue)">{{item.dictLabel}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :lg="12">
|
||||||
|
<el-form-item :label-width="labelWidth" label="排序" prop="couponSort">
|
||||||
|
<el-input-number v-model.number="formData.couponSort" controls-position="right" :min="0" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="handleEditClick(formRef)" :loading="loadingStatus">编辑</el-button>
|
||||||
|
<el-button @click="handleResetClick(formRef)">重置</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import modal from '@/plugins/modal.js'
|
||||||
|
import { reactive, ref, watch } from "vue";
|
||||||
|
import { addOrUpdateCoupon } from "@/api/business/Marketing/CouponManage/Coupons/coupon.js";
|
||||||
|
|
||||||
|
|
||||||
|
// 打开弹窗时回调
|
||||||
|
const openDialog = async () => {
|
||||||
|
await getcoupon_type()
|
||||||
|
await getcoupon_expire_type()
|
||||||
|
await getapplicable_scope()
|
||||||
|
await getdisplay_status()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = ref({
|
||||||
|
...props.data,
|
||||||
|
});
|
||||||
|
watch(props, async (v) => {
|
||||||
|
formData.value = v.data;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// 业务参数
|
||||||
|
// 优惠劵类型字典选项列表
|
||||||
|
const coupon_type = ref([]);
|
||||||
|
// 到期类型字典选项列表
|
||||||
|
const coupon_expire_type = ref([]);
|
||||||
|
// 适用范围字典选项列表
|
||||||
|
const applicable_scope = ref([]);
|
||||||
|
// 显示状态字典选项列表
|
||||||
|
const display_status = ref([]);
|
||||||
|
|
||||||
|
// -业务方法
|
||||||
|
//字典获取
|
||||||
|
async function getcoupon_type() {
|
||||||
|
await proxy.getDicts('coupon_type').then((res) => {
|
||||||
|
coupon_type.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//字典获取
|
||||||
|
async function getcoupon_expire_type() {
|
||||||
|
await proxy.getDicts('coupon_expire_type').then((res) => {
|
||||||
|
coupon_expire_type.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//字典获取
|
||||||
|
async function getapplicable_scope() {
|
||||||
|
await proxy.getDicts('applicable_scope').then((res) => {
|
||||||
|
applicable_scope.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//字典获取
|
||||||
|
async function getdisplay_status() {
|
||||||
|
await proxy.getDicts('display_status').then((res) => {
|
||||||
|
display_status.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -基础参数
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: Boolean,
|
||||||
|
data: Object,
|
||||||
|
done: Function,
|
||||||
|
});
|
||||||
|
|
||||||
|
const loadingStatus = ref(false)
|
||||||
|
const labelWidth = 100;
|
||||||
|
const formRef = ref();
|
||||||
|
const { proxy } = getCurrentInstance()
|
||||||
|
const emits = defineEmits(["update:modelValue"]);
|
||||||
|
const imgData = ref({
|
||||||
|
fileDir: "Coupon"
|
||||||
|
})
|
||||||
|
|
||||||
|
// 验证
|
||||||
|
const rules = reactive({
|
||||||
|
couponGuid: [{ required: true, message: "不能为空", trigger: "blur", type: "number" }],
|
||||||
|
couponName: [{ required: true, message: "优惠劵名称不能为空", trigger: "blur" }],
|
||||||
|
couponType: [{ required: true, message: "优惠劵类型不能为空", trigger: "blur", type: "number" }],
|
||||||
|
couponMinConsumeMoney: [{ required: true, message: "最低消费金额不能为空", trigger: "blur" }],
|
||||||
|
couponExpireType: [{ required: true, message: "到期类型不能为空", trigger: "blur", type: "number" }],
|
||||||
|
couponSendNumber: [{ required: true, message: "发送数量(-1不限制)不能为空", trigger: "blur", type: "number" }],
|
||||||
|
couponDisplayStatus: [{ required: true, message: "显示状态不能为空", trigger: "blur", type: "number" }],
|
||||||
|
couponSort: [{ required: true, message: "排序不能为空", trigger: "blur", type: "number" }],
|
||||||
|
});
|
||||||
|
|
||||||
|
// -基础方法
|
||||||
|
// 提交
|
||||||
|
const handleEditClick = async (formEl) => {
|
||||||
|
if (!formEl) return;
|
||||||
|
formEl.validate(async (valid) => {
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loadingStatus.value = true
|
||||||
|
|
||||||
|
|
||||||
|
const { code } = await addOrUpdateCoupon(formData.value);
|
||||||
|
if (code == 200) {
|
||||||
|
modal.msgSuccess('修改成功')
|
||||||
|
closeDialog();
|
||||||
|
loadingStatus.value = false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleResetClick = async (formEl) => {
|
||||||
|
if (!formEl) return;
|
||||||
|
formEl.resetFields();
|
||||||
|
}
|
||||||
|
const closeDialog = () => {
|
||||||
|
props.done();
|
||||||
|
emits("update:modelValue", false);
|
||||||
|
};
|
||||||
|
|
||||||
|
</script>
|
@ -0,0 +1,124 @@
|
|||||||
|
<!--
|
||||||
|
* @Descripttion: (优惠券/tb_coupon导入弹窗)
|
||||||
|
* @version: (1.0)
|
||||||
|
* @Author: (lwh)
|
||||||
|
* @Date: (2023-07-24)
|
||||||
|
* @LastEditors: (lwh)
|
||||||
|
* @LastEditTime: (2023-07-24)
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<el-dialog title="导入" v-model="props.modelValue" width="400px" @closed="closeDialog">
|
||||||
|
<el-upload
|
||||||
|
name="file"
|
||||||
|
ref="uploadRef"
|
||||||
|
:limit="1"
|
||||||
|
accept=".xlsx, .xls"
|
||||||
|
:headers="upload.headers"
|
||||||
|
:action="upload.url + '?updateSupport=' + upload.updateSupport"
|
||||||
|
:disabled="upload.isUploading"
|
||||||
|
:on-progress="handleFileUploadProgress"
|
||||||
|
:on-success="handleFileSuccess"
|
||||||
|
:auto-upload="false"
|
||||||
|
drag>
|
||||||
|
<el-icon class="el-icon--upload">
|
||||||
|
<upload-filled />
|
||||||
|
</el-icon>
|
||||||
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
|
<template #tip>
|
||||||
|
<div class="el-upload__tip text-center">
|
||||||
|
<div class="el-upload__tip">
|
||||||
|
<el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的优惠券
|
||||||
|
</div>
|
||||||
|
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||||
|
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-upload>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="closeDialog">取消</el-button>
|
||||||
|
<el-button type="primary" @click="submitFileForm">提交</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { reactive, ref, watch } from "vue";
|
||||||
|
import { ElMessage, ElMessageBox, ElNotification, ElLoading } from 'element-plus'
|
||||||
|
import { getToken } from '@/utils/auth'
|
||||||
|
|
||||||
|
|
||||||
|
// 业务参数
|
||||||
|
const formRef = ref();
|
||||||
|
const labelWidth = 100;
|
||||||
|
const { proxy } = getCurrentInstance()
|
||||||
|
let loadingInstance;
|
||||||
|
let uploadRef = ref()
|
||||||
|
|
||||||
|
/*** 导入参数 */
|
||||||
|
const upload = reactive({
|
||||||
|
// 是否禁用上传
|
||||||
|
isUploading: false,
|
||||||
|
// 是否更新已经存在的数据
|
||||||
|
updateSupport: false,
|
||||||
|
// 设置上传的请求头部
|
||||||
|
headers: { Authorization: 'Bearer ' + getToken() },
|
||||||
|
// 上传的地址
|
||||||
|
url: import.meta.env.VITE_APP_BASE_API + '/business/coupon/importData',
|
||||||
|
})
|
||||||
|
|
||||||
|
// 打开遮罩层
|
||||||
|
function loading(content) {
|
||||||
|
loadingInstance = ElLoading.service({
|
||||||
|
lock: true,
|
||||||
|
text: content,
|
||||||
|
background: "rgba(0, 0, 0, 0.7)",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 关闭遮罩层
|
||||||
|
function closeLoading() {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// -业务方法
|
||||||
|
/** 下载模板操作 */
|
||||||
|
function importTemplate() {
|
||||||
|
proxy.download('/business/coupon/importTemplate', '优惠券数据导入模板')
|
||||||
|
}
|
||||||
|
/**文件上传中处理 */
|
||||||
|
const handleFileUploadProgress = (event, file, fileList) => {
|
||||||
|
upload.isUploading = true
|
||||||
|
loading('正在导入数据,请稍候...')
|
||||||
|
}
|
||||||
|
/** 文件上传成功处理 */
|
||||||
|
const handleFileSuccess = (response, file, fileList) => {
|
||||||
|
closeLoading();
|
||||||
|
closeDialog()
|
||||||
|
upload.isUploading = false
|
||||||
|
uploadRef.value.clearFiles()
|
||||||
|
ElMessageBox.alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.data + '</div>', '导入结果', {
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
})
|
||||||
|
props.done()
|
||||||
|
}
|
||||||
|
/** 提交上传文件 */
|
||||||
|
function submitFileForm() {
|
||||||
|
uploadRef.value.submit()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -基础参数
|
||||||
|
const emits = defineEmits(["update:modelValue"]);
|
||||||
|
const dialogVisible = ref(props.modelValue);
|
||||||
|
const formData = reactive({});
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: Boolean,
|
||||||
|
done: Function,
|
||||||
|
});
|
||||||
|
|
||||||
|
// -基础方法
|
||||||
|
const closeDialog = () => {
|
||||||
|
dialogVisible.value = false;
|
||||||
|
emits("update:modelValue", false);
|
||||||
|
};
|
||||||
|
</script>
|
299
src/views/business/Marketing/CouponManage/Coupons/index.vue
Normal file
299
src/views/business/Marketing/CouponManage/Coupons/index.vue
Normal file
@ -0,0 +1,299 @@
|
|||||||
|
<!--
|
||||||
|
* @Descripttion: (优惠券/tb_coupon)
|
||||||
|
* @version: (1.0)
|
||||||
|
* @Author: (lwh)
|
||||||
|
* @Date: (2023-07-24)
|
||||||
|
* @LastEditors: (lwh)
|
||||||
|
* @LastEditTime: (2023-07-24)
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-row :gutter="24">
|
||||||
|
<!-- 搜索框 queryParams.需要搜索的字段 -->
|
||||||
|
<el-form :model="queryParams" label-position="left" style="margin:15px;" inline ref="queryForm" v-show="showSearch"
|
||||||
|
@submit.prevent>
|
||||||
|
<el-form-item label="优惠劵名称" prop="couponName">
|
||||||
|
<el-input v-model="queryParams.couponName" placeholder="请输入优惠劵名称" clearable @keyup.enter="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="优惠劵类型" prop="couponType">
|
||||||
|
<el-select v-model="queryParams.couponType" placeholder="请选择优惠劵类型" clearable @change="handleQuery">
|
||||||
|
<el-option v-for="item in coupon_type " :key="item.dictValue" :label="item.dictLabel"
|
||||||
|
:value="item.dictValue"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="显示状态" prop="couponDisplayStatus">
|
||||||
|
<el-radio-group v-model="queryParams.couponDisplayStatus">
|
||||||
|
<el-radio v-for="item in display_status " :key="item.dictValue"
|
||||||
|
:label="item.dictValue">{{ item.dictLabel }}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button icon="search" type="primary" @click="handleQuery">{{ $t('btn.search') }}</el-button>
|
||||||
|
<el-button icon="refresh" @click="resetQuery">{{ $t('btn.reset') }}</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 工具按钮 -->
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" v-hasPermi="['business:coupon:addOrUpdate']" plain icon="plus"
|
||||||
|
@click="AddDialogVisible = true">
|
||||||
|
{{ $t('btn.add') }}
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="danger" :disabled="multiple" v-hasPermi="['business:coupon:delete']" plain icon="delete"
|
||||||
|
@click="handleDelete">
|
||||||
|
{{ $t('btn.delete') }}
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" plain icon="Upload" @click="UploadDialogVisible = true"
|
||||||
|
v-hasPermi="['business:coupon:import']">导入</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="warning" plain icon="download" @click="handleExport" v-hasPermi="['business:coupon:export']">
|
||||||
|
{{ $t('btn.export') }}
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 表格渲染 prop="对应的字段"-->
|
||||||
|
<el-table v-loading="loading" :data="dataList" ref="tableRef" border highlight-current-row
|
||||||
|
@selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="50" align="center" />
|
||||||
|
|
||||||
|
<el-table-column prop="couponName" label="优惠劵名称" align="center" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column prop="couponType" label="优惠劵类型" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :options="coupon_type" :value="scope.row.couponType" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="couponDeductionMoney" label="减免金额" align="center" />
|
||||||
|
<el-table-column prop="couponDiscountRate" label="折扣率" align="center" />
|
||||||
|
<el-table-column prop="couponMinConsumeMoney" label="最低消费金额" align="center" />
|
||||||
|
<el-table-column prop="couponExpireType" label="到期类型" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :options="coupon_expire_type" :value="scope.row.couponExpireType" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="couponEffectiveDays" label="有效天数" align="center" />
|
||||||
|
<el-table-column prop="couponFixedStartTime" label="固定时间-开始时间" align="center" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column prop="couponFixedEndTime" label="固定时间-结束时间" align="center" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column prop="couponApplicableScope" label="适用范围" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :options="applicable_scope" :value="scope.row.couponApplicableScope" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="couponSendNumber" label="发送数量(-1不限制)" align="center" />
|
||||||
|
<el-table-column prop="couponDisplayStatus" label="显示状态" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :options="display_status" :value="scope.row.couponDisplayStatus" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="couponSort" label="排序" align="center" sortable />
|
||||||
|
|
||||||
|
<el-table-column label="操作" width="350" fixed="right">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button type="primary" size="small" icon="edit" @click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['business:coupon:addOrUpdate']">编辑</el-button>
|
||||||
|
<el-button type="danger" size="small" icon="delete" @click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['business:coupon:delete']">删除</el-button>
|
||||||
|
<el-button size="small" icon="view" @click="handleDetail(scope.row)">查看</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
</el-table>
|
||||||
|
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 添加 -->
|
||||||
|
<AddDialog v-model="AddDialogVisible" :done="() => resetQuery()"></AddDialog>
|
||||||
|
<!-- 编辑 -->
|
||||||
|
<EditDialog v-model="EditDialogVisible" :data="EditDialogRow" :done="() => resetQuery()"></EditDialog>
|
||||||
|
<!-- 详情 -->
|
||||||
|
<DetailDialog v-model="DetailDialogVisible" :data="DetailDialogRow" :done="() => resetQuery()"></DetailDialog>
|
||||||
|
<!-- 导入 -->
|
||||||
|
<UploadDialog v-model="UploadDialogVisible" :done="() => resetQuery()"></UploadDialog>
|
||||||
|
</template>
|
||||||
|
<script setup name="coupon">
|
||||||
|
import { ElMessageBox } from 'element-plus'
|
||||||
|
import modal from '@/plugins/modal.js'
|
||||||
|
import { exportCoupon, couponList, delCoupon } from '@/api/business/Marketing/CouponManage/Coupons/coupon.js'
|
||||||
|
import AddDialog from "./components/AddDialog.vue";
|
||||||
|
import EditDialog from "./components/EditDialog.vue";
|
||||||
|
import DetailDialog from "./components/DetailDialog.vue";
|
||||||
|
import UploadDialog from "./components/UploadDialog.vue";
|
||||||
|
|
||||||
|
const AddDialogVisible = ref(false);
|
||||||
|
const EditDialogVisible = ref(false);
|
||||||
|
const EditDialogRow = ref({});
|
||||||
|
const DetailDialogVisible = ref(false);
|
||||||
|
const DetailDialogRow = ref({});
|
||||||
|
const UploadDialogVisible = ref(false);
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance()
|
||||||
|
|
||||||
|
// 选中categoryId数组数组
|
||||||
|
const ids = ref([])
|
||||||
|
// 非单选禁用
|
||||||
|
const single = ref(true)
|
||||||
|
// 非多个禁用
|
||||||
|
const multiple = ref(true)
|
||||||
|
// 显示搜索条件
|
||||||
|
const showSearch = ref(true)
|
||||||
|
// 数据列表
|
||||||
|
const dataList = ref([])
|
||||||
|
// 总记录数
|
||||||
|
const total = ref(0)
|
||||||
|
// 是否加载
|
||||||
|
const loading = ref(true)
|
||||||
|
|
||||||
|
const data = reactive({
|
||||||
|
form: {},
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const { queryParams } = toRefs(data)
|
||||||
|
|
||||||
|
// 业务参数
|
||||||
|
|
||||||
|
|
||||||
|
// 业务方法
|
||||||
|
|
||||||
|
// 字典获取
|
||||||
|
const coupon_type = ref([]);
|
||||||
|
async function getcoupon_type() {
|
||||||
|
await proxy.getDicts('coupon_type').then((res) => {
|
||||||
|
coupon_type.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getcoupon_type()
|
||||||
|
// 字典获取
|
||||||
|
const coupon_expire_type = ref([]);
|
||||||
|
async function getcoupon_expire_type() {
|
||||||
|
await proxy.getDicts('coupon_expire_type').then((res) => {
|
||||||
|
coupon_expire_type.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getcoupon_expire_type()
|
||||||
|
// 字典获取
|
||||||
|
const applicable_scope = ref([]);
|
||||||
|
async function getapplicable_scope() {
|
||||||
|
await proxy.getDicts('applicable_scope').then((res) => {
|
||||||
|
applicable_scope.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getapplicable_scope()
|
||||||
|
// 字典获取
|
||||||
|
const display_status = ref([]);
|
||||||
|
async function getdisplay_status() {
|
||||||
|
await proxy.getDicts('display_status').then((res) => {
|
||||||
|
display_status.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getdisplay_status()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//基础方法
|
||||||
|
|
||||||
|
// 查询数据
|
||||||
|
function getList() {
|
||||||
|
loading.value = true
|
||||||
|
|
||||||
|
|
||||||
|
couponList(queryParams.value).then((res) => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
loading.value = false;
|
||||||
|
dataList.value = res.data.result;
|
||||||
|
total.value = res.data.totalNum;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 多选框选中数据
|
||||||
|
function handleSelectionChange(selection) {
|
||||||
|
ids.value = selection.map((item) => item.couponId)
|
||||||
|
single.value = selection.length != 1
|
||||||
|
multiple.value = !selection.length
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置查询操作 */
|
||||||
|
function resetQuery() {
|
||||||
|
proxy.resetForm('queryForm')
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
function handleQuery() {
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
function handleDelete(row) {
|
||||||
|
const Ids = row.couponId || ids.value
|
||||||
|
|
||||||
|
ElMessageBox.confirm("是否确认删除?", "系统提示", {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: "warning",
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
return delCoupon(Ids)
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
handleQuery()
|
||||||
|
modal.msgSuccess("删除成功")
|
||||||
|
})
|
||||||
|
.catch(() => { })
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
function handleExport(row) {
|
||||||
|
const Ids = row.couponId || ids.value
|
||||||
|
const name = ref("所有")
|
||||||
|
|
||||||
|
if (Ids.length != 0) {
|
||||||
|
let str = ''
|
||||||
|
for (const key in Ids) {
|
||||||
|
str += Ids[key] + ','
|
||||||
|
}
|
||||||
|
str = str.slice(0, str.length - 1)
|
||||||
|
queryParams.value.ids = str
|
||||||
|
name.value = "选中"
|
||||||
|
}
|
||||||
|
|
||||||
|
ElMessageBox.confirm('是否确认导出' + name.value + '数据?', '警告', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
return exportCoupon(queryParams.value)
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
proxy.download(response.data.path)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
function handleUpdate(row) {
|
||||||
|
EditDialogVisible.value = true
|
||||||
|
EditDialogRow.value = row
|
||||||
|
}
|
||||||
|
|
||||||
|
// 详情
|
||||||
|
function handleDetail(row) {
|
||||||
|
DetailDialogVisible.value = true
|
||||||
|
DetailDialogRow.value = row
|
||||||
|
}
|
||||||
|
|
||||||
|
handleQuery()
|
||||||
|
</script>
|
@ -15,6 +15,7 @@
|
|||||||
<!-- 表格渲染 prop="对应的字段"-->
|
<!-- 表格渲染 prop="对应的字段"-->
|
||||||
<el-table v-loading="loading" :data="goodssList" ref="tableRef" border highlight-current-row
|
<el-table v-loading="loading" :data="goodssList" ref="tableRef" border highlight-current-row
|
||||||
@row-click="handleRowClick">
|
@row-click="handleRowClick">
|
||||||
|
<el-table-column type="selection" width="50" align="center" />
|
||||||
<el-table-column prop="goodsPicture" width="150" label="图片" align="center">
|
<el-table-column prop="goodsPicture" width="150" label="图片" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-image preview-teleported :hide-on-click-modal="true" lazy class="table-td-thumb" fit="contain"
|
<el-image preview-teleported :hide-on-click-modal="true" lazy class="table-td-thumb" fit="contain"
|
||||||
@ -25,7 +26,9 @@
|
|||||||
</el-image>
|
</el-image>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="goodsName" label="商品名称" align="left" :show-overflow-tooltip="true" />
|
<el-table-column prop="goodsName" width="450" label="商品名称" align="left" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column prop="goodsPriceLowest" label="价格" align="center" />
|
||||||
|
<el-table-column prop="goodsTotalInventory" label="库存总量" align="center" />
|
||||||
|
|
||||||
</el-table>
|
</el-table>
|
||||||
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
|
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
|
||||||
@ -72,7 +75,7 @@ const formData = ref({
|
|||||||
const goodssList = ref([]);
|
const goodssList = ref([]);
|
||||||
// 打开窗口时运行
|
// 打开窗口时运行
|
||||||
const openDialog = async () => {
|
const openDialog = async () => {
|
||||||
|
|
||||||
|
|
||||||
await getgoodsListFun()
|
await getgoodsListFun()
|
||||||
}
|
}
|
||||||
@ -94,7 +97,7 @@ const getgoodsListFun = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
watch(props, (v) => {
|
watch(props, (v) => {
|
||||||
if(v.data.shopGuid){
|
if (v.data.shopGuid) {
|
||||||
queryParams.shopGuid = v.data.shopGuid
|
queryParams.shopGuid = v.data.shopGuid
|
||||||
}
|
}
|
||||||
formData.value = v.data;
|
formData.value = v.data;
|
||||||
|
135
src/views/business/components/ChooseMultipleGoodsDialog.vue
Normal file
135
src/views/business/components/ChooseMultipleGoodsDialog.vue
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog v-model="props.modelValue" title="选择商品" width="900px" @closed="closeDialog" @open="openDialog">
|
||||||
|
|
||||||
|
<el-form inline :model="queryParams">
|
||||||
|
<el-form-item label="商品名称">
|
||||||
|
<el-input v-model='queryParams.goodsName' placeholder='请输入商品名称'></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="handleQuery">
|
||||||
|
搜索
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<!-- 表格渲染 prop="对应的字段"-->
|
||||||
|
<el-table v-loading="loading" :data="goodssList" ref="tableRef" border highlight-current-row
|
||||||
|
@row-click="handleRowClick">
|
||||||
|
<el-table-column type="selection" width="50" align="center" />
|
||||||
|
<el-table-column prop="goodsPicture" width="150" label="图片" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-image preview-teleported :hide-on-click-modal="true" lazy class="table-td-thumb" fit="contain"
|
||||||
|
:src="scope.row.goodsPicture?.split(',')[0]" :preview-src-list="scope.row.goodsPicture?.split(',')">
|
||||||
|
<div><el-icon :size="15">
|
||||||
|
<document />
|
||||||
|
</el-icon></div>
|
||||||
|
</el-image>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="goodsName" width="450" label="商品名称" align="left" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column prop="goodsPriceLowest" label="价格" align="center" />
|
||||||
|
<el-table-column prop="goodsTotalInventory" label="库存总量" align="center" />
|
||||||
|
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="handleEditClick()">添加</el-button>
|
||||||
|
<el-button @click="handleResetClick()">重置</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { reactive, ref, watch, nextTick } from 'vue';
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { allGoodsList } from '@/api/business/GoodsManager/Goodss/goods.js'
|
||||||
|
|
||||||
|
// 业务参数
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
|
// 基础参数
|
||||||
|
const tableRef = ref(null);
|
||||||
|
// 查询参数
|
||||||
|
const queryParams = reactive({
|
||||||
|
goodsName: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
const emits = defineEmits(['update:modelValue']);
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: Boolean,
|
||||||
|
data: Object,
|
||||||
|
// done: Function,
|
||||||
|
});
|
||||||
|
const formData = ref({
|
||||||
|
...props.data
|
||||||
|
});
|
||||||
|
|
||||||
|
const goodssList = ref([]);
|
||||||
|
// 打开窗口时运行
|
||||||
|
const openDialog = async () => {
|
||||||
|
|
||||||
|
|
||||||
|
await getgoodsListFun()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
function handleQuery() {
|
||||||
|
getgoodsListFun()
|
||||||
|
}
|
||||||
|
|
||||||
|
const getgoodsListFun = async () => {
|
||||||
|
loading.value = true
|
||||||
|
await allGoodsList(queryParams).then((res) => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
goodssList.value = res.data
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(props, (v) => {
|
||||||
|
formData.value = v.data;
|
||||||
|
});
|
||||||
|
|
||||||
|
// -业务方法
|
||||||
|
let goodsName = ref("");
|
||||||
|
let goodsGuid = ref("");
|
||||||
|
|
||||||
|
|
||||||
|
// -基础方法
|
||||||
|
|
||||||
|
// 点击行
|
||||||
|
const handleRowClick = (row) => {
|
||||||
|
goodsName.value = row.goodsName
|
||||||
|
goodsGuid.value = row.goodsGuid
|
||||||
|
}
|
||||||
|
|
||||||
|
const closeDialog = () => {
|
||||||
|
queryParams.goodsName = ""
|
||||||
|
goodsName.value = ""
|
||||||
|
emits('update:modelValue', false);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 提交
|
||||||
|
const handleEditClick = async () => {
|
||||||
|
if (goodsName.value !== "") {
|
||||||
|
|
||||||
|
formData.value.goodsName = goodsName.value
|
||||||
|
formData.value.goodsGuid = goodsGuid.value
|
||||||
|
if (formData.value.goodsName != null) {
|
||||||
|
// props.done();
|
||||||
|
closeDialog();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ElMessage.error("请选择商品")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleResetClick = async formEl => {
|
||||||
|
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user