订单修改成产品维度(renew接口有传mallId,这里先暂存,提交完后会注释掉)

master
yujialong 1 year ago
parent 60e10283cd
commit fc2fc8bb17
  1. 4
      apis/modules/order.js
  2. 4
      libs/util.js
  3. 214
      order/addCourse/addCourse.vue
  4. 124
      order/editCourse/editCourse.vue
  5. 222
      order/orderDetail/orderDetail.vue

@ -47,4 +47,8 @@ export const publicConfiguration = (data) => {
export const bulkShipping = (data) => { export const bulkShipping = (data) => {
return post('nakadai/nakadai/orderOther/bulkShipping', data) return post('nakadai/nakadai/orderOther/bulkShipping', data)
}
export const queryCitySettlementPrice = (mallId, provinceId, cityId) => {
return post(`nakadai/mallPrice/queryCitySettlementPrice?mallId=${mallId}&provinceId=${provinceId}&cityId=${cityId}`)
} }

@ -67,9 +67,9 @@ export default {
getBmName(val) { getBmName(val) {
return uni.getStorageSync('team').partnerClassificationName return uni.getStorageSync('team').partnerClassificationName
}, },
// 返回图标。如果有图标,则直接返回,否则判断是否是数据产品,即productType=2,如果是,则取数据图标,否则则显示通用图标,这两个图标都在config/product.js里有配置 // 返回图标。如果有图标,则直接返回
getIcon(e) { getIcon(e) {
return e.miniProgramPictureAddress || (e.productType === 2 ? Product.dataIcon : Product.normalIcon) return e.appletIcon || Product.normalIcon
}, },
// 预览文档 // 预览文档
openFile(id) { openFile(id) {

@ -4,8 +4,14 @@
<uni-search-bar class="search" radius="5" placeholder="请输入产品名称" clearButton="auto" cancelButton="none" v-model="keyword" /> <uni-search-bar class="search" radius="5" placeholder="请输入产品名称" clearButton="auto" cancelButton="none" v-model="keyword" />
</uni-card> </uni-card>
<ul class="tab"> <ul class="tab-wrap">
<li v-for="(tab, i) in tabs" :class="{active: curTab === tab.id}" @click="tabChange(tab)">{{ tab.name }}</li> <view class="tab">
<li :class="{active: curTab === ''}" @click="tabChange('')">全部</li>
</view>
<scroll-view scroll-x :scroll-left="scrollLeft" class="tab tab-scroll">
<li v-for="(tab, i) in tabs" :key="i" :class="{active: curTab === tab.id}" @click="tabChange(tab.id)">{{ tab.name }}</li>
</scroll-view>
</ul> </ul>
<ul class="list"> <ul class="list">
@ -26,32 +32,19 @@
</template> </template>
<script> <script>
import { AppletsDataProductList } from '@/apis/modules/product.js' import { productCategoryList, listOfGoods } from '@/apis/modules/product.js'
import { renew } from '@/apis/modules/order.js' import { renew, queryCitySettlementPrice } from '@/apis/modules/order.js'
export default { export default {
data() { data() {
return { return {
// authority: 01234
orderType: 1, orderType: 1,
customerId: '', customerId: '',
provinceId: '',
cityId: '',
teamId: '',
curTab: '', curTab: '',
tabs: [ tabs: [],
{
name: '全部',
id: ''
},
{
name: '实训课程',
id: 1
},
{
name: '理论课程',
id: 0
},
{
name: '数据产品',
id: 2
}
],
reachBottom: 0, // 0->,1->,-1-> reachBottom: 0, // 0->,1->,-1->
status: 'more', // more|loading|noMore status: 'more', // more|loading|noMore
searchTimer: null, searchTimer: null,
@ -105,22 +98,38 @@
const { options } = pages[pages.length - 1] const { options } = pages[pages.length - 1]
this.orderType = options.orderType this.orderType = options.orderType
this.customerId = options.customerId this.customerId = options.customerId
this.provinceId = options.provinceId
this.cityId = options.cityId
this.teamId = options.teamId
this.getTypes()
this.getList() this.getList()
}, },
methods: { methods: {
//
getTypes() {
productCategoryList().then(res => {
res.classificationList.forEach(e => {
e.id = e.classificationId
e.name = e.classificationName
})
this.tabs.push(...res.classificationList)
}).catch(e => {})
},
// //
getList() { getList() {
uni.showLoading({ uni.showLoading({
title: '加载中' title: '加载中'
}) })
AppletsDataProductList({ listOfGoods({
sort: 'desc',
keywords: this.keyword,
productType: this.curTab,
pageNum: this.page, pageNum: this.page,
pageSize: this.pageSize pageSize: this.pageSize,
}).then(({ data }) => { sort: 0,
const { records } = data isShelves: 0,
hotTag: 1,
productName: this.keyword,
productType: this.curTab,
}).then(({ page }) => {
const { records } = page
const list = this.courses const list = this.courses
const all = this.checkAll.length // const all = this.checkAll.length //
const pageChange = this.reachBottom > 0 // const pageChange = this.reachBottom > 0 //
@ -131,9 +140,9 @@
text: '', text: '',
value: 1 value: 1
} }
e.check = (all && pageChange) || checked.find(n => n.id === e.id && n.productType === e.productType) ? 1 : 0 e.check = (all && pageChange) || checked.find(n => n.mallId === e.mallId) ? 1 : 0
// //
if (list.find(n => n.dataOrCourseId == e.id && n.productType == e.productType)) { if (list.find(n => n.mallId == e.mallId)) {
// //
checkData.disable = true checkData.disable = true
e.check = 1 e.check = 1
@ -144,7 +153,7 @@
// list // list
this.list = pageChange ? [...this.list, ...records] : records this.list = pageChange ? [...this.list, ...records] : records
this.page++ // page+1 this.page++ // page+1
const noMore = this.list.length === data.total // const noMore = this.list.length === page.total //
this.status = noMore ? 'noMore' : 'more' // noMore this.status = noMore ? 'noMore' : 'more' // noMore
this.reachBottom = noMore ? -1 : 0 // -1 this.reachBottom = noMore ? -1 : 0 // -1
uni.hideLoading() uni.hideLoading()
@ -166,8 +175,8 @@
checkChange(e, i) { checkChange(e, i) {
const { checked } = this const { checked } = this
const item = this.list[i] const item = this.list[i]
const { id, productType } = item const { mallId } = item
const include = checked.findIndex(e => e.id === id && e.productType === productType) const include = checked.findIndex(e => e.mallId === mallId)
// pushpush // pushpush
if (e.detail.value.length) { if (e.detail.value.length) {
include === -1 && checked.push(item) include === -1 && checked.push(item)
@ -185,8 +194,8 @@
const { checked, list } = this const { checked, list } = this
list.map(e => { list.map(e => {
e.check = isCheck ? 1 : 0 e.check = isCheck ? 1 : 0
const { id, productType } = e const { mallId } = e
const include = checked.findIndex(n => n.id === id && n.productType === productType) const include = checked.findIndex(n => n.mallId === mallId)
// pushpush // pushpush
if (isCheck) { if (isCheck) {
include === -1 && checked.push(e) include === -1 && checked.push(e)
@ -196,51 +205,50 @@
} }
}) })
}, },
// //
createParam(e) { createParam(e, authority) {
const { orderType } = this const { orderType } = this
const trial = orderType == 2 // const trial = orderType == 2 //
return { return {
dataOrCourseId: e.id, // id dataOrCourseId: e.associatedProduct, // id
mallId: e.mallId,
productName: e.productName, // productName: e.productName, //
periodOfUse: '', // 使 periodOfUse: '', // 使
startTime: this.$util.formatDate(new Date(), 'yyyy-MM-dd'), // startTime: this.$util.formatDate(new Date(), 'yyyy-MM-dd'), //
endTime: '', // endTime: '', //
remainingPeriod: '', // remainingPeriod: '', //
marketValue: '', // marketValue: '', //
marketPrice: e.marketPrice, // marketPrice: e.marketUnitPrice, //
finalPrice: trial ? 0 : '', // finalPrice: trial ? 0 : '', //
finalValue: trial ? 0 : '', // finalValue: trial ? 0 : '', //
discountRate: trial ? '0%' : '', // discountRate: trial ? '0%' : '', //
accountNum: e.productType === 2 ? '' : 1, // accountNum: authority ? 1 : '', //
totalAmount: '', // totalAmount: '', //
isEnable: 1, // 10 isEnable: 0, // 10
ship: 0, // 01 ship: 0, // 01
authority: e.productType === 2 ? 0 : 1, // 01 authority, // 01
productType: e.productType, // (0-> 1- 2 )
options: 2, options: 2,
miniProgramPictureAddress: e.miniProgramPictureAddress, // miniProgramPictureAddress: e.appletIcon || '', //
settlementPrice: trial ? 0 : '', // settlementPrice: trial ? 0 : '', //
settlementMethod: e.settlementMethod, // 01 settlementPriceUnit: e.settlementPrice || 0, //
settlementPriceUnit: e.settlementPrice, //
businessProportion: e.businessProportion, //
serviceFee: 0 // serviceFee: 0 //
} }
}, },
// //
handleRenew(authority, customerId, productId, result, resolve, reject) { handleRenew(authority, customerId, productId, mallId, result, resolve, reject) {
renew({ renew({
authority, authority,
customerId, customerId,
productId productId,
mallId
}).then(({ orderOthers }) => { }).then(({ orderOthers }) => {
result.map(e => { result.map(e => {
const item = orderOthers.find(n => n.dataOrCourseId == e.dataOrCourseId && n.authority == authority == e.authority) const item = orderOthers.find(n => n.dataOrCourseId == e.dataOrCourseId && n.authority == authority && e.authority == authority)
if (item) { if (item) {
let date = new Date(item.endTime) let date = new Date(item.endTime)
date = new Date(date.setDate(date.getDate() + 1)) date = new Date(date.setDate(date.getDate() + 1))
e.startTime = this.$util.formatDate(date, 'yyyy-MM-dd') e.startTime = this.$util.formatDate(date, 'yyyy-MM-dd')
e.renew = 1
} }
}) })
resolve() resolve()
@ -253,29 +261,81 @@
const list = this.checked // const list = this.checked //
if (list.length) { if (list.length) {
const result = this.courses const result = this.courses
const courseIds = [] console.log(123, result)
const dataIds = [] const list1 = [] //
const list0 = [] //
const list2 = [] //
const list3 = [] //
const list4 = [] //
const mallId1 = [] //
const mallId0 = [] //
const mallId2 = [] //
const mallId3 = [] //
const mallId4 = [] //
const { customerId } = this const { customerId } = this
list.map(e => {
// id const listPromise = []
if (!result.find(n => (n.dataOrCourseId == e.id || n.dataOrCourseId == e.dataOrCourseId) && ((n.authority && e.productType != 2) || (!n.authority && e.productType == 2)))) { list.forEach(async e => {
e.productType === 2 ? dataIds.push(e.id) : courseIds.push(e.id) listPromise.push(new Promise(async (resolve, reject) => {
result.push(this.createParam(e)) // id
} if (!result.find(n => (n.dataOrCourseId == e.associatedProduct || n.dataOrCourseId == e.dataOrCourseId) && n.authority == e.authority)) {
//
if (this.provinceId) {
const res = await queryCitySettlementPrice(e.mallId, this.provinceId, this.cityId)
if (res.mallPrice) e.settlementPrice = res.mallPrice.discountRate
}
console.log(44, e)
const classId = e.classificationId
const pid = +e.associatedProduct
const mallId = e.mallId
if (classId == 1 || classId == 2) {
list1.push(pid)
mallId1.push(mallId)
} else if (classId == 3) {
list2.push(pid)
mallId2.push(mallId)
} else if (classId == 4) {
list3.push(pid)
mallId3.push(mallId)
} else if (classId == 5) {
list0.push(pid)
mallId0.push(mallId)
} else if (classId == 6) {
list4.push(pid)
mallId4.push(mallId)
}
result.push(this.createParam(e, this.$util.getOrderType(classId)))
resolve()
} else {
resolve()
}
}))
}) })
const promises = [] Promise.all(listPromise).then(_ => {
// const promises = []
dataIds.length && promises.push(new Promise((resolve, reject) => { // 5authorityrenew
this.handleRenew(0, customerId, dataIds, result, resolve, reject) list0.length && promises.push(new Promise((resolve, reject) => {
})) this.handleRenew(0, customerId, list0, mallId0, result, resolve, reject)
courseIds.length && promises.push(new Promise((resolve, reject) => { }))
this.handleRenew(1, customerId, courseIds, result, resolve, reject) list1.length && promises.push(new Promise((resolve, reject) => {
})) this.handleRenew(1, customerId, list1, mallId1, result, resolve, reject)
Promise.all(promises).then(_ => { }))
uni.setStorageSync('courses', result) // list2.length && promises.push(new Promise((resolve, reject) => {
uni.redirectTo({ this.handleRenew(2, customerId, list2, mallId2, result, resolve, reject)
url: `../editCourse/editCourse?customerId=${customerId}&orderType=${this.orderType}&action=add` }))
}) list3.length && promises.push(new Promise((resolve, reject) => {
this.handleRenew(3, customerId, list3, mallId3, result, resolve, reject)
}))
list4.length && promises.push(new Promise((resolve, reject) => {
this.handleRenew(4, customerId, list4, mallId4, result, resolve, reject)
}))
Promise.all(promises).then(_ => {
uni.setStorageSync('courses', result) //
uni.redirectTo({
url: `../editCourse/editCourse?customerId=${customerId}&orderType=${this.orderType}&teamId=${this.teamId}`
})
})
}) })
} else { } else {
this.$util.errMsg('请选择产品!') this.$util.errMsg('请选择产品!')
@ -289,6 +349,16 @@
.page { .page {
padding-bottom: 130rpx; padding-bottom: 130rpx;
} }
.tab-wrap {
display: flex;
.tab-scroll {
width: calc(100% - 100rpx);
white-space: nowrap;
li {
display: inline-block;
}
}
}
.list { .list {
li { li {
display: flex; display: flex;

@ -88,6 +88,8 @@
<script> <script>
import { getOrderOtherTime } from '@/apis/modules/order.js' import { getOrderOtherTime } from '@/apis/modules/order.js'
import { getPartnerTeamRates } from '@/apis/modules/parner.js'
import { productCategoryList } from '@/apis/modules/product.js'
export default { export default {
data() { data() {
return { return {
@ -97,6 +99,7 @@
isRenew: 0, // isRenew: 0, //
orderType: 1, orderType: 1,
customerId: '', customerId: '',
teamId: '',
timer: null, timer: null,
units: [{ units: [{
text: '日', text: '日',
@ -109,24 +112,12 @@
id: 2 id: 2
}], }],
unitText: ['日', '月', '年'], unitText: ['日', '月', '年'],
productTypes: [ productTypes: [],
{
name: '实训课程',
id: 1
},
{
name: '理论课程',
id: 0
},
{
name: '数据产品',
id: 2
}
],
courses: {} , // courses: {} , //
orderRepeat: [], orderRepeat: [],
repeatMsg: '', repeatMsg: '',
err: '', err: '',
rate: ''
} }
}, },
onShow() { onShow() {
@ -138,55 +129,35 @@
this.isHandle = options.action === 'handle' this.isHandle = options.action === 'handle'
this.isRenew = options.action === 'renew' this.isRenew = options.action === 'renew'
this.isAdd = options.action === 'add' this.isAdd = options.action === 'add'
this.teamId = options.teamId
this.handleProduct() this.handleProduct()
this.teamId && this.getRate()
}, },
methods: { methods: {
// //
handleProduct() { handleProduct() {
const list = uni.getStorageSync('courses') const list = uni.getStorageSync('courses')
const courses = { let courses = {}
practice: { //
shrink: false, productCategoryList().then(res => {
name: '实训课程产品', const typeList = []
list: [] res.classificationList.forEach(e => {
}, typeList.push({
theory: { id: e.classificationId,
shrink: false, name: e.classificationName
name: '理论课程产品', })
list: [] courses['list' + this.$util.getOrderType(e.classificationId)] = {
}, shrink: false,
data: { name: e.classificationName,
shrink: false, list: []
name: '数据产品', }
list: [] })
} this.productTypes = typeList
} list.map(e => {
// 3push(0-> 1- 2 ) courses['list' + e.authority].list.push(e)
list.map(e => { })
const type = e.productType this.courses = courses
!type ? }).catch(e => {})
courses.theory.list.push(e) :
type === 1 ?
courses.practice.list.push(e) :
courses.data.list.push(e)
})
// let selectData= []
// let itemIndex = ''
// for (let item in courses) {
// if(courses[item].list.length) {
// const data = courses[item].list.find(options=>{
// if(options.id == this.editId) {
// itemIndex = item
// }
// return options.id == this.editId
// })
// selectData.push(data)
// break
// }
// }
// courses[itemIndex].list = selectData
this.courses = courses
try { try {
uni.removeStorageSync('courses') uni.removeStorageSync('courses')
} catch (e) {} } catch (e) {}
@ -282,6 +253,7 @@
// //
dealSettlePrice(row) { dealSettlePrice(row) {
// 0 // 0
console.log('dealSettlePrice=>', row, this.orderType)
if (this.orderType == 2) { if (this.orderType == 2) {
row.settlementPrice = 0 row.settlementPrice = 0
row.serviceFee = 0 row.serviceFee = 0
@ -289,27 +261,29 @@
const unit = row.options // 使 const unit = row.options // 使
const useUnit = row.periodOfUse // 使 const useUnit = row.periodOfUse // 使
let sPrice = '' let sPrice = ''
if (row.settlementMethod == 0) { // **/**(1)
// **/**(1) const priceUnit = row.settlementPriceUnit
const priceUnit = row.settlementPriceUnit sPrice = ((!unit ?
sPrice = ((!unit ? priceUnit / 365 * useUnit :
priceUnit / 365 * useUnit : unit === 1 ?
unit === 1 ? priceUnit / 12 * useUnit :
priceUnit / 12 * useUnit : priceUnit * useUnit) * (row.authority ?
priceUnit * useUnit) * (row.authority ? 1 :
1 : row.accountNum)).toFixed((2))
row.accountNum)).toFixed((2))
} else {
// *
sPrice = (row.finalPrice * row.businessProportion / 100).toFixed((2))
}
row.settlementPrice = this.$util.handleNaN(sPrice) row.settlementPrice = this.$util.handleNaN(sPrice)
// *10% //
if (row.settlementPrice) { row.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2)
row.serviceFee = (row.settlementPrice * 0.1).toFixed(2)
}
} }
}, },
//
getRate() {
getPartnerTeamRates({
teamId: this.teamId
}).then(({ teamRates }) => {
console.log('teamRates=>',teamRates)
this.rate = teamRates.annualMarketingFee || 0
}).catch(res => {})
},
// //
calcDiscount(row) { calcDiscount(row) {
const price = row.authority ? row.finalPrice : row.finalValue const price = row.authority ? row.finalPrice : row.finalValue

@ -80,6 +80,7 @@
<button v-if="item.status === 1 || isHandle || !orderId && auth('订单管理:发货')" class="course-btn" type="primary" @click.stop="handleDeliver(n, i)">{{ item.ship ? '取消' : ''}}发货</button> <button v-if="item.status === 1 || isHandle || !orderId && auth('订单管理:发货')" class="course-btn" type="primary" @click.stop="handleDeliver(n, i)">{{ item.ship ? '取消' : ''}}发货</button>
<button v-else-if="!isDetail && auth('订单管理:启用')" class="course-btn" type="primary" @click.stop="handleEnable(n, i)">{{ item.isEnable ? '禁用' : '启用'}}</button> <button v-else-if="!isDetail && auth('订单管理:启用')" 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> <image v-if="!orderId || isRenew" class="del" src="@/static/image/trash.png" mode="widthFix" @click.stop="delCourse(c, i)"></image>
<button v-if="(item.authority == 3 || item.authority == 4) && ((item.mallNonAssociatedLinks && item.mallNonAssociatedLinks.length) || item.shipContent)" class="course-btn" type="primary" @click.stop="showShip(item)">发货信息</button>
</view> </view>
</view> </view>
@ -111,7 +112,7 @@
</view> </view>
<view class="line"> <view class="line">
<view class="label">{{ item.authority ? '市场价' : '市场单价' }}</view> <view class="label">{{ item.authority ? '市场价' : '市场单价' }}</view>
<view class="val">{{ item.marketValue || 0 }}</view> <view class="val">{{ item.marketValue && item.marketValue + '元' }}</view>
</view> </view>
<view class="line"> <view class="line">
<view class="label">结算价</view> <view class="label">结算价</view>
@ -205,14 +206,20 @@
<view class="item" v-for="item in customerList" @click="customerChange(item)">{{ item.customerName }}</view> <view class="item" v-for="item in customerList" @click="customerChange(item)">{{ item.customerName }}</view>
</view> </view>
</view> </view>
<uni-popup ref="info" type="bottom" background-color="#fff">
<view class="ship-info">
<view class="ship-text" v-html="shipInfo" @click="copy"></view>
<uni-easyinput type="textarea" v-model="shipContent" placeholder="请填写需交付的产品登录地址、账号、密码等内容...(300个字以内)" :disabled="isDetail"></uni-easyinput>
</view>
</uni-popup>
</view> </view>
</template> </template>
<script> <script>
import { queryCustomer, queryCustomerDetails } from '@/apis/modules/client.js' import { queryCustomer, queryCustomerDetails } from '@/apis/modules/client.js'
import { add, update, del, getDetail, renew, ship, miniProgramOrderRecord, bulkShipping } from '@/apis/modules/order.js' import { add, update, del, getDetail, renew, ship, miniProgramOrderRecord, bulkShipping, getOrderOtherTime, queryCitySettlementPrice } from '@/apis/modules/order.js'
import { teamList, getAllTeam } from '@/apis/modules/parner.js' import { teamList, getAllTeam, getPartnerTeamRates } from '@/apis/modules/parner.js'
import { getOrderOtherTime } from '@/apis/modules/order.js' import { productCategoryList } from '@/apis/modules/product.js'
export default { export default {
data() { data() {
return { return {
@ -282,6 +289,10 @@
id: 2 id: 2
}], }],
unitText: ['日', '月', '年'], unitText: ['日', '月', '年'],
rate: '',
shipInfo: '',
shipContent: ''
} }
}, },
watch: { watch: {
@ -361,9 +372,9 @@
} }
} }
this.courses = order.orderOther this.courses = order.orderOther
this.handleRenew(0) for (let i = 0; i < 5; i++) {
this.handleRenew(1) this.handleRenew(i)
this.handleRenew(2) }
Promise.all(this.promises).then(_ => { Promise.all(this.promises).then(_ => {
this.handleProduct(this.courses) this.handleProduct(this.courses)
this.calcTotal() this.calcTotal()
@ -375,43 +386,36 @@
}, },
// //
handleProduct(list) { handleProduct(list) {
const courses = { let courses = {}
practice: { //
shrink: false, productCategoryList().then(res => {
name: '实训课程产品', res.classificationList.forEach(e => {
list: [] courses['list' + this.$util.getOrderType(e.classificationId)] = {
}, shrink: false,
theory: { name: e.classificationName,
shrink: false, list: []
name: '理论课程产品', }
list: [] })
},
data: { list.map(e => {
shrink: false, e.serviceFee = (e.finalPrice * (this.rate / 100)).toFixed(2) // != 0 &&
name: '数据产品', courses['list' + e.authority].list.push(e)
list: [] })
} console.log(123,courses)
} this.courseList = courses
// 3push(0-> 1- 2 ) }).catch(e => {})
list.map(e => {
e.serviceFee = (e.settlementPrice * 0.1).toFixed(2)
const type = e.productType
!type ?
courses.theory.list.push(e) :
type === 1 ?
courses.practice.list.push(e) :
courses.data.list.push(e)
})
this.courseList = courses
}, },
// pc // pc
handleRenew(authority) { handleRenew(authority) {
const productId = this.courses.filter(e => e.authority == authority).map(e => e.dataOrCourseId) const list = this.courses.filter(e => e.authority == authority)
const productId = list.map(e => e.dataOrCourseId)
const mallId = list.map(e => e.mallId)
productId.length && this.promises.push(new Promise((resolve, reject) => { productId.length && this.promises.push(new Promise((resolve, reject) => {
renew({ renew({
authority, authority,
customerId: this.form.customerId, customerId: this.form.customerId,
productId productId,
mallId
}).then(({ orderOthers }) => { }).then(({ orderOthers }) => {
const { courses } = this const { courses } = this
const now = new Date() const now = new Date()
@ -502,25 +506,53 @@
this.keyword = '' this.keyword = ''
}, },
// //
customerChange(item) { async customerChange(item) {
const { form } = this const { form } = this
// //
queryCustomerDetails({ const { result } = await queryCustomerDetails({
customerId: item.customerId customerId: item.customerId
}).then(({ result }) => { })
this.handleErr('customerName') this.handleErr('customerName')
const e = result.customer const e = result.customer
form.customerId = e.customerId const { provinceId, cityId } = e
form.customerName = e.customerName form.customerId = e.customerId
form.provinceId = e.provinceId form.customerName = e.customerName
form.cityId = e.cityId form.provinceId = provinceId
form.provinceName = e.provinceName form.cityId = cityId
form.cityName = e.cityName form.provinceName = e.provinceName
form.phone = e.phone form.cityName = e.cityName
form.email = e.email form.phone = e.phone
form.orderContact = e.name form.email = e.email
}).catch(e => {}) form.orderContact = e.name
this.closeCustomer()
//
const list = this.courseList
const courses = []
const promises = []
for (const i in list) {
list[i].list.forEach(n => {
promises.push(new Promise(async (resolve, reject) => {
const res = await queryCitySettlementPrice(n.mallId, provinceId, cityId)
n.settlementPriceUnit = res.mallPrice ? res.mallPrice.discountRate : 0
courses.push(n)
resolve()
}))
})
}
Promise.all(promises).then(_ => {
this.courses = courses
this.calcTotal()
this.closeCustomer()
})
},
//
getRate() {
getPartnerTeamRates({
teamId: this.form.teamId
}).then(({ teamRates }) => {
this.rate = teamRates.annualMarketingFee || 0
this.calcTotal()
}).catch(res => {})
}, },
// //
getTeam(getInfo) { getTeam(getInfo) {
@ -531,6 +563,7 @@
}, },
// //
getBm() { getBm() {
this.getRate()
teamList({ teamList({
pageNum: 1, pageNum: 1,
pageSize: 1000, pageSize: 1000,
@ -543,17 +576,19 @@
// //
toAdd() { toAdd() {
uni.setStorageSync('courses', this.courses) uni.setStorageSync('courses', this.courses)
uni.setStorageSync('orderForm', this.form)
const { customerId, orderType } = this.form const { customerId, orderType } = this.form
customerId ? customerId ?
this.$util.to(`../addCourse/addCourse?orderType=${orderType}&customerId=${customerId}`) : this.$util.to(`../addCourse/addCourse?orderType=${orderType}&customerId=${customerId}&provinceId=${this.form.provinceId}&cityId=${this.form.cityId}&teamId=${this.form.teamId || ''}`) :
this.$util.errMsg('请先选择客户!') this.$util.errMsg('请先选择客户!')
}, },
// //
editCourse(c, i) { editCourse(c, i) {
if (this.isDetail) return false if (this.isDetail) return false
uni.setStorageSync('courses', this.courses) uni.setStorageSync('courses', this.courses)
uni.setStorageSync('orderForm', this.form)
const { customerId, orderType } = this.form const { customerId, orderType } = this.form
this.$util.to(`../editCourse/editCourse?orderType=${orderType}&customerId=${customerId}&action=${this.isEdit ? 'edit' : this.isRenew ? 'renew' : this.isHandle ? 'handle' : !this.orderId ? 'add' : ''}`) this.$util.to(`../editCourse/editCourse?orderType=${orderType}&customerId=${customerId}&action=${this.isEdit ? 'edit' : this.isRenew ? 'renew' : this.isHandle ? 'handle' : !this.orderId ? 'add' : ''}&teamId=${this.form.teamId || ''}`)
}, },
// //
toClient() { toClient() {
@ -625,6 +660,10 @@
e.finalValue = 0 e.finalValue = 0
e.discountRate = '0%' e.discountRate = '0%'
} else { } else {
console.log(111, e)
this.calcDiscount(e)
this.dealSettlePrice(e)
this.calcFinalPrice(e)
const curPurchase = +e.settlementPrice + +e.serviceFee const curPurchase = +e.settlementPrice + +e.serviceFee
purchase += curPurchase purchase += curPurchase
profit += +e.finalPrice - curPurchase profit += +e.finalPrice - curPurchase
@ -632,7 +671,28 @@
}) })
form.purchaseCost = Math.round(purchase) form.purchaseCost = Math.round(purchase)
form.profit = Math.round(profit) form.profit = Math.round(profit)
form.orderAmount = +form.purchaseCost + +form.profit form.orderAmount = (+form.purchaseCost + +form.profit).toFixed(2)
},
//
showShip(row) {
console.log(33)
let val = ''
row.mallNonAssociatedLinks && row.mallNonAssociatedLinks.forEach(e => {
val += e.urlName + ':' + e.url + '\n'
})
this.shipInfo = val
this.shipContent = row.shipContent || val
this.$refs.info.open()
},
//
copy() {
const that = this
uni.setClipboardData({
data: this.shipInfo,
success() {
that.$util.sucMsg('复制成功')
}
})
}, },
// //
handleErr(val) { handleErr(val) {
@ -717,7 +777,6 @@
}) })
} else { } else {
add(data).then(res => { add(data).then(res => {
// form.orderOther.find(e => !e.ship) || this.publicNotice(form, orderId) //
uni.hideLoading() uni.hideLoading()
this.$util.sucMsg('添加成功') this.$util.sucMsg('添加成功')
setTimeout(() => { setTimeout(() => {
@ -789,6 +848,7 @@
}, 500) }, 500)
}, },
dealSettlePrice(row) { dealSettlePrice(row) {
console.log('dealSettlePrice', row)
// 0 // 0
if (this.orderType == 2) { if (this.orderType == 2) {
row.settlementPrice = 0 row.settlementPrice = 0
@ -797,30 +857,19 @@
const unit = row.options // 使 const unit = row.options // 使
const useUnit = row.periodOfUse // 使 const useUnit = row.periodOfUse // 使
let sPrice = '' let sPrice = ''
if (row.settlementMethod == 0) { // **/**(1)
// **/**(1) const priceUnit = row.settlementPriceUnit
const priceUnit = row.settlementPriceUnit sPrice = ((!unit ?
sPrice = ((!unit ? priceUnit / 365 * useUnit :
priceUnit / 365 * useUnit : unit === 1 ?
unit === 1 ? priceUnit / 12 * useUnit :
priceUnit / 12 * useUnit : priceUnit * useUnit) * (row.authority ?
priceUnit * useUnit) * (row.authority ? 1 :
1 : row.accountNum)).toFixed((2))
row.accountNum)).toFixed((2))
} else {
// *
sPrice = (row.finalPrice * row.businessProportion / 100).toFixed((2))
}
row.settlementPrice = this.$util.handleNaN(sPrice) row.settlementPrice = this.$util.handleNaN(sPrice)
// *10% //
console.log('row.settlementPrice =>' ,row.settlementPrice) row.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2)
if (row.settlementPrice) { console.log('row.settlementPrice =>' ,this.rate,row.serviceFee)
console.log(2222)
row.serviceFee = (row.settlementPrice * 0.1).toFixed(2)
}else {
console.log(1111111)
row.serviceFee = 0
}
} }
}, },
calcDiscount(row) { calcDiscount(row) {
@ -877,9 +926,8 @@
}, 500) }, 500)
}, },
// //
updateServiceFee(options) { updateServiceFee(row) {
options.serviceFee = (options.settlementPrice * 0.1).toFixed(2) options.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2)
console.log('options===>',options)
} }
} }
} }
@ -1119,4 +1167,12 @@
.defaultBox { .defaultBox {
font-size: 28rpx; font-size: 28rpx;
} }
.ship-info {
padding: 30rpx;
white-space: pre-wrap;
font-size: 28rpx;
.ship-text {
margin-bottom: 20rpx;
}
}
</style> </style>

Loading…
Cancel
Save