|
|
@ -14,11 +14,7 @@ |
|
|
|
placeholder="请输入规格名称" |
|
|
|
placeholder="请输入规格名称" |
|
|
|
@change="onChangeSpecGroupIpt" |
|
|
|
@change="onChangeSpecGroupIpt" |
|
|
|
/> |
|
|
|
/> |
|
|
|
<a |
|
|
|
<a v-if="!isSpecLocked" class="group-item-delete" href="javascript:;" @click="handleDeleteSpecGroup(index)" |
|
|
|
v-if="!isSpecLocked" |
|
|
|
|
|
|
|
class="group-item-delete" |
|
|
|
|
|
|
|
href="javascript:;" |
|
|
|
|
|
|
|
@click="handleDeleteSpecGroup(index)" |
|
|
|
|
|
|
|
>删除规格组</a |
|
|
|
>删除规格组</a |
|
|
|
> |
|
|
|
> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -95,13 +91,26 @@ |
|
|
|
bordered |
|
|
|
bordered |
|
|
|
> |
|
|
|
> |
|
|
|
<template slot="select_goods" slot-scope="text, item"> |
|
|
|
<template slot="select_goods" slot-scope="text, item"> |
|
|
|
<SelectGoods :multiple="false" :source='source' :channel="channel" @change="handleSelectGoods($event, item)" /> |
|
|
|
<SelectGoods |
|
|
|
|
|
|
|
:multiple="false" |
|
|
|
|
|
|
|
:source="source" |
|
|
|
|
|
|
|
:channel="channel" |
|
|
|
|
|
|
|
@change="handleSelectGoods($event, item)" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</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_id" slot-scope="text, item"> |
|
|
|
|
|
|
|
{{ item.goods_id }}{{item.goods_name}} |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<!-- 商品名称 --> |
|
|
|
|
|
|
|
<!-- <template slot="goods_name" slot-scope="text, item"> |
|
|
|
|
|
|
|
{{ item.goods_name }} |
|
|
|
|
|
|
|
</template> --> |
|
|
|
|
|
|
|
<!-- 商品价格 --> |
|
|
|
|
|
|
|
<template slot="goods_price" slot-scope="text, item"> |
|
|
|
<template slot="goods_price" slot-scope="text, item"> |
|
|
|
{{ item.goods_price }} |
|
|
|
{{ item.goods_price }} |
|
|
|
</template> |
|
|
|
</template> |
|
|
@ -124,12 +133,14 @@ |
|
|
|
{{ item.goods_sku_no }} |
|
|
|
{{ item.goods_sku_no }} |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<!-- 操作 --> |
|
|
|
<!-- 操作 --> |
|
|
|
<template slot="action" slot-scope="text, item"> |
|
|
|
<template slot="action" slot-scope="text, item, index"> |
|
|
|
<router-link |
|
|
|
<!-- <router-link |
|
|
|
v-if="item.goods_id" |
|
|
|
v-if="item.goods_id" |
|
|
|
:to="{ path: '/goods/update', query: { goodsId: item.goods_id } }" |
|
|
|
:to="{ path: '/goods/update', query: { goodsId: item.goods_id } }" |
|
|
|
>去修改</router-link |
|
|
|
>去修改</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> |
|
|
|
</template> |
|
|
|
</a-table> |
|
|
|
</a-table> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
@ -142,11 +153,12 @@ import MultiSpecModel from '@/common/model/goods/MultiSpec' |
|
|
|
import { SelectImage } from '@/components' |
|
|
|
import { SelectImage } from '@/components' |
|
|
|
import SelectGoods from '@/components/SelectGoods/SelectGoods.vue' |
|
|
|
import SelectGoods from '@/components/SelectGoods/SelectGoods.vue' |
|
|
|
import * as GoodsApi from '@/api/goods' |
|
|
|
import * as GoodsApi from '@/api/goods' |
|
|
|
|
|
|
|
import { GoodsItem } from '@/components/Table/table' |
|
|
|
export default { |
|
|
|
export default { |
|
|
|
components: { |
|
|
|
components: { |
|
|
|
SelectImage, |
|
|
|
SelectImage, |
|
|
|
SelectGoods |
|
|
|
SelectGoods, |
|
|
|
|
|
|
|
GoodsItem |
|
|
|
}, |
|
|
|
}, |
|
|
|
props: { |
|
|
|
props: { |
|
|
|
// 默认的规格列表 |
|
|
|
// 默认的规格列表 |
|
|
@ -172,9 +184,9 @@ export default { |
|
|
|
// 规格列表 |
|
|
|
// 规格列表 |
|
|
|
specList: [], |
|
|
|
specList: [], |
|
|
|
// SKU列表 |
|
|
|
// SKU列表 |
|
|
|
skuList: [] |
|
|
|
skuList: [], |
|
|
|
}, |
|
|
|
}, |
|
|
|
visible: false |
|
|
|
visible: false, |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
watch: { |
|
|
@ -182,7 +194,7 @@ export default { |
|
|
|
if (val.length && this.MultiSpecModel.isEmpty()) { |
|
|
|
if (val.length && this.MultiSpecModel.isEmpty()) { |
|
|
|
this.getData() |
|
|
|
this.getData() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 初始化数据 |
|
|
|
// 初始化数据 |
|
|
|
created() { |
|
|
|
created() { |
|
|
@ -190,6 +202,27 @@ export default { |
|
|
|
this.getData() |
|
|
|
this.getData() |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
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信息(展示) |
|
|
|
// 获取规格及SKU信息(展示) |
|
|
|
getData() { |
|
|
|
getData() { |
|
|
|
const { defaultSpecList, defaultSkuList } = this |
|
|
|
const { defaultSpecList, defaultSkuList } = this |
|
|
@ -219,7 +252,7 @@ export default { |
|
|
|
app.MultiSpecModel.handleDeleteSpecGroup(groupIndex) |
|
|
|
app.MultiSpecModel.handleDeleteSpecGroup(groupIndex) |
|
|
|
// 关闭对话框 |
|
|
|
// 关闭对话框 |
|
|
|
modal.destroy() |
|
|
|
modal.destroy() |
|
|
|
} |
|
|
|
}, |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -241,7 +274,7 @@ export default { |
|
|
|
app.MultiSpecModel.handleDeleteSpecValue(groupIndex, valueIndex) |
|
|
|
app.MultiSpecModel.handleDeleteSpecValue(groupIndex, valueIndex) |
|
|
|
// 关闭对话框 |
|
|
|
// 关闭对话框 |
|
|
|
modal.destroy() |
|
|
|
modal.destroy() |
|
|
|
} |
|
|
|
}, |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -286,13 +319,13 @@ export default { |
|
|
|
|
|
|
|
|
|
|
|
async handleSelectGoods(goodsId, item) { |
|
|
|
async handleSelectGoods(goodsId, item) { |
|
|
|
const skuList = this.multiSpecData.skuList |
|
|
|
const skuList = this.multiSpecData.skuList |
|
|
|
const skuItem = skuList.find(sku => sku.goods_id === goodsId) |
|
|
|
const skuItem = skuList.find((sku) => sku.goods_id === goodsId) |
|
|
|
if (skuItem) { |
|
|
|
if (skuItem) { |
|
|
|
this.$message.error('一个商品只能选择一次', 2) |
|
|
|
this.$message.error('一个商品只能选择一次', 2) |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.getGoodsDetail(goodsId).then(res => { |
|
|
|
this.getGoodsDetail(goodsId).then((res) => { |
|
|
|
const queryGoodsId = this.$route.query.goodsId |
|
|
|
const queryGoodsId = this.$route.query.goodsId |
|
|
|
if (res.spec_type === 20 && queryGoodsId !== goodsId) { |
|
|
|
if (res.spec_type === 20 && queryGoodsId !== goodsId) { |
|
|
|
this.$message.error('您选择的商品是多规格商品', 2) |
|
|
|
this.$message.error('您选择的商品是多规格商品', 2) |
|
|
@ -300,27 +333,30 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const sku = res.skuList[0] |
|
|
|
const sku = res.skuList[0] |
|
|
|
|
|
|
|
console.log(res) |
|
|
|
item.goods_price = sku.goods_price |
|
|
|
item.goods_price = sku.goods_price |
|
|
|
item.cost_price = sku.cost_price |
|
|
|
item.cost_price = sku.cost_price |
|
|
|
item.stock_num = sku.stock_num |
|
|
|
item.stock_num = sku.stock_num |
|
|
|
item.goods_weight = sku.goods_weight |
|
|
|
item.goods_weight = sku.goods_weight |
|
|
|
item.goods_sku_no = sku.goods_sku_no |
|
|
|
item.goods_sku_no = sku.goods_sku_no |
|
|
|
// item.goods_name = res.goods_name |
|
|
|
item.goods_name = res.goods_name |
|
|
|
item.goods_id = res.goods_id |
|
|
|
item.goods_id = res.goods_id |
|
|
|
|
|
|
|
item.goods_image = res.goods_image |
|
|
|
|
|
|
|
item.goods_price_min = res.goods_price_min |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
console.log(item) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 获取商品详情 |
|
|
|
// 获取商品详情 |
|
|
|
getGoodsDetail(goodsId = null) { |
|
|
|
getGoodsDetail(goodsId = null) { |
|
|
|
if (!goodsId) return false |
|
|
|
if (!goodsId) return false |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
GoodsApi.detail({ goodsId }) |
|
|
|
GoodsApi.detail({ goodsId }).then((result) => { |
|
|
|
.then(result => { |
|
|
|
|
|
|
|
resolve(result.data.goodsInfo) |
|
|
|
resolve(result.data.goodsInfo) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
<style lang="less" scoped> |
|
|
|
<style lang="less" scoped> |
|
|
|