commodity.vue
6.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<!-- 商品管理 -->
<template>
<d2-container class="commodity">
<el-form
:inline="true"
v-model="searchForm"
label-width="85px"
slot="header"
>
<el-form-item label="商品名称">
<el-input
v-model="searchForm.goodsName"
placeholder="请输入商品名称"
clearable
></el-input>
</el-form-item>
<el-form-item label="分类">
<el-select
v-model="searchForm.goodsType"
placeholder="请选择产品分类"
clearable
>
<el-option
v-for="item in baseData.goodsType"
:key="item.goodsType"
:label="item.goodsTypeName"
:value="item.goodsType"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="品牌商">
<el-select
v-model="searchForm.brandMerchantCode"
placeholder="请选择品牌商"
>
<el-option
v-for="item in baseData.brandList"
:key="item.confId"
:label="item.confKey"
:value="item.confId"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button
:id="tableParams.btnId"
type="primary"
icon="el-icon-search"
>查询</el-button>
<el-button @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
<d2-table-header>
<auth-button
category="Button"
:data="editFormReset"
></auth-button>
</d2-table-header>
<d2-table
ref="commodityTable"
:hasNum="false"
:searchForm="searchForm"
:tableParams="tableParams"
:getListApi="getListApi"
:beforeSearchFn="beforeSearchFn"
>
<img
slot="img"
slot-scope="scope"
class="pro-img"
: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"
@closeDialog="handleDetailClose"
>
<store-detail
v-if="detailVisible"
:detailData="detailData"
></store-detail>
</d2-dialog>
</d2-container>
</template>
<script>
import { getList, exportBaseList } from '@api/commodity'
import { BaseData } from '@/common/constants.js'
import Blob from '@/common/Blob.js'
import Export2Excel from '@/common/Export2Excel.js'
import { mapActions } from 'vuex'
import _ from 'lodash'
import storeDetail from './storeDetail'
export default {
name: 'commodity',
data() {
return {
searchForm: {
goodsName: '',
goodsType: '',
brandMerchantCode: ''
},
editFormReset: {
aa: ''
},
getListApi: getList,
// 表格参数
tableParams: {
mutiSelectUniqueKey: 'goodsCode',
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: true,
tableColumns: [{
label: '商品ID',
prop: 'goodsCode'
}, {
label: '商品图片',
prop: 'img',
addHtml: 'img'
}, {
label: '商品名称',
parentProp: 'goodsInfo',
prop: 'goodsName'
}, {
label: '分类',
parentProp: 'goodsInfo',
prop: 'goodsTypeName'
}, {
label: '品牌商',
parentProp: 'goodsInfo',
prop: 'brandMerchantName'
}, {
label: '属性',
prop: 'attr'
}, {
label: '关联商品数',
prop: 'upgradeGoodsNum'
}, {
label: '关联商户数',
prop: 'merchantNum'
}, {
label: '产品状态',
prop: 'state',
formatter: (cellValue) => {
return {
0: '上架',
1: '下架'
}[cellValue.state]
}
}, {
label: '创建时间',
parentProp: 'goodsInfo',
prop: 'createdDate'
}]
},
// 查看门店
detailVisible: false,
// 基本数据
baseData: {
goodsType: [],
brandList: []
}
}
},
components: {
storeDetail
},
mounted() {
this.getBaseData()
// var allOpt = { confId: '', confKey: '全部' }
// this.baseData.goodsType.unshift(allOpt)
// this.baseData.brandList.unshift(allOpt)
},
methods: {
...mapActions('d2admin/base', ['get']),
async getBaseData() {
this.baseData.goodsType = await this.get(BaseData.productType)
},
beforeSearchFn() {
return new Promise(resolve => {
console.log('搜索前操作--')
resolve()
})
},
handleReset() {
var keys = Object.keys(this.searchForm)
keys.forEach(item => {
this.searchForm[item] = ''
})
},
handleAdd(form) {
this.$router.push({
name: 'editCommodity',
params: {
addOrEdit: 'add',
form: form
}
})
},
handleExport() {
const tHeader = ['商品ID', '商品名称', '分类', '品牌商']
const fieldVal = ['goodsCode', 'goodsName', 'goodsTypeName', 'brandMerchantName']
exportBaseList(this.searchForm).then(res => {
console.log(res)
// const exportData = this.
})
},
handleEdit(row) {
this.$router.push({
name: 'editCommodity',
params: {
addOrEdit: 'edit',
row: row
}
})
},
handleDetail(row) {
this.detailData = _.cloneDeep(row)
this.detailVisible = true
},
handleDetailClose() {
this.detailVisible = false
}
}
}
</script>
<style scoped>
.commodity .pro-img {
width: 80px;
height: 80px;
}
</style>