diff --git a/pages/shop/addGoods.vue b/pages/shop/addGoods.vue
index af22b32..a15bdc2 100644
--- a/pages/shop/addGoods.vue
+++ b/pages/shop/addGoods.vue
@@ -23,7 +23,7 @@
-
+
@@ -66,11 +66,17 @@
-
-
- {{value[0]}}(可选{{value[1].canbuy || 1}}个):
-
- {{item}}、
+
+
+
+ {{value[0]}}(可选{{value[1].canbuy || 1}}个)
+ x
+
+
+
+ {{item}}
+ x
+
@@ -254,9 +260,7 @@
this.getGategoryList()
if (option.dataList != undefined && option.dataList != null && option.dataList != 'undefined') {
this.dataList = JSON.parse(option.dataList)
- this.NB.sendRequest("/app/product/getById/" + this.dataList.id, {
-
- }, false, 'post', 'application/x-www-form-urlencoded').then((res) => {
+ this.NB.sendRequest("/app/product/getById/" + this.dataList.id, {}, false, 'post', 'application/x-www-form-urlencoded').then((res) => {
if (res.code == 200) {
this.modalType = 1
this.formData.id = res.result.id
@@ -432,6 +436,9 @@
submit() {
let that = this;
this.syncLunchBoxByMoreBuy()
+ if (!this.validateRequiredProductFields()) {
+ return
+ }
if (!this.validateProductSpecs()) {
return
}
@@ -481,6 +488,43 @@
// }
// });
},
+ validateRequiredProductFields() {
+ const productName = String(this.formData.productName || '').trim()
+ if (!productName) {
+ uni.showToast({
+ title: '请输入商品名称',
+ icon: 'none'
+ })
+ return false
+ }
+ if (!this.formData.productPicture) {
+ uni.showToast({
+ title: '请上传商品主图',
+ icon: 'none'
+ })
+ return false
+ }
+ for (let i = 0; i < this.formData.attributeListPrice.length; i++) {
+ const specPrice = String(this.formData.attributeListPrice[i].specPrice || '').trim()
+ if (!specPrice) {
+ uni.showToast({
+ title: '请输入商品价格',
+ icon: 'none'
+ })
+ return false
+ }
+ }
+ const startPayNum = String(this.formData.startPayNum || '').trim()
+ if (!startPayNum) {
+ uni.showToast({
+ title: '请输入起售数量',
+ icon: 'none'
+ })
+ return false
+ }
+ this.formData.productName = productName
+ return true
+ },
back() {
uni.navigateBack()
},
@@ -602,37 +646,82 @@
this.formData.sellEndTime = e.detail.value
}
},
+ confirmDeleteAttributeCategory(categoryName){
+ uni.showModal({
+ title: '提示',
+ content: '确定删除“' + categoryName + '”分类及其下所有属性吗?',
+ success: (res) => {
+ if(res.confirm){
+ this.removeAttributeCategory(categoryName)
+ }
+ }
+ })
+ },
+ confirmDeleteAttributeValue(categoryName, attributeTitle){
+ uni.showModal({
+ title: '提示',
+ content: '确定删除“' + attributeTitle + '”属性吗?',
+ success: (res) => {
+ if(res.confirm){
+ this.removeAttributeValue(categoryName, attributeTitle)
+ }
+ }
+ })
+ },
+ removeAttributeCategory(categoryName){
+ let attributeListMap = new Map(this.formData.attributeList1)
+ attributeListMap.delete(categoryName)
+ this.formData.attributeList1 = attributeListMap
+ this.attrValueArr = this.attrValueArr.filter(item => item.parentName != categoryName)
+ delete this.canbuyMap[categoryName]
+ this.$forceUpdate()
+ },
+ removeAttributeValue(categoryName, attributeTitle){
+ let attributeListMap = new Map(this.formData.attributeList1)
+ let attributeGroup = attributeListMap.get(categoryName)
+ if(!attributeGroup){
+ return
+ }
+ let nextTitle = (attributeGroup.title || []).filter(item => item != attributeTitle)
+ if(nextTitle.length == 0){
+ attributeListMap.delete(categoryName)
+ delete this.canbuyMap[categoryName]
+ }else{
+ attributeListMap.set(categoryName, Object.assign({}, attributeGroup, {
+ title: nextTitle
+ }))
+ }
+ this.formData.attributeList1 = attributeListMap
+ this.attrValueArr = this.attrValueArr.filter(item => !(item.parentName == categoryName && item.title == attributeTitle))
+ this.$forceUpdate()
+ },
guigeSubmit(){
if(this.modalclassType == 'shuxing'){
// 保存当前分类的canbuy值
if(this.typeToAttrName){
this.canbuyMap[this.typeToAttrName] = parseInt(this.currentCanbuy) || 1
}
+ let attributeListMap = new Map()
for(let i=0;i {
+ }, false, 'get', 'application/x-www-form-urlencoded').then((res) => {
if (res.code == 200) {
this.defaultList = res.result;
this.$refs.attrValueDialog.open();