|
|
|
@ -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 }} |
|
|
|
@ -120,10 +130,12 @@ |
|
|
|
|
{{ item.goods_sku_no }} |
|
|
|
|
</template> |
|
|
|
|
<!-- 操作 --> |
|
|
|
|
<template slot="action" slot-scope="text, item"> |
|
|
|
|
<router-link v-if="item.goods_id" :to="{ path: '/goods/update', query: { goodsId: item.goods_id } }" |
|
|
|
|
<template slot="action" slot-scope="text, item, index"> |
|
|
|
|
<!-- <router-link v-if="item.goods_id" :to="{ path: '/goods/update', query: { goodsId: item.goods_id } }" |
|
|
|
|
>去修改</router-link |
|
|
|
|
> |
|
|
|
|
> --> |
|
|
|
|
<a @click="handleEdit(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> |
|
|
|
@ -136,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: { |
|
|
|
|
// 默认的规格列表 |
|
|
|
@ -150,7 +163,7 @@ export default { |
|
|
|
|
// 商品规格是否锁定(锁定状态下不允许编辑规格) |
|
|
|
|
isSpecLocked: PropTypes.bool.def(false), |
|
|
|
|
checkList: PropTypes.array.def([]), |
|
|
|
|
source: PropTypes.any.def(0) |
|
|
|
|
source: PropTypes.any.def(0), |
|
|
|
|
}, |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
@ -181,8 +194,30 @@ export default { |
|
|
|
|
created() { |
|
|
|
|
// 获取规格及SKU信息 |
|
|
|
|
this.getData() |
|
|
|
|
console.log(this.multiSpecData) |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
handleEdit(item) { |
|
|
|
|
const routeData = this.$router.resolve({ |
|
|
|
|
path: '/goods/update', |
|
|
|
|
query: { |
|
|
|
|
goodsId: item.goods_id, |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
window.open(routeData.href, '_blank') |
|
|
|
|
}, |
|
|
|
|
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() { |
|
|
|
|
const { defaultSpecList, defaultSkuList } = this |
|
|
|
@ -277,13 +312,15 @@ 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) { |
|
|
|
|
this.$message.error('一个商品只能选择一次', 2) |
|
|
|
|
return false |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
if (!goodsId) { |
|
|
|
|
item.goods_price = ''; |
|
|
|
|
item.cost_price = ''; |
|
|
|
@ -293,21 +330,25 @@ export default { |
|
|
|
|
item.goods_id = ''; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
======= |
|
|
|
|
>>>>>>> 91171ecce6528fcdb23bb2aee7aa2efea0485347 |
|
|
|
|
this.getGoodsDetail(goodsId).then((res) => { |
|
|
|
|
const queryGoodsId = this.$route.query.goodsId |
|
|
|
|
if (res.spec_type === 20 && queryGoodsId !== goodsId) { |
|
|
|
|
this.$message.error('您选择的商品是多规格商品', 2) |
|
|
|
|
return false |
|
|
|
|
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 |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|