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

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

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

Loading…
Cancel
Save