index.vue
8.6 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
<!-- -->
<template>
<div style="padding: 0 10px;background-color:#f7f7f7;">
<div class="tab_show">
<el-tabs v-model="formInline.type" @tab-click="handleClick">
<el-tab-pane label="全部" :name="null" />
<el-tab-pane label="待商家处理" name="1" />
<el-tab-pane label="待商家收货" name="2" />
</el-tabs>
<!-- 搜索 -->
<div class="formSearch">
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item>
<div>
<el-input v-model="formInline.search" placeholder="请输入内容">
<el-select
slot="prepend"
v-model="formInline.searchType"
style="width:130px"
placeholder="请选择"
>
<el-option label="售后id" value="1" />
<el-option label="买家账户" value="2" />
<el-option label="收件人姓名" value="3" />
<el-option label="收件人手机号" value="4" />
<el-option label="商品ID" value="5" />
</el-select>
</el-input>
</div>
</el-form-item>
<el-form-item label="订单状态">
<el-select v-model="formInline.state" placeholder="请选择订单状态">
<el-option label="全部" :value="null" />
<el-option label="待付款" value="1" />
<el-option label="待发货" value="2" />
<el-option label="已发货" value="3" />
<el-option label="已完成" value="4" />
<el-option label="已关闭" value="5" />
</el-select>
</el-form-item>
<el-form-item label="售后状态">
<el-select v-model="formInline.afterState" placeholder="请选择售后状态">
<el-option label="全部" :value="null" />
<!-- <el-option label="无售后" value="0" /> -->
<el-option label="售后中" value="1" />
<el-option label="售后成功" value="2" />
<el-option label="售后关闭" value="3" />
</el-select>
</el-form-item>
<el-form-item label="售后类型">
<el-select v-model="formInline.afterType" placeholder="请选择售后类型">
<el-option label="全部" :value="null" />
<el-option label="仅退款" value="1" />
<el-option label="退货退款" value="2" />
</el-select>
</el-form-item>
</el-form>
<div style="width:20%">
<el-button style="background-color: #3F9B6A;color: #fff" @click="search">查询</el-button>
<el-button style="background-color: #3F9B6A;color: #fff" @click="afterOrderDataExport">导出订单</el-button>
</div>
</div>
<!-- 表格 -->
<div class="tableBox">
<el-table
ref="multipleTable"
v-loading="loading"
:data="tableData"
:header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}"
tooltip-effect="dark"
>
<el-table-column label="售后id" width="220">
<template slot-scope="scope">{{ scope.row.afterId }}</template>
</el-table-column>
<el-table-column prop="afterFormid" label="售后单号" width="220" />
<el-table-column prop="afterId" label="售后类型" show-overflow-tooltip>
<template slot-scope="scope">
<span v-if="scope.row.afterType == 1">仅退款</span>
<span v-if="scope.row.afterType == 2">退货退款</span>
</template>
</el-table-column>
<el-table-column prop="price" label="退款金额(元)" show-overflow-tooltip />
<el-table-column prop="afterStateName" label="售后状态" show-overflow-tooltip />
<el-table-column prop="createTime" label="申请时间" show-overflow-tooltip />
<el-table-column label="操作" show-overflow-tooltip>
<template slot-scope="scope">
<div class="btnList">
<div @click="view(scope.row)" class="tableBtn greens" >{{ scope.row.afterState == 1 ? '处理' : '查看' }}</div>
</div>
</template>
</el-table-column>
</el-table>
<div class="fenye">
<el-pagination
class="pagination"
:current-page="currentPage"
:page-size="10"
background
small
:page-sizes="[10, 20, 50, 100]"
layout="prev, pager, next,total"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</div>
</div>
<after-details ref="afterDetails" @childMessage="handleChildMessage" />
</div>
</template>
<script>
// 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
// 例如:import 《组件名称》 from '《组件路径》';
import { aftersaleGetAll, afterOrderExport } from '@/api/order'
import AfterDetails from './afterDetails';
import { type } from 'os';
export default {
components: { AfterDetails },
data() {
// 这里存放数据
return {
loading: false,
activeName: 'first',
total: 1,
tableData: [],
currentPage: 1,
formInline: {
searchType: '1', // 搜索类型 1-订单ID 2-买家账户 3-收件人姓名 4-收件人手机号 5-商品ID
search: '', // 搜索字段
state: '', // 订单状态 1-待付款 2-待发货 3-已发货 4-已完成 5-已关闭
afterState: '', // 售后状态 0-无售后 1-售后中 2-售后成功 3-售后关闭
afterType: '', // 售后类型 1-仅退款 2-退货退款
type: null, // 列表类型 1-待商家处理 2-待商家收货
page: 1,
pageSize: 10
},
multipleSelection: []
}
},
// 监听属性 类似于data概念
computed: {},
// 监控data中的数据变化
watch: {},
// 生命周期 - 创建完成(可以访问当前this实例)
created() {},
// 生命周期 - 挂载完成(可以访问DOM元素)
mounted() {
this.getAll(this.formInline)
},
// 方法集合
methods: {
handleSizeChange(val) {
this.formInline.pageSize = val
this.getAll(this.formInline)
},
handleCurrentChange(val) {
this.formInline.page = val
this.getAll(this.formInline)
},
handleClick(tab, event) {
this.formInline.type = tab.name
this.getAll(this.formInline)
},
// 查询
search() {
this.total = 1
this.formInline.page = 1
this.getAll(this.formInline)
},
// 处理
view(row) {
this.$refs.afterDetails.show(row.afterId)
},
handleChildMessage(msg){
this.getAll(this.formInline)
},
// 初始化查询所有数据
async getAll(formInline) {
this.loading = true
try {
const res = await aftersaleGetAll(formInline)
this.total = res.data.total
this.tableData = res.data.list
} finally {
this.loading = false
}
},
// 导出订单
async afterOrderDataExport() {
this.$message({
message: '数据导出中,请勿重复操作!',
type: 'success'
})
console.log(this.formInline, 'this.formInline')
const res = await afterOrderExport(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) // 将流文件写入a标签的href属性值
elink.style.display = 'none' // 障眼法藏起来a标签
document.body.appendChild(elink) // 将a标签追加到文档对象中
elink.click() // 模拟点击了a标签,会触发a标签的href的读取,浏览器就会自动下载了
URL.revokeObjectURL(elink.href) // 释放URL 对象
document.body.removeChild(elink)
} else {
// IE10+下载
navigator.msSaveBlob(blob, fileName)
}
},
}
}
</script>
<style lang='scss' scoped>
//@import url(); 引入公共css类
@import url("../../../styles/elDialog.scss");
.tab_show {
padding: 0 20px 20px 20px;
background-color:#fff;
}
.fenye {
margin-top: 20px;
display: flex;
justify-content: flex-end;
position: relative;
}
::v-deep .el-pagination__total {
position: absolute;
left: 10px;
}
.formSearch {
display: flex;
width: 100%;
font-size: 14px;
justify-content: space-between;
}
</style>