From 2796a734f6d3e6c6838e52bed5a6281318a3c1fa Mon Sep 17 00:00:00 2001 From: zhangyouji Date: Wed, 17 Apr 2024 15:18:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=95=86=E5=9F=8E=E5=8D=95?= =?UTF-8?q?=E9=80=89=E6=94=B9=E5=A4=9A=E9=80=89=EF=BC=8C=E7=94=B5=E5=AD=90?= =?UTF-8?q?=E5=AF=B9=E8=B4=A6=E5=8D=95=E9=99=90=E5=88=B6=E5=88=B0=E6=B2=B9?= =?UTF-8?q?=E7=AB=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packageElectron/index.vue | 14 +- packageIntegral/productAddition/index.vue | 166 +++++++++----------- packageIntegral/productUpdate/index.vue | 175 +++++++++------------- 3 files changed, 148 insertions(+), 207 deletions(-) diff --git a/packageElectron/index.vue b/packageElectron/index.vue index e991e75..3803aac 100644 --- a/packageElectron/index.vue +++ b/packageElectron/index.vue @@ -48,7 +48,9 @@ paramter: { currentPage: 1, pagesize: 20, - params: {}, + params: { + siteId: uni.getStorageSync('oilSitePriceId') + }, }, dataList: [], optionsList: [{ @@ -63,7 +65,7 @@ }, { text: '金额异常', value: '' - }], + }] } @@ -77,22 +79,22 @@ selectOptions(index) { this.currentIndex = index this.paramter.currentPage = 1 + this.paramter.params ={ + siteId: uni.getStorageSync('oilSitePriceId') + } if(index == 0){ - this.paramter.params ={} this.paramter.params.status = '5' }else if(index ==1){ - this.paramter.params ={} this.paramter.params.status = '1' }else if(index ==2){ - this.paramter.params ={} this.paramter.params.status = '2' }else if(index ==3){ - this.paramter.params ={} this.paramter.params.status = '3' } this.getByPage() }, getByPage(){ + // this.parameter.params.siteId = this.siteId serve.getByPage(this.paramter).then(res=>{ if (res.code === 20000) { if (!res.data.list.length&&this.paramter.currentPage!=1) { diff --git a/packageIntegral/productAddition/index.vue b/packageIntegral/productAddition/index.vue index 7df9313..dc32b42 100644 --- a/packageIntegral/productAddition/index.vue +++ b/packageIntegral/productAddition/index.vue @@ -62,10 +62,8 @@ {{item.attributeName}}: - - @@ -95,9 +93,10 @@ * 规格: - {{radioAttributes}} - {{radioAttributes}}+{{checkboxAttributes[index]}} + + {{value}} + + {{value}} + @@ -139,10 +138,6 @@ - 上一步 @@ -216,8 +211,7 @@ stock: '', integral: '' }], - radioAttributes: '', - checkboxAttributes: [], + stockList: [], checkedList: [] } @@ -275,12 +269,6 @@ }) checkboxArr[index].checked = true; //改变当前选中的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 { @@ -355,14 +343,13 @@ integral: '' }] this.stockList = [] - this.radioAttributes = '' - this.checkboxAttributes = [] if (this.productDate.attributesTypeId) { this.attributesTypeList.forEach(tab => { if (tab.value == this.productDate.attributesTypeId) { this.attributesList = tab.attributesList this.attributesList.forEach(tab => { tab.attributesList = [] + tab.checkboxAttributes=[] tab.attributeContent.split(',').forEach(item => { tab.attributesList.push({ value: item, @@ -378,34 +365,53 @@ } }, - changeRadio(item, index) { - if (JSON.stringify(this.checkedList) == '[]') { - this.checkedList.push({ - attributeId: item.id, - checked: this.radioAttributes - }) - } else { - this.checkedList[index].checked = this.radioAttributes - } - this.stockCheck() - }, changeCheckBox(item, index) { if (this.checkedList.length < index + 1) { this.checkedList.push({ attributeId: item.id, - checked: item.attributesList[index].value + checked: item.checkboxAttributes[index] }) } else { let checked = [] - this.checkboxAttributes.forEach(tab => { + item.checkboxAttributes.forEach(tab => { checked.push(tab) }) this.checkedList[index].checked = checked.join(',') - this.checkedList.checked } - this.stockCheck() + let arrays = [] + this.attributesList.forEach(tab=>{ + arrays.push(tab.checkboxAttributes) + }) + let arrList = this.combineArrays(arrays) + this.stockCheck(arrList) }, - stockCheck() { + combineArrays(arr) { + if (arr.length === 0) { + return []; + } else if (arr.length === 1) { + return arr[0]; + } else if (arr.length === 2 && JSON.stringify(arr[1])=='[]') { + let result = []; + arr[0].forEach(tab=>{ + result.push([tab]) + }) + return result; + } else { + let result = []; + let subCombinations = this.combineArrays(arr.slice(1)); + for (let elem of arr[0]) { + if (Array.isArray(subCombinations)) { + for (let subComb of subCombinations) { + result.push([elem].concat(subComb)); + } + } else { + result.push([elem, subCombinations]); + } + } + return result; + } + }, + stockCheck(arrList) { this.stockList = [] let obj = { marketPrice: '', @@ -413,46 +419,23 @@ stock: '', integral: '' } - if (this.attributesList.length == 1) { + arrList.forEach(tab=>{ let data = {} - let name = this.attributesList[0].attributeName - let value = this.radioAttributes - data[name] = value - obj.attributeJson = JSON.stringify(data) - this.stockList.push(obj) - } else { - this.attributesList.forEach((item, ind) => { - if (ind != 0) { - this.checkboxAttributes.forEach((tab, index) => { - let data = {} - let tabName = this.attributesList[ind].attributeName - let tabValue = tab - data[tabName] = tabValue - obj.attributeJson = JSON.stringify(data) - let stockObj = JSON.parse(JSON.stringify(obj)) - this.stockList.push(stockObj) - }) - } + let tabName = '' + let tabValue = '' + tab.forEach((item,i)=>{ + tabName = this.attributesList[i].attributeName + tabValue = item + data[tabName] = tabValue }) - - - } + obj.attributeJson = JSON.stringify(data) + let stockObj = JSON.parse(JSON.stringify(obj)) + this.stockList.push(stockObj) + }) }, deleteCheckAll(i) { - if (this.checkboxAttributes.length > 1) { - this.checkboxAttributes.splice(i, 1) - } else { - this.checkboxAttributes.splice(i, 1) - this.radioAttributes = '' - } this.stockList.splice(i, 1) }, - deleteRadio() { - this.radioAttributes = '' - }, - changeChecked(item) { - item.checked = !item.checked - }, addStockList() { this.stockList.forEach(tab => { tab.marketPrice = this.bottonList[0].marketPrice @@ -550,16 +533,16 @@ return /^[0-9]+$/.test(value); }, addCompleted() { - if (this.radioItem[0].checked = true) { - this.productDate.newMark == '1' - } else { - this.productDate.newMark == '2' - } - if (this.radioItem[1].checked = true) { - this.productDate.recommend == '1' - } else { - this.productDate.recommend == '2' - } + if (this.radioItem[0].checked = true) { + this.productDate.newMark == 1 + } else { + this.productDate.newMark == 2 + } + if (this.radioItem[1].checked = true) { + this.productDate.recommend == 1 + } else { + this.productDate.recommend == 2 + } if (!this.productDate.attributesTypeId) { uni.showToast({ title: '请选择请选择规格', @@ -567,26 +550,17 @@ }) return } - if(this.attributesList.length==1){ - if(!this.radioAttributes){ + this.attributesList.forEach(tab=>{ + if(JSON.stringify(tab.checkboxAttributes) == '[]'){ uni.showToast({ title: '请选择商品规格', icon: 'none' }) - return + throw Error(`请选择商品规格!`) } - } - if(this.attributesList.length>1){ - if(JSON.stringify(this.checkboxAttributes) == '[]'){ - uni.showToast({ - title: '请选择商品规格', - icon: 'none' - }) - return - } - } + }) if (JSON.stringify(this.stockList.length) == '[]') { - uni.showToast({ + uni.showToast({ title: '请选择商品规格', icon: 'none' }) @@ -926,4 +900,4 @@ .hidden { display: none; } - \ No newline at end of file + diff --git a/packageIntegral/productUpdate/index.vue b/packageIntegral/productUpdate/index.vue index 6ad39e6..19421c4 100644 --- a/packageIntegral/productUpdate/index.vue +++ b/packageIntegral/productUpdate/index.vue @@ -62,10 +62,8 @@ {{item.attributeName}}: - - @@ -98,9 +96,10 @@ * 规格: - {{radioAttributes}} - {{radioAttributes}}+{{checkboxAttributes[index]}} + + {{value}} + + {{value}} + @@ -142,10 +141,6 @@ - 上一步 @@ -218,8 +213,7 @@ stock: '', integral: '' }], - radioAttributes: '', - checkboxAttributes: [], + stockList: [], checkedList: [] } @@ -260,11 +254,12 @@ } else { this.radioItem[1].checked = false } - this.attributesTypeList.forEach(tab => { - if (tab.value == this.productDate.attributesTypeId) { - this.attributesList = tab.attributesList + this.attributesTypeList.forEach(tabs => { + if (tabs.value == this.productDate.attributesTypeId) { + this.attributesList = tabs.attributesList this.attributesList.forEach(tab => { tab.attributesList = [] + tab.checkboxAttributes = [] tab.attributeContent.split(',').forEach(item => { tab.attributesList.push({ value: item, @@ -275,21 +270,9 @@ } }) this.checkedList = this.productDate.checkedList - if (this.productDate.checkedList.length == 1) { - this.radioAttributes = this.productDate.checkedList[0].checked - } else { - this.checkboxAttributes = [] - this.productDate.checkedList.forEach((tab, index) => { - if (index == 0) { - this.radioAttributes = this.productDate.checkedList[0].checked - } else { - tab.checked.split(',').forEach(item => { - this.checkboxAttributes.push(item) - }) - - } - }) - } + this.productDate.checkedList.forEach((tab, index) => { + this.attributesList[index].checkboxAttributes = tab.checked.split(',') + }) this.stockList = this.productDate.stockList @@ -329,12 +312,6 @@ }) checkboxArr[index].checked = true; //改变当前选中的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 { @@ -409,14 +386,13 @@ integral: '' }] this.stockList = [] - this.radioAttributes = '' - this.checkboxAttributes = [] if (this.productDate.attributesTypeId) { this.attributesTypeList.forEach(tab => { if (tab.value == this.productDate.attributesTypeId) { this.attributesList = tab.attributesList this.attributesList.forEach(tab => { tab.attributesList = [] + tab.checkboxAttributes = [] tab.attributeContent.split(',').forEach(item => { tab.attributesList.push({ value: item, @@ -431,37 +407,55 @@ this.attributesList = [] } - }, - changeRadio(item, index) { - if (JSON.stringify(this.checkedList) == '[]') { - this.checkedList.push({ - attributeId: item.id, - checked: this.radioAttributes - }) - } else { - this.checkedList[index].checked = this.radioAttributes - } - this.stockCheck() - }, changeCheckBox(item, index) { if (this.checkedList.length < index + 1) { this.checkedList.push({ attributeId: item.id, - checked: item.attributesList[index].value + checked: item.checkboxAttributes[index] }) } else { let checked = [] - this.checkboxAttributes.forEach(tab => { + item.checkboxAttributes.forEach(tab => { checked.push(tab) }) this.checkedList[index].checked = checked.join(',') - this.checkedList.checked } - this.stockCheck() + let arrays = [] + this.attributesList.forEach(tab => { + arrays.push(tab.checkboxAttributes) + }) + let arrList = this.combineArrays(arrays) + this.stockCheck(arrList) }, - stockCheck() { + combineArrays(arr) { + if (arr.length === 0) { + return []; + } else if (arr.length === 1) { + return arr[0]; + } else if (arr.length === 2 && JSON.stringify(arr[1]) == '[]') { + let result = []; + arr[0].forEach(tab => { + result.push([tab]) + }) + return result; + } else { + let result = []; + let subCombinations = this.combineArrays(arr.slice(1)); + for (let elem of arr[0]) { + if (Array.isArray(subCombinations)) { + for (let subComb of subCombinations) { + result.push([elem].concat(subComb)); + } + } else { + result.push([elem, subCombinations]); + } + } + return result; + } + }, + stockCheck(arrList) { this.stockList = [] let obj = { marketPrice: '', @@ -469,43 +463,23 @@ stock: '', integral: '' } - if (this.attributesList.length == 1) { + arrList.forEach(tab => { let data = {} - let name = this.attributesList[0].attributeName - let value = this.radioAttributes - data[name] = value - obj.attributeJson = JSON.stringify(data) - this.stockList.push(obj) - } else { - this.attributesList.forEach((item, ind) => { - if (ind != 0) { - this.checkboxAttributes.forEach((tab, index) => { - let data = {} - let tabName = this.attributesList[ind].attributeName - let tabValue = tab - data[tabName] = tabValue - obj.attributeJson = JSON.stringify(data) - let stockObj = JSON.parse(JSON.stringify(obj)) - this.stockList.push(stockObj) - }) - } + let tabName = '' + let tabValue = '' + tab.forEach((item, i) => { + tabName = this.attributesList[i].attributeName + tabValue = item + data[tabName] = tabValue }) - - - } + obj.attributeJson = JSON.stringify(data) + let stockObj = JSON.parse(JSON.stringify(obj)) + this.stockList.push(stockObj) + }) }, deleteCheckAll(i) { - if (this.checkboxAttributes.length > 1) { - this.checkboxAttributes.splice(i, 1) - } else { - this.checkboxAttributes.splice(i, 1) - this.radioAttributes = '' - } this.stockList.splice(i, 1) }, - deleteRadio() { - this.radioAttributes = '' - }, addStockList() { this.stockList.forEach(tab => { tab.marketPrice = this.bottonList[0].marketPrice @@ -551,7 +525,7 @@ }) }, fail(err) { - console.log('相机调用失败',err) + console.log('相机调用失败', err) } }) }, @@ -601,33 +575,24 @@ }, addCompleted() { if (this.radioItem[0].checked = true) { - this.productDate.newMark == '1' + this.productDate.newMark == 1 } else { - this.productDate.newMark == '2' + this.productDate.newMark == 2 } if (this.radioItem[1].checked = true) { - this.productDate.recommend == '1' + this.productDate.recommend == 1 } else { - this.productDate.recommend == '2' + this.productDate.recommend == 2 } - if(this.attributesList.length==1){ - if(!this.radioAttributes){ + this.attributesList.forEach(tab => { + if (JSON.stringify(tab.checkboxAttributes) == '[]') { uni.showToast({ title: '请选择商品规格', icon: 'none' }) - return + throw Error(`请选择商品规格!`) } - } - if(this.attributesList.length>1){ - if(JSON.stringify(this.checkboxAttributes) == '[]'){ - uni.showToast({ - title: '请选择商品规格', - icon: 'none' - }) - return - } - } + }) if (!this.productDate.attributesTypeId) { uni.showToast({ title: '请选择规格',