|
@@ -0,0 +1,368 @@
|
|
1
|
+<template>
|
|
2
|
+ <div class="app-container">
|
|
3
|
+ <div class="header">
|
|
4
|
+ <el-button icon="el-icon-d-arrow-left" plain type="primary" class="back" @click="goBack">返回</el-button>
|
|
5
|
+ <h1>{{ '【' + carInfo.licensePlate + '】' }}车辆明细</h1>
|
|
6
|
+ </div>
|
|
7
|
+ <el-divider></el-divider>
|
|
8
|
+ <el-descriptions class="descriptions" :column="column" border style="text-align: center;">
|
|
9
|
+ <el-descriptions-item>
|
|
10
|
+ <template slot="label">
|
|
11
|
+ <svg-icon slot="prefix" icon-class="car" class="el-input__icon input-icon" />
|
|
12
|
+ 车牌号
|
|
13
|
+ </template>
|
|
14
|
+ {{ carInfo.licensePlate }}
|
|
15
|
+ </el-descriptions-item>
|
|
16
|
+ <el-descriptions-item>
|
|
17
|
+ <template slot="label">
|
|
18
|
+ <svg-icon slot="prefix" icon-class="Branding" class="el-input__icon input-icon" />
|
|
19
|
+ 品牌
|
|
20
|
+ </template>
|
|
21
|
+ {{ carInfo.brand }}
|
|
22
|
+ </el-descriptions-item>
|
|
23
|
+ <el-descriptions-item>
|
|
24
|
+ <template slot="label">
|
|
25
|
+ <svg-icon slot="prefix" icon-class="PhAppStoreLogoFill" class="el-input__icon input-icon" />
|
|
26
|
+ 系列
|
|
27
|
+ </template>
|
|
28
|
+ {{ carInfo.series }}
|
|
29
|
+ </el-descriptions-item>
|
|
30
|
+ <el-descriptions-item>
|
|
31
|
+ <template slot="label">
|
|
32
|
+ <svg-icon slot="prefix" icon-class="cost" class="el-input__icon input-icon" />
|
|
33
|
+ 总价
|
|
34
|
+ </template>
|
|
35
|
+ {{ carInfo.cost }}
|
|
36
|
+ </el-descriptions-item>
|
|
37
|
+ <el-descriptions-item>
|
|
38
|
+ <template slot="label">
|
|
39
|
+ <svg-icon slot="prefix" icon-class="date" class="el-input__icon input-icon" />
|
|
40
|
+ 上牌时间
|
|
41
|
+ </template>
|
|
42
|
+ {{ parseTime(carInfo.acquisitionTime, '{y}-{m}-{d}') }}
|
|
43
|
+ </el-descriptions-item>
|
|
44
|
+ <el-descriptions-item>
|
|
45
|
+ <template slot="label">
|
|
46
|
+ <i class="el-icon-user-solid"></i>
|
|
47
|
+ 驾驶员
|
|
48
|
+ </template>
|
|
49
|
+ {{ carInfo.driver }}
|
|
50
|
+ </el-descriptions-item>
|
|
51
|
+ <el-descriptions-item>
|
|
52
|
+ <template slot="label">
|
|
53
|
+ <svg-icon slot="prefix" icon-class="date" class="el-input__icon input-icon" />
|
|
54
|
+ 预计使用年限
|
|
55
|
+ </template>
|
|
56
|
+ {{ carInfo.expectLife }}
|
|
57
|
+ </el-descriptions-item>
|
|
58
|
+ <el-descriptions-item>
|
|
59
|
+ <template slot="label">
|
|
60
|
+ <svg-icon slot="prefix" icon-class="car" class="el-input__icon input-icon" />
|
|
61
|
+ 预计行驶里程(万千米)
|
|
62
|
+ </template>
|
|
63
|
+ {{ carInfo.expectKm }}
|
|
64
|
+ </el-descriptions-item>
|
|
65
|
+ <el-descriptions-item>
|
|
66
|
+ <template slot="label">
|
|
67
|
+ <svg-icon slot="prefix" icon-class="JamYelpSquare" class="el-input__icon input-icon" />
|
|
68
|
+ 是否为租车
|
|
69
|
+ </template>
|
|
70
|
+ {{ carInfo.isRent == '0' ? '否' : '是' }}
|
|
71
|
+ </el-descriptions-item>
|
|
72
|
+ <el-descriptions-item>
|
|
73
|
+ <template slot="label">
|
|
74
|
+ <svg-icon slot="prefix" icon-class="TeenyiconsYenSolid" class="el-input__icon input-icon" />
|
|
75
|
+ 单日成本
|
|
76
|
+ </template>
|
|
77
|
+ {{ carInfo.dayCost }}
|
|
78
|
+ </el-descriptions-item>
|
|
79
|
+ <el-descriptions-item>
|
|
80
|
+ <template slot="label">
|
|
81
|
+ <svg-icon slot="prefix" icon-class="remark" class="el-input__icon input-icon" />
|
|
82
|
+ 备注
|
|
83
|
+ </template>
|
|
84
|
+ {{ carInfo.remark }}
|
|
85
|
+ </el-descriptions-item>
|
|
86
|
+ </el-descriptions>
|
|
87
|
+ <!-- 费用明细 -->
|
|
88
|
+ <el-divider></el-divider>
|
|
89
|
+
|
|
90
|
+ <el-card>
|
|
91
|
+ <el-row :gutter="10" class="mb8">
|
|
92
|
+ <el-col :span="1.5">
|
|
93
|
+ <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
|
|
94
|
+ </el-col>
|
|
95
|
+ <el-col :span="1.5">
|
|
96
|
+ <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single"
|
|
97
|
+ @click="handleUpdate">修改</el-button>
|
|
98
|
+ </el-col>
|
|
99
|
+ <el-col :span="1.5">
|
|
100
|
+ <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
|
|
101
|
+ @click="handleDelete">删除</el-button>
|
|
102
|
+ </el-col>
|
|
103
|
+ <el-col :span="1.5">
|
|
104
|
+ <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
|
|
105
|
+ </el-col>
|
|
106
|
+ </el-row>
|
|
107
|
+ <el-table v-loading="loading" :data="expenseList" @selection-change="handleSelectionChange">
|
|
108
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
109
|
+ <el-table-column type="index" width="55" align="center" label="序号" />
|
|
110
|
+ <el-table-column label="费用类型" align="center" prop="expenseType">
|
|
111
|
+ <template slot-scope="scope">
|
|
112
|
+ <el-tag :type="typeStyle(scope.row.expenseType)">{{ expenseTypeText(scope.row.expenseType) }}</el-tag>
|
|
113
|
+ </template>
|
|
114
|
+ </el-table-column>
|
|
115
|
+ <el-table-column label="费用金额" align="center" prop="expense">
|
|
116
|
+ <template slot-scope="scope">
|
|
117
|
+ {{ scope.row.expense + '元' }}
|
|
118
|
+ </template>
|
|
119
|
+ </el-table-column>
|
|
120
|
+ <el-table-column label="发生日期" align="center" prop="occurDate" width="180">
|
|
121
|
+ <template slot-scope="scope">
|
|
122
|
+ {{ scope.row.occurDate }}
|
|
123
|
+ </template>
|
|
124
|
+ </el-table-column>
|
|
125
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
126
|
+ <template slot-scope="scope">
|
|
127
|
+ <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
|
128
|
+ v-hasPermi="['oa:carExpense:edit']">修改</el-button>
|
|
129
|
+ <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
|
130
|
+ v-hasPermi="['oa:carExpense:remove']">删除</el-button>
|
|
131
|
+ </template>
|
|
132
|
+ </el-table-column>
|
|
133
|
+ </el-table>
|
|
134
|
+ <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
|
135
|
+ @pagination="getList" />
|
|
136
|
+ </el-card>
|
|
137
|
+ <!-- 添加明细 -->
|
|
138
|
+ <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
|
139
|
+ <el-form ref="expenseForm" :model="form" :rules="rules" label-width="100px">
|
|
140
|
+ <el-form-item label="费用类型" prop="expenseType">
|
|
141
|
+ <el-select v-model="form.expenseType" placeholder="请选择" clearable>
|
|
142
|
+ <el-option label="保险费" value="0"></el-option>
|
|
143
|
+ <el-option label="维修/保养费" value="1"></el-option>
|
|
144
|
+ <el-option label="轮胎费" value="2"></el-option>
|
|
145
|
+ </el-select>
|
|
146
|
+ </el-form-item>
|
|
147
|
+ <el-form-item label="费用金额" prop="expense">
|
|
148
|
+ <el-input v-model="form.expense" placeholder="请输入费用金额" />
|
|
149
|
+ </el-form-item>
|
|
150
|
+ <el-form-item label="发生日期" prop="occurDate">
|
|
151
|
+ <el-date-picker clearable v-model="form.occurDate" type="date" value-format="yyyy-MM-dd"
|
|
152
|
+ placeholder="请选择发生日期">
|
|
153
|
+ </el-date-picker>
|
|
154
|
+ </el-form-item>
|
|
155
|
+ </el-form>
|
|
156
|
+ <div slot="footer" class="dialog-footer">
|
|
157
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
158
|
+ <el-button @click="cancel">取 消</el-button>
|
|
159
|
+ </div>
|
|
160
|
+ </el-dialog>
|
|
161
|
+ </div>
|
|
162
|
+</template>
|
|
163
|
+
|
|
164
|
+<script>
|
|
165
|
+import { getCar } from '@/api/oa/car/car.js'
|
|
166
|
+import { listCarExpense, getCarExpense, delCarExpense, addCarExpense, updateCarExpense } from "@/api/oa/car/carExpense";
|
|
167
|
+export default {
|
|
168
|
+ data() {
|
|
169
|
+ let validateExpense = (rule, value, callback) => {
|
|
170
|
+ setTimeout(() => {
|
|
171
|
+ if (!value) {
|
|
172
|
+ return callback(new Error('请输入金额'));
|
|
173
|
+ }
|
|
174
|
+ if (!this.isNumber(Number(value))) {
|
|
175
|
+ callback(new Error('请输入数字值'));
|
|
176
|
+ } else {
|
|
177
|
+ callback();
|
|
178
|
+ }
|
|
179
|
+ }, 100)
|
|
180
|
+ }
|
|
181
|
+ return {
|
|
182
|
+ column: 4,
|
|
183
|
+ carInfo: {},
|
|
184
|
+ expenseList: [],
|
|
185
|
+ queryParams: {
|
|
186
|
+ pageNum: 1,
|
|
187
|
+ pageSize: 10,
|
|
188
|
+ },
|
|
189
|
+ total: 0,
|
|
190
|
+ multiple: true,
|
|
191
|
+ // 选中数组
|
|
192
|
+ ids: [],
|
|
193
|
+ // 非单个禁用
|
|
194
|
+ single: true,
|
|
195
|
+ title: '',
|
|
196
|
+ open: false,
|
|
197
|
+ form: {},
|
|
198
|
+ rules: {
|
|
199
|
+ expenseType: [
|
|
200
|
+ { required: true, message: '请选择费用类型', trigger: 'change' }
|
|
201
|
+ ],
|
|
202
|
+ expense: [
|
|
203
|
+ { validator: validateExpense, required: true, trigger: 'blur' },
|
|
204
|
+ ],
|
|
205
|
+ occurDate: [
|
|
206
|
+ { required: true, message: '请选择发生日期', trigger: 'change' },
|
|
207
|
+ ],
|
|
208
|
+ },
|
|
209
|
+ loading: false
|
|
210
|
+ }
|
|
211
|
+ },
|
|
212
|
+ created() {
|
|
213
|
+ if (this.$route.query) {
|
|
214
|
+ getCar(this.$route.query.carId).then(res => {
|
|
215
|
+ console.log(res);
|
|
216
|
+ this.carInfo = res.data;
|
|
217
|
+ })
|
|
218
|
+ this.getList();
|
|
219
|
+ }
|
|
220
|
+ if (this.$store.state.app.device == 'desktop') {
|
|
221
|
+
|
|
222
|
+ } else {
|
|
223
|
+ this.column = 1
|
|
224
|
+ }
|
|
225
|
+ },
|
|
226
|
+ methods: {
|
|
227
|
+ getList() {
|
|
228
|
+ this.queryParams.carId = this.$route.query.carId
|
|
229
|
+ listCarExpense(this.queryParams).then(res => {
|
|
230
|
+ console.log(res);
|
|
231
|
+ this.expenseList = res.rows;
|
|
232
|
+ this.total = res.total;
|
|
233
|
+ })
|
|
234
|
+ },
|
|
235
|
+ goBack() {
|
|
236
|
+ this.$router.push({ path: '/car' });
|
|
237
|
+ },
|
|
238
|
+ /** 搜索按钮操作 */
|
|
239
|
+ handleQuery() {
|
|
240
|
+ this.queryParams.pageNum = 1;
|
|
241
|
+ this.getList();
|
|
242
|
+ },
|
|
243
|
+ // 多选框选中数据
|
|
244
|
+ handleSelectionChange(selection) {
|
|
245
|
+ this.ids = selection.map(item => item.carExpenseId)
|
|
246
|
+ this.single = selection.length !== 1
|
|
247
|
+ this.multiple = !selection.length
|
|
248
|
+ },
|
|
249
|
+ handleAdd() {
|
|
250
|
+ this.reset();
|
|
251
|
+ this.open = true;
|
|
252
|
+ this.title = "添加车辆明细";
|
|
253
|
+ },
|
|
254
|
+ handleUpdate(row) {
|
|
255
|
+ this.reset();
|
|
256
|
+ const carExpenseId = row.carExpenseId || this.ids
|
|
257
|
+ getCarExpense(carExpenseId).then(response => {
|
|
258
|
+ this.form = response.data;
|
|
259
|
+ this.open = true;
|
|
260
|
+ this.title = "修改车辆明细";
|
|
261
|
+ });
|
|
262
|
+ },
|
|
263
|
+ handleDelete(row) {
|
|
264
|
+ debugger
|
|
265
|
+ const carExpenseIds = row.carExpenseId || this.ids;
|
|
266
|
+ this.$modal.confirm('是否确认删除车辆费用编号为"' + carExpenseIds + '"的数据项?').then(function () {
|
|
267
|
+ return delCarExpense(carExpenseIds);
|
|
268
|
+ }).then(() => {
|
|
269
|
+ this.getList();
|
|
270
|
+ this.$modal.msgSuccess("删除成功");
|
|
271
|
+ }).catch(() => { });
|
|
272
|
+ },
|
|
273
|
+ handleExport() {
|
|
274
|
+ this.download('oa/carExpense/export', {
|
|
275
|
+ ...this.queryParams
|
|
276
|
+ }, `carExpense_${new Date().getTime()}.xlsx`)
|
|
277
|
+ },
|
|
278
|
+ // 表单重置
|
|
279
|
+ reset() {
|
|
280
|
+ this.form = {
|
|
281
|
+ carExpenseId: null,
|
|
282
|
+ carId: null,
|
|
283
|
+ expenseType: null,
|
|
284
|
+ expense: null,
|
|
285
|
+ occurDate: null
|
|
286
|
+ };
|
|
287
|
+ this.resetForm("expenseForm");
|
|
288
|
+ },
|
|
289
|
+ submitForm() {
|
|
290
|
+ this.$refs["expenseForm"].validate(valid => {
|
|
291
|
+ if (valid) {
|
|
292
|
+ this.form.carId = this.$route.query.carId
|
|
293
|
+ if (this.form.carExpenseId != null) {
|
|
294
|
+ updateCarExpense(this.form).then(response => {
|
|
295
|
+ this.$modal.msgSuccess("修改成功");
|
|
296
|
+ this.open = false;
|
|
297
|
+ this.getList();
|
|
298
|
+ });
|
|
299
|
+ } else {
|
|
300
|
+ addCarExpense(this.form).then(response => {
|
|
301
|
+ this.$modal.msgSuccess("新增成功");
|
|
302
|
+ this.open = false;
|
|
303
|
+ this.getList();
|
|
304
|
+ });
|
|
305
|
+ }
|
|
306
|
+ }
|
|
307
|
+ });
|
|
308
|
+ },
|
|
309
|
+ cancel() {
|
|
310
|
+ this.open = false;
|
|
311
|
+ this.reset();
|
|
312
|
+ },
|
|
313
|
+ isNumber(value) {
|
|
314
|
+ return typeof value === 'number' && /^\d+(\.\d+)?$/.test(value);
|
|
315
|
+ },
|
|
316
|
+ expenseTypeText(row) {
|
|
317
|
+ if (row == '0') {
|
|
318
|
+ return '保险费'
|
|
319
|
+ }
|
|
320
|
+ if (row == '1') {
|
|
321
|
+ return '维修/保养费'
|
|
322
|
+ }
|
|
323
|
+ if (row == '2') {
|
|
324
|
+ return '轮胎费'
|
|
325
|
+ }
|
|
326
|
+ },
|
|
327
|
+ typeStyle(row) {
|
|
328
|
+ if (row == '0') {
|
|
329
|
+ return 'primary'
|
|
330
|
+ }
|
|
331
|
+ if (row == '1') {
|
|
332
|
+ return 'warning'
|
|
333
|
+ }
|
|
334
|
+ if (row == '2') {
|
|
335
|
+ return 'success'
|
|
336
|
+ }
|
|
337
|
+ }
|
|
338
|
+ },
|
|
339
|
+}
|
|
340
|
+</script>
|
|
341
|
+
|
|
342
|
+<style lang="scss" scoped>
|
|
343
|
+.header {
|
|
344
|
+ position: relative;
|
|
345
|
+ text-align: center;
|
|
346
|
+
|
|
347
|
+ .back {
|
|
348
|
+ position: absolute;
|
|
349
|
+ left: 12px;
|
|
350
|
+ top: -10px;
|
|
351
|
+ }
|
|
352
|
+}
|
|
353
|
+
|
|
354
|
+.descriptions {
|
|
355
|
+ padding: 20px 50px;
|
|
356
|
+}
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+::v-deep .el-descriptions-item__label.is-bordered-label {
|
|
360
|
+ color: #121212;
|
|
361
|
+ background: rgba($color: #46a6ff, $alpha: 0.1);
|
|
362
|
+ width: 200px;
|
|
363
|
+}
|
|
364
|
+
|
|
365
|
+::v-deep .el-descriptions .is-bordered .el-descriptions-item__cell {
|
|
366
|
+ border: 1px solid #2d3f62;
|
|
367
|
+}
|
|
368
|
+</style>
|