|
|
@ -9,7 +9,7 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view :class="['line req', {err: err === 'customerName'}]"> |
|
|
|
<view :class="['line req', {err: err === 'customerName'}]"> |
|
|
|
<view class="name">客户名称</view> |
|
|
|
<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 v-else :class="['ph', {val: form.customerName}]" @click="customerVisible = true">{{ form.customerName || '请选择客户' }}</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="line"> |
|
|
|
<view class="line"> |
|
|
@ -52,18 +52,25 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</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 v-if="c.list.length" class="block pro-wrap" id="products"> |
|
|
|
<view class="l-title">{{ c.name }}</view> |
|
|
|
<view class="l-title">{{ c.name }}</view> |
|
|
|
<uni-icons class="arrow" type="top" size="20" color="#007EFF" @click="toggle(c)"></uni-icons> |
|
|
|
<uni-icons class="arrow" type="top" size="20" color="#007EFF" @click="toggle(c)"></uni-icons> |
|
|
|
<ul class="pro-list" v-show="!c.shrink"> |
|
|
|
<ul class="pro-list" v-show="!c.shrink"> |
|
|
|
<li v-for="(item, i) in c.list" @click.stop="editCourse(c, i)"> |
|
|
|
<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="name"> |
|
|
|
<view class="left"> |
|
|
|
<view class="left"> |
|
|
|
<image class="icon" :src="$util.getIcon(item)" mode="widthFix"></image> |
|
|
|
<image class="icon" :src="$util.getIcon(item)" mode="widthFix"></image> |
|
|
|
{{ item.productName }} |
|
|
|
{{ item.productName }} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<image v-if="!isDetail" class="del" src="@/static/image/trash.png" mode="widthFix" @click.stop="delCourse(c, i)"></image> |
|
|
|
<image v-if="!isDetail && !isEdit" class="del" src="@/static/image/trash.png" mode="widthFix" @click.stop="delCourse(c, i)"></image> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="info"> |
|
|
|
<view class="info"> |
|
|
|
<view class="line"> |
|
|
|
<view class="line"> |
|
|
@ -92,6 +99,8 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</li> |
|
|
|
</li> |
|
|
|
|
|
|
|
</uni-swipe-action-item> |
|
|
|
|
|
|
|
</uni-swipe-action> |
|
|
|
</ul> |
|
|
|
</ul> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
</template> |
|
|
@ -137,11 +146,14 @@ |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
<script> |
|
|
|
import { queryCustomer, queryCustomerDetails } from '@/apis/modules/client.js' |
|
|
|
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 { |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
return { |
|
|
|
isDetail: false, |
|
|
|
isDetail: false, |
|
|
|
|
|
|
|
isEdit: 0, // 编辑 |
|
|
|
|
|
|
|
isHandle: 0, // 处理 |
|
|
|
|
|
|
|
isRenew: 0, // 续费 |
|
|
|
orderId: '', |
|
|
|
orderId: '', |
|
|
|
orderTypes: [{ |
|
|
|
orderTypes: [{ |
|
|
|
text: '正式', |
|
|
|
text: '正式', |
|
|
@ -186,7 +198,8 @@ |
|
|
|
searchTimer: null, |
|
|
|
searchTimer: null, |
|
|
|
customerList: [], |
|
|
|
customerList: [], |
|
|
|
customerListAll: [], |
|
|
|
customerListAll: [], |
|
|
|
err: '' |
|
|
|
err: '', |
|
|
|
|
|
|
|
promises: [], |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
watch: { |
|
|
@ -202,6 +215,9 @@ |
|
|
|
const { options } = pages[pages.length - 1] |
|
|
|
const { options } = pages[pages.length - 1] |
|
|
|
this.orderId = options.orderId |
|
|
|
this.orderId = options.orderId |
|
|
|
this.isDetail = !!options.show |
|
|
|
this.isDetail = !!options.show |
|
|
|
|
|
|
|
this.isEdit = options.text === '修改' |
|
|
|
|
|
|
|
this.isHandle = options.text === '处理' |
|
|
|
|
|
|
|
this.isRenew = options.text === '续费' |
|
|
|
const store = uni.getStorageSync('courses') |
|
|
|
const store = uni.getStorageSync('courses') |
|
|
|
if (this.orderId) { |
|
|
|
if (this.orderId) { |
|
|
|
this.getInfo() |
|
|
|
this.getInfo() |
|
|
@ -231,9 +247,7 @@ |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
// 非详情才需要查询客户 |
|
|
|
// 非详情才需要查询客户 |
|
|
|
if (!this.isDetail) { |
|
|
|
this.isDetail || this.getCustomer() |
|
|
|
this.getCustomer() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 设置标题 |
|
|
|
// 设置标题 |
|
|
|
uni.setNavigationBarTitle({ |
|
|
|
uni.setNavigationBarTitle({ |
|
|
|
title: this.orderId ? |
|
|
|
title: this.orderId ? |
|
|
@ -253,12 +267,17 @@ |
|
|
|
orderId: this.orderId |
|
|
|
orderId: this.orderId |
|
|
|
}).then(({ orderDetails }) => { |
|
|
|
}).then(({ orderDetails }) => { |
|
|
|
const order = orderDetails |
|
|
|
const order = orderDetails |
|
|
|
this.contract = order.contractInformation |
|
|
|
if (!this.isRenew) this.contract = order.contractInformation // 非续费才回显合同 |
|
|
|
this.form = order.order |
|
|
|
this.form = order.order |
|
|
|
this.courses = order.orderOther |
|
|
|
this.courses = order.orderOther |
|
|
|
this.handleProduct(order.orderOther) |
|
|
|
this.handleRenew(0) |
|
|
|
|
|
|
|
this.handleRenew(1) |
|
|
|
|
|
|
|
this.handleRenew(2) |
|
|
|
|
|
|
|
Promise.all(this.promises).then(_ => { |
|
|
|
|
|
|
|
this.handleProduct(this.courses) |
|
|
|
this.calcTotal() |
|
|
|
this.calcTotal() |
|
|
|
uni.hideLoading() |
|
|
|
uni.hideLoading() |
|
|
|
|
|
|
|
}) |
|
|
|
}).catch(e => { |
|
|
|
}).catch(e => { |
|
|
|
uni.hideLoading() |
|
|
|
uni.hideLoading() |
|
|
|
}) |
|
|
|
}) |
|
|
@ -294,6 +313,68 @@ |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.courseList = courses |
|
|
|
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() { |
|
|
|
getCustomer() { |
|
|
|
queryCustomer({ |
|
|
|
queryCustomer({ |
|
|
@ -354,7 +435,7 @@ |
|
|
|
if (this.isDetail) return false |
|
|
|
if (this.isDetail) return false |
|
|
|
uni.setStorageSync('courses', this.courses) |
|
|
|
uni.setStorageSync('courses', this.courses) |
|
|
|
const { customerId, orderType } = this.form |
|
|
|
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) { |
|
|
|
delCourse(c, i) { |
|
|
@ -382,6 +463,22 @@ |
|
|
|
toggle(c) { |
|
|
|
toggle(c) { |
|
|
|
c.shrink = !c.shrink |
|
|
|
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) { |
|
|
|
calcTotal(out) { |
|
|
|
this.handleErr('orderType') |
|
|
|
this.handleErr('orderType') |
|
|
@ -426,7 +523,8 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 提交 |
|
|
|
// 提交 |
|
|
|
submit() { |
|
|
|
submit() { |
|
|
|
const { form, courses } = this |
|
|
|
const { form } = this |
|
|
|
|
|
|
|
const courses = [] |
|
|
|
if (!form.customerId) { |
|
|
|
if (!form.customerId) { |
|
|
|
this.err = 'customerName' |
|
|
|
this.err = 'customerName' |
|
|
|
return this.$util.errMsg('请选择客户!') |
|
|
|
return this.$util.errMsg('请选择客户!') |
|
|
@ -435,10 +533,14 @@ |
|
|
|
this.err = 'orderType' |
|
|
|
this.err = 'orderType' |
|
|
|
return this.$util.errMsg('请选择订单类型!') |
|
|
|
return this.$util.errMsg('请选择订单类型!') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (const i in this.courseList) { |
|
|
|
|
|
|
|
courses.push(...this.courseList[i].list) |
|
|
|
|
|
|
|
} |
|
|
|
if (!courses.length) return this.$util.errMsg('请选择课程权限或数据权限后再确认订单!') |
|
|
|
if (!courses.length) return this.$util.errMsg('请选择课程权限或数据权限后再确认订单!') |
|
|
|
courses.map(e => { |
|
|
|
courses.map(e => { |
|
|
|
e.startTime = this.$util.formatDate(new Date(e.startTime), 'yyyy-MM-dd') |
|
|
|
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({ |
|
|
|
uni.showLoading({ |
|
|
|
title: '提交中' |
|
|
|
title: '提交中' |
|
|
|
}) |
|
|
|
}) |
|
|
|