From 5a441a218851b535f170b5022a4f0e41160069b4 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Wed, 28 Jun 2023 16:15:58 +0800 Subject: [PATCH] fix --- order/addCourse/addCourse.vue | 43 ++--- order/clientDetail/clientDetail.vue | 2 +- order/editCourse/editCourse.vue | 4 - order/orderDetail/orderDetail.vue | 241 +++++++++++++++++----------- order/ordered/ordered.vue | 55 ++++--- order/orders/orders.vue | 8 +- order/products/products.vue | 12 +- pages/teams/teams.vue | 6 +- 8 files changed, 219 insertions(+), 152 deletions(-) diff --git a/order/addCourse/addCourse.vue b/order/addCourse/addCourse.vue index ed3fb07..3a6a5d5 100644 --- a/order/addCourse/addCourse.vue +++ b/order/addCourse/addCourse.vue @@ -127,7 +127,7 @@ isShelves: 0, hotTag: 1, productName: this.keyword, - productType: this.curTab, + productClassification: this.curTab, }).then(({ page }) => { const { records } = page const list = this.courses @@ -167,8 +167,8 @@ this.getList() }, // tab切换 - tabChange(tab) { - this.curTab = tab.id + tabChange(id) { + this.curTab = id this.initList() }, // 选择框回调 @@ -232,16 +232,16 @@ miniProgramPictureAddress: e.appletIcon || '', // 图标 settlementPrice: trial ? 0 : '', // 结算价 settlementPriceUnit: e.settlementPrice || 0, // 结算单价 - serviceFee: 0 // 平台服务费(前端计算后展示,不入库) + serviceFee: 0, // 平台服务费(前端计算后展示,不入库) + mallNonAssociatedLinks: e.mallNonAssociatedLinks // 产品链接 } }, // 判断是否为客户已有的课程 - handleRenew(authority, customerId, productId, mallId, result, resolve, reject) { + handleRenew(authority, customerId, productId, result, resolve, reject) { renew({ authority, customerId, productId, - mallId }).then(({ orderOthers }) => { result.map(e => { const item = orderOthers.find(n => n.dataOrCourseId == e.dataOrCourseId && n.authority == authority && e.authority == authority) @@ -267,12 +267,6 @@ const list2 = [] // 职站增值 const list3 = [] // 实训课程(非集成) const list4 = [] // 实验工具 - - const mallId1 = [] // 实训、理论 - const mallId0 = [] // 数据前瞻 - const mallId2 = [] // 职站增值 - const mallId3 = [] // 实训课程(非集成) - const mallId4 = [] // 实验工具 const { customerId } = this const listPromise = [] @@ -290,20 +284,15 @@ const pid = +e.associatedProduct const mallId = e.mallId if (classId == 1 || classId == 2) { - list1.push(pid) - mallId1.push(mallId) + list1.push(mallId) } else if (classId == 3) { - list2.push(pid) - mallId2.push(mallId) + list2.push(mallId) } else if (classId == 4) { - list3.push(pid) - mallId3.push(mallId) + list3.push(mallId) } else if (classId == 5) { - list0.push(pid) - mallId0.push(mallId) + list0.push(mallId) } else if (classId == 6) { - list4.push(pid) - mallId4.push(mallId) + list4.push(mallId) } result.push(this.createParam(e, this.$util.getOrderType(classId))) resolve() @@ -316,19 +305,19 @@ const promises = [] // 有5种产品,要传不同的authority调renew接口 list0.length && promises.push(new Promise((resolve, reject) => { - this.handleRenew(0, customerId, list0, mallId0, result, resolve, reject) + this.handleRenew(0, customerId, list0, result, resolve, reject) })) list1.length && promises.push(new Promise((resolve, reject) => { - this.handleRenew(1, customerId, list1, mallId1, result, resolve, reject) + this.handleRenew(1, customerId, list1, result, resolve, reject) })) list2.length && promises.push(new Promise((resolve, reject) => { - this.handleRenew(2, customerId, list2, mallId2, result, resolve, reject) + this.handleRenew(2, customerId, list2, result, resolve, reject) })) list3.length && promises.push(new Promise((resolve, reject) => { - this.handleRenew(3, customerId, list3, mallId3, result, resolve, reject) + this.handleRenew(3, customerId, list3, result, resolve, reject) })) list4.length && promises.push(new Promise((resolve, reject) => { - this.handleRenew(4, customerId, list4, mallId4, result, resolve, reject) + this.handleRenew(4, customerId, list4, result, resolve, reject) })) Promise.all(promises).then(_ => { uni.setStorageSync('courses', result) // 把选中的产品添加至缓存 diff --git a/order/clientDetail/clientDetail.vue b/order/clientDetail/clientDetail.vue index d506ec4..844ac0e 100644 --- a/order/clientDetail/clientDetail.vue +++ b/order/clientDetail/clientDetail.vue @@ -94,7 +94,7 @@ 已订阅产品 - + 订单 diff --git a/order/editCourse/editCourse.vue b/order/editCourse/editCourse.vue index 29d76a8..5f0653a 100644 --- a/order/editCourse/editCourse.vue +++ b/order/editCourse/editCourse.vue @@ -22,7 +22,6 @@ 使用期限 - {{ units.find(e => e.id === item.options).text }} @@ -56,7 +55,6 @@ 元 - @@ -72,7 +70,6 @@ 元 - @@ -280,7 +277,6 @@ getPartnerTeamRates({ teamId: this.teamId }).then(({ teamRates }) => { - console.log('teamRates=>',teamRates) this.rate = teamRates.annualMarketingFee || 0 }).catch(res => {}) }, diff --git a/order/orderDetail/orderDetail.vue b/order/orderDetail/orderDetail.vue index 71fd552..065af02 100644 --- a/order/orderDetail/orderDetail.vue +++ b/order/orderDetail/orderDetail.vue @@ -80,7 +80,7 @@ - + @@ -88,7 +88,7 @@ 起始日期 - {{ item.endTime ? item.startTime + ' - ' + item.endTime : item.startTime}} + {{ item.endTime ? item.startTime + ' - ' + item.endTime : item.startTime}} {{ item.endTime ? item.startTime + ' - ' + item.endTime : item.startTime}} @@ -97,8 +97,8 @@ 使用期限 - - {{item.periodOfUse}}{{ units.find(e => e.id === item.options).text }} + + {{item.periodOfUse}}{{ units.find(e => e.id === item.options).text }} {{ units.find(e => e.id === item.options).text }} @@ -116,7 +116,7 @@ 结算价 - {{ item.settlementPrice }} + {{ item.settlementPrice }} 元 @@ -132,7 +132,7 @@ 成交价 - {{ item.finalPrice }} + {{ item.finalPrice }} 元 @@ -169,7 +169,7 @@ 提交({{ courses.length }}) - {{ courses.find(e => !e.ship) ? '一键发货' : '取消全部发货' }} + {{ courses.find(e => !e.ship) ? '一键发货' : '取消全部发货' }} @@ -211,6 +211,10 @@ + + + + @@ -292,7 +296,8 @@ rate: '', shipInfo: '', - shipContent: '' + shipContent: '', + curRow: {} } }, watch: { @@ -331,13 +336,12 @@ uni.removeStorageSync('courses') } catch (e) {} this.calcTotal() - } else { - // 如果是客户订单记录页面点的新增,会有客户id,要默认选中该客户 - const { customerId } = options - customerId && this.customerChange({ - customerId - }) } + // 如果是客户订单记录页面点的新增,会有客户id,要默认选中该客户 + const { customerId } = options + customerId && this.customerChange({ + customerId + }) // 非详情才需要查询客户 this.isDetail || this.getCustomer() // 设置标题 @@ -371,6 +375,9 @@ this.getBm() } } + order.orderOther.forEach(e => { + e.settlementPriceUnit = e.settlementPrice + }) this.courses = order.orderOther for (let i = 0; i < 5; i++) { this.handleRenew(i) @@ -401,25 +408,23 @@ e.serviceFee = (e.finalPrice * (this.rate / 100)).toFixed(2) // 服务费 != 0 && 才需要算 courses['list' + e.authority].list.push(e) }) - console.log(123,courses) this.courseList = courses }).catch(e => {}) }, // 处理开始结束时间和订单状态(参考pc,订单模块不是本人开发的,所以也不懂这里逻辑) handleRenew(authority) { const list = this.courses.filter(e => e.authority == authority) - const productId = list.map(e => e.dataOrCourseId) - const mallId = list.map(e => e.mallId) + const productId = list.map(e => e.mallId) productId.length && this.promises.push(new Promise((resolve, reject) => { renew({ authority, customerId: this.form.customerId, productId, - mallId }).then(({ orderOthers }) => { const { courses } = this const now = new Date() orderOthers.map(e => { + // e.settlementPriceUnit = e.settlementPrice const item = courses.find(n => n.dataOrCourseId == e.dataOrCourseId && n.authority == authority && e.authority == authority) if (item) { if (this.isRenew) { // 续费 @@ -593,7 +598,10 @@ // 前往创建客户 toClient() { uni.setStorageSync('courses', this.courseList) - this.$util.to(`/order/clientDetail/clientDetail`) + uni.redirectTo({ + url: `/order/clientDetail/clientDetail` + }) + // this.$util.to(`/order/clientDetail/clientDetail`) }, // 删除课程 delCourse(c, i) { @@ -635,7 +643,7 @@ calcTotal(out) { this.handleErr('orderType') const { form } = this - const isTrial = form.orderType === 2 // 是否试用 + const isTrial = form.orderType == 2 // 是否试用 let total = 0 const list = this.courses let purchase = 0 // 总采购成本 @@ -654,16 +662,16 @@ list.map(e => { // out=1 && 试用,则把结算价等重置为0 if (out && isTrial) { + console.log(123, e, out, isTrial) e.settlementPrice = 0 e.serviceFee = 0 e.finalPrice = 0 e.finalValue = 0 e.discountRate = '0%' } else { - console.log(111, e) this.calcDiscount(e) this.dealSettlePrice(e) - this.calcFinalPrice(e) + // this.calcFinalPrice(e) const curPurchase = +e.settlementPrice + +e.serviceFee purchase += curPurchase profit += +e.finalPrice - curPurchase @@ -672,10 +680,27 @@ form.purchaseCost = Math.round(purchase) form.profit = Math.round(profit) form.orderAmount = (+form.purchaseCost + +form.profit).toFixed(2) + console.log(111, this.courseList, this.courses) + }, + // 计算订单总额 + calcAmount() { + const { form } = this + const list = this.courses + let purchase = 0 // 总采购成本 + let profit = 0 // 总利润 + list.map(e => { + const curPurchase = +e.settlementPrice + +e.serviceFee + purchase += curPurchase + profit += +e.finalPrice - curPurchase + }) + form.purchaseCost = Math.round(purchase) + form.profit = Math.round(profit) + form.orderAmount = (+form.purchaseCost + +form.profit).toFixed(2) + console.log(111, this.courseList, this.courses) }, // 显示发货信息 showShip(row) { - console.log(33) + this.curRow = row let val = '' row.mallNonAssociatedLinks && row.mallNonAssociatedLinks.forEach(e => { val += e.urlName + ':' + e.url + '\n' @@ -684,6 +709,16 @@ this.shipContent = row.shipContent || val this.$refs.info.open() }, + // 关闭发货信息 + closeShip() { + this.$refs.info.close() + }, + // 提交发货信息 + submitShip() { + if (this.shipContent.length > 300) return this.$util.errMsg('请填写300个字以内!') + this.curRow.shipContent = this.shipContent + this.$refs.info.close() + }, // 复制发货信息 copy() { const that = this @@ -730,64 +765,6 @@ this.courses = courses this.isEdit && bulkShipping({orderOthers: courses}).then(res => {}).catch(res => {}) // 编辑的情况下,需要调接口去直接发货 }, - // 提交 - submit() { - const { form } = this - const courses = [] - if (!form.customerId) { - this.err = 'customerName' - return this.$util.errMsg('请选择客户!') - } - if (!form.orderType) { - 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('请选择课程权限或数据权限后再确认订单!') - let invalid = 0 - courses.forEach(e => { - if (!e.periodOfUse) { - invalid = 1 - return this.$util.errMsg('请输入使用期限!') - } - e.startTime = this.$util.formatDate(new Date(e.startTime), 'yyyy-MM-dd') - }) - if (invalid) return false - if (this.isRenew || courses.some(e => e.renew)) form.orderNature = 2 - uni.showLoading({ - title: '提交中' - }) - const data = { - contractInformation: this.contract, // 合同信息 - order: form, // 订单基本数据 - orderOther: courses // 产品列表 - } - if (this.isEdit || this.isHandle) { - update(data).then(res => { - uni.hideLoading() - this.$util.sucMsg('编辑成功') - setTimeout(() => { - // this.$util.to(`../orders/orders`) - uni.navigateBack() - }, 1500) - }).catch(res => { - uni.hideLoading() - }) - } else { - add(data).then(res => { - uni.hideLoading() - this.$util.sucMsg('添加成功') - setTimeout(() => { - // this.$util.to(`../orders/orders`) - uni.navigateBack() - }, 1500) - }).catch(res => { - uni.hideLoading() - }) - } - }, calcDate(row, fromData) { clearTimeout(this.timer) this.timer = setTimeout(() => { @@ -848,9 +825,8 @@ }, 500) }, dealSettlePrice(row) { - console.log('dealSettlePrice', row) // 如果是试用,结算价和平台服务费都是0 - if (this.orderType == 2) { + if (this.form.orderType == 2) { row.settlementPrice = 0 row.serviceFee = 0 } else { @@ -869,7 +845,8 @@ row.settlementPrice = this.$util.handleNaN(sPrice) // 平台服务费 row.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2) - console.log('row.settlementPrice =>' ,this.rate,row.serviceFee) + this.calcAmount() + console.log('row.settlementPrice =>' ,row.settlementPrice,row.settlementPriceUnit,sPrice,row) } }, calcDiscount(row) { @@ -928,7 +905,68 @@ // 结算价修改后计算平台服务费 updateServiceFee(row) { options.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2) - } + }, + // 提交 + submit() { + const { form } = this + const courses = [] + if (!form.customerId) { + this.err = 'customerName' + return this.$util.errMsg('请选择客户!') + } + if (!form.orderType) { + 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('请选择课程权限或数据权限后再确认订单!') + let invalid = 0 + courses.forEach(e => { + if (!e.periodOfUse) { + invalid = 1 + return this.$util.errMsg('请输入使用期限!') + } + e.startTime = this.$util.formatDate(new Date(e.startTime), 'yyyy-MM-dd') + }) + if (invalid) return false + if (this.isRenew || courses.some(e => e.renew)) form.orderNature = 2 + uni.showLoading({ + title: '提交中' + }) + const data = { + contractInformation: this.contract, // 合同信息 + order: form, // 订单基本数据 + orderOther: courses // 产品列表 + } + if (this.isEdit || this.isHandle) { + update(data).then(res => { + uni.hideLoading() + this.$util.sucMsg('编辑成功') + setTimeout(() => { + // this.$util.to(`../orders/orders`) + uni.navigateBack() + }, 1500) + }).catch(res => { + uni.hideLoading() + }) + } else { + add(data).then(res => { + uni.hideLoading() + this.$util.sucMsg('添加成功') + setTimeout(() => { + // this.$util.to(`../orders/orders`) + uni.navigateBack() + // uni.redirectTo({ + // url: `../orders/orders` + // }) + }, 1500) + }).catch(res => { + uni.hideLoading() + }) + } + }, } } @@ -988,6 +1026,9 @@ padding: 0 16rpx; margin-right: 10rpx; font-size: 28rpx; + &.mg { + margin-left: 10rpx; + } } .del { width: 40rpx; @@ -1029,6 +1070,7 @@ } } .bottom { + z-index: 2; position: fixed; bottom: 0; padding-bottom: env(safe-area-inset-bottom); @@ -1155,15 +1197,17 @@ color: #333; } } + .edit { + margin-left: 10rpx; + } } -.period{ - display: inline-block; - text-align: right; - margin-right: 10rpx; - margin-left: 20rpx; - color: #333; - width: 60%;font-size: 28rpx; +.period { + flex: none; + width: 100rpx; + font-size: 28rpx; + text-align: center; } + .defaultBox { font-size: 28rpx; } @@ -1175,4 +1219,17 @@ margin-bottom: 20rpx; } } +.ship-btns { + display: flex; + justify-content: center; + align-items: center; + button { + padding: 0 16rpx; + margin: 0; + font-size: 28rpx; + &:first-child { + margin-right: 20rpx; + } + } +} diff --git a/order/ordered/ordered.vue b/order/ordered/ordered.vue index e412121..fcc59e4 100644 --- a/order/ordered/ordered.vue +++ b/order/ordered/ordered.vue @@ -5,8 +5,14 @@ -