feature/0423
wanghousheng 8 months ago
parent 885fc3b8af
commit 5a384fd335
  1. 77
      src/components/SelectGoods/SelectGoods.vue
  2. 7
      src/views/recovery/order/Index.vue

@ -1,6 +1,31 @@
<template>
<div>
<a-button @click="handleSelectGoods">选择商品</a-button>
<a-table
v-show="selectedItems.length"
class="table-goodsList"
rowKey="goods_id"
:columns="columns"
: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}`,
}"
:subTitleColor="true"
/>
</template>
<!-- 操作项 -->
<span slot="action" slot-scope="text, item, index">
<a v-action:delete @click="handleDeleteItem(index)">删除</a>
</span>
</a-table>
<GoodsModal
ref="GoodsModal"
:multiple="multiple"
@ -15,37 +40,39 @@
import PropTypes from 'ant-design-vue/es/_util/vue-types'
import cloneDeep from 'lodash.clonedeep'
import { GoodsModal } from '@/components/Modal'
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' },
},
]
//
export default {
name: 'SelectGoods',
components: {
GoodsModal
GoodsModal,
GoodsItem,
},
model: {
prop: 'value',
event: 'change'
event: 'change',
},
props: {
// , false
@ -53,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: {
@ -69,24 +96,22 @@ 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]
@ -97,32 +122,30 @@ 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)
this.$emit('select', multiple ? this.selectedItems : this.selectedItems[0])
const sGoodsIds = multiple ? selectedGoodsIds : selectedGoodsIds.length ? selectedGoodsIds[0] : undefined
return this.$emit('change', sGoodsIds)
}
}
},
},
}
</script>

@ -116,9 +116,14 @@ const columns = [
},
{
title: '期待价格',
width: '180px',
width: '100px',
dataIndex: 'expect_price',
},
{
title: '实际回收价',
width: '100px',
dataIndex: 'real_price',
},
{
title: '添加时间',
width: '180px',

Loading…
Cancel
Save