优惠卷
This commit is contained in:
@@ -52,18 +52,18 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择优惠劵">
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
@@ -75,7 +75,7 @@
|
||||
<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>
|
||||
@@ -83,12 +83,10 @@
|
||||
<script>
|
||||
import handselTypes from '../handselTypes'
|
||||
import { activate, storageupActivate } from '@/api/shop'
|
||||
import { queryReceive } from '@/api/coupon'
|
||||
|
||||
import shopList from '@/components/shopList'
|
||||
import coupon from '@/components/coupon'
|
||||
|
||||
export default {
|
||||
components: { shopList },
|
||||
components: { coupon },
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
@@ -131,15 +129,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) {
|
||||
@@ -167,6 +166,16 @@ export default {
|
||||
});
|
||||
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
|
||||
}
|
||||
// let arr = []
|
||||
// this.productIds.forEach(ele => {
|
||||
// arr.push({
|
||||
@@ -174,7 +183,6 @@ export default {
|
||||
// num: ele.num
|
||||
// })
|
||||
// })
|
||||
// this.form.products = arr
|
||||
this.$refs.form.validate(async valid => {
|
||||
if (valid) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user