+
返回
@@ -77,7 +77,7 @@
- 确定
+ 确定
取消
@@ -477,10 +477,18 @@ export default {
NoAdd: true,
phoneRepeat: false,
emailRepeat: false,
- submiting: false // 新增编辑防抖标识
+ submiting: false, // 新增编辑防抖标识
+ updateTime: 0
};
},
watch: {
+ // 监听信息是否有更改,有的话页面离开的时候要询问是否要保存
+ form: {
+ handler(){
+ this.updateTime++
+ },
+ deep:true
+ },
'form2.keyword': function(val) {
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
@@ -739,226 +747,236 @@ export default {
this.$router.push(`/bmOrder?businessManagerId=${row.businessManagerId}&customerId=${this.customerId}&customerName=${this.form.customerName}&userName=${row.userName}`)
},
- tabChange(index) {
- this.curTab = index
- this.$router.push(`addcustomer?id=${this.customerId}&type=${index}`)
- this.pageProduct = 1
- this.pageOrder = 1
- this.pageBm = 1
- index === 'tab3' && this.handlePageOrder()
- },
- // 获取城市
- getCityData(){
- let data = {
- provinceId: this.form.provinceId
- }
- this.$get(this.api.queryCity,data).then(res => {
- this.cityList = res.list
- }).catch(res => {});
- },
- // 清除学校
- clearSchool(){
- this.form.provinceId = '',
- this.form.cityId = '',
- this.form.customerName = ''
- },
- // 获取学校/客户名称
- getSchoolData(){
- let data = {
- schoolName: '',
- provinceId: '',
- cityId: ''
- }
- this.$get(this.api.querySchoolData).then(res => {
- this.schoolList = res.list
- }).catch(res => {});
- },
- // 查询客户是否存在
- SchoolChange(val){
- this.clearSchool()
- if(val){
- let obj = {}
- obj = this.schoolList.find((item)=>{
- return item.schoolId === val
- });
- this.form.customerName = obj.schoolName
- this.form.provinceId = obj.provinceId
- this.getCityData()
- this.form.cityId = obj.cityId
-
- this.$get(this.api.queryCustomerIsExists,{
- schoolId: this.form.schoolId
- }).then(res => {
- this.NoAdd = true
- }).catch(res => {
- this.NoAdd = false
- })
- }
- },
- // 获取行业类
- getIndustryClass(){
- this.$get(this.api.queryCustomerIndustryClass).then(res => {
- this.IndustryClassList = res.list
- }).catch(res => {});
- },
- // 清除行业类
- clearIndustry(){
- this.form.industryId = ''
- },
- // 获取行业
- changIndustry(){
- this.clearIndustry()
- this.changIndustryData()
- },
- changIndustryData(){
- let data = {
- industryClassId: this.form.industryClassId
- }
- this.$get(this.api.queryCustomerIndustry,data).then(res => {
- this.industryList = res.list
- }).catch(res => {});
- },
- switchOff(val, row) {
- this.$post(`${this.api.orderBulkDisableEnable}?isOpen=${val}`, row.startAndEndTimeList.map(e => e.id)).then(res => {
- this.$message.success(val ? '启用成功' : '禁用成功')
- }).catch(res => {})
- },
- phoneChange() { // 切换手机号
- let regex = /^1[3456789]\d{9}$/;
- if (regex.test(this.form.phone)) {
- let url = "";
- if (!this.form.customerId) {
- url = `${this.api.checkEmailOrPhone}?phone=${this.form.phone}&email=`;
- } else {
- url = `${this.api.checkEmailOrPhone}?customerId=${this.form.customerId}&phone=${this.form.phone}&email=`;
- }
- this.$post(url).then(res => {
- if (res.status === 200) {
- this.phoneRepeat = false;
- }
- }).catch(err => {
- this.phoneRepeat = true;
- });
- }
- },
- emailChange() { // 切换邮箱
- let regex = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
- if (regex.test(this.form.email)) {
- let url = "";
- if (!this.form.customerId) {
- url = `${this.api.checkEmailOrPhone}?email=${this.form.email}&phone=`;
- } else {
- url = `${this.api.checkEmailOrPhone}?customerId=${this.form.customerId}&email=${this.form.email}&phone=`;
- }
- this.$post(url).then(res => {
- if (res.status === 200) {
- this.emailRepeat = false;
- }
- }).catch(err => {
- this.emailRepeat = true;
- });
- }
- },
- saveAdd(formName){
- this.$refs[formName].validate((valid) => {
- if (valid) {
- if (this.submiting) return false
- if (this.phoneRepeat) {
- this.$message.warning("该手机号已存在");
- return;
- }
- if (this.emailRepeat) {
- this.$message.warning("该邮箱已存在");
- return;
- }
- this.submiting = true
- if(this.NoAdd){
- let obj = {};
- obj = this.schoolList.find((item)=>{
- return item.schoolId == this.form.schoolId;
- });
- this.form.customerName = obj.schoolName
- this.form.provinceId = obj.provinceId
- this.getCityData()
- this.form.cityId = obj.cityId
- let data = {
- customerName: this.form.customerName,
- customerId: this.customerId,
- schoolId: this.form.schoolId,
- countries: this.form.countries,
- industryClassId: this.form.industryClassId,
- industryId: this.form.industryId,
- provinceId: this.form.provinceId,
- account: this.form.account,
- phone: this.form.phone,
- cityId: this.form.cityId,
- customerType: this.form.customerType,
- expireDate: this.form.expireDate,
- email: this.form.email,
- name: this.form.name,
- position: this.form.position
- }
- if(this.customerId){
- this.$post(this.api.updateCustomer,data).then((res) => {
- this.$message.success('编辑成功')
- this.goback()
- }).catch((res) => {
+ // tab切换
+ tabChange(index, to) {
+ // 当前tab是第一个,并且不是从确认询问后跳过来的,就直接调询问框询问是否保存
+ if (this.curTab === 'tab1' && !to) {
+ this.goback(index)
+ } else {
+ this.curTab = index
+ this.$router.push(`addcustomer?id=${this.customerId}&type=${index}`)
+ this.pageProduct = 1
+ this.pageOrder = 1
+ this.pageBm = 1
+ index === 'tab3' && this.handlePageOrder()
+ this.updateTime = this.form.customerId ? 1 : 0
+ }
+ },
+ // 获取城市
+ getCityData(){
+ let data = {
+ provinceId: this.form.provinceId
+ }
+ this.$get(this.api.queryCity,data).then(res => {
+ this.cityList = res.list
+ }).catch(res => {});
+ },
+ // 清除学校
+ clearSchool(){
+ this.form.provinceId = '',
+ this.form.cityId = '',
+ this.form.customerName = ''
+ },
+ // 获取学校/客户名称
+ getSchoolData(){
+ let data = {
+ schoolName: '',
+ provinceId: '',
+ cityId: ''
+ }
+ this.$get(this.api.querySchoolData).then(res => {
+ this.schoolList = res.list
+ }).catch(res => {});
+ },
+ // 查询客户是否存在
+ SchoolChange(val){
+ this.clearSchool()
+ if(val){
+ let obj = {}
+ obj = this.schoolList.find((item)=>{
+ return item.schoolId === val
+ });
+ this.form.customerName = obj.schoolName
+ this.form.provinceId = obj.provinceId
+ this.getCityData()
+ this.form.cityId = obj.cityId
+
+ this.$get(this.api.queryCustomerIsExists,{
+ schoolId: this.form.schoolId
+ }).then(res => {
+ this.NoAdd = true
+ }).catch(res => {
+ this.NoAdd = false
+ })
+ }
+ },
+ // 获取行业类
+ getIndustryClass(){
+ this.$get(this.api.queryCustomerIndustryClass).then(res => {
+ this.IndustryClassList = res.list
+ }).catch(res => {});
+ },
+ // 清除行业类
+ clearIndustry(){
+ this.form.industryId = ''
+ },
+ // 获取行业
+ changIndustry(){
+ this.clearIndustry()
+ this.changIndustryData()
+ },
+ changIndustryData(){
+ let data = {
+ industryClassId: this.form.industryClassId
+ }
+ this.$get(this.api.queryCustomerIndustry,data).then(res => {
+ this.industryList = res.list
+ }).catch(res => {});
+ },
+ switchOff(val, row) {
+ this.$post(`${this.api.orderBulkDisableEnable}?isOpen=${val}`, row.startAndEndTimeList.map(e => e.id)).then(res => {
+ this.$message.success(val ? '启用成功' : '禁用成功')
+ }).catch(res => {})
+ },
+ phoneChange() { // 切换手机号
+ let regex = /^1[3456789]\d{9}$/;
+ if (regex.test(this.form.phone)) {
+ let url = "";
+ if (!this.form.customerId) {
+ url = `${this.api.checkEmailOrPhone}?phone=${this.form.phone}&email=`;
+ } else {
+ url = `${this.api.checkEmailOrPhone}?customerId=${this.form.customerId}&phone=${this.form.phone}&email=`;
+ }
+ this.$post(url).then(res => {
+ if (res.status === 200) {
+ this.phoneRepeat = false;
+ }
+ }).catch(err => {
+ this.phoneRepeat = true;
+ });
+ }
+ },
+ emailChange() { // 切换邮箱
+ let regex = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
+ if (regex.test(this.form.email)) {
+ let url = "";
+ if (!this.form.customerId) {
+ url = `${this.api.checkEmailOrPhone}?email=${this.form.email}&phone=`;
+ } else {
+ url = `${this.api.checkEmailOrPhone}?customerId=${this.form.customerId}&email=${this.form.email}&phone=`;
+ }
+ this.$post(url).then(res => {
+ if (res.status === 200) {
+ this.emailRepeat = false;
+ }
+ }).catch(err => {
+ this.emailRepeat = true;
+ });
+ }
+ },
+ saveAdd(tab){
+ this.$refs.form.validate((valid) => {
+ if (valid) {
+ if (this.submiting) return false
+ if (this.phoneRepeat) {
+ this.$message.warning("该手机号已存在");
+ return;
+ }
+ if (this.emailRepeat) {
+ this.$message.warning("该邮箱已存在");
+ return;
+ }
+ this.submiting = true
+ if(this.NoAdd){
+ let obj = {};
+ obj = this.schoolList.find((item)=>{
+ return item.schoolId == this.form.schoolId;
+ });
+ this.form.customerName = obj.schoolName
+ this.form.provinceId = obj.provinceId
+ this.getCityData()
+ this.form.cityId = obj.cityId
+ let data = {
+ customerName: this.form.customerName,
+ customerId: this.customerId,
+ schoolId: this.form.schoolId,
+ countries: this.form.countries,
+ industryClassId: this.form.industryClassId,
+ industryId: this.form.industryId,
+ provinceId: this.form.provinceId,
+ account: this.form.account,
+ phone: this.form.phone,
+ cityId: this.form.cityId,
+ customerType: this.form.customerType,
+ expireDate: this.form.expireDate,
+ email: this.form.email,
+ name: this.form.name,
+ position: this.form.position
+ }
+ if(this.customerId){
+ this.$post(this.api.updateCustomer,data).then((res) => {
+ setTimeout(() => {
this.submiting = false
- })
- }else{
- this.$post(this.api.addCustomer,data).then((res) => {
- let customerId = res.customerId
- this.$store.commit('schoolIdData',{schoolId: this.form.schoolId})
- // this.$post(this.api.saveOrUpdate,{
- // clientId: 0,
- // id: '',
- // roleName: '超级管理员',
- // remark: '拥有一切权限',
- // isPort: 2
- // }).then(res => {
- // let roleId = res.roleId
- // let perData = {
- // roleId,
- // permissionId: ["1408370117262635009","1409351488911056897","1409351867862228993","1408370186435096578","1409352518310699009","1409352550615228418","1409352584240963585","1409352623344459778","1409352647054860289","1409352682471563266","1409352720786530305","1409352742290726913","1408370244584927233","1409352872662278146","1409352903574298626","1409352923509825538","1409352940068937730","1409353018443702273"],
- // isPort: 2
- // }
- // this.$post(this.api.doAssign,perData).then(res => {}).catch(res => {})
- // this.$post(`${this.api.updateCustomerByRoleId}?customerId=${customerId}&roleId=${roleId}`).then(res => {}).catch(res => {})
- // }).catch(res => {})
-
- this.$message.success('添加成功')
- this.goback()
- }).catch((res) => {
+ }, 1500)
+ this.$message.success('编辑成功')
+ tab ? this.tabChange(tab, 1) : this.backPage()
+ }).catch((res) => {
+ this.submiting = false
+ })
+ }else{
+ this.$post(this.api.addCustomer,data).then((res) => {
+ setTimeout(() => {
this.submiting = false
- })
- }
- }else{
- this.$message.warning('该客户已存在')
- }
- }
- })
- },
- handleSelectionChange(val) {
- this.multipleSelection = val
- },
- showContract(row){
- if(!row.contractFile) return this.$message.warning('文件链接无效')
- let type = row.contractFile.split('.').pop()
- let img = ['jpg','gif','png','jepg']
-
- this.fileSrc = row.contractFile
- if(img.includes(type)){
- this.showImg = true
- }else if('pdf'.includes(type)){
- this.pdfVisible = true
- }else{
- window.open(`https://view.officeapps.live.com/op/view.aspx?src=${this.fileSrc}`)
- }
+ }, 1500)
+ this.$store.commit('schoolIdData',{schoolId: this.form.schoolId})
+ this.$message.success('添加成功')
+ tab ? this.tabChange(tab, 1) : this.backPage()
+ }).catch((res) => {
+ this.submiting = false
+ })
+ }
+ }else{
+ this.$message.warning('该客户已存在')
+ }
+ }
+ })
+ },
+ handleSelectionChange(val) {
+ this.multipleSelection = val
+ },
+ showContract(row){
+ if(!row.contractFile) return this.$message.warning('文件链接无效')
+ let type = row.contractFile.split('.').pop()
+ let img = ['jpg','gif','png','jepg']
- },
- goback(){
- this.$router.push(`customer?page=${this.$store.state.customerPage}`)
+ this.fileSrc = row.contractFile
+ if(img.includes(type)){
+ this.showImg = true
+ }else if('pdf'.includes(type)){
+ this.pdfVisible = true
+ }else{
+ window.open(`https://view.officeapps.live.com/op/view.aspx?src=${this.fileSrc}`)
+ }
+ },
+ goback(i) {
+ const id = this.form.customerId
+ const updateTime = this.updateTime
+ // 更改了信息才需要提示
+ if ((id && updateTime > 1) || (!id && updateTime)) {
+ this.$confirm(`编辑的内容未保存,是否保存?`, '提示', {
+ type: 'warning'
+ }).then(() => {
+ this.saveAdd(i)
+ }).catch(() => {
+ i ? this.tabChange(i, 1) : this.backPage()
+ })
+ } else {
+ this.tabChange(i, 1)
}
+ },
+ backPage(){
+ this.$router.push(`customer?page=${this.$store.state.customerPage}`)
+ }
}
};
diff --git a/src/views/customer/Order.vue b/src/views/customer/Order.vue
index 32af66e..a5ce0cc 100644
--- a/src/views/customer/Order.vue
+++ b/src/views/customer/Order.vue
@@ -30,7 +30,7 @@
-
+
diff --git a/src/views/join/index.vue b/src/views/join/index.vue
index cb4d3f4..ca3855a 100644
--- a/src/views/join/index.vue
+++ b/src/views/join/index.vue
@@ -61,7 +61,7 @@ export default {
{ required: true, message: '请输入手机号', trigger: 'blur' }
],
code: [
- { required: util.isMobile(), message: "请输入验证码", trigger: 'blur' }
+ { required: true, message: "请输入验证码", trigger: 'blur' }
]
},
phoneDisabled: false,
diff --git a/src/views/order/AddOrder.vue b/src/views/order/AddOrder.vue
index 2518d1b..7454754 100644
--- a/src/views/order/AddOrder.vue
+++ b/src/views/order/AddOrder.vue
@@ -1058,7 +1058,6 @@ export default {
},
// 选择客户返回传值
backToOrder(val) {
- console.log(val)
this.showSelectClient = !this.showSelectClient;
if (val.customerId) {
this.form.customerName = val.customerName;
@@ -1341,12 +1340,14 @@ export default {
// 课程计算折扣率
calculateDiscountCourse(val, row) {
const { finalPrice, marketValue } = row
- if (finalPrice) row.discountRate = marketValue == 0 ? '0%' : (finalPrice / marketValue * 100).toFixed(2) + "%";
+ // (原价-现价)÷原价 x100%
+ if (finalPrice) row.discountRate = marketValue == 0 ? '0%' : ((marketValue - finalPrice) / marketValue * 100).toFixed(2) + "%";
},
// 数据计算折扣率
calculateDiscount(val, row) {
const { finalValue, marketValue } = row
- if (finalValue) row.discountRate = marketValue == 0 ? '0%' : (finalValue / marketValue * 100).toFixed(2) + "%";
+ // (原价-现价)÷原价 x100%
+ if (finalValue) row.discountRate = marketValue == 0 ? '0%' : ((marketValue - finalValue) / marketValue * 100).toFixed(2) + "%";
},
// 合同起止日期选择
contractTimeChange(val) {
@@ -1367,19 +1368,27 @@ export default {
dealFinalValue(val, row) {
const { periodOfUse, options, accountNum, finalPrice } = row
if (periodOfUse && accountNum && finalPrice) {
- row.finalValue = (finalPrice / accountNum / periodOfUse * (!options ?
- 365 :
- options === 1 ?
- 12 :
- 1)).toFixed(2)
+ row.finalValue = (finalPrice / accountNum / periodOfUse).toFixed(2)
this.calculateDiscount(val, row)
}
},
// 计算成交价。计算规则:成交单价*账号数*时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算)
dealComputers(e, row) {
- const { finalValue, accountNum, periodOfUse, options } = row
- if (finalValue && accountNum) {
- row.finalPrice = Math.round(finalValue * periodOfUse * accountNum)
+ const { finalValue, accountNum, periodOfUse, finalPrice } = row
+ if (periodOfUse) {
+ if (accountNum) {
+ // 有成交单价,则成交价=成交单价*账号数*时间
+ if (finalValue) {
+ row.finalPrice = Math.round(finalValue * periodOfUse * accountNum)
+ } else if (!finalValue && finalPrice) {
+ // 有成交价,没有成交单价,则成交单价=成交价/账号数/时间
+ row.finalValue = (finalPrice / periodOfUse / accountNum).toFixed(2)
+ this.calculateDiscount(e, row)
+ }
+ } else if (finalValue && finalValue) {
+ // 有成交价、成交单价,没有数量,则数量=成交价/时间/成交单价
+ row.accountNum = Math.floor(finalPrice / periodOfUse / finalValue)
+ }
}
this.dealSettlePrice(row)
this.allAmount(e, row)
@@ -1388,22 +1397,24 @@ export default {
dealSettlePrice(row) {
const unit = row.options // 使用期限单位
const useUnit = row.periodOfUse // 使用期限
- let sPrice = ''
- if (row.settlementMethod == 0) {
- // 结算单价。计算规则:结算单价(**元/年)*购买时长(单位年)*数量(课程为1,数据为账号数量)(单位是万)
- const priceUnit = row.settlementPriceUnit
- sPrice = ((!unit ?
- priceUnit / 365 * useUnit :
- unit === 1 ?
- priceUnit / 12 * useUnit :
- priceUnit * useUnit) * (row.authority ?
- 1 :
- row.accountNum)).toFixed(2)
- } else {
- // 比例分成。计算规则:成交价*商务分成比例(单位是万)
- sPrice = (row.finalPrice * row.businessProportion / 100).toFixed(2)
+ if (this.form.orderType !== 2) {
+ let sPrice = ''
+ if (row.settlementMethod == 0) {
+ // 结算单价。计算规则:结算单价(**元/年)*购买时长(单位年)*数量(课程为1,数据为账号数量)(单位是万)
+ const priceUnit = row.settlementPriceUnit
+ sPrice = ((!unit ?
+ priceUnit / 365 * useUnit :
+ unit === 1 ?
+ priceUnit / 12 * useUnit :
+ priceUnit * useUnit) * (row.authority ?
+ 1 :
+ row.accountNum)).toFixed(2)
+ } else {
+ // 比例分成。计算规则:成交价*商务分成比例(单位是万)
+ sPrice = (row.finalPrice * row.businessProportion / 100).toFixed(2)
+ }
+ row.settlementPrice = this.handleNaN(sPrice)
}
- row.settlementPrice = this.handleNaN(sPrice)
},
// 使用期限转换以及计算剩余天数
deadLine(e,row,options, isDate) {
@@ -1439,6 +1450,7 @@ export default {
price * useUnit)).toFixed(2)
this.dealComputers(e, row)
+ row.authority ? this.calculateDiscountCourse(e, row) : this.calculateDiscount(e, row)
// 只有改变了起止日期才需要调接口查询订单,该接口作用是把开始时间传过去,会返回一个提示或者时间,如果是时间,则把时间+1天,如果是提示,则无法保存
if (isDate) {
const cId = row.dataOrCourseId
diff --git a/src/views/parner/staff.vue b/src/views/parner/staff.vue
index b0a108d..84fb65d 100644
--- a/src/views/parner/staff.vue
+++ b/src/views/parner/staff.vue
@@ -408,32 +408,27 @@ export default {
},
// 添加
add() {
- const { orgList } = this
- if (orgList.length) {
- const curNode = this.$refs.orgTree.getCurrentNode()
- if (curNode && curNode.isTeam) {
- util.warningMsg('请选择分类添加城市合伙人!')
- } else {
- const { accountId } = this
- // 获取邀请码
- this.$post(`${this.api.generateInvitationCode}?accountId=${accountId}`).then(({ expireTime, invitationCode }) => {
- const date = new Date(Date.now() + expireTime * 1000) // 返回的秒,要*1000
- this.expireTime = `${date.getFullYear()}-${util.preZero(date.getMonth() + 1)}-${util.preZero(date.getDate())} ${util.preZero(date.getHours())}:${util.preZero(date.getMinutes())}:${util.preZero(date.getMinutes())}`
- this.parnerVisible = true
- const cur = this.$refs.orgTree.getCurrentKey()
- const link = `${location.origin}${Setting.isDev || Setting.isPro ? '' : '/nakadai'}/#/join?accountId=${accountId}&id=${cur ? cur: this.orgList[0].id}`
+ const curNode = this.$refs.orgTree.getCurrentNode()
+ if (curNode && curNode.isTeam) {
+ util.warningMsg('请选择分类添加城市合伙人!')
+ } else {
+ const { accountId } = this
+ // 获取邀请码
+ this.$post(`${this.api.generateInvitationCode}?accountId=${accountId}`).then(({ expireTime, invitationCode }) => {
+ const date = new Date(Date.now() + expireTime * 1000) // 返回的秒,要*1000
+ this.expireTime = `${date.getFullYear()}-${util.preZero(date.getMonth() + 1)}-${util.preZero(date.getDate())} ${util.preZero(date.getHours())}:${util.preZero(date.getMinutes())}:${util.preZero(date.getMinutes())}`
+ this.parnerVisible = true
+ const cur = this.$refs.orgTree.getCurrentKey()
+ const link = `${location.origin}${Setting.isDev || Setting.isPro ? '' : '/nakadai'}/#/join?accountId=${accountId}&id=${cur || ''}`
- // 生成二维码
- this.link = link
- axios.get(`${this.api.generationQrCode}?url=${encodeURIComponent(link)}`, {
- responseType: 'blob'
- }).then(({ data }) => {
- this.qrcode = window.URL.createObjectURL(data)
- }).catch(res => {})
+ // 生成二维码
+ this.link = link
+ axios.get(`${this.api.generationQrCode}?url=${encodeURIComponent(link)}`, {
+ responseType: 'blob'
+ }).then(({ data }) => {
+ this.qrcode = window.URL.createObjectURL(data)
}).catch(res => {})
- }
- } else {
- util.errorMsg('请添加分类!')
+ }).catch(res => {})
}
},
// 复制链接