电子结算单

This commit is contained in:
2024-04-16 17:16:00 +08:00
parent a0b52f8a4c
commit dfbafd8ea8
11 changed files with 1171 additions and 207 deletions

View File

@@ -51,12 +51,12 @@
<view id="instruction" :class="currentBoxId == 'instruction' ? 'show' : 'hidden'">
<uni-forms :modelValue="productDate" label-width="200rpx">
<uni-forms-item label="属性类别:">
<uni-forms-item label="选择规格:">
<uni-data-select v-model="productDate.attributesTypeId" :localdata="attributesTypeList"
placeholder="请选择商品品牌" @change="attributesData"></uni-data-select>
placeholder="请选择规格" @change="attributesData"></uni-data-select>
</uni-forms-item>
<view class="content" v-show="productDate.attributesTypeId">
<view style="margin: 10rpx 0;">商品类型</view>
<view style="margin: 10rpx 0;">商品规格</view>
<view>
<uni-section type="line">
<view class="uni-px-5" v-for="(item,index) in attributesList">
@@ -170,6 +170,7 @@
isBoxShow: false,
productDate: {
productStatus: '1',
newMark: 1,
images: []
},
productList: [],
@@ -268,16 +269,18 @@
checkbox(e) {
var index = e; //获取当前点击的下标
var checkboxArr = this.radioItem; //选项集合
// if (checkboxArr[index].checked) return;//如果点击的当前已选中则返回
// checkboxArr.forEach(item => {
// item.checked = false
// })
if (checkboxArr[index].checked == false) {
checkboxArr[index].checked = true; //改变当前选中的checked值
if (checkboxArr[index].checked) return; //如果点击的当前已选中则返回
checkboxArr.forEach(item => {
item.checked = false
})
checkboxArr[index].checked = true; //改变当前选中的checked值
} else {
checkboxArr[index].checked = false; //改变当前选中的checked值
}
// if (checkboxArr[index].checked == false) {
// checkboxArr[index].checked = true; //改变当前选中的checked值
// } else {
// checkboxArr[index].checked = false; //改变当前选中的checked值
// }
if (checkboxArr[0].checked == true) {
this.productDate.newMark = 1
} else {
@@ -294,6 +297,13 @@
let currentFlag = e.currentTarget.id;
if (currentFlag == 'next') {
this.$refs.productForm.validate().then(res => {
if (this.isNumber(this.productDate.price) == false) {
uni.showToast({
title: '商品售价不是数字',
icon: 'none'
})
return
}
switch (currentFlag) {
case 'next':
this.currentBoxId = 'instruction'
@@ -383,7 +393,7 @@
if (this.checkedList.length < index + 1) {
this.checkedList.push({
attributeId: item.id,
checked: this.radioAttributes
checked: item.attributesList[index].value
})
} else {
let checked = []
@@ -456,7 +466,7 @@
let _that = this
let imageUrl = ''
uni.chooseImage({
count: 10, //默认9
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: function(res) {
@@ -493,17 +503,25 @@
})
},
getImage(imageUrl) {
if (JSON.stringify(this.productDate.images) == '[]') {
this.productDate.images.push({
url: imageUrl,
mainMark: 1
})
if (this.productDate.images.length < 10) {
if (JSON.stringify(this.productDate.images) == '[]') {
this.productDate.images.push({
url: imageUrl,
mainMark: 1
})
} else {
this.productDate.images.push({
url: imageUrl,
mainMark: ''
})
}
} else {
this.productDate.images.push({
url: imageUrl,
mainMark: ''
uni.showToast({
title: '最多只能上传十张图片~',
icon: 'none'
})
}
},
setMainImage(items, index) {
let obj = items
@@ -528,6 +546,9 @@
url: '/pages/index/index'
})
},
isNumber(value) {
return /^[0-9]+$/.test(value);
},
addCompleted() {
if (this.radioItem[0].checked = true) {
this.productDate.newMark == '1'
@@ -539,6 +560,109 @@
} else {
this.productDate.recommend == '2'
}
if (!this.productDate.attributesTypeId) {
uni.showToast({
title: '请选择请选择规格',
icon: 'none'
})
return
}
if(this.attributesList.length==1){
if(!this.radioAttributes){
uni.showToast({
title: '请选择商品规格',
icon: 'none'
})
return
}
}
if(this.attributesList.length>1){
if(JSON.stringify(this.checkboxAttributes) == '[]'){
uni.showToast({
title: '请选择商品规格',
icon: 'none'
})
return
}
}
if (JSON.stringify(this.stockList.length) == '[]') {
uni.showToast({
title: '请选择商品规格',
icon: 'none'
})
return
} else {
this.stockList.forEach(tab => {
if (!tab.marketPrice) {
uni.showToast({
title: '市场价格必填!',
icon: 'none'
})
throw Error(`市场价格必填!`)
} else {
if (this.isNumber(tab.marketPrice) == false) {
uni.showToast({
title: '市场价格不是数字!',
icon: 'none'
})
throw Error(`市场价格不是数字!`)
}
}
if (!tab.sellPrice) {
uni.showToast({
title: '销售价格必填!',
icon: 'none'
})
throw Error(`销售价格必填!`)
} else {
if (this.isNumber(tab.sellPrice) == false) {
uni.showToast({
title: '销售价格不是数字!',
icon: 'none'
})
throw Error(`销售价格不是数字!`)
}
}
if (!tab.stock) {
uni.showToast({
title: '库存数量必填!',
icon: 'none'
})
throw Error(`库存数量必填!`)
} else {
if (this.isNumber(tab.stock) == false) {
uni.showToast({
title: '库存数量不是数字!',
icon: 'none'
})
throw Error(`库存数量不是数字!`)
}
}
if (!tab.integral) {
uni.showToast({
title: '积分价值必填!',
icon: 'none'
})
throw Error(`积分价值必填!`)
} else {
if (this.isNumber(tab.integral) == false) {
uni.showToast({
title: '积分价值不是数字!',
icon: 'none'
})
throw Error(`积分价值不是数字!`)
}
}
})
}
if (JSON.stringify(this.productDate.images) == '[]') {
uni.showToast({
title: '请上传商品图片',
icon: 'none'
})
return
}
this.productDate.checkedList = this.checkedList
this.productDate.stockList = this.stockList
serve.saveProduct(this.productDate).then(res => {