Commit 4183488c by 李伟康

refactor(OrderPopup): 组件间统一使用 dataKey 替代 key

- 将 GoodsList、PackageList、SkuGoodsList 和 OrderPopup 组件中的 key 属性统一改为 dataKey
- 更新了相关组件的 initGoodsList 方法,使用 dataKey 来获取数据
- 这个改动提高了代码的一致性和可维护性
1 parent 110b1e90
......@@ -38,7 +38,7 @@ export default {
params: Object,
data: [Object, Array],
cacheData: Array,
key: String
dataKey: String
},
mounted () {
},
......@@ -83,7 +83,7 @@ export default {
},
initGoodsList (goodsData) {
let { goodsType } = this.params,
{ data ,key } = this,
{ data ,dataKey } = this,
arr = []
goodsData.map(val => {
if (val.goodsFlag == 1) {
......@@ -95,7 +95,7 @@ export default {
if (goodsType.includes(subVal.merchantGoodsPosition)) arr.push(val)
}
})
let paramsData = key ? data[key] : data
let paramsData = dataKey ? data[dataKey] : data
if (paramsData.length) paramsData.map(e => {
this.currentIds.push(e.goods.goodsId)
this.chooseList.push(e)
......
......@@ -55,7 +55,7 @@ export default {
params: Object,
data: [Object, Array],
cacheData: Array,
key: String
dataKey: String
},
mounted () {
},
......@@ -99,7 +99,7 @@ export default {
}
},
initGoodsList (goodsData) {
let { data, key } = this,
let { data, dataKey } = this,
arr = []
goodsData.map(val => {
if (val.goodsFlag == 3) {
......@@ -110,7 +110,7 @@ export default {
arr.push(val)
}
})
let paramsData = key ? data[key] : data
let paramsData = dataKey ? data[dataKey] : data
if (paramsData.length) paramsData.map(e => {
this.currentIds.push(e.packageGoods.packageCode)
this.chooseList.push(e)
......
......@@ -101,7 +101,8 @@ export default {
props: {
params: Object,
data: [Object, Array],
cacheData: Array
cacheData: Array,
dataKey: String
},
mounted () {
},
......@@ -145,7 +146,7 @@ export default {
}
},
initGoodsList (goodsData) {
let { data } = this,
let { data,dataKey } = this,
arr = []
goodsData.map((val) => {
if (val.goodsFlag == 1) {
......@@ -161,18 +162,23 @@ export default {
if (val.goodsFlag == 2) {
val.active = false
val.key = Date.now()
if (val.goodsFlag == 2) val.multipleSpecificationsGoods.specificationList.forEach(item => {
item.specificationSelectValueList = []
item.specificationValueList.forEach(second => {
if (second.show) {
item.specificationSelectValueList.push(second.specificationValue)
}
if (val.goodsFlag == 2) {
if(val.multipleSpecificationsGoods?.goods?.sellPrice) val.multipleSpecificationsGoods.goods.sellPrice = null
val.multipleSpecificationsGoods.specificationList.forEach(item => {
item.value = ''
item.specificationSelectValueList = []
item.specificationValueList.forEach(second => {
if (second.show) {
item.specificationSelectValueList.push(second.specificationValue)
}
})
})
})
}
arr.push(val)
}
})
if (data.length) data.map(e => {
let paramsData = dataKey ? data[dataKey] : data
if (paramsData.length) paramsData.map(e => {
if (e.goodsFlag == 1) {
this.currentIds.push(e.goods.goodsId)
this.chooseList.push(e)
......
......@@ -50,7 +50,7 @@
:is="componentObject.name"
:params.sync="componentObject"
:data="data"
:key="key"
:dataKey="dataKey"
ref="componentRef"
@choose="chooseContent = $event"
></component>
......@@ -108,7 +108,7 @@ export default {
},
data: [Object, Array],
externalData: null,
key: String
dataKey: String
},
provide () {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!