From 13c39305b2fdc9555e349501a47d43a135d15f7b Mon Sep 17 00:00:00 2001 From: e <2432808546@qq.com> Date: Thu, 15 Jul 2021 10:06:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=9F=BA=E6=9C=AC=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/http.js | 2 +- src/views/order/AddOrder.vue | 318 +++++++++++++++++++------------ src/views/order/selectClient.vue | 13 +- 3 files changed, 210 insertions(+), 123 deletions(-) diff --git a/src/utils/http.js b/src/utils/http.js index 4c86c9b..e9682f5 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -41,7 +41,7 @@ axios.interceptors.response.use( response => { if (response.status === 200) { if(response.data.status!==200){// 接口定义的非正常返回的时候,应当处于报错状态 - Message.error(response.data.message) + Message.error(response.data.message)// 非服务器状态码对应的报错信息 return Promise.reject(response); } return Promise.resolve(response); diff --git a/src/views/order/AddOrder.vue b/src/views/order/AddOrder.vue index 80c9b68..4a072d5 100644 --- a/src/views/order/AddOrder.vue +++ b/src/views/order/AddOrder.vue @@ -11,7 +11,10 @@ 返回 订单处理 - 确定 + + 确定 + + 确定 @@ -22,7 +25,7 @@ 基本信息
- + @@ -41,22 +44,23 @@ - - + + - - + + -
+
+ - + @@ -70,8 +74,8 @@ - - + + @@ -89,10 +93,10 @@

课程权限
- 添加 + 添加
- + @@ -171,10 +175,10 @@

数据平台权限 - 添加 + 添加 - + @@ -182,7 +186,7 @@ @@ -214,22 +218,22 @@ - + @@ -237,27 +241,48 @@ - + + + @@ -271,7 +296,7 @@
- + @@ -470,6 +495,9 @@ export default { data() { return { loading:false,// 页面加载 + disabled:false,// 全局禁用,用于查看。 + editDisabled:false,// 编辑禁用,区分查看的功能 + showSelectClient:false,// 切换展示选择客户页 form: {// 基本信息 // orderNumber: '',// 编号 @@ -622,107 +650,79 @@ export default { created(){ this.token = sessionStorage.getItem('token') this.getCityData() + // 处于查看状态 if(this.$route.query.watch){ + this.disabled = true this.getDetail(this.$route.query.watch) } + // 处于编辑状态 if(this.$route.query.edit){ + this.editDisabled = true this.getDetail(this.$route.query.edit) } }, - // mounted() { - // if(this.form.orderId){ - // let data = { - // orderId: this.form.orderId - // } - // this.$get(this.api.queryOrderDetails,data).then((res) => { - // this.form = { - // orderNumber: res.message[0].orders[0].orderNumber, - // orderDate: res.message[0].orders[0].orderDate, - // provinceId: res.message[0].orders[0].provinceId, - // orderContact: res.message[0].orders[0].orderContact, - // email: res.message[0].orders[0].email, - // customerId: res.message[0].orders[0].customerId, - // orderType: res.message[0].orders[0].orderType, - // cityId: res.message[0].orders[0].cityId, - // phone: res.message[0].orders[0].phone, - // orderAmount: res.message[0].orders[0].orderAmount, - // orderId: res.message[0].orders[0].orderId, - // } - // this.jurisdictionData = res.message[0].coursePermissionss - // let arr1 = this.jurisdictionData - // let result1 = arr1.map(e => e.courseId).join() - // this.curArr = this.curArr.concat(result1) - // if(res.message[0].contractInformations[0].contractInformationLink){ - // var iconImg = []; - // iconImg.push({'name':'合同文件','url': res.message[0].contractInformations[0].contractInformationLink}); - // this.uploadList = iconImg - // } - // this.contract = { - // contractInformationName: res.message[0].contractInformations[0].contractInformationName, - // contractInformationNumber: res.message[0].contractInformations[0].contractInformationNumber, - // contractInformationSum: res.message[0].contractInformations[0].contractInformationSum, - // contractInformationLink: res.message[0].contractInformations[0].contractInformationLink, - // contractInformationId: res.message[0].contractInformations[0].contractInformationId, - // orderId: res.message[0].contractInformations[0].orderId - // } - // this.getCityData() - // this.getSchoolData() - // }).catch((res) => { - // }) - // } - // }, methods: { // 读取页面详情 async getDetail(id){ this.$get(this.api.orderDetail,{orderId:+id}).then(res=>{ console.log(res,'请求详情'); - let form = res.orderDetails.order - console.log(form.orderAmount,'amount'); - + let form = res.orderDetails.order,// 基本信息 + contract = res.orderDetails.contractInformation,// 合同 + list = res.orderDetails.orderOther// 俩列表 + list.map(e=>{ + e.ship?e.ship=true:e.ship = false + e.isEnable?e.isEnable=false:e.isEnable=true + }) + let dataArr = list.filter(e=>{// 数据平台 + return e.authority===0 + }), + classArr = list.filter(e=>{// 课程权限 + return e.authority===1 + }) + console.log(dataArr,'dataArr'); this.form = { - orderNumber : form.orderNumber, - createTime:form.createTime, - provinceId:form.provinceId, - orderContact:form.orderContact, - email:form.email, - customerId:form.customerId, - customerName:form.customerName, - orderType:form.orderType, - cityId:form.cityId, - phone:form.phone, - orderAmount:form.orderAmount, + orderNumber: form.orderNumber, + createTime: form.createTime, + provinceId: form.provinceId, + orderContact: form.orderContact, + email: form.email, + customerId: form.customerId, + customerName: form.customerName, + orderType: form.orderType, + cityId: form.cityId, + phone: form.phone, + orderAmount: form.orderAmount, + orderId:form.orderId } - console.log(this.form,'amount'); - + if(contract.startTime&&contract.endTime){ + this.contractTime = [contract.startTime,contract.endTime] + } + this.contract = { + contractName:contract.contractName, + contractMoney:contract.contractMoney, + contractNumber:contract.contractNumber, + startTime:contract.startTime?contract.startTime:'', + endTime:contract.endTime?contract.endTime:'', + uploadList:{name:contract.contractFile?contract.contractFile.split().pop():'',url:contract.contractFile} + } + this.dataPlatform = dataArr }) }, - // 订单客户框触发选择页面 - gotoClient(){ - this.showSelectClient = !this.showSelectClient - - }, - // 选择客户返回传值 - backToOrder(val){ - this.showSelectClient = !this.showSelectClient - if(val.id){ - this.form.customerName = val.name - this.form.customerId = val.id - this.$get(this.api.queryCustomerDetails,{customerId:val.id}).then(res=>{ - this.form.provinceId = res.result.customer.provinceId - this.form.cityId = res.result.customer.cityId - this.getCityData() - }) - this.$forceUpdate() - } - }, // 新增订单 addOrder(){ + this.dataPlatform.map(e=>{ + e.ship?e.ship=1:e.ship=0 + e.isEnable?e.isEnable=0:e.isEnable=1 + }) + this.jurisdictionData.map(e=>{ + e.ship?e.ship=1:e.ship=0 + e.isEnable?e.isEnable=0:e.isEnable=1 + }) let param = { contractInformation:this.contract,//合同信息 order:this.form,// 订单基本数据 - orderOther:[...this.jurisdictionData,...this.dataPlatform.map(e=>e.authority=0)]//订单其他数据 + orderOther:[...this.dataPlatform,...this.jurisdictionData]//订单其他数据 } - console.log(this.$refs,'refs'); this.$refs['form'].validate((valid) => { if (valid) { this.loading = true @@ -741,6 +741,54 @@ export default { }) }, + // 编辑订单确定 + orderUpdate(){ + this.dataPlatform.map(e=>{ + e.ship?e.ship=1:e.ship=0 + e.isEnable?e.isEnable=0:e.isEnable=1 + }) + this.jurisdictionData.map(e=>{ + e.ship?e.ship=1:e.ship=0 + e.isEnable?e.isEnable=0:e.isEnable=1 + }) + let param = { + contractInformation:this.contract,//合同信息 + order:this.form,// 订单基本数据 + orderOther:[...this.dataPlatform,...this.jurisdictionData]//订单其他数据 + } + this.loading = true + this.$post(this.api.orderUpdate,param).then(res=>{ + this.$message.success('修改成功!') + this.loading = false + this.$router.push('/order') + }).catch(err=>{ + this.loading = false + + }) + }, + // 订单客户框触发选择页面 + gotoClient(){ + this.showSelectClient = !this.showSelectClient + }, + // 选择客户返回传值 + backToOrder(val){ + this.showSelectClient = !this.showSelectClient + if(val.id){ + this.form.customerName = val.name + this.form.customerId = val.id + this.form.phone = val.phone + this.form.email = val.email + this.form.orderContact = val.name + console.log(val,'取得返回值'); + this.$get(this.api.queryCustomerDetails,{customerId:val.id}).then(res=>{ + this.form.provinceId = res.result.customer.provinceId + this.form.cityId = res.result.customer.cityId + this.getCityData() + }) + this.$forceUpdate() + } + }, + // 课程权限 addClassJurisdiction(){ @@ -821,9 +869,16 @@ export default { // 计算折扣率 discount(val,row){ if(val){ - row.discountRate = Math.floor(val/row.marketValue*100).toFixed(3)+'%' + row.discountRate = Math.floor(val/row.marketValue*100).toFixed(2)+'%' } }, + // 已知成交和总额,计算账号数目 + userAmount(val,row){ + if(val&&row.totalAmount){ + row.accountNum = Math.floor(row.totalAmount/val) + } + }, + // 合同起止日期选择 contractTimeChange(val){ if(val.length>0){ @@ -848,17 +903,24 @@ export default { if(row.accountNum){// 若有账号 row.marketValue = all/row.accountNum } - if(row.marketValue){ - + if(row.finalPrice){ + row.accountNum = all/row.finalPrice } + console.log(val,row); } }, // 权限switch切换--计算天数 formSwitch (e,row) { - this.deadLine(row.periodOfUse,row) + if(this.editDisabled){ + + return + } + // this.deadLine(row.periodOfUse,row) }, + // // 使用期限转换以及计算剩余天数 deadLine(e,row){ + console.log(row.ship,e,'row.consignment'); if(e==='') { console.log('進入return'); @@ -867,6 +929,7 @@ export default { return } function completeDate(value) { + if(value==0) return '12' return value < 10 ? "0"+value:value; } let char = "-"; @@ -877,8 +940,8 @@ export default { //补全0,并拼接当前的时间点 let nowYear = year + char + completeDate(month) + char +completeDate(day); // 判断结束日期 - console.log(parseInt(e%12),'取余'); - let endYear = +year + parseInt(e/12) + char + completeDate((month+e)%12) + char +completeDate(day); + console.log('取余',year,parseInt((+month+(+e))%12),+month+(+e)); + let endYear = +year + parseInt((+month+(+e))/12) + char + completeDate((+month+(+e))%12) + char +completeDate(day); // 得出起始年月日 row.startTime = nowYear row.endTime = endYear @@ -895,11 +958,20 @@ export default { // 计算成交总额 dealComputers(e,row){ if(row.finalPrice&&row.accountNum){ - row.totalAmount = row.finalPrice*row.accountNum/10000; + row.totalAmount = (row.finalPrice*row.accountNum/10000).toFixed(2); } this.allAmount() }, + // 删除数据平台产品 + delDataForm(index){ + this.$confirm('确定要删除吗?', '提示', { + type: 'warning' + }) + .then(() => { + this.dataPlatform.splice(index,1) + }) + }, // 清除省份 clearprovince(){ this.form.cityId = '', @@ -1104,11 +1176,15 @@ export default {