|
|
|
|
@ -1,31 +1,40 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<Modal :width="62" loading title="产品组合" :value.sync="isShow" @on-visible-change="$emit('update:isShow',$event)" @on-ok="submit" @on-cancel="reset">
|
|
|
|
|
<Modal :width="62" title="产品组合" :value.sync="isShow" @on-visible-change="$emit('update:isShow',$event)" @on-cancel="reset">
|
|
|
|
|
<Form :model="form" ref="form">
|
|
|
|
|
<FormItem
|
|
|
|
|
prop="products"
|
|
|
|
|
v-for="(item, index) in form.products"
|
|
|
|
|
:key="index"
|
|
|
|
|
:label="'产品'+item.index">
|
|
|
|
|
<Row>
|
|
|
|
|
<Col span="6" offset="1">
|
|
|
|
|
<Select type="text" v-model="item.value" placeholder="选择产品">
|
|
|
|
|
:key="index">
|
|
|
|
|
<div class="product">
|
|
|
|
|
<div class="product-content">
|
|
|
|
|
<div style="width: 60px">{{'产品'+item.index}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="product-content">
|
|
|
|
|
<Select type="text" v-model="item.value" placeholder="选择产品" style="width: 140px;">
|
|
|
|
|
<Option v-for="pro in products" :key="pro.id" :value="pro.id">{{pro.name}}</Option>
|
|
|
|
|
</Select>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span="3" offset="1">
|
|
|
|
|
<InputNumber :min="0" v-model="item.num" placeholder="数量"></InputNumber>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span="3" offset="1" >
|
|
|
|
|
<Input type="text" v-model="item.unit" placeholder="单位"></Input>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span="3" offset="1">
|
|
|
|
|
<InputNumber :precision="2" type="text" v-model="item.price" placeholder="价格"></InputNumber>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span="3" offset="1">
|
|
|
|
|
<Button icon="md-remove" type="primary" @click="removeProduct(item.index,item.id)">移除</Button>
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="product-content">
|
|
|
|
|
<InputNumber :min="0" v-model="item.num" placeholder="数量" style="width: 80px;"></InputNumber>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="product-content">
|
|
|
|
|
<Input type="text" v-model="item.unit" placeholder="单位" style="width: 80px;"></Input>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="product-content">
|
|
|
|
|
<InputNumber :precision="2" type="text" v-model="item.price" placeholder="价格" style="width: 100px;"></InputNumber>
|
|
|
|
|
</div>
|
|
|
|
|
<template v-if="!item.id">
|
|
|
|
|
<div class="product-content">
|
|
|
|
|
<Button icon="md-add" type="primary" @click="submit(item)" style="width: 80px;">确认</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template>
|
|
|
|
|
<div class="product-content">
|
|
|
|
|
<Button icon="md-remove" type="primary" @click="removeProduct(item.index,item.id)" style="width: 80px;">移除</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</div>
|
|
|
|
|
</FormItem>
|
|
|
|
|
<FormItem style="display: flex;justify-content: center;">
|
|
|
|
|
<Button style="width: 200px;" type="dashed" @click="addProduct" icon="md-add">新增</Button>
|
|
|
|
|
@ -57,7 +66,6 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
removeProduct(index,id){
|
|
|
|
|
console.log(index,id)
|
|
|
|
|
if(id){
|
|
|
|
|
deleteItems({
|
|
|
|
|
deleting_ids:[{id}]
|
|
|
|
|
@ -106,6 +114,7 @@ export default {
|
|
|
|
|
const res = await getItems({package_id:this.id})
|
|
|
|
|
this.form.products.push(...(res.map(item => {
|
|
|
|
|
return {
|
|
|
|
|
id:item.id,
|
|
|
|
|
value:item.product_type_id,
|
|
|
|
|
index:++this.productIndex,
|
|
|
|
|
num:item.num,
|
|
|
|
|
@ -115,17 +124,18 @@ export default {
|
|
|
|
|
})))
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
submit(){
|
|
|
|
|
submit(item){
|
|
|
|
|
saveItems({
|
|
|
|
|
save_rows:this.form.products.map(item => {
|
|
|
|
|
return {package_id:this.id,unit:item.unit,num:item.num,product_type_id:item.value,price:item.price}
|
|
|
|
|
})
|
|
|
|
|
save_rows:[{package_id:this.id,unit:item.unit,num:item.num,product_type_id:item.value,price:item.price}]
|
|
|
|
|
// this.form.products.map(item => {
|
|
|
|
|
// return {package_id:this.id,unit:item.unit,num:item.num,product_type_id:item.value,price:item.price}
|
|
|
|
|
// })
|
|
|
|
|
}).then(res => {
|
|
|
|
|
Message({
|
|
|
|
|
type:'success',
|
|
|
|
|
message:'产品组合更改完成'
|
|
|
|
|
})
|
|
|
|
|
this.$emit('update:isShow',false)
|
|
|
|
|
this.getItems()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -144,4 +154,14 @@ export default {
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.product{
|
|
|
|
|
min-width: 700px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-evenly;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
::v-deep .ivu-modal-body{
|
|
|
|
|
overflow: scroll;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|