master
2812875475 2024-03-25 14:17:18 +08:00
parent 82c0241ce0
commit 5775329fac
2 changed files with 87 additions and 19 deletions

View File

@ -101,16 +101,21 @@
</el-row> </el-row>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<h1 style=" display: inline-block; margin-right: 200px; margin-left: 30px">{{ good.name }}</h1> <h1 style=" display: inline-block; margin-right: 200px; margin-left: 30px">{{ good.name }}</h1>{{combinedResults}}
<h3 style="display: inline-block; color: red;">50</h3> <h3 style="display: inline-block; color: red;">{{price}}</h3>
<el-form ref="form" :model="form" label-width="80px" style="margin-top: 80px"> <el-form ref="form" :model="form" label-width="80px" style="margin-top: 80px">
<el-form-item :label="rule.name" v-for="(rule, index) in form.ruleList" :key="index"> <el-form-item :label="rule.name" v-for="(rule, index) in form.ruleList" :key="index">
<el-radio-group size="small" v-model="rule.selectedValue"> <el-radio-group size="small" v-model="rule.selectedValue" @change="changeCheck(rule, $event)">
<el-radio v-for="item in rule.value" :key="item" :label="item">{{ item }}</el-radio> <el-radio v-for="item in rule.value"
:key="item"
:label="item"
:value="item.value"
>{{ item }}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="规格2"> <el-form-item label="购买数量">
<el-input-number v-model="form.num" :min="1" :max="100" label="描述文字"></el-input-number> <el-input-number v-model="form.num" :min="1" :max="100" label="描述文字"></el-input-number>库存{{stock}}
<h3 style="color: red;">总价{{sumPrice}}</h3>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="onSubmit"></el-button> <el-button type="primary" @click="onSubmit"></el-button>
@ -154,7 +159,6 @@ export default {
computed: {}, computed: {},
data() { data() {
return { return {
names:"",
/*图片*/ /*图片*/
imageList: [], imageList: [],
/*品牌信息*/ /*品牌信息*/
@ -171,7 +175,7 @@ export default {
// //
form: { form: {
ruleList: [], ruleList: [],
selectedValue: 1 num:1
}, },
ruleValueList: [], ruleValueList: [],
/*国歌表单*/ /*国歌表单*/
@ -181,7 +185,18 @@ export default {
attributeList: [] attributeList: []
}, },
/*商品详情*/ /*商品详情*/
goodDetail: [] goodDetail: [],
/*监控选中的值*/
names:"",
// rule value
previousRule: null,
previousValue: null,
//
combinedResults: "",
sku:[],
price:0,
stock:0,
sumPrice:0,
} }
}, },
created() { created() {
@ -189,13 +204,45 @@ export default {
this.details(id) this.details(id)
}, },
watch:{ watch:{
"names":{ "form.num":{
handler(val){ handler(val){
console.log(val) this.stock=this.stock-1
} this.sumPrice=this.sumPrice+this.price
} }
}, },
},
methods: { methods: {
changeCheck(rule, value){
//this.form.num=1
//console.log(checkValue)
console.log(rule.selectedValue)
this.combinedResults=""
if (this.previousValue !== null) {
//
const combined = `${this.previousValue}${value}`;
this.combinedResults+=combined
console.log(this.combinedResults); //
// rule value
this.previousRule = null;
this.previousValue = null;
} else {
// rule value
this.previousRule = rule;
this.previousValue = value;
}
this.sku.forEach(
sku=>{
if(this.combinedResults===sku.sku){
this.price=sku.price
this.sumPrice=sku.price
this.stock=sku.stock
}
}
)
},
/*立即购买按钮*/ /*立即购买按钮*/
onSubmit() { onSubmit() {
@ -209,14 +256,15 @@ export default {
this.good.name = res.data.product.name this.good.name = res.data.product.name
this.good.carouselImages = res.data.product.carouselImages this.good.carouselImages = res.data.product.carouselImages
this.imageList.push(res.data.product.carouselImages) this.imageList.push(res.data.product.carouselImages)
this.sku=res.data.projectSkuInfo
let e1=[] let e1=[]
res.data.ruleList.forEach( res.data.ruleList.forEach(
rule=>{ rule=>{
e1.push( e1.push({id:rule.id,name:rule.name,value:rule.value})
{id:rule.id,name:rule.name,value:rule.value}
)
} }
) )
console.log(e1) console.log(e1)
this.form.ruleList =e1 this.form.ruleList =e1
this.categoryCommonElement = res.data.categoryCommonElementResp this.categoryCommonElement = res.data.categoryCommonElementResp

View File

@ -176,7 +176,9 @@
reserve-keyword reserve-keyword
placeholder="请输入关键词" placeholder="请输入关键词"
:remote-method="remoteSearchBrandList" :remote-method="remoteSearchBrandList"
:loading="loading"> :loading="loading"
clearable
>
<el-option <el-option
v-for="brand in brandList" v-for="brand in brandList"
:key="brand.id" :key="brand.id"
@ -254,6 +256,7 @@
<span v-if="title.prop.indexOf('prop') >-1 ">{{ scope.row[title.prop] }}</span> <span v-if="title.prop.indexOf('prop') >-1 ">{{ scope.row[title.prop] }}</span>
<el-input-number v-else-if="['stock','price'].indexOf(title.prop) > -1" <el-input-number v-else-if="['stock','price'].indexOf(title.prop) > -1"
v-model="scope.row[title.prop]" :step="0.1" :max="10000"></el-input-number> v-model="scope.row[title.prop]" :step="0.1" :max="10000"></el-input-number>
<div v-else-if="['image'].indexOf(title.prop) > -1" style="width: 30px; height: 30px;"> <div v-else-if="['image'].indexOf(title.prop) > -1" style="width: 30px; height: 30px;">
<image-upload v-model="scope.row[title.prop]" <image-upload v-model="scope.row[title.prop]"
:limit="1" :limit="1"
@ -482,7 +485,7 @@ export default {
mianType:'', mianType:'',
parentType:'', parentType:'',
type:'', type:'',
specification:"", specification:[],
groupList:"", groupList:"",
attributeList:"", attributeList:"",
persionList:"", persionList:"",
@ -564,6 +567,11 @@ export default {
this.categoryCommonElement.templateAttributeGroupList = templateAttributeGroupList; this.categoryCommonElement.templateAttributeGroupList = templateAttributeGroupList;
this.categoryCommonElement.templateAttributeList = templateAttributeList; this.categoryCommonElement.templateAttributeList = templateAttributeList;
this.categoryCommonElement.attributeList = attributeList; this.categoryCommonElement.attributeList = attributeList;
console.log(attributeList)
let e=[]
e=attributeList.filter(attribute=>attribute.value!=null)
console.log(e)
this.attributeCheckedList=e
}) })
} }
} }
@ -780,9 +788,19 @@ export default {
this.reset(); this.reset();
const id = row.id || this.ids const id = row.id || this.ids
getInfo(id).then(response => { getInfo(id).then(response => {
console.log(this.categoryCommonElement) // let a=[]
// response.data.specification.forEach(
// specification=>{
// a.push(
// {image:specification.image,stock:specification.stock,price:specification.price}
// )
// }
// )
// this.skuList=a
// console.log(this.skuList)
this.test.id=id this.test.id=id
this.form = response.data; this.form = response.data;
//this.oneSettingValue=response.data.specificationList
this.oneSettingValue=response.data.specification this.oneSettingValue=response.data.specification
this.changeRule(response.data.ruleId) this.changeRule(response.data.ruleId)
this.onSubmit() this.onSubmit()
@ -808,10 +826,12 @@ export default {
}); });
} else { } else {
this.selectAttribute() this.selectAttribute()
console.log(this.form)
addInfo(this.form).then(response => { addInfo(this.form).then(response => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
this.skuList=[]
}); });
} }
} }
@ -841,7 +861,7 @@ export default {
} }
) )
this.form.sku=this.skuList1 this.form.sku=this.skuList1
this.form.specification=this.oneSettingValue this.form.specification=this.skuList
this.form.groupList=this.a this.form.groupList=this.a
this.form.attributeList=this.b this.form.attributeList=this.b
this.form.persionList=this.c this.form.persionList=this.c