This commit is contained in:
faiz 2024-05-17 16:55:51 +08:00
parent 578361bf5a
commit 57c4cb6d1f
1 changed files with 50 additions and 29 deletions

View File

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