3f535f30
杨鑫
'初始'
|
1
2
3
|
<!-- -->
<template>
<div style="padding: 0 10px;background-color:#f7f7f7;">
|
89bb9f2b
wesley88
1
|
4
|
<div class="tab_show" v-if ="ontype == '1'">
|
3f535f30
杨鑫
'初始'
|
5
6
7
8
|
<!-- 搜索 -->
<div class="formSearch">
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="商品名称">
|
89bb9f2b
wesley88
1
|
9
|
<el-input v-model="formInline.search" placeholder="请输入商品名称" style="width:168px" />
|
3f535f30
杨鑫
'初始'
|
10
11
|
</el-form-item>
<el-form-item label="上架状态">
|
b12ba7ef
杨鑫
'最新'
|
12
|
<el-select v-model="formInline.shelveState" placeholder="请选择上架状态" style="width:168px">
|
3f535f30
杨鑫
'初始'
|
13
14
15
16
17
18
|
<el-option label="全部" :value="null" />
<el-option label="上架" value="1" />
<el-option label="下架" value="0" />
</el-select>
</el-form-item>
<el-form-item label="官方分类">
|
89bb9f2b
wesley88
1
|
19
|
<el-cascader v-model="formInline.classifyId" :options="categoryList" clearable :props="{
|
3f535f30
杨鑫
'初始'
|
20
21
22
23
24
|
checkStrictly: true,
expandTrigger: 'hover',
label:'categoryName',
value:'id',
children:'childs'
|
89bb9f2b
wesley88
1
|
25
|
}" />
|
3f535f30
杨鑫
'初始'
|
26
27
28
|
</el-form-item>
</el-form>
|
b12ba7ef
杨鑫
'最新'
|
29
|
<div style="width:20%">
|
89bb9f2b
wesley88
1
|
30
31
32
|
<el-button @click="search" style="background-color: #3F9B6A;color: #fff;">查询</el-button>
<el-button @click="clear" class="buttonHover"
style="color: #606266;border: 1px solid #dddfe5;background-color: #fff;">重置</el-button>
|
b12ba7ef
杨鑫
'最新'
|
33
|
|
3f535f30
杨鑫
'初始'
|
34
35
|
</div>
</div>
|
b12ba7ef
杨鑫
'最新'
|
36
|
<div style="margin-bottom:20px;">
|
89bb9f2b
wesley88
1
|
37
38
39
|
<el-button @click="add" style="background-color: #3F9B6A;color: #fff;">新增商品</el-button>
<el-button @click="sends" style="background-color: #3F9B6A;color: #fff;">批量导入</el-button>
<el-button @click="productDataExport" style="background-color: #3F9B6A;color: #fff;">导出商品</el-button>
|
b12ba7ef
杨鑫
'最新'
|
40
|
</div>
|
3f535f30
杨鑫
'初始'
|
41
42
|
<!-- 表格 -->
<div class="tableBox">
|
89bb9f2b
wesley88
1
|
43
44
45
|
<el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" @selection-change="handleSelectionChange"
:header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}">
<!-- <el-table-column
|
3f535f30
杨鑫
'初始'
|
46
47
48
49
50
51
52
|
type="selection"
v-if="teble_sel"
min-width="4%">
</el-table-column> -->
<el-table-column prop="productId" label="商品id" show-overflow-tooltip />
<el-table-column label="商品主图" width="150" align="center">
<template slot-scope="scope">
|
65478d1d
杨鑫
'最新'
|
53
|
<img height="80" width="80" :src="$baseURL+msgList(scope.row.productImage)" alt srcset>
|
3f535f30
杨鑫
'初始'
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
</template>
</el-table-column>
<el-table-column prop="productName" label="商品名称" width="220" />
<el-table-column prop="section" label="售价区间" show-overflow-tooltip />
<el-table-column prop="memberSection" label="会员价" show-overflow-tooltip />
<el-table-column prop="ifCredit" label="积分兑换" show-overflow-tooltip>
<template slot-scope="scope">
<span v-if="scope.row.ifCredit == 1">允许</span>
<span v-if="scope.row.ifCredit == 0">不允许</span>
</template>
</el-table-column>
<el-table-column prop="stockNumber" label="库存" show-overflow-tooltip />
<el-table-column prop="volume" label="销量" show-overflow-tooltip />
<el-table-column prop="volume" label="上架状态" show-overflow-tooltip>
<template slot-scope="scope">
<span v-if="scope.row.shelveState==0">未上架</span>
<span v-if="scope.row.shelveState==1">已上架</span>
<span v-if="scope.row.shelveState==2">待审核</span>
<span v-if="scope.row.shelveState==3">审核失败</span>
</template>
</el-table-column>
<el-table-column prop="reject" label="驳回原因" show-overflow-tooltip />
<el-table-column :formatter="row=>getBrandName(row)" label="品牌" show-overflow-tooltip />
<el-table-column prop="createTime" label="创建时间" width="180" />
|
1991126c
杨鑫
'最新'
|
78
|
<el-table-column label="操作" width="180" fixed="right">
|
3f535f30
杨鑫
'初始'
|
79
80
|
<template slot-scope="scope">
<div class="btnList">
|
89bb9f2b
wesley88
1
|
81
82
83
84
85
|
<div @click="edit(scope.row)" class="tableBtn greens">编辑</div>
<div @click="down(scope.row)" v-if="scope.row.shelveState==0" class="tableBtn greens">上架</div>
<div @click="down(scope.row)" v-if="scope.row.shelveState==1" class="tableBtn greens">下架</div>
<div @click="setVipPrice(scope.row)" v-if="scope.row.shelveState==1" class="tableBtn greens">设置会员价</div>
<div @click="del(scope.row)" v-if="scope.row.shelveState!=1" class="tableBtn greens">删除</div>
|
3f535f30
杨鑫
'初始'
|
86
|
|
89bb9f2b
wesley88
1
|
87
|
<!-- <el-button type="text" @click="edit(scope.row)">编辑</el-button>
|
3f535f30
杨鑫
'初始'
|
88
89
90
91
92
93
94
95
96
|
<el-button v-if="scope.row.shelveState==0" type="text" @click="down(scope.row)">上架</el-button>
<el-button v-if="scope.row.shelveState==1" type="text" @click="down(scope.row)">下架</el-button>
<el-button v-if="scope.row.shelveState==1" type="text" @click="setVipPrice(scope.row)">设置会员价</el-button>
<el-button v-if="scope.row.shelveState!=1" type="text" @click="del(scope.row)">删除</el-button> -->
</div>
</template>
</el-table-column>
</el-table>
<div class="fenye">
|
89bb9f2b
wesley88
1
|
97
98
99
|
<el-pagination :current-page="formInline.page" :page-sizes="[10, 20, 50, 100]" :page-size="10" background
layout="prev, pager, next,total" :total="total" @size-change="handleSizeChange"
@current-change="handleCurrentChange" />
|
3f535f30
杨鑫
'初始'
|
100
101
102
103
104
|
</div>
</div>
</div>
<!-- 批量导入 -->
|
89bb9f2b
wesley88
1
|
105
|
<el-dialog title="批量导入商品" :visible.sync="batchAdd" :close-on-click-modal="false" center width="400px">
|
3f535f30
杨鑫
'初始'
|
106
|
<div class="uploadDialog">
|
89bb9f2b
wesley88
1
|
107
108
109
|
<el-upload drag :limit="1" :auto-upload="false" accept=".xlsx" :headers="headers" :action="UploadUrl"
:before-upload="beforeUploadFile" :on-change="fileChange" :on-remove="batchRemove" :on-exceed="exceedFile"
:on-success="handleSuccess" :on-error="handleError" :file-list="batchFileList">
|
3f535f30
杨鑫
'初始'
|
110
111
|
<i class="el-icon-upload" />
<div class="el-upload__text">
|
ad7d1a78
杨鑫
'最新'
|
112
|
<em style="color:#3F9B6A;">点击上传</em>
|
3f535f30
杨鑫
'初始'
|
113
114
115
116
117
118
119
120
121
122
123
124
|
</div>
<div slot="tip" class="el-upload__tip">只能上传xlsx文件,且不超过10M</div>
<div slot="tip" class="el-upload__tip">
上传前不知道excel模板的,请点击
<span class="clickMe" @click="poDownload">点我下载模板</span> 去下载
</div>
</el-upload>
<br>
<el-button size="small" type="primary" @click="uploadFile">立即上传</el-button>
</div>
</el-dialog>
<!-- 设置会员价弹窗 -->
|
89bb9f2b
wesley88
1
|
125
|
<el-dialog title="设置会员价" :visible.sync="vipPriceVisible" width="50%" class="vipDialog">
|
3f535f30
杨鑫
'初始'
|
126
127
128
129
|
<el-form ref="form" label-width="80px">
<el-form-item label="优惠方式">
<el-radio-group v-model="mode" @change="modeChange">
<el-radio :label="1">折扣</el-radio>
|
41c84754
杨鑫
'最新'
|
130
|
<!-- <el-radio :label="2">指定价格</el-radio> -->
|
3f535f30
杨鑫
'初始'
|
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
</el-radio-group>
</el-form-item>
<div class="priceTable">
<table>
<tr>
<th>规格</th>
<th>售价</th>
<th v-for="(item,index) in gradeList" :key="index">
{{ item }}
</th>
</tr>
<tr v-for="(item,index) in productData" :key="index">
<td>
{{ item.value }}
</td>
<td>
{{ item.price }}
</td>
<td v-for="(itemJ,indexJ) in item.memberPrices" :key="indexJ" class="td-input">
|
89bb9f2b
wesley88
1
|
150
151
|
<el-input v-model="itemJ.price" oninput="value=value.replace(/([^\d|\.])/g, '')" />
{{ mode==1?'折':'元' }}
|
3f535f30
杨鑫
'初始'
|
152
153
154
155
|
</td>
</tr>
</table>
</div>
|
89bb9f2b
wesley88
1
|
156
157
|
<el-button style="background-color: #3F9B6A;color: #fff;" class="clearBtn"
@click="clearProductMember">清除所有旧会员价</el-button>
|
3f535f30
杨鑫
'初始'
|
158
159
|
</el-form>
<span slot="footer" class="dialog-footer">
|
1991126c
杨鑫
'最新'
|
160
|
<el-button @click="vipPriceVisible = false" class="buttonHover"
|
89bb9f2b
wesley88
1
|
161
|
style="color: #606266;border: 1px solid #dddfe5;background-color: #fff;">取 消</el-button>
|
3f535f30
杨鑫
'初始'
|
162
163
164
165
|
<el-button type="primary" @click="vipPriceSubmit">确 定</el-button>
</span>
</el-dialog>
<!-- 新增/修改商品弹窗 -->
|
89bb9f2b
wesley88
1
|
166
167
168
169
170
171
172
173
|
<!-- <el-dialog :title="!commId ? '新增商品' : '编辑商品'" :visible.sync="commidyVisible" custom-class="bian_css" width="70%"
center top="6vh" :close-on-click-modal="false" @before-close="closeModal" @close="closeModal">
<CommAdd ref="child" :show-tinymce="showTinymce" :product-id="commId" @cancel="cancelForm" />
</el-dialog> -->
<div v-if ="ontype == '2'" class="tab_show">
<CommAdd v-if ="ontype == '2'" ref="child" :show-tinymce="showTinymce" :product-id="commId" @cancel="cancelForm" />
</div>
|
3f535f30
杨鑫
'初始'
|
174
175
176
177
|
</div>
</template>
<script>
|
89bb9f2b
wesley88
1
|
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
import CommAdd from '@/views/commodity/commoditySystem/addCommodity.vue'
import {
getBtnList,
getToken
} from '@/utils/auth'
import {
uploadUrl
} from '@/utils/request'
import {
getClassifyGetAll,
getClassifyDelete,
getClassifyStart,
downloadTemplate,
importProduct,
getClassify,
getProductMembers,
setProductMember,
clearProductMember,
productExport,
getBrandList
} from '@/api/commodity'
export default {
components: {
CommAdd
|
65478d1d
杨鑫
'最新'
|
202
|
},
|
89bb9f2b
wesley88
1
|
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
|
data() {
// 这里存放数据
return {
ontype:'1',
showTinymce: false,
btnList: '',
activeName: 'first',
formInline: {
search: '', // 搜索字段
shelveState: '', // 上架状态 1-上架 0-不上架 null-全部
stock: '', // 库存状态 1-有库存 0-无库存 null-全部
classifyId: '', // 最下级分类id
page: 1, // 当前页
pageSize: 10
},
batchAdd: false,
batchFileList: [],
total: 1,
tableData: [],
categoryList: [],
UploadUrl: uploadUrl,
headers: {
'Authorization-business': getToken()
},
vipPriceVisible: false,
productId: 0,
mode: 1,
productData: [],
gradeList: [],
commidyVisible: false,
commId: 0,
brandList: [],
teble_sel: false,
canst: '' //组合商品ID
|
3f535f30
杨鑫
'初始'
|
237
|
}
|
3f535f30
杨鑫
'初始'
|
238
|
},
|
89bb9f2b
wesley88
1
|
239
240
241
242
243
244
245
|
computed: {
getBrandName() {
return (row) => {
const find = this.brandList.find(item => item.id === row.brandId);
if (find) return find.brandName
return '-'
}
|
3f535f30
杨鑫
'初始'
|
246
247
|
}
},
|
89bb9f2b
wesley88
1
|
248
249
|
mounted() {
this.getBrandList()
|
3f535f30
杨鑫
'初始'
|
250
|
this.getAll(this.formInline)
|
89bb9f2b
wesley88
1
|
251
252
|
this.queryAllCategory()
this.btnList = getBtnList()
|
3f535f30
杨鑫
'初始'
|
253
|
},
|
89bb9f2b
wesley88
1
|
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
|
// 方法集合
methods: {
msgList(list) {
if (list && list != '') {
let strin = list.split(',')
return strin[0]
}
},
async getBrandList() {
const {
data
} = await getBrandList()
this.brandList = data
},
cancelForm() {
this.commidyVisible = false
this.ontype = '1'
this.formInline = {
search: '',
shelveState: '',
stock: '',
classifyId: '',
page: 1,
pageSize: 10
}
this.getAll(this.formInline)
this.closeModal()
},
closeModal() {
this.showTinymce = false
this.$refs.child.last()
|
3f535f30
杨鑫
'初始'
|
285
|
this.$refs.child.reset()
|
89bb9f2b
wesley88
1
|
286
287
288
289
290
291
|
},
btnClick(id) {
if (id.permissionName === '批量导入') {
this.sends()
} else if (id.permissionName === '新增商品') {
this.add()
|
3f535f30
杨鑫
'初始'
|
292
|
}
|
89bb9f2b
wesley88
1
|
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
|
},
handleSizeChange(val) {
this.formInline.pageSize = val
this.getAll(this.formInline)
},
handleCurrentChange(val) {
this.formInline.page = val
this.getAll(this.formInline)
},
// 查询
search() {
this.total = 1
this.formInline.page = 1
this.getAll(this.formInline)
},
// 重置
clear() {
this.formInline = {
search: '', // 搜索字段
shelveState: '', // 上架状态 1-上架 0-不上架 null-全部
stock: '', // 库存状态 1-有库存 0-无库存 null-全部
classifyId: '', // 最下级分类id
page: 1, // 当前页
pageSize: 10
}
},
// 新增商品
add() {
this.showTinymce = true
// if (this.commId) {
// this.$refs.child.reset()
// }
this.commidyVisible = true
this.commId = null
this.ontype = '2'
// this.$router.push({ name: 'addCommodity', params: { id: '1' }})
},
// 导出商品
async productDataExport() {
this.$message({
message: '数据导出中,请勿重复操作!',
type: 'success'
})
const res = await productExport(this.formInline)
if (!res) {
return
}
const blob = new Blob([res], {
type: 'application/vnd.ms-excel'
})
const fileName = '商品数据明细表.xls'
if ('download' in document.createElement('a')) {
// 非IE下载
const elink = document.createElement('a')
elink.download = fileName
elink.href = URL.createObjectURL(blob)
elink.style.display = 'none'
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href) // 释放URL 对象
document.body.removeChild(elink)
} else {
// IE10+下载
navigator.msSaveBlob(blob, fileName)
}
},
// 批量导入
sends() {
this.batchAdd = true
this.batchFileList = []
},
// 编辑商品
edit(row) {
this.showTinymce = true
this.commidyVisible = true
this.ontype = '2'
this.commId = row.productId
this.$nextTick(() => {
this.$refs.child?.details()
})
// this.$router.push({
// name: 'addCommodity',
// params: { productId: row.productId }
// })
// let res = await getClassifyGetById({ productId: row.productId });
// console.log(res);
},
// 设置会员价
setVipPrice(row) {
var _ = this
this.productId = row.productId
getProductMembers({
productId: row.productId
}).then(res => {
console.log(res, '11231312312312')
if (res.code === '') {
_.productData = res.data
if (_.productData && _.productData.length > 0) {
_.gradeList = []
const _memberPrices = _.productData[0].memberPrices
_memberPrices.forEach(function(item, i) {
_.gradeList.push(item.memberLevelName)
|
3f535f30
杨鑫
'初始'
|
395
|
})
|
89bb9f2b
wesley88
1
|
396
397
|
_.mode = _.productData[0].mode ? _.productData[0].mode : 1
_.vipPriceVisible = true
|
3f535f30
杨鑫
'初始'
|
398
|
}
|
89bb9f2b
wesley88
1
|
399
400
401
402
403
404
405
406
407
408
409
|
}
})
},
// 设置会员价提交
vipPriceSubmit() {
for (let i = 0; i < this.productData.length; i++) {
this.productData[i].mode = this.mode
for (let j = 0; j < this.productData[i].memberPrices.length; j++) {
this.productData[i].memberPrices[j].mode = this.mode
var _price = this.productData[i].memberPrices[j].price
if (!_price) {
|
3f535f30
杨鑫
'初始'
|
410
411
|
this.$message({
type: 'warning',
|
89bb9f2b
wesley88
1
|
412
|
message: '会员价格不能为空!'
|
3f535f30
杨鑫
'初始'
|
413
414
|
})
return false
|
89bb9f2b
wesley88
1
|
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
|
} else if (this.productData[i].mode === 1) {
if (_price <= 0 || _price >= 10) {
this.$message({
type: 'warning',
message: '会员折数必须大于0小于10!'
})
return false
}
} else if (this.productData[i].mode === 2) {
if (_price > this.productData[i].price) {
this.$message({
type: 'warning',
message: '会员价格不能大于原价!'
})
return false
}
|
3f535f30
杨鑫
'初始'
|
431
432
433
|
}
}
}
|
89bb9f2b
wesley88
1
|
434
435
436
437
|
setProductMember({
productId: this.productId,
members: this.productData
}).then(res => {
|
3f535f30
杨鑫
'初始'
|
438
|
if (res.code === '') {
|
89bb9f2b
wesley88
1
|
439
440
441
|
this.$message({
type: 'success',
message: '设置成功!'
|
3f535f30
杨鑫
'初始'
|
442
|
})
|
89bb9f2b
wesley88
1
|
443
444
|
this.getAll(this.formInline)
this.vipPriceVisible = false
|
3f535f30
杨鑫
'初始'
|
445
446
|
}
})
|
89bb9f2b
wesley88
1
|
447
448
449
450
451
452
453
454
455
456
457
458
|
},
// 清空会员价
clearProductMember() {
console.log(this.productData, 'this.productData')
this.$confirm('该商品所有旧设置的会员价将被清除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
clearProductMember({
productId: this.productId
}).then(res => {
|
3f535f30
杨鑫
'初始'
|
459
|
if (res.code === '') {
|
89bb9f2b
wesley88
1
|
460
461
462
463
|
this.productData.map(item => {
item.memberPrices.map(itemChild => {
itemChild.price = null
})
|
3f535f30
杨鑫
'初始'
|
464
|
})
|
89bb9f2b
wesley88
1
|
465
466
|
this.$message.success('清除成功')
// this.vipPriceVisible = false
|
3f535f30
杨鑫
'初始'
|
467
468
469
|
}
})
})
|
89bb9f2b
wesley88
1
|
470
471
472
473
474
475
476
|
},
// 删除商品
del(row) {
this.$confirm('选中数据将被永久删除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
|
3f535f30
杨鑫
'初始'
|
477
|
})
|
89bb9f2b
wesley88
1
|
478
479
480
481
482
483
484
485
486
487
488
489
|
.then(() => {
getClassifyDelete({
productId: row.productId
}).then(res => {
if (res.code === '') {
this.$message({
type: 'success',
message: '删除成功!'
})
this.getAll(this.formInline)
}
})
|
3f535f30
杨鑫
'初始'
|
490
|
})
|
89bb9f2b
wesley88
1
|
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
|
.catch(() => {})
},
// 商品上下架
async down(row) {
console.log(row.shelveState)
if (row.shelveState) {
console.log(111)
const res = await getClassifyStart({
productId: row.productId,
shelveState: 0
})
if (res.code === '') {
this.$message({
type: 'success',
message: '下架成功!'
})
this.getAll(this.formInline)
}
|
3f535f30
杨鑫
'初始'
|
509
|
} else {
|
89bb9f2b
wesley88
1
|
510
511
512
513
|
const res = await getClassifyStart({
productId: row.productId,
shelveState: 1
})
|
3f535f30
杨鑫
'初始'
|
514
|
if (res.code === '') {
|
89bb9f2b
wesley88
1
|
515
516
517
518
|
this.$message({
type: 'success',
message: '上架成功!'
})
|
3f535f30
杨鑫
'初始'
|
519
520
|
this.getAll(this.formInline)
}
|
89bb9f2b
wesley88
1
|
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
|
}
},
// 初始化查询所有数据
async getAll(formInline) {
this.formInline.classifyId =
this.formInline.classifyId[2] ||
this.formInline.classifyId[1] ||
this.formInline.classifyId[0] ||
this.formInline.classifyId
const res = await getClassifyGetAll(formInline)
this.total = res.data.total
this.tableData = res.data.list
console.log(this.tableData)
},
// 初始化查询所有分类
async queryAllCategory() {
const res = await getClassify()
this.categoryList = res.data
this.handleRemoveEmptyChild(this.categoryList)
},
handleRemoveEmptyChild(arr) {
for (let i = 0; i < arr.length; i++) {
if (arr[i].childs && Array.isArray(arr[i].childs)) {
this.handleRemoveEmptyChild(arr[i].childs)
}
if (arr[i].childs && Array.isArray(arr[i].childs) && arr[i].childs.length === 0) {
delete arr[i].childs
|
3f535f30
杨鑫
'初始'
|
548
|
}
|
1991126c
杨鑫
'最新'
|
549
|
}
|
89bb9f2b
wesley88
1
|
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
|
},
// *********************导入部分
UploadUrls: function() {
// 因为action参数是必填项,我们使用二次确认进行文件上传时,直接填上传文件的url会因为没有参数导致api报404,所以这里将action设置为一个返回为空的方法就行,避免抛错
return ''
},
// 下载模板
poDownload() {
downloadTemplate().then(res => {
console.log(res, 1111)
// const content = res
const blob = new Blob([res])
const fileName = '批量导入商品模板.xlsx'
if ('download' in document.createElement('a')) {
// 非IE下载
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'none'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href) // 释放URL 对象
document.body.removeChild(elink)
} else {
// IE10+下载
navigator.msSaveBlob(blob, fileName)
}
})
},
// 导入
uploadFile() {
if (this.batchFileList.length === 0) {
this.$message.warning('请上传文件')
} else {
const formDate = new FormData()
formDate.append('file', this.batchFileList[0])
console.log(formDate.get('file'))
importProduct(formDate).then(res => {
console.log(res)
if (res.code === '') {
this.$message.success('导入成功')
this.batchAdd = false
this.batchFileList = []
this.getAll(this.formInline)
}
})
|
1991126c
杨鑫
'最新'
|
596
|
}
|
89bb9f2b
wesley88
1
|
597
598
599
600
601
602
603
604
605
|
},
// 上传文件之前的钩子, 参数为上传的文件,若返回 false 或者返回 Promise 且被 reject,则停止上传
beforeUploadFile(file) {
console.log('before upload')
console.log(file)
const extension = file.name.substring(file.name.lastIndexOf('.') + 1)
const size = file.size / 1024 / 1024
if (extension !== 'xlsx') {
this.$message.warning('只能上传后缀是.xlsx的文件')
|
1991126c
杨鑫
'最新'
|
606
|
}
|
89bb9f2b
wesley88
1
|
607
608
|
if (size > 10) {
this.$message.warning('文件大小不得超过10M')
|
1991126c
杨鑫
'最新'
|
609
|
}
|
89bb9f2b
wesley88
1
|
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
|
},
// 文件状态改变时的钩子
fileChange(file, batchFileList) {
console.log(file.raw)
this.batchFileList.push(file.raw)
console.log(this.batchFileList)
},
batchRemove(file, batchFileList) {
this.batchFileList = []
},
// 文件超出个数限制时的钩子
exceedFile(files, batchFileList) {
this.$message.warning(`只能选择1个文件`)
},
// 文件上传成功时的钩子
handleSuccess(res, file, batchFileList) {
this.$message.success('文件上传成功')
},
// 文件上传失败时的钩子
handleError() {
this.$message.error('文件上传失败')
},
// 切换优惠方式清除内容
modeChange() {
this.productData.forEach(item => {
item.memberPrices.forEach(itemJ => {
itemJ.price = ''
})
})
},
handleSelectionChange(val) {
console.log(val)
let zuheId = ''
for (let i = 0; i < val.length; i++) {
zuheId += val[i].productId + ','
|
1991126c
杨鑫
'最新'
|
645
|
}
|
89bb9f2b
wesley88
1
|
646
|
this.canst = zuheId
|
1991126c
杨鑫
'最新'
|
647
|
}
|
89bb9f2b
wesley88
1
|
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
|
}
}
</script>
<style lang='scss' scoped>
//@import url(); 引入公共css类
@import url("../../../styles/elDialog.scss");
::v-deep .bian_css {
margin: auto;
max-height: 840px;
overflow-y: auto;
.el-dialog__body {
padding: 0px;
background-color: #fff;
}
.el-dialog__header {
background-color: #fff;
padding: 10px 20px 10px 20px;
border-bottom: 1px solid #EFEFEF;
}
.el-dialog__title {
font-size: 14px;
color: #000000e6;
}
.el-date-table td.available:hover {
background-color: #3F9B6A;
}
.el-date-table td.start-date span {
background-color: #3F9B6A;
}
}
.tab_show {
padding: 0 20px 20px 20px;
background-color: #fff;
}
.fenye {
margin-top: 20px;
display: flex;
justify-content: flex-end;
position: relative;
}
|
3f535f30
杨鑫
'初始'
|
697
698
699
700
|
::v-deep .el-pagination__total {
position: absolute;
left: 10px;
}
|
89bb9f2b
wesley88
1
|
701
|
|
3f535f30
杨鑫
'初始'
|
702
|
.formSearch {
|
89bb9f2b
wesley88
1
|
703
704
705
706
707
|
display: flex;
width: 100%;
font-size: 14px;
justify-content: space-between;
}
|
3f535f30
杨鑫
'初始'
|
708
|
|
89bb9f2b
wesley88
1
|
709
710
711
712
713
714
715
716
717
718
|
.uploadDialog {
// display: flex;
// flex-direction: column;
// justify-content: center;
>>>.el-upload__tip {
display: inline-block;
width: 360px;
margin: auto;
}
|
3f535f30
杨鑫
'初始'
|
719
|
}
|
89bb9f2b
wesley88
1
|
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
|
.vipDialog {
.priceTable {
table {
width: 100%;
text-align: center;
border-left: 1px solid #EBEEF5;
border-bottom: 1px solid #EBEEF5;
font-size: 14px;
color: #606266;
border-collapse: collapse;
tr {
border-top: 1px solid #EBEEF5;
th {
padding: 12px 0;
background: #F2F3F5;
color: #0009;
border-right: 1px solid #F2F3F5;
}
td {
padding: 12px 0;
border-right: 1px solid #EBEEF5;
&.td-input {
.el-input {
width: 80px;
margin-right: 0;
}
}
&:nth-child(1),
&:nth-child(2) {
|
3f535f30
杨鑫
'初始'
|
755
|
width: 80px;
|
3f535f30
杨鑫
'初始'
|
756
|
}
|
89bb9f2b
wesley88
1
|
757
758
759
760
761
|
.el-input {
width: 100px;
margin-right: 10px;
}
|
3f535f30
杨鑫
'初始'
|
762
763
764
765
|
}
}
}
}
|
1991126c
杨鑫
'最新'
|
766
|
|
89bb9f2b
wesley88
1
|
767
768
769
770
|
.clearBtn {
margin-top: 20px;
}
}
|
3f535f30
杨鑫
'初始'
|
771
|
</style>
|