|
@@ -12,7 +12,7 @@
|
|
|
<br>
|
|
|
<br>
|
|
|
<span style="font-size: 14px; line-height: 40px">面值总额:¥{{ $numberFormat(totalPrice) }}</span>
|
|
|
- <span style="margin-left: 80px;font-size: 14px; line-height: 40px">优惠券数量:{{ couponPkgItemList.length }}</span>
|
|
|
+ <span style="margin-left: 80px;font-size: 14px; line-height: 40px">优惠券数量:{{ totalCouponNum }}</span>
|
|
|
<el-table :data="couponPkgItemList">
|
|
|
<el-table-column label="券编号" prop="couponId" align="center" />
|
|
|
<el-table-column label="券名称" prop="title" />
|
|
@@ -35,6 +35,7 @@
|
|
|
controls-position="right"
|
|
|
:min="1"
|
|
|
size="small"
|
|
|
+ @change="changeCouponNum"
|
|
|
></el-input-number>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -46,7 +47,7 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column v-if="!readonly" prop="date" label="操作" align="center">
|
|
|
<template slot-scope="{ $index }">
|
|
|
- <el-button type="text" class="del" @click="couponPkgItemList.splice($index, 1);getPrice()">删除</el-button>
|
|
|
+ <el-button type="text" class="del" @click="couponPkgItemList.splice($index, 1);getPrice();getCouponNum()">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -65,6 +66,7 @@
|
|
|
<script>
|
|
|
import { couponPkgCreate, couponPkgDetail, couponPkgUpdate } from "@/api/business/couponPkg";
|
|
|
import CouponAdd from "./components/CouponAdd"
|
|
|
+import { accMul } from '@/utils/util'
|
|
|
export default {
|
|
|
components: {
|
|
|
CouponAdd
|
|
@@ -77,6 +79,7 @@ export default {
|
|
|
couponTableVisible: false,
|
|
|
couponPkgItemList: [],
|
|
|
totalPrice: 0,
|
|
|
+ totalCouponNum: 0,
|
|
|
addIng: false,
|
|
|
rules: {
|
|
|
title: [{ required: true, message: '请输入券包名称', trigger: 'blur' }]
|
|
@@ -86,9 +89,10 @@ export default {
|
|
|
created() {
|
|
|
if(this.id) {
|
|
|
couponPkgDetail(this.id).then(res => {
|
|
|
- const { couponPkgItemVOList, facePrice, title } = res.data
|
|
|
+ const { couponPkgItemVOList, facePrice, title, couponNum } = res.data
|
|
|
this.addData = { title }
|
|
|
this.totalPrice = facePrice
|
|
|
+ this.totalCouponNum = couponNum
|
|
|
this.couponPkgItemList = couponPkgItemVOList.map(item => {
|
|
|
return {
|
|
|
... item,
|
|
@@ -102,16 +106,30 @@ export default {
|
|
|
confirmCoupon(arr) {
|
|
|
this.couponPkgItemList = this.couponPkgItemList.concat(arr)
|
|
|
this.getPrice()
|
|
|
+ this.getCouponNum()
|
|
|
+ },
|
|
|
+
|
|
|
+ changeCouponNum() {
|
|
|
+ this.getPrice()
|
|
|
+ this.getCouponNum()
|
|
|
},
|
|
|
|
|
|
getPrice() {
|
|
|
let num = 0
|
|
|
this.couponPkgItemList.forEach(item => {
|
|
|
- num = item.discount + num
|
|
|
+ num = (accMul(item.discount, item.couponNum)) + num
|
|
|
})
|
|
|
this.totalPrice = num
|
|
|
},
|
|
|
|
|
|
+ getCouponNum() {
|
|
|
+ let num = 0
|
|
|
+ this.couponPkgItemList.forEach(item => {
|
|
|
+ num = item.couponNum + num
|
|
|
+ })
|
|
|
+ this.totalCouponNum = num
|
|
|
+ },
|
|
|
+
|
|
|
update() {
|
|
|
const subForm = this.$refs["addItem"];
|
|
|
subForm.validate((valid) => {
|
|
@@ -125,7 +143,7 @@ export default {
|
|
|
title: this.addData.title,
|
|
|
couponPkgItemList: this.couponPkgItemList,
|
|
|
facePrice: this.totalPrice,
|
|
|
- couponNum: this.couponPkgItemList.length
|
|
|
+ couponNum: this.totalCouponNum
|
|
|
}
|
|
|
if(this.id){
|
|
|
data.id = this.id
|