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
524
525
526
527
528
529
530
531
532
533
534
535
<template>
<div class="goods-parameter">
<p class="tip-p">
<el-link class="edit-type-span el-icon-search" type="primary" :underline="false" @click="viewPriceExp">查看各类价格说明
</el-link>
<span class="tip-span">所有商品价格均为含税价,必须开具发票</span>
</p>
<div v-show="(!orgGoodsPam.pamTableList || orgGoodsPam.pamTableList.length === 0)">
<el-table
border
size="small"
:data="singleSpecTable"
style="width: 80%;margin-right:10%;"
>
<el-table-column align="center" prop="js_price" label="协议价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.js_price" placeholder="请输入协议价"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="sl_price" label="结算价">
<template slot-scope="scope">
<span
class="sl-price-span-input">{{ scope.row.sl_price = scope.row.js_price ? scope.row.js_price : '' }}</span>
</template>
</el-table-column>
<el-table-column align="center" prop="price" label="指导价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.price" placeholder="请输入指导价"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="sc_price" label="市场价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.sc_price" placeholder="请输入市场价"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="stock" label="库存量">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.stock" placeholder="请输入库存量"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="weight" label="重量">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.weight" placeholder="请输入重量"></el-input>
</template>
</el-table-column>
<!-- <el-table-column align="center" prop="imgs9" label="图片">-->
<!-- <template slot-scope="scope">-->
<!-- <!–----------–>-->
<!-- <el-upload-->
<!-- action="/"-->
<!-- class="uploadData50"-->
<!-- list-type="picture-card"-->
<!-- :limit="5"-->
<!-- :on-exceed="limit5"-->
<!-- :file-list="singleSpecImgList"-->
<!-- :http-request="(file)=> { return upLoadSingleSpecImg(file,scope.row) }"-->
<!-- :on-remove=" (file) => { return removeSingleSpeImg(file,scope.row)}"-->
<!-- ></el-upload>-->
<!-- <!–----------–>-->
<!-- </template>-->
<!-- </el-table-column>-->
</el-table>
</div>
<div v-show="orgGoodsPam.pamTableList.length > 0" v-for="(item,index) in orgGoodsPam.pamTableList" :key="index"
class="single-spe-con">
<p style="margin: 10px 0;color: #333;font-size: 14px;font-weight: 400;">
<span v-show="orgGoodsPam.pamNameList.length === 1">
{{ orgGoodsPam.pamNameList[0].spec_name }} <span>:</span>{{ orgGoodsPam.pamDataList[index]}}
</span>
<span v-show="orgGoodsPam.pamNameList.length > 1">
<span v-for="(itemv,indexv) in orgGoodsPam.pamNameList" style="margin-right:20px;">
{{ orgGoodsPam.pamNameList[indexv].spec_name }} <span>:</span>{{ orgGoodsPam.pamDataList[index][indexv]}}
</span>
</span>
</p>
<el-table
border
size="small"
:data="item"
style="width: 80%"
>
<el-table-column align="center" prop="js_price" label="协议价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.js_price" placeholder="请输入协议价"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="sl_price" label="结算价">
<template slot-scope="scope">
<!-- <el-input size="mini" style="width:90%" v-model="scope.row.hh2" :disabled="true" placeholder="根据结算价自动计算"></el-input>-->
<span
class="sl-price-span-input">{{ scope.row.sl_price = scope.row.js_price ? scope.row.js_price : '' }}</span>
</template>
</el-table-column>
<el-table-column align="center" prop="price" label="指导价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.price" placeholder="请输入指导价"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="sc_price" label="市场价">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.sc_price" placeholder="请输入市场价"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="stock" label="库存量">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.stock" placeholder="请输入库存量"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="weight" label="重量">
<template slot-scope="scope">
<el-input size="mini" style="width:90%" v-model="scope.row.weight" placeholder="请输入重量"></el-input>
</template>
</el-table-column>
<el-table-column align="center" prop="thumb" label="图片">
<template slot-scope="scope">
<span
v-show="!scope.row.thumb"
class="span-img"
@click="upPreSpeImg(index,scope.row)"
></span>
<span v-show="scope.row.thumb" class="span-img-con">
<img
class="spec-img"
:src="scope.row.thumb"
alt=""
@click="changeSpeImg(index,scope.row)"
/>
<span class="span-img-del el-icon-delete del-span-block" @click="delSingleSpecImg(index,scope.row)"></span>
</span>
<input type="file" style="display: none;" :ref=" 'hxz' + index " accept="image/*"
@change="changeIMG(index,scope.row)">
</template>
</el-table-column>
</el-table>
</div>
<!-- 查看各类价格说明 -->
<el-dialog
title="各类价格说明"
:visible.sync="isViewPriceExp"
width="40%"
center
append-to-body
>
<el-form ref="workOrderForm" size="small" label-width="150px">
<el-form-item label="协议价:">
<span>指您供货给下游的价格</span>
</el-form-item>
<el-form-item label="结算价:">
<span>与云仓平台结算的价格,根据协议价自动计算</span>
</el-form-item>
<el-form-item label="指导售价:">
<span>指导下游商户制定销售的价格</span>
</el-form-item>
<el-form-item label="市场价:">
<span>市场售价,参考京东、天猫等平台的售价</span>
</el-form-item>
<el-form-item>
<span class="pre-price-tip">商品价格均为含税价,必须开具发票。请准确填写并更新商品实际库存,超卖导致的虚假及延迟发货会引起用户投诉与平台判罚。</span>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="isViewPriceExp = false" size="mini">取 消</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import { UploadImg } from '@/api/module/goods';
export default {
name: 'goodsparameter',
props: {
parameterdata: {
type: Object,
required: true
}
},
data() {
return {
orgGoodsPam: {},
preTableTitle: [],
isHoverSpeImg: false,
/** 无规格 数据 */
singleSpecTable: [
{
js_price: '', // 协议价
sl_price: '', // 结算价
price: '', // 指导价
sc_price: '', // 市场价
stock: '', // 库存
weight: '', // 重量 g
}
],
singleSpecImgList: [],
isViewPriceExp: false
} // return end
},
watch:{
'parameterdata': function(val) {
//debugger
this.orgGoodsPam = val;
//console.log("监听",this.orgGoodsPam);
},
},
created() {
//this.orgGoodsPam = this.parameterdata;
},
mounted() {
if(this.parameterdata.pamTableList && this.parameterdata.pamTableList.length > 0) {
this.orgGoodsPam = this.parameterdata;
}else {
if( this.parameterdata.singleSpecTable.length === 1 ) {
this.singleSpecTable = this.parameterdata.singleSpecTable
}
}
},
methods: {
/** 初始化 商品售价 数据 */
initInfo() {
this.orgGoodsPam = {};
//this.singleSpecTable =
},
// 查看各类价格说明
viewPriceExp() {
this.isViewPriceExp = true;
},
// ------ 无规格,上传图片相关 ------
limit5() {
this.$message({type: 'warning',message: '只能上传5张图片'});
},
// 上传 无规格组合 的图片
upLoadSingleSpecImg(param) {
this.getBase64(param.file).then((res) => {
let result = res.split(",");
this.Base64img = result[1];
let data = {"img_data": this.Base64img}
UploadImg(data).then(res => {
if (res && res.code == 1) {
this.singleSpecImgList.push({ url: res.data.image_url });
this.singleSpecTable[0].imgs9 = [];
this.singleSpecImgList.forEach(item=> {
this.singleSpecTable[0].imgs9.push(item.url)
})
this.$message({ message:'上传成功',type:'success'});
}else {
this.singleSpecImgList = [];
this.$message({ message:'上传失败,请重新上传',type:'error'});
}
})
});
},
// 删除 无规格组合 的图片
removeSingleSpeImg(file) {
if(file.status === "success") {
for(let i = 0; i < this.singleSpecImgList.length; i++) {
if(file.uid === this.singleSpecImgList[i].uid) {
this.singleSpecImgList.splice(i,1);
this.singleSpecTable[0].imgs9.splice(i,1);
}
}
this.$message({ type: 'success', message: '删除成功!' });
}
},
/** 规格组合 上传图片 */
// 上传图片
upPreSpeImg(index, row) {
let domRef = "hxz" + index;
//console.log(domRef,this.$refs[domRef][0]);
this.$refs[domRef][0].value = '';
this.$refs[domRef][0].click();
},
// 更换 某一个规格的图片
changeSpeImg(index, row) {
this.upPreSpeImg(index,row);
},
// 真正的上传图片方法,原生input
changeIMG(index, row) {
let curRow = row;
let inputDom = "hxz" + index;
let file = this.$refs[inputDom][0].files[0];
if( file.size > 1024 * 1024 * 3 ) {
this.$message({ type: 'error',message: '规格图片不能大于 3 M'});
return;
}
this.getBase64(file).then((res) => {
let result = res.split(",");
this.Base64img = result[1];
let data = {"img_data": this.Base64img}
UploadImg(data).then(res => {
// this.loading = false;
if (res && res.code == 1) {
curRow.thumb = res.data.image_url;
// this.singleSpecImgList.push({'url': res.data.image_url})
this.$message({ message:'上传成功',type:'success'});
}else {
this.$message({ message:'上传失败,请重新上传',type:'error'});
}
})
});
},
/**如果保存失败,将乘以100的价格还原
* 当多规格数据时候,才调用
* */
priceReduce() {
// debugger
if(this.parameterdata.pamTableList && this.parameterdata.pamTableList.length > 0) {
this.parameterdata.pamTableList.forEach((item)=> {
if(item[0].js_price) {
item[0].js_price = item[0].js_price / 100;
}
if(item[0].price) {
item[0].price = item[0].price / 100;
}
if(item[0].sc_price) {
item[0].sc_price = item[0].sc_price / 100;
}
if(item[0].sl_price) {
item[0].sl_price = item[0].sl_price / 100;
}
})
}
// else {
// if(this.singleSpecTable[0].js_price) {
// this.singleSpecTable[0].js_price = this.singleSpecTable[0].js_price / 100
// }
// if(this.singleSpecTable[0].price) {
// this.singleSpecTable[0].price = this.singleSpecTable[0].price / 100
// }
// if(this.singleSpecTable[0].sc_price) {
// this.singleSpecTable[0].sc_price = this.singleSpecTable[0].sc_price / 100
// }
// if(this.singleSpecTable[0].sl_price) {
// this.singleSpecTable[0].sl_price = this.singleSpecTable[0].sl_price / 100
// }
// }
},
// 删除 单个规格的图片
delSingleSpecImg(index,row) {
if( row.thumb ) {
row.thumb = '';
this.$message({type: 'success',message: '删除成功'});
}
},
speImgHover(index,row) {
this.isHoverSpeImg = true;
},
speImgLeave(index, row) {
this.isHoverSpeImg = false;
},
// -- 通用 方法 --
// 图片转换为 base64
getBase64(file) {
return new Promise(function (resolve, reject) {
let reader = new FileReader();
let imgResult = "";
reader.readAsDataURL(file);
reader.onload = function () {
imgResult = reader.result;
};
reader.onerror = function (error) {
reject(error);
};
reader.onloadend = function () {
resolve(imgResult);
};
});
},
} // methods end
}
</script>
<style lang="scss" type="text/stylus" scoped>
.span-img {
margin: 0;
padding: 0;
display : inline-block;
width:50px;
height:50px;
position: relative;
top:4px;
cursor: pointer;
border-radius: 6px;
border: 1px dashed #c0ccda;
background-color : #fbfdff;
}
.span-img:hover {
border: 1px dashed #1890ff;
}
.spec-img {
width: 100%;
height: 100%;
border-radius: 6px;
cursor: pointer;
position: relative;
border: none;
}
.span-img-con {
margin: 0;
padding: 0;
display : inline-block;
width:50px;
height:50px;
position: relative;
top:4px;
cursor: pointer;
border-radius: 6px;
border: 1px solid #c0ccda;
}
.span-img-del {
position: absolute;
display : inline-block;
width: 18px;
height: 18px;
font-size: 18px;
color: #333;
line-height : 18px;
top: 50%;
left: 50%;
margin-top: -9px;
margin-left: -9px;
}
.del-span-block {
display : none;
}
.span-img-del:hover {
color: #F56C6C;
}
.span-img-con:hover > .del-span-block {
display : block;
}
p {
margin: 0;
padding: 0;
}
.tip-p {
margin: 0 0 20px 0;
}
.goods-parameter {
padding: 20px;
}
.edit-type-span {
display: inline-block;
cursor: pointer;
margin: 0 20px;
}
.single-spe-con {
margin: 25px 0;
}
.sl-price-span-input {
display: inline-block;
width: 90%;
height: 28px;
padding: 0 15px;
line-height : 28px;
border-radius : 4px;
border : 1px solid #DCDFE6;
vertical-align : bottom;
}
/* 一般提示性文字 */
.tip-span {
color: #909399;
font-size: 12px;
}
.pre-price-tip {
color: #F56C6C;
font-size: 12px;
}
// 上传图片样式
.uploadData50 {
display: inline-block;
/deep/ .el-upload--picture-card {
width: 50px;
height: 50px;
}
/deep/ .el-upload {
width: 50px;
height: 50px;
line-height: 50px;
}
/deep/ .el-upload-list--picture-card .el-upload-list__item {
width: 50px;
height: 50px;
line-height: 50px;
}
/deep/ .el-upload-list--picture-card .el-upload-list__item-thumbnail {
width: 50px;
height: 50px;
line-height: 50px;
}
/deep/ .avatar {
width: 50px;
height: 50px;
}
}
</style>