|
|
@ -20,7 +20,7 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="line req"> |
|
|
|
<view class="line req"> |
|
|
|
<view class="name">使用期限</view> |
|
|
|
<view class="name">使用期限</view> |
|
|
|
<input class="period" type="number" v-model="item.periodOfUse" placeholder="请输入" @change="calcDate(item, !item.authority)"> |
|
|
|
<input class="period" type="number" v-model="item.periodOfUse" placeholder="请输入" @input="calcDate(item, !item.authority)"> |
|
|
|
<view class="val unit" @click="showUnit(i)"> |
|
|
|
<view class="val unit" @click="showUnit(i)"> |
|
|
|
<text>{{ units.find(e => e.value === item.options).text }}</text> |
|
|
|
<text>{{ units.find(e => e.value === item.options).text }}</text> |
|
|
|
<image class="icon" src="@/static/image/arrow-down.png" mode="widthFix"></image> |
|
|
|
<image class="icon" src="@/static/image/arrow-down.png" mode="widthFix"></image> |
|
|
@ -40,7 +40,7 @@ |
|
|
|
<view class="line req"> |
|
|
|
<view class="line req"> |
|
|
|
<view class="name">数量</view> |
|
|
|
<view class="name">数量</view> |
|
|
|
<view v-if="item.authority" class="val">1</view> |
|
|
|
<view v-if="item.authority" class="val">1</view> |
|
|
|
<input v-else type="number" v-model="item.accountNum" placeholder="请输入" @change="calcFinalPrice(item)"> |
|
|
|
<input v-else type="number" v-model="item.accountNum" placeholder="请输入" @input="calcFinalPrice(item)"> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="line"> |
|
|
|
<view class="line"> |
|
|
|
<view class="name">{{ item.authority ? '市场价' : '市场单价' }}</view> |
|
|
|
<view class="name">{{ item.authority ? '市场价' : '市场单价' }}</view> |
|
|
@ -61,7 +61,7 @@ |
|
|
|
<view class="line req"> |
|
|
|
<view class="line req"> |
|
|
|
<view class="name">成交价</view> |
|
|
|
<view class="name">成交价</view> |
|
|
|
<view class="inline"> |
|
|
|
<view class="inline"> |
|
|
|
<input type="number" v-model="item.finalPrice" placeholder="请输入" @change="calcFinalValue(item)"> |
|
|
|
<input type="number" v-model="item.finalPrice" placeholder="请输入" @input="calcFinalValue(item)"> |
|
|
|
元 |
|
|
|
元 |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -82,6 +82,7 @@ |
|
|
|
data() { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
return { |
|
|
|
customerId: '', |
|
|
|
customerId: '', |
|
|
|
|
|
|
|
timer: null, |
|
|
|
units: [{ |
|
|
|
units: [{ |
|
|
|
text: '日', |
|
|
|
text: '日', |
|
|
|
value: 0 |
|
|
|
value: 0 |
|
|
@ -154,7 +155,6 @@ |
|
|
|
} catch (e) {} |
|
|
|
} catch (e) {} |
|
|
|
}, |
|
|
|
}, |
|
|
|
showUnit(i) { |
|
|
|
showUnit(i) { |
|
|
|
console.log(333, this.$refs, this.$refs.unit[i].show) |
|
|
|
|
|
|
|
this.$refs.unit[i].show() |
|
|
|
this.$refs.unit[i].show() |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 收缩产品 |
|
|
|
// 收缩产品 |
|
|
@ -173,121 +173,139 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 使用期限转换以及计算剩余天数 |
|
|
|
// 使用期限转换以及计算剩余天数 |
|
|
|
calcDate(row, fromData) { |
|
|
|
calcDate(row, fromData) { |
|
|
|
const { periodOfUse, options } = row |
|
|
|
clearTimeout(this.timer) |
|
|
|
let optionsData = 0 |
|
|
|
this.timer = setTimeout(() => { |
|
|
|
if (periodOfUse) { |
|
|
|
const { periodOfUse, options } = row |
|
|
|
if (options == 1){ |
|
|
|
let optionsData = 0 |
|
|
|
optionsData = periodOfUse === '12' ? 31536000000 : periodOfUse*30*24*60*60*1000 |
|
|
|
if (periodOfUse) { |
|
|
|
} else if (options == 2){ |
|
|
|
if (options == 1){ |
|
|
|
optionsData = periodOfUse*365*24*60*60*1000 |
|
|
|
optionsData = periodOfUse === '12' ? 31536000000 : periodOfUse*30*24*60*60*1000 |
|
|
|
} else { |
|
|
|
} else if (options == 2){ |
|
|
|
optionsData = periodOfUse*24*60*60*1000 |
|
|
|
optionsData = periodOfUse*365*24*60*60*1000 |
|
|
|
} |
|
|
|
} else { |
|
|
|
} |
|
|
|
optionsData = periodOfUse*24*60*60*1000 |
|
|
|
let time = new Date(row.startTime).getTime() |
|
|
|
|
|
|
|
let endTime = time + optionsData |
|
|
|
|
|
|
|
row.endTime = time + optionsData |
|
|
|
|
|
|
|
let dt = new Date(endTime) |
|
|
|
|
|
|
|
row.endTime = (dt.getFullYear()) + "-" + (dt.getMonth() + 1) + "-" + (dt.getDate()) |
|
|
|
|
|
|
|
let endYear = endTime - time |
|
|
|
|
|
|
|
let endYears = endYear/1000/60/60/24 |
|
|
|
|
|
|
|
row.remainingPeriod = endYears |
|
|
|
|
|
|
|
const unit = row.options // 使用期限单位 |
|
|
|
|
|
|
|
const useUnit = row.periodOfUse // 使用期限 |
|
|
|
|
|
|
|
// 计算市场价 |
|
|
|
|
|
|
|
const price = row.marketPrice // 市场单价 |
|
|
|
|
|
|
|
// 结算单价是元/年,所以如果选择的不是年,要进行换算(日:/365,月:/12) |
|
|
|
|
|
|
|
row.marketValue = (!unit ? |
|
|
|
|
|
|
|
price / 365 * useUnit : |
|
|
|
|
|
|
|
unit === 1 ? |
|
|
|
|
|
|
|
price / 12 * useUnit : |
|
|
|
|
|
|
|
price * useUnit).toFixed(2) |
|
|
|
|
|
|
|
this.dealSettlePrice(row) |
|
|
|
|
|
|
|
// 只有改变了起止日期才需要调接口查询订单,该接口作用是把开始时间传过去,会返回一个提示或者时间,如果是时间,则把时间+1天,如果是提示,则无法保存 |
|
|
|
|
|
|
|
if (!fromData) { |
|
|
|
|
|
|
|
const cId = row.dataOrCourseId |
|
|
|
|
|
|
|
const date = new Date(row.startTime) |
|
|
|
|
|
|
|
const orderRepeat = this.orderRepeat |
|
|
|
|
|
|
|
getOrderOtherTime({ |
|
|
|
|
|
|
|
customerId: this.customerId, |
|
|
|
|
|
|
|
id: cId, |
|
|
|
|
|
|
|
startTime: this.$util.formatDate(date, 'yyyy-MM-dd'), |
|
|
|
|
|
|
|
endTime: row.endTime |
|
|
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
|
|
orderRepeat.includes(cId) && orderRepeat.splice(orderRepeat.findIndex(e => e === cId), 1) |
|
|
|
|
|
|
|
if (res.endTime) { |
|
|
|
|
|
|
|
let time = new Date(res.endTime) |
|
|
|
|
|
|
|
time = new Date(time.setDate(time.getDate() + 1)) |
|
|
|
|
|
|
|
row.startTime = this.$util.formatDate(time, 'yyyy-MM-dd') |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}).catch(res => { |
|
|
|
} |
|
|
|
this.repeatMsg = res.message |
|
|
|
let time = new Date(row.startTime).getTime() |
|
|
|
orderRepeat.includes(cId) || orderRepeat.push(cId) |
|
|
|
let endTime = time + optionsData |
|
|
|
}) |
|
|
|
row.endTime = time + optionsData |
|
|
|
} |
|
|
|
let dt = new Date(endTime) |
|
|
|
// 折扣率 |
|
|
|
row.endTime = (dt.getFullYear()) + "-" + (dt.getMonth() + 1) + "-" + (dt.getDate()) |
|
|
|
this.calcDiscount(row) |
|
|
|
let endYear = endTime - time |
|
|
|
|
|
|
|
let endYears = endYear/1000/60/60/24 |
|
|
|
|
|
|
|
row.remainingPeriod = endYears |
|
|
|
|
|
|
|
const unit = row.options // 使用期限单位 |
|
|
|
|
|
|
|
const useUnit = row.periodOfUse // 使用期限 |
|
|
|
|
|
|
|
// 计算市场价 |
|
|
|
|
|
|
|
const price = row.marketPrice // 市场单价 |
|
|
|
|
|
|
|
// 结算单价是元/年,所以如果选择的不是年,要进行换算(日:/365,月:/12) |
|
|
|
|
|
|
|
row.marketValue = (!unit ? |
|
|
|
|
|
|
|
price / 365 * useUnit : |
|
|
|
|
|
|
|
unit === 1 ? |
|
|
|
|
|
|
|
price / 12 * useUnit : |
|
|
|
|
|
|
|
price * useUnit).toFixed(2) |
|
|
|
|
|
|
|
this.dealSettlePrice(row) |
|
|
|
|
|
|
|
// 只有改变了起止日期才需要调接口查询订单,该接口作用是把开始时间传过去,会返回一个提示或者时间,如果是时间,则把时间+1天,如果是提示,则无法保存 |
|
|
|
|
|
|
|
if (!fromData) { |
|
|
|
|
|
|
|
const cId = row.dataOrCourseId |
|
|
|
|
|
|
|
const date = new Date(row.startTime) |
|
|
|
|
|
|
|
const orderRepeat = this.orderRepeat |
|
|
|
|
|
|
|
getOrderOtherTime({ |
|
|
|
|
|
|
|
customerId: this.customerId, |
|
|
|
|
|
|
|
id: cId, |
|
|
|
|
|
|
|
startTime: this.$util.formatDate(date, 'yyyy-MM-dd'), |
|
|
|
|
|
|
|
endTime: row.endTime |
|
|
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
|
|
orderRepeat.includes(cId) && orderRepeat.splice(orderRepeat.findIndex(e => e === cId), 1) |
|
|
|
|
|
|
|
if (res.endTime) { |
|
|
|
|
|
|
|
let time = new Date(res.endTime) |
|
|
|
|
|
|
|
time = new Date(time.setDate(time.getDate() + 1)) |
|
|
|
|
|
|
|
row.startTime = this.$util.formatDate(time, 'yyyy-MM-dd') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).catch(res => { |
|
|
|
|
|
|
|
this.repeatMsg = res.message |
|
|
|
|
|
|
|
orderRepeat.includes(cId) || orderRepeat.push(cId) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 折扣率 |
|
|
|
|
|
|
|
this.calcDiscount(row) |
|
|
|
|
|
|
|
}, 500) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 计算结算价及平台服务费 |
|
|
|
// 计算结算价及平台服务费 |
|
|
|
dealSettlePrice(row) { |
|
|
|
dealSettlePrice(row) { |
|
|
|
const unit = row.options // 使用期限单位 |
|
|
|
console.log(33, row) |
|
|
|
const useUnit = row.periodOfUse // 使用期限 |
|
|
|
clearTimeout(this.timer) |
|
|
|
let sPrice = '' |
|
|
|
this.timer = setTimeout(() => { |
|
|
|
if (row.settlementMethod == 0) { |
|
|
|
const unit = row.options // 使用期限单位 |
|
|
|
// 结算单价。计算规则:结算单价(**元/年)*购买时长(单位年)*数量(课程为1,数据为账号数量) |
|
|
|
const useUnit = row.periodOfUse // 使用期限 |
|
|
|
const priceUnit = row.settlementPriceUnit |
|
|
|
let sPrice = '' |
|
|
|
sPrice = ((!unit ? |
|
|
|
if (row.settlementMethod == 0) { |
|
|
|
priceUnit / 365 * useUnit : |
|
|
|
// 结算单价。计算规则:结算单价(**元/年)*购买时长(单位年)*数量(课程为1,数据为账号数量) |
|
|
|
unit === 1 ? |
|
|
|
const priceUnit = row.settlementPriceUnit |
|
|
|
priceUnit / 12 * useUnit : |
|
|
|
sPrice = ((!unit ? |
|
|
|
priceUnit * useUnit) * (row.authority ? |
|
|
|
priceUnit / 365 * useUnit : |
|
|
|
1 : |
|
|
|
unit === 1 ? |
|
|
|
row.accountNum)).toFixed((2)) |
|
|
|
priceUnit / 12 * useUnit : |
|
|
|
} else { |
|
|
|
priceUnit * useUnit) * (row.authority ? |
|
|
|
// 比例分成。计算规则:成交价*商务分成比例 |
|
|
|
1 : |
|
|
|
sPrice = (row.finalPrice * row.businessProportion / 100).toFixed((2)) |
|
|
|
row.accountNum)).toFixed((2)) |
|
|
|
} |
|
|
|
} else { |
|
|
|
row.settlementPrice = this.$util.handleNaN(sPrice) |
|
|
|
// 比例分成。计算规则:成交价*商务分成比例 |
|
|
|
// 平台服务费(结算价*10%) |
|
|
|
sPrice = (row.finalPrice * row.businessProportion / 100).toFixed((2)) |
|
|
|
if (row.settlementPrice) { |
|
|
|
} |
|
|
|
row.serviceFee = (row.settlementPrice * 0.1).toFixed(2) |
|
|
|
row.settlementPrice = this.$util.handleNaN(sPrice) |
|
|
|
} |
|
|
|
// 平台服务费(结算价*10%) |
|
|
|
|
|
|
|
if (row.settlementPrice) { |
|
|
|
|
|
|
|
row.serviceFee = (row.settlementPrice * 0.1).toFixed(2) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, 500) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 计算折扣率 |
|
|
|
// 计算折扣率 |
|
|
|
calcDiscount(row) { |
|
|
|
calcDiscount(row) { |
|
|
|
const price = row.authority ? row.finalPrice : row.finalValue |
|
|
|
clearTimeout(this.timer) |
|
|
|
const { marketValue } = row |
|
|
|
this.timer = setTimeout(() => { |
|
|
|
// (原价-现价)÷原价 x100% |
|
|
|
const price = row.authority ? row.finalPrice : row.finalValue |
|
|
|
if (price) row.discountRate = marketValue != 0 ? ((marketValue - price) / marketValue * 100).toFixed(2) + '%' : '0%' |
|
|
|
const { marketValue } = row |
|
|
|
|
|
|
|
console.log(66, row) |
|
|
|
|
|
|
|
// (原价-现价)÷原价 x100% |
|
|
|
|
|
|
|
if (price) row.discountRate = marketValue != 0 ? ((marketValue - price) / marketValue * 100).toFixed(2) + '%' : '0%' |
|
|
|
|
|
|
|
}, 500) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 成交价修改后,计算成交单价,数据才需要 计算规则:成交价/账号数/时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算) |
|
|
|
// 成交价修改后,计算成交单价,数据才需要 计算规则:成交价/账号数/时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算) |
|
|
|
calcFinalValue(row) { |
|
|
|
calcFinalValue(row) { |
|
|
|
const { authority, periodOfUse, options, accountNum, finalPrice } = row |
|
|
|
clearTimeout(this.timer) |
|
|
|
if (!authority && periodOfUse && accountNum && finalPrice) { |
|
|
|
this.timer = setTimeout(() => { |
|
|
|
row.finalValue = (finalPrice / accountNum / periodOfUse).toFixed(2) |
|
|
|
const { authority, periodOfUse, options, accountNum, finalPrice } = row |
|
|
|
} |
|
|
|
if (!authority && periodOfUse && accountNum && finalPrice) { |
|
|
|
// 折扣率 |
|
|
|
row.finalValue = (finalPrice / accountNum / periodOfUse).toFixed(2) |
|
|
|
this.calcDiscount(row) |
|
|
|
} |
|
|
|
|
|
|
|
// 折扣率 |
|
|
|
|
|
|
|
this.calcDiscount(row) |
|
|
|
|
|
|
|
this.dealSettlePrice(row) |
|
|
|
|
|
|
|
}, 500) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 计算成交价。计算规则:成交单价*账号数*时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算) |
|
|
|
// 计算成交价。计算规则:成交单价*账号数*时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算) |
|
|
|
calcFinalPrice(row) { |
|
|
|
calcFinalPrice(row) { |
|
|
|
const { finalValue, accountNum, periodOfUse, finalPrice } = row |
|
|
|
clearTimeout(this.timer) |
|
|
|
if (periodOfUse) { |
|
|
|
this.timer = setTimeout(() => { |
|
|
|
if (accountNum) { |
|
|
|
const { finalValue, accountNum, periodOfUse, finalPrice } = row |
|
|
|
// 有成交单价,则成交价=成交单价*账号数*时间 |
|
|
|
if (periodOfUse) { |
|
|
|
if (finalValue) { |
|
|
|
if (accountNum) { |
|
|
|
row.finalPrice = Math.round(finalValue * periodOfUse * accountNum) |
|
|
|
// 有成交单价,则成交价=成交单价*账号数*时间 |
|
|
|
} else if (!finalValue && finalPrice) { |
|
|
|
if (finalValue) { |
|
|
|
// 有成交价,没有成交单价,则成交单价=成交价/账号数/时间 |
|
|
|
row.finalPrice = Math.round(finalValue * periodOfUse * accountNum) |
|
|
|
row.finalValue = (finalPrice / periodOfUse / accountNum).toFixed(2) |
|
|
|
} else if (!finalValue && finalPrice) { |
|
|
|
this.calculateDiscount(e, row) |
|
|
|
// 有成交价,没有成交单价,则成交单价=成交价/账号数/时间 |
|
|
|
} |
|
|
|
row.finalValue = (finalPrice / periodOfUse / accountNum).toFixed(2) |
|
|
|
} else if (finalValue && finalValue && !row.authority) { |
|
|
|
this.calculateDiscount(e, row) |
|
|
|
// 有成交价、成交单价,没有数量,则数量=成交价/时间/成交单价 |
|
|
|
} |
|
|
|
row.accountNum = Math.floor(finalPrice / periodOfUse / finalValue) |
|
|
|
} else if (finalValue && finalValue && !row.authority) { |
|
|
|
|
|
|
|
// 有成交价、成交单价,没有数量,则数量=成交价/时间/成交单价 |
|
|
|
|
|
|
|
row.accountNum = Math.floor(finalPrice / periodOfUse / finalValue) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.dealSettlePrice(row) |
|
|
|
this.dealSettlePrice(row) |
|
|
|
}, 500) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 确定 |
|
|
|
// 确定 |
|
|
|
submit() { |
|
|
|
submit() { |
|
|
|