This commit is contained in:
2024-04-09 08:56:34 +08:00
parent 53aa029391
commit 7cf3af639d
3 changed files with 202 additions and 98 deletions

View File

@@ -6,7 +6,7 @@
</cu-custom>
<view id="chooseType" :class="currentBoxId == 'chooseType' ? 'show' : 'hidden'">
<uni-forms ref="productForm" :modelValue="productDate" :rules="rules" label-width="200rpx">
<uni-forms-item label="商品分类:" name="name">
<uni-forms-item label="商品分类:" name="demandRegion">
<mulpicker
v-model="productDate.demandRegion"
:list="productList"
@@ -74,20 +74,20 @@
<view class="uni-px-5" v-for="(item,index) in attributesList">
<view style="display: inline-block;">{{item.attributeName}}</view>
<view style="display: inline-block;">
<uni-data-checkbox v-if="index==0" mode="tag" v-model="radioAttributes" :localdata="item.attributesList"></uni-data-checkbox>
<uni-data-checkbox v-else-if="index!=0" mode="tag" multiple v-model="checkboxAttributes" :localdata="hobby"></uni-data-checkbox>
<uni-data-checkbox v-if="index==0" mode="tag" @change="changeRadio(item,index)" v-model="radioAttributes" :localdata="item.attributesList"></uni-data-checkbox>
<uni-data-checkbox v-else-if="index!=0" mode="tag" @change="changeCheckBox(item,index)" multiple v-model="checkboxAttributes" :localdata="item.attributesList"></uni-data-checkbox>
</view>
</view>
</uni-section>
</view>
</view>
<view>
<view style="padding-bottom: 20rpx;border-bottom: 1rpx solid #f6f6f6;">
<view>批量填充<text style="color: #999999;margin: 10rpx 0;">批量填充填入信息后可以批量将内容填写到SKU 信息里</text></view>
<view class="tagButton" @tap="changeChecked(item)" v-for="item in bottonList">{{item.label}}</view>
<view class="tagButton" v-for="item in bottonList">{{item.label}}</view>
<view class="redButton" @tap="addStockList">确定</view>
</view>
<view v-for="(items,index) in stockList">
<view style="padding: 20rpx 0;;border-bottom: 1rpx solid #f6f6f6;" v-for="(items,index) in stockList">
<view style="margin: 10rpx 0;">
<text style="color: red;">*</text>
<text>规格</text>
@@ -163,6 +163,7 @@
currentBoxId: 'chooseType', //当前显示的view的id
isBoxShow: false,
productDate:{
productStatus:'1',
images:[]
},
productList:[],
@@ -175,9 +176,9 @@
checked: false
}],
rules:{
name:{rules:[{required: true,errorMessage: '请选择商品分类'}]},
demandRegion:{rules:[{required: true,errorMessage: '请选择商品分类'}]},
productName:{rules:[{required: true,errorMessage: '请输入商品名称'}]},
brandId:{rules:[{required: true,errorMessage: '请输入商品品牌'}]},
brandId:{rules:[{required: true,errorMessage: '请选择商品品牌'}]},
price:{rules:[{required: true,errorMessage: '请输入商品售价'}]},
},
attributesTypeList:[],
@@ -190,7 +191,8 @@
],
radioAttributes:'',
checkboxAttributes:[],
stockList:[]
stockList:[],
checkedList:[]
}
},
@@ -205,6 +207,11 @@
this.productDate.categoryOneId = val.split(',')[0]
this.productDate.categoryTwoId = val.split(',')[1]
}
},
'productDate.attributesTypeId'(val){
if(!val){
this.stockList = []
}
}
},
methods: {
@@ -257,20 +264,40 @@
},
changeBox(e){
let currentFlag = e.currentTarget.id;
switch(currentFlag){
case 'next':
this.currentBoxId = 'instruction'
break;
case 'previous':
this.currentBoxId = 'chooseType'
break;
default:
this.currentBoxId = 'viewInstruction'
break;
}
if(currentFlag == 'next'){
this.getAttributesType()
this.$refs.productForm.validate().then(res=>{
console.log('表单数据信息:', res);
switch(currentFlag){
case 'next':
this.currentBoxId = 'instruction'
break;
case 'previous':
this.currentBoxId = 'chooseType'
break;
default:
this.currentBoxId = 'viewInstruction'
break;
}
if(currentFlag == 'next'){
this.getAttributesType()
}
}).catch(err =>{
console.log('表单错误信息:', err);
})
}else{
switch(currentFlag){
case 'next':
this.currentBoxId = 'instruction'
break;
case 'previous':
this.currentBoxId = 'chooseType'
break;
default:
this.currentBoxId = 'viewInstruction'
break;
}
}
},
getAttributesType(){
this.attributesTypeList = []
@@ -304,6 +331,25 @@
}
},
changeRadio(item,index){
if(JSON.stringify(this.checkedList) == '[]'){
this.checkedList.push({attributeId:item.id,checked:item.attributeName})
}else{
this.checkedList[index].checked = item.attributeName
}
},
changeCheckBox(item,index){
if(this.checkedList.length<index+1){
this.checkedList.push({attributeId:item.id,checked:item.attributeName})
}else{
let checked = []
this.checkboxAttributes.forEach(tab=>{
checked.push(tab)
})
this.checkedList[index].checked = checked.join(',')
this.checkedList.checked
}
},
deleteCheckAll(i){
if(this.checkboxAttributes.length>1){
this.checkboxAttributes.splice(i,1)
@@ -358,7 +404,6 @@
sourceType: ['album'], //从相册选择
success: function(res) {
console.log(res)
console.log('进入1')
const JSESSIONID = utils.uuid()
uni.uploadFile({
url: 'http://uat.xingoil.com/adminapi/oil-oss/obejct/uploadFile',
@@ -379,14 +424,11 @@
'token': utils.md5Salt(JSESSIONID)
},
success(e) {
console.log('进入2')
console.log(e)
let obj = JSON.parse(e.data),
imageUrl = obj.data.publicUrl
_that.getImage(imageUrl)
},
fail(err) {
console.log(err)
}
})
},fail() {
@@ -440,9 +482,15 @@
}else{
this.productDate.recommend == '2'
}
this.productDate.checkedList = this.checkedList
this.productDate.stockList = this.stockList
serve.saveProduct(this.productDate).then(res=>{
console.log(res)
uni.showToast({
title: res.msg,
icon: 'none'
})
this.closed()
})
}
}
@@ -524,6 +572,10 @@
line-height: 72rpx;
}
}
.content{
padding-bottom: 20rpx;
border-bottom: 1rpx solid #F6F6F6;
}
.tagButton{
display: inline-block;
width: 133rpx;