|
|
|
@ -9,7 +9,7 @@ |
|
|
|
|
</view> |
|
|
|
|
<view :class="['line req', {err: err === 'customerName'}]"> |
|
|
|
|
<view class="name">客户名称</view> |
|
|
|
|
<view v-if="isDetail" class="val">{{ form.customerName }}</view> |
|
|
|
|
<view v-if="orderId" class="val">{{ form.customerName }}</view> |
|
|
|
|
<view v-else :class="['ph', {val: form.customerName}]" @click="customerVisible = true">{{ form.customerName || '请选择客户' }}</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
@ -52,46 +52,55 @@ |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
<template v-for="c in courseList"> |
|
|
|
|
<template v-for="(c, n) in courseList"> |
|
|
|
|
<view v-if="c.list.length" class="block pro-wrap" id="products"> |
|
|
|
|
<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" @click.stop="editCourse(c, i)"> |
|
|
|
|
<view class="name"> |
|
|
|
|
<view class="left"> |
|
|
|
|
<image class="icon" :src="$util.getIcon(item)" mode="widthFix"></image> |
|
|
|
|
{{ item.productName }} |
|
|
|
|
</view> |
|
|
|
|
<image v-if="!isDetail" class="del" src="@/static/image/trash.png" mode="widthFix" @click.stop="delCourse(c, i)"></image> |
|
|
|
|
</view> |
|
|
|
|
<view class="info"> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">使用期限</view> |
|
|
|
|
<view class="val">{{ item.startTime + ' - ' + item.endTime }}</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">市场价(元)</view> |
|
|
|
|
<view class="val">{{ item.marketValue }}元</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">结算价</view> |
|
|
|
|
<view class="val">{{ item.settlementPrice }}元</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">折扣率</view> |
|
|
|
|
<view class="val">{{ item.discountRate }}</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<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> |
|
|
|
|
</view> |
|
|
|
|
</li> |
|
|
|
|
<uni-swipe-action> |
|
|
|
|
<uni-swipe-action-item |
|
|
|
|
v-for="(item, i) in c.list" |
|
|
|
|
:threshold="0" |
|
|
|
|
:right-options="item.ops" |
|
|
|
|
@click="e => productHandle(e, n, i)" |
|
|
|
|
> |
|
|
|
|
<li @click.stop="editCourse(c, i)"> |
|
|
|
|
<view class="name"> |
|
|
|
|
<view class="left"> |
|
|
|
|
<image class="icon" :src="$util.getIcon(item)" mode="widthFix"></image> |
|
|
|
|
{{ item.productName }} |
|
|
|
|
</view> |
|
|
|
|
<image v-if="!isDetail && !isEdit" class="del" src="@/static/image/trash.png" mode="widthFix" @click.stop="delCourse(c, i)"></image> |
|
|
|
|
</view> |
|
|
|
|
<view class="info"> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">使用期限</view> |
|
|
|
|
<view class="val">{{ item.startTime + ' - ' + item.endTime }}</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">市场价(元)</view> |
|
|
|
|
<view class="val">{{ item.marketValue }}元</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">结算价</view> |
|
|
|
|
<view class="val">{{ item.settlementPrice }}元</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">折扣率</view> |
|
|
|
|
<view class="val">{{ item.discountRate }}</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<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> |
|
|
|
|
</view> |
|
|
|
|
</li> |
|
|
|
|
</uni-swipe-action-item> |
|
|
|
|
</uni-swipe-action> |
|
|
|
|
</ul> |
|
|
|
|
</view> |
|
|
|
|
</template> |
|
|
|
@ -137,11 +146,14 @@ |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import { queryCustomer, queryCustomerDetails } from '@/apis/modules/client.js' |
|
|
|
|
import { add, update, getDetail } from '@/apis/modules/order.js' |
|
|
|
|
import { add, update, getDetail, renew, ship } from '@/apis/modules/order.js' |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
isDetail: false, |
|
|
|
|
isEdit: 0, // 编辑 |
|
|
|
|
isHandle: 0, // 处理 |
|
|
|
|
isRenew: 0, // 续费 |
|
|
|
|
orderId: '', |
|
|
|
|
orderTypes: [{ |
|
|
|
|
text: '正式', |
|
|
|
@ -186,7 +198,8 @@ |
|
|
|
|
searchTimer: null, |
|
|
|
|
customerList: [], |
|
|
|
|
customerListAll: [], |
|
|
|
|
err: '' |
|
|
|
|
err: '', |
|
|
|
|
promises: [], |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
@ -202,6 +215,9 @@ |
|
|
|
|
const { options } = pages[pages.length - 1] |
|
|
|
|
this.orderId = options.orderId |
|
|
|
|
this.isDetail = !!options.show |
|
|
|
|
this.isEdit = options.text === '修改' |
|
|
|
|
this.isHandle = options.text === '处理' |
|
|
|
|
this.isRenew = options.text === '续费' |
|
|
|
|
const store = uni.getStorageSync('courses') |
|
|
|
|
if (this.orderId) { |
|
|
|
|
this.getInfo() |
|
|
|
@ -231,9 +247,7 @@ |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
// 非详情才需要查询客户 |
|
|
|
|
if (!this.isDetail) { |
|
|
|
|
this.getCustomer() |
|
|
|
|
} |
|
|
|
|
this.isDetail || this.getCustomer() |
|
|
|
|
// 设置标题 |
|
|
|
|
uni.setNavigationBarTitle({ |
|
|
|
|
title: this.orderId ? |
|
|
|
@ -253,12 +267,17 @@ |
|
|
|
|
orderId: this.orderId |
|
|
|
|
}).then(({ orderDetails }) => { |
|
|
|
|
const order = orderDetails |
|
|
|
|
this.contract = order.contractInformation |
|
|
|
|
if (!this.isRenew) this.contract = order.contractInformation // 非续费才回显合同 |
|
|
|
|
this.form = order.order |
|
|
|
|
this.courses = order.orderOther |
|
|
|
|
this.handleProduct(order.orderOther) |
|
|
|
|
this.calcTotal() |
|
|
|
|
uni.hideLoading() |
|
|
|
|
this.handleRenew(0) |
|
|
|
|
this.handleRenew(1) |
|
|
|
|
this.handleRenew(2) |
|
|
|
|
Promise.all(this.promises).then(_ => { |
|
|
|
|
this.handleProduct(this.courses) |
|
|
|
|
this.calcTotal() |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}) |
|
|
|
|
}).catch(e => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}) |
|
|
|
@ -294,6 +313,68 @@ |
|
|
|
|
}) |
|
|
|
|
this.courseList = courses |
|
|
|
|
}, |
|
|
|
|
// 处理开始结束时间和订单状态 |
|
|
|
|
handleRenew(authority) { |
|
|
|
|
const productId = this.courses.filter(e => e.authority == authority).map(e => e.dataOrCourseId) |
|
|
|
|
productId.length && this.promises.push(new Promise((resolve, reject) => { |
|
|
|
|
renew({ |
|
|
|
|
authority, |
|
|
|
|
customerId: this.form.customerId, |
|
|
|
|
productId |
|
|
|
|
}).then(({ orderOthers }) => { |
|
|
|
|
const { courses } = this |
|
|
|
|
const now = new Date() |
|
|
|
|
orderOthers.map(e => { |
|
|
|
|
const item = courses.find(n => n.dataOrCourseId == e.dataOrCourseId && n.authority == authority && e.authority == authority) |
|
|
|
|
if (item) { |
|
|
|
|
if (this.isRenew) { // 续费 |
|
|
|
|
let date = new Date(e.endTime) |
|
|
|
|
if (now < date) { // 没过期,则返回的结束日期+1天作为开始时间 |
|
|
|
|
date = new Date(date.setDate(date.getDate() + 1)) |
|
|
|
|
item.startTime = this.$util.formatDate(date, 'yyyy-MM-dd') |
|
|
|
|
console.log(444, item, now < date,date,e.startTime) |
|
|
|
|
} else { // 过期了则当前日期作为开始时间 |
|
|
|
|
item.startTime = this.$util.formatDate(now, 'yyyy-MM-dd') |
|
|
|
|
} |
|
|
|
|
item.endTime = '' |
|
|
|
|
item.periodOfUse = '' |
|
|
|
|
item.marketValue = e.marketValue |
|
|
|
|
} else if (!this.isDetail) { // 如果不是查看 |
|
|
|
|
item.startTime = e.startTime.split(' ')[0] |
|
|
|
|
item.endTime = e.endTime.split(' ')[0] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const startTime = new Date(item.startTime) |
|
|
|
|
const endTime = new Date(item.endTime) |
|
|
|
|
// 1: 未生效,2:生效中,3:已过期 |
|
|
|
|
item.status = now < startTime ? |
|
|
|
|
1 : |
|
|
|
|
now > startTime && now < endTime ? |
|
|
|
|
2 : |
|
|
|
|
3 |
|
|
|
|
if (item.status === 3) item.isEnable = 0 // 已过期的,变成禁用状态,且不能启用 |
|
|
|
|
|
|
|
|
|
// 1、查看时不可操作 |
|
|
|
|
// 2、发货和启用不要同时出现,生效前只会显示发货不发货按钮,生效后只显示禁启用按钮 |
|
|
|
|
// 3、处理中的订单显示发货,不显示禁用 |
|
|
|
|
this.$set(item, 'ops', this.isDetail ? |
|
|
|
|
[] : |
|
|
|
|
[{ |
|
|
|
|
text: item.status === 1 || this.isHandle || !this.orderId ? |
|
|
|
|
item.ship ? '取消发货' : '发货' : |
|
|
|
|
item.isEnable ? '禁用' : '启用', |
|
|
|
|
style: { |
|
|
|
|
backgroundColor: '#34b3fd' |
|
|
|
|
} |
|
|
|
|
}], |
|
|
|
|
) |
|
|
|
|
}) |
|
|
|
|
resolve() |
|
|
|
|
}).catch(e => { |
|
|
|
|
reject() |
|
|
|
|
}) |
|
|
|
|
})) |
|
|
|
|
}, |
|
|
|
|
// 获取客户列表 |
|
|
|
|
getCustomer() { |
|
|
|
|
queryCustomer({ |
|
|
|
@ -354,7 +435,7 @@ |
|
|
|
|
if (this.isDetail) return false |
|
|
|
|
uni.setStorageSync('courses', this.courses) |
|
|
|
|
const { customerId, orderType } = this.form |
|
|
|
|
this.$util.to(`../editCourse/editCourse?orderType=${orderType}&customerId=${customerId}`) |
|
|
|
|
this.$util.to(`../editCourse/editCourse?orderType=${orderType}&customerId=${customerId}&action=${this.isEdit ? 'edit' : this.isRenew ? 'renew' : this.isHandle ? 'handle' : !this.orderId ? 'add' : ''}`) |
|
|
|
|
}, |
|
|
|
|
// 删除课程 |
|
|
|
|
delCourse(c, i) { |
|
|
|
@ -382,6 +463,22 @@ |
|
|
|
|
toggle(c) { |
|
|
|
|
c.shrink = !c.shrink |
|
|
|
|
}, |
|
|
|
|
// 产品发货和启用处理 |
|
|
|
|
productHandle(e, n, i) { |
|
|
|
|
const row = this.courseList[n].list[i] |
|
|
|
|
const { text } = e.content |
|
|
|
|
if (text === '发货' || text === '取消发货') { |
|
|
|
|
row.ship = text === '发货' ? 1 : 0 |
|
|
|
|
this.isEdit && ship(row).then(res => {}).catch(res => {}) |
|
|
|
|
row.ops[0].text = text === '发货' ? '取消发货' : '发货' |
|
|
|
|
console.log(444, row.ops) |
|
|
|
|
} else { |
|
|
|
|
row.isEnable = text === '启用' ? 1 : 0 |
|
|
|
|
row.ops[0].text = text === '启用' ? '禁用' : '启用' |
|
|
|
|
} |
|
|
|
|
this.courseList[n].list[i] = row |
|
|
|
|
console.log(111,row, this.courseList) |
|
|
|
|
}, |
|
|
|
|
// 计算订单总额 |
|
|
|
|
calcTotal(out) { |
|
|
|
|
this.handleErr('orderType') |
|
|
|
@ -426,7 +523,8 @@ |
|
|
|
|
}, |
|
|
|
|
// 提交 |
|
|
|
|
submit() { |
|
|
|
|
const { form, courses } = this |
|
|
|
|
const { form } = this |
|
|
|
|
const courses = [] |
|
|
|
|
if (!form.customerId) { |
|
|
|
|
this.err = 'customerName' |
|
|
|
|
return this.$util.errMsg('请选择客户!') |
|
|
|
@ -435,10 +533,14 @@ |
|
|
|
|
this.err = 'orderType' |
|
|
|
|
return this.$util.errMsg('请选择订单类型!') |
|
|
|
|
} |
|
|
|
|
for (const i in this.courseList) { |
|
|
|
|
courses.push(...this.courseList[i].list) |
|
|
|
|
} |
|
|
|
|
if (!courses.length) return this.$util.errMsg('请选择课程权限或数据权限后再确认订单!') |
|
|
|
|
courses.map(e => { |
|
|
|
|
e.startTime = this.$util.formatDate(new Date(e.startTime), 'yyyy-MM-dd') |
|
|
|
|
}) |
|
|
|
|
if (this.isRenew || courses.some(e => e.renew)) form.orderNature = 2 |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '提交中' |
|
|
|
|
}) |
|
|
|
|