main
fanfan 6 months ago
parent 7ba5457985
commit a4cd9ab34d
  1. 82
      src/components/Modal/GoodsModal/GoodsModal.vue
  2. 1
      src/views/goods/modules/Update.vue

@ -47,7 +47,7 @@
image: item.goods_image,
imageAlt: '商品图片',
title: item.goods_name,
subtitle: `¥${item.goods_price_min}`
subtitle: `¥${item.goods_price_min}`,
}"
:subTitleColor="true"
/>
@ -71,27 +71,27 @@ import { STable, GoodsItem } from '@/components/Table'
const columns = [
{
title: '商品ID',
dataIndex: 'goods_id'
dataIndex: 'goods_id',
},
{
title: '商品信息',
width: '335px',
scopedSlots: { customRender: 'item' }
scopedSlots: { customRender: 'item' },
},
{
title: '商品价格',
dataIndex: 'goods_price_min',
scopedSlots: { customRender: 'goods_price_min' }
scopedSlots: { customRender: 'goods_price_min' },
},
{
title: '库存总量',
dataIndex: 'stock_total'
dataIndex: 'stock_total',
},
{
title: '状态',
dataIndex: 'status',
scopedSlots: { customRender: 'status' }
}
scopedSlots: { customRender: 'status' },
},
]
export default {
@ -102,13 +102,13 @@ export default {
// , multiple
maxNum: PropTypes.integer.def(100),
//
defaultList: PropTypes.array.def([])
defaultList: PropTypes.array.def([]),
},
components: {
STable,
GoodsItem
GoodsItem,
},
data () {
data() {
return {
//
title: '商品库',
@ -119,15 +119,17 @@ export default {
//
searchForm: this.$form.createForm(this),
//
queryParam: {},
queryParam: {
channel: 'zy',
status: 10,
},
// table
columns,
// Promise
loadData: param => {
return GoodsApi.list({ ...param, ...this.queryParam })
.then(response => {
return response.data.list
})
loadData: (param) => {
return GoodsApi.list({ ...param, ...this.queryParam }).then((response) => {
return response.data.list
})
},
// ID
fieldName: 'goods_id',
@ -136,26 +138,25 @@ export default {
//
selectedItems: [],
//
categoryListTree: []
categoryListTree: [],
}
},
computed: {
rowSelection () {
rowSelection() {
return {
selectedRowKeys: this.selectedRowKeys,
onChange: this.onSelectChange,
type: !this.multiple ? 'radio' : 'checkbox'
type: !this.multiple ? 'radio' : 'checkbox',
}
}
},
},
created () {
created() {
//
this.getCategoryList()
},
methods: {
//
handle () {
handle() {
//
this.visible = true
this.$nextTick(() => {
@ -167,24 +168,24 @@ export default {
},
//
setDefaultValue () {
setDefaultValue() {
const { fieldName, defaultList } = this
if (defaultList.length) {
this.selectedItems = cloneDeep(defaultList)
this.selectedRowKeys = defaultList.map(item => item[fieldName])
this.selectedRowKeys = defaultList.map((item) => item[fieldName])
}
},
//
getCategoryList () {
getCategoryList() {
this.isLoading = true
CategoryModel.getListFromScreen()
.then(selectList => this.categoryListTree = selectList)
.finally(() => this.isLoading = false)
.then((selectList) => (this.categoryListTree = selectList))
.finally(() => (this.isLoading = false))
},
//
onSelectChange (selectedRowKeys, newSelectedItems) {
onSelectChange(selectedRowKeys, newSelectedItems) {
const { selectedItems } = this
this.selectedRowKeys = selectedRowKeys
this.selectedItems = this.createSelectedItems(selectedRowKeys, selectedItems, newSelectedItems)
@ -196,16 +197,16 @@ export default {
* @param array oldSelectedItems 已选择的列表记录 (change前)
* @param array newSelectedItems 已选择的列表记录 (change后)
*/
createSelectedItems (selectedRowKeys, oldSelectedItems, newSelectedItems) {
createSelectedItems(selectedRowKeys, oldSelectedItems, newSelectedItems) {
const { fieldName } = this
const selectedItems = []
oldSelectedItems.forEach(item => {
oldSelectedItems.forEach((item) => {
if (selectedRowKeys.includes(item[fieldName])) {
selectedItems.push(item)
}
})
const oldSelectedKeys = oldSelectedItems.map(item => item[fieldName])
newSelectedItems.forEach(item => {
const oldSelectedKeys = oldSelectedItems.map((item) => item[fieldName])
newSelectedItems.forEach((item) => {
if (!oldSelectedKeys.includes(item[fieldName]) && selectedRowKeys.includes(item[fieldName])) {
selectedItems.push(item)
}
@ -217,12 +218,12 @@ export default {
* 刷新列表
* @param Boolean bool 强制刷新到第一页
*/
handleRefresh (bool = false) {
handleRefresh(bool = false) {
this.$refs.table.refresh(true)
},
//
handleSearch (e) {
handleSearch(e) {
e.preventDefault()
this.searchForm.validateFields((error, values) => {
if (!error) {
@ -233,7 +234,7 @@ export default {
},
//
handleCancel () {
handleCancel() {
this.visible = false
this.queryParam = {}
this.searchForm.resetFields()
@ -242,18 +243,17 @@ export default {
},
//
handleSubmit (e) {
handleSubmit(e) {
e.preventDefault()
//
this.$emit('handleSubmit', {
selectedItems: this.selectedItems,
selectedRowKeys: this.selectedRowKeys
selectedRowKeys: this.selectedRowKeys,
})
//
this.handleCancel()
}
}
},
},
}
</script>

@ -639,6 +639,7 @@ export default {
// form
this.isLoading = true
GoodsModel.getFromData(this.goodsId).then(() => {
this.formData.goods.goods_images = []
//
if (!isEmptyObject(this.form.getFieldsValue())) {
//

Loading…
Cancel
Save