packageDetailTable.vue
8.88 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
<template>
<div class="detail-table">
<!-- 表头 -->
<div class="table-header">
<span class="th th-expand"></span>
<span class="th th-index">排序</span>
<span class="th th-name">
选项卡名称
<el-tooltip content="在展业助手App中对外展示的套餐或商品名称" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-tabDescription">
选项卡描述
<el-tooltip content="在展业助手App中对外展示的套餐或商品描述" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-price">现售价</span>
<span class="th th-min">最低售价</span>
<span class="th th-discount">优惠价(元)</span>
<span class="th th-incentive">销售激励(元)</span>
<span class="th th-main">是否主推</span>
<span class="th th-img">
预览主图
<el-tooltip content="页面展示主图,建议尺寸 664x336px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-thumb">
预览小图
<el-tooltip content="列表中展示的缩略图,建议尺寸 88x120px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-detail">
内容详图
<el-tooltip content="商品或套餐详情展示的内容长图" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
</div>
<!-- 数据行 -->
<div v-for="(item, index) in list"
:key="item.id || index"
class="table-item">
<!-- 主行 -->
<div class="table-row"
:class="{ 'is-expanded': expandedRows.includes(item.id || index) }">
<span class="td td-expand">
<i v-if="item.packageItems && item.packageItems.length"
class="expand-icon"
:class="[expandedRows.includes(item.id || index) ? 'el-icon-arrow-down' : 'el-icon-arrow-right']"
@click="toggleExpand(item.id || index)" />
</span>
<span class="td td-index">{{ index + 1 }}</span>
<span class="td td-name">
<span>{{ item.tabName }}</span>
<div class="sub-text">{{ item.packageCode }}</div>
</span>
<span class="td td-tabDescription">{{ item.tabDescription || '-' }}</span>
<span class="td td-price">{{ priceFilter(item.currentPrice) }}</span>
<span class="td td-min">{{ priceFilter(item.minimumPrice) }}</span>
<span class="td td-discount">{{ priceFilter(item.discountPrice) }}</span>
<span class="td td-incentive">{{ priceFilter(item.salesIncentive) }}</span>
<span class="td td-main">{{ item.isMainPush == 1 ? '是' : '否' }}</span>
<span class="td td-img">
<el-image v-if="item.mainImageUrl"
class="thumb-img"
fit="cover"
:preview-src-list="[item.mainImageUrl]"
:src="item.mainImageUrl" />
<span v-else>-</span>
</span>
<span class="td td-thumb">
<el-image v-if="item.thumbImageUrl"
class="thumb-img"
fit="cover"
:preview-src-list="[item.thumbImageUrl]"
:src="item.thumbImageUrl" />
<span v-else>-</span>
</span>
<span class="td td-detail">
<el-image v-if="item.detailImageUrl"
class="thumb-img"
fit="cover"
:preview-src-list="[item.detailImageUrl]"
:src="item.detailImageUrl" />
<span v-else>-</span>
</span>
</div>
<!-- 子商品展开区 -->
<div v-if="(item.packageItems && item.packageItems.length) && expandedRows.includes(item.id || index)"
class="sub-table-wrapper">
<div class="sub-table-header">
<span class="sh-col sh-col-name">产品名称</span>
<span class="sh-col sh-col-name">商品别名</span>
<span class="sh-col sh-col-id">产品ID</span>
<span class="sh-col sh-col-price">现售价</span>
<span class="sh-col sh-col-min">最低售价</span>
<span class="sh-col sh-col-discount">优惠价</span>
</div>
<div v-for="(sub, subIdx) in item.packageItems"
:key="subIdx"
class="sub-table-row">
<span class="sc sc-name">{{ sub.goodsName || '-' }}</span>
<span class="sc sc-name">{{ sub.goodsAlias || '-' }}</span>
<span class="sc sc-id">{{ sub.upgradeProductId || '-' }}</span>
<span class="sc sc-price">{{ priceFilter(sub.currentPrice) }}</span>
<span class="sc sc-min">{{ priceFilter(sub.minimumPrice) }}</span>
<span class="sc sc-discount">{{ priceFilter(sub.discountPrice) }}</span>
</div>
</div>
</div>
<div v-if="!list.length" class="table-empty">
暂无数据
</div>
</div>
</template>
<script>
export default {
name: "PackageDetailTable",
props: {
list: {
type: Array,
default: () => [],
},
},
data() {
return {
expandedRows: [],
};
},
methods: {
priceFilter(num) {
const pow = 10 ** 2;
if (this.filterEmpty(num)) {
return "-";
}
return `¥${(Math.round(num * pow) / pow).toFixed(2)}`;
},
filterEmpty(data) {
return (data ?? "") === "";
},
toggleExpand(key) {
const idx = this.expandedRows.indexOf(key);
if (idx > -1) {
this.expandedRows.splice(idx, 1);
} else {
this.expandedRows.push(key);
}
},
},
};
</script>
<style lang="scss" scoped>
.detail-table {
border: 1px solid #ebeef5;
font-size: 13px;
max-height: 500px;
overflow: auto;
}
// 表头
.table-header {
display: flex;
align-items: center;
background-color: #f5f7fa;
border-bottom: 1px solid #ebeef5;
min-width: 1300px;
.th {
padding: 10px 8px;
box-sizing: border-box;
color: #909399;
font-weight: 500;
display: flex;
align-items: center;
flex-shrink: 0;
}
}
// 数据行
.table-item {
border-bottom: 1px solid #ebeef5;
}
.table-row {
display: flex;
align-items: center;
min-width: 1300px;
padding: 8px 0;
background-color: #fff;
&:hover {
background-color: #f5f7fa;
}
&.is-expanded {
background-color: #ecf5ff;
}
}
.td {
padding: 0 8px;
display: flex;
align-items: center;
box-sizing: border-box;
flex-shrink: 0;
}
// 列宽定义(和新增页保持一致)
.td-expand,
.th-expand {
width: 36px;
justify-content: center;
flex-shrink: 0;
}
.td-index,
.th-index {
width: 50px;
justify-content: center;
flex-shrink: 0;
color: #606266;
}
.th-name,
.td-name {
min-width: 180px;
flex: 2;
align-items: flex-start;
}
.td-name {
flex-flow: column;
}
.th-tabDescription,
.td-tabDescription {
word-break: break-all;
min-width: 160px;
flex: 1.5;
}
.th-store,
.td-store {
width: 90px;
justify-content: center;
flex-shrink: 0;
}
.th-price,
.td-price {
width: 90px;
flex-shrink: 0;
color: #606266;
}
.th-min,
.td-min {
width: 90px;
flex-shrink: 0;
color: #606266;
}
.th-discount,
.td-discount {
width: 120px;
flex-shrink: 0;
}
.th-incentive,
.td-incentive {
width: 120px;
flex-shrink: 0;
}
.th-main,
.td-main {
width: 80px;
justify-content: center;
flex-shrink: 0;
}
.th-img,
.td-img {
width: 100px;
justify-content: center;
flex-shrink: 0;
}
.th-thumb,
.td-thumb {
width: 100px;
justify-content: center;
flex-shrink: 0;
}
.th-detail,
.td-detail {
width: 100px;
justify-content: center;
flex-shrink: 0;
}
// 子元素样式
.sub-text {
margin-top: 4px;
font-size: 12px;
color: #c0c4cc;
}
.header-tip {
color: #c0c4cc;
cursor: pointer;
margin-left: 4px;
font-size: 12px;
}
.expand-icon {
cursor: pointer;
color: #909399;
font-size: 12px;
transition: transform 0.2s;
&:hover {
color: #409eff;
}
}
.thumb-img {
width: 60px;
height: 60px;
border-radius: 4px;
}
// 子商品表格
.sub-table-wrapper {
border: 1px solid #ebeef5;
padding: 8px 20px 8px 80px;
background-color: #fafafa;
}
.sub-table-header {
display: flex;
align-items: center;
background-color: #f5f7fa;
border: 1px solid #e4e7ed;
min-width: 700px;
.sh-col {
padding: 8px 10px;
color: #909399;
font-weight: 500;
font-size: 12px;
flex-shrink: 0;
}
}
.sub-table-row {
display: flex;
align-items: center;
border-bottom: 1px solid #ebeef5;
min-width: 700px;
.sc {
padding: 8px 10px;
font-size: 12px;
flex-shrink: 0;
}
}
.sh-col-name,
.sc-name {
min-width: 160px;
flex: 2;
}
.sh-col-id,
.sc-id {
width: 160px;
text-align: center;
}
.sh-col-price,
.sc-price {
width: 100px;
text-align: center;
}
.sh-col-min,
.sc-min {
width: 100px;
text-align: center;
}
.sh-col-discount,
.sc-discount {
width: 120px;
text-align: center;
}
.table-empty {
text-align: center;
padding: 30px;
color: #c0c4cc;
}
</style>