|
|
|
@ -7,7 +7,14 @@ |
|
|
|
|
<a-form class="search-form" :form="searchForm" layout="inline" @submit="handleSearch"> |
|
|
|
|
<a-form-item label="渠道"> |
|
|
|
|
<a-select @change="getChannel" style="width: 120px" placeholder="请选择"> |
|
|
|
|
<a-select-option :value="item.id" v-for="(item) in checkList" :key="item.id"> |
|
|
|
|
<a-select-option :value="item.id" v-for="item in checkList" :key="item.id"> |
|
|
|
|
{{ item.name }} |
|
|
|
|
</a-select-option> |
|
|
|
|
</a-select> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item label="数据类型"> |
|
|
|
|
<a-select @change="getDataType" style="width: 120px" placeholder="请选择"> |
|
|
|
|
<a-select-option :value="item.val" v-for="item in dataType" :key="item.val"> |
|
|
|
|
{{ item.name }} |
|
|
|
|
</a-select-option> |
|
|
|
|
</a-select> |
|
|
|
@ -26,12 +33,50 @@ |
|
|
|
|
v-decorator="['categoryId', { initialValue: 0 }]" |
|
|
|
|
></a-tree-select> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item label="类型"> |
|
|
|
|
<a-select @change="getGoodsType" style="width: 120px" placeholder="请选择"> |
|
|
|
|
<a-select-option :value="item.val" v-for="item in goodsType" :key="item.val"> |
|
|
|
|
{{ item.name }} |
|
|
|
|
</a-select-option> |
|
|
|
|
</a-select> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item label="状态"> |
|
|
|
|
<a-select @change="getGoodsStarus" style="width: 120px" placeholder="请选择"> |
|
|
|
|
<a-select-option :value="item.val" v-for="item in goodsStatus" :key="item.val"> |
|
|
|
|
{{ item.name }} |
|
|
|
|
</a-select-option> |
|
|
|
|
</a-select> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item label="前台价"> |
|
|
|
|
<div style="display: flex" class="goodsType"> |
|
|
|
|
<a-input v-decorator="['goods_price_min']" placeholder="请输入" />- |
|
|
|
|
<a-input style="margin-left: 5px" v-decorator="['goods_price_max']" placeholder="请输入" /> |
|
|
|
|
</div> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item label="利润率"> |
|
|
|
|
<div style="display: flex" class="goodsType"> |
|
|
|
|
<a-input v-decorator="['profit_rate_min']" placeholder="请输入" />- |
|
|
|
|
<a-input style="margin-left: 5px" v-decorator="['profit_rate_max']" placeholder="请输入" /> |
|
|
|
|
</div> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item class="search-btn"> |
|
|
|
|
<a-button type="primary" icon="search" html-type="submit">搜索</a-button> |
|
|
|
|
</a-form-item> |
|
|
|
|
</a-form> |
|
|
|
|
</a-row> |
|
|
|
|
<!-- 操作板块 --> |
|
|
|
|
<a-modal v-model:visible="visible" title="商品分类" @ok="handleUpdateClassify(selectedRowKeys, categoryIds)"> |
|
|
|
|
<a-tree-select |
|
|
|
|
style="min-width: 400px" |
|
|
|
|
placeholder="请选择商品分类" |
|
|
|
|
:dropdownStyle="{ maxHeight: '500px', overflow: 'auto' }" |
|
|
|
|
:treeData="categoryListTree" |
|
|
|
|
treeCheckable |
|
|
|
|
treeCheckStrictly |
|
|
|
|
allowClear |
|
|
|
|
@change="onChangeCategory" |
|
|
|
|
></a-tree-select> |
|
|
|
|
</a-modal> |
|
|
|
|
<div class="row-item-tab clearfix"> |
|
|
|
|
<div class="tab-list fl-l"> |
|
|
|
|
<a-radio-group :defaultValue="queryParam.listType" @change="handleTabs"> |
|
|
|
@ -41,26 +86,25 @@ |
|
|
|
|
<a-radio-button value="sold_out">已售罄</a-radio-button> |
|
|
|
|
</a-radio-group> |
|
|
|
|
</div> |
|
|
|
|
<a-button |
|
|
|
|
class="fl-l" |
|
|
|
|
type="primary" |
|
|
|
|
icon="plus" |
|
|
|
|
@click="handleCreate()" |
|
|
|
|
>创建商品</a-button |
|
|
|
|
> |
|
|
|
|
<a-button |
|
|
|
|
class="fl-l" |
|
|
|
|
icon="arrow-up" |
|
|
|
|
@click="handleImport()" |
|
|
|
|
>批量导入</a-button |
|
|
|
|
> |
|
|
|
|
<a-button class="fl-l" type="primary" icon="plus" @click="handleCreate()">创建商品</a-button> |
|
|
|
|
<a-button class="fl-l" icon="arrow-up" @click="handleImport()">批量导入</a-button> |
|
|
|
|
<div v-if="selectedRowKeys.length" class="button-group"> |
|
|
|
|
<a-button-group class="ml-10"> |
|
|
|
|
<a-button icon="arrow-up" @click="handleUpdateStatus(selectedRowKeys, true)">上架</a-button> |
|
|
|
|
<a-button |
|
|
|
|
icon="arrow-up" |
|
|
|
|
style="background-color: red; color: #fff" |
|
|
|
|
@click="handleUpdateStatus(selectedRowKeys, 1)" |
|
|
|
|
>上架</a-button |
|
|
|
|
> |
|
|
|
|
<a-button |
|
|
|
|
icon="arrow-down" |
|
|
|
|
@click="handleUpdateStatus(selectedRowKeys, false)" |
|
|
|
|
>下架</a-button |
|
|
|
|
style="background-color: gray; color: #fff" |
|
|
|
|
@click="handleUpdateStatus(selectedRowKeys, 2)" |
|
|
|
|
>移除</a-button |
|
|
|
|
> |
|
|
|
|
<a-button style="background-color: green; color: #fff" @click="visible = true">归类</a-button> |
|
|
|
|
<a-button style="background-color: blue; color: #fff" @click="handleUpdateSales(selectedRowKeys, false)" |
|
|
|
|
>停售</a-button |
|
|
|
|
> |
|
|
|
|
<a-button icon="delete" @click="handleDelete(selectedRowKeys)">删除</a-button> |
|
|
|
|
</a-button-group> |
|
|
|
@ -92,19 +136,13 @@ |
|
|
|
|
class="cur-p" |
|
|
|
|
:color="text == 10 ? 'green' : 'red'" |
|
|
|
|
@click="handleUpdateStatus([item.goods_id], text != 10)" |
|
|
|
|
>{{ text == 10 ? '上架' : '下架' }}</a-tag |
|
|
|
|
>{{ text == 10 ? '上架' : '下架' }}</a-tag |
|
|
|
|
> |
|
|
|
|
</span> |
|
|
|
|
<!-- 操作项 --> |
|
|
|
|
<div class="actions" slot="action" slot-scope="text, item"> |
|
|
|
|
<router-link |
|
|
|
|
:to="{ path: '/goods/update', query: { goodsId: item.goods_id } }" |
|
|
|
|
>编辑</router-link |
|
|
|
|
> |
|
|
|
|
<router-link |
|
|
|
|
:to="{ path: '/goods/copy', query: { goodsId: item.goods_id } }" |
|
|
|
|
>复制</router-link |
|
|
|
|
> |
|
|
|
|
<router-link :to="{ path: '/goods/update', query: { goodsId: item.goods_id } }">编辑</router-link> |
|
|
|
|
<router-link :to="{ path: '/goods/copy', query: { goodsId: item.goods_id } }">复制</router-link> |
|
|
|
|
<a @click="handleDelete([item.goods_id])">删除</a> |
|
|
|
|
</div> |
|
|
|
|
</s-table> |
|
|
|
@ -115,79 +153,80 @@ |
|
|
|
|
import * as GoodsApi from '@/api/goods' |
|
|
|
|
import { ContentHeader, STable } from '@/components' |
|
|
|
|
import CategoryModel from '@/common/model/Category' |
|
|
|
|
import * as Api from '@/api/store' |
|
|
|
|
import * as Api from '@/api/store' |
|
|
|
|
|
|
|
|
|
// 表格表头 |
|
|
|
|
const columns = [ |
|
|
|
|
{ |
|
|
|
|
title: '商品ID', |
|
|
|
|
dataIndex: 'goods_id', |
|
|
|
|
sorter: true |
|
|
|
|
sorter: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '渠道', |
|
|
|
|
dataIndex: 'channel_name', |
|
|
|
|
width: '60px' |
|
|
|
|
width: '60px', |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '商品图片', |
|
|
|
|
dataIndex: 'goods_image', |
|
|
|
|
scopedSlots: { customRender: 'goods_image' } |
|
|
|
|
scopedSlots: { customRender: 'goods_image' }, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '商品名称', |
|
|
|
|
dataIndex: 'goods_name', |
|
|
|
|
width: '270px', |
|
|
|
|
scopedSlots: { customRender: 'goods_name' } |
|
|
|
|
scopedSlots: { customRender: 'goods_name' }, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '商品价格', |
|
|
|
|
dataIndex: 'goods_price_min', |
|
|
|
|
scopedSlots: { customRender: 'goods_price_min' }, |
|
|
|
|
sorter: true |
|
|
|
|
sorter: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '商品利润', |
|
|
|
|
dataIndex: 'profit', |
|
|
|
|
sorter: true |
|
|
|
|
sorter: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '商品利润率', |
|
|
|
|
dataIndex: 'profit_rate', |
|
|
|
|
sorter: true |
|
|
|
|
sorter: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '库存总量', |
|
|
|
|
dataIndex: 'stock_total', |
|
|
|
|
sorter: true |
|
|
|
|
sorter: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '状态', |
|
|
|
|
dataIndex: 'status', |
|
|
|
|
scopedSlots: { customRender: 'status' } |
|
|
|
|
scopedSlots: { customRender: 'status' }, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '添加时间', |
|
|
|
|
width: '180px', |
|
|
|
|
dataIndex: 'create_time', |
|
|
|
|
sorter: true |
|
|
|
|
sorter: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '操作', |
|
|
|
|
dataIndex: 'action', |
|
|
|
|
width: '150px', |
|
|
|
|
scopedSlots: { customRender: 'action' } |
|
|
|
|
} |
|
|
|
|
scopedSlots: { customRender: 'action' }, |
|
|
|
|
}, |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
name: 'Index', |
|
|
|
|
components: { |
|
|
|
|
ContentHeader, |
|
|
|
|
STable |
|
|
|
|
STable, |
|
|
|
|
}, |
|
|
|
|
data () { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
visible: false, |
|
|
|
|
// 当前表单元素 |
|
|
|
|
searchForm: this.$form.createForm(this), |
|
|
|
|
// 商品分类列表 |
|
|
|
@ -195,7 +234,10 @@ export default { |
|
|
|
|
// 查询参数 |
|
|
|
|
queryParam: { |
|
|
|
|
listType: 'all', |
|
|
|
|
channel: '' |
|
|
|
|
channel: '', |
|
|
|
|
is_self: '', |
|
|
|
|
is_pool: '', |
|
|
|
|
date_type: '', |
|
|
|
|
}, |
|
|
|
|
// 正在加载 |
|
|
|
|
isLoading: false, |
|
|
|
@ -208,7 +250,7 @@ export default { |
|
|
|
|
const data = { ...param, ...this.queryParam } |
|
|
|
|
const orderEnum = { |
|
|
|
|
ascend: 'asc', |
|
|
|
|
descend: 'desc' |
|
|
|
|
descend: 'desc', |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (data.sortField && data.sortOrder && orderEnum[data.sortOrder]) { |
|
|
|
@ -226,10 +268,26 @@ export default { |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
checkList: [] |
|
|
|
|
checkList: [], |
|
|
|
|
goodsType: [ |
|
|
|
|
{ name: '自营', val: 1 }, |
|
|
|
|
{ name: 'POP', val: 2 }, |
|
|
|
|
{ name: '其他', val: 0 }, |
|
|
|
|
], |
|
|
|
|
goodsStatus: [ |
|
|
|
|
{ name: '待处理', val: 0 }, |
|
|
|
|
{ name: '已入池', val: 1 }, |
|
|
|
|
{ name: '未入池', val: 2 }, |
|
|
|
|
], |
|
|
|
|
dataType: [ |
|
|
|
|
{ name: 'API数据', val: 0 }, |
|
|
|
|
{ name: '人工数据', val: 1 }, |
|
|
|
|
{ name: '商品池', val: 2 }, |
|
|
|
|
], |
|
|
|
|
categoryIds: [], |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
created () { |
|
|
|
|
created() { |
|
|
|
|
this.getDataList() |
|
|
|
|
|
|
|
|
|
// 默认的查询参数 |
|
|
|
@ -240,27 +298,27 @@ export default { |
|
|
|
|
this.getCategoryList() |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
|
rowSelection () { |
|
|
|
|
rowSelection() { |
|
|
|
|
return { |
|
|
|
|
selectedRowKeys: this.selectedRowKeys, |
|
|
|
|
onChange: this.onSelectChange |
|
|
|
|
onChange: this.onSelectChange, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 选中项发生变化时的回调 |
|
|
|
|
onSelectChange (selectedRowKeys) { |
|
|
|
|
onSelectChange(selectedRowKeys) { |
|
|
|
|
this.selectedRowKeys = selectedRowKeys |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 切换tab |
|
|
|
|
handleTabs (e) { |
|
|
|
|
handleTabs(e) { |
|
|
|
|
this.queryParam.listType = e.target.value |
|
|
|
|
this.handleRefresh(true) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 确认搜索 |
|
|
|
|
handleSearch (e) { |
|
|
|
|
handleSearch(e) { |
|
|
|
|
e.preventDefault() |
|
|
|
|
this.searchForm.validateFields((error, values) => { |
|
|
|
|
if (!error) { |
|
|
|
@ -271,25 +329,33 @@ export default { |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 重置搜索表单 |
|
|
|
|
handleReset () { |
|
|
|
|
handleReset() { |
|
|
|
|
this.searchForm.resetFields() |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getDataList () { |
|
|
|
|
return Api.getDataList().then(result => { |
|
|
|
|
getDataList() { |
|
|
|
|
return Api.getDataList().then((result) => { |
|
|
|
|
const obj = result.data |
|
|
|
|
Object.keys(obj).forEach(item => { |
|
|
|
|
this.checkList.push({ id: item, name: obj[item] }) |
|
|
|
|
Object.keys(obj).forEach((item) => { |
|
|
|
|
this.checkList.push({ id: item, name: obj[item] }) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getChannel (val) { |
|
|
|
|
getChannel(val) { |
|
|
|
|
this.queryParam.channel = val |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getDataType(val) { |
|
|
|
|
this.queryParam.date_type = val |
|
|
|
|
}, |
|
|
|
|
getGoodsType(val) { |
|
|
|
|
this.queryParam.is_self = val |
|
|
|
|
}, |
|
|
|
|
getGoodsStarus(val) { |
|
|
|
|
this.queryParam.is_pool = val |
|
|
|
|
}, |
|
|
|
|
// 获取分类列表 |
|
|
|
|
getCategoryList () { |
|
|
|
|
getCategoryList() { |
|
|
|
|
this.isLoading = true |
|
|
|
|
CategoryModel.getListFromScreen() |
|
|
|
|
.then((selectList) => { |
|
|
|
@ -299,9 +365,9 @@ export default { |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 修改商品状态(上下架) |
|
|
|
|
handleUpdateStatus (goodsIds, state = true) { |
|
|
|
|
handleUpdateStatus(goodsIds, is_pool) { |
|
|
|
|
this.isLoading = true |
|
|
|
|
GoodsApi.state({ goodsIds, state }) |
|
|
|
|
GoodsApi.state({ goodsIds, is_pool }) |
|
|
|
|
.then((result) => { |
|
|
|
|
// 显示成功 |
|
|
|
|
this.$message.success(result.message, 1.5) |
|
|
|
@ -311,31 +377,57 @@ export default { |
|
|
|
|
this.isLoading = false |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 归类 |
|
|
|
|
onChangeCategory(list) { |
|
|
|
|
this.categoryIds = [] |
|
|
|
|
list.forEach((item) => { |
|
|
|
|
this.categoryIds.push(item.value) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
handleUpdateClassify(goodsIds, categoryIds) { |
|
|
|
|
console.log(goodsIds, categoryIds) |
|
|
|
|
if (categoryIds.length == 0) { |
|
|
|
|
this.$message.warn('请至少选择1个商品分类', 1.5) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
return |
|
|
|
|
this.isLoading = true |
|
|
|
|
GoodsApi.state({ goodsIds, categoryIds }) |
|
|
|
|
.then((result) => { |
|
|
|
|
// 显示成功 |
|
|
|
|
this.$message.success(result.message, 1.5) |
|
|
|
|
this.handleRefresh() |
|
|
|
|
}) |
|
|
|
|
.finally((result) => { |
|
|
|
|
this.isLoading = false |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 停售 |
|
|
|
|
handleUpdateSales() {}, |
|
|
|
|
// 删除记录 |
|
|
|
|
handleDelete (goodsIds) { |
|
|
|
|
handleDelete(goodsIds) { |
|
|
|
|
const app = this |
|
|
|
|
const modal = this.$confirm({ |
|
|
|
|
title: '您确定要删除该记录吗?', |
|
|
|
|
content: '删除后不可恢复', |
|
|
|
|
onOk () { |
|
|
|
|
onOk() { |
|
|
|
|
return GoodsApi.deleted({ goodsIds }) |
|
|
|
|
.then((result) => { |
|
|
|
|
app.$message.success(result.message, 1.5) |
|
|
|
|
app.handleRefresh() |
|
|
|
|
}) |
|
|
|
|
.finally((result) => modal.destroy()) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 新增记录 |
|
|
|
|
handleCreate () { |
|
|
|
|
handleCreate() { |
|
|
|
|
this.$router.push('/goods/create') |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 批量导入 |
|
|
|
|
handleImport () { |
|
|
|
|
handleImport() { |
|
|
|
|
this.$router.push('/goods/import/batch') |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -343,11 +435,11 @@ export default { |
|
|
|
|
* 刷新列表 |
|
|
|
|
* @param Boolean bool 强制刷新到第一页 |
|
|
|
|
*/ |
|
|
|
|
handleRefresh (bool = false) { |
|
|
|
|
handleRefresh(bool = false) { |
|
|
|
|
this.selectedRowKeys = [] |
|
|
|
|
this.$refs.table.refresh(bool) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
<style lang="less" scoped> |
|
|
|
@ -365,4 +457,11 @@ export default { |
|
|
|
|
align-items: center; |
|
|
|
|
margin-top: 10px; |
|
|
|
|
} |
|
|
|
|
.goodsType { |
|
|
|
|
display: flex; |
|
|
|
|
input { |
|
|
|
|
width: 100px; |
|
|
|
|
margin-right: 5px; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|