From b26d59d32b2db8458268cbc6227faaeb8f8d1c95 Mon Sep 17 00:00:00 2001 From: e <2432808546@qq.com> Date: Wed, 14 Jul 2021 11:29:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E5=8F=B0=E8=AE=A2=E5=8D=95--70%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/order/AddOrder.vue | 640 ++++++++++++++++++------------- src/views/order/Order.vue | 2 +- src/views/order/selectClient.vue | 19 +- 3 files changed, 389 insertions(+), 272 deletions(-) diff --git a/src/views/order/AddOrder.vue b/src/views/order/AddOrder.vue index ac5b83e..80c9b68 100644 --- a/src/views/order/AddOrder.vue +++ b/src/views/order/AddOrder.vue @@ -1,5 +1,5 @@ @@ -457,31 +469,38 @@ export default { }, data() { return { + loading:false,// 页面加载 showSelectClient:false,// 切换展示选择客户页 - - token: this.$store.state.loginToken, form: {// 基本信息 - orderNumber: '', - orderDate: '', - provinceId: '', - orderContact: '', + // orderNumber: '',// 编号 + provinceId: '',// 省份id + orderContact: '',// 联系人 email: '', - customerId: '', + customerId: '',// 客户id orderType: '', cityId: '', phone: '', - orderAmount: '', - orderId: this.$store.state.orderId, - customerName:'' + orderAmount: 0, + // orderId: this.$store.state.orderId, + customerName:'',// 客户名称 }, - contractInformation: {//合同信息 - contractInformationName: '', - contractInformationNumber: '', - contractInformationSum: '', - contractInformationLink: '', - contractInformationId: '', - orderId: '' + jurisdictionData: [],// 课程权限 + dataPlatform:[],// 数据平台data + + contract:{ // 合同信息 + contractName:'', // 合同名称 + contractFile: '', // 合同文件 + contractMoney: '', // 合同金额 + contractNumber: '',// 合同编号 + startTime: '', // 期限-头 + endTime: '', // 期限-尾 + // orderId: '', // 绑定订单id }, + contractTime:[],// 合同起止日期绑定值 + + token:'', + + orderOther:{// 订单其他数据 }, @@ -491,28 +510,37 @@ export default { { required: true, message: '请输入订单编号', trigger: 'blur' } ], customerName: [ - { required: true, message: '请选择订单客户', trigger: 'blur' } + { required: true, message: '请选择订单客户', trigger: 'change' } ], orderContact: [ { required: true, message: '请输入联系人姓名', trigger: 'blur' } ], - createTime: [ - { required: true, message: '请选择订单时间', trigger: 'change' } - ], + orderType: [ { required: true, message: '请选择订单类型', trigger: 'change' } ], phone: [ - { required: true, message: '请选择客户获取手机号', trigger: 'blur' }, + { required: true, message: '请输入手机号', trigger: 'blur' }, { pattern: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' } ], + email: [ + { required: true, message: '请输入邮箱地址', trigger: 'blur' }, + { + pattern: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, + message: '请输入正确的邮箱', + trigger: 'blur' + } + ], + orderAmount: [ // { pattern: /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/, message: '请输入正确金额格式,可保留两位小数' } - { pattern: /(?:^[1-9]([0-9]+)?(?:\.[0-9]{1,2})?$)|(?:^(?:0)$)|(?:^[0-9]\.[0-9](?:[0-9])?$)/, message: '请输入正确金额格式,可保留两位小数' } + { required: true, message: '请输入订单金额', trigger: 'blur' }, + + // { pattern: /(?:^[1-9]([0-9]+)?(?:\.[0-9]{1,2})?$)|(?:^(?:0)$)|(?:^[0-9]\.[0-9](?:[0-9])?$)/, message: '请输入正确金额格式,可保留两位小数', trigger: 'blur'} ], }, orderTypeList: [{ @@ -526,29 +554,7 @@ export default { provinceList: this.$store.state.provinceList, cityList: [], schoolList: [], - jurisdictionData: [ - { name:'1', - date:'', - startDate:'', - endDate:'', - consignment:false, - - } - ],// 课程权限 - - dataPlatform:[ - { - name:'1', - date:'', - startDate:'', - endDate:'', - platformState:'', - bargain:'', - account:'', - gross:'' - - } - ],// 数据平台data + permissionData: [], classVisible: false, configSearch: '', @@ -600,11 +606,21 @@ export default { extranet: '' }], curArr: '', - test: [] + test: [], + + // 数据平台权限弹框 + showPlatform:false,// 弹框显示 + platfromTotals:0,// 列表条目 + platfromPage:1,// 页码 + boxDataPlatform:[],// 数据平台弹框 + platformSelect:[],// 数据平台弹框选中 + productName:'',// 搜索产品名称 + + }; }, created(){ - console.log(this.$route.query.watch,'route'); + this.token = sessionStorage.getItem('token') this.getCityData() if(this.$route.query.watch){ this.getDetail(this.$route.query.watch) @@ -613,48 +629,48 @@ export default { 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.contractInformation = { - // 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) => { - // }) - // } - }, + // 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){ @@ -680,10 +696,10 @@ export default { }) }, - // 点击订单客户框触发 + // 订单客户框触发选择页面 gotoClient(){ - // 记录当前页面数据,进入次级页面选择客户 this.showSelectClient = !this.showSelectClient + }, // 选择客户返回传值 backToOrder(val){ @@ -702,25 +718,187 @@ export default { // 新增订单 addOrder(){ let param = { - contractInformation:{},//合同信息 - order:{},// 订单基本数据 - orderOther:{}//订单其他数据 + contractInformation:this.contract,//合同信息 + order:this.form,// 订单基本数据 + orderOther:[...this.jurisdictionData,...this.dataPlatform.map(e=>e.authority=0)]//订单其他数据 } - this.$post(this.api.orderAdd,param).then(res=>{ - console.log(res,'新增订单'); + console.log(this.$refs,'refs'); + this.$refs['form'].validate((valid) => { + if (valid) { + this.loading = true + this.$post(this.api.orderAdd,param).then(res=>{ + console.log(res,'新增订单'); + this.$router.push('/order') + this.loading = false + this.$message.success('添加订单成功!') + }).catch(err=>{ + this.loading = false + }) + } else { + this.$message('请填上必填项!'); + return false; + } }) + }, // 课程权限 addClassJurisdiction(){ this.classVisible = !this.classVisible - }, // 数据平台权限 - addDataJurisdiction(){ + addDataJurisdiction(val){ + if(val!=='search'){ + this.showPlatform = !this.showPlatform + } + let param = { + pageSize:10, + pageNum:this.platfromPage, + status:1, + productName:this.productName + } + this.$post(this.api.listByEntity,param).then(res=>{ + console.log(res,'请求成功'); + this.boxDataPlatform = res.pageList.records + this.platfromTotals = res.pageList.total + }).catch(err=>{ + console.log(err,'请求错误'); + }) }, + // 数据平台--弹框列表选中 + boxDataPlatformSelection(val){ + this.platformSelect = val + console.log(val,'数据选中',this.platformSelect); + }, + // 数据平台弹框--确定 + addPlatform(){ + console.log(this.platformSelect,'this.platformSelect'); + if(this.platformSelect.length>0){ + let that = this + let fn = function(e){ + let obj = { + productName:e.productName,// 名称 + periodOfUse:'',// 使用期限 + dataOrCourseId:e.id,// id + accountNum:'',// 账号数 + startTime:'',// 开始 + endTime:'', // 终止 + remainingPeriod:'',// 剩余期限 + marketValue:e.market,// 市场价 + finalPrice:'',// 成交价 + discountRate:'',// 折扣率 + totalAmount:'',// 总价 + ship:false,// 发货否 + authority:0,// 数据平台权限 + } + that.dataPlatform.push(obj) + } + + this.platformSelect.map(e=>{// 取得选中的值,进行赋值 + if(this.dataPlatform.length>0){ + // 比对是否存在该id,若存在,不操作,不存在,则进行push操作 + let find = this.dataPlatform.some(i=>e.id === i.dataOrCourseId)// 判断已有的相同的id不进行处理 + if(!find){ + fn(e) + } + }else{ + fn(e) + } + }) + this.showPlatform = !this.showPlatform + this.platformSelect = [] + }else{ + return this.$message('请选中数据后再确定!') + } + }, + // 数据平台弹框--页数变更 + platfromCurrentChange(val) { + this.platfromPage = val; + this.addDataJurisdiction(); + }, + // 计算折扣率 + discount(val,row){ + if(val){ + row.discountRate = Math.floor(val/row.marketValue*100).toFixed(3)+'%' + } + }, + // 合同起止日期选择 + contractTimeChange(val){ + if(val.length>0){ + this.contract.startTime = val[0] + this.contract.endTime = val[1] + console.log(this.contract.startTime,this.contract.endTime,'s-e'); + } + }, + // 新增数据平台权限时,计算总的金额数目 + allAmount($event,row){ + // 课程权限未完善,没写 + let arr = [] + this.dataPlatform.map(e=>{ + arr.push(+e.totalAmount) + }) + this.form.orderAmount = arr.reduce((a,b)=>a+b) + }, + // 总金额--计算账号,或者市场价 + allAmountChange(val,row){ + if(val){ + let all = val*10000 + if(row.accountNum){// 若有账号 + row.marketValue = all/row.accountNum + } + if(row.marketValue){ + + } + } + }, + // 权限switch切换--计算天数 + formSwitch (e,row) { + this.deadLine(row.periodOfUse,row) + }, + // 使用期限转换以及计算剩余天数 + deadLine(e,row){ + console.log(row.ship,e,'row.consignment'); + if(e==='') { + console.log('進入return'); + row.startTime = '' + row.endTime = '' + return + } + function completeDate(value) { + return value < 10 ? "0"+value:value; + } + let char = "-"; + let nowDate = new Date() + let day = nowDate.getDate(); + let month = nowDate.getMonth() + 1; + let year = nowDate.getFullYear(); + //补全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); + // 得出起始年月日 + row.startTime = nowYear + row.endTime = endYear + + // 计算剩余天数 + let date1 = Date.parse(endYear); + + let date2 = Date.parse(nowYear); + let ms = Math.abs(date1 - date2) + let days = Math.floor(ms / (24 * 3600 * 1000)); + console.log(Date.parse(endYear),nowYear,date1,date2,days,'剩余期限'); + row.remainingPeriod = days + }, + // 计算成交总额 + dealComputers(e,row){ + if(row.finalPrice&&row.accountNum){ + row.totalAmount = row.finalPrice*row.accountNum/10000; + } + this.allAmount() + }, // 清除省份 clearprovince(){ @@ -781,43 +959,6 @@ export default { this.form.email = res.message[0].email }).catch(res => {}); }, - async saveOrder() { - // try { - // await Promise.all([ - // this.$refs.form.validate(), - // this.$refs.contractInformation.validate() - // ]); - // if(this.jurisdictionData.length == 0){ - // this.$message.error('请添加课程配置!'); - // }else{ - // function findCherries(fruit) { - // return fruit.transactionPrice === ''; - // } - // if(this.jurisdictionData.find(findCherries)){ - // this.$message.error('请先填写成交价!'); - // }else{ - // let data = { - // order: this.form, - // coursePermissionss: this.jurisdictionData, - // contractInformation: this.contractInformation - // } - // if(this.form.orderId){ - // this.$post(this.api.updateOrder,data).then((res) => { - // this.$message.success('编辑成功'); - // this.goback() - // }).catch((res) => {}) - // } else { - // this.$post(this.api.addOrder,data).then((res) => { - // this.$message.success('添加成功'); - // this.goback() - // }).catch((res) => {}) - // } - // } - // } - // } catch (error) { - // return; - // } - }, // // 获取应用配置 // getConfig(rows){ @@ -866,6 +1007,7 @@ export default { this.pageNo = val; this.getConfig(); }, + // 查询应用权限 getPermissions(val){ this.$get(this.api.queryCoursePermissions,val).then(res => { @@ -899,15 +1041,15 @@ export default { }) .catch(() => {}); }, - discountChange(row){ - let reg = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/ - if(!(reg.test(row.transactionPrice))){ - this.$message.error('请输入正确金额格式,可保留两位小数!'); - row.transactionPrice = '' - }else{ - row.discount = this.Percentage(row.transactionPrice,row.marketPrice) - } - }, + // discountChange(row){ + // let reg = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/ + // if(!(reg.test(row.transactionPrice))){ + // this.$message.error('请输入正确金额格式,可保留两位小数!'); + // row.transactionPrice = '' + // }else{ + // row.discount = this.Percentage(row.transactionPrice,row.marketPrice) + // } + // }, getSummaries(param) { const { columns, data } = param; var sums = 0; @@ -918,16 +1060,18 @@ export default { return sums; }, - // 上传文件 + // 上传文件超出 handleExceed(files, fileList) { this.$message.warning( `当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!` ); }, + // 上传成功 uploadSuccess(response, file, fileList) { - this.uploadList.push({ name: file.name, url: response.message.fileUrl }); - this.contractInformation.contractInformationLink = response.message.fileUrl + this.contract.contractFile = response.filesResult.fileUrl + console.log(this.contract,response,'this.contract'); }, + // 上传报错 uploadError(err, file, fileList) { this.$message({ message: "上传出错,请重试!", @@ -935,16 +1079,15 @@ export default { center: true }); }, + // 删除上传合同前的确认 beforeRemove(file, fileList) { return this.$confirm(`确定移除 ${file.name}?`); }, + // 删除文件钩子 handleRemove(file, fileList) { - this.contractInformation.contractInformationLink = '' - }, - downLoad(){ - let downFile = this.contractInformation.contractInformationLink.replace("http://liuwanr.oss-cn-shenzhen.aliyuncs.com/","") - window.open(`${this.api.downloadFiles}?objectName=${downFile}`) + this.contract.contractFile = '' }, + configure(){ this.ipVisible = true }, @@ -954,51 +1097,7 @@ export default { goback(){ this.$router.go(-1) }, - - // 课程部分的switch切换 - courseSwitch(e,row){ - this.deadLine(row.date,row) - }, - // 平台权限switch切换 - platformSwitch (e,row) { - this.deadLine(row.date,row) - }, - // 使用期限转换 - deadLine(e,row){ - console.log(row.consignment,e,'row.consignment'); - if(e===''||!row.consignment) { - console.log('進入return'); - row.startDate = '' - row.endDate = '' - return - } - function completeDate(value) { - return value < 10 ? "0"+value:value; - } - let char = "-"; - let nowDate = new Date() - let day = nowDate.getDate(); - let month = nowDate.getMonth() + 1; - let year = nowDate.getFullYear(); - //补全0,并拼接当前的时间点 - let nowYear = year + char + completeDate(month) + char +completeDate(day); - // 判断结束日期 - let endYear = +year+parseInt(e/12) + char + completeDate(month+e%12) + char +completeDate(day); - // 待接口改 - row.startDate = nowYear - row.endDate = endYear - this.$forceUpdate(); - console.log(endYear,nowYear); - - }, - // 计算成交总额 - dealComputers(e,row){ - if(row.bargain&&row.account){ - row.gross = row.bargain*row.account; - this.$forceUpdate(); - console.log(row.gross,'row.gross'); - } - }, + } }; @@ -1010,6 +1109,9 @@ export default { /deep/ .small .el-input__inner{ width: 70px; } +/deep/ .contractDate .el-date-editor--daterange.el-input__inner{ + width: 100%; +} .mag{ margin-right: 20px; } diff --git a/src/views/order/Order.vue b/src/views/order/Order.vue index 8620bc7..cff1d15 100644 --- a/src/views/order/Order.vue +++ b/src/views/order/Order.vue @@ -83,7 +83,7 @@