diff --git a/package1/myCenter/addGoods.vue b/package1/myCenter/addGoods.vue index def224b..d41d4ac 100644 --- a/package1/myCenter/addGoods.vue +++ b/package1/myCenter/addGoods.vue @@ -171,6 +171,7 @@ formData: { id: '', shopId: '', + attrId:'', categoryId: '', //商品分类id categoryName: '', //商品分类名称 productPicture: '', //商品图标 @@ -212,6 +213,7 @@ }, onShow() { + this.attrId = uni.getStorageSync('attrId'); this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() uni.authorize({ scope: 'scope.writePhotosAlbum', @@ -230,7 +232,7 @@ }, onLoad(option) { this.getGategoryList() - if (option.dataList) { + if (option.dataList != undefined && option.dataList != null && option.dataList != 'undefined') { this.dataList = JSON.parse(option.dataList) this.tui.request("/app/product/getById/" + this.dataList.id, "POST", { @@ -640,73 +642,69 @@ }) }, checkSpec(type){ + let that = this this.$refs.addTypeDialog.open() this.modalclassType = type - this.tui.request("/dictData/getByCondition", "GET", { - name: "", - status: "", - pageNumber: 1, - pageSize: 100000, - sort: 'sortOrder', - order: 'asc', - dictId: '2026945661353725952' - }, false, true).then((res) => { - if(res.code == 200){ - this.categoryData = res.result.content - for (var i = 0; i < this.categoryData.length; i++) { - if (i == this.categoryIndex) { - this.categoryData[i].parentId = true + that.tui.request("/app/productAttribute/selectByCategoryId", "post", {categoryId:that.attrId}, false, true).then((res) => { + if (res.code == 200) { + that.categoryData = res.result + for (var i = 0; i < that.categoryData.length; i++) { + that.categoryData[i].title = that.categoryData[i].attributeName + if (i == that.categoryIndex) { + that.categoryData[i].parentId = true } else { - this.categoryData[i].parentId = false + that.categoryData[i].parentId = false } } //如果是选择属性,需要拿一个分类名,保存成parent - this.typeToAttrName = res.result.content[this.categoryIndex].title + that.typeToAttrName = res.result[that.categoryIndex].title // 恢复该分类之前设置的canbuy值 - this.currentCanbuy = this.canbuyMap[this.typeToAttrName] || 1 - this.getCateGorySon(res.result.content[this.categoryIndex].id) + that.currentCanbuy = that.canbuyMap[that.typeToAttrName] || 1 + that.getCateGorySon(res.result[that.categoryIndex].id) + } else { + this.tui.toast(res.message) } - }).catch(() => {}); + }).catch((res) => {}) }, getCateGorySon(id){ - this.tui.request("/dictData/getByCondition", "GET", { - name: "", - status: "", - pageNumber: 1, - pageSize: 100000, - sort: 'sortOrder', - order: 'asc', - dictId: id + let that = this + that.tui.request("/app/productAttributeValue/selectByAttributeId", "get", { + id: id, }, false, true).then((res) => { - if(res.code == 200){ - this.categorySonData = res.result.content - // 先给所有子项初始化checked为false,确保Vue响应性 - console.log("111111",this.specValueArr) - console.log("22222",this.attrValueArr) - for (var i = 0; i < this.categorySonData.length; i++) { - this.$set(this.categorySonData[i], 'checked', false) + if (res.code == 200) { + that.categorySonData = res.result + for (var i = 0; i < that.categorySonData.length; i++) { + that.categorySonData[i].title = that.categorySonData[i].value + that.$set(that.categorySonData[i], 'checked', false) } - if(this.modalclassType == 'shuxing'){ - for (var i = 0; i < this.categorySonData.length; i++) { - for (var m = 0; m < this.attrValueArr.length; m++) { - if(this.attrValueArr[m].title == this.categorySonData[i].title && this.attrValueArr[m].parentName == this.typeToAttrName){ - this.$set(this.categorySonData[i], 'checked', true) + if(that.modalclassType == 'shuxing'){ + for (var i = 0; i < that.categorySonData.length; i++) { + for (var m = 0; m < that.attrValueArr.length; m++) { + if(that.attrValueArr[m].title == that.categorySonData[i].title && that.attrValueArr[m].parentName == that.typeToAttrName){ + that.$set(that.categorySonData[i], 'checked', true) } } } }else{ //guige - for (var i = 0; i < this.categorySonData.length; i++) { - for (var m = 0; m < this.specValueArr.length; m++) { - if(this.specValueArr[m].id == this.categorySonData[i].id){ - this.$set(this.categorySonData[i], 'checked', true) + for (var i = 0; i < that.categorySonData.length; i++) { + for (var m = 0; m < that.specValueArr.length; m++) { + if(that.specValueArr[m].id == that.categorySonData[i].id){ + that.$set(that.categorySonData[i], 'checked', true) } } } } - this.$forceUpdate() + console.log() + that.$forceUpdate(that.categorySonData) + that.$forceUpdate(that.categoryData) + } else { + uni.showToast({ + title: "删除失败", + icon: 'none' + }) } - }).catch(() => {}); + }).catch((res) => {}) }, deldantiaoguige(index){ for (var m = 0; m < this.specValueArr.length; m++) { diff --git a/package1/myCenter/attributeList.vue b/package1/myCenter/attributeList.vue index 3566024..9190021 100644 --- a/package1/myCenter/attributeList.vue +++ b/package1/myCenter/attributeList.vue @@ -6,69 +6,79 @@ - 代买饭 + 规格管理 - + - - - - - 编辑分类 - - - 请在下方输入框中输入分类名 - - - 分类名称: - - - - 排序: + + + + + 编辑规格 + - - 删除 - 确认 + + + 规格名称: + + + + 删除 + 确认 + + - + - 新增分类 + 新增规格 - *您可以点击默认项快捷添加分类,如没有想要的快捷项,可以手动输入 + *您可以点击默认项快捷添加规格,如没有想要的快捷项,可以手动输入 - -
    + placeholder="请输入规格名称"> + 确认 + + + + + 管理属性 + + + + + *您可以点击默认项快捷添加属性,如没有想要的快捷项,可以手动输入 + + +
      +
    • + + {{item.value}} + 修改 + 删除 + +
    • +
    +
    +
    +
    + 提示 - “{{goodsList[0].productName}}”分类下有以下库存,确认继续删除吗? + “{{goodsList[0].productName}}”规格下有以下库存,确认继续删除吗? @@ -124,8 +161,14 @@ - + @@ -148,7 +191,7 @@ isOpenId: '', delType: '', goodsList: [], - dialogTit: '输入分类名', + dialogTit: '输入规格名', typeText:'', sortText:'', sortTextEdit:'', @@ -279,6 +322,9 @@ checked:false }] }], + attrId:'', + valueEditId:'', + isEdieValue:false, multipleList:[] } }, @@ -298,21 +344,34 @@ } }, onShow() { + this.attrId = uni.getStorageSync('attrId'); this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() this.getGategoryList() }, methods: { - //初始化获取分类列表 - getGategoryList() { - this.tui.request("/dictData/getByCondition", "get", { - name: "", - status: "", - pageNumber: 1, - pageSize: 100000, - sort: sortOrder, - order: asc, - dictId: 2026945661353725952 + editValue(item){ + this.isEdieValue = true + this.valueEditId = item.id + this.specVal = item.value + this.$refs.addDialog.open() + }, + delValue(item){ + this.tui.request("/app/productAttributeValue/delById", "post", { + id: item.id }, false, true).then((res) => { + if (res.code == 200) { + this.tui.toast("删除成功") + this.goGategoryLow(this.editItem) + this.$forceUpdate() + } else { + this.tui.toast("添加失败") + } + + }).catch((res) => {}) + }, + //初始化获取规格列表 + getGategoryList() { + this.tui.request("/app/productAttribute/selectByCategoryId", "post", {categoryId:this.attrId}, false, true).then((res) => { if (res.code == 200) { this.indexList = res.result; } else { @@ -324,14 +383,13 @@ inputDialogToggle(type, item, parent) { this.typeModel = type; if (type == 'edit') { - this.inputVal = item.categoryName; + this.inputVal = item.attributeName; this.editItem = item; - this.sortTextEdit = (this.editItem.sort == null || this.editItem.sort == 'null') ? '' : this.editItem.sort this.$refs.delDialog.open('bottom') } else if (type == 'add') { this.inputVal = ''; this.isOpenId = item; - this.dialogTit = '输入分类名' + this.dialogTit = '输入规格名' this.$refs.addTypeDialog.open('bottom') } @@ -345,7 +403,7 @@ handleBlurSort(e){ this.sortTextEdit = e.detail.value }, - //查询分类下有没有库存 + //查询规格下有没有库存 getTypeToNum(id) { let that = this; this.tui.request("/app/stock/getlistByAttributeList", "post", { @@ -363,7 +421,7 @@ if (res1.result.length > 0) { uni.showModal({ title: "提示", - content: "此分类已经维护了子分类,确定继续删除吗?", + content: "此规格已经维护了子规格,确定继续删除吗?", success: function(res2) { if (res2.confirm) { that.delItemModal() @@ -391,26 +449,50 @@ back() { uni.navigateBack() }, - toggle(index){ - this.addIndex = index + toggle(){ + this.specVal = '' + this.isEdieValue = false this.$refs.addDialog.open() }, addSpec(e){ - - let data = { - value:e, - checked:false + let that = this; + if(this.isEdieValue){ + that.tui.request("/app/productAttributeValue/edit", "post", { + id: that.valueEditId, + value:e + }, false, true).then((res) => { + if (res.code == 200) { + that.tui.toast("修改成功") + that.goGategoryLow(that.editItem) + that.$forceUpdate() + } else { + that.tui.toast("添加失败") + } + + }).catch((res) => {}) + }else{ + that.tui.request("/app/productAttributeValue/save", "post", { + attributeId: that.editItem.id, + value:e + }, false, true).then((res) => { + if (res.code == 200) { + that.tui.toast("添加成功") + that.goGategoryLow(that.editItem) + that.$forceUpdate() + } else { + that.tui.toast("添加失败") + } + + }).catch((res) => {}) } - this.defaultList[this.addIndex].list.push(data) - this.$refs.addClose.val = '' }, - //分类编辑(新增,修改) + //规格编辑(新增,修改) dialogInputConfirm(e) { let that = this; switch (that.typeModel) { case 'add': for (let i = 0; i < that.indexList.length; i++) { - if (that.indexList[i].categoryName == e) { + if (that.indexList[i].attributeName == e) { uni.showToast({ title: "请勿重复添加!", icon: 'error' @@ -419,72 +501,16 @@ } } if(e == ''){ - that.tui.toast("请输入分类名") + that.tui.toast("请输入规格名") return } - if(e != '' && that.multipleList == ''){ - that.multipleList = [{ - attributeName:'颜色', - productAttributeValueVoList:[{ - checked: true, - value: "均色" - }] - },{ - attributeName:'尺码', - productAttributeValueVoList:[{ - checked: true, - value: "均码" - }] - }] - }else if(e != '' && that.multipleList != ''){ - for(let i=0;i { + that.tui.request("/app/productAttribute/save", "post", { + categoryId: that.attrId, + attributeName:e + }, false, true).then((res) => { if (res.code == 200) { that.tui.toast("添加成功") that.$refs.addTypeDialog.close() - that.sortText = '' - that.getGategoryList() } else { that.tui.toast("添加失败") @@ -492,18 +518,17 @@ }).catch((res) => {}) // that.$refs.addTypeDialog.val = '' - for(var i=0;i { if (res.code == 200) { @@ -537,7 +562,24 @@ }, //带删除按钮的弹窗 dialogDel() { - this.delItem(this.editItem, 'del') + this.tui.request("/app/productAttribute/delById", "post", { + id: this.editItem.id, + }, false, true).then((res) => { + if (res.code == 200) { + this.getGategoryList() + uni.showToast({ + title: "删除成功", + icon: 'none' + }) + this.$refs.carPopup.close() + this.$refs.delDialog.close() + } else { + uni.showToast({ + title: "删除失败", + icon: 'none' + }) + } + }).catch((res) => {}) }, delItemModal() { this.show = false; @@ -568,11 +610,23 @@ this.delItems = item; this.getTypeToNum(this.delItems.id) }, - //跳转子分类页 - goGategoryLow(id) { - uni.navigateTo({ - url: '/package1/inventory/gategoryLow?id=' + id - }) + //跳转子规格页 + goGategoryLow(item) { + this.editItem = item + this.tui.request("/app/productAttributeValue/selectByAttributeId", "get", { + id: item.id, + }, false, true).then((res) => { + if (res.code == 200) { + this.defaultList = res.result; + this.$refs.attrValueDialog.open(); + } else { + uni.showToast({ + title: "删除失败", + icon: 'none' + }) + } + }).catch((res) => {}) + }, //选择多个规格保存 addMultipleType(item,item1,index){ @@ -590,7 +644,7 @@ this.multipleList.push(data) }else{ for(var i=0;i