Commit 7c59048c by cwq0219

商品管理-导出

1 parent 4f64e075
...@@ -108,8 +108,7 @@ ...@@ -108,8 +108,7 @@
<script> <script>
import { getList, exportBaseList } from '@api/commodity' import { getList, exportBaseList } from '@api/commodity'
import { BaseData } from '@/common/constants.js' import { BaseData } from '@/common/constants.js'
import Blob from '@/common/Blob.js' import { export_json_to_excel } from '@/common/Export2Excel.js'
import Export2Excel from '@/common/Export2Excel.js'
import { mapActions } from 'vuex' import { mapActions } from 'vuex'
import _ from 'lodash' import _ from 'lodash'
import storeDetail from './storeDetail' import storeDetail from './storeDetail'
...@@ -153,7 +152,7 @@ export default { ...@@ -153,7 +152,7 @@ export default {
prop: 'brandMerchantName' prop: 'brandMerchantName'
}, { }, {
label: '属性', label: '属性',
prop: 'attr' prop: 'attribute'
}, { }, {
label: '关联商品数', label: '关联商品数',
prop: 'upgradeGoodsNum' prop: 'upgradeGoodsNum'
...@@ -162,12 +161,13 @@ export default { ...@@ -162,12 +161,13 @@ export default {
prop: 'merchantNum' prop: 'merchantNum'
}, { }, {
label: '产品状态', label: '产品状态',
prop: 'state', prop: 'goodsStatus',
formatter: (cellValue) => { formatter: (cellValue) => {
return { // return {
0: '上架', // 0: '上架',
1: '下架' // 1: '下架'
}[cellValue.state] // }[cellValue.state]
return '上架'
} }
}, { }, {
label: '创建时间', label: '创建时间',
...@@ -223,13 +223,19 @@ export default { ...@@ -223,13 +223,19 @@ export default {
}) })
}, },
handleExport() { handleExport() {
const tHeader = ['商品ID', '商品名称', '分类', '品牌商'] const tHeader = ['商品ID', '商品名称', '分类', '品牌商', '属性', '关联商品数', '关联商户数', '产品状态', '创建时间']
const fieldVal = ['goodsCode', 'goodsName', 'goodsTypeName', 'brandMerchantName'] const fieldVal = ['goodsCode', 'goodsName', 'goodsTypeName', 'brandMerchantName', 'attribute', 'upgradeGoodsNum', 'merchantNum', 'goodsStatus', 'createdDate']
exportBaseList(this.searchForm).then(res => { exportBaseList(this.searchForm).then(res => {
console.log(res) // console.log(res)
// const exportData = this. require.ensure([], () => {
const data = this.formatJson(fieldVal, res)
export_json_to_excel(tHeader, data, '基础商品列表')
})
}) })
}, },
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => v[j]))
},
handleEdit(row) { handleEdit(row) {
this.$router.push({ this.$router.push({
name: 'editCommodity', name: 'editCommodity',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!