|
|
|
@ -90,13 +90,23 @@ |
|
|
|
|
:pagination="false" |
|
|
|
|
bordered |
|
|
|
|
> |
|
|
|
|
<template slot="select_goods" slot-scope="text, item"> |
|
|
|
|
<SelectGoods :multiple="false" :source="source" @change="handleSelectGoods($event, item)" /> |
|
|
|
|
<template slot="select_goods" slot-scope="text, item, index"> |
|
|
|
|
<SelectGoods :multiple="false" :source="source" @change="handleSelectGoods($event, item, index)" /> |
|
|
|
|
</template> |
|
|
|
|
<!-- 商品名称 --> |
|
|
|
|
<!-- <template slot="goods_name" slot-scope="text, item"> |
|
|
|
|
{{ item.goods_name }} |
|
|
|
|
</template> --> |
|
|
|
|
<template slot="item" slot-scope="item" v-if="item.goods_id"> |
|
|
|
|
<GoodsItem |
|
|
|
|
:data="{ |
|
|
|
|
image: item.goods_image, |
|
|
|
|
imageAlt: '商品图片', |
|
|
|
|
title: item.goods_name, |
|
|
|
|
}" |
|
|
|
|
:subTitleColor="true" |
|
|
|
|
/> |
|
|
|
|
</template> |
|
|
|
|
<template slot="goods_name" slot-scope="text, item"> |
|
|
|
|
{{ item.goods_id }} |
|
|
|
|
</template> |
|
|
|
|
<!-- 商品价格 --> |
|
|
|
|
<template slot="goods_price" slot-scope="text, item"> |
|
|
|
|
{{ item.goods_price }} |
|
|
|
@ -125,7 +135,7 @@ |
|
|
|
|
>去修改</router-link |
|
|
|
|
> --> |
|
|
|
|
<a @click="handleEdit(index, item)" v-if="item.goods_id" style="margin-left: 10px">去修改</a> |
|
|
|
|
<a @click="handleCancel(index, item)" v-if="item.goods_id" style="margin-left: 10px">取消选择</a> |
|
|
|
|
<a @click="handleCancel(index)" v-if="item.goods_id" style="margin-left: 10px">取消选择</a> |
|
|
|
|
</template> |
|
|
|
|
</a-table> |
|
|
|
|
</a-form-item> |
|
|
|
@ -138,11 +148,12 @@ import MultiSpecModel from '@/common/model/goods/MultiSpec' |
|
|
|
|
import { SelectImage } from '@/components' |
|
|
|
|
import SelectGoods from '@/components/SelectGoods/SelectGoods.vue' |
|
|
|
|
import * as GoodsApi from '@/api/goods' |
|
|
|
|
|
|
|
|
|
import { GoodsItem } from '@/components/Table' |
|
|
|
|
export default { |
|
|
|
|
components: { |
|
|
|
|
SelectImage, |
|
|
|
|
SelectGoods, |
|
|
|
|
GoodsItem, |
|
|
|
|
}, |
|
|
|
|
props: { |
|
|
|
|
// 默认的规格列表 |
|
|
|
@ -183,6 +194,7 @@ export default { |
|
|
|
|
created() { |
|
|
|
|
// 获取规格及SKU信息 |
|
|
|
|
this.getData() |
|
|
|
|
console.log(this.multiSpecData) |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
handleEdit(item) { |
|
|
|
@ -194,15 +206,17 @@ export default { |
|
|
|
|
}) |
|
|
|
|
window.open(routeData.href, '_blank') |
|
|
|
|
}, |
|
|
|
|
handleCancel(index, item) { |
|
|
|
|
for (let key in this.multiSpecData.skuList[index]) { |
|
|
|
|
if (this.multiSpecData.skuList[index].hasOwnProperty(key)) { |
|
|
|
|
this.multiSpecData.skuList[index][key] = '' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.multiSpecData.skuList[index].spec_value_0 = item.spec_value_0 |
|
|
|
|
this.multiSpecData.skuList[index].tempId = item.tempId |
|
|
|
|
this.multiSpecData.skuList[index].skuKeys = item.skuKeys |
|
|
|
|
handleCancel(index) { |
|
|
|
|
this.multiSpecData.skuList[index].cost_price = '' |
|
|
|
|
this.multiSpecData.skuList[index].goods_id = '' |
|
|
|
|
this.multiSpecData.skuList[index].goods_image = '' |
|
|
|
|
this.multiSpecData.skuList[index].goods_name = '' |
|
|
|
|
this.multiSpecData.skuList[index].goods_price = '' |
|
|
|
|
this.multiSpecData.skuList[index].goods_price_min = '' |
|
|
|
|
this.multiSpecData.skuList[index].goods_sku_no = '' |
|
|
|
|
this.multiSpecData.skuList[index].goods_weight = '' |
|
|
|
|
this.multiSpecData.skuList[index].line_price = '' |
|
|
|
|
this.multiSpecData.skuList[index].stock_num = '' |
|
|
|
|
}, |
|
|
|
|
// 获取规格及SKU信息(展示) |
|
|
|
|
getData() { |
|
|
|
@ -298,7 +312,8 @@ export default { |
|
|
|
|
this.visible = true |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
async handleSelectGoods(goodsId, item) { |
|
|
|
|
async handleSelectGoods(goodsId, item, index) { |
|
|
|
|
console.log(index) |
|
|
|
|
const skuList = this.multiSpecData.skuList |
|
|
|
|
const skuItem = skuList.find((sku) => sku.goods_id === goodsId) |
|
|
|
|
if (skuItem) { |
|
|
|
@ -309,17 +324,19 @@ export default { |
|
|
|
|
const queryGoodsId = this.$route.query.goodsId |
|
|
|
|
if (res.spec_type === 20 && queryGoodsId !== goodsId) { |
|
|
|
|
this.$message.error('您选择的商品是多规格商品', 2) |
|
|
|
|
return |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const sku = res.skuList[0] |
|
|
|
|
item.goods_price = sku.goods_price |
|
|
|
|
item.cost_price = sku.cost_price |
|
|
|
|
item.stock_num = sku.stock_num |
|
|
|
|
item.goods_weight = sku.goods_weight |
|
|
|
|
item.goods_sku_no = sku.goods_sku_no |
|
|
|
|
// item.goods_name = res.goods_name |
|
|
|
|
item.goods_id = res.goods_id |
|
|
|
|
const sku = res.skuList[index] |
|
|
|
|
this.multiSpecData.skuList[index].goods_price = sku.goods_price |
|
|
|
|
this.multiSpecData.skuList[index].cost_price = sku.cost_price |
|
|
|
|
this.multiSpecData.skuList[index].stock_num = sku.stock_num |
|
|
|
|
this.multiSpecData.skuList[index].goods_weight = sku.goods_weight |
|
|
|
|
this.multiSpecData.skuList[index].goods_sku_no = sku.goods_sku_no |
|
|
|
|
this.multiSpecData.skuList[index].goods_name = res.goods_name |
|
|
|
|
this.multiSpecData.skuList[index].goods_id = res.goods_id |
|
|
|
|
this.multiSpecData.skuList[index].goods_image = res.goods_image |
|
|
|
|
this.multiSpecData.skuList[index].goods_price_min = res.goods_price_min |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|