You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
397 lines
17 KiB
397 lines
17 KiB
<template>
|
|
<div class="app-container">
|
|
<div v-show="viewState == 1">
|
|
<!--标题按钮部分开始-->
|
|
<div class="tab-header webtop">
|
|
<!--标题-->
|
|
<div>{{ viewTitle }}</div>
|
|
<!--start 添加修改按钮-->
|
|
<div>
|
|
<el-button type="primary" size="small" :disabled="submitdisabled" @click="save()">保存
|
|
</el-button>
|
|
<el-button type="info" size="small" @click="handleReturn()">关闭</el-button>
|
|
</div>
|
|
</div>
|
|
<!--标题按钮部分结束-->
|
|
<!--Start 新增修改部分-->
|
|
<div class="listconadd">
|
|
<div class="titwu"><span>单车返利</span></div>
|
|
<el-form ref="form_obj" :model="formobj" :rules="rules" class="formaddcopy02">
|
|
<el-row style="border-top: 1px solid #E0E3EB">
|
|
<el-col :span="8">
|
|
<div class="span-sty"><span class="icon">*</span>返利类型</div>
|
|
<el-form-item prop="rebateTypeValue">
|
|
<el-select class="addinputInfo" v-model="formobj.rebateTypeValue" placeholder="请选择" filterable clearable @change="changeRebateType">
|
|
<el-option v-for="item in rebateType_list" :key="item.dictKey" :label="item.dictValue" :value="item.dictValue"/>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="8">
|
|
<div class="span-sty"><span class="icon">*</span>厂家返利名称</div>
|
|
<el-form-item prop="rebateName"><el-input class="addinputInfo addinputw" v-model="formobj.rebateName" placeholder="" clearable></el-input></el-form-item>
|
|
</el-col>
|
|
<el-col :span="8">
|
|
<div class="span-sty"><span class="icon">*</span>所属年月</div>
|
|
<el-form-item prop="palceGenDate"><el-date-picker class="addinputInfo" v-model="formobj.palceGenDate" type="month" clearable format="yyyy-MM" value-format="yyyy-MM" placeholder="选择日期" /></el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="8">
|
|
<div class="span-sty"><span class="icon">*</span>计算方式</div>
|
|
<el-form-item prop="calculationModeValue">
|
|
<el-select class="addinputInfo" v-model="formobj.calculationModeValue" placeholder="请选择" filterable clearable @change="changeCalculationMode">
|
|
<el-option v-for="item in calculationMode_list" :key="item.dictKey" :label="item.dictValue" :value="item.dictValue"/>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="8">
|
|
<div class="span-sty">
|
|
<span class="icon">*</span>计算标准
|
|
<span v-if="formobj.calculationModeValue == '比例'">(%)</span>
|
|
<span v-else>(元)</span>
|
|
</div>
|
|
<el-form-item prop="calculationStandard"><el-input class="addinputInfo addinputw" v-model="formobj.calculationStandard" @keyup.native="formobj.calculationStandard = getSpecialNumber(formobj.calculationStandard, 2)" clearable placeholder="" /></el-form-item>
|
|
</el-col>
|
|
<el-col :span="8">
|
|
<div class="span-sty"><span class="icon">*</span>返利政策方</div>
|
|
<el-form-item prop="policySideValue">
|
|
<el-select class="addinputInfo" v-model="formobj.policySideValue" placeholder="请选择" filterable clearable @change="changePolicySide">
|
|
<el-option v-for="item in policySide_list" :key="item.dictKey" :label="item.dictValue" :value="item.dictValue"/>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<div class="title titleOne">
|
|
<div>返利车辆列表</div>
|
|
<div>
|
|
<el-button type="primary" size="mini" icon="el-icon-plus" class="btntopblueline" @click="addjacket()">批量选择</el-button>
|
|
</div>
|
|
</div>
|
|
<el-table :key="tableKey" :data="formobj.scmVehRebateVehs" :index="index" border style="width: 100%" show-summary :summary-method="getSummaries">
|
|
<el-table-column fixed width="80px" label="序号" type="index" :index="index + 1" align="center"/>
|
|
<el-table-column fixed prop="name" label="操作" width="100px" align="center" header-align="center">
|
|
<template slot-scope="scope">
|
|
<el-button size="mini" type="danger" @click="dataDelete(scope.$index)">删除
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="brandName" label="品牌" align="center" width="120" />
|
|
<el-table-column prop="purchaseSystemName" label="采购系统" align="center" width="140" />
|
|
<el-table-column prop="vinNo" label="车架号" align="center" width="90" />
|
|
<el-table-column prop="manufactorSettlementPrice" label="车辆入库价" align="center" width="110"/>
|
|
<el-table-column prop="freight" label="其中运费" align="center" width="100" />
|
|
<el-table-column prop="topAmount" label="上装" align="center" width="90" />
|
|
<el-table-column prop="estimateRebate" label="预计返利" align="center" width="100" />
|
|
<el-table-column label="其中待支付费用" align="center" width="225">
|
|
<template slot-scope="scope">
|
|
<el-input v-model="scope.row.expectTreatCost" @keyup.native="scope.row.expectTreatCost = getNumber(scope.row.expectTreatCost, 2)" clearable placeholder="待支付的相关人员返利等"></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="其中抵顶费用" align="center" width="310">
|
|
<template slot-scope="scope">
|
|
<el-input v-model="scope.row.expectSuppCost" @keyup.native="scope.row.expectSuppCost = getNumber(scope.row.expectSuppCost, 2)" clearable placeholder="抵顶各种垫付款,例如垫付厂家人员房租"></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="抵顶费用说明" align="center" min-width="250">
|
|
<template slot-scope="scope">
|
|
<el-input v-model="scope.row.expectSuppRemark" clearable placeholder=""></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="备注" align="center" min-width="250">
|
|
<template slot-scope="scope">
|
|
<el-input v-model="scope.row.remarks" clearable placeholder=""></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</el-form>
|
|
</div>
|
|
</div>
|
|
<!--End 添加修改部分-->
|
|
<bicyclerebatemanagementByVehicle v-show="viewState == 2" ref="divSelect" @backData="backData" @doback="resetState"/>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import req from '@/api/bikerebate/bicyclerebatemanagement'
|
|
import { getTypeValueList, typeValues } from '@/api/cheliang/dictcommons'
|
|
import bicyclerebatemanagementByVehicle from './bicyclerebatemanagementByVehicle'
|
|
|
|
export default {
|
|
name: 'BicycleRebateManagementAdd',
|
|
components: {
|
|
bicyclerebatemanagementByVehicle
|
|
},
|
|
data() {
|
|
return {
|
|
viewTitle: '',
|
|
index: 0,
|
|
tableKey: 0,
|
|
viewState: 1,
|
|
rebateType_list: [], // 返利类型
|
|
calculationMode_list: [], // 计算方式
|
|
policySide_list: [], // 返利政策方
|
|
// 表单数据
|
|
formobj: {
|
|
rebateTypeKey: '',
|
|
rebateTypeValue: '',
|
|
rebateName: '',
|
|
palceGenDate: '',
|
|
calculationModeKey: '',
|
|
calculationModeValue: '',
|
|
policySideKey: '',
|
|
policySideValue: '',
|
|
calculationStandard: '',
|
|
sid: '',
|
|
orgPath: '',
|
|
createBySid: '',
|
|
scmVehRebateVehs: []
|
|
},
|
|
rules: {
|
|
rebateTypeValue: [{ required: true, message: '返利类型不能为空', trigger: 'change' }],
|
|
rebateName: [{ required: true, message: '返利名称不能为空', trigger: 'blur' }],
|
|
palceGenDate: [{ required: true, message: '所属年月不能为空', trigger: 'change' }],
|
|
calculationModeValue: [{ required: true, message: '计算方式不能为空', trigger: 'change' }],
|
|
calculationStandard: [{ required: true, message: '计算标准不能为空', trigger: 'blur' }]
|
|
},
|
|
submitdisabled: false
|
|
}
|
|
},
|
|
methods: {
|
|
init() {
|
|
getTypeValueList({ type: 'rebateType', groupNum: 'DC' }).then((res) => {
|
|
if (res.success) {
|
|
this.rebateType_list = res.data
|
|
}
|
|
})
|
|
typeValues({ type: 'calculationMode' }).then((resp) => {
|
|
if (resp.success) {
|
|
this.calculationMode_list = resp.data
|
|
}
|
|
})
|
|
typeValues({ type: 'policySide' }).then((resp) => {
|
|
if (resp.success) {
|
|
this.policySide_list = resp.data
|
|
}
|
|
})
|
|
},
|
|
getSpecialNumber(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(/\-{2,}/g, '.') // 两个以上的“-”号转换成一个
|
|
val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.') // 只保留一个小数点
|
|
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 {
|
|
// 通过正则保留小数点后指定的位数
|
|
val = val.replace(reg, '$1.$2')
|
|
}
|
|
return val
|
|
},
|
|
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 {
|
|
// 通过正则保留小数点后指定的位数
|
|
val = val.replace(reg, '$1.$2')
|
|
}
|
|
return val
|
|
},
|
|
showAdd() {
|
|
this.$nextTick(() => {
|
|
this.$refs['form_obj'].clearValidate()
|
|
this.init()
|
|
})
|
|
this.formobj.orgPath = window.sessionStorage.getItem('defaultOrgPath')
|
|
this.formobj.createBySid = window.sessionStorage.getItem('userSid')
|
|
this.viewTitle = '【新增】单车返利'
|
|
},
|
|
changeRebateType(value) {
|
|
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) {
|
|
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 = ''
|
|
}
|
|
},
|
|
changePolicySide(value) {
|
|
const choose = this.policySide_list.filter((item) => item.dictValue === value)
|
|
if (choose !== null && choose.length > 0) {
|
|
this.formobj.policySideKey = choose[0].dictKey
|
|
} else {
|
|
this.formobj.policySideKey = ''
|
|
}
|
|
},
|
|
// 明细表添加一行数据
|
|
addjacket() {
|
|
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
|
|
if (value.length > 0) {
|
|
value.forEach((e) => {
|
|
this.formobj.scmVehRebateVehs.push({
|
|
vinNo: e.vinNo,
|
|
vehSid: e.vehSid,
|
|
manufactorSettlementPrice: e.manufactorSettlementPrice,
|
|
freight: e.freight,
|
|
topAmount: e.topAmount,
|
|
estimateRebate: '',
|
|
expectTreatCost: '',
|
|
expectSuppCost: '',
|
|
expectSuppRemark: '',
|
|
brandName: e.brandName,
|
|
brandSid: e.brandSid,
|
|
purchaseSystemName: e.purchaseSystemName,
|
|
purchaseSystemSid: e.purchaseSystemSid,
|
|
vehModelName: e.vehModelName,
|
|
vehModelSid: e.vehModelSid,
|
|
remarks: ''
|
|
})
|
|
})
|
|
}
|
|
this.formobj.scmVehRebateVehs.forEach((e) => {
|
|
// 计算方式为比例时,
|
|
if (this.formobj.calculationModeKey === '001') {
|
|
if (e.brandName === '陕汽') {
|
|
// 预计返利 = (车辆入库价 - 运费 - 上装) * (计算标准 / 100)
|
|
e.estimateRebate = Math.round(((parseFloat(e.manufactorSettlementPrice !== '' ? e.manufactorSettlementPrice : 0) - parseFloat(e.freight !== '' ? e.freight : 0) - parseFloat(e.topAmount !== '' ? e.topAmount : 0)) * (parseFloat(this.formobj.calculationStandard) / 100)) * 100) / 100
|
|
} else {
|
|
// 预计返利 = (车辆入库价 - 运费) * (计算标准 / 100)
|
|
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) {
|
|
this.formobj.scmVehRebateVehs.splice(index, 1)
|
|
},
|
|
resetState() {
|
|
this.viewState = 1
|
|
},
|
|
save() {
|
|
if (this.formobj.scmVehRebateVehs.length === 0) {
|
|
this.$message({ showClose: true, type: 'error', message: '返利车辆列表不能为空' })
|
|
return
|
|
}
|
|
this.$refs['form_obj'].validate((valid) => {
|
|
if (valid) {
|
|
this.submitdisabled = true
|
|
req.save(this.formobj).then((resp) => {
|
|
this.submitdisabled = false
|
|
if (resp.success) {
|
|
this.$message({ showClose: true, type: 'success', message: resp.msg })
|
|
this.handleReturn('true')
|
|
}
|
|
}).catch(() => {
|
|
this.submitdisabled = false
|
|
})
|
|
} else {
|
|
return false
|
|
}
|
|
})
|
|
},
|
|
// 合计
|
|
getSummaries(param) {
|
|
const { columns, data } = param
|
|
const sums = []
|
|
columns.forEach((column, index) => {
|
|
if (index === 0) {
|
|
sums[index] = '合计'
|
|
return
|
|
}
|
|
const values = data.map(item => Number(item[column.property]))
|
|
if (column.property === 'estimateRebate') {
|
|
sums[index] = values.reduce((prev, curr) => {
|
|
const value = Number(curr)
|
|
if (!isNaN(value)) {
|
|
return Math.round((parseFloat(prev) + parseFloat(curr)) * 100) / 100
|
|
} else {
|
|
return Math.round((parseFloat(prev)) * 100) / 100
|
|
}
|
|
}, 0)
|
|
sums[index] += ''
|
|
}
|
|
})
|
|
return sums
|
|
},
|
|
// 返回(===既判断)
|
|
handleReturn(isreload) {
|
|
if (isreload === 'true') this.$emit('reloadlist')
|
|
// 表单数据
|
|
this.formobj = {
|
|
rebateTypeKey: '',
|
|
rebateTypeValue: '',
|
|
rebateName: '',
|
|
palceGenDate: '',
|
|
calculationModeKey: '',
|
|
calculationModeValue: '',
|
|
policySideKey: '',
|
|
policySideValue: '',
|
|
calculationStandard: '',
|
|
sid: '',
|
|
orgPath: '',
|
|
createBySid: '',
|
|
scmVehRebateVehs: []
|
|
}
|
|
this.$refs['form_obj'].resetFields()
|
|
this.$emit('doback')
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style scoped>
|
|
.span-sty {
|
|
width: 130px !important;
|
|
}
|
|
.addinputInfo {
|
|
margin-left: 120px !important;
|
|
}
|
|
.formaddcopy02 .el-row .el-col /deep/ .el-form-item .addinputw {
|
|
margin-left: 120px !important;
|
|
width: calc(100% - 115px);
|
|
}
|
|
/deep/ .el-form-item__error {
|
|
margin-left: 120px !important;
|
|
}
|
|
.titleOne {
|
|
padding: 7px;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
</style>
|
|
|
|
|