Merge branch 'ymf_test' of https://e.coding.net/g-cphe0354/yinshoukeguanliduan/management into ymf
This commit is contained in:
commit
8318b9ed80
|
|
@ -417,6 +417,17 @@ export function modityActivate(data) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增、修改活动 新的!
|
||||
* @returns
|
||||
*/
|
||||
export function storageupActivate(data) {
|
||||
return request({
|
||||
url: `/shop/storage/upActivate`,
|
||||
method: "post",
|
||||
data
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 活动列表
|
||||
* @returns
|
||||
|
|
|
|||
|
|
@ -0,0 +1,175 @@
|
|||
<template>
|
||||
<el-dialog title="选择优惠劵" top="5vh" :visible.sync="dialogVisible">
|
||||
<div class="head-container">
|
||||
<el-table ref="table" :data="tableData.list" height="500" v-loading="tableData.loading">
|
||||
<!-- <el-table-column type="selection" width="55" align="center" v-if="!radio"></el-table-column> -->
|
||||
<el-table-column label="名称" prop="title" />
|
||||
<el-table-column label="使用门槛">
|
||||
<template v-slot="scope">
|
||||
{{ `满${scope.row.fullAmount}${scope.row.discountAmount ? '减' + scope.row.discountAmount + '元' :
|
||||
''}` }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="总发放数量" prop="number" />
|
||||
<el-table-column label="已使用" prop="useNumber" />
|
||||
<el-table-column label="剩余" prop="leftNumber" />
|
||||
<el-table-column label="操作">
|
||||
<template v-slot="scope">
|
||||
<el-button type="primary" @click="selectHandle(scope.row)">选择</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<el-pagination :total="tableData.total" :current-page="tableData.page + 1" :page-size="tableData.size"
|
||||
@current-change="paginationChange" @size-change="sizeChange"
|
||||
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
|
||||
<span slot="footer" class="dialog-footer" v-if="!radio">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="confirmHandle">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getTbShopCoupon, delTbShopCoupon } from '@/api/coupon'
|
||||
export default {
|
||||
props: {
|
||||
// 是否为单选
|
||||
radio: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
searhForm: {
|
||||
name: '',
|
||||
category: ''
|
||||
},
|
||||
categoryList: [],
|
||||
tableData: {
|
||||
page: 0,
|
||||
size: 10,
|
||||
total: 0,
|
||||
loading: false,
|
||||
list: []
|
||||
},
|
||||
goods: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 单选商品
|
||||
selectHandle(row) {
|
||||
this.$emit('success', [{ ...row }])
|
||||
this.close()
|
||||
},
|
||||
// 确定选商品
|
||||
confirmHandle() {
|
||||
let res = this.$refs.table.selection
|
||||
this.$emit('success', res)
|
||||
this.close()
|
||||
},
|
||||
// 重置查询
|
||||
resetHandle() {
|
||||
this.searhForm.name = ''
|
||||
this.searhForm.category = ''
|
||||
this.tableData.page = 0
|
||||
this.tableData.size = 10
|
||||
this.tableData.list = []
|
||||
this.getTableData()
|
||||
},
|
||||
// 分页大小改变
|
||||
sizeChange(e) {
|
||||
this.tableData.size = e
|
||||
this.getTableData()
|
||||
},
|
||||
// 分页回调
|
||||
paginationChange(e) {
|
||||
this.tableData.page = e - 1
|
||||
this.getTableData()
|
||||
},
|
||||
// 商品列表
|
||||
async getTableData() {
|
||||
this.tableData.loading = true
|
||||
try {
|
||||
const res = await getTbShopCoupon({
|
||||
page: this.tableData.page,
|
||||
size: this.tableData.size,
|
||||
name: this.searhForm.name,
|
||||
categoryId: this.searhForm.category,
|
||||
shopId: localStorage.getItem('shopId'),
|
||||
sort: 'id',
|
||||
})
|
||||
this.tableData.list = res.content
|
||||
this.tableData.total = res.totalElements
|
||||
|
||||
if (this.goods.length) {
|
||||
this.$nextTick(() => {
|
||||
this.selection()
|
||||
})
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.tableData.loading = false
|
||||
}, 500);
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
// 商品分类
|
||||
async tbShopCategoryGet() {
|
||||
try {
|
||||
const res = await getTbShopCoupon({
|
||||
page: 0,
|
||||
size: 100,
|
||||
sort: 'id',
|
||||
shopId: localStorage.getItem('shopId')
|
||||
})
|
||||
this.categoryList = res.content
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
async show(goods, categoryId) {
|
||||
this.dialogVisible = true
|
||||
if (goods && goods.length) {
|
||||
this.goods = goods
|
||||
} else {
|
||||
this.goods = []
|
||||
}
|
||||
this.resetHandle()
|
||||
|
||||
console.log(categoryId);
|
||||
|
||||
if (categoryId) {
|
||||
this.searhForm.category = categoryId
|
||||
}
|
||||
|
||||
console.log(this.searhForm);
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false
|
||||
},
|
||||
selection() {
|
||||
this.goods.forEach(row => {
|
||||
this.tableData.list.forEach((item, index) => {
|
||||
if (row.id == item.id) {
|
||||
this.$refs.table.toggleRowSelection(this.tableData.list[index]);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.shop_info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
span {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
<el-input v-model="searhForm.name" placeholder="商品名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-select v-model="searhForm.category" placeholder="商品分类">
|
||||
<el-select v-model="searhForm.category" placeholder="商品分类" :disabled="disableCategory">
|
||||
<el-option :label="item.name" :value="item.id" v-for="item in categoryList"
|
||||
:key="item.id"></el-option>
|
||||
</el-select>
|
||||
|
|
@ -75,6 +75,11 @@
|
|||
import { tbShopCategoryGet, tbProduct } from "@/api/shop";
|
||||
export default {
|
||||
props: {
|
||||
// 是否禁用分类
|
||||
disableCategory: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// 是否为单选
|
||||
radio: {
|
||||
type: Boolean,
|
||||
|
|
|
|||
|
|
@ -80,6 +80,9 @@
|
|||
<el-button type="primary" @click="addRewardHandle('rewardCoupons')">添加券</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item prop="rewardCoupons">
|
||||
<div>
|
||||
<div class="tips">奖励券不受优惠券发放数量影响</div>
|
||||
</div>
|
||||
<el-table :data="form.rewardCoupons" border style="width: 600px;">
|
||||
<el-table-column label="券ID" prop="couponId"></el-table-column>
|
||||
<el-table-column label="名称" prop="couponName"></el-table-column>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,444 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="140px" label-position="left">
|
||||
<el-form-item label="分享标题" prop="title">
|
||||
<el-input v-model="form.title" style="width: 500px;" placeholder="例如:邀请1人可得,双方各得10元优惠券"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="分享封面" prop="shareImg">
|
||||
<div class="img_list">
|
||||
<div class="item" v-if="form.shareImg">
|
||||
<el-image :src="form.shareImg" style="width: 100%;height: 100%" :preview-src-list="urlList" />
|
||||
<div class="del" @click.stop="form.shareImg = ''">删除</div>
|
||||
</div>
|
||||
<div class="item upload" @click="formImgKey = 'shareImg'; $refs.addImg.show()" v-else>
|
||||
<i class="icon el-icon-plus"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tips">建议尺寸:630*504</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="演示">
|
||||
<div class="preview_wrap">
|
||||
<div class="message_wrap">
|
||||
<div class="msg">
|
||||
<div class="content">
|
||||
<div class="name">
|
||||
<img class="logo" :src="shopInfo.logo">
|
||||
<span class="t">{{ shopInfo.name }}</span>
|
||||
</div>
|
||||
<div class="title">{{ form.title }}</div>
|
||||
<el-image :src="form.shareImg" style="width: 100%;height: 110px;" fit="cover">
|
||||
<div slot="error" class="image-slot">
|
||||
<i class="el-icon-folder-delete"></i>
|
||||
</div>
|
||||
</el-image>
|
||||
<div class="btm">
|
||||
<i class="icon el-icon-link"></i>
|
||||
小程序
|
||||
</div>
|
||||
</div>
|
||||
<img class="avatar" src="@/assets/images/avatar.png">
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<i class="icon el-icon-microphone"></i>
|
||||
<div class="ipt"></div>
|
||||
<i class="icon el-icon-picture-outline-round"></i>
|
||||
<i class="icon el-icon-circle-plus-outline"></i>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="loading" @click="onSubmitHandle">保存</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<addImg ref="addImg" @successEvent="e => form[formImgKey] = e[0].url" />
|
||||
<AddCoupon ref="AddCoupon" @success="addCouponSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { byShopId, tbShopShare } from '@/api/inviteFirend.js'
|
||||
import addImg from "@/views/product/components/addImages.vue";
|
||||
import AddCoupon from './addCoupon.vue'
|
||||
export default {
|
||||
components: { addImg, AddCoupon },
|
||||
data() {
|
||||
const imgValidate1 = (rule, value, callback) => {
|
||||
if (!this.form.shareImg) {
|
||||
callback(new Error("请上传分享封面图"));
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const imgValidate2 = (rule, value, callback) => {
|
||||
if (!this.form.invitedImg) {
|
||||
callback(new Error("请上传邀请顶部图"));
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const imgValidate3 = (rule, value, callback) => {
|
||||
if (!this.form.beInvitedImg) {
|
||||
callback(new Error("请上传被邀顶部图"));
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const startTimeValidate = (rule, value, callback) => {
|
||||
if (!this.form.startTime) {
|
||||
callback(new Error("请选择活动日期"));
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const newCouponsValidate = (rule, value, callback) => {
|
||||
if (!this.form.newCoupons.length) {
|
||||
callback(new Error("请添加新用户获得券"));
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const rewardCouponsValidate = (rule, value, callback) => {
|
||||
if (!this.form.rewardCoupons.length) {
|
||||
callback(new Error("请添加奖励券"));
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
return {
|
||||
loading: false,
|
||||
createdAt: [],
|
||||
formImgKey: '',
|
||||
couponKey: '',
|
||||
tableType: '1', // 1添加 2编辑
|
||||
tableEditorIndex: 0, // 编辑时的index
|
||||
shopInfo: {
|
||||
name: localStorage.getItem('shopName'),
|
||||
logo: localStorage.getItem('logo')
|
||||
},
|
||||
form: {
|
||||
status: 1,
|
||||
title: '',
|
||||
shareImg: '',
|
||||
invitedImg: '',
|
||||
beInvitedImg: '',
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
newCoupons: [],
|
||||
invitedNum: '1',
|
||||
rewardCoupons: [],
|
||||
getMethod: 'get'
|
||||
},
|
||||
rules: {
|
||||
title: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入标题',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
shareImg: [
|
||||
{
|
||||
required: true,
|
||||
validator: imgValidate1,
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
invitedImg: [
|
||||
{
|
||||
required: true,
|
||||
validator: imgValidate2,
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
beInvitedImg: [
|
||||
{
|
||||
required: true,
|
||||
validator: imgValidate3,
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
startTime: [
|
||||
{
|
||||
required: true,
|
||||
validator: startTimeValidate,
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
newCoupons: [
|
||||
{
|
||||
required: true,
|
||||
validator: newCouponsValidate,
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
invitedNum: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入邀请人数',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
rewardCoupons: [
|
||||
{
|
||||
required: true,
|
||||
validator: rewardCouponsValidate,
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
},
|
||||
urlList: []
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.byShopId()
|
||||
},
|
||||
methods: {
|
||||
// 添加完成优惠券
|
||||
addCouponSuccess(e) {
|
||||
if (this.tableType == 1) {
|
||||
this.form[this.couponKey].push({ ...e })
|
||||
} else {
|
||||
// this.form[this.couponKey][this.tableEditorIndex] = { ...e }
|
||||
this.$set(this.form[this.couponKey], this.tableEditorIndex, { ...e })
|
||||
}
|
||||
},
|
||||
// 添加奖励券
|
||||
addRewardHandle(key, type = 1, row = {}, index = 0) {
|
||||
this.tableEditorIndex = index
|
||||
this.tableType = type
|
||||
this.couponKey = key
|
||||
if (key == 'rewardCoupons' && !this.form.invitedNum) {
|
||||
this.$refs.form.validateField('invitedNum')
|
||||
return
|
||||
}
|
||||
this.$refs.AddCoupon.show(row)
|
||||
},
|
||||
// 日期回调
|
||||
timeChange(e) {
|
||||
this.form.startTime = e[0]
|
||||
this.form.endTime = e[1]
|
||||
},
|
||||
// 过滤input只能输入整数
|
||||
inputFilterInt(e, key) {
|
||||
if (!e) return
|
||||
setTimeout(() => {
|
||||
this.form[key] = e.replace(/[^\d]/g, '')
|
||||
}, 50)
|
||||
},
|
||||
// 提交
|
||||
onSubmitHandle() {
|
||||
this.$refs.form.validate(async valid => {
|
||||
if (valid) {
|
||||
try {
|
||||
this.loading = true
|
||||
this.form.shopId = localStorage.getItem('shopId')
|
||||
await tbShopShare(this.form)
|
||||
this.loading = false
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: `保存成功`,
|
||||
type: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
this.loading = false
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// 获取店铺设置
|
||||
async byShopId() {
|
||||
try {
|
||||
const res = await byShopId()
|
||||
if (res.id) {
|
||||
this.form = res
|
||||
this.createdAt = [res.startTime, res.endTime]
|
||||
this.urlList = [res.shareImg, res.invitedImg, res.beInvitedImg]
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.img_list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
|
||||
.item {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: #F5F7FA;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
&.upload {
|
||||
border: 1px dashed #ddd;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
|
||||
.del {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.del {
|
||||
width: 100%;
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(255, 0, 0, 0.6);
|
||||
backdrop-filter: blur(3px);
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
transform: translateY(100%);
|
||||
transition: all .2s ease-in-out;
|
||||
}
|
||||
|
||||
.img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.icon {
|
||||
font-size: 20px;
|
||||
color: #ddd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.preview_wrap {
|
||||
width: 300px;
|
||||
height: 368px;
|
||||
background-color: #EDEDED;
|
||||
position: relative;
|
||||
padding: 20px 10px;
|
||||
|
||||
.message_wrap {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
.msg {
|
||||
display: flex;
|
||||
|
||||
.content {
|
||||
width: 180px;
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
padding: 10px 10px 6px;
|
||||
position: relative;
|
||||
|
||||
&::before {
|
||||
$size: 8px;
|
||||
content: "";
|
||||
width: $size;
|
||||
height: $size;
|
||||
border-radius: 1px;
|
||||
background-color: #fff;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: $size / 2 * -1;
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 10px;
|
||||
|
||||
.logo {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.t {
|
||||
font-size: 10px;
|
||||
color: #999;
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.btm {
|
||||
font-size: 10px;
|
||||
color: #999;
|
||||
line-height: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-top: 1px solid #ececec;
|
||||
padding-top: 6px;
|
||||
|
||||
.icon {
|
||||
font-size: 14px;
|
||||
color: rgb(87, 87, 253);
|
||||
margin-right: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
background-color: #F6F6F6;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 10px;
|
||||
gap: 10px;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 40px;
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
width: 100px;
|
||||
height: 4px;
|
||||
border-radius: 4px;
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
left: 50%;
|
||||
margin-left: -50px;
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
.ipt {
|
||||
flex: 1;
|
||||
height: 30px;
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.icon {
|
||||
font-size: 22px;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -6,17 +6,20 @@
|
|||
<el-tab-pane label="邀请记录" name="3"></el-tab-pane>
|
||||
</el-tabs>
|
||||
<Setting v-if="activeName == 1" />
|
||||
<Share v-if="activeName == 2" />
|
||||
<Record v-if="activeName == 3" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Setting from './components/invite_friend/setting.vue'
|
||||
import Share from './components/invite_friend/share.vue'
|
||||
import Record from './components/invite_friend/record.vue'
|
||||
export default {
|
||||
name: 'invite_friend',
|
||||
components: {
|
||||
Setting,
|
||||
Share,
|
||||
Record
|
||||
},
|
||||
data() {
|
||||
|
|
|
|||
|
|
@ -6,29 +6,35 @@
|
|||
</div>
|
||||
<!-- 优惠券 -->
|
||||
<div v-if="form.type == 1" class="content">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="left">
|
||||
<el-form-item label="优惠券券名" prop="title">
|
||||
<el-form ref="form" :inline="true" :model="form" :rules="rules" label-width="120px" label-position="left">
|
||||
<el-form-item label="优惠券券名" prop="title" style="width: 100%;">
|
||||
<el-input v-model="form.title" placeholder="" style="width: 289px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="使用门槛">
|
||||
<el-input v-model="form.fullAmount" type="number" placeholder="" style="width: 180px;margin-right: 66px;">
|
||||
<el-form-item v-if="form.type == 1" label="使用门槛" prop="fullAmount">
|
||||
<el-input v-model="form.fullAmount" oninput="value= value.replace(/[^\d|\.]/g, '')" placeholder="" style="width: 180px;margin-right: 66px;">
|
||||
<template slot="prepend">满</template>
|
||||
<template slot="append">元</template>
|
||||
</el-input>
|
||||
<el-input v-model="form.discountAmount" type="number" placeholder="" style="width: 180px;">
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.type == 1" label="" prop="discountAmount">
|
||||
<el-input v-model="form.discountAmount" oninput="value= value.replace(/[^\d|\.]/g, '')" placeholder="" style="width: 180px;">
|
||||
<template slot="prepend">减</template>
|
||||
<template slot="append">元</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="有效期类型">
|
||||
<el-form-item label="有效期类型" style="width: 100%;">
|
||||
<el-radio-group v-model="form.validityType">
|
||||
<el-radio v-for="item in couponEnum.validityType" :key="item.value" :label="item.value">
|
||||
{{ item.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.validityType == 'custom'" label="有效时间" prop="validEndTime">
|
||||
<el-form-item v-if="form.validityType == 'fixed'" label="有效期(天)" prop="validDays" style="width: 100%;">
|
||||
<el-input v-model="form.validDays" placeholder="" style="width: 200px;">
|
||||
<template slot="append">天</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.validityType == 'custom'" label="有效时间" prop="validEndTime" style="width: 100%;">
|
||||
<el-date-picker
|
||||
v-model="validityTime"
|
||||
type="daterange"
|
||||
|
|
@ -40,12 +46,7 @@
|
|||
@change="validityChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="有效期(天)" prop="validDays">
|
||||
<el-input v-model="form.validDays" placeholder="" style="width: 200px;">
|
||||
<template slot="append">天</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="使用门槛" prop="daysToTakeEffect">
|
||||
<!-- <el-form-item label="使用门槛" prop="daysToTakeEffect" style="width: 100%;">
|
||||
<el-input v-model="form.daysToTakeEffect" placeholder="" style="width: 200px;">
|
||||
<template slot="prepend">隔</template>
|
||||
<template slot="append">天生效</template>
|
||||
|
|
@ -54,19 +55,19 @@
|
|||
<i class="el-icon-question" />
|
||||
</el-tooltip>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="可用周期" prop="userDays">
|
||||
<el-form-item label="可用周期" prop="userDays" style="width: 100%;">
|
||||
<el-checkbox-group v-model="form.userDays">
|
||||
<el-checkbox v-for="(city,index) in couponEnum.cycle" :key="index" :label="city.label" @change="userDayChagne">{{ city.label }}</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="指定时间段">
|
||||
<el-form-item label="指定时间段" style="width: 100%;">
|
||||
<el-radio-group v-model="form.useTimeType">
|
||||
<el-radio v-for="item in couponEnum.useTimeType" :key="item.value" :label="item.value">
|
||||
{{ item.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.useTimeType == 'custom'" label="指定时间段" prop="useEndTime">
|
||||
<el-form-item v-if="form.useTimeType == 'custom'" label="指定时间段" prop="useEndTime" style="width: 100%;">
|
||||
<el-time-picker
|
||||
v-model="useTime"
|
||||
is-range
|
||||
|
|
@ -78,35 +79,89 @@
|
|||
@change="useTimeChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="发放数量" prop="number">
|
||||
<el-input v-model="form.number" type="number" placeholder="" style="width: 200px;" />
|
||||
<el-form-item label="发放数量" prop="number" style="width: 100%;">
|
||||
<el-input v-model="form.number" oninput="value=value.replace(/^(0+)|[^\d]+/g,'')" placeholder="" style="width: 200px;" />
|
||||
<el-tooltip class="item" effect="dark" content="限用户自行领取,(当库存为 0时,集草等活动仍会赠送)" placement="top-start">
|
||||
<i class="el-icon-question" />
|
||||
</el-tooltip>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<!-- <el-button @click="dialogVisible = false">取 消</el-button> -->
|
||||
<el-button type="primary" :loading="loading" @click="onSubmitHandle">确 定</el-button>
|
||||
</span>
|
||||
</div>
|
||||
<!-- 商品券 -->
|
||||
<div v-if="form.type == 2" class="content">
|
||||
<div v-if="form.type == 2">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="left">
|
||||
<el-form-item label="商品券券名" prop="title">
|
||||
<el-form-item label="优惠券券名" prop="title" style="width: 100%;">
|
||||
<el-input v-model="form.title" placeholder="" style="width: 289px;" />
|
||||
</el-form-item>
|
||||
<el-form-item />
|
||||
<el-form-item />
|
||||
<el-form-item label="发放数量" prop="number">
|
||||
<el-input v-model="form.number" type="number" placeholder="" style="width: 289px;" />
|
||||
<el-form-item label="使用门槛" prop="fullAmount">
|
||||
全额满<el-input v-model="form.fullAmount" oninput="value= value.replace(/[^\d|\.]/g, '')" placeholder="" style="width: 100px;margin: 0 23px;"><template slot="suffix">元</template></el-input>可用
|
||||
</el-form-item>
|
||||
<el-form-item label="有效期类型" style="width: 100%;">
|
||||
<el-radio-group v-model="form.validityType">
|
||||
<el-radio v-for="item in couponEnum.validityType" :key="item.value" :label="item.value">
|
||||
{{ item.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.validityType == 'fixed'" label="有效期(天)" prop="validDays" style="width: 100%;">
|
||||
<el-input v-model="form.validDays" placeholder="" style="width: 200px;">
|
||||
<template slot="append">天</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.validityType == 'custom'" label="有效时间" prop="validEndTime" style="width: 100%;">
|
||||
<el-date-picker
|
||||
v-model="validityTime"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="['06:00:00', '23:59:59']"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
@change="validityChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="使用门槛" prop="daysToTakeEffect" style="width: 100%;">
|
||||
<el-input v-model="form.daysToTakeEffect" placeholder="" style="width: 200px;">
|
||||
<template slot="prepend">隔</template>
|
||||
<template slot="append">天生效</template>
|
||||
</el-input>
|
||||
<el-tooltip class="item" effect="dark" content="领取后0天后0点0分" placement="top-start">
|
||||
<i class="el-icon-question" />
|
||||
</el-tooltip>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="可用周期" prop="userDays" style="width: 100%;">
|
||||
<el-checkbox-group v-model="form.userDays">
|
||||
<el-checkbox v-for="(city,index) in couponEnum.cycle" :key="index" :label="city.label" @change="userDayChagne">{{ city.label }}</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="指定时间段" style="width: 100%;">
|
||||
<el-radio-group v-model="form.useTimeType">
|
||||
<el-radio v-for="item in couponEnum.useTimeType" :key="item.value" :label="item.value">
|
||||
{{ item.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.useTimeType == 'custom'" label="指定时间段" prop="useEndTime" style="width: 100%;">
|
||||
<el-time-picker
|
||||
v-model="useTime"
|
||||
is-range
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="['00:00:00', '23:59:59']"
|
||||
value-format="HH:mm"
|
||||
@change="useTimeChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="发放数量" prop="number" style="width: 100%;">
|
||||
<el-input v-model="form.number" oninput="value=value.replace(/^(0+)|[^\d]+/g,'')" placeholder="" style="width: 200px;" />
|
||||
<el-tooltip class="item" effect="dark" content="限用户自行领取,(当库存为 0时,集草等活动仍会赠送)" placement="top-start">
|
||||
<i class="el-icon-question" />
|
||||
</el-tooltip>
|
||||
</el-form-item>
|
||||
<el-form-item label="使用门槛">
|
||||
全额满<el-input v-model="form.fullAmount" placeholder="" style="width: 100px;margin: 0 23px;"><template slot="suffix">元</template></el-input>可用
|
||||
</el-form-item>
|
||||
<el-form-item label="赠送商品" prop="products">
|
||||
<div>
|
||||
<el-button type="primary" icon="el-icon-plus" @click="$refs.shopListRef.show([...form.products])">
|
||||
|
|
@ -124,10 +179,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<!-- <el-button @click="dialogVisible = false">取 消</el-button> -->
|
||||
<el-button type="primary" :loading="loading" @click="onSubmitHandle">确 定</el-button>
|
||||
</span>
|
||||
</div>
|
||||
|
|
@ -186,6 +240,20 @@ export default {
|
|||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
fullAmount: [
|
||||
{
|
||||
required: true,
|
||||
message: '填写满减金额',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
discountAmount: [
|
||||
{
|
||||
required: true,
|
||||
message: '填写满减金额',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
number: [
|
||||
{
|
||||
required: true,
|
||||
|
|
@ -253,6 +321,7 @@ export default {
|
|||
*/
|
||||
tabClick(item) {
|
||||
console.log(this.form)
|
||||
this.form = this.resetForm
|
||||
this.form.number = ''
|
||||
this.form.type = item.type
|
||||
this.$refs.form.resetFields()
|
||||
|
|
@ -311,7 +380,7 @@ export default {
|
|||
res.map(async item => {
|
||||
if (!await this.checkShop(item.id)) {
|
||||
this.form.products.push({
|
||||
id: item.id,
|
||||
productId: item.id,
|
||||
name: item.name,
|
||||
num: null
|
||||
})
|
||||
|
|
@ -319,7 +388,7 @@ export default {
|
|||
})
|
||||
} else {
|
||||
this.form.products.push({
|
||||
id: res[0].id,
|
||||
productId: res[0].id,
|
||||
name: res[0].name,
|
||||
num: null
|
||||
})
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
<el-table-column label="总发放数量" prop="number" />
|
||||
<el-table-column label="已领取" align="center">
|
||||
<template v-slot="scope">
|
||||
<div style="display: flex;align-items: center;">
|
||||
<div style="display: flex;align-items: center;justify-content: center;">
|
||||
<div style="width: 30px;">{{ scope.row.number-scope.row.leftNumber }}</div>
|
||||
<div style="margin: 0 10px;">|</div>
|
||||
<div style="color: #3F9EFF;cursor: pointer;flex-shrink: 0;" @click="couponDetailsOpen(scope.row)">详情</div>
|
||||
|
|
|
|||
|
|
@ -139,11 +139,11 @@
|
|||
<template v-slot="scope">
|
||||
<template v-if="scope.row.status!='unpaid'">
|
||||
<el-button v-if="canTuikuan(scope.row)" type="text" size="mini" @click="tuikuan(scope.row)"><span >退款</span></el-button>
|
||||
<span class="color-999" v-else>已退款</span>
|
||||
<span class="color-999" v-if="isTui(scope.row)">已退款</span>
|
||||
</template>
|
||||
<template v-if="scope.row.status=='unpaid'">
|
||||
<el-button v-if="canTuicai(scope.row)" type="text" size="mini" @click="tuiCai(scope.row)"><span >退菜</span></el-button>
|
||||
<span class="color-999" v-else>已退菜</span>
|
||||
<span class="color-999" v-if="scope.row=='return'">已退菜</span>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
|
@ -292,6 +292,9 @@ export default {
|
|||
console.log('drawer close')
|
||||
this.$emit('close');
|
||||
},
|
||||
isTui(item){
|
||||
return $util.isTui(item);
|
||||
},
|
||||
canTuikuan(item){
|
||||
return $util.canTuiKuan(this.detail,item);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -11,10 +11,14 @@ export function returnPackFee(arr) {
|
|||
}
|
||||
|
||||
export function canTuicai(orderInfo,item){
|
||||
if(orderInfo.status=='unpaid'&&orderInfo.isPostpaid!==null&&orderInfo.isPostpaid==0){
|
||||
return false
|
||||
}
|
||||
return orderInfo.status=='unpaid'&&orderInfo.useType!='dine-in-before'&& item.status!='return'
|
||||
}
|
||||
export function canTuiKuan(orderInfo,item){
|
||||
return orderInfo.status!='unpaid'&& item.status!='return'&&item.status!='refund'&&item.status!='refunding'
|
||||
// return orderInfo.status!='unpaid'&& item.status!='return'&&item.status!='refund'&&item.status!='refunding'
|
||||
return orderInfo.status=='closed'&& item.status!='return'&&item.status!='refund'&&item.status!='refunding' && !item.userCouponId
|
||||
}
|
||||
export function isTui(item){
|
||||
return item.status=='return'||item.status=='refund'||item.status=='refunding'
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ export default {
|
|||
Editor,
|
||||
addImg,
|
||||
},
|
||||
name:'add_shop',
|
||||
name: 'add_shop',
|
||||
data() {
|
||||
const validatordateUsed = (rule, value, callback) => {
|
||||
if (!this.form.notices.dateUsed) {
|
||||
|
|
@ -602,18 +602,32 @@ export default {
|
|||
batchNumberForm: {
|
||||
batchNumber: 0,
|
||||
},
|
||||
routequery:''
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.tbShopUnit();
|
||||
this.tbShopCategoryGet();
|
||||
this.changeTypeEnum(0);
|
||||
|
||||
if (this.$route.query.goods_id) {
|
||||
this.tbProductGetDetail();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
watch: {
|
||||
// 监听路由对象中的参数变化
|
||||
$route(to, from) {
|
||||
console.log(to.query.goods_id)
|
||||
if (to.query.goods_id) {
|
||||
if (this.routequery == to.query.goods_id) {
|
||||
return false;
|
||||
} else {
|
||||
this.tbProductGetDetail();
|
||||
}
|
||||
this.routequery = to.query.goods_id
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
uploadImgSucess(res, item) {
|
||||
console.log(res);
|
||||
console.log(item);
|
||||
|
|
|
|||
|
|
@ -27,12 +27,19 @@
|
|||
<el-radio :label="0">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="售卖时间管控" >
|
||||
<el-form-item label="售卖时间管控">
|
||||
<el-radio-group v-model="form.useTime">
|
||||
<el-radio :label="1">启用</el-radio>
|
||||
<el-radio :label="0">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="排列方式">
|
||||
<el-radio-group v-model="form.sortMode">
|
||||
<el-radio label="0">默认</el-radio>
|
||||
<el-radio label="1">价格由高到低</el-radio>
|
||||
<el-radio label="2">销量由高到低</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="" v-if="form.useTime == 1">
|
||||
<!-- <el-time-picker is-range v-model="form.saleTime" value-format="HH:mm" format="HH:mm"
|
||||
:picker-options="pickerOptions" range-separator="至" start-placeholder="开始时间"
|
||||
|
|
@ -51,7 +58,7 @@
|
|||
|
||||
|
||||
</el-form-item>
|
||||
<el-form-item label="分组排序" >
|
||||
<el-form-item label="分组排序">
|
||||
<el-input-number v-model="form.sort" controls-position="right" :min="0"></el-input-number>
|
||||
</el-form-item>
|
||||
|
||||
|
|
@ -86,6 +93,7 @@ export default {
|
|||
productIds: [],
|
||||
saleTime: [],
|
||||
useTime: 0,
|
||||
sortMode: '0',
|
||||
shopId: localStorage.getItem('shopId')
|
||||
},
|
||||
pickerOptions: {
|
||||
|
|
@ -182,7 +190,7 @@ export default {
|
|||
},
|
||||
async show(obj) {
|
||||
let res = await hasPermission('允许修改分组');
|
||||
if ( !res) { return; }
|
||||
if (!res) { return; }
|
||||
// if()
|
||||
this.form.useTime = 0
|
||||
if (obj && obj.id) {
|
||||
|
|
@ -192,6 +200,9 @@ export default {
|
|||
this.form.name = obj.name
|
||||
this.form.sort = obj.sort
|
||||
this.form.productIds = obj.productIds
|
||||
this.form.sortMode = obj.sortMode + ''
|
||||
console.log(obj, '体哦啊是1')
|
||||
console.log(this.form, '体哦啊是1')
|
||||
// if (obj.saleStartTime != null) {
|
||||
// this.$set(this.form, 'saleTime', [obj.saleStartTime, obj.saleEndTime])
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -298,11 +298,9 @@ export default {
|
|||
}
|
||||
},
|
||||
async mounted() {
|
||||
console.log(this.$route.query.productId, 'tiaoshi1')
|
||||
if (this.$route.query.productId) {
|
||||
this.query.productId = this.$route.query.productId
|
||||
}
|
||||
console.log(this.query)
|
||||
|
||||
await this.tbShopCategoryGet()
|
||||
await this.getTableData()
|
||||
|
|
@ -533,7 +531,6 @@ export default {
|
|||
})
|
||||
})
|
||||
|
||||
console.log(res);
|
||||
|
||||
this.tableData.loading = false
|
||||
this.tableData.data = res.content
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
<el-button type="primary" :loading="loading" @click="submitHandle">保 存</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<shopList ref="shopList" radio @success="selectConfirmGoods" />
|
||||
<shopList ref="shopList" disableCategory radio @success="selectConfirmGoods" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,142 @@
|
|||
<template>
|
||||
<el-dialog
|
||||
title="添加临时菜"
|
||||
width="410px"
|
||||
:visible.sync="show"
|
||||
@close="reset"
|
||||
>
|
||||
<div>
|
||||
<div>将临时菜添加至购物车,不会影响总商品库</div>
|
||||
<div class="u-m-t-16">
|
||||
<el-form ref="form" :model="form" label-width="80px">
|
||||
<el-form-item label="菜品名称">
|
||||
<el-input v-model="form.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="菜品分类">
|
||||
<el-select v-model="form.category" filterable placeholder="选择分类">
|
||||
<el-option
|
||||
v-for="item in category"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="价格">
|
||||
<el-input v-model="form.price" placeholder="请输入价格" type="number">
|
||||
<template slot="append">元</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="单位">
|
||||
<el-select v-model="form.unit" filterable placeholder="选择单位">
|
||||
<el-option
|
||||
v-for="item in units"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="下单数量">
|
||||
<el-input v-model="form.num" placeholder="请输入下单数量" type="number">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.note" placeholder="请输入备注" >
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
<div slot="footer">
|
||||
<el-button size="medium" @click="close"> 取消 </el-button>
|
||||
<el-button size="medium" type="primary" @click="confirm">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
import { tbShopCategoryGet,tbShopUnit } from "@/api/shop";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
show: false,
|
||||
form: {
|
||||
name: "",
|
||||
category:'',
|
||||
price: "",
|
||||
unit:'',
|
||||
num:1,
|
||||
note:''
|
||||
},
|
||||
category:[],
|
||||
units:[]
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
async getCategory() {
|
||||
const { content } = await tbShopCategoryGet({
|
||||
page: 0,
|
||||
size: 300,
|
||||
sort: "id",
|
||||
shopId: localStorage.getItem("shopId"),
|
||||
});
|
||||
this.category = content.reduce((prve, cur) => {
|
||||
prve.push(cur);
|
||||
return [...prve, ...cur.childrenList];
|
||||
}, []);
|
||||
},
|
||||
async getUnit() {
|
||||
const { content } = await tbShopUnit({
|
||||
page: 0,
|
||||
size: 300,
|
||||
sort: "id",
|
||||
shopId: localStorage.getItem("shopId"),
|
||||
});
|
||||
this.units = content
|
||||
},
|
||||
reset() {},
|
||||
|
||||
open() {
|
||||
this.show = true;
|
||||
},
|
||||
close() {
|
||||
this.show = false;
|
||||
},
|
||||
confirm() {
|
||||
this.$emit("confirm", this.form);
|
||||
this.close();
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getCategory()
|
||||
this.getUnit()
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
::v-deep .el-dialog__body {
|
||||
margin-bottom: 14px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
::v-deep .el-form-item__label {
|
||||
text-align: left;
|
||||
}
|
||||
input[type="number"]::-webkit-inner-spin-button,
|
||||
input[type="number"]::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
::v-deep .el-input__inner::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
::v-deep .el-input__inner::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -0,0 +1,456 @@
|
|||
<template>
|
||||
<el-dialog
|
||||
width="700px"
|
||||
:title="title"
|
||||
:visible.sync="show"
|
||||
top="20px"
|
||||
@close="reset"
|
||||
>
|
||||
<div class="u-p-15">
|
||||
<div class="">
|
||||
<el-tabs v-model="activeName" @tab-click="tabClick">
|
||||
<el-tab-pane label="优惠券(单选)" name="youhui">
|
||||
<el-table
|
||||
ref="table"
|
||||
empty-text="无可用优惠券"
|
||||
:data="quans.fullReductionCoupon"
|
||||
@cell-click="fullReductionCouponClick"
|
||||
>
|
||||
<el-table-column
|
||||
type="index"
|
||||
label=""
|
||||
v-if="quans.fullReductionCoupon.length > 0"
|
||||
>
|
||||
<template v-slot="scope">
|
||||
<el-checkbox
|
||||
@change="fullReductionCouponClick(scope.row)"
|
||||
:value="scope.row.id == fullReductionCouponSel.id"
|
||||
></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column type="index" label="#"> </el-table-column>
|
||||
<el-table-column prop="name" label="券名称"> </el-table-column>
|
||||
<el-table-column label="券类型" width="80">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="discountAmount" label="抵扣">
|
||||
<template v-slot="scope">
|
||||
<span class="color-red">
|
||||
¥{{ scope.row.discountAmount }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="discountAmount" label="限制" width="120">
|
||||
<template v-slot="scope">
|
||||
<div class="u-flex">
|
||||
<span>支付满</span>
|
||||
<span class="color-red no-wrap">
|
||||
{{ scope.row.fullAmount }}
|
||||
</span>
|
||||
<span>元可用</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="useRestrictions" label="描述">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="商品券(多选)" name="goods">
|
||||
<el-table
|
||||
ref="table1"
|
||||
@cell-click="productCouponClick"
|
||||
empty-text="无可用商品券"
|
||||
:data="quans.productCoupon"
|
||||
tooltip-effect="dark"
|
||||
style="width: 100%"
|
||||
@selection-change="productCouponChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" :selectable="goodsCoupSelectableHandle"> </el-table-column>
|
||||
<el-table-column type="index" width="50" label="#">
|
||||
</el-table-column>
|
||||
<el-table-column prop="name" label="券名称"> </el-table-column>
|
||||
|
||||
<el-table-column label="商品信息" width="120">
|
||||
<template v-slot="scope">
|
||||
<div class="u-flex">
|
||||
<div class="u-flex">
|
||||
<el-image
|
||||
:src="scope.row.productCover"
|
||||
fit="cover"
|
||||
style="width: 40px; height: 40px"
|
||||
:preview-src-list="[scope.row.productCover]"
|
||||
></el-image>
|
||||
</div>
|
||||
<div class="u-p-l-10">
|
||||
<div class="">{{ scope.row.productName }}</div>
|
||||
<div class="">x{{ scope.row.num || "" }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="discountAmount" label="抵扣">
|
||||
<template v-slot="scope">
|
||||
<span class="color-red">
|
||||
¥{{ scope.row.discountAmount }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="券类型">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="useRestrictions" label="描述">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<div v-if="quansSelArr.length > 0">
|
||||
<div class="font-bold u-m-b-10">已选优惠券</div>
|
||||
<el-table empty-text="未选择优惠券" :data="quansSelArr">
|
||||
<el-table-column type="index" width="50" label="#">
|
||||
</el-table-column>
|
||||
<el-table-column prop="name" label="券名称"> </el-table-column>
|
||||
<el-table-column label="券类型" width="80">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="商品信息" width="120">
|
||||
<template v-slot="scope">
|
||||
<div class="u-flex">
|
||||
<div class="u-flex">
|
||||
<el-image
|
||||
:src="scope.row.productCover"
|
||||
fit="cover"
|
||||
style="width: 40px; height: 40px"
|
||||
:preview-src-list="[scope.row.productCover]"
|
||||
></el-image>
|
||||
</div>
|
||||
<div class="u-p-l-10">
|
||||
<div class="">{{ scope.row.productName }}</div>
|
||||
<div class="">x{{ scope.row.num || "" }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="discountAmount" label="抵扣">
|
||||
<template v-slot="scope">
|
||||
<span class="color-red">
|
||||
¥{{ scope.row.discountAmount }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="useRestrictions" label="描述">
|
||||
</el-table-column>
|
||||
<el-table-column prop="useRestrictions" label="">
|
||||
<template v-slot="scope">
|
||||
<el-button type="danger" size="mini" @click="delQuan(scope.row)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="u-flex u-m-t-20">
|
||||
<span class="">抵扣:</span>
|
||||
<span class="color-red font-bold">{{ AllCouponPrice }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-flex u-row-center u-m-t-50">
|
||||
<el-button size="medium" @click="close">取消</el-button>
|
||||
<el-button size="medium" type="primary" @click="confirm"
|
||||
>确定</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
import { $activateByOrderId } from "@/api/table";
|
||||
import {
|
||||
returnProductCouponAllPrice,returnProductCoupon,
|
||||
returnProductCouponPrice,
|
||||
returnFullReductionCouponAllPrice,returnNewGoodsList
|
||||
} from "../util";
|
||||
let $originFullReductionCoupon = [];
|
||||
export default {
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: "选择优惠券",
|
||||
},
|
||||
goodsArr: {
|
||||
type: Array,
|
||||
default: [],
|
||||
},
|
||||
vipUser: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
isVip: false,
|
||||
};
|
||||
},
|
||||
},
|
||||
orderPrice: {
|
||||
type: [Number, String],
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
propSelCoup: [],
|
||||
fullReductionCouponSel: {
|
||||
id: "",
|
||||
},
|
||||
quansSelArr: [],
|
||||
quans: {
|
||||
fullReductionCoupon: [],
|
||||
productCoupon: [],
|
||||
},
|
||||
currentRow: null,
|
||||
multipleSelection: null,
|
||||
fullReductionCouponSelId: "",
|
||||
activeName: "youhui",
|
||||
form: {},
|
||||
show: false,
|
||||
isSetProductCoup: false,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
activeName(newval) {
|
||||
if (newval == "youhui") {
|
||||
this.filterFullReductionCoupon();
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
goodsDiscount() {
|
||||
const coupArr = this.quansSelArr.filter((v) => v.type == 2);
|
||||
return returnProductCouponAllPrice(coupArr, this.goodsArr, this.vipUser);
|
||||
},
|
||||
fullReductionCouponDiscount() {
|
||||
const coupArr = this.quansSelArr.filter((v) => v.type == 1);
|
||||
return returnFullReductionCouponAllPrice(coupArr);
|
||||
},
|
||||
AllCouponPrice() {
|
||||
return (
|
||||
this.goodsDiscount * 1 +
|
||||
this.fullReductionCouponDiscount * 1
|
||||
).toFixed(2);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
goodsCoupSelectableHandle(row,index){
|
||||
console.log(row,index);
|
||||
return true
|
||||
},
|
||||
delQuan(row) {
|
||||
if (row.type == 2) {
|
||||
const index = this.quansSelArr.findIndex((item) => item.id == row.id);
|
||||
this.quansSelArr.splice(index, 1);
|
||||
this.$refs.table1.toggleRowSelection(row, false);
|
||||
} else {
|
||||
this.fullReductionCouponSel = { id: "" };
|
||||
this.quansSelArr.splice(0, 1);
|
||||
}
|
||||
if (index != -1) {
|
||||
const row = this.quansSelArr.find;
|
||||
}
|
||||
},
|
||||
reset() {
|
||||
this.quansSelArr = [];
|
||||
this.fullReductionCouponSel = { id: "" };
|
||||
this.$refs.table1.clearSelection();
|
||||
},
|
||||
filterFullReductionCoupon() {
|
||||
this.quans.fullReductionCoupon = $originFullReductionCoupon.filter(
|
||||
(v) => this.orderPrice - this.goodsDiscount >= v.fullAmount
|
||||
);
|
||||
},
|
||||
productCouponChange(val) {
|
||||
const oldval=this.quansSelArr;
|
||||
if (this.isSetProductCoup) {
|
||||
return;
|
||||
}
|
||||
|
||||
const firstCoup = this.quansSelArr[0];
|
||||
const firstIsDikouQuan = firstCoup ? firstCoup.type == 1 : false;
|
||||
if (firstCoup && firstIsDikouQuan) {
|
||||
if (
|
||||
this.orderPrice -
|
||||
this.fullReductionCouponDiscount -
|
||||
returnProductCouponAllPrice(val, this.goodsArr, this.vipUser) <
|
||||
firstCoup.fullAmount
|
||||
) {
|
||||
this.$confirm(
|
||||
"所选优惠券不满足最低抵扣" + firstCoup.fullAmount + "元要求",
|
||||
"提示",
|
||||
{
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: "放弃选择商品券",
|
||||
cancelButtonText: "删除优惠券",
|
||||
type: "warning",
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
val.map((v) => {
|
||||
this.$refs.table1.toggleRowSelection(v);
|
||||
});
|
||||
})
|
||||
.catch((action) => {
|
||||
if (action == "cancel") {
|
||||
this.quansSelArr.splice(0, 1);
|
||||
this.fullReductionCouponSel = { id: "" };
|
||||
this.quansSelArr = [...val];
|
||||
}
|
||||
if (action == "close") {
|
||||
val.map((v) => {
|
||||
this.$refs.table1.toggleRowSelection(v);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.quansSelArr.splice(
|
||||
val.length <= 0 ? 1 : val.length,
|
||||
this.quansSelArr.length
|
||||
);
|
||||
for (let i in val) {
|
||||
this.$set(this.quansSelArr, i * 1 + 1, { ...val[i] });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.quansSelArr = [...val];
|
||||
}
|
||||
},
|
||||
fullReductionCouponClick(row) {
|
||||
if (row.id == this.fullReductionCouponSel.id) {
|
||||
this.fullReductionCouponSel = { id: "" };
|
||||
this.quansSelArr.splice(0, 1);
|
||||
return;
|
||||
}
|
||||
const dikouQuan = this.quansSelArr[0];
|
||||
this.fullReductionCouponSel = row;
|
||||
if (dikouQuan && dikouQuan.type == 1) {
|
||||
this.$set(this.quansSelArr, 0, row);
|
||||
} else {
|
||||
this.quansSelArr.unshift(row);
|
||||
}
|
||||
if (!this.fullReductionCouponSel.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
this.orderPrice -
|
||||
this.fullReductionCouponDiscount -
|
||||
this.goodsDiscount <
|
||||
this.fullReductionCouponSel.fullAmount
|
||||
) {
|
||||
this.fullReductionCouponSel = { id: "" };
|
||||
this.quansSelArr.splice(0, 1);
|
||||
this.$confirm(
|
||||
"所选优惠券不满足最低抵扣" +
|
||||
this.fullReductionCouponSel.fullAmount +
|
||||
"元要求",
|
||||
"提示",
|
||||
{
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: "确定",
|
||||
type: "warning",
|
||||
}
|
||||
).then(() => {});
|
||||
}
|
||||
},
|
||||
productCouponClick(row) {
|
||||
this.$refs.table1.toggleRowSelection(row);
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.currentRow = val;
|
||||
},
|
||||
handleSelectionChange(val) {
|
||||
this.multipleSelection = val;
|
||||
},
|
||||
tabClick() {},
|
||||
init() {},
|
||||
|
||||
changeKey(key, val) {
|
||||
this[key] = val;
|
||||
},
|
||||
|
||||
confirm() {
|
||||
this.$emit("confirm", [...this.quansSelArr]);
|
||||
this.close();
|
||||
},
|
||||
setSelectCoupon() {
|
||||
const dikouQuan = this.propSelCoup.find((v) => v.type == 1);
|
||||
this.fullReductionCouponSel = dikouQuan ? dikouQuan : { id: "" };
|
||||
const productCouArr = this.propSelCoup.filter((v) => v.type == 2);
|
||||
this.quans.productCoupon.map((v) => {
|
||||
for (let i in productCouArr) {
|
||||
this.isSetProductCoup = true;
|
||||
if (v.id == productCouArr[i].id) {
|
||||
this.$refs.table1.toggleRowSelection(v, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.isSetProductCoup = false;
|
||||
},
|
||||
async open(data, propSelCoup) {
|
||||
this.propSelCoup = [...propSelCoup] || [];
|
||||
console.log(data);
|
||||
if (data.memberId) {
|
||||
let quansRes = await $activateByOrderId({
|
||||
orderId: data.id,
|
||||
memberId: data.memberId,
|
||||
});
|
||||
quansRes.fullReductionCoupon = quansRes.fullReductionCoupon.filter(
|
||||
(v) => {
|
||||
return this.orderPrice >= v.fullAmount && v.use;
|
||||
}
|
||||
);
|
||||
const canDikouGoodsArr = returnNewGoodsList(this.goodsArr|| [])
|
||||
$originFullReductionCoupon = quansRes.fullReductionCoupon;
|
||||
this.quans.productCoupon = quansRes.productCoupon.map(v=>{
|
||||
const coup = returnProductCoupon(v, canDikouGoodsArr,this.vipUser)
|
||||
return coup
|
||||
}).filter(v=>v.use)
|
||||
// this.quans = quans;
|
||||
this.filterFullReductionCoupon();
|
||||
this.quansSelArr = this.propSelCoup;
|
||||
this.$nextTick(() => {
|
||||
this.setSelectCoupon();
|
||||
});
|
||||
}
|
||||
|
||||
this.show = true;
|
||||
this.init();
|
||||
},
|
||||
close() {
|
||||
this.show = false;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.number = `${this.value}`;
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.codeImg {
|
||||
width: 160px;
|
||||
border: 1px solid rgb(220, 223, 230);
|
||||
height: 160px;
|
||||
}
|
||||
::v-deep .el-input .el-input__inner::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
::v-deep .el-input .el-input__inner::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -63,11 +63,19 @@
|
|||
@cell-click="productCouponClick"
|
||||
empty-text="无可用商品券"
|
||||
:data="quans.productCoupon"
|
||||
tooltip-effect="dark"
|
||||
style="width: 100%"
|
||||
@selection-change="productCouponChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55"> </el-table-column>
|
||||
<el-table-column
|
||||
label=""
|
||||
v-if="quans.fullReductionCoupon.length > 0"
|
||||
>
|
||||
<template v-slot="scope">
|
||||
<el-checkbox
|
||||
@change="productCouponClick(scope.row)"
|
||||
:value="scope.row.checked"
|
||||
></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column type="index" width="50" label="#">
|
||||
</el-table-column>
|
||||
<el-table-column prop="name" label="券名称"> </el-table-column>
|
||||
|
|
@ -90,13 +98,13 @@
|
|||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="discountAmount" label="抵扣">
|
||||
<!-- <el-table-column prop="discountAmount" label="抵扣">
|
||||
<template v-slot="scope">
|
||||
<span class="color-red">
|
||||
¥{{ scope.row.discountAmount }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
<el-table-column label="券类型">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||
|
|
@ -104,6 +112,11 @@
|
|||
</el-table-column>
|
||||
<el-table-column prop="useRestrictions" label="描述">
|
||||
</el-table-column>
|
||||
<el-table-column prop="useRestrictions" label="是否可用">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.use ? "可以" : "不可用" }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
|
@ -118,23 +131,32 @@
|
|||
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="商品信息">
|
||||
<el-table-column label="商品信息" width="120">
|
||||
<template v-slot="scope">
|
||||
<div class="u-flex" v-if="scope.row.type == 2">
|
||||
<el-image
|
||||
:src="scope.row.productCover"
|
||||
style="width: 40px; height: 40px"
|
||||
:preview-src-list="[scope.row.productCover]"
|
||||
></el-image>
|
||||
<div class="u-m-l-10">{{ scope.row.productName }}</div>
|
||||
<div class="u-flex">
|
||||
<el-image
|
||||
:src="scope.row.productCover"
|
||||
fit="cover"
|
||||
style="width: 40px; height: 40px"
|
||||
:preview-src-list="[scope.row.productCover]"
|
||||
></el-image>
|
||||
</div>
|
||||
<div class="u-p-l-10">
|
||||
<div class="">{{ scope.row.productName }}</div>
|
||||
<div class="">x{{ scope.row.num || "" }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="discountAmount" label="抵扣">
|
||||
<template v-slot="scope">
|
||||
<span class="color-red">
|
||||
<span class="color-red" v-if="scope.row.type == 1">
|
||||
¥{{ scope.row.discountAmount }}
|
||||
</span>
|
||||
<span class="color-red" v-if="scope.row.type == 2">
|
||||
¥{{ returnProDiscount(scope.row, scope.row.index) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="useRestrictions" label="描述">
|
||||
|
|
@ -147,9 +169,22 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="u-flex u-m-t-20">
|
||||
<span class="">抵扣:</span>
|
||||
<span class="color-red font-bold">{{ AllCouponPrice }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-row-between u-m-t-20">
|
||||
<div class="u-flex">
|
||||
<span>抵扣金额:</span>
|
||||
<span class="color-red">¥{{ AllCouponPrice }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-relative">
|
||||
<span>支付金额:</span>
|
||||
<span class="color-red">¥{{ payPrice }}</span>
|
||||
<div
|
||||
class="u-absolute u-flex line-th color-999"
|
||||
style="right: 0; bottom: 100%"
|
||||
v-if="orderPrice * 1 != payPrice * 1"
|
||||
>
|
||||
<span class="">¥{{ orderPrice }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-flex u-row-center u-m-t-50">
|
||||
|
|
@ -165,11 +200,21 @@
|
|||
<script>
|
||||
import { $activateByOrderId } from "@/api/table";
|
||||
import {
|
||||
returnProductCouponAllPrice,
|
||||
returnProductCouponPrice,
|
||||
returnNewGoodsList,
|
||||
returnFullReductionCouponAllPrice,
|
||||
} from "../util";
|
||||
returnCouponAllPrice,
|
||||
returnProductCoupon,
|
||||
returnCanUseFullReductionCoupon,
|
||||
returnCoupCanUse,
|
||||
returnProductCouponAllPrice,
|
||||
returnGoodsPayPriceMap,
|
||||
returnProductCoupAllPrice,
|
||||
} from "../quan_util.js";
|
||||
let $originFullReductionCoupon = [];
|
||||
//可以抵扣的商品列表
|
||||
let canDikouGoodsArr = [];
|
||||
//商品数量从0到n每一个对应的价格
|
||||
let $goodsPayPriceMap = {};
|
||||
export default {
|
||||
props: {
|
||||
title: {
|
||||
|
|
@ -187,15 +232,11 @@ export default {
|
|||
isVip: false,
|
||||
};
|
||||
},
|
||||
},
|
||||
orderPrice: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
propSelCoup: [],
|
||||
orderPrice:0,
|
||||
fullReductionCouponSel: {
|
||||
id: "",
|
||||
},
|
||||
|
|
@ -223,32 +264,58 @@ export default {
|
|||
computed: {
|
||||
goodsDiscount() {
|
||||
const coupArr = this.quansSelArr.filter((v) => v.type == 2);
|
||||
return returnProductCouponAllPrice(coupArr, this.goodsArr, this.vipUser);
|
||||
return returnProductCouponAllPrice(
|
||||
coupArr,
|
||||
canDikouGoodsArr,
|
||||
this.vipUser
|
||||
);
|
||||
},
|
||||
fullReductionCouponDiscount() {
|
||||
const coupArr = this.quansSelArr.filter((v) => v.type == 1);
|
||||
return returnFullReductionCouponAllPrice(coupArr);
|
||||
},
|
||||
AllCouponPrice() {
|
||||
return (
|
||||
this.goodsDiscount * 1 +
|
||||
this.fullReductionCouponDiscount * 1
|
||||
).toFixed(2);
|
||||
return returnCouponAllPrice(
|
||||
this.quansSelArr,
|
||||
canDikouGoodsArr,
|
||||
this.vipUser
|
||||
);
|
||||
},
|
||||
payPrice() {
|
||||
const pay = this.orderPrice - this.AllCouponPrice;
|
||||
return (pay < 0 ? 0 : pay).toFixed(2);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
delQuan(row) {
|
||||
if (row.type == 2) {
|
||||
const index = this.quansSelArr.findIndex((item) => item.id == row.id);
|
||||
this.quansSelArr.splice(index, 1);
|
||||
this.$refs.table1.toggleRowSelection(row, false);
|
||||
returnProDiscount(row) {
|
||||
console.log(row);
|
||||
//相同商品抵扣券数组
|
||||
const arr = this.quans.productCoupon.filter((v) => v.proId == row.proId);
|
||||
const index = arr.findIndex((v) => v.id == row.id);
|
||||
if (index != -1) {
|
||||
return returnProductCoupAllPrice(
|
||||
$goodsPayPriceMap[row.proId],
|
||||
index,
|
||||
row.num
|
||||
);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
goodsCoupSelectableHandle(row, index) {
|
||||
console.log(row, index);
|
||||
return true;
|
||||
},
|
||||
delQuan(row) {
|
||||
const index = this.quansSelArr.findIndex((item) => item.id == row.id);
|
||||
if (row.type == 2 && index != -1) {
|
||||
this.quansSelArr.splice(index, 1);
|
||||
this.quans.productCoupon[index].checked = false;
|
||||
}
|
||||
if (row.type == 1 && index != -1) {
|
||||
this.fullReductionCouponSel = { id: "" };
|
||||
this.quansSelArr.splice(0, 1);
|
||||
}
|
||||
if (index != -1) {
|
||||
const row = this.quansSelArr.find;
|
||||
}
|
||||
},
|
||||
reset() {
|
||||
this.quansSelArr = [];
|
||||
|
|
@ -256,64 +323,12 @@ export default {
|
|||
this.$refs.table1.clearSelection();
|
||||
},
|
||||
filterFullReductionCoupon() {
|
||||
this.quans.fullReductionCoupon = $originFullReductionCoupon.filter(
|
||||
(v) => this.orderPrice - this.goodsDiscount >= v.fullAmount
|
||||
this.quans.fullReductionCoupon = returnCanUseFullReductionCoupon(
|
||||
$originFullReductionCoupon,
|
||||
this.payPrice,
|
||||
this.fullReductionCouponSel
|
||||
);
|
||||
},
|
||||
productCouponChange(val) {
|
||||
if (this.isSetProductCoup) {
|
||||
return;
|
||||
}
|
||||
|
||||
const firstCoup = this.quansSelArr[0];
|
||||
const firstIsDikouQuan = firstCoup ? firstCoup.type == 1 : false;
|
||||
if (firstCoup && firstIsDikouQuan) {
|
||||
if (
|
||||
this.orderPrice -
|
||||
this.fullReductionCouponDiscount -
|
||||
returnProductCouponAllPrice(val, this.goodsArr, this.vipUser) <
|
||||
firstCoup.fullAmount
|
||||
) {
|
||||
this.$confirm(
|
||||
"所选优惠券不满足最低抵扣" + firstCoup.fullAmount + "元要求",
|
||||
"提示",
|
||||
{
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: "放弃选择商品券",
|
||||
cancelButtonText: "删除优惠券",
|
||||
type: "warning",
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
val.map((v) => {
|
||||
this.$refs.table1.toggleRowSelection(v);
|
||||
});
|
||||
})
|
||||
.catch((action) => {
|
||||
if (action == "cancel") {
|
||||
this.quansSelArr.splice(0, 1);
|
||||
this.fullReductionCouponSel = { id: "" };
|
||||
this.quansSelArr = [...val];
|
||||
}
|
||||
if (action == "close") {
|
||||
val.map((v) => {
|
||||
this.$refs.table1.toggleRowSelection(v);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.quansSelArr.splice(
|
||||
val.length <= 0 ? 1 : val.length,
|
||||
this.quansSelArr.length
|
||||
);
|
||||
for (let i in val) {
|
||||
this.$set(this.quansSelArr, i * 1 + 1, { ...val[i] });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.quansSelArr = [...val];
|
||||
}
|
||||
},
|
||||
fullReductionCouponClick(row) {
|
||||
if (row.id == this.fullReductionCouponSel.id) {
|
||||
this.fullReductionCouponSel = { id: "" };
|
||||
|
|
@ -327,33 +342,54 @@ export default {
|
|||
} else {
|
||||
this.quansSelArr.unshift(row);
|
||||
}
|
||||
if(!this.fullReductionCouponSel.id){
|
||||
return
|
||||
}
|
||||
|
||||
if (
|
||||
this.orderPrice -
|
||||
this.fullReductionCouponDiscount -
|
||||
this.goodsDiscount <
|
||||
this.fullReductionCouponSel.fullAmount
|
||||
) {
|
||||
this.fullReductionCouponSel = { id: "" };
|
||||
this.quansSelArr.splice(0, 1);
|
||||
this.$confirm(
|
||||
"所选优惠券不满足最低抵扣" +
|
||||
this.fullReductionCouponSel.fullAmount +
|
||||
"元要求",
|
||||
"提示",
|
||||
{
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: "确定",
|
||||
type: "warning",
|
||||
}
|
||||
).then(() => {});
|
||||
if (!this.fullReductionCouponSel.id) {
|
||||
return;
|
||||
}
|
||||
},
|
||||
productCouponClick(row) {
|
||||
this.$refs.table1.toggleRowSelection(row);
|
||||
productCouponClick(item) {
|
||||
if (!item.use) {
|
||||
return;
|
||||
}
|
||||
if (this.fullReductionCouponSel.id && !item.checked) {
|
||||
const goodsQuan = this.quans.productCoupon.filter((v) => v.checked);
|
||||
const fullReductionCoupon = this.fullReductionCouponSel.id
|
||||
? [this.fullReductionCouponSel]
|
||||
: [];
|
||||
let coupArr = [...goodsQuan, item];
|
||||
const payPrice =
|
||||
this.orderPrice -
|
||||
returnCouponAllPrice(coupArr, canDikouGoodsArr, this.vipUser);
|
||||
console.log(payPrice);
|
||||
if (this.fullReductionCouponSel.fullAmount > payPrice) {
|
||||
this.$confirm(
|
||||
"选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券",
|
||||
"提示",
|
||||
{
|
||||
confirmButtonText: "继续选择",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
this.fullReductionCouponSel = {
|
||||
id: "",
|
||||
};
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
}
|
||||
item.checked = !item.checked;
|
||||
const CheckedArr = this.quans.productCoupon.filter((v) => v.checked);
|
||||
this.quansSelArr = [
|
||||
...(this.fullReductionCouponSel.id
|
||||
? [this.fullReductionCouponSel]
|
||||
: []),
|
||||
...CheckedArr,
|
||||
];
|
||||
const noCheckedArr = this.quans.productCoupon.filter((v) => !v.checked);
|
||||
noCheckedArr.map((v) => {
|
||||
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr);
|
||||
});
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.currentRow = val;
|
||||
|
|
@ -372,51 +408,44 @@ export default {
|
|||
this.$emit("confirm", [...this.quansSelArr]);
|
||||
this.close();
|
||||
},
|
||||
setSelectCoupon() {
|
||||
const dikouQuan = this.propSelCoup.find((v) => v.type == 1);
|
||||
this.fullReductionCouponSel = dikouQuan ? dikouQuan : { id: "" };
|
||||
const productCouArr = this.propSelCoup.filter((v) => v.type == 2);
|
||||
this.quans.productCoupon.map((v) => {
|
||||
for (let i in productCouArr) {
|
||||
this.isSetProductCoup = true;
|
||||
if (v.id == productCouArr[i].id) {
|
||||
this.$refs.table1.toggleRowSelection(v, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.isSetProductCoup = false;
|
||||
},
|
||||
async open(data, propSelCoup) {
|
||||
this.propSelCoup = [...propSelCoup] || [];
|
||||
console.log(data);
|
||||
this.orderPrice=data.orderPrice;
|
||||
this.quansSelArr = [...propSelCoup];
|
||||
$goodsPayPriceMap = returnGoodsPayPriceMap(this.goodsArr || []);
|
||||
if (data.memberId) {
|
||||
let quansRes = await $activateByOrderId({
|
||||
orderId: data.id,
|
||||
memberId: data.memberId,
|
||||
});
|
||||
quansRes.fullReductionCoupon = quansRes.fullReductionCoupon.filter(
|
||||
(v) => this.orderPrice >= v.fullAmount
|
||||
(v) => v.use && this.orderPrice * 1 >= v.fullAmount * 1
|
||||
);
|
||||
const selFullReductionCoupon = this.quansSelArr.find(
|
||||
(v) => v.type == 1
|
||||
);
|
||||
this.fullReductionCouponSel = selFullReductionCoupon
|
||||
? selFullReductionCoupon
|
||||
: { id: "" };
|
||||
this.quans.fullReductionCoupon = quansRes.fullReductionCoupon;
|
||||
canDikouGoodsArr = returnNewGoodsList(this.goodsArr || []);
|
||||
$originFullReductionCoupon = quansRes.fullReductionCoupon;
|
||||
this.quans.productCoupon = quansRes.productCoupon
|
||||
.map((v) => {
|
||||
const calcCoup = returnProductCoupon(
|
||||
v,
|
||||
canDikouGoodsArr,
|
||||
this.vipUser
|
||||
);
|
||||
return {
|
||||
...v,
|
||||
discountAmount: returnProductCouponPrice(
|
||||
v,
|
||||
this.goodsArr,
|
||||
this.vipUser
|
||||
),
|
||||
...calcCoup,
|
||||
checked: this.quansSelArr.find((selCoup) => selCoup.id == v.id)
|
||||
? true
|
||||
: false,
|
||||
};
|
||||
})
|
||||
.filter((v) => v.discountAmount > 0);
|
||||
.filter((v) => v.use);
|
||||
// this.quans = quans;
|
||||
this.filterFullReductionCoupon();
|
||||
this.quansSelArr = this.propSelCoup;
|
||||
this.$nextTick(() => {
|
||||
this.setSelectCoupon();
|
||||
});
|
||||
}
|
||||
|
||||
this.show = true;
|
||||
|
|
@ -433,6 +462,9 @@ export default {
|
|||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.line-th {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
.codeImg {
|
||||
width: 160px;
|
||||
border: 1px solid rgb(220, 223, 230);
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ export default {
|
|||
this.goods = item?item:this.goods;
|
||||
console.log(item)
|
||||
this.show = true;
|
||||
if (item != "-999") {
|
||||
if (item.productId != "-999") {
|
||||
this.number = 1;
|
||||
} else {
|
||||
this.number = item.num;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,206 @@
|
|||
export function isTui(item) {
|
||||
return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
|
||||
}
|
||||
//是否使用会员价
|
||||
export function isUseMemberPrice(vipUser,goods){
|
||||
return vipUser.id&&vipUser.isVip&&goods.isMember
|
||||
}
|
||||
|
||||
//计算商品券优惠价格
|
||||
export function returnProductCouponPrice(coup, goodsArr, vipUser) {
|
||||
const item = goodsArr.find(v => v.productId == coup.proId);
|
||||
if (!item) {
|
||||
return 0
|
||||
}
|
||||
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
||||
const price = item ? (isUseMemberPrice(vipUser,item) ? memberPrice : item.price) : 0;
|
||||
return price * coup.num
|
||||
|
||||
}
|
||||
//返回新的商品列表,过滤掉退菜的,退单的商品
|
||||
export function returnNewGoodsList(arr) {
|
||||
let goodsMap = {}
|
||||
return arr.filter(v => !isTui(v))
|
||||
}
|
||||
//根据当前购物车商品以及数量,已选券对应商品数量,判断该商品券是否可用
|
||||
export function returnCoupCanUse(goodsArr = [], coup, selCoupArr = []) {
|
||||
// if(!coup.use){
|
||||
// return false
|
||||
// }
|
||||
const findGoods = goodsArr.filter(v => v.productId == coup.proId)
|
||||
if (!findGoods.length) {
|
||||
return false
|
||||
}
|
||||
const findGoodsTotalNumber = findGoods.reduce((prve, cur) => {
|
||||
return prve + cur.num * 1
|
||||
}, 0)
|
||||
const selCoupNumber = selCoupArr.filter(v => v.proId == coup.proId).reduce((prve, cur) => {
|
||||
return prve + cur.num * 1
|
||||
}, 0)
|
||||
if (selCoupNumber >= findGoodsTotalNumber) {
|
||||
return false
|
||||
}
|
||||
return findGoodsTotalNumber < (coup.num + selCoupNumber) ? false : true
|
||||
}
|
||||
//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
|
||||
export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
|
||||
const newGoodsArr = returnNewGoodsList(goodsArr)
|
||||
const item = newGoodsArr.find(v => v.productId == coup.proId);
|
||||
if (!item) {
|
||||
return {
|
||||
...coup,
|
||||
discountAmount: 0,
|
||||
use: false
|
||||
}
|
||||
}
|
||||
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
||||
const price = item ? (isUseMemberPrice(vipUser,item) ? memberPrice : item.price) : 0;
|
||||
const discountAmount = (price * coup.num).toFixed(2)
|
||||
console.log(discountAmount);
|
||||
|
||||
const canUse = !coup.use ? false : (discountAmount > 0 && returnCoupCanUse(goodsArr, coup, selCoupArr))
|
||||
// const canUse=discountAmount>0
|
||||
return {
|
||||
...coup,
|
||||
discountAmount: discountAmount,
|
||||
use: canUse
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 根据购物车商品计算商品券抵扣价格以及是否满足可用需求
|
||||
* 1.商品券对应商品数量大于购物车对应商品数量不可用
|
||||
* 2.未在购物车找到相关商品不可用
|
||||
* @param {*} coupArr
|
||||
* @param {*} goodsArr
|
||||
* @param {*} vipUser
|
||||
* @returns
|
||||
*/
|
||||
export function returnProductAllCoup(coupArr, goodsArr, vipUser) {
|
||||
return coupArr.map((v) => {
|
||||
return returnProductCoupon(v, goodsArr, vipUser)
|
||||
})
|
||||
|
||||
}
|
||||
//返回商品实际支付价格
|
||||
export function returnProductPayPrice(goods,vipUser){
|
||||
const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price;
|
||||
const price = isUseMemberPrice(vipUser,goods) ? memberPrice : goods.price;
|
||||
return price
|
||||
}
|
||||
//返回商品券抵扣的商品价格
|
||||
export function returnProductCoupAllPrice(productPriceArr,startIndex,num){
|
||||
return productPriceArr.slice(startIndex,startIndex+num).reduce((prve,cur)=>{
|
||||
let curPrice=0
|
||||
if(typeof cur==='object'){
|
||||
curPrice=cur.memberPrice*1
|
||||
}else{
|
||||
curPrice=cur*1
|
||||
}
|
||||
return prve+curPrice
|
||||
},0)
|
||||
}
|
||||
//返回同类商品券在同类商品价格数组里的开始位置
|
||||
export function returnProCoupStartIndex(coupArr,index){
|
||||
return coupArr.slice(0,index).reduce((prve,cur)=>{
|
||||
return prve+cur.num*1
|
||||
},0)
|
||||
}
|
||||
//返回商品数量从0到n每一个对应的价格对照表
|
||||
export function returnGoodsPayPriceMap(goodsArr){
|
||||
return goodsArr.reduce((prve,cur)=>{
|
||||
if(!prve.hasOwnProperty(cur.productId)){
|
||||
prve[cur.productId]=[]
|
||||
}
|
||||
const arr=new Array(cur.num).fill(cur).map(v=>{
|
||||
return {
|
||||
memberPrice:v.memberPrice?v.memberPrice:v.price,
|
||||
price:v.price
|
||||
}
|
||||
})
|
||||
prve[cur.productId].push(...arr)
|
||||
return prve
|
||||
},{})
|
||||
}
|
||||
//计算商品券总优惠价格
|
||||
export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||
if (coupArr.length == 0) {
|
||||
return 0;
|
||||
}
|
||||
//商品分组
|
||||
const goodsMap={}
|
||||
//商品数量从0到n每一个对应的价格
|
||||
const goodsPayPriceMap={}
|
||||
//商品券分组
|
||||
let coupMap={}
|
||||
for(let i in coupArr){
|
||||
const coup=coupArr[i]
|
||||
if(coupMap.hasOwnProperty(coup.proId)){
|
||||
coupMap[coup.proId].push(coup)
|
||||
}else{
|
||||
coupMap[coup.proId]=[coup]
|
||||
}
|
||||
}
|
||||
let total=0
|
||||
for(let key in coupMap){
|
||||
const arr=coupMap[key]
|
||||
for(let i in arr){
|
||||
const coup=arr[i]
|
||||
if(!goodsMap.hasOwnProperty(coup.proId)){
|
||||
goodsMap[coup.proId]=goodsArr.filter(v=>v.productId==coup.proId).map(v=>{
|
||||
return {
|
||||
...v,
|
||||
payPrice:returnProductPayPrice(v,vipUser)
|
||||
}
|
||||
}).sort((a,b)=>{
|
||||
const aPrice=a.payPrice
|
||||
const bPrice=b.payPrice
|
||||
return aPrice-bPrice
|
||||
})
|
||||
goodsPayPriceMap[coup.proId]=goodsMap[coup.proId].reduce((prve,cur)=>{
|
||||
const arr=new Array(cur.num).fill(cur.payPrice)
|
||||
console.log(arr);
|
||||
prve.push(...arr)
|
||||
return prve
|
||||
},[])
|
||||
}
|
||||
const proCoupStartIndex=returnProCoupStartIndex(arr,i)
|
||||
console.log(proCoupStartIndex);
|
||||
total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coup.num)
|
||||
}
|
||||
}
|
||||
|
||||
return total.toFixed(2);
|
||||
|
||||
}
|
||||
//计算满减券总优惠价格
|
||||
export function returnFullReductionCouponAllPrice(coupArr) {
|
||||
if (coupArr.length == 0) {
|
||||
return 0;
|
||||
}
|
||||
return coupArr.filter(v => v.type == 1).reduce((a, b) => {
|
||||
const price = b.discountAmount
|
||||
return a + price;
|
||||
}, 0).toFixed(2);
|
||||
|
||||
}
|
||||
//计算优惠券总价格
|
||||
export function returnCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||
const poductAllprice = returnProductCouponAllPrice(coupArr, goodsArr, vipUser)
|
||||
const pointAllPrice = returnFullReductionCouponAllPrice(coupArr)
|
||||
return (poductAllprice * 1 + pointAllPrice * 1).toFixed(2);
|
||||
}
|
||||
|
||||
//返回当前满减券列表可用状态
|
||||
export function returnCanUseFullReductionCoupon(coupArr, payPrice, selCoup) {
|
||||
return coupArr.map(v => {
|
||||
if (v.id == selCoup.id) {
|
||||
return v
|
||||
}
|
||||
const isfullAmount = payPrice >= v.fullAmount * 1
|
||||
return {
|
||||
...v,
|
||||
use: v.use && isfullAmount
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ export function returnProductCouponPrice(coup, goodsArr, vipUser) {
|
|||
}
|
||||
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
||||
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0;
|
||||
return price
|
||||
return price*coup.num
|
||||
|
||||
}
|
||||
//返回新的商品列表,过滤掉退菜的,退单的商品
|
||||
|
|
@ -139,8 +139,28 @@ export function returnNewGoodsList(arr) {
|
|||
let goodsMap={}
|
||||
return arr.filter(v => !isTui(v))
|
||||
}
|
||||
//根据当前购物车商品以及数量,已选券对应商品数量,判断该商品券是否可用
|
||||
export function returnCoupCanUse(goodsArr=[],coup,selCoupArr=[]) {
|
||||
if(!coup.use){
|
||||
return false
|
||||
}
|
||||
const findGoods=goodsArr.filter(v=>v.productId==coup.proId)
|
||||
if(!findGoods.length){
|
||||
return false
|
||||
}
|
||||
const findGoodsTotalNumber=findGoods.reduce((prve,cur)=>{
|
||||
return prve+cur.num*1
|
||||
},0)
|
||||
const selCoupNumber=selCoupArr.filter(v=>v.proId==coup.proId).reduce((prve,cur)=>{
|
||||
return prve+cur.num*1
|
||||
},0)
|
||||
if(selCoupNumber>=findGoodsTotalNumber){
|
||||
return false
|
||||
}
|
||||
return findGoodsTotalNumber<(coup.num+selCoupNumber)?false:true
|
||||
}
|
||||
//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
|
||||
export function returnProductCoupon(coup, goodsArr, vipUser) {
|
||||
export function returnProductCoupon(coup, goodsArr, vipUser,selCoupArr=[]) {
|
||||
const newGoodsArr = returnNewGoodsList(goodsArr)
|
||||
const item = newGoodsArr.find(v => v.productId == coup.proId);
|
||||
if(!item){
|
||||
|
|
@ -148,8 +168,11 @@ export function returnProductCoupon(coup, goodsArr, vipUser) {
|
|||
}
|
||||
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
||||
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0;
|
||||
const canUse=!v.use?false:(discountAmount>0)
|
||||
return { ...coup, discountAmount: price,use:canUse}
|
||||
const discountAmount=(price*coup.num).toFixed(2)
|
||||
console.log(discountAmount);
|
||||
const canUse=!coup.use?false:(discountAmount>0&&returnCoupCanUse(goodsArr,coup,selCoupArr))
|
||||
// const canUse=discountAmount>0
|
||||
return { ...coup, discountAmount: discountAmount,use:canUse}
|
||||
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,25 +19,28 @@
|
|||
下载会员充值二维码
|
||||
</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>
|
||||
允许充值自定义金额:<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="minNum"></el-table-column>
|
||||
<el-table-column label="最大金额" prop="maxNum"></el-table-column>
|
||||
<el-table-column label="赠送金额" prop="handselNum"></el-table-column>
|
||||
<el-table-column label="赠送类型" prop="handselType">
|
||||
<el-table-column label="充值金额" prop="amount"></el-table-column>
|
||||
<el-table-column label="赠送金额" prop="giftAmount"></el-table-column>
|
||||
<!-- <el-table-column label="赠送金额" prop="handselNum"></el-table-column>
|
||||
<el-table-column label="是否使用优惠券" prop="isUseCoupon">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.handselType | handselTypeFilter }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="排序" sortable prop="sort"></el-table-column> -->
|
||||
<el-table-column label="是否启用" prop="isDel">
|
||||
</el-table-column>
|
||||
<el-table-column label="排序" sortable prop="sort"></el-table-column> -->
|
||||
<el-table-column label="赠送积分" prop="giftPoints"></el-table-column>
|
||||
<el-table-column label="是否使用优惠券" prop="isUseCoupon">
|
||||
<template v-slot="scope">
|
||||
<el-switch v-model="scope.row.isDel" active-value="0" inactive-value="1"
|
||||
@change="statusChange($event, scope.row)"></el-switch>
|
||||
<!-- <el-switch v-model="scope.row.isUseCoupon" :active-value="1" :inactive-value="0"
|
||||
@change="statusChange($event, scope.row)" disabled></el-switch> -->
|
||||
{{ scope.row.isUseCoupon == 1 ? '是':'否'}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120">
|
||||
|
|
@ -65,7 +68,7 @@
|
|||
import handselTypes from './handselTypes'
|
||||
import addActive from './components/addActive'
|
||||
import QR from './components/downloadQR.vue'
|
||||
import { findActivate, modityActivate } from '@/api/shop'
|
||||
import { findActivate, storageupActivate } from '@/api/shop'
|
||||
import { tbShopInfo, tbShopInfoPut } from "@/api/user";
|
||||
import dayjs from 'dayjs'
|
||||
export default {
|
||||
|
|
@ -104,16 +107,27 @@ export default {
|
|||
methods: {
|
||||
// 切换状态
|
||||
async statusChange(e, row) {
|
||||
try {
|
||||
this.tableData.loading = true
|
||||
const data = { ...row }
|
||||
data.status = e
|
||||
await modityActivate(data)
|
||||
this.getTableData()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
this.tableData.loading = false
|
||||
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() {
|
||||
|
|
@ -151,7 +165,7 @@ export default {
|
|||
}
|
||||
|
||||
console.log(this.shopInfo);
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,25 @@
|
|||
<div>
|
||||
<el-dialog :title="form.id ? '编辑活动' : '添加活动'" :visible.sync="dialogVisible" @close="reset">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="left">
|
||||
<el-form-item label="最小金额">
|
||||
<el-form-item label="充值">
|
||||
<template>
|
||||
<div style="display: flex;">
|
||||
<el-input style="width: 220px;" placeholder="请输入金额" v-model="form.amount"
|
||||
@input="(v) => (form.amount = v.replace(/^(0+)|[^\d]+/g, ''))">
|
||||
<template slot="prepend">满</template>
|
||||
<template slot="append">元</template>
|
||||
</el-input>
|
||||
<el-input style="margin-left: 20px; width: 220px;" placeholder="请输入金额"
|
||||
v-model="form.giftAmount"
|
||||
@input="(v) => (form.giftAmount = v.replace(/^(0+)|[^\d]+/g, ''))">
|
||||
<template slot="prepend">赠</template>
|
||||
<template slot="append">元</template>
|
||||
</el-input>
|
||||
</div>
|
||||
</template>
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="最小金额">
|
||||
<el-input-number v-model="form.minNum" controls-position="right" :min="1"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="最大金额">
|
||||
|
|
@ -11,32 +29,46 @@
|
|||
<el-form-item label="赠送金额">
|
||||
<el-input-number v-model="form.handselNum" controls-position="right" :min="0"></el-input-number>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="赠送类型">
|
||||
<el-form-item label="赠送类型">
|
||||
<el-select v-model="form.handselType">
|
||||
<el-option :label="item.label" :value="item.value" v-for="item in handselTypes"
|
||||
:key="item.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-switch v-model="form.isDel" active-value="0" inactive-value="1"></el-switch>
|
||||
</el-form-item> -->
|
||||
|
||||
<el-form-item label="是否使用优惠券">
|
||||
<el-switch v-model="form.isUseCoupon" :active-value="1" :inactive-value="0"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否赠送商品">
|
||||
<el-switch v-model="form.isGiftPro" :active-value="1" :inactive-value="0"></el-switch>
|
||||
<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="赠送商品">
|
||||
<el-form-item label="积分">
|
||||
<template>
|
||||
<div class="labelboxss">
|
||||
<div>赠送</div>
|
||||
<el-input style="width: 140px;margin: 0 15px;" v-model="form.giftPoints"></el-input>
|
||||
<div>积分</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择优惠劵" v-if="form.isUseCoupon == 1">
|
||||
<div>
|
||||
<el-button type="primary" icon="el-icon-plus" @click="$refs.shopListRef.show([...productIds])">
|
||||
添加商品
|
||||
<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="item.id">
|
||||
<div class="name">{{ item.name }}</div>
|
||||
<el-input style="width: 120px;" v-model="item.num" placeholder='请填写数量'
|
||||
@input="checkIfNum(item)"></el-input>
|
||||
<el-button type="text" @click="productIds.splice(index, 1)"
|
||||
style="margin-left: 20px;">删除</el-button>
|
||||
<div class="name">{{ item.title }}</div>
|
||||
<!-- <el-input style="width: 120px;" v-model="item.num" placeholder='请填写数量'
|
||||
@input="checkIfNum(item)"></el-input> -->
|
||||
<!-- <el-button type="text" @click="productIds.splice(index, 1)"
|
||||
style="margin-left: 20px;">删除</el-button> -->
|
||||
<el-button type="text" @click="productIds = []" style="margin-left: 20px;">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
|
@ -46,18 +78,18 @@
|
|||
<el-button type="primary" :loading="loading" @click="onSubmitHandle">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<shopList ref="shopListRef" @success="slectShop" />
|
||||
<coupon ref="coupon" @success="slectShop" />
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import handselTypes from '../handselTypes'
|
||||
import { modityActivate, activate } from '@/api/shop'
|
||||
import shopList from '@/components/shopList'
|
||||
import { activate, storageupActivate } from '@/api/shop'
|
||||
import coupon from '@/components/coupon'
|
||||
|
||||
export default {
|
||||
components: { shopList },
|
||||
components: { coupon },
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
|
|
@ -70,7 +102,10 @@ export default {
|
|||
maxNum: 1,
|
||||
handselNum: 1, // 打印类型
|
||||
handselType: 'GD',
|
||||
isDel: '0'
|
||||
isDel: '0',
|
||||
num: 1,
|
||||
amount: '',
|
||||
giftAmount: ''
|
||||
},
|
||||
productIds: [],
|
||||
resetForm: '',
|
||||
|
|
@ -97,15 +132,16 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
slectShop(res) {
|
||||
if (this.productIds.length) {
|
||||
res.map(async item => {
|
||||
if (!await this.checkShop(item.id)) {
|
||||
this.productIds.push({ ...item })
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.productIds = 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) {
|
||||
|
|
@ -125,21 +161,41 @@ export default {
|
|||
this.form.config.categoryList = e
|
||||
},
|
||||
onSubmitHandle() {
|
||||
// console.log(this.form)
|
||||
let arr = []
|
||||
this.productIds.forEach(ele => {
|
||||
arr.push({
|
||||
productId: ele.id,
|
||||
num: ele.num
|
||||
})
|
||||
})
|
||||
this.form.products = arr
|
||||
console.log(this.form)
|
||||
if (this.form.amount == '') {
|
||||
this.$message({
|
||||
message: '充值金额不能为空',
|
||||
type: 'warning'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (this.form.isUseCoupon == 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
|
||||
this.form.shopId = localStorage.getItem('shopId')
|
||||
let res = await modityActivate(this.form)
|
||||
let res = await storageupActivate(this.form)
|
||||
this.$emit('success', res)
|
||||
this.close()
|
||||
this.$notify({
|
||||
|
|
@ -156,12 +212,17 @@ export default {
|
|||
})
|
||||
},
|
||||
async show(obj) {
|
||||
this.productIds = []
|
||||
this.dialogVisible = true
|
||||
if (obj && obj.id) {
|
||||
this.form = { ...obj }
|
||||
let res = await activate(obj.id)
|
||||
this.productIds = res
|
||||
console.log(res, '调试1')
|
||||
// 留着以后说不定多个优惠劵
|
||||
// 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() {
|
||||
|
|
@ -174,6 +235,35 @@ export default {
|
|||
}
|
||||
</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;
|
||||
|
|
|
|||
|
|
@ -25,13 +25,14 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
show() {
|
||||
this.isshow = true
|
||||
this.getlist()
|
||||
},
|
||||
async getlist() {
|
||||
let res = await getwxacode({
|
||||
shopId: localStorage.getItem('shopId')
|
||||
})
|
||||
this.isshow = true
|
||||
|
||||
this.imgUrl = res
|
||||
}, downImg() {
|
||||
// window.location.href()
|
||||
|
|
|
|||
Loading…
Reference in New Issue