上架
- 下架下架
删除
@@ -121,22 +137,26 @@
class="cur-p"
:color="text == 10 ? 'green' : 'red'"
@click="handleUpdateStatus([item.goods_id], text != 10)"
- >{{ text == 10 ? '上架' : '下架' }}{{ text == 10 ? '上架' : '下架' }}
+
@@ -145,108 +165,109 @@ import * as GoodsApi from '@/api/goods'
import { ContentHeader, STable } from '@/components'
import CategoryModel from '@/common/model/Category'
import store from '../../store'
+import Update from './modules/Update'
// 表格表头
const columns = [
{
title: '商品ID',
dataIndex: 'goods_id',
width: '80px',
- sorter: true,
+ sorter: true
},
{
title: '渠道',
width: '50px',
- dataIndex: 'channel_name',
+ dataIndex: 'channel_name'
},
{
title: '商品编号',
dataIndex: 'goods_no',
- width: '100px',
+ width: '100px'
},
{
title: '商品图片',
width: '100px',
dataIndex: 'goods_image',
- scopedSlots: { customRender: 'goods_image' },
+ scopedSlots: { customRender: 'goods_image' }
},
{
title: '商品名称',
dataIndex: 'goods_name',
width: '260px',
- scopedSlots: { customRender: 'goods_name' },
+ scopedSlots: { customRender: 'goods_name' }
},
{
title: '商品价格',
width: '90px',
dataIndex: 'goods_price_min',
scopedSlots: { customRender: 'goods_price_min' },
- sorter: true,
+ sorter: true
},
{
title: '成本价',
width: '80px',
dataIndex: 'cost_price_min',
scopedSlots: { customRender: 'cost_price_min' },
- sorter: true,
+ sorter: true
},
{
title: '利润',
width: '80px',
dataIndex: 'profit',
- sorter: true,
+ sorter: true
},
{
title: '利润率',
width: '80px',
dataIndex: 'profit_rate',
sorter: true,
- scopedSlots: { customRender: 'profit_rate' },
+ scopedSlots: { customRender: 'profit_rate' }
},
{
title: '总销量',
width: '80px',
dataIndex: 'sales_actual',
- sorter: true,
+ sorter: true
},
{
title: '库存总量',
width: '90px',
dataIndex: 'stock_total',
- sorter: true,
+ sorter: true
},
{
title: '状态',
width: '60px',
dataIndex: 'status',
- scopedSlots: { customRender: 'status' },
+ scopedSlots: { customRender: 'status' }
},
{
title: '排序',
width: '80px',
dataIndex: 'sort',
- sorter: true,
+ sorter: true
},
{
title: '添加时间',
- width: '130px',
+ width: '150px',
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,
+ Update
},
- data() {
+ data () {
return {
// 当前表单元素
searchForm: this.$form.createForm(this),
@@ -256,7 +277,7 @@ export default {
queryParam: {
listType: 'all',
spec_type: '',
- channel: '',
+ channel: ''
},
// 正在加载
isLoading: false,
@@ -269,7 +290,7 @@ export default {
const data = { ...param, ...this.queryParam }
const orderEnum = {
ascend: 'asc',
- descend: 'desc',
+ descend: 'desc'
}
if (data.sortField && data.sortOrder && orderEnum[data.sortOrder]) {
@@ -288,40 +309,40 @@ export default {
specsType: [
{ name: '全部', val: '' },
{ name: '单规格', val: 10 },
- { name: '多规格', val: 20 },
+ { name: '多规格', val: 20 }
],
- checkList: [],
+ checkList: []
}
},
- created() {
+ created () {
// 默认的查询参数
if (this.$route.query.listType) {
this.queryParam.listType = this.$route.query.listType
}
// 获取商品分类列表
this.getCategoryList()
- this.getDataList() //渠道
+ this.getDataList() // 渠道
},
computed: {
- rowSelection() {
+ rowSelection () {
return {
selectedRowKeys: this.selectedRowKeys,
- onChange: this.onSelectChange,
+ onChange: this.onSelectChange
}
- },
+ }
},
methods: {
// 批量修改
- handleModify() {
+ handleModify () {
this.$router.push('/goods/modify')
},
// 导出
- handleExport(goodsIds) {
+ handleExport (goodsIds) {
const formData = this.searchForm.getFieldsValue()
this.isLoading = true
var index = window.publicConfig.BASE_API.indexOf('?')
var resolve = window.publicConfig.BASE_API.substring(0, index)
- let params =
+ const params =
'&goodsName=' +
(formData.goodsName || '') +
'&goodsNo=' +
@@ -345,10 +366,10 @@ export default {
console.log(params)
window.open(resolve + '?s=/admin/goods/export' + params)
},
- getChannel(val) {
+ getChannel (val) {
this.queryParam.channel = val
},
- getDataList() {
+ getDataList () {
return GoodsApi.getDataList().then((result) => {
const obj = result.data
Object.keys(obj).forEach((item) => {
@@ -356,22 +377,22 @@ export default {
})
})
},
- onchangeSpecs(val) {
+ onchangeSpecs (val) {
this.queryParam.spec_type = val
},
// 选中项发生变化时的回调
- 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) {
@@ -382,12 +403,12 @@ export default {
},
// 重置搜索表单
- handleReset() {
+ handleReset () {
this.searchForm.resetFields()
},
// 获取分类列表
- getCategoryList() {
+ getCategoryList () {
this.isLoading = true
CategoryModel.getListFromScreen()
.then((selectList) => {
@@ -397,7 +418,7 @@ export default {
},
// 修改商品状态(上下架)
- handleUpdateStatus(goodsIds, state = true) {
+ handleUpdateStatus (goodsIds, state = true) {
if (!this.$auth('/goods/index.status')) {
return false
}
@@ -414,29 +435,33 @@ export default {
},
// 删除记录
- 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())
- },
+ }
})
},
-
+ // 编辑记录
+ async handleEdit (id) {
+ // 显示对话框
+ this.$refs.UpdateRef.initData(id)
+ },
// 新增记录
- handleCreate() {
+ handleCreate () {
this.$router.push('/goods/create')
},
// 批量导入
- handleImport() {
+ handleImport () {
this.$router.push('/goods/import/batch')
},
@@ -444,11 +469,11 @@ export default {
* 刷新列表
* @param Boolean bool 强制刷新到第一页
*/
- handleRefresh(bool = false) {
+ handleRefresh (bool = false) {
this.selectedRowKeys = []
this.$refs.table.refresh(bool)
- },
- },
+ }
+ }
}