feature/0423
wanghousheng 10 months ago
parent 95eab50c6e
commit c9fa00edec
  1. 57
      src/components/SelectGoods/SelectGoods.vue
  2. 2
      src/views/apps/sharp/goods/Create.vue
  3. 31
      src/views/store/Setting.vue

@ -1,7 +1,7 @@
<template>
<div>
<a-button @click="handleSelectGoods">选择商品</a-button>
<!-- <a-table
<a-table
v-show="selectedItems.length"
class="table-goodsList"
rowKey="goods_id"
@ -9,21 +9,23 @@
:dataSource="selectedItems"
:pagination="false"
>
<!-- 商品信息 -->
<template slot="item" slot-scope="item">
<GoodsItem
:data="{
image: item.goods_image,
imageAlt: '商品图片',
title: item.goods_name,
subtitle: `¥${item.goods_price_min}`,
subtitle: `¥${item.goods_price_min}`
}"
:subTitleColor="true"
/>
</template>
<!-- 操作项 -->
<span slot="action" slot-scope="text, item, index">
<a v-action:delete @click="handleDeleteItem(index)">删除</a>
</span>
</a-table> -->
</a-table>
<GoodsModal
ref="GoodsModal"
:multiple="multiple"
@ -43,22 +45,22 @@ import { GoodsItem } from '@/components/Table'
const columns = [
{
title: '商品ID',
dataIndex: 'goods_id',
dataIndex: 'goods_id'
},
{
title: '商品信息',
scopedSlots: { customRender: 'item' },
scopedSlots: { customRender: 'item' }
},
{
title: '库存总量',
dataIndex: 'stock_total',
dataIndex: 'stock_total'
},
{
title: '操作',
width: '180px',
dataIndex: 'action',
scopedSlots: { customRender: 'action' },
},
scopedSlots: { customRender: 'action' }
}
]
//
@ -66,11 +68,11 @@ export default {
name: 'SelectGoods',
components: {
GoodsModal,
GoodsItem,
GoodsItem
},
model: {
prop: 'value',
event: 'change',
event: 'change'
},
props: {
// , false
@ -78,15 +80,15 @@ export default {
// , multiple
maxNum: PropTypes.integer.def(100),
//
defaultList: PropTypes.array.def([]),
defaultList: PropTypes.array.def([])
},
data() {
data () {
return {
columns,
//
selectedItems: [],
// ID
selectedGoodsIds: [],
selectedGoodsIds: []
}
},
watch: {
@ -94,22 +96,24 @@ export default {
defaultList: {
//
immediate: true,
handler(val) {
handler (val) {
const { selectedItems } = this
if (val.length && !selectedItems.length) {
this.onUpdate(cloneDeep(val))
}
},
},
}
}
},
created () {
},
created() {},
methods: {
//
onUpdate(selectedItems) {
onUpdate (selectedItems) {
if (this.multiple || !selectedItems.length) {
//
this.selectedItems = selectedItems
this.selectedGoodsIds = selectedItems.map((item) => item.goods_id)
this.selectedGoodsIds = selectedItems.map(item => item.goods_id)
} else {
//
const single = selectedItems[selectedItems.length - 1]
@ -120,30 +124,31 @@ export default {
},
//
handleSelectGoods() {
handleSelectGoods () {
this.$refs.GoodsModal.handle()
},
// modal
handleSelectGoodsSubmit(result) {
handleSelectGoodsSubmit (result) {
const { selectedItems } = result
this.onUpdate(cloneDeep(selectedItems))
},
//
handleDeleteItem(index) {
handleDeleteItem (index) {
const { selectedItems } = this
selectedItems.splice(index, 1)
this.onUpdate(selectedItems)
},
// change
onChange() {
onChange () {
const { multiple, selectedGoodsIds } = this
const sGoodsIds = multiple ? selectedGoodsIds : selectedGoodsIds.length ? selectedGoodsIds[0] : undefined
const sGoodsIds = multiple ? selectedGoodsIds : (selectedGoodsIds.length ? selectedGoodsIds[0] : undefined)
return this.$emit('change', sGoodsIds)
},
},
}
}
}
</script>

@ -58,9 +58,7 @@
</template>
<script>
import { pick, get } from 'lodash'
import * as Api from '@/api/sharp/goods'
import { isEmpty } from '@/utils/util'
import { SelectGoods } from '@/components'
import { MultiSpec } from './modules'

@ -48,12 +48,35 @@
extra="建议尺寸: 300*300"
>
<SelectImage
multiple
:defaultList="record.bigBrandImg ? record.bigBrandImg : []"
v-decorator="['big_brand_img_id']"
/>
</a-form-item>
<a-form-item
label="秒杀背景图"
:labelCol="labelCol"
:wrapperCol="wrapperCol"
extra="建议尺寸: 300*300"
>
<SelectImage
multiple
:defaultList="record.flashSaleImg ? record.flashSaleImg : []"
v-decorator="['flash_sale_img_id']"
/>
</a-form-item>
<!-- <a-form-item
label="排行榜背景图"
:labelCol="labelCol"
:wrapperCol="wrapperCol"
extra="建议尺寸: 300*300"
>
<SelectImage
multiple
:defaultList="record.rankingImg ? record.rankingImg : []"
v-decorator="['ranking_img_id']"
/>
</a-form-item> -->
<!-- <a-form-item
label="新人首单"
:labelCol="labelCol"
:wrapperCol="wrapperCol"
@ -64,7 +87,7 @@
:defaultList="record.newPeopleOrderImg ? record.newPeopleOrderImg : []"
v-decorator="['new_people_order_img_id']"
/>
</a-form-item>
</a-form-item> -->
<a-form-item :wrapperCol="{ span: wrapperCol.span, offset: labelCol.span }">
<a-button type="primary" html-type="submit">提交</a-button>
</a-form-item>
@ -142,7 +165,9 @@ export default {
const params = {
new_product_img_id: (values.new_product_img_id && values.new_product_img_id.join(',')) || '',
big_brand_img_id: (values.big_brand_img_id && values.big_brand_img_id.join(',')) || '',
new_people_order_img_id: (values.new_people_order_img_id && values.new_people_order_img_id.join(',')) || ''
new_people_order_img_id: (values.new_people_order_img_id && values.new_people_order_img_id.join(',')) || '',
flash_sale_img_id: (values.flash_sale_img_id && values.flash_sale_img_id.join(',')) || '',
ranking_img_id: (values.ranking_img_id && values.ranking_img_id.join(',')) || ''
}
Api.update({ form: { ...values, ...params } })

Loading…
Cancel
Save