candidate-list.vue
8.2 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
<template>
<layout-body>
<layout-filter ref="filter" :model="query">
<filter-item label="品牌">
<select-brand v-model="query.brandId"></select-brand>
</filter-item>
<filter-item label="品类">
<select-category v-model="query.sort"></select-category>
</filter-item>
<filter-item label="价格区间">
<Price v-model="query.price"></Price>
</filter-item>
<filter-item label="库存状态">
<Select v-model="query.stockStatus" clearable>
<Option value="0">库存正常</Option>
<Option value="1">即将售罄</Option>
</Select>
</filter-item>
<filter-item>
<Button type="primary" @click="search">筛选</Button>
<Button @click="reset">清空条件</Button>
</filter-item>
</layout-filter>
<layout-action v-show="!nullData">
<Button type="error" @click="addSellPool">添加到推广池</Button>
<span class="add-num">已添加到推广池:{{spreadPrdCnt}}</span>
</layout-action>
<layout-list>
<Table border :columns="tableCols" :data="tableData" @on-selection-change="changeProductStr" v-show="!nullData"></Table>
<Page :total="pageData.total" :current="pageData.current"
@on-change="pageChange" :page-size="10" show-total v-show="!nullData"></Page>
<div class="null-data" v-show="nullData">
<p class="red">请选择查询条件,查找你想要推广的商品。.......</p>
<p class="red">*注:品牌或品类筛选必须选择其中一个。</p>
<p><Icon type="android-arrow-forward"></Icon><a href="//www.yohobuy.com/boys-brands/">品牌一览</a></p>
</div>
</layout-list>
</layout-body>
</template>
<script>
import CandidateListService from 'services/kol/candidate-list-service';
import {Price} from './components';
import _ from 'lodash';
export default {
data() {
return {
query: {
poolId: null,
brandId: null,
sort: [],
price: [],
stockStatus: null
},
pageData: {
total: 0,
current: 1,
},
nullData: true,
tableData: [],
tableCols: [{
type: 'selection',
width: 60,
align: 'center'
}, {
title: 'skn',
key: 'productSkn',
width: 100,
align: 'center'
}, {
title: '商品图片',
key: 'imageUrl',
render: (h, params) => {
return h('img', {
attrs: {
src: params.row.imageUrl,
style: 'max-width: 100%; display: block; margin: 0 auto;'
}
});
}
}, {
title: '商品名称',
key: 'productName',
align: 'center'
}, {
title: '商品品牌',
key: 'brandName',
align: 'center'
}, {
title: '商品类目',
key: 'sortName',
align: 'center'
}, {
title: '库存状态',
key: 'stockStatus',
align: 'center',
width: 110,
renderHeader: (h, params) => {
return h('div', [
h('strong', params.column.title),
h('Tooltip', {
attrs: {
placement: 'bottom-start',
content: '这里指整个商品下所有颜色尺码的库存状态。具体颜色、尺码的库存明细请参考商品详情页面。'
}
}, [
h('Icon', {
props: {
type: 'android-alert'
},
attrs: {style: 'font-size: 16px;vertical-align: text-top; margin-left: 5px;'}
})
])
]);
}
}, {
title: '当前价格(元)',
key: 'currentPrice',
width: 110,
align: 'center'
}, {
title: '结算比例',
key: 'commissionRate',
align: 'center'
}, {
title: '预估佣金',
key: 'brokerage',
align: 'center'
}],
productSknStr: '',
spreadPrdCnt: null
};
},
created() {
this.candidateListService = new CandidateListService();
},
methods: {
filterValues() {
let params = {
page: this.pageData.current,
size: 10,
brandId: +this.query.brandId,
maxSortId: _.get(this.query, 'sort[0].value') || '',
middleSortId: _.get(this.query, 'sort[1].value') || '',
smallSortId: _.get(this.query, 'sort[2].value') || '',
priceRangeLow: _.get(this.query, 'price[0]') || '',
priceRangeHigh: _.get(this.query, 'price[1]') || '',
stockStatus: this.query.stockStatus
};
return _.pickBy(params, val => val);
},
search() {
if (!this.query.brandId && this.query.sort.length === 0 && this.query.price.length === 0 && !this.query.stockStatus) {
this.$Message.warning('请选择筛选条件!');
return;
}
if (!this.query.brandId && this.query.sort.length === 0) {
this.$Message.warning('请先选择品牌或品类!');
return;
}
this.candidateListService.queryWarehouseProductList(this.filterValues()).then(ret => {
if (ret && ret.code === 200) {
this.tableData = _.get(ret, 'data.list', []);
this.pageData.total = _.get(ret, 'data.total', 0);
this.pageData.current = _.get(ret, 'data.page', 1);
this.spreadPrdCnt = _.get(ret, 'data.spreadPrdCnt', '');
this.nullData = false;
} else {
this.$Message.error(ret.message);
}
});
},
addSellPool() {
this.candidateListService.batchAddProduct({
productSknStr: this.productSknStr
}).then(ret => {
if (ret && ret.code === 200) {
this.$Message.success('添加成功!');
this.search();
} else {
this.$Message.error(`添加失败:${ret.message}`);
}
});
},
changeProductStr(selection) {
this.productSknStr = '';
_.each(selection, (item) => {
if (!this.productSknStr) {
this.productSknStr += item.productSkn;
} else {
this.productSknStr += `,${item.productSkn}`;
}
});
},
reset() {
this.$refs.filter.reset();
this.search();
},
pageChange(val) {
this.pageData.current = val;
this.search();
}
},
components: {
Price
},
watch: {
}
};
</script>
<style lang="scss">
.ivu-table-column-center .ivu-tooltip-inner {
white-space: normal !important;
}
.add-num {
float: right;
margin-top: 15px;
}
.null-data {
width: 260px;
margin: 180px auto 0;
line-height: 30px;
.ivu-icon-android-arrow-forward {
margin-right: 10px;
}
.red {
color: #ed3f16;
}
}
</style>