Commit b16f1275 by cwq0219

提交

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