This commit is contained in:
gboy 2024-07-01 17:31:51 +08:00
commit bc2e2c02fe
1 changed files with 53 additions and 4 deletions

View File

@ -154,7 +154,7 @@
<template v-if="manyTabDate"> <template v-if="manyTabDate">
<el-table-column v-for="(item,iii) in manyTabDate" :key="iii" align="center" :label="manyTabTit[iii].title" min-width="80"> <el-table-column v-for="(item,iii) in manyTabDate" :key="iii" align="center" :label="manyTabTit[iii].title" min-width="80">
<template slot-scope="scope"> <template slot-scope="scope">
<span class="priceBox" v-text="scope.row[iii]" /> <el-input @input="handleMany(scope.row,iii,manyTabTit[iii].title)" v-model="scope.row[iii]" type="text" />
</template> </template>
</el-table-column> </el-table-column>
</template> </template>
@ -431,6 +431,8 @@ export default {
], ],
tableIndex: 0, tableIndex: 0,
attrInfo: {}, attrInfo: {},
fatAttrValue:[],
detailStatus:true,
oneFormBatch: [ oneFormBatch: [
{ {
image: '', image: '',
@ -458,7 +460,7 @@ export default {
watch: { watch: {
'formValidate.attr': { 'formValidate.attr': {
handler: function(val) { handler: function(val) {
if (this.formValidate.spec_type === 1) this.watCh(val) if (this.formValidate.spec_type === 1 && this.detailStatus) this.watCh(val)
}, },
immediate: false, immediate: false,
deep: true deep: true
@ -471,6 +473,47 @@ export default {
}, },
methods: { methods: {
handleMany(row,i,val){
// row.detail[val] = row[i]
// console.log('row',row);
// console.log('i',i);
// console.log(val);
if(row[i]){
this.detailStatus = false
this.fatAttrValue.map((res,key)=>{
console.log(row.detail[val])
if(row.detail[val] == res.detail[val] && key!=0){
//
res[i] = row[i]
// detail
res.detail[val] = row[i]
//sku
let skuValue = ''
Object.keys(this.manyTabTit).map((res,i)=>{
skuValue = skuValue?`${skuValue},${row[res]}`:`${skuValue}${row[res]}`
})
res['sku'] = skuValue
}
})
this.ManyAttrValue = this.fatAttrValue
row.detail[val] = row[i]
row.detail[val] = row[i]
let skuValue = ''
Object.keys(this.manyTabTit).map((res,i)=>{
skuValue = skuValue?`${skuValue},${row[res]}`:`${skuValue}${row[res]}`
})
row['sku'] = skuValue
//attr
let arrMode = []
this.ManyAttrValue.forEach((res)=>{
if(!arrMode.includes(res.detail[val])){
arrMode.push(res.detail[val])
}
})
this.formValidate.attr.find(res=>res.value == this.manyTabTit[i].title).detail = arrMode
}
},
// //
proportionChange(val,i,e){ proportionChange(val,i,e){
val.cost = toFixedNoRounding(val.price * e) val.cost = toFixedNoRounding(val.price * e)
@ -612,12 +655,17 @@ export default {
tmpTab['value' + i] = '' tmpTab['value' + i] = ''
}) })
this.ManyAttrValue = this.attrFormat(val) this.ManyAttrValue = this.attrFormat(val)
console.log(this.ManyAttrValue) this.fatAttrValue = this.attrFormat(val)
this.ManyAttrValue.forEach((val, index) => { this.ManyAttrValue.forEach((val, index) => {
const key = Object.values(val.detail).sort().join('/') const key = Object.values(val.detail).sort().join('/')
if (this.attrInfo[key]) this.ManyAttrValue[index] = this.attrInfo[key] if (this.attrInfo[key]) this.ManyAttrValue[index] = this.attrInfo[key]
val.image = this.formValidate.image val.image = this.formValidate.image
}) })
this.fatAttrValue.forEach((val, index) => {
const key = Object.values(val.detail).sort().join('/')
if (this.attrInfo[key]) this.fatAttrValue[index] = this.attrInfo[key]
val.image = this.formValidate.image
})
this.attrInfo = {} this.attrInfo = {}
this.ManyAttrValue.forEach((val) => { this.ManyAttrValue.forEach((val) => {
if (val.detail !== 'undefined' && val.detail !== null) { if (val.detail !== 'undefined' && val.detail !== null) {
@ -626,6 +674,7 @@ export default {
}) })
this.manyTabTit = tmp this.manyTabTit = tmp
this.manyTabDate = tmpTab this.manyTabDate = tmpTab
console.log(this.manyTabTit);
this.formThead = Object.assign({}, this.formThead, tmp) this.formThead = Object.assign({}, this.formThead, tmp)
}, },
attrFormat(arr) { attrFormat(arr) {
@ -739,7 +788,7 @@ export default {
this.OneattrValue = info.attrValue this.OneattrValue = info.attrValue
} else { } else {
this.ManyAttrValue = info.attrValue this.ManyAttrValue = info.attrValue
console.log(this.ManyAttrValue); this.fatAttrValue = info.attrValue
this.ManyAttrValue.forEach(val => { this.ManyAttrValue.forEach(val => {
if (val.detail !== 'undefined' && val.detail !== null) { if (val.detail !== 'undefined' && val.detail !== null) {
this.attrInfo[ this.attrInfo[