step3.vue
13.5 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
<template>
<div>
<Row>
<Form :label-width="100">
<Row>
<div class="create-group">
<span class="create-group-indicator"></span>
<span class="create-group-title">网销信息</span>
<span class="create-group-sub-title">(商品上架销售需要完成必填项信息)</span>
</div>
</Row>
<Row>
<Col>
<div class="create-item-title">商品颜色主图
<span class="create-group-sub-title">(商品正面图默认为用户选择商品颜色和展示使用。用户从不同频道查看商品,优先展示频道封面图)
<a href="javascript: void 0;" @click="onClickShowExample">查看色卡图片示例</a>
</span>
</div>
</Col>
</Row>
<Row v-for="good,goodIndex in product.goods" :key="good">
<Col span="4">
<div class="color-item-title">
<span>{{good.goodsName}}({{good.factoryGoodsName}})</span>
</div>
</Col>
<Col span="4">
<div class="upload-item">
<div class="upload-item-img">
<img :src="good.goodsImage[0].imageUrl" alt="" width="120px" height="120px">
</div>
<div class="upload-item-title">
商品正面图*
</div>
</div>
</Col>
<Col span="4">
<div class="upload-item">
<div class="upload-item-img">
<drag-file-upload
:id="{goodIndex, imageIndex: 1}"
@success="uploadSuccess"
@remove="uploadRemove">
</drag-file-upload>
</div>
<div class="upload-item-title">
商品反面图
</div>
</div>
</Col>
<Col span="4">
<div class="upload-item">
<div class="upload-item-img">
<drag-file-upload
:id="{goodIndex, imageIndex: 2}"
@success="uploadSuccess"
@remove="uploadRemove">
</drag-file-upload>
</div>
<div class="upload-item-title">
模特图
</div>
</div>
</Col>
<Col span="4">
<div class="upload-item">
<div class="upload-item-img">
<drag-file-upload
:id="{goodIndex, imageIndex: 3}"
@success="uploadSuccess"
@remove="uploadRemove">
</drag-file-upload>
</div>
<div class="upload-item-title">
男生频道封面图
</div>
</div>
</Col>
<Col span="4">
<div class="upload-item">
<div class="upload-item-img">
<drag-file-upload
:id="{goodIndex, imageIndex: 4}"
@success="uploadSuccess"
@remove="uploadRemove">
</drag-file-upload>
</div>
<div class="upload-item-title">
女生频道封面图
</div>
</div>
</Col>
</Row>
<Row>
<Col>
<div class="create-item-title">商品描述
<span class="create-group-sub-title">(详情页内容)</span>
</div>
</Col>
</Row>
<Row>
<Col>
<editor :content="desc" :z-index="2" @change="updateProductDesc"></editor>
</Col>
</Row>
<Row>
<Col>
<div class="create-item-title">商品属性
<span class="create-group-sub-title">(请认真选择所列的属性项,所填内容会对商品搜索、智能推荐等功能产生影响,从而影响商品曝光展示)</span>
</div>
</Col>
</Row>
<Row v-for="attr in model.productStandardRelationStr" :key="attr">
<Col span="8" v-if="attr.inputType === 'select'">
<Form-item :label="attr.attributeName">
<Select v-model="attr.model" :placeholder="'请选择' + attr.attributeName" :label-in-value="true">
<Option v-for="name in attr.idNameList" :value="name.id" :key="name">{{name.text}}</Option>
</Select>
</Form-item>
</Col>
<Col v-else>
<Form-item :label="attr.attributeName">
<Checkbox-group v-model="attr.model">
<Checkbox v-for="name in attr.idNameList" :label="name.id" :key="name">
<span>{{name.text}}</span>
</Checkbox>
</Checkbox-group>
</Form-item>
</Col>
</Row>
<Row v-for="attr in model.attributeProValuesOne" :key="attr">
<Col span="8" v-if="attr.inputType === 'select'">
<Form-item :label="attr.attributeName">
<Select v-model="attr.model" :placeholder="'请选择' + attr.attributeName">
<Option v-for="name in attr.idNameList" :value="name.id" :key="name">{{name.text}}</Option>
</Select>
</Form-item>
</Col>
<Col v-else>
<Form-item :label="attr.attributeName">
<Checkbox-group v-model="attr.model">
<Checkbox v-for="name in attr.idNameList" :label="name.id" :key="name">
<span>{{name.text}}</span>
</Checkbox>
</Checkbox-group>
</Form-item>
</Col>
</Row>
<Row v-for="attr in model.attributeProValuesTwo" :key="attr">
<Col span="8" v-if="attr.inputType === 'select'">
<Form-item :label="attr.attributeName">
<Select v-model="attr.model" :placeholder="'请选择' + attr.attributeName">
<Option v-for="name in attr.idNameList" :value="name.id" :key="name">{{name.text}}</Option>
</Select>
</Form-item>
</Col>
<Col v-else>
<Form-item :label="attr.attributeName">
<Checkbox-group v-model="attr.model">
<Checkbox v-for="name in attr.idNameList" :label="name.id" :key="name">
<span>{{name.text}}</span>
</Checkbox>
</Checkbox-group>
</Form-item>
</Col>
</Row>
<Row v-if="model.productMaterial">
<Col>
<Form-item :label="model.productMaterial.attributeName">
<Checkbox-group v-model="model.productMaterial.model">
<Checkbox v-for="name in model.productMaterial.idNameList" :label="name.id" :key="name">
<span>{{name.text}}</span>
</Checkbox>
</Checkbox-group>
</Form-item>
</Col>
</Row>
</Form>
</Row>
<Row>
<Col>
<div style="text-align: center">
<Button type="primary" @click="nextStep" size="large">保存并退出</Button>
</div>
</Col>
</Row>
<modal-example ref="example"></modal-example>
</div>
</template>
<script>
import xss from 'xss';
import ProductCreateService from 'services/product/product-create-service';
import {step3} from '../store';
export default {
props: ['step', 'product'],
created() {
this.productCreateService = new ProductCreateService();
},
data() {
return step3.call(this);
},
mounted: function() {
this.maxSortId = this.product.maxSortId;
this.smallSortId = this.product.smallSortId;
this.getAllAttr(this.smallSortId, this.maxSortId);
},
methods: {
nextStep: function() {
this.$Loading.start();
this.submit().then((result) => {
this.$Loading.finish();
if (result.code === 200) {
this.$Notice.success({title: '保存成功'});
this.$router.push({name: 'product.offsale'});
} else {
this.$Notice.error({
title: '网销信息更新失败',
desc: result.message
});
}
});
},
updateProductDesc: function(c) {
this.desc = c;
},
getAllAttr: function(smallSortId, maxSortId) {
return this.productCreateService.getAllAttr(smallSortId, maxSortId).then((result) => {
this.model.productStandardRelationStr = this.productCreateService.addNoneItem(result[0]);
this.model.attributeProValuesOne = this.productCreateService.addNoneItem(result[1]);
this.model.attributeProValuesTwo = this.productCreateService.addNoneItem(result[2]);
this.model.productMaterial = result[3];
});
},
submit: function() {
let submitData = this.beforeSubmit();
return this.productCreateService.updateNetInfo(submitData);
},
beforeSubmit: function() {
let result = {
productSkn: this.product.productSkn,
id: this.product.productId,
productIntro: xss(this.desc),
goodsImagesReqStr: JSON.stringify(this.handleImage()),
productStandardRelationStr: JSON.stringify(this.handleRelation()),
attributeProValuesOne: JSON.stringify(this.handleOne()),
attributeProValuesTwo: JSON.stringify(this.handleTwo()),
productMaterial: this.handleMaterial()
};
return result;
},
handleRelation: function() {
return this.productCreateService.handleRelation(this.model.productStandardRelationStr);
},
handleOne: function() {
return this.productCreateService.handleValue(this.product.productSkn, this.model.attributeProValuesOne);
},
handleTwo: function() {
return this.productCreateService.handleValue(this.product.productSkn, this.model.attributeProValuesTwo);
},
handleMaterial: function() {
return this.model.productMaterial.model.join(',');
},
handleImage: function() {
return this.productCreateService.handleColorImage(this.product);
},
uploadSuccess: function(data, file) {
let colorIndex = data.goodIndex;
let imageIndex = data.imageIndex;
this.product.goods[colorIndex].goodsImage[imageIndex].imageUrl = file.url;
},
uploadRemove: function(data) {
let colorIndex = data.goodIndex;
let imageIndex = data.imageIndex;
this.product.goods[colorIndex].goodsImage[imageIndex].imageUrl = '';
},
onClickShowExample: function() {
this.$refs.example.show();
}
}
};
</script>
<style lang="scss" scoped>
.upload-item {
display: inline-block;
height: 220px;
width: 130px;
text-align: center;
margin: 10px 0;
}
.color-item-title {
text-align: center;
margin: 50px 0;
}
.upload-item-img {
display: inline-block;
height: 126px;
width: 124px;
border: 2px solid #e8e8e8;
box-sizing: border-box;
}
.upload-item-title {
display: inline-block;
margin-top: 15px;
}
</style>