index.vue
6.72 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
<template>
<div class="simple-page">
<el-card shadow="never">
<el-form size="small"
:inline="true"
:model="query">
<el-form-item label="合同编号">
<el-input v-model.trim="query.contractNo"
placeholder="请输入合同编号"
clearable />
</el-form-item>
<el-form-item label="客户姓名">
<el-input v-model.trim="query.customerName"
placeholder="请输入客户姓名"
clearable />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">
查询
</el-button>
<el-button @click="handleReset">
重置
</el-button>
</el-form-item>
</el-form>
<div class="toolbar">
<el-button size="small"
type="primary"
@click="openEditor()">
新增权益订单
</el-button>
<el-button size="small"
:loading="exporting"
@click="handleExport">
导出
</el-button>
</div>
<el-table v-loading="loading"
empty-text="暂无权益订单"
border
:data="rows">
<el-table-column label="合同编号"
min-width="150"
prop="contractNo" />
<el-table-column label="客户姓名"
min-width="110"
prop="customerName" />
<el-table-column label="手机号"
min-width="130"
prop="mobile" />
<el-table-column label="权益商品"
min-width="160"
prop="packageName"
show-overflow-tooltip />
<el-table-column label="车牌号"
min-width="110"
prop="vehicleNo" />
<el-table-column label="状态"
min-width="100"
prop="statusName" />
<el-table-column fixed="right"
label="操作"
width="320">
<template #default="scope">
<el-button type="text" @click="openEditor(scope.row, true)">
查看
</el-button>
<el-button type="text" @click="openEditor(scope.row)">
编辑
</el-button>
<el-button type="text" @click="showRecords(scope.row)">
修改记录
</el-button>
<el-button type="text" @click="printContract(scope.row)">
合同
</el-button>
<el-button class="danger"
type="text"
@click="chargeBack(scope.row)">
退单
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination class="pagination"
layout="total, sizes, prev, pager, next, jumper"
:current-page="pageNum"
:page-size="pageSize"
:total="total"
@current-change="handlePageChange"
@size-change="handleSizeChange" />
</el-card>
<el-dialog title="修改记录"
width="720px"
:visible.sync="recordVisible">
<el-table empty-text="暂无修改记录"
border
:data="recordRows">
<el-table-column label="修改时间"
prop="updateTime"
width="180" />
<el-table-column label="操作人"
prop="operatorName"
width="120" />
<el-table-column label="修改内容"
prop="content"
show-overflow-tooltip />
</el-table>
</el-dialog>
</div>
</template>
<script>
import {
chargeBackOrder,
exportEquityOrders,
getEquityOrderList,
getOrderUpdateDetails,
printEquityContract,
} from "@/api/equityOrder";
import { normalizePage, openDownload } from "../migrationSupport";
export default {
name: "EquityOrderList",
data() {
return {
query: { contractNo: "", customerName: "" },
rows: [],
recordRows: [],
pageNum: 1,
pageSize: 20,
total: 0,
loading: false,
exporting: false,
recordVisible: false,
};
},
created() {
this.loadList();
},
methods: {
async loadList() {
this.loading = true;
try {
const result = normalizePage(await getEquityOrderList({
...this.query,
pageNum: this.pageNum,
pageSize: this.pageSize,
}));
this.rows = result.rows;
this.total = result.total;
} catch (error) {
this.rows = [];
this.total = 0;
this.$message.error("权益订单加载失败,请稍后重试");
} finally {
this.loading = false;
}
},
handleSearch() {
this.pageNum = 1;
return this.loadList();
},
handleReset() {
this.query = { contractNo: "", customerName: "" };
return this.handleSearch();
},
handlePageChange(pageNum) {
this.pageNum = pageNum;
this.loadList();
},
handleSizeChange(pageSize) {
this.pageSize = pageSize;
this.handleSearch();
},
openEditor(row = {}, readonly = false) {
this.$router.push({
name: "equityOrderEdit",
query: { id: row.id, readonly: readonly ? "1" : "0" },
});
},
async showRecords(row) {
try {
const result = normalizePage(await getOrderUpdateDetails({ equityId: row.id }));
this.recordRows = result.rows;
this.recordVisible = true;
} catch (error) {
this.$message.error("修改记录加载失败");
}
},
async printContract(row) {
try {
openDownload(await printEquityContract({ contractNo: row.contractNo }));
} catch (error) {
this.$message.error("合同预览失败");
}
},
async chargeBack(row) {
try {
await this.$confirm(`确认退回合同 ${row.contractNo || ""} 吗?`, "退单确认", { type: "warning" });
await chargeBackOrder({ id: row.id, contractNo: row.contractNo });
this.$message.success("退单成功");
await this.loadList();
} catch (error) {
if (error !== "cancel" && error !== "close") {
this.$message.error("退单失败,请稍后重试");
}
}
},
async handleExport() {
this.exporting = true;
try {
openDownload(await exportEquityOrders({ ...this.query }));
} catch (error) {
this.$message.error("导出失败,请稍后重试");
} finally {
this.exporting = false;
}
},
},
};
</script>
<style scoped>
.simple-page {
padding: 16px;
}
.toolbar {
margin-bottom: 16px;
}
.pagination {
margin-top: 16px;
text-align: right;
}
.danger {
color: #f56c6c;
}
</style>