feature/0423
陈伟 11 months ago
parent 2935e94ebb
commit 78ce31ad59
  1. 30
      src/common/model/goods/MultiSpec.js
  2. 103
      src/views/goods/modules/MultiSpec.vue

@ -4,11 +4,23 @@ import { debounce, isEmpty } from '@/utils/util'
// 默认的sku字段属性
const defaultColumns = [
{
/* {
title: '预览图',
dataIndex: 'image',
width: 90,
scopedSlots: { customRender: 'image' }
}, */
{
title: '选择商品',
dataIndex: 'select_goods',
width: 120,
scopedSlots: { customRender: 'select_goods' }
},
{
title: '商品名称',
dataIndex: 'goods_name',
width: 120,
scopedSlots: { customRender: 'goods_name' }
},
{
title: '商品价格',
@ -22,6 +34,12 @@ const defaultColumns = [
width: 120,
scopedSlots: { customRender: 'cost_price' }
},
/* {
title: '划线价格',
dataIndex: 'line_price',
width: 120,
scopedSlots: { customRender: 'line_price' }
}, */
{
title: '库存数量',
dataIndex: 'stock_num',
@ -39,6 +57,13 @@ const defaultColumns = [
dataIndex: 'goods_sku_no',
width: 140,
scopedSlots: { customRender: 'goods_sku_no' }
},
{
title: '操作',
dataIndex: 'action',
width: 140,
scopedSlots: { customRender: 'action' }
}
]
@ -47,8 +72,11 @@ const defaultSkuItemData = {
image_id: 0,
image: {},
// imageList: [],
goods_id: '',
goods_name: '',
goods_price: '',
line_price: '',
cost_price: '',
stock_num: '',
goods_weight: '',
goods_sku_no: ''

@ -19,7 +19,8 @@
class="group-item-delete"
href="javascript:;"
@click="handleDeleteSpecGroup(index)"
>删除规格组</a>
>删除规格组</a
>
</div>
<div class="spec-value clearfix">
<div class="spec-value-item" v-for="(itm, idx) in item.valueList" :key="idx">
@ -39,11 +40,7 @@
/>
</div>
<div v-if="!isSpecLocked" class="spec-value-add">
<a
class="group-item-delete"
href="javascript:;"
@click="handleAddSpecValue(index)"
>新增规格值</a>
<a class="group-item-delete" href="javascript:;" @click="handleAddSpecValue(index)">新增规格值</a>
</div>
</div>
</div>
@ -53,14 +50,10 @@
class="spec-group-add-btn"
icon="plus"
@click="handleAddSpecGroup"
>添加规格组</a-button>
</a-form-item>
<a-form-item
v-show="multiSpecData.skuList.length"
label="SKU列表"
:labelCol="labelCol"
:wrapperCol="wrapperCol"
>添加规格组</a-button
>
</a-form-item>
<a-form-item v-show="multiSpecData.skuList.length" label="SKU列表" :labelCol="labelCol" :wrapperCol="wrapperCol">
<!-- 批量设置 -->
<div v-if="multiSpecData.skuList.length > 1" class="sku-batch">
<span class="title">批量设置:</span>
@ -76,6 +69,12 @@
:min="0"
:precision="2"
/>
<!-- <a-input-number
v-model="multiSpecData.skuBatchForm.line_price"
placeholder="划线价格"
:min="0"
:precision="2"
/> -->
<a-input-number
v-model="multiSpecData.skuBatchForm.stock_num"
placeholder="库存数量"
@ -91,6 +90,7 @@
<a-input v-model="multiSpecData.skuBatchForm.goods_sku_no" placeholder="sku编码" />
<a-button @click="handleSkuBatch">立即设置</a-button>
</div>
<!-- sku列表table -->
<a-table
class="sku-list"
@ -100,33 +100,42 @@
:pagination="false"
bordered
>
<!-- 预览图 -->
<template slot="image" slot-scope="text, item">
<SelectImage
v-model="item.image_id"
:defaultList="(item.image_id > 0 && item.image) ? [item.image] : []"
:width="50"
/>
<template slot="select_goods" slot-scope="text, item">
<SelectGoods :multiple="false" @change="handleSelectGoods($event, item)" />
</template>
<!-- 商品名称 -->
<template slot="goods_name" slot-scope="text, item">
{{ item.goods_name }}
</template>
<!-- 商品价格 -->
<template slot="goods_price" slot-scope="text, item">
<a-input-number v-model="item.goods_price" size="small" :min="0.01" :precision="2" />
{{ item.goods_price }}
</template>
<!-- 成本价 -->
<!-- 成本价 -->
<template slot="cost_price" slot-scope="text, item">
<a-input-number v-model="item.cost_price" size="small" :min="0" :precision="2" />
{{ item.cost_price }}
</template>
<!-- 库存数量 -->
<template slot="stock_num" slot-scope="text, item">
<a-input-number v-model="item.stock_num" size="small" :min="0" :precision="0" />
{{ item.stock_num }}
</template>
<!-- 商品重量 -->
<template slot="goods_weight" slot-scope="text, item">
<a-input-number v-model="item.goods_weight" size="small" :min="0" :precision="2" />
<!-- <a-input-number v-model="item.goods_weight" size="small" :min="0" :precision="2" /> -->
{{ item.goods_weight }}
</template>
<!-- sku编码 -->
<template slot="goods_sku_no" slot-scope="text, item">
<a-input v-model="item.goods_sku_no" size="small" />
<!-- <a-input v-model="item.goods_sku_no" size="small" /> -->
{{ 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 } }"
>去修改</router-link
>
</template>
</a-table>
</a-form-item>
@ -137,10 +146,13 @@
import PropTypes from 'ant-design-vue/es/_util/vue-types'
import MultiSpecModel from '@/common/model/goods/MultiSpec'
import { SelectImage } from '@/components'
import SelectGoods from '@/components/SelectGoods/SelectGoods.vue'
import * as GoodsApi from '@/api/goods'
export default {
components: {
SelectImage
SelectImage,
SelectGoods
},
props: {
//
@ -148,7 +160,8 @@ export default {
// SKU
defaultSkuList: PropTypes.array.def([]),
// ()
isSpecLocked: PropTypes.bool.def(false)
isSpecLocked: PropTypes.bool.def(false),
checkList: PropTypes.array.def([])
},
data () {
return {
@ -164,7 +177,8 @@ export default {
specList: [],
// SKU
skuList: []
}
},
visible: false
}
},
watch: {
@ -180,7 +194,6 @@ export default {
this.getData()
},
methods: {
// SKU()
getData () {
const { defaultSpecList, defaultSkuList } = this
@ -270,11 +283,37 @@ export default {
return false
}
return true
}
},
showModal () {
this.visible = true
},
async handleSelectGoods (goodsId, item) {
console.log(goodsId, item)
this.getGoodsDetail(goodsId).then(res => {
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
})
},
//
getGoodsDetail (goodsId = null) {
if (!goodsId) return false
return new Promise((resolve, reject) => {
GoodsApi.detail({ goodsId })
.then(result => {
resolve(result.data.goodsInfo)
})
})
}
}
}
</script>
<style lang="less" scoped>
//

Loading…
Cancel
Save