|
|
@ -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,15 +119,17 @@ 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 |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
// 主键ID字段名 |
|
|
|
// 主键ID字段名 |
|
|
|
fieldName: 'goods_id', |
|
|
|
fieldName: 'goods_id', |
|
|
@ -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> |
|
|
|
|
|
|
|
|
|
|
|