master
fanfan 5 months ago
parent 0834c1ccc7
commit 91171ecce6
  1. 26
      src/common/model/goods/MultiSpec.js
  2. 7
      src/components/SelectGoods/SelectGoods.vue
  3. 67
      src/views/goods/modules/MultiSpec.vue

@ -5,24 +5,22 @@ import { log } from '@/api/market/presale'
// 默认的sku字段属性 // 默认的sku字段属性
const defaultColumns = [ const defaultColumns = [
/* {
title: '预览图',
dataIndex: 'image',
width: 90,
scopedSlots: { customRender: 'image' }
}, */
{ {
title: '选择商品', title: '选择商品',
dataIndex: 'select_goods', dataIndex: 'select_goods',
width: 120, width: 120,
scopedSlots: { customRender: 'select_goods' } scopedSlots: { customRender: 'select_goods' }
}, },
/* { {
title: '商品名称', title: '商品ID',
dataIndex: 'goods_name', dataIndex: 'goods_id',
width: 120, width: 90,
scopedSlots: { customRender: 'goods_name' } },
}, */ {
title: '商品信息',
scopedSlots: { customRender: 'item' },
width: 180,
},
{ {
title: '商品价格', title: '商品价格',
dataIndex: 'goods_price', dataIndex: 'goods_price',
@ -79,7 +77,9 @@ const defaultSkuItemData = {
cost_price: '', cost_price: '',
stock_num: '', stock_num: '',
goods_weight: '', goods_weight: '',
goods_sku_no: '' goods_sku_no: '',
goods_image :'',
goods_name :''
} }
// const demoSpecList = [ // const demoSpecList = [

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<a-button @click="handleSelectGoods">选择商品</a-button> <a-button @click="handleSelectGoods">选择商品</a-button>
<a-table <!-- <a-table
v-show="selectedItems.length" v-show="selectedItems.length"
class="table-goodsList" class="table-goodsList"
rowKey="goods_id" rowKey="goods_id"
@ -9,7 +9,6 @@
:dataSource="selectedItems" :dataSource="selectedItems"
:pagination="false" :pagination="false"
> >
<!-- 商品信息 -->
<template slot="item" slot-scope="item"> <template slot="item" slot-scope="item">
<GoodsItem <GoodsItem
:data="{ :data="{
@ -21,11 +20,10 @@
:subTitleColor="true" :subTitleColor="true"
/> />
</template> </template>
<!-- 操作项 -->
<span slot="action" slot-scope="text, item, index"> <span slot="action" slot-scope="text, item, index">
<a v-action:delete @click="handleDeleteItem(index)">删除</a> <a v-action:delete @click="handleDeleteItem(index)">删除</a>
</span> </span>
</a-table> </a-table> -->
<GoodsModal <GoodsModal
ref="GoodsModal" ref="GoodsModal"
:multiple="multiple" :multiple="multiple"
@ -147,6 +145,7 @@ export default {
onChange () { onChange () {
const { multiple, selectedGoodsIds } = this const { multiple, selectedGoodsIds } = this
const sGoodsIds = multiple ? selectedGoodsIds : (selectedGoodsIds.length ? selectedGoodsIds[0] : undefined) const sGoodsIds = multiple ? selectedGoodsIds : (selectedGoodsIds.length ? selectedGoodsIds[0] : undefined)
console.log(sGoodsIds)
return this.$emit('change', sGoodsIds) return this.$emit('change', sGoodsIds)
} }

@ -90,13 +90,23 @@
:pagination="false" :pagination="false"
bordered bordered
> >
<template slot="select_goods" slot-scope="text, item"> <template slot="select_goods" slot-scope="text, item, index">
<SelectGoods :multiple="false" :source="source" @change="handleSelectGoods($event, item)" /> <SelectGoods :multiple="false" :source="source" @change="handleSelectGoods($event, item, index)" />
</template> </template>
<!-- 商品名称 --> <!-- 商品名称 -->
<!-- <template slot="goods_name" slot-scope="text, item"> <template slot="item" slot-scope="item" v-if="item.goods_id">
{{ item.goods_name }} <GoodsItem
</template> --> :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"> <template slot="goods_price" slot-scope="text, item">
{{ item.goods_price }} {{ item.goods_price }}
@ -125,7 +135,7 @@
>去修改</router-link >去修改</router-link
> --> > -->
<a @click="handleEdit(index, item)" v-if="item.goods_id" style="margin-left: 10px">去修改</a> <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> </template>
</a-table> </a-table>
</a-form-item> </a-form-item>
@ -138,11 +148,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'
export default { export default {
components: { components: {
SelectImage, SelectImage,
SelectGoods, SelectGoods,
GoodsItem,
}, },
props: { props: {
// //
@ -183,6 +194,7 @@ export default {
created() { created() {
// SKU // SKU
this.getData() this.getData()
console.log(this.multiSpecData)
}, },
methods: { methods: {
handleEdit(item) { handleEdit(item) {
@ -194,15 +206,17 @@ export default {
}) })
window.open(routeData.href, '_blank') window.open(routeData.href, '_blank')
}, },
handleCancel(index, item) { handleCancel(index) {
for (let key in this.multiSpecData.skuList[index]) { this.multiSpecData.skuList[index].cost_price = ''
if (this.multiSpecData.skuList[index].hasOwnProperty(key)) { this.multiSpecData.skuList[index].goods_id = ''
this.multiSpecData.skuList[index][key] = '' this.multiSpecData.skuList[index].goods_image = ''
} this.multiSpecData.skuList[index].goods_name = ''
} this.multiSpecData.skuList[index].goods_price = ''
this.multiSpecData.skuList[index].spec_value_0 = item.spec_value_0 this.multiSpecData.skuList[index].goods_price_min = ''
this.multiSpecData.skuList[index].tempId = item.tempId this.multiSpecData.skuList[index].goods_sku_no = ''
this.multiSpecData.skuList[index].skuKeys = item.skuKeys this.multiSpecData.skuList[index].goods_weight = ''
this.multiSpecData.skuList[index].line_price = ''
this.multiSpecData.skuList[index].stock_num = ''
}, },
// SKU() // SKU()
getData() { getData() {
@ -298,7 +312,8 @@ export default {
this.visible = true this.visible = true
}, },
async handleSelectGoods(goodsId, item) { async handleSelectGoods(goodsId, item, index) {
console.log(index)
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) {
@ -312,14 +327,16 @@ export default {
return return
} }
const sku = res.skuList[0] const sku = res.skuList[index]
item.goods_price = sku.goods_price this.multiSpecData.skuList[index].goods_price = sku.goods_price
item.cost_price = sku.cost_price this.multiSpecData.skuList[index].cost_price = sku.cost_price
item.stock_num = sku.stock_num this.multiSpecData.skuList[index].stock_num = sku.stock_num
item.goods_weight = sku.goods_weight this.multiSpecData.skuList[index].goods_weight = sku.goods_weight
item.goods_sku_no = sku.goods_sku_no this.multiSpecData.skuList[index].goods_sku_no = sku.goods_sku_no
// item.goods_name = res.goods_name this.multiSpecData.skuList[index].goods_name = res.goods_name
item.goods_id = res.goods_id 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
}) })
}, },

Loading…
Cancel
Save