From 16cc7fb9ff6277c5f78ee4db96ff74212f743d38 Mon Sep 17 00:00:00 2001 From: dt_2916866708 <> Date: Fri, 2 Feb 2024 10:55:47 +0800 Subject: [PATCH] 12121 --- src/views/product/productAdd/newIndex.vue | 115 +++++++++--------- .../productList/components/EditorStock.vue | 2 +- src/views/product/productList/index.vue | 4 +- 3 files changed, 63 insertions(+), 58 deletions(-) diff --git a/src/views/product/productAdd/newIndex.vue b/src/views/product/productAdd/newIndex.vue index 0f0e53a..3bf9a2b 100644 --- a/src/views/product/productAdd/newIndex.vue +++ b/src/views/product/productAdd/newIndex.vue @@ -21,7 +21,7 @@ - + - + @@ -45,7 +45,7 @@ - + @@ -57,12 +57,12 @@ - + - + @@ -76,9 +76,8 @@ --> - - +
@@ -555,29 +554,30 @@ export default { console.log(from.path) //从哪来 console.log(to.path, to.params) //到哪去 }, - 'formValidate.content': function(n) { - console.log(n, '++++++++++++++++++++++') - }, + 'formValidate.content': function(n) { }, ManyAttrValue(n) {}, 'formValidate.attr': { - handler: function(val) { - if (this.isAttr) this.watCh(val) //重要!!! + handler: function(val,o) { + if (this.isAttr) this.watCh(val,o) //重要!!! }, immediate: false, deep: true } }, - created() { - this.chenkId() - this.getCategorySelect() - this.productGetRule() - this.brandGetAll() + async created() { + await this.chenkId() + await this.getCategorySelect() + await this.productGetRule() + await this.brandGetAll() }, mounted() {}, + deactivated() { + this.$destroy(); + }, methods: { - chenkId() { - if (this.$route.params && this.$route.params.id) { - this.getproductInfo(this.$route.params.id) + async chenkId() { + if (this.$route.query && this.$route.query.id) { + await this.getproductInfo(this.$route.query.id) } }, productAddGetSites(ids) { @@ -590,19 +590,23 @@ export default { }) }, async inverseAnalysis(data) { - let { categoryOneId, categoryTwoId } = data - let categorys = [categoryOneId, categoryTwoId] - this.OilStationSelectionList = data.siteInfos - Object.assign(this.formValidate, { + let { categoryOneId, categoryTwoId } = data; + let categorys = [categoryOneId, categoryTwoId]; + this.OilStationSelectionList = data.siteInfos; + this.formValidate = { + ...this.formValidate, categorys, ...data - }) + } + // Object.assign(this.formValidate, { + // categorys, + // ...data + // }) this.$refs.CustomUpload.fileList = [...this.formValidate.images.filter(item => item.mainMark == '1')] this.$refs.CustomLBUpload.fileList = [...this.formValidate.images.filter(item => item.mainMark != '1')] await this.confirm() this.$nextTick(() => { - this.formValidate.attr = this.formValidate.attr - .map(item => { + this.formValidate.attr = this.formValidate.attr.map(item => { let align = this.formValidate.checkedList.find(i => item.id == i.attributeId) if (align) { return { @@ -615,22 +619,24 @@ export default { } else { return null } - }) - .filter(item => item) + }).filter(item => item); setTimeout(() => { this.ManyAttrValue.forEach((item, index) => { - let data = this.formValidate.stockList.find(i => i.attributeJson == JSON.stringify(item.data)) + let data = this.formValidate.stockList.find(i => i.attributeJson == JSON.stringify(item.data)); if (data) { - Object.assign(item, data) + Object.assign(item, data,{delect:false}) + }else{ + Object.assign(item, data,{delect:true}) } }) + this.ManyAttrValue = this.ManyAttrValue.filter(item=>!item.delect) }, 1000) }) }, - getproductInfo(id) { - productApi.productAddGetEdit(id).then(res => { + async getproductInfo(id) { + await productApi.productAddGetEdit(id).then( async res => { if (res.code == 20000) { - this.inverseAnalysis(res.data) + await this.inverseAnalysis(res.data) } }) }, @@ -645,8 +651,8 @@ export default { this.isOilStationSelection = false this.formValidate.siteIds = e.map(item => item.siteId) }, - brandGetAll() { - productApi.brandGetAll().then(res => { + async brandGetAll() { + await productApi.brandGetAll().then(res => { if (res.code == 20000) { this.brandOptions = res.data } @@ -709,7 +715,7 @@ export default { }, setTagsViewTitle() { const title = this.isDisabled ? '商品详情' : '编辑商品' - const route = Object.assign({}, this.tempRoute, { title: `${title}-${this.$route.params.id}` }) + const route = Object.assign({}, this.tempRoute, { title: `${title}-${this.$route.query.id}` }) this.$store.dispatch('tagsView/updateVisitedView', route) }, onChangeGroup() { @@ -720,7 +726,7 @@ export default { this.checkboxGroup.includes('isHot') ? (this.formValidate.isHot = true) : (this.formValidate.isHot = false) }, // sku算法 - watCh(val) { + watCh(val,o) { let arr = [] this.manyTabDate = [] for (let i = 0; i < val.length; i++) { @@ -747,7 +753,8 @@ export default { return res }, [{}] - ) + ); + console.log(this.ManyAttrValue ,"this.ManyAttrValue ") }, attrFormat(arr) { let data = [] @@ -852,8 +859,8 @@ export default { } }, // 商品分类; - getCategorySelect() { - productApi.getClassificationTree().then(res => { + async getCategorySelect() { + await productApi.getClassificationTree().then(res => { if (res.code == 20000) { this.merCateList = res.data } @@ -961,6 +968,7 @@ export default { } else { item.splice(index, 1) } + }, // 添加规则名称 createAttrName() { @@ -1012,7 +1020,7 @@ export default { // 详情 getInfo() { this.fullscreenLoading = true - productDetailApi(this.$route.params.id) + productDetailApi(this.$route.query.id) .then(async res => { // this.isAttr = true; let info = res @@ -1172,6 +1180,7 @@ export default { if (this.currentTab-- < 0) this.currentTab = 0 }, handleSubmitNest(name) { + console.log(this.formValidate,"handleSubmitNest") this.$refs[name].validate(valid => { if (valid) { if (this.currentTab++ > 2) this.currentTab = 0 @@ -1198,7 +1207,10 @@ export default { let [categoryOneId, categoryTwoId] = this.formValidate.categorys let isRecommendOrNewMark = this.formValidate.recommendOrNewMark == '1' ? 'newMark' : 'recommend' let siteIds = this.OilStationSelectionList.map(item => item.siteId) - + if(siteIds.length==0){ + this.$message.error('请选择油站') + return + } let checkedList = this.formValidate.attr.map(item => { let attributeId = item.id let checked = item.sku.value.join(',') @@ -1223,19 +1235,12 @@ export default { skuNum, id } - }) - console.log(this.formValidate, 'formValidate') - console.log(categoryOneId, categoryTwoId, 'categoryOneId categoryTwoId') - console.log(isRecommendOrNewMark, 'isRecommendOrNewMark') - console.log(siteIds, 'siteIds') - console.log(checkedList, 'checkedList') - console.log(images, 'images') - console.log(stockList, 'stockList') + }) this.formValidate[isRecommendOrNewMark] = '1' loadingFn.call( this, 'loading', - productApi[this.$route.params.id ? 'addUpdate' : 'addSave']( + productApi[this.$route.query.id ? 'addUpdate' : 'addSave']( Object.assign(this.formValidate, { categoryOneId, categoryTwoId, @@ -1249,7 +1254,7 @@ export default { this.$message.success('操作成功') setTimeout(() => { this.$router.push({ path: 'productList' }) - this.$destroy() + // this.$destroy() }, 1000) } }) diff --git a/src/views/product/productList/components/EditorStock.vue b/src/views/product/productList/components/EditorStock.vue index 83c2076..3aacbcf 100644 --- a/src/views/product/productList/components/EditorStock.vue +++ b/src/views/product/productList/components/EditorStock.vue @@ -21,7 +21,7 @@ diff --git a/src/views/product/productList/index.vue b/src/views/product/productList/index.vue index ceaa962..ed2e9f3 100644 --- a/src/views/product/productList/index.vue +++ b/src/views/product/productList/index.vue @@ -697,8 +697,8 @@ export default { edit(row) { console.log(row) this.$router.push({ - name: 'productAdd', - params: { + path: '/product/productAdd', + query: { id: row.id } })