Commit 980999b4 by chenxin

fix: wm券号

parent 836a887b
......@@ -123,7 +123,8 @@ export default {
wmShopIds: [], // 保存过的店铺id不能重复选择
countFlag: 0, // 微盟店铺 0不能使用 1只能添加1条 2能添加多条
weimobShopList: [], // 微盟店铺list
weimobDemoCodeList: [{ pid: '', card: '', loading: false, cardList: [], save: false, cardName: '' }] // 保存的微盟店铺以及对应的微盟券号 {pid:xxxx,card:xxxx,loading:false, cardList: [], save: false, name: ''}
weimobDemoCodeList: [{ pid: '', card: '', loading: false, cardList: [], save: false, cardName: '' }], // 保存的微盟店铺以及对应的微盟券号 {pid:xxxx,card:xxxx,loading:false, cardList: [], save: false, name: ''}
cardValidity: false // 卡券有效期是否禁用
};
},
watch: {
......@@ -769,6 +770,41 @@ export default {
this.$message({ message: '该条券号保存不完整', type: 'warning' });
return;
}
const now = this.weimobDemoCodeList[idx].cardList.find(v => v.cardTemplateId == this.weimobDemoCodeList[idx].card);
if (idx > 0) {
// 与上一个进行比较
const before = this.weimobDemoCodeList[idx - 1].cardList.find(v => v.cardTemplateId == this.weimobDemoCodeList[idx - 1].card);
// (1:固定类型;2:动态类型;3:永久有效)
try {
if (before.expireDateType != now.expireDateType) {
throw new Error();
} else {
if (before.expireDateType == 1 && before.startDate != now.startDate || before.expireDate != now.expireDate) {
throw new Error();
}
if (before.expireDateType == 2 && before.startDayCount != now.startDayCount || before.expDayCount != now.expDayCount) {
throw new Error();
}
}
} catch (error) {
// 清空该行数据
this.weimobDemoCodeList[idx].card = '';
this.$message({ message: '微盟卡券有效期不一致', type: 'warning' });
return;
}
} else {
// 第一个把默认值放入
if (now.expireDateType == 1) {
this.form.cardEffectiveMode = 0;
this.form.dateTime = [now.startDate, now.expireDate];
}
if (now.expireDateType == 2) {
this.form.cardEffectiveMode = 1;
this.form.startDay = now.startDayCount;
this.form.limitDay = now.expDayCount;
}
this.cardValidity = true; // 禁用有效期
}
this.weimobDemoCodeList[idx].save = true;
this.weimobDemoCodeList[idx].name = saveItem.cardList.find(v => {
return v.cardTemplateId == saveItem.card;
......@@ -784,6 +820,10 @@ export default {
this.weimobDemoCodeList.splice(idx, 1);
if (this.weimobDemoCodeList.length === 0) {
this.addWmShop();
this.cardValidity = false;
this.form.dateTime = [,];
this.form.startDay = '';
this.form.limitDay = '';
}
},
addWmShop() {
......@@ -799,23 +839,20 @@ export default {
},
// 第一层店铺change 根据微盟店铺id查询所有店铺卡券 wmPid=xxx
handleShopChange(wmPid, idx) {
if (wmPid) {
this.weimobDemoCodeList[idx].loading = true;
listEntepriseWeimobCoupon({ wmPid })
.then(res => {
this.weimobDemoCodeList[idx].cardList = res.result || [];
this.weimobDemoCodeList[idx].loading = false;
if (this.weimobDemoCodeList[idx].cardList.length === 0) {
this.$message({ message: '该店铺没有对应微盟券号', type: 'warning' });
}
})
.catch(() => {
this.weimobDemoCodeList[idx].loading = false;
});
} else {
this.weimobDemoCodeList[idx].cardList = [];
this.weimobDemoCodeList[idx].card = '';
}
this.weimobDemoCodeList[idx].cardList = [];
this.weimobDemoCodeList[idx].card = '';
this.weimobDemoCodeList[idx].loading = true;
listEntepriseWeimobCoupon({ wmPid })
.then(res => {
this.weimobDemoCodeList[idx].cardList = res.result || [];
this.weimobDemoCodeList[idx].loading = false;
if (this.weimobDemoCodeList[idx].cardList.length === 0) {
this.$message({ message: '该店铺没有对应微盟券号', type: 'warning' });
}
})
.catch(() => {
this.weimobDemoCodeList[idx].loading = false;
});
},
// ---------微盟店铺结束--------
// ------微盟适用商品开始-------
......
......@@ -42,7 +42,7 @@
</el-select>
<template v-if="isAdd || isCopy">
<el-button type="text" v-if="!saveItem.save" class="ml10" @click="saveWmShop(saveItem, idx)">保存</el-button>
<el-button type="text" v-if="saveItem.save" class="ml10" @click="delWmShop(saveItem, idx)">删除</el-button>
<el-button type="text" class="ml10" @click="delWmShop(saveItem, idx)">删除</el-button>
</template>
</div>
<template v-if="isAdd || isCopy">
......@@ -197,15 +197,15 @@
<el-form-item class="is-required" prop="useCustomCode" label="有效期">
<div>
<el-radio v-model="form.cardEffectiveMode" :disabled="isEdit || isInfo" :label="0">固定日期</el-radio>
<el-date-picker v-model="form.dateTime" @focus="form.cardEffectiveMode = 0" :disabled="isEdit || isInfo" :picker-options="pickerOptions" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
<el-radio v-model="form.cardEffectiveMode" :disabled="isEdit || isInfo || cardValidity" :label="0">固定日期</el-radio>
<el-date-picker v-model="form.dateTime" @focus="form.cardEffectiveMode = 0" :disabled="isEdit || isInfo || cardValidity" :picker-options="pickerOptions" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</div>
<div class="pt20">
<el-radio v-model="form.cardEffectiveMode" :label="1" :disabled="isEdit || isInfo">领取后,</el-radio>
<el-select v-model="form.startDay" @focus="form.cardEffectiveMode = 1" class="w200" placeholder="请选择" :disabled="isEdit || isInfo">
<el-radio v-model="form.cardEffectiveMode" :label="1" :disabled="isEdit || isInfo || cardValidity">领取后,</el-radio>
<el-select v-model="form.startDay" @focus="form.cardEffectiveMode = 1" class="w200" placeholder="请选择" :disabled="isEdit || isInfo || cardValidity">
<el-option v-for="item in startDayOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
生效,有效天数 <el-input-number controls-position="right" class="w200" @focus="form.cardEffectiveMode = 1" :disabled="isEdit || isInfo" v-model="form.limitDay" :precision="0" :min="1" :max="isEdit || isInfo ? 100000000 : 99"></el-input-number>
生效,有效天数 <el-input-number controls-position="right" class="w200" @focus="form.cardEffectiveMode = 1" :disabled="isEdit || isInfo || cardValidity" v-model="form.limitDay" :precision="0" :min="1" :max="isEdit || isInfo ? 100000000 : 99"></el-input-number>
</div>
</el-form-item>
......
......@@ -129,7 +129,8 @@ export default {
writeOffBeginTime: '',
writeOffEndTime: '',
sortBy: '',
showSelfFlag: ''
showSelfFlag: '',
coupCardId: this.$route.query.coupCardId
},
total: 0,
cardOrderShow: false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment