@@ -157,55 +141,23 @@ export default {
}
})
},
- UpNumber(e) {
- if (this.formobj.calculationModeValue === '') {
- this.formobj.calculationStandard = ''
- this.$message({ showClose: true, type: 'error', message: '请先选择计算方式' })
- return
+ getNumber(val, limit) {
+ val = val.replace(/[^0-9.]/g, '') // 保留数字
+ val = val.replace(/^00/, '0.') // 开头不能有两个0
+ val = val.replace(/^\./g, '0.') // 开头为小数点转换为0.
+ val = val.replace(/\.{2,}/g, '.') // 两个以上的小数点转换成一个
+ val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.'); // 只保留一个小数点
+ /^0\d+/.test(val) ? val = val.slice(1) : '' // 两位以上数字开头不能为0
+ const str = '^(\\d+)\\.(\\d{' + limit + '}).*$'
+ const reg = new RegExp(str)
+ if (limit === 0) {
+ // 不需要小数点
+ val = val.replace(reg, '$1')
} else {
- if (this.formobj.calculationModeKey === '001') {
- e.target.value = e.target.value.replace(/[^\d.]/g, '') // 清除“数字”和“.”"-"以外的字符
- e.target.value = e.target.value.replace(/^00/, '0.') // 开头不能有两个0
- e.target.value = e.target.value.replace(/\.{2,}/g, '.') // 只保留第一个. 清除多余的
- e.target.value = e.target.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3') // 只能输入两个小数
- if (e.target.value.indexOf('.') < 0 && e.target.value !== '' && e.target.value !== '-') {
- // 以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
- e.target.value = parseFloat(e.target.value)
- }
- this.formobj.calculationStandard = e.target.value
- } else if (this.formobj.calculationModeKey === '002') {
- e.target.value = e.target.value.replace(/[^\d]/g, '') // 清除“数字”和“.”"-"以外的字符
- e.target.value = e.target.value.replace(/^00/, '0') // 开头不能有两个0
- if (e.target.value.indexOf('.') < 0 && e.target.value !== '' && e.target.value !== '-') {
- // 以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
- console.log(e.target.value)
- e.target.value = parseFloat(e.target.value)
- }
- this.formobj.calculationStandard = e.target.value
- }
+ // 通过正则保留小数点后指定的位数
+ val = val.replace(reg, '$1.$2')
}
- },
- estimateRebate(row) {
- if (this.formobj.calculationModeKey === '001') {
- var price = ''
- price = parseFloat(row.manufactorSettlementPrice) - parseFloat(row.freight)
- row.estimateRebate = this.multiplication(price, (parseFloat(this.formobj.calculationStandard) / 100))
- } else if (this.formobj.calculationModeKey === '002') {
- row.estimateRebate = this.formobj.calculationStandard
- }
- return row.estimateRebate
- },
- multiplication(arg1, arg2) {
- var m = 0
- var s1 = arg1.toString()
- var s2 = arg2.toString()
- try {
- m += s1.split('.')[1].length
- } catch (e) {}
- try {
- m += s2.split('.')[1].length
- } catch (e) {}
- return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m)
+ return val
},
showAdd() {
this.$nextTick(() => {
@@ -217,33 +169,29 @@ export default {
this.viewTitle = '【新增】单车返利'
},
changeRebateType(value) {
- let bb = null
- this.rebateType_list.forEach((e) => {
- if (e.dictValue === value) {
- bb = {
- key: e.dictKey,
- value: e.dictValue
- }
- }
- })
- this.formobj.rebateTypeKey = bb.key
+ const choose = this.rebateType_list.filter((item) => item.dictValue === value)
+ if (choose !== null && choose.length > 0) {
+ this.formobj.rebateTypeKey = choose[0].dictKey
+ } else {
+ this.formobj.rebateTypeKey = ''
+ }
},
changeCalculationMode(value) {
- let bb = null
- this.calculationMode_list.forEach((e) => {
- if (e.dictValue === value) {
- bb = {
- key: e.dictKey,
- value: e.dictValue
- }
- }
- })
- this.formobj.calculationModeKey = bb.key
+ const choose = this.calculationMode_list.filter((item) => item.dictValue === value)
+ if (choose !== null && choose.length > 0) {
+ this.formobj.calculationModeKey = choose[0].dictKey
+ } else {
+ this.formobj.calculationModeKey = ''
+ }
},
// 明细表添加一行数据
addjacket() {
- this.viewState = 2
- this.$refs['divSelect'].showData(this.formobj.scmVehRebateVehs)
+ if (this.formobj.calculationModeValue !== '' && this.formobj.calculationStandard !== '') {
+ this.viewState = 2
+ this.$refs['divSelect'].showData(this.formobj.scmVehRebateVehs)
+ } else {
+ this.$message({ showClose: true, type: 'error', message: '请先选择计算方式及填写计算标准' })
+ }
},
backData(value) {
this.viewState = 1
@@ -263,6 +211,15 @@ export default {
})
})
}
+ this.formobj.scmVehRebateVehs.forEach((e) => {
+ // 计算方式为比例时,预计返利 = (厂家结算价 - 运费) * (计算标准 / 100)
+ if (this.formobj.calculationModeKey === '001') {
+ e.estimateRebate = Math.round(((parseFloat(e.manufactorSettlementPrice !== '' ? e.manufactorSettlementPrice : 0) - parseFloat(e.freight !== '' ? e.freight : 0)) * (parseFloat(this.formobj.calculationStandard) / 100)) * 100) / 100
+ } else if (this.formobj.calculationModeKey === '002') {
+ // 计算方式为固定金额时,预计返利 = 计算标准
+ e.estimateRebate = this.formobj.calculationStandard
+ }
+ })
},
// 明细表删除一行数据
dataDelete(index) {
@@ -282,11 +239,7 @@ export default {
req.save(this.formobj).then((resp) => {
this.submitdisabled = false
if (resp.success) {
- this.$message({
- showClose: true,
- type: 'success',
- message: resp.msg
- })
+ this.$message({ showClose: true, type: 'success', message: resp.msg })
this.handleReturn('true')
}
}).catch(() => {
@@ -317,7 +270,6 @@ export default {
}
}, 0)
sums[index] += ''
- // this.formobj.currentAmount = sums[index] += ''
} else {
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
diff --git a/anrui-scm/anrui-scm-ui/src/views/bikerebate/bikerebatemanagement/bicyclerebatemanagementByVehicle.vue b/anrui-scm/anrui-scm-ui/src/views/bikerebate/bikerebatemanagement/bicyclerebatemanagementByVehicle.vue
index 1101d90ae0..00710bfd2f 100644
--- a/anrui-scm/anrui-scm-ui/src/views/bikerebate/bikerebatemanagement/bicyclerebatemanagementByVehicle.vue
+++ b/anrui-scm/anrui-scm-ui/src/views/bikerebate/bikerebatemanagement/bicyclerebatemanagementByVehicle.vue
@@ -317,12 +317,7 @@ export default {
if (this.sids.length > 0) {
this.$emit('backData', this.sids)
} else {
- this.$notify({
- title: '提示',
- message: '请选择至少一条车型记录!',
- type: 'error',
- duration: 2000
- })
+ this.$notify({ title: '提示', message: '请选择至少一条车型记录!', type: 'error', duration: 2000 })
}
}
}
diff --git a/anrui-scm/anrui-scm-ui/src/views/bikerebate/bikerebatemanagement/bicyclerebatemanagementEdit.vue b/anrui-scm/anrui-scm-ui/src/views/bikerebate/bikerebatemanagement/bicyclerebatemanagementEdit.vue
index f274eb45b5..8f93cbbca0 100644
--- a/anrui-scm/anrui-scm-ui/src/views/bikerebate/bikerebatemanagement/bicyclerebatemanagementEdit.vue
+++ b/anrui-scm/anrui-scm-ui/src/views/bikerebate/bikerebatemanagement/bicyclerebatemanagementEdit.vue
@@ -56,7 +56,7 @@
计算标准(%)
-
+
@@ -94,7 +94,7 @@
- {{ estimateRebate() }}
+ {{ formobj.estimateRebate }}
@@ -157,79 +157,48 @@ export default {
}
})
},
- UpNumber(e) {
- if (this.formobj.calculationModeValue === '') {
- this.formobj.calculationStandard = ''
- this.$message({ showClose: true, type: 'error', message: '请先选择计算方式' })
- return
+ getNumber(val, limit) {
+ val = val.replace(/[^0-9.]/g, '') // 保留数字
+ val = val.replace(/^00/, '0.') // 开头不能有两个0
+ val = val.replace(/^\./g, '0.') // 开头为小数点转换为0.
+ val = val.replace(/\.{2,}/g, '.') // 两个以上的小数点转换成一个
+ val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.'); // 只保留一个小数点
+ /^0\d+/.test(val) ? val = val.slice(1) : '' // 两位以上数字开头不能为0
+ const str = '^(\\d+)\\.(\\d{' + limit + '}).*$'
+ const reg = new RegExp(str)
+ if (limit === 0) {
+ // 不需要小数点
+ val = val.replace(reg, '$1')
} else {
- if (this.formobj.calculationModeKey === '001') {
- e.target.value = e.target.value.replace(/[^\d.]/g, '') // 清除“数字”和“.”"-"以外的字符
- e.target.value = e.target.value.replace(/^00/, '0.') // 开头不能有两个0
- e.target.value = e.target.value.replace(/\.{2,}/g, '.') // 只保留第一个. 清除多余的
- e.target.value = e.target.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3') // 只能输入两个小数
- if (e.target.value.indexOf('.') < 0 && e.target.value !== '' && e.target.value !== '-') {
- // 以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
- e.target.value = parseFloat(e.target.value)
- }
- this.formobj.calculationStandard = e.target.value
- } else if (this.formobj.calculationModeKey === '002') {
- e.target.value = e.target.value.replace(/[^\d]/g, '') // 清除“数字”和“.”"-"以外的字符
- e.target.value = e.target.value.replace(/^00/, '0') // 开头不能有两个0
- if (e.target.value.indexOf('.') < 0 && e.target.value !== '' && e.target.value !== '-') {
- // 以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
- console.log(e.target.value)
- e.target.value = parseFloat(e.target.value)
- }
- this.formobj.calculationStandard = e.target.value
- }
+ // 通过正则保留小数点后指定的位数
+ val = val.replace(reg, '$1.$2')
}
+ return val
},
- estimateRebate() {
+ estimateRebateInput() {
if (this.formobj.calculationModeKey === '001') {
- var price = ''
- price = parseFloat(this.formobj.manufactorSettlementPrice) - parseFloat(this.formobj.freight)
- this.formobj.estimateRebate = this.multiplication(price, (parseFloat(this.formobj.calculationStandard) / 100))
+ // 计算方式为比例时,预计返利 = (厂家结算价 - 运费) * (计算标准 / 100)
+ this.formobj.estimateRebate = Math.round(((parseFloat(this.formobj.manufactorSettlementPrice !== '' ? this.formobj.manufactorSettlementPrice : 0) - parseFloat(this.formobj.freight !== '' ? this.formobj.freight : 0)) * (parseFloat(this.formobj.calculationStandard) / 100)) * 100) / 100
} else if (this.formobj.calculationModeKey === '002') {
+ // 计算方式为固定金额时,预计返利 = 计算标准
this.formobj.estimateRebate = this.formobj.calculationStandard
}
- return this.formobj.estimateRebate
- },
- multiplication(arg1, arg2) {
- var m = 0
- var s1 = arg1.toString()
- var s2 = arg2.toString()
- try {
- m += s1.split('.')[1].length
- } catch (e) {}
- try {
- m += s2.split('.')[1].length
- } catch (e) {}
- return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m)
},
changeRebateType(value) {
- let bb = null
- this.rebateType_list.forEach((e) => {
- if (e.dictValue === value) {
- bb = {
- key: e.dictKey,
- value: e.dictValue
- }
- }
- })
- this.formobj.rebateTypeKey = bb.key
+ const choose = this.rebateType_list.filter((item) => item.dictValue === value)
+ if (choose !== null && choose.length > 0) {
+ this.formobj.rebateTypeKey = choose[0].dictKey
+ } else {
+ this.formobj.rebateTypeKey = ''
+ }
},
changeCalculationMode(value) {
- let bb = null
- this.calculationMode_list.forEach((e) => {
- if (e.dictValue === value) {
- bb = {
- key: e.dictKey,
- value: e.dictValue
- }
- }
- })
- this.formobj.calculationModeKey = bb.key
+ const choose = this.calculationMode_list.filter((item) => item.dictValue === value)
+ if (choose !== null && choose.length > 0) {
+ this.formobj.calculationModeKey = choose[0].dictKey
+ } else {
+ this.formobj.calculationModeKey = ''
+ }
},
showEdit(row) {
this.init()
@@ -250,11 +219,7 @@ export default {
req.update(this.formobj).then((resp) => {
this.submitdisabled = false
if (resp.success) {
- this.$message({
- showClose: true,
- type: 'success',
- message: resp.msg
- })
+ this.$message({ showClose: true, type: 'success', message: resp.msg })
this.handleReturn('true')
}
}).catch(() => {