|
|
|
@ -3,10 +3,6 @@ |
|
|
|
|
<view class="block"> |
|
|
|
|
<view class="l-title">基本信息</view> |
|
|
|
|
<view class="form-list"> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="name">商务经理</view> |
|
|
|
|
<view class="val">{{ form.businessManagerName }}</view> |
|
|
|
|
</view> |
|
|
|
|
<view :class="['line req', {err: err === 'customerName'}]"> |
|
|
|
|
<view class="name">客户名称</view> |
|
|
|
|
<view v-if="orderId" class="val">{{ form.customerName }}</view> |
|
|
|
@ -37,6 +33,16 @@ |
|
|
|
|
<view v-if="isDetail" class="val">{{ orderTypes.find(e => e.value === form.orderType).text }}</view> |
|
|
|
|
<uni-data-picker v-else class="picker-input" placeholder="请选择订单类型" popup-title="请选择订单类型" preload :clear-icon="false" :localdata="orderTypes" v-model="form.orderType" @change="calcTotal(1)"></uni-data-picker> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="name">团队</view> |
|
|
|
|
<view v-if="isDetail" class="val">{{ form.partnerClassificationName }}</view> |
|
|
|
|
<uni-data-picker v-else class="picker-input" placeholder="请选择团队" popup-title="请选择团队" preload :clear-icon="false" :localdata="teams" :map="{text: 'partnerClassificationName', value: 'id'}" v-model="form.teamId" @change="getBm"></uni-data-picker> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="name">商务经理</view> |
|
|
|
|
<view v-if="isDetail" class="val">{{ form.businessManagerName }}</view> |
|
|
|
|
<uni-data-picker v-else class="picker-input" placeholder="请选择商务经理" popup-title="请选择商务经理" preload :localdata="bms" :map="{text: 'userName', value: 'partnerId'}" v-model="form.businessManagerId" :readonly="form.teamId ? false : true"></uni-data-picker> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="name">订单编号</view> |
|
|
|
|
<view class="val">{{ form.orderNumber }}</view> |
|
|
|
@ -57,25 +63,25 @@ |
|
|
|
|
<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"> |
|
|
|
|
<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)"> |
|
|
|
|
<li v-for="(item, i) in c.list" :key="i" @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 class="course-action"> |
|
|
|
|
<!-- 1、查看时不可操作 |
|
|
|
|
2、发货和启用不要同时出现,生效前只会显示发货不发货按钮,生效后只显示禁启用按钮 |
|
|
|
|
3、处理中的订单显示发货,不显示禁用 --> |
|
|
|
|
<button v-if="item.status === 1 || isHandle || !orderId" class="course-btn" type="primary" @click.stop="handleDeliver(n, i)">{{ item.ship ? '取消' : ''}}发货</button> |
|
|
|
|
<button v-else-if="!isDetail" class="course-btn" type="primary" @click.stop="handleEnable(n, i)">{{ item.isEnable ? '禁用' : '启用'}}</button> |
|
|
|
|
<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 }}</view> |
|
|
|
|
<view class="val">{{ item.startTime + (item.endTime && ' - ' + item.endTime) }}</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">市场价(元)</view> |
|
|
|
@ -99,8 +105,6 @@ |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</li> |
|
|
|
|
</uni-swipe-action-item> |
|
|
|
|
</uni-swipe-action> |
|
|
|
|
</ul> |
|
|
|
|
</view> |
|
|
|
|
</template> |
|
|
|
@ -128,7 +132,10 @@ |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="product-btns"> |
|
|
|
|
<view v-if="!isDetail" class="btn" @click="submit">提交({{ courses.length }})</view> |
|
|
|
|
<view v-if="isHandle || (!orderId && courses.length)" class="btn" @click="batchDeliver">{{ courses.find(e => !e.ship) ? '一键发货' : '取消全部发货' }}</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
@ -146,7 +153,8 @@ |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import { queryCustomer, queryCustomerDetails } from '@/apis/modules/client.js' |
|
|
|
|
import { add, update, getDetail, renew, ship } from '@/apis/modules/order.js' |
|
|
|
|
import { add, update, getDetail, renew, ship, miniProgramOrderRecord, bulkShipping } from '@/apis/modules/order.js' |
|
|
|
|
import { teamList, getAllTeam } from '@/apis/modules/parner.js' |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
@ -163,7 +171,8 @@ |
|
|
|
|
value: 2 |
|
|
|
|
}], |
|
|
|
|
form: { |
|
|
|
|
businessManagerName: uni.getStorageSync('team').userName, |
|
|
|
|
businessManagerId: '', |
|
|
|
|
businessManagerName: '', |
|
|
|
|
// orderNumber: '', // 编号 |
|
|
|
|
provinceId: '', // 省份id |
|
|
|
|
provinceName: '', |
|
|
|
@ -179,9 +188,11 @@ |
|
|
|
|
customerName: '', |
|
|
|
|
profit: 0, // 利润 |
|
|
|
|
purchaseCost: 0, // 采购成本 |
|
|
|
|
teamId: uni.getStorageSync('team').id, |
|
|
|
|
businessManagerId: this.$util.getBmId() |
|
|
|
|
teamId: '', |
|
|
|
|
partnerClassificationName: '', |
|
|
|
|
}, |
|
|
|
|
teams: [], |
|
|
|
|
bms: [], |
|
|
|
|
courseList: {}, |
|
|
|
|
courses: [], // 缓存的产品列表 |
|
|
|
|
contract: { // 合同信息 |
|
|
|
@ -218,10 +229,9 @@ |
|
|
|
|
this.isEdit = options.text === '修改' |
|
|
|
|
this.isHandle = options.text === '处理' |
|
|
|
|
this.isRenew = options.text === '续费' |
|
|
|
|
this.getTeam() |
|
|
|
|
const store = uni.getStorageSync('courses') |
|
|
|
|
if (this.orderId) { |
|
|
|
|
this.getInfo() |
|
|
|
|
} else if (store) { |
|
|
|
|
if (store) { |
|
|
|
|
// 新增取缓存,取了删除 |
|
|
|
|
const list = [] |
|
|
|
|
for (const i in store) { |
|
|
|
@ -269,6 +279,16 @@ |
|
|
|
|
const order = orderDetails |
|
|
|
|
if (!this.isRenew) this.contract = order.contractInformation // 非续费才回显合同 |
|
|
|
|
this.form = order.order |
|
|
|
|
// 如果有teamId的,则遍历团队列表来获取团队名称 |
|
|
|
|
const { teamId } = this.form |
|
|
|
|
if (teamId) { |
|
|
|
|
const item = this.teams.find(e => e.id == teamId) |
|
|
|
|
if (item) this.form.partnerClassificationName = item.partnerClassificationName |
|
|
|
|
if (!this.isDetail) { |
|
|
|
|
this.form.businessManagerId = +this.form.businessManagerId |
|
|
|
|
this.getBm() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.courses = order.orderOther |
|
|
|
|
this.handleRenew(0) |
|
|
|
|
this.handleRenew(1) |
|
|
|
@ -313,7 +333,7 @@ |
|
|
|
|
}) |
|
|
|
|
this.courseList = courses |
|
|
|
|
}, |
|
|
|
|
// 处理开始结束时间和订单状态 |
|
|
|
|
// 处理开始结束时间和订单状态(参考pc,订单模块不是本人开发的,所以也不懂这里逻辑) |
|
|
|
|
handleRenew(authority) { |
|
|
|
|
const productId = this.courses.filter(e => e.authority == authority).map(e => e.dataOrCourseId) |
|
|
|
|
productId.length && this.promises.push(new Promise((resolve, reject) => { |
|
|
|
@ -332,7 +352,6 @@ |
|
|
|
|
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') |
|
|
|
|
} |
|
|
|
@ -341,7 +360,7 @@ |
|
|
|
|
item.marketValue = e.marketValue |
|
|
|
|
} else if (!this.isDetail) { // 如果不是查看 |
|
|
|
|
item.startTime = e.startTime.split(' ')[0] |
|
|
|
|
item.endTime = e.endTime.split(' ')[0] |
|
|
|
|
item.endTime = e.endTime ? e.endTime.split(' ')[0] : '' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const startTime = new Date(item.startTime) |
|
|
|
@ -353,21 +372,6 @@ |
|
|
|
|
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 => { |
|
|
|
@ -422,6 +426,24 @@ |
|
|
|
|
}).catch(e => {}) |
|
|
|
|
this.closeCustomer() |
|
|
|
|
}, |
|
|
|
|
// 获取团队 |
|
|
|
|
getTeam() { |
|
|
|
|
getAllTeam().then(({ team }) => { |
|
|
|
|
this.teams = team |
|
|
|
|
this.orderId && this.getInfo() |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}, |
|
|
|
|
// 获取商务经理 |
|
|
|
|
getBm() { |
|
|
|
|
teamList({ |
|
|
|
|
pageNum: 1, |
|
|
|
|
pageSize: 1000, |
|
|
|
|
type: 1, |
|
|
|
|
partnerClassificationId: this.form.teamId |
|
|
|
|
}).then(({ pageList }) => { |
|
|
|
|
this.bms = pageList.records |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}, |
|
|
|
|
// 跳转 |
|
|
|
|
toAdd() { |
|
|
|
|
uni.setStorageSync('courses', this.courses) |
|
|
|
@ -463,21 +485,15 @@ |
|
|
|
|
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) |
|
|
|
|
// 处理禁用启用 |
|
|
|
|
handleEnable(c, i) { |
|
|
|
|
this.courseList[c].list[i].isEnable = this.courseList[c].list[i].isEnable ? 0 : 1 |
|
|
|
|
}, |
|
|
|
|
// 处理发货 |
|
|
|
|
handleDeliver(c, i) { |
|
|
|
|
const row = this.courseList[c].list[i] |
|
|
|
|
row.ship = row.ship ? 0 : 1 |
|
|
|
|
this.isEdit && ship(row).then(res => {}).catch(res => {}) // 编辑的情况下,需要调接口去直接发货 |
|
|
|
|
}, |
|
|
|
|
// 计算订单总额 |
|
|
|
|
calcTotal(out) { |
|
|
|
@ -521,6 +537,39 @@ |
|
|
|
|
handleErr(val) { |
|
|
|
|
if (val === this.err) this.err = '' |
|
|
|
|
}, |
|
|
|
|
// 发送服务通知 |
|
|
|
|
publicNotice(form, id) { |
|
|
|
|
miniProgramOrderRecord({ |
|
|
|
|
content: form.orderOther.map(e => e.productName).join(), |
|
|
|
|
openId: uni.getStorageSync('openid'), |
|
|
|
|
page: `orderId=201&show=1?id=${id}&isShow=1`, |
|
|
|
|
school: form.customerName, |
|
|
|
|
state: '已完成', |
|
|
|
|
}).then(res => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
this.$util.sucMsg('编辑成功') |
|
|
|
|
setTimeout(() => { |
|
|
|
|
uni.navigateBack() |
|
|
|
|
}, 1500) |
|
|
|
|
}).catch(res => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 一键发货/取消全部发货 |
|
|
|
|
batchDeliver() { |
|
|
|
|
const list = this.courseList |
|
|
|
|
const ship = this.courses.find(e => !e.ship) ? 1 : 0 // 是否发货。如果全部发货了,则全部遍历为0,否则为1(1发货,0未发货) |
|
|
|
|
const courses = [] |
|
|
|
|
for (const i in list) { |
|
|
|
|
list[i].list.forEach(e => { |
|
|
|
|
e.ship = ship |
|
|
|
|
courses.push(e) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.courses = courses |
|
|
|
|
this.isEdit && bulkShipping({orderOthers: courses}).then(res => {}).catch(res => {}) // 编辑的情况下,需要调接口去直接发货 |
|
|
|
|
console.log(11, this.courses) |
|
|
|
|
}, |
|
|
|
|
// 提交 |
|
|
|
|
submit() { |
|
|
|
|
const { form } = this |
|
|
|
@ -549,7 +598,7 @@ |
|
|
|
|
order: form, // 订单基本数据 |
|
|
|
|
orderOther: courses // 产品列表 |
|
|
|
|
} |
|
|
|
|
if (this.orderId) { |
|
|
|
|
if (this.isEdit || this.isHandle) { |
|
|
|
|
update(data).then(res => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
this.$util.sucMsg('编辑成功') |
|
|
|
@ -561,6 +610,7 @@ |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
add(data).then(res => { |
|
|
|
|
// form.orderOther.find(e => !e.ship) || this.publicNotice(form, orderId) // 新增的时候要判断是否全部产品都发货了,全部发货了才发服务通知 |
|
|
|
|
uni.hideLoading() |
|
|
|
|
this.$util.sucMsg('添加成功') |
|
|
|
|
setTimeout(() => { |
|
|
|
@ -608,6 +658,15 @@ |
|
|
|
|
display: inline-flex; |
|
|
|
|
align-items: center; |
|
|
|
|
} |
|
|
|
|
.course-action { |
|
|
|
|
display: inline-flex; |
|
|
|
|
align-items: center; |
|
|
|
|
} |
|
|
|
|
.course-btn { |
|
|
|
|
padding: 0 16rpx; |
|
|
|
|
margin-right: 10rpx; |
|
|
|
|
font-size: 28rpx; |
|
|
|
|
} |
|
|
|
|
.del { |
|
|
|
|
width: 40rpx; |
|
|
|
|
} |
|
|
|
@ -732,11 +791,16 @@ |
|
|
|
|
color: #333; |
|
|
|
|
white-space: nowrap; |
|
|
|
|
} |
|
|
|
|
.product-btns { |
|
|
|
|
display: inline-flex; |
|
|
|
|
align-items: center; |
|
|
|
|
margin-left: 20rpx; |
|
|
|
|
} |
|
|
|
|
.btn { |
|
|
|
|
width: 180rpx; |
|
|
|
|
margin-left: 30rpx; |
|
|
|
|
padding: 0 20rpx; |
|
|
|
|
margin-left: 16rpx; |
|
|
|
|
line-height: 80rpx; |
|
|
|
|
font-size: 32rpx; |
|
|
|
|
font-size: 30rpx; |
|
|
|
|
text-align: center; |
|
|
|
|
color: #fff; |
|
|
|
|
border-radius: 10rpx; |
|
|
|
|