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

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

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

Loading…
Cancel
Save