|
|
|
@ -63,7 +63,8 @@ |
|
|
|
|
<view class="l-title">{{ c.name }}</view> |
|
|
|
|
<uni-icons class="arrow" type="top" size="20" color="#007EFF" @click="toggle(c)"></uni-icons> |
|
|
|
|
<ul class="pro-list" v-show="!c.shrink"> |
|
|
|
|
<li v-for="(item, i) in c.list" :key="i" @click.stop="editCourse(c, i)"> |
|
|
|
|
<!-- <li v-for="(item, i) in c.list" :key="i" @click.stop="editCourse(c, i)"> --> |
|
|
|
|
<li v-for="(item, i) in c.list" :key="i"> |
|
|
|
|
<view class="name"> |
|
|
|
|
<view class="left"> |
|
|
|
|
<image class="icon" :src="$util.getIcon(item)" mode="widthFix"></image> |
|
|
|
@ -78,18 +79,44 @@ |
|
|
|
|
<image v-if="!orderId || isRenew" class="del" src="@/static/image/trash.png" mode="widthFix" @click.stop="delCourse(c, i)"></image> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
<view class="info"> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">起始日期</view> |
|
|
|
|
<!-- <view class="val">{{ item.startTime + (item.endTime && ' - ' + item.endTime) }}</view> --> |
|
|
|
|
<view v-if="!isHandle">{{ item.endTime ? item.startTime + ' - ' + item.endTime : item.startTime}}</view> |
|
|
|
|
<uni-datetime-picker v-else type="date" v-model="item.startTime" :border="false" @change="calcDate(item)"> |
|
|
|
|
<view :class="['ph', {val: item.startTime}]"> |
|
|
|
|
{{ item.endTime ? item.startTime + ' - ' + item.endTime : item.startTime}} |
|
|
|
|
</view> |
|
|
|
|
</uni-datetime-picker> |
|
|
|
|
</view> |
|
|
|
|
<view class="line" :class="[ {err: err === 'periodOfUse' + item.dataOrCourseId + item.authority}]"> |
|
|
|
|
<view class="label">使用期限</view> |
|
|
|
|
<view class="val">{{ item.startTime + (item.endTime && ' - ' + item.endTime) }}</view> |
|
|
|
|
<input v-if="isHandle" class="period" type="number" v-model="item.periodOfUse" placeholder="请输入" :disabled="!isHandle" @input="calcDate(item, !item.authority)" @change="handleErr(item, 'periodOfUse')"> |
|
|
|
|
<view v-if="!isHandle" class="defaultBox">{{item.periodOfUse}}{{ units.find(e => e.id === item.options).text }}</view> |
|
|
|
|
|
|
|
|
|
<view v-else class="val unit" @click="selectUnit(item)"> |
|
|
|
|
<text>{{ units.find(e => e.id === item.options).text }}</text> |
|
|
|
|
<image class="icon" src="@/static/image/arrow-down.png" mode="widthFix"></image> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view :class="['line req', {err: err === 'accountNum' + item.dataOrCourseId + item.authority}]"> |
|
|
|
|
<view class="label">数量</view> |
|
|
|
|
<view v-if="item.authority" class="val">1</view> |
|
|
|
|
<input v-else type="number" v-model="item.accountNum" placeholder="请输入账号数量" @input="calcFinalPrice(item)" @change="handleErr(item, 'accountNum')"> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">市场价(元)</view> |
|
|
|
|
<view class="label">{{ item.authority ? '市场价' : '市场单价' }}</view> |
|
|
|
|
<view class="val">{{ item.marketValue || 0 }}元</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">结算价</view> |
|
|
|
|
<view class="val">{{ item.settlementPrice }}元</view> |
|
|
|
|
<view v-if="!isHandle" class="defaultBox">{{ item.settlementPrice }}</view> |
|
|
|
|
<view class="inline" v-else> |
|
|
|
|
<input type="number" v-model="item.settlementPrice" placeholder="请输入" @change="handleErr(item, 'settlementPrice')" @input="updateServiceFee(item)"> |
|
|
|
|
元 |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">折扣率</view> |
|
|
|
@ -99,9 +126,13 @@ |
|
|
|
|
<view class="label">平台服务费</view> |
|
|
|
|
<view class="val">{{ item.serviceFee }}元</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line done"> |
|
|
|
|
<view class="val">成交价格</view> |
|
|
|
|
<view class="price">{{ item.finalPrice }}元</view> |
|
|
|
|
<view :class="['line req', {err: err === 'finalPrice' + item.dataOrCourseId + item.authority}]"> |
|
|
|
|
<view class="label">成交价</view> |
|
|
|
|
<view v-if="!isHandle" class="defaultBox">{{ item.finalPrice }}</view> |
|
|
|
|
<view class="inline" v-else> |
|
|
|
|
<input type="number" v-model="item.finalPrice" placeholder="请输入" :disabled="isEdit && !item.authority" @input="calcFinalValue(item)" @change="handleErr(item, 'finalPrice')"> |
|
|
|
|
元 |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</li> |
|
|
|
@ -142,11 +173,11 @@ |
|
|
|
|
<view v-if="isDetail" class="action"> |
|
|
|
|
<template v-if="form.isDel !== 1"> |
|
|
|
|
<template v-if="form.orderStatus === 1"> |
|
|
|
|
<view class="item" @click="toAction(`../orderDetail/orderDetail?orderId=${orderId}&action=edit`)"> |
|
|
|
|
<view class="item" v-if="auth('订单管理:修改')" @click="toAction(`../orderDetail/orderDetail?orderId=${orderId}&action=edit`)"> |
|
|
|
|
<uni-icons class="icon" custom-prefix="iconfont" type="icon-edit" size="30" color="#959595"></uni-icons> |
|
|
|
|
<view class="text">修改</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="item" @click="toAction(`../orderDetail/orderDetail?orderId=${orderId}&action=renew`)"> |
|
|
|
|
<view class="item" v-if="auth('订单管理:续费')" @click="toAction(`../orderDetail/orderDetail?orderId=${orderId}&action=renew`)"> |
|
|
|
|
<uni-icons class="icon" custom-prefix="iconfont" type="icon-product" size="30" color="#959595"></uni-icons> |
|
|
|
|
<view class="text">续费</view> |
|
|
|
|
</view> |
|
|
|
@ -178,6 +209,7 @@ |
|
|
|
|
import { queryCustomer, queryCustomerDetails } from '@/apis/modules/client.js' |
|
|
|
|
import { add, update, del, getDetail, renew, ship, miniProgramOrderRecord, bulkShipping } from '@/apis/modules/order.js' |
|
|
|
|
import { teamList, getAllTeam } from '@/apis/modules/parner.js' |
|
|
|
|
import { getOrderOtherTime } from '@/apis/modules/order.js' |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
@ -193,6 +225,7 @@ |
|
|
|
|
text: '试用', |
|
|
|
|
value: 2 |
|
|
|
|
}], |
|
|
|
|
|
|
|
|
|
form: { |
|
|
|
|
businessManagerId: '', |
|
|
|
|
businessManagerName: '', |
|
|
|
@ -234,6 +267,18 @@ |
|
|
|
|
customerListAll: [], |
|
|
|
|
err: '', |
|
|
|
|
promises: [], |
|
|
|
|
orderRepeat:[], |
|
|
|
|
units: [{ |
|
|
|
|
text: '日', |
|
|
|
|
id: 0 |
|
|
|
|
}, { |
|
|
|
|
text: '月', |
|
|
|
|
id: 1 |
|
|
|
|
}, { |
|
|
|
|
text: '年', |
|
|
|
|
id: 2 |
|
|
|
|
}], |
|
|
|
|
unitText: ['日', '月', '年'], |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
@ -675,6 +720,158 @@ |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
calcDate(row, fromData) { |
|
|
|
|
clearTimeout(this.timer) |
|
|
|
|
this.timer = setTimeout(() => { |
|
|
|
|
const { periodOfUse, options } = row |
|
|
|
|
let optionsData = 0 |
|
|
|
|
if (periodOfUse) { |
|
|
|
|
if (options == 1){ |
|
|
|
|
optionsData = periodOfUse === '12' ? 31536000000 : periodOfUse*30*24*60*60*1000 |
|
|
|
|
} else if (options == 2){ |
|
|
|
|
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 |
|
|
|
|
orderRepeat.includes(cId) || orderRepeat.push(cId) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
// 折扣率 |
|
|
|
|
this.calcDiscount(row) |
|
|
|
|
}, 500) |
|
|
|
|
}, |
|
|
|
|
dealSettlePrice(row) { |
|
|
|
|
// 如果是试用,结算价和平台服务费都是0 |
|
|
|
|
if (this.orderType == 2) { |
|
|
|
|
row.settlementPrice = 0 |
|
|
|
|
row.serviceFee = 0 |
|
|
|
|
} else { |
|
|
|
|
const unit = row.options // 使用期限单位 |
|
|
|
|
const useUnit = row.periodOfUse // 使用期限 |
|
|
|
|
let sPrice = '' |
|
|
|
|
if (row.settlementMethod == 0) { |
|
|
|
|
// 结算单价。计算规则:结算单价(**元/年)*购买时长(单位年)*数量(课程为1,数据为账号数量) |
|
|
|
|
const priceUnit = row.settlementPriceUnit |
|
|
|
|
sPrice = ((!unit ? |
|
|
|
|
priceUnit / 365 * useUnit : |
|
|
|
|
unit === 1 ? |
|
|
|
|
priceUnit / 12 * useUnit : |
|
|
|
|
priceUnit * useUnit) * (row.authority ? |
|
|
|
|
1 : |
|
|
|
|
row.accountNum)).toFixed((2)) |
|
|
|
|
} else { |
|
|
|
|
// 比例分成。计算规则:成交价*商务分成比例 |
|
|
|
|
sPrice = (row.finalPrice * row.businessProportion / 100).toFixed((2)) |
|
|
|
|
} |
|
|
|
|
row.settlementPrice = this.$util.handleNaN(sPrice) |
|
|
|
|
// 平台服务费(结算价*10%) |
|
|
|
|
console.log('row.settlementPrice =>' ,row.settlementPrice) |
|
|
|
|
if (row.settlementPrice) { |
|
|
|
|
console.log(2222) |
|
|
|
|
row.serviceFee = (row.settlementPrice * 0.1).toFixed(2) |
|
|
|
|
}else { |
|
|
|
|
console.log(1111111) |
|
|
|
|
row.serviceFee = 0 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
calcDiscount(row) { |
|
|
|
|
const price = row.authority ? row.finalPrice : row.finalValue |
|
|
|
|
const { marketValue } = row |
|
|
|
|
// (原价-现价)÷原价 x100% |
|
|
|
|
if (price) row.discountRate = marketValue != 0 ? ((marketValue - price) / marketValue * 100).toFixed(2) + '%' : '0%' |
|
|
|
|
}, |
|
|
|
|
selectUnit(item) { |
|
|
|
|
const that = this |
|
|
|
|
uni.showActionSheet({ |
|
|
|
|
title: '标题', |
|
|
|
|
itemList: that.unitText, |
|
|
|
|
success: ({ tapIndex }) => { |
|
|
|
|
item.options = tapIndex |
|
|
|
|
that.calcDate(item) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 成交价修改后,计算成交单价,数据才需要 计算规则:成交价/账号数/时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算) |
|
|
|
|
calcFinalValue(row) { |
|
|
|
|
clearTimeout(this.timer) |
|
|
|
|
this.timer = setTimeout(() => { |
|
|
|
|
const { authority, periodOfUse, options, accountNum, finalPrice } = row |
|
|
|
|
if (!authority && periodOfUse && accountNum && finalPrice) { |
|
|
|
|
row.finalValue = (finalPrice / accountNum / periodOfUse).toFixed(2) |
|
|
|
|
} |
|
|
|
|
// 折扣率 |
|
|
|
|
this.calcDiscount(row) |
|
|
|
|
this.dealSettlePrice(row) |
|
|
|
|
}, 500) |
|
|
|
|
}, |
|
|
|
|
// 计算成交价。计算规则:成交单价*账号数*时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算) |
|
|
|
|
calcFinalPrice(row) { |
|
|
|
|
clearTimeout(this.timer) |
|
|
|
|
this.timer = setTimeout(() => { |
|
|
|
|
const { finalValue, accountNum, periodOfUse, finalPrice } = row |
|
|
|
|
if (periodOfUse) { |
|
|
|
|
if (accountNum) { |
|
|
|
|
// 有成交单价,则成交价=成交单价*账号数*时间 |
|
|
|
|
if (finalValue) { |
|
|
|
|
row.finalPrice = Math.round(finalValue * periodOfUse * accountNum) |
|
|
|
|
} else if (!finalValue && finalPrice) { |
|
|
|
|
// 有成交价,没有成交单价,则成交单价=成交价/账号数/时间 |
|
|
|
|
row.finalValue = (finalPrice / periodOfUse / accountNum).toFixed(2) |
|
|
|
|
this.calcDiscount(row) |
|
|
|
|
} |
|
|
|
|
} else if (finalValue && finalPrice && !row.authority) { |
|
|
|
|
// 有成交价、成交单价,没有数量,则数量=成交价/时间/成交单价 |
|
|
|
|
row.accountNum = Math.floor(finalPrice / periodOfUse / finalValue) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.dealSettlePrice(row) |
|
|
|
|
}, 500) |
|
|
|
|
}, |
|
|
|
|
// 结算价修改后计算平台服务费 |
|
|
|
|
updateServiceFee(options) { |
|
|
|
|
options.serviceFee = (options.settlementPrice * 0.1).toFixed(2) |
|
|
|
|
console.log('options===>',options) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -715,6 +912,7 @@ |
|
|
|
|
.left { |
|
|
|
|
display: inline-flex; |
|
|
|
|
align-items: center; |
|
|
|
|
max-width: 480rpx; |
|
|
|
|
} |
|
|
|
|
.course-action { |
|
|
|
|
display: inline-flex; |
|
|
|
@ -865,4 +1063,42 @@ |
|
|
|
|
background-color: #007EFF; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.unit { |
|
|
|
|
display: inline-flex; |
|
|
|
|
align-items: center; |
|
|
|
|
.icon { |
|
|
|
|
width: 28rpx; |
|
|
|
|
margin-left: 20rpx; |
|
|
|
|
} |
|
|
|
|
input { |
|
|
|
|
font-size: 28rpx; |
|
|
|
|
} |
|
|
|
|
text{ |
|
|
|
|
font-size: 28rpx; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.line { |
|
|
|
|
.inline { |
|
|
|
|
display: flex; |
|
|
|
|
align-items: center; |
|
|
|
|
font-size: 28rpx; |
|
|
|
|
input { |
|
|
|
|
text-align: right; |
|
|
|
|
margin-right: 10rpx; |
|
|
|
|
margin-left: 20rpx; |
|
|
|
|
color: #333; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.period{ |
|
|
|
|
display: inline-block; |
|
|
|
|
text-align: right; |
|
|
|
|
margin-right: 10rpx; |
|
|
|
|
margin-left: 20rpx; |
|
|
|
|
color: #333; |
|
|
|
|
width: 60%;font-size: 28rpx; |
|
|
|
|
} |
|
|
|
|
.defaultBox { |
|
|
|
|
font-size: 28rpx; |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|