Commit b16f1275 by cwq0219

提交

1 parent 15dfa52d
<!-- 产品管理 -->
<!-- 商品管理 -->
<template>
<d2-container class="product">
<d2-container class="commodity">
<el-form
:inline="true"
v-model="searchForm"
label-width="85px"
slot="header"
>
<el-form-item label="产品名称">
<el-form-item label="商品名称">
<el-input
v-model="searchForm.goodsName"
placeholder="请输入产品名称"
placeholder="请输入商品名称"
clearable
></el-input>
</el-form-item>
......@@ -57,7 +57,8 @@
></auth-button>
</d2-table-header>
<d2-table
ref="productTable"
ref="commodityTable"
:hasNum="false"
:searchForm="searchForm"
:tableParams="tableParams"
:getListApi="getListApi"
......@@ -70,21 +71,52 @@
:src="scope.scope.goodsInfo.thumbUrl"
/>
<auth-button
v-if="Object.keys(scope.scope).includes('upgradeGoodsList')"
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
></auth-button>
<!-- <auth-button
v-if="Object.keys(scope.scope).includes('upgradeGoodsList')"
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
></auth-button>
<el-button
v-else
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
type="text"
@click="handleUpOrDown"
>{{scope.scope.state ? '上架' : '下架'}}</el-button> -->
</d2-table>
<d2-dialog
title="门店列表"
:className="storeDetail"
:isVisible.sync="detailVisible"
:showClose="showClose"
noCancel="true"
@closeDialog="handleDetailClose"
@confirmDialog="handleDetailClose"
>
<store-detail
v-if="detailVisible"
:detailData="detailData"
></store-detail>
</d2-dialog>
</d2-container>
</template>
<script>
import { getList } from '@api/product'
import { getList, exportBaseList } from '@api/commodity'
import { BaseData, brandMerchantList } from '@/common/constants.js'
import { export_json_to_excel } from '@/common/Export2Excel.js'
import { mapActions } from 'vuex'
import _ from 'lodash'
import storeDetail from './storeDetail'
export default {
name: 'product',
name: 'commodity',
data() {
return {
searchForm: {
......@@ -98,31 +130,45 @@ export default {
getListApi: getList,
// 表格参数
tableParams: {
needUnique: true,
mutiSelectUniqueKey: 'uniqueVal',
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: true,
tableColumns: [{
label: '缩略图',
prop: 'thumbUrl',
label: '序号',
prop: 'index'
}, {
label: '商品ID',
prop: 'goodsCode'
}, {
label: '商品图片',
prop: 'img',
addHtml: 'img'
}, {
label: '产品名称',
label: '商品名称',
parentProp: 'goodsInfo',
prop: 'goodsName'
}, {
label: '产品ID',
prop: 'id'
}, {
label: '分类',
parentProp: 'goodsInfo',
prop: 'goodsTypeName'
}, {
label: '品牌商',
parentProp: 'goodsInfo',
prop: 'brandMerchantName'
}, {
label: '创建时间',
prop: 'createDateStr'
label: '属性',
prop: 'attribute'
}, {
label: '关联商品数',
prop: 'upgradeGoodsNum'
}, {
label: '关联商户数',
prop: 'merchantNum'
}, {
label: '产品状态',
prop: 'state',
prop: 'goodsStatus',
formatter: (cellValue) => {
// return {
// 0: '上架',
......@@ -130,8 +176,14 @@ export default {
// }[cellValue.state]
return '上架'
}
}, {
label: '创建时间',
prop: 'createDateStr'
}]
},
// 查看门店
detailVisible: false,
showClose: false,
// 基本数据
baseData: {
goodsType: [],
......@@ -140,6 +192,10 @@ export default {
}
},
components: {
storeDetail
},
mounted() {
this.getBaseData()
this.baseData.brandList = _.cloneDeep(brandMerchantList)
......@@ -170,28 +226,49 @@ export default {
},
handleAdd(form) {
this.$router.push({
name: 'editproduct',
name: 'editCommodity',
params: {
addOrEdit: 'add',
form: form
}
})
},
handleExport() {
const tHeader = ['序号', '商品ID', '商品名称', '分类', '品牌商', '属性', '关联商品数', '关联商户数', '产品状态', '创建时间']
const fieldVal = ['index', 'goodsCode', 'goodsName', 'goodsTypeName', 'brandMerchantName', 'attribute', 'upgradeGoodsNum', 'merchantNum', 'goodsStatus', 'createdDate']
exportBaseList(this.searchForm).then(res => {
// console.log(res)
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) {
this.$router.push({
name: 'editproduct',
name: 'editCommodity',
params: {
addOrEdit: 'edit',
row: row
}
})
},
handleDetail(row) {
this.detailData = _.cloneDeep(row)
this.detailVisible = true
},
handleDetailClose() {
this.detailVisible = false
}
}
}
</script>
<style scoped>
.product .pro-img {
.commodity .pro-img {
width: 80px;
height: 80px;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!