车辆管理

master
tangwenkang 2023-11-25 11:16:44 +08:00
parent 30ddc5764e
commit e0cd26ccbc
5 changed files with 944 additions and 2 deletions

45
src/api/table.js 100644
View File

@ -0,0 +1,45 @@
import request from '@/utils/request'
export function listCarType() {
return request({
url: '/history/car/listCarType',
method: 'get'
})
}
export function getCarList(form) {
return request({
url: '/history/car/listCar',
method: 'post',
data:form
})
}
export function delCar(carVin) {
return request({
url: '/history/car/deleteCar?carVin='+carVin,
method: 'post'
})
}
export function updateCar(carForm) {
return request({
url: '/history/car/updateCar',
method: 'post',
data:carForm
})
}
export function listFence() {
return request({
url: '/history/car/listFence',
method: 'get'
})
}
export function insertCar(carInsert) {
return request({
url: '/history/car/insertCar',
method: 'post',
data:carInsert
})
}

View File

@ -17,7 +17,7 @@ const service = axios.create({
// axios中请求配置有baseURL选项表示请求URL公共部分
baseURL: process.env.VUE_APP_BASE_API,
// 超时
timeout: 10000
timeout: 50000
})
// request拦截器

View File

@ -31,7 +31,7 @@ import AMapLoader from '@amap/amap-jsapi-loader';
methods: {
initAMap() {
AMapLoader.load({
key: "164dc573bc4daf5bf1f1ebcebdae0717", // WebKey load
key: "0b5f26b194361cbc9571101bc2856962", // WebKey load
version: "2.0", // JSAPI 1.4.15
plugins: ['AMap.MouseTool'], // 使'AMap.Scale'
})

View File

@ -0,0 +1,886 @@
<template>
<div>
<div v-show="!isShow">
<div id="container" ></div>
<el-button type="primary" @click="isShowAll"></el-button>
</div>
<div v-show="!isList">
<el-form :model="form" ref="myForm">
<table style="width: 100%">
<tr>
<td>车辆VIN:</td>
<td>
<el-input v-model="form.carVin" size="medium" style="width: 100%;"></el-input>
</td>
<td>车辆名称:</td>
<td>
<el-input v-model="form.carName" size="medium" style="width: 100%;"></el-input>
</td>
<td>车辆类型:</td>
<td>
<el-select v-model="form.carTypeId" placeholder="请选择车辆类型" style="width: 100%">
<el-option v-for="carType in carTypes" :label="carType.carTypeName" :value="carType.carTypeId" :key="carType.carTypeId"></el-option>
</el-select>
</td>
<td>电子围栏:</td>
<td>
<el-input v-model="form.fenceName" size="medium" style="width: 100%;"></el-input>
</td>
<td>车辆状态:</td>
<td>
<el-select v-model="form.carStatus" placeholder="请选择车辆状态" style="width: 100%">
<el-option value="1">在线</el-option>
<el-option value="0">离线</el-option>
</el-select>
</td>
</tr>
<tr>
<td>车辆品牌:</td>
<td><el-input v-model="form.carBrand" size="medium" style="width: 100%;"></el-input></td>
<td>
<el-button type="primary" @click="findForm" size="mini">搜索</el-button>
</td>
<td>
<el-button @click="resetForm" size="mini">重置</el-button>
</td>
</tr>
</table>
</el-form>
<br><br>
<div style="text-align: right;">
<button type="submit" @click="refreshTable"></button>
</div>
<el-table :data="carList"
element-loading-text="Loading"
border
fit
highlight-current-row>
<el-table-column label="车辆编号">
<template slot-scope="scope">
{{scope.row.carId}}
</template>
</el-table-column>
<el-table-column label="车辆VIN">
<template slot-scope="scope">
{{scope.row.carVin}}
</template>
</el-table-column>
<el-table-column label="车辆名称">
<template slot-scope="scope">
{{scope.row.carName}}
</template>
</el-table-column>
<el-table-column label="车辆品牌">
<template slot-scope="scope">
{{scope.row.carBrand}}
</template>
</el-table-column>
<el-table-column label="车辆类型">
<template slot-scope="scope">
{{scope.row.carTypeName}}
</template>
</el-table-column>
<el-table-column label="电子围栏">
<template slot-scope="scope">
{{scope.row.fenceName}}
</template>
</el-table-column>
<el-table-column label="车辆状态">
<template slot-scope="scope">
<div v-if="scope.row.carStatus===0">线</div>
<div v-if="scope.row.carStatus===1">线</div>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button type="primary" @click="updateCarList(scope.row)"></el-button>
<el-button type="primary" @click="delCar(scope.row.carVin)"></el-button>
<el-button type="primary" @click="realTimeTrajectory"></el-button>
</template>
</el-table-column>
</el-table>
<div style="text-align: right;">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="this.form.pageNum"
:page-sizes="[3, 5, 7, 10]"
:page-size="this.form.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
<el-dialog :visible.sync="dialogVisible" width="30%">
<el-form :model="carForm">
<el-form-item label="车辆编号">
<el-input v-model="carForm.carId" readonly></el-input>
</el-form-item>
<el-form-item label="车辆VIN">
<el-input v-model="carForm.carVin" readonly></el-input>
</el-form-item>
<el-form-item label="车辆名称">
<el-input v-model="carForm.carName" readonly placeholder="请输入车辆名称"></el-input>
</el-form-item>
<el-form-item label="车辆品牌">
<el-input v-model="carForm.carBrand" readonly placeholder="请输入车辆品牌"></el-input>
</el-form-item>
<el-form-item label="车辆类型">
<el-select v-model="carForm.carTypeId" placeholder="请选择车辆类型">
<el-option v-for="carType in carTypes" :label="carType.carTypeName" :value="carType.carTypeId" :key="carType.carTypeId"></el-option>
</el-select>
</el-form-item>
<el-form-item label="电子围栏">
<el-select v-model="carForm.fenceId" placeholder="请选择围栏">
<el-option v-for="fence in fences" :label="fence.fenceName" :value="fence.fenceId" :key="fence.fenceId"></el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="updateCar"></el-button>
</span>
</el-dialog>
<el-button type="primary" @click="tapInsert"></el-button>
<el-dialog :visible.sync="dialogVisibleTwo" width="30%">
<el-form :model="carInsert">
<el-form-item label="车辆VIN">
<el-input v-model="carInsert.carVin" placeholder="请输入车辆VIN"></el-input>
</el-form-item>
<el-form-item label="车辆名称">
<el-input v-model="carInsert.carName" placeholder="请输入车辆名称"></el-input>
</el-form-item>
<el-form-item label="车辆品牌">
<el-input v-model="carInsert.carBrand" placeholder="请输入车辆品牌"></el-input>
</el-form-item>
<el-form-item label="车辆类型">
<el-select v-model="carInsert.carTypeId" placeholder="请选择车辆类型">
<el-option v-for="carType in carTypes" :label="carType.carTypeName" :value="carType.carTypeId" :key="carType.carTypeId"></el-option>
</el-select>
</el-form-item>
<el-form-item label="电子围栏">
<el-select v-model="carInsert.fenceId" placeholder="请选择围栏">
<el-option v-for="fence in fences" :label="fence.fenceName" :value="fence.fenceId" :key="fence.fenceId"></el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisibleTwo = false"> </el-button>
<el-button type="primary" @click="insertCar"></el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import AMapLoader from '@amap/amap-jsapi-loader';
import {delCar, getCarList, insertCar, listCarType, listFence, updateCar} from "@/api/table";
export default {
name: 'AMapAnimation',
props: {
equipmentId: String,
},
beforeDestroy() {
this.map && this.map.destroy();//
},
data() {
return {
carList:[],
total:0,
form:{
pageNum:1,
pageSize:10,
carVin:null,
carName:null,
carBrand:null,
carTypeId:null,
fenceName:null,
carStatus:null,
},
carForm:{
carId:null,
carVin:null,
carName:null,
carBrand:null,
carTypeId:null,
fenceId:null,
},
carInsert:{
carVin:null,
carName:null,
carBrand:null,
carTypeId:null,
fenceId:null,
},
carTypes:[],
carVin:null,
car:null,
isShow:true,
isList:false,
dialogVisible:false,
dialogVisibleTwo:false,
fences:[],
duration:2000,
AMap: null,
map: null,
marker: null,
lineArr: [
[116.478935,39.997761],
[116.478939,39.997825],
[116.478912,39.998549],
[116.478912,39.998549],
[116.478998,39.998555],
[116.478998,39.998555],
[116.479282,39.99856],
[116.479658,39.998528],
[116.480151,39.998453],
[116.480784,39.998302],
[116.480784,39.998302],
[116.481149,39.998184],
[116.481573,39.997997],
[116.481863,39.997846],
[116.482072,39.997718],
[116.482362,39.997718],
[116.483633,39.998935],
[116.48367,39.998968],
[116.484648,39.999861]],
};
},
mounted() {
this.initMap()
this.startAnimation()
},
created() {
this.getList()
this.listCarType()
this.listFence()
},
methods: {
/*重置表单*/
resetForm() {
this.form = { // form
carVin: '', // VIN
carName: '', //
carTypeId: null, // null
fenceName: '', //
carStatus: '', //
carBrand: '', //
};
this.$refs.myForm.resetFields(); //
},
isShowAll(){
this.isShow = true
this.isList = false
},
insertCar(){
insertCar(this.carInsert).then(res=>{
if(res.code === 200){
this.$message.success("添加成功!")
location.reload()
}
})
},
tapInsert(){
this.dialogVisibleTwo = true
},
updateCarList(car){
this.dialogVisible = true
this.carForm = car
console.log(this.carForm)
},
/*电子围栏列表*/
listFence(){
listFence().then(res=>{
this.fences = res.data
})
},
/*地图展示*/
realTimeTrajectory(){
this.isShow = false
this.isList = true
},
/*刷新*/
refreshTable(){
this.getList()
},
handleSizeChange(val) {
this.form.pageSize=val
this.getList()
},
handleCurrentChange(val) {
this.form.pageNum=val
this.getList()
},
/*车辆列表*/
getList(){
getCarList(this.form).then(response => {
this.carList = response.data
this.total = response.data.total
})
},
delCar(carVin){
this.carVin = carVin
delCar(this.carVin).then(res=>{
if(res.code === 200){
this.$message.success("删除成功!")
location.reload()
}
})
},
updateCar(){
updateCar(this.carForm).then(res=>{
if(res.code === 200){
this.$message.success("修改成功!")
location.reload()
}
})
},
/*表单查询*/
findForm(){
this.getList()
},
/*查询车辆类型表*/
listCarType(){
listCarType().then(res=>{
this.carTypes = res.data
})
},
initMap() {
AMapLoader.load({
key: "0b5f26b194361cbc9571101bc2856962", // WebKey load
version: "2.0", // JSAPI 1.4.15
plugins: [
"AMap.Scale",
"AMap.HawkEye",
"AMap.ToolBar",
"AMap.AutoComplete",
"AMap.PlaceSearch",
"AMap.ControlBar",
"AMap.MouseTool",
"AMap.DragRoute",
"AMap.MoveAnimation"], // 使'AMap.Scale'
}).then((AMap) => {
// DOM
this.map = new AMap.Map("container", { //id
resizeEnable: true,
viewMode: "3D", // 使3D
zoomEnable: true, // true
dragEnable: true, // true
doubleClickZoom: true, // true
zoom: 13, //
center: this.lineArr[0], //
// mapStyle: "amap://styles/darkblue", //
})
this.marker = new AMap.Marker({
position: this.lineArr[0],
icon: "https://a.amap.com/jsapi_demos/static/demo-center-v2/car.png",
offset: new AMap.Pixel(-13, -26),
});
this.map.add(this.marker)
//
this.polyline = new AMap.Polyline({
path: this.lineArr,
showDir: true,
strokeColor: "#28F", //线
// strokeOpacity: 1, //线
strokeWeight: 6, //线
// strokeStyle: "solid" //线
});
this.map.add(this.polyline)
//
this.passedPolyline = new AMap.Polyline({
strokeColor: "#AF5", //线
strokeWeight: 6, //线
});
this.map.add(this.passedPolyline)
// marker
this.marker.on('moving', (e) => {
console.log('marker动了', e)
this.passedPolyline.setPath(e.passedPath); //
this.map.setCenter(e.target.getPosition(), true) //
});
this.map.setFitView(); //
})
},
startAnimation () {
setTimeout(()=>{
AMap.plugin('AMap.MoveAnimation', () => {
console.log('开始回放')
this.marker.moveAlong(this.lineArr, {
//
duration: this.duration,//
// JSAPI2.0 moveAlong
autoRotation: true,
});
})
},2000)
},
}
}
</script>
<style scoped lang="scss">
#container{
padding:0px;
margin: 0px;
width: 100%;
height: 800px;
}
html {
font-size: 12px;
}
.amap-copyright{
box-sizing: content-box
}
* {
box-sizing: border-box
}
.input-textarea{
color:grey;
height:8em;
overflow:auto;
border-radius:0.4rem;
border:1px solid #ced4da;
margin-bottom:1rem;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
line-height: 1.5;
font-weight: 300;
color: #111213;
}
hr {
margin: 0.5rem 0;
box-sizing: content-box;
height: 0;
overflow: visible;
border: 0;
border-top: 1px solid rgba(0, 0, 0, .1)
}
p {
margin-top: 0;
margin-bottom: 0;
}
label {
display: inline-block;
margin-bottom: 0.4rem;
}
label, .btn {
margin-left: 0;
font-size: 1rem;
}
button, input, select {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
overflow: visible;
text-transform: none
}
[type=button]::-moz-focus-inner, [type=reset]::-moz-focus-inner, [type=submit]::-moz-focus-inner, button::-moz-focus-inner {
padding: 0;
border-style: none;
}
input[type=checkbox], input[type=radio] {
box-sizing: border-box;
padding: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
padding: 0;
margin: 0 0.5rem 0 0;
}
h4 {
font-family: inherit;
line-height: 1.8;
font-weight: 300;
color: inherit;
font-size: 1.1rem;
margin-top: 0;
margin-bottom: .5rem
}
.btn {
display: inline-block;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 1px solid transparent;
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
background-color: transparent;
background-image: none;
color: #25A5F7;
border-color: #25A5F7;
padding: .25rem .5rem;
line-height: 1.5;
border-radius: 1rem;
-webkit-appearance: button;
cursor:pointer;
}
.btn:hover {
color: #fff;
background-color: #25A5F7;
border-color: #25A5F7
}
.btn:hover {
text-decoration: none
}
.input-item {
position: relative;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-ms-flex-align: center;
align-items: center;
width: 100%;
height: 3rem;
}
.input-item:last-child {
margin-bottom: 0;
}
.input-item>select, .input-item>input[type=text], .input-item>input[type=date] {
position: relative;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
width: 1%;
margin-bottom: 0;
}
.input-item>select:not(:last-child), .input-item>input[type=text]:not(:last-child), .input-item>input[type=date]:not(:last-child) {
border-top-right-radius: 0;
border-bottom-right-radius: 0
}
.input-item>select:not(:first-child), .input-item>input[type=text]:not(:first-child), .input-item>input[type=date]:not(:first-child) {
border-top-left-radius: 0;
border-bottom-left-radius: 0
}
.input-item-prepend {
margin-right: -1px;
}
.input-item-text, input[type=text],input[type=date], select {
height: calc(2.2rem + 2px);
}
.input-item-text {
width: 6rem;
text-align: justify;
padding: 0.4rem 0.7rem;
display: inline-block;
text-justify: distribute-all-lines;
/*ie6-8*/
text-align-last: justify;
/* ie9*/
-moz-text-align-last: justify;
/*ff*/
-webkit-text-align-last: justify;
/*chrome 20+*/
-ms-flex-align: center;
align-items: center;
margin-bottom: 0;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
text-align: center;
white-space: nowrap;
background-color: #e9ecef;
border: 1px solid #ced4da;
border-radius: .25rem;
border-bottom-right-radius: 0;
border-top-right-radius: 0;
}
.input-item-text input[type=checkbox], .input-item-text input[type=radio] {
margin-top: 0
}
.input-card {
display: flex;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: border-box;
border-radius: .25rem;
width: 22rem;
border-width: 0;
border-radius: 0.4rem;
box-shadow: 0 2px 6px 0 rgba(114, 124, 245, .5);
position: fixed;
bottom: 1rem;
right: 1rem;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
padding: 0.75rem 1.25rem;
}
.input-text {
line-height: 2rem;
margin-right: 2rem;
}
.info hr {
margin-right: 0;
margin-left: 0;
border-top-color: grey;
}
.info {
padding: .75rem 1.25rem;
margin-bottom: 1rem;
border-radius: .25rem;
position: fixed;
top: 1rem;
background-color: white;
width: auto;
min-width: 22rem;
border-width: 0;
right: 1rem;
box-shadow: 0 2px 6px 0 rgba(114, 124, 245, .5);
}
.code {
left: 1.5rem;
right: 1.5rem;
top: 1.5rem;
bottom: 1.5rem;
overflow: auto;
margin-bottom: 0rem;
}
.code .btn {
top: 1rem;
position: absolute;
right: 1rem;
}
.code .result {
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 0.5rem;
padding: 1rem;
bottom: 1rem;
position: absolute;
top: 5.5rem;
right: 1rem;
left: 1rem;
overflow: auto;
}
.code .status {
color: #80adff;
display: inline-block;
font-size: 14px;
}
.code h4 {
display: inline-block;
max-width: 20rem;
margin-right: 1rem;
margin-bottom: 1rem;
}
select, input[type=text], input[type=date] {
display: inline-block;
width: 100%;
padding: .375rem 1.75rem .375rem .75rem;
line-height: 1.5;
color: #495057;
vertical-align: middle;
background: #fff url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E") no-repeat right .75rem center;
background-size: 8px 10px;
border: 1px solid #ced4da;
border-radius: .25rem;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none
}
input[type=text],input[type=date] {
background: #fff;
padding: .375rem .75rem;
}
select:focus, input[type=text]:focus, input[type=date]:focus {
border-color: #80bdff;
outline: 0;
box-shadow: 0 0 0 .1rem rgba(128, 189, 255, .1)
}
.btn:focus {
outline: 0;
box-shadow: none;
}
select:focus::-ms-value, input[type=text]:focus::-ms-value,input[type=date]:focus::-ms-value {
color: #495057;
background-color: #fff
}
/* native toastr */
.native-toast {
position: fixed;
background-color: rgba(50, 50, 50, .8);
border-radius: 33px;
color: white;
left: 50%;
text-align: center;
padding: 6px 12px;
opacity: 0;
z-index: 99999;
transition: transform .25s, opacity .25s, top .25s;
box-sizing: border-box;
}
.native-toast-bottom {
bottom: 50px;
-ms-transform: translateX(-50%) translateY(50px);
transform: translateX(-50%) translateY(50px)
}
.native-toast-bottom.native-toast-shown {
opacity: 1;
-ms-transform: translateX(-50%) translateY(0);
transform: translateX(-50%) translateY(0);
}
.native-toast-bottom.native-toast-edge {
bottom: 0;
}
.native-toast-top {
top: 50px;
-ms-transform: translateX(-50%) translateY(-50px);
transform: translateX(-50%) translateY(-50px)
}
.native-toast-top.native-toast-shown {
opacity: 1;
-ms-transform: translateX(-50%) translateY(0);
transform: translateX(-50%) translateY(0);
}
.native-toast-top.native-toast-edge {
top: 0;
}
.native-toast-center {
top: 0;
-ms-transform: translateX(-50%) translateY(-50px);
transform: translateX(-50%) translateY(-50px)
}
.native-toast-center.native-toast-shown {
opacity: 1;
top: 50%;
-ms-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
.native-toast-edge {
border-radius: 0;
width: 100%;
text-align: left;
}
@media screen and (min-width: 40rem) {
.native-toast:not(.native-toast-edge) {
max-width: 18rem;
}
}
/*
max-width does not seem to work in small screen?
*/
/*@media screen and (max-width: 768px) {
.native-toast:not(.native-toast-edge) {
max-width: 400px;
}
}
@media screen and (max-width: 468px) {
.native-toast:not(.native-toast-edge) {
max-width: 300px;
}
}*/
/* types */
.native-toast-error {
background-color: #d92727;
color: white;
}
.native-toast-success {
background-color: #62a465;
color: white;
}
.native-toast-warning {
background-color: #fdaf17;
color: white;
}
.native-toast-info {
background-color: #5060ba;
color: white;
}
[class^="native-toast-icon-"] {
vertical-align: middle;
margin-right: 8px
}
[class^="native-toast-icon-"] svg {
width: 16px;
height: 16px;
}
</style>

View File

@ -0,0 +1,11 @@
<script setup>
</script>
<template>
</template>
<style scoped lang="scss">
</style>