edit
This commit is contained in:
parent
578361bf5a
commit
57c4cb6d1f
|
@ -45,7 +45,7 @@
|
|||
</el-table-column>
|
||||
<el-table-column label="售价" min-width="100" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-input @input="handleOnform" v-model="oneFormBatch[0].price" class="priceBox" controls-position="right"/>
|
||||
<el-input @input="handleOnform('price')" v-model="oneFormBatch[0].price" class="priceBox" controls-position="right"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="成本价" min-width="100" align="center">
|
||||
|
@ -60,20 +60,20 @@
|
|||
</el-table-column>
|
||||
<el-table-column label="占比" min-width="100" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-select @change="BatchProportionChange" v-model="oneFormBatch[0].proportion" placeholder="请选择">
|
||||
<!-- <el-select @change="BatchProportionChange" v-model="oneFormBatch[0].proportion" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in proportionList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<!-- <el-input-number :disabled="true" v-model="oneFormBatch[0].proportion" :min="0" class="priceBox" controls-position="right"/> -->
|
||||
</el-select> -->
|
||||
<el-input @input="handleOnform('proportion')" v-model="oneFormBatch[0].proportion" :min="0" class="priceBox" controls-position="right"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="抵扣卷" min-width="100" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-input-number :disabled='true' v-model="oneFormBatch[0].coupon" :min="0" class="priceBox" controls-position="right"/>
|
||||
<el-input @input="batchInput" v-model="oneFormBatch[0].coupon" class="priceBox" controls-position="right"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="库存" min-width="100" align="center">
|
||||
|
@ -123,15 +123,15 @@
|
|||
</el-table-column>
|
||||
<el-table-column v-for="(item,iii) in attrValue" :key="iii" :label="formThead[iii].title" align="center" min-width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-select @change="proportionChange(scope.row,iii,$event)" v-if="formThead[iii].title === '占比'" v-model="scope.row[iii]" placeholder="请选择">
|
||||
<!-- <el-select @change="proportionChange(scope.row,iii,$event)" v-if="formThead[iii].title === '占比'" v-model="scope.row[iii]" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in proportionList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-input @input="handleCost(scope.row,iii)" :disabled="formThead[iii].title =='抵扣卷'" v-if="formThead[iii].title != '占比'" v-model="scope.row[iii]" type="text" class="priceBox" />
|
||||
</el-select> -->
|
||||
<el-input @input="handleCost(scope.row,iii)" v-model="scope.row[iii]" type="text" class="priceBox" />
|
||||
<!-- <el-input v-else @input="handleCost(scope.row,iii)" :disabled="formThead[iii].title === '占比'" v-model="scope.row[iii]" class="priceBox" controls-position="right"/> -->
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -170,15 +170,15 @@
|
|||
</el-table-column>
|
||||
<el-table-column v-for="(item,iii) in attrValue" :key="iii" :label="formThead[iii].title" align="center" min-width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-input @input="handleCost(scope.row,iii)" :disabled="formThead[iii].title =='抵扣卷'" v-if="formThead[iii].title !=='占比'" v-model="scope.row[iii]" type="text" class="priceBox" />
|
||||
<el-select @change="proportionChange(scope.row,iii,$event)" v-if="formThead[iii].title === '占比'" v-model="scope.row[iii]" placeholder="请选择">
|
||||
<el-input @input="handleCost(scope.row,iii)" v-model="scope.row[iii]" type="text" class="priceBox" />
|
||||
<!-- <el-select @change="proportionChange(scope.row,iii,$event)" v-if="formThead[iii].title === '占比'" v-model="scope.row[iii]" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in proportionList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-select> -->
|
||||
<!-- <el-input v-if="formThead[iii].title==='商品编号'" v-model="scope.row[iii]" type="text" class="priceBox" /> -->
|
||||
<!-- <el-input v-else @input="handleCost(scope.row,iii)" :disabled="formThead[iii].title === '占比'" v-model="scope.row[iii]" class="priceBox" controls-position="right"/> -->
|
||||
</template>
|
||||
|
@ -249,7 +249,7 @@ const defaultObj = {
|
|||
cost: 0,
|
||||
ot_price: 0,
|
||||
proportion:0.6,
|
||||
coupon:'',
|
||||
coupon:0,
|
||||
stock: 0,
|
||||
growth:0,
|
||||
bar_code: '',
|
||||
|
@ -396,7 +396,7 @@ export default {
|
|||
price: 0,
|
||||
cost: 0,
|
||||
proportion:0.6,
|
||||
coupon:'',
|
||||
coupon:0,
|
||||
growth:0,
|
||||
ot_price: 0,
|
||||
stock: 0,
|
||||
|
@ -412,7 +412,7 @@ export default {
|
|||
image: '',
|
||||
price: 0,
|
||||
proportion:0.6,
|
||||
coupon:'',
|
||||
coupon:0,
|
||||
growth:0,
|
||||
cost: 0,
|
||||
ot_price: 0,
|
||||
|
@ -461,22 +461,32 @@ export default {
|
|||
this.oneFormBatch[0].growth = Math.floor(this.oneFormBatch[0].price*obj.growth)
|
||||
},
|
||||
handleOnform(type){
|
||||
if(type=='ot_price'){
|
||||
this.oneFormBatch[0].ot_price = this.oneFormBatch[0].ot_price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
|
||||
}else if(type=='cost'){
|
||||
this.oneFormBatch[0].cost = this.oneFormBatch[0].cost.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
|
||||
switch (type) {
|
||||
case 'ot_price':
|
||||
this.oneFormBatch[0].ot_price = this.oneFormBatch[0].ot_price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
|
||||
break;
|
||||
case 'cost':
|
||||
this.oneFormBatch[0].proportion = toFixedNoRounding(this.oneFormBatch[0].cost/this.oneFormBatch[0].price)
|
||||
this.oneFormBatch[0].cost = this.oneFormBatch[0].cost.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
|
||||
break;
|
||||
case 'price':
|
||||
this.oneFormBatch[0].price = this.oneFormBatch[0].price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
|
||||
this.oneFormBatch[0].cost = toFixedNoRounding(this.oneFormBatch[0].price * this.oneFormBatch[0].proportion)
|
||||
break;
|
||||
case 'proportion':
|
||||
this.oneFormBatch[0].proportion = this.oneFormBatch[0].proportion.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
|
||||
this.oneFormBatch[0].cost = toFixedNoRounding(this.oneFormBatch[0].price * this.oneFormBatch[0].proportion)
|
||||
break;
|
||||
}
|
||||
// this.oneFormBatch[0].growth = parseInt( this.oneFormBatch[0].price*(0.9-( this.oneFormBatch[0].cost/ this.oneFormBatch[0].price)))
|
||||
// this.oneFormBatch[0].proportion = (this.oneFormBatch[0].cost/this.oneFormBatch[0].price).toFixed(2)
|
||||
}else{
|
||||
this.oneFormBatch[0].price = this.oneFormBatch[0].price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
|
||||
this.oneFormBatch[0].cost = toFixedNoRounding(this.oneFormBatch[0].price * this.oneFormBatch[0].proportion)
|
||||
let obj = this.proportionList.find(item=>item.value==this.oneFormBatch[0].proportion)
|
||||
this.oneFormBatch[0].coupon = Math.floor(this.oneFormBatch[0].price*obj.coupon)
|
||||
this.oneFormBatch[0].growth = Math.floor(this.oneFormBatch[0].price*obj.growth)
|
||||
// let obj = this.proportionList.find(item=>item.value==this.oneFormBatch[0].proportion)
|
||||
// this.oneFormBatch[0].coupon = Math.floor(this.oneFormBatch[0].price*obj.coupon)
|
||||
// this.oneFormBatch[0].growth = Math.floor(this.oneFormBatch[0].price*obj.growth)
|
||||
// this.oneFormBatch[0].growth = parseInt( this.oneFormBatch[0].price*(0.9-( this.oneFormBatch[0].cost/ this.oneFormBatch[0].price)))
|
||||
// this.oneFormBatch[0].proportion = (this.oneFormBatch[0].cost/this.oneFormBatch[0].price).toFixed(2)
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
calculatePercentage(number) {
|
||||
// 假设输入的是0.6,50%
|
||||
|
@ -491,6 +501,7 @@ export default {
|
|||
switch(i){
|
||||
case 'cost':
|
||||
val.cost=val.cost.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
|
||||
val.proportion = toFixedNoRounding(val.cost/val.price)
|
||||
// val.proportion = (val.cost/val.price).toFixed(2)
|
||||
// val.growth = parseInt(val.price*(0.9-(val.cost/val.price)))
|
||||
break;
|
||||
|
@ -502,26 +513,36 @@ export default {
|
|||
break;
|
||||
case 'price':
|
||||
val.price=val.price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
|
||||
let obj = this.proportionList.find(item=>item.value==val.proportion)
|
||||
// let obj = this.proportionList.find(item=>item.value==val.proportion)
|
||||
val.cost = toFixedNoRounding(val.price * val.proportion)
|
||||
val.coupon = Math.floor(val.price*obj.coupon)
|
||||
val.growth = Math.floor(val.price*obj.growth)
|
||||
// val.coupon = Math.floor(val.price*obj.coupon)
|
||||
// val.growth = Math.floor(val.price*obj.growth)
|
||||
break;
|
||||
case 'growth':
|
||||
val.growth=val.growth.replace(/[^\d]/g,'')
|
||||
break;
|
||||
case 'proportion':
|
||||
val.proportion=val.proportion.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1')
|
||||
val.cost = toFixedNoRounding(val.price * val.proportion)
|
||||
break;
|
||||
case 'bar_code':
|
||||
val.bar_code = val.bar_code.replace(/[\W]/g,'')
|
||||
break;
|
||||
case 'coupon':
|
||||
val.coupon = val.coupon.replace(/[\W]/g,'')
|
||||
break;
|
||||
}
|
||||
},
|
||||
batchInput(e){
|
||||
this.oneFormBatch[0].coupon = e.replace(/[\W]/g,'')
|
||||
},
|
||||
batchDel() {
|
||||
this.oneFormBatch = [
|
||||
{
|
||||
image: '',
|
||||
price: 0,
|
||||
proportion:0.6,
|
||||
coupon:'',
|
||||
coupon:0,
|
||||
growth:0,
|
||||
cost: 0,
|
||||
ot_price: 0,
|
||||
|
|
Loading…
Reference in New Issue