carTable.vue
5.13 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
<template>
<div>
<el-table :data="tableData" style="width: 98%;margin:0 auto;" v-loading.body="loading">
<el-table-column label="序号" type="index" width="120" align="center"></el-table-column>
<el-table-column label="车牌号码" property="vehicle.plate_text" type="name" width="180" align="center"></el-table-column>
<el-table-column label="车库类型" property="lib_code" type="name" width="180" align="center" :formatter="setLib"></el-table-column>
<el-table-column label="车牌类型" property="vehicle.plate_type" :formatter="setPlateType" width="180" align="center"></el-table-column>
<el-table-column label="车辆类型" property="vehicle.vehicle_type" :formatter="setCarType" align="center"> </el-table-column>
<el-table-column label="车身颜色" property="vehicle.body_color" :formatter="setCarColor" align="center"> </el-table-column>
<el-table-column label="车主姓名" property="owner.name" align="center"> </el-table-column>
<el-table-column label="身份证号" property="owner.cnsf_id" align="center"></el-table-column>
<el-table-column label="操作" width="300px" align="center">
<template slot-scope="scope">
<div class="tab-btn-box">
<span class="table-btn" size="" @click="handleSee(scope.$index, scope.row)">查看详情</span>
<span class="table-btn" size="" @click="handleEdit(scope.$index, scope.row)">编辑车辆</span>
<span class="table-btn dengers" size="" @click="handleDelete(scope.$index, scope.row)">删除</span>
</div>
</template>
</el-table-column>
</el-table>
<div class="block">
<el-pagination class="pages" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="currentPage"
:page-size="limit" layout="total,prev, pager, next, jumper" :total="total">
</el-pagination>
</div>
<div>
<carDetail ref='detail'></carDetail>
</div>
</div>
</template>
<script>
import carDetail from './carDetail'
export default {
data() {
return {
tableData: [],
currentPage: 1,
limit: 20,
total: 0,
offset: 0,
loading: true,
provenceName: "",
cityName: "",
cData: '',
carLibs:[]
};
},
props: {
lib_code: {
//库名称
// type: String
},
plateType: {
//车牌类型
// type: String
},
plateText: {
//车牌号码
// type: String
},
carOwner: {
//车主姓名
}
},
methods: {
handleSee(index, row) {
this.$refs.detail.dataInit(row)
},
handleEdit(index, row) {
this.$emit("edit", index, row);
},
handleDelete(index, row) {
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
console.log(this.axios)
this.axios
.delete(this.IP + "/api/v1/alarm/traffic/lib_vehicles/" + row.unid)
.then((response)=> {
this.initTable();
this.$message({
type: "success",
message: "删除成功!"
});
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除"
});
});
},
setLib(row, column, cellValue){
let str;
this.carLibs.forEach(ele => {
if (ele.lib==cellValue) {
str = ele.name
}
});
return str
},
setPlateType(row, column, cellValue) {
return this.getCode('号牌类型', cellValue)
},
setCarType(row, column, cellValue) {
return this.getCode('车辆类型', cellValue)
},
setCarColor(row, column, cellValue) {
return this.getCode('车身颜色', cellValue)
},
handleSizeChange(val) {
alert(val);
},
handleCurrentChange(val) {
this.offset = (val - 1) * this.limit;
this.initTable();
},
initTable() {
this.axios
.get(this.IP + "/api/v1/alarm/traffic/lib_vehicles", {
params: {
offset: this.offset,
limit: this.limit,
plate_text__like: this.plateText,
plate_type: this.plateType,
owner_name__like: this.carOwner,
lib_code: this.lib_code,
}
}).then((response)=> {
this.tableData = response.data.list_data;
this.total = response.data.total_num;
this.loading = false;
});
}
},
components: {
carDetail
},
computed: {},
created() {
this.faceapi.getCarDbData().then(res=>{
this.carLibs = res.list_data
this.initTable();
})
}
};
</script>
<style lang="stylus" scoped>
.mb20 {
margin-bottom: 50px;
}
.pages {
float: right;
margin: 20px 15px 30px 0;
}
</style>