selectGoods.vue
13.7 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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
<template>
<div class="select-store">
<GLDialog bigTitle="选择商品" mode="big" :visible.sync="dialogVisible" :before-close="handleClose" :close-on-click-modal="false" @onOk="handleConfirm" @onCancel="handleClose">
<glsx-combi-form ref="showSearch" labelWidth="105px" :formObj="searchForm" :formData="searchFormData">
<span slot="footer">
<el-button :size="size" type="primary" @click="resetTable">查询</el-button>
<el-button :size="size" v-if="goodsInfo.goodsSource != 1" @click="resetSearch">重置</el-button>
</span>
<div class="categorySlot" slot="categorySlot">
<categoryCascader :checkStrictly="true" :categoryCode.sync="yzhSearchForm"></categoryCascader>
</div>
<div class="supplyPriceSlot" slot="supplyPriceSlot">
<inputNumRange :formData="yzhSearchForm" :keyObj="{ from: 'startSellPrice', to: 'endSellPrice' }"></inputNumRange>
</div>
<div class="spreadPriceSlot" slot="spreadPriceSlot">
<inputNumRange :formData="yzhSearchForm" :keyObj="{ from: 'startDiffPrice', to: 'endDiffPrice' }"></inputNumRange>
</div>
</glsx-combi-form>
<GLTable ref="goodsRef" :noDataImg="url" :searchForm="searchForm" :tableParams="tableParams" :beforeSearchFn="beforeSearchFn" :pageConf="pageConf" @refreshTable="getList" :getListApi="getListApi" :pageSizes="pageSizes" :hasNum="false" :setTableFinishFun="setTableFinishFun">
<div slot="radioHtml" class="store-table" slot-scope="scope">
<el-radio :disabled="scope.scope.shelvesStatus == 1002" v-model="curInfo.id" :label="scope.scope.id" @click.native="handleClick(scope.scope)"></el-radio>
</div>
<div slot="selfRadioHtml" class="store-table" slot-scope="scope">
<el-radio v-model="curInfo.goodsId" :label="scope.scope.goodsId" @click.native="handleClick(scope.scope)"></el-radio>
</div>
<div slot="imageSlot" slot-scope="scope">
<el-popover placement="top" width="160" trigger="hover" popper-class="table-popover-block">
<img class="table-popover-img" :src="scope.scope.goodsImage" />
<img class="img-36 pointer" slot="reference" :src="scope.scope.goodsImage" />
</el-popover>
</div>
<template slot="gasImageSlot" slot-scope="scope">
<el-popover placement="top" width="160" trigger="hover" popper-class="table-popover-block">
<img class="table-popover-img" :src="scope.scope.aliasUrl" />
<img class="img-36 pointer" slot="reference" :src="scope.scope.aliasUrl" />
</el-popover>
</template>
<div slot="goodsNameSlot" class="goodsNameSlot" slot-scope="scope">
<img :src="scope.scope.goodsImage" alt="" />
{{ scope.scope.goodsName }}
</div>
<!-- 云中鹤平台 -->
<div slot="yzhImageSlot" slot-scope="scope">
<el-popover placement="top" width="160" trigger="hover" popper-class="table-popover-block">
<img class="table-popover-img" :src="scope.scope.goodsImgUrl" />
<img class="img-36 pointer" slot="reference" :src="scope.scope.goodsImgUrl" />
</el-popover>
</div>
<div slot="goodscategorySlot" class="goodscategorySlot" slot-scope="scope">{{ scope.scope.firstCategoryName }}/{{ scope.scope.secondCategoryName }}/{{ scope.scope.lastCategoryName }}</div>
<div slot="yzhGoodsStatus" slot-scope="scope" class="yzhGoodsStatus">
<div class="yzhstatusClass" :style="yzhStatusMap[scope.scope.shelvesStatus].color"></div>
{{ yzhStatusMap[scope.scope.shelvesStatus].name }}
</div>
</GLTable>
</GLDialog>
</div>
</template>
<script>
import url from '@/assets/empty.png'
import inputNumRange from '@/components/InputNumRange'
import categoryCascader from '@/components/CategoryCascader'
const MERCHANT_SEARCH_ITEM = {
label: '门店名称',
name: 'merchantName',
type: 'input',
width: '200px',
labelWidth: '10px',
isClear: true
}
const YZH_SERACH_ITEM = [
{
label: '商品名称',
name: 'goodsSkuName',
type: 'input',
placeholder: '请输入商品名称',
width: '200px',
labelWidth: '10px',
isClear: true
},
{
label: '商品类型',
addHtml: 'categorySlot'
},
{
label: '商品状态',
name: 'shelvesStatus',
type: 'select',
width: '200px',
optionList: [
{
id: '',
label: '全部'
},
{
id: '1001',
label: '可上架'
},
{
id: '1002',
label: '不可上架'
}
],
optionId: 'id',
optionLabel: 'label'
},
{
label: '供货价',
addHtml: 'supplyPriceSlot'
},
{
label: '差价',
tips: '市场价和供货价的价格差',
addHtml: 'spreadPriceSlot'
}
]
const defaultTableCol = [
{
label: '',
prop: '',
width: 80,
addHtml: 'radioHtml'
},
{
label: '商品名称',
prop: 'goodsName'
},
{
label: '缩略图',
addHtml: 'imageSlot'
},
{
label: '价格(元)',
formatter: cellValue => {
return cellValue.retailPrice ? Number(Number(cellValue.retailPrice / 100).toFixed(2)) : '--'
}
}
]
const merchantGoodsTableCol = [
{
label: '',
prop: '',
width: 80,
addHtml: 'selfRadioHtml'
},
{
label: '商品信息',
addHtml: 'goodsNameSlot'
},
{
label: '门店名称',
prop: 'merchantName'
},
{
label: '零售价(元)',
formatter: cellValue => {
return cellValue.retailPrice ? Number(Number(cellValue.retailPrice / 100).toFixed(2)) : '--'
}
},
{
label: '划线价(元)',
formatter: cellValue => {
return cellValue.originalPrice ? Number(Number(cellValue.originalPrice / 100).toFixed(2)) : '--'
}
}
]
const gasGoodsTableCol = [
{
label: '',
prop: '',
width: 80,
addHtml: 'radioHtml'
},
{
label: '商品编码',
prop: 'alias'
},
{
label: '商品图片',
addHtml: 'gasImageSlot'
},
{
label: '商品信息',
prop: 'aliasName'
},
{
label: '销售价/元',
formatter: cellValue => {
return cellValue.salesPrice ? Number(Number(cellValue.salesPrice / 100).toFixed(2)) : '--'
}
},
{
label: '面额/元',
prop: 'faceValue'
},
{
label: '成本/元',
prop: 'sellPrice'
},
{
label: '库存',
formatter: cellValue => {
return cellValue.stock - cellValue.usedStock
}
}
]
const yzhGoodsTableCol = [
{
label: '',
prop: '',
width: 80,
addHtml: 'radioHtml'
},
{
label: '商品图片',
addHtml: 'yzhImageSlot'
},
{
label: '商品名称',
prop: 'goodsSkuName'
},
{
label: '分类',
addHtml: 'goodscategorySlot'
},
{
label: '供货价/元',
prop: 'sellPrice'
// formatter: cellValue => {
// return cellValue.retailPrice ? Number(Number(cellValue.retailPrice / 100).toFixed(2)) : '--'
// }
},
{
label: '市场价/元',
prop: 'marketPrice'
// formatter: cellValue => {
// return cellValue.originalPrice ? Number(Number(cellValue.originalPrice / 100).toFixed(2)) : '--'
// }
},
{
label: '库存',
prop: 'goodsStock'
},
{
label: '商品状态',
addHtml: 'yzhGoodsStatus'
}
]
export default {
name: 'selectStore',
data() {
return {
url: url,
searchForm: {
goodsName: '',
discoverGoodsId: '',
goodsType: '',
shelvesStatus: ''
},
total: 0,
storeList: [],
heightBox: 200,
curInfo: {},
// 搜索
searchFormData: [
{
label: '商品名称',
name: 'goodsName',
type: 'input',
placeholder: '请输入商品名称',
width: '200px',
labelWidth: '10px',
isClear: true
}
],
pageConfig: {
pageSize: 10,
pageNum: 1
},
getListApi: null,
tableParams: {
listName: 'list',
tableColumns: {}
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
pageSizes: [5, 10, 20, 30, 40],
baseData: {},
yzhStatusMap: {
1001: {
name: '可上架',
color: 'background:#fdb757'
},
1002: {
name: '不可上架',
color: 'background:#ee3527'
}
},
yzhSearchForm: {
categoryCode: [],
startSellPrice: '',
endSellPrice: '',
startDiffPrice: '',
endDiffPrice: ''
}
}
},
props: {
dialogVisible: {
type: Boolean,
default: false
},
routeInfo: {
type: Object,
default: () => {}
},
storeSearchForm: {
type: Object
},
goodsInfo: {
required: true,
default: () => {}
}
},
components: {
inputNumRange,
categoryCascader
},
created() {
// let { smartcarlifeInfoId, goodsName, coverList, goodsImage, minSellPrice, retailPrice } = this.goodsInfo || {}
// this.curInfo = {
// id: smartcarlifeInfoId,
// goodsName,
// goodsImage: coverList?.[0] || '',
// minSellPrice: minSellPrice ? Number(Number(minSellPrice*10*10).toFixed(0)) : 0,
// retailPrice: retailPrice ? Number(Number(retailPrice*10*10).toFixed(0)) : 0,
// }
const { goodsSource } = this.goodsInfo
this.searchForm.discoverGoodsId = this.routeInfo.type == 2 ? this.routeInfo.id : '' //1查看,2编辑,空是新增,编辑进来要传id
this.searchForm.goodsType = this.routeInfo.goodsType // 1是配置 2是车主
if (goodsSource == 2) {
//来源是门店自营的搜素和列表字段都要改
this.searchFormData.push(MERCHANT_SEARCH_ITEM)
} else if (goodsSource == 4) {
this.searchFormData = [...YZH_SERACH_ITEM]
}
this.tableParams.tableColumns = {
1: defaultTableCol,
2: merchantGoodsTableCol,
3: gasGoodsTableCol,
4: yzhGoodsTableCol
}[goodsSource]
this.getListApi =
this.$apis.goods[
{
1: 'getCarlifeGoodsApi',
2: 'getSelfSupportGoodsApi',
3: 'getOilCouponListApi',
4: 'getYzgGoodsListApi'
}[goodsSource]
]
},
mounted() {
let clientHeight = document.documentElement.clientHeight
this.heightBox = clientHeight - 0.15 * clientHeight - 425
},
methods: {
resetTable() {
this.$refs.goodsRef.refreshTable()
},
resetSearch() {
this.searchForm = {
goodsName: '',
discoverGoodsId: '',
goodsType: '',
shelvesStatus: ''
}
this.yzhSearchForm = {
categoryCode: [],
startSellPrice: '',
endSellPrice: '',
startDiffPrice: '',
endDiffPrice: ''
}
this.resetTable()
},
beforeSearchFn() {
return new Promise(resolve => {
const { goodsSource } = this.goodsInfo
if (goodsSource == 2) {
delete this.searchForm.goodsType
}
if (goodsSource == 3) this.searchForm.aliasName = this.searchForm.goodsName
if (goodsSource == 4) {
this.searchForm = {
...this.searchForm,
...this.$common.utils.deepClone(this.yzhSearchForm)
}
const { categoryCode } = this.searchForm
this.searchForm.categoryCode = categoryCode && categoryCode.length ? categoryCode.pop() : ''
const categoryCodeLength = this.searchForm.categoryCode.length
if (categoryCodeLength > 0 && categoryCodeLength < 6) {
const name = categoryCodeLength === 2 ? 'categoryCode1' : 'categoryCode2'
this.searchForm[name] = this.searchForm.categoryCode
delete this.searchForm.categoryCode
}
}
resolve()
})
},
setTableFinishFun() {
this.$refs.goodsRef.tableHeightValues = '460px'
},
handleClick(item) {
console.log(item)
this.curInfo = item
},
handleClose() {
this.$emit('handleGoodsClose')
},
handleConfirm() {
if (Object.keys(this.curInfo).length) this.$emit('handleGoodsConfirm', this.curInfo)
else
this.$message({
message: '请选择商品',
type: 'error',
customClass: 'message-Z-zinde'
})
}
}
}
</script>
<style lang="scss" scoped>
/deep/.glsx-combi-form .el-form {
.el-form-item {
margin-right: 12px !important;
}
.el-button {
margin-top: 1px;
}
}
.goodsNameSlot {
img {
width: 36px;
height: 36px;
vertical-align: middle;
margin-right: 8px;
}
}
.select-store {
.storeDailog {
width: 500px;
}
.title {
margin-bottom: 12px;
}
.customer-tag-box {
display: flex;
margin: 20px 16px;
.tag-label {
display: inline-block;
height: 30px;
line-height: 30px;
}
.input-tag-wrapper {
max-height: 75px;
overflow: auto;
position: relative;
font-size: 14px;
background-color: #fff;
background-image: none;
border-radius: 4px;
border: 1px solid #dcdfe6;
box-sizing: border-box;
color: #666;
display: inline-block;
outline: none;
padding: 5px;
flex-wrap: wrap;
transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
width: 648px;
display: flex;
align-items: center;
cursor: pointer;
i {
color: #75acff;
margin-right: 3px;
font-size: 14px;
}
}
}
// .customer-list {
// width: calc(100% - 280px);
// margin-right: 10px;
// }
.p-16 {
padding: 16px;
}
/deep/ .store-table .el-radio__label {
display: none;
}
}
.yzhGoodsStatus {
display: flex;
align-items: center;
}
.yzhstatusClass {
width: 6px;
height: 6px;
background: #fdb757;
border-radius: 8px;
margin-right: 8px;
}
.supplyPriceSlot,
.spreadPriceSlot {
width: 200px;
}
</style>