forked from huangdaju/cloud-ui
Merge remote-tracking branch 'origin/xiaofan' into yinyuyang
# Conflicts: # src/router/index.jsyinyuyang
commit
c261ea7fa3
|
@ -52,7 +52,9 @@
|
|||
"nprogress": "0.2.0",
|
||||
"quill": "1.3.7",
|
||||
"screenfull": "5.0.2",
|
||||
"sockjs-client": "^1.6.1",
|
||||
"sortablejs": "1.10.2",
|
||||
"stompjs": "^2.3.3",
|
||||
"vue": "2.6.12",
|
||||
"vue-count-to": "1.0.13",
|
||||
"vue-cropper": "0.5.5",
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 查询菜单列表
|
||||
export function list(data) {
|
||||
export function list(params) {
|
||||
return request({
|
||||
url: '/system/car/list',
|
||||
method: 'get',
|
||||
data
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,18 @@ export function del(carIds) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
export function close(carVin) {
|
||||
return request({
|
||||
url: '/system/car/close/'+carVin,
|
||||
method: 'post'
|
||||
});
|
||||
}
|
||||
export function open(carVin) {
|
||||
return request({
|
||||
url: '/system/car/open/'+carVin,
|
||||
method: 'post'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -62,3 +73,16 @@ export function findById(carId) {
|
|||
}
|
||||
|
||||
|
||||
export function getRealTimeData() {
|
||||
return request({
|
||||
url: '/analyze/realTimeData',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getRealTimeDataTwo(vin) {
|
||||
return request({
|
||||
url: '/analyze/realTimeDataTwo/' +vin,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ service.interceptors.request.use(config => {
|
|||
const s_url = sessionObj.url; // 请求地址
|
||||
const s_data = sessionObj.data; // 请求数据
|
||||
const s_time = sessionObj.time; // 请求时间
|
||||
const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交
|
||||
const interval = 500; // 间隔时间(ms),小于此时间视为重复提交
|
||||
if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) {
|
||||
const message = '数据正在处理,请勿重复提交';
|
||||
console.warn(`[${s_url}]: ` + message)
|
||||
|
|
|
@ -115,9 +115,9 @@
|
|||
<el-table v-loading="loading" :data="carList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="id" align="center" prop="carId" />
|
||||
<el-table-column label="车辆vin码" align="center" prop="carVin" />
|
||||
<el-table-column label="车辆vin" align="center" prop="carVin" />
|
||||
<el-table-column label="车辆类型" align="center" prop="carType" />
|
||||
<el-table-column label="电子围栏id" align="center" prop="carFenceId" />
|
||||
<el-table-column label="电子围栏" align="center" prop="carFenceId" />
|
||||
<el-table-column label="车辆状态" align="center" prop="state">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.car_state" :value="scope.row.state"/>
|
||||
|
@ -130,6 +130,22 @@
|
|||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-success"
|
||||
v-if="scope.row.state === 1"
|
||||
@click="handleUpdateOpen(scope.row.carVin)"
|
||||
v-hasPermi="['system:car:edit']"
|
||||
>上线</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-error"
|
||||
v-if="scope.row.state === 0"
|
||||
@click="handleUpdateClose(scope.row.carVin)"
|
||||
v-hasPermi="['system:car:edit']"
|
||||
>下线</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
|
@ -144,6 +160,15 @@
|
|||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['system:car:remove']"
|
||||
>删除</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-eleme"
|
||||
@click="$router.push({
|
||||
path:'track',
|
||||
query:{
|
||||
carVin:scope.row.carVin}})"
|
||||
>实时轨迹查询</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
@ -176,16 +201,6 @@
|
|||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="车辆状态" prop="state">
|
||||
<el-select v-model="form.state" placeholder="请选择车辆状态">
|
||||
<el-option
|
||||
v-for="dict in dict.type.car_state"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="parseInt(dict.value)"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="电机厂商" prop="carElectricalmachiney">
|
||||
<el-input v-model="form.carElectricalmachiney" placeholder="请输入电机厂商" />
|
||||
</el-form-item>
|
||||
|
@ -211,7 +226,8 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {list, add, update, findById, del, exportA, selectFence} from "@/api/system/car";
|
||||
import {list, add, update, findById, del, exportA, selectFence,open,close} from "@/api/system/car";
|
||||
import {getRealTimeDataTwo} from "@/api/system/car";
|
||||
|
||||
export default {
|
||||
name: "Car",
|
||||
|
@ -232,7 +248,7 @@ export default {
|
|||
// 总条数
|
||||
total: 0,
|
||||
//电子围栏空数组
|
||||
fenceIds:[],
|
||||
// fenceIds:[],
|
||||
//电子围栏选中的数组
|
||||
selectedFenceIds: [],
|
||||
// 车辆管理表格数据
|
||||
|
@ -245,9 +261,8 @@ export default {
|
|||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
carVin: '',
|
||||
carType: '',
|
||||
carFenceId: '',
|
||||
carVin: null,
|
||||
carType: null,
|
||||
state: null,
|
||||
carElectricalmachiney: null,
|
||||
carBattery: null,
|
||||
|
@ -256,7 +271,6 @@ export default {
|
|||
},
|
||||
// 表单参数
|
||||
form: {
|
||||
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
|
@ -265,7 +279,6 @@ export default {
|
|||
},
|
||||
created() {
|
||||
this.getList();
|
||||
|
||||
this.selectFenceList()
|
||||
},
|
||||
methods: {
|
||||
|
@ -273,10 +286,6 @@ export default {
|
|||
selectFence().then(res=>{
|
||||
this.selectFence=res.data
|
||||
console.log(this.selectFence)
|
||||
this.fenceIds = this.selectFence
|
||||
console.log(this.fenceIds)
|
||||
|
||||
|
||||
})
|
||||
},
|
||||
/** 查询车辆管理列表 */
|
||||
|
@ -298,8 +307,8 @@ export default {
|
|||
this.form = {
|
||||
carId: null,
|
||||
carVin: null,
|
||||
carType: '',
|
||||
carFenceId: '',
|
||||
carType: null,
|
||||
carFenceId: null,
|
||||
state: null,
|
||||
carElectricalmachiney: null,
|
||||
carBattery: null,
|
||||
|
@ -341,23 +350,41 @@ export default {
|
|||
this.reset();
|
||||
const carId = row.carId || this.ids
|
||||
findById(carId).then(response => {
|
||||
console.log("Response Data:",response.data);
|
||||
this.form = response.data;
|
||||
this.form.carFenceId = this.form.carFenceId.split(",");
|
||||
console.log("Car Fence IDs:",this.form.carFenceId)
|
||||
this.selectedFenceIds = this.form.carFenceId.split(",");
|
||||
console.log("selectedFenceIds:"+this.selectedFenceIds)
|
||||
this.open = true;
|
||||
this.title = "修改车辆管理";
|
||||
});
|
||||
},
|
||||
/** 启用车辆 **/
|
||||
handleUpdateOpen(carVin){
|
||||
open(carVin).then(res=>{
|
||||
this.$message.success('上线成功')
|
||||
this.getList();
|
||||
})
|
||||
},
|
||||
/** 禁用车辆 **/
|
||||
handleUpdateClose(carVin){
|
||||
close(carVin).then(res=>{
|
||||
this.$message.success('下线成功')
|
||||
this.getList();
|
||||
})
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
//判断是否为数组,如果不正确转为数组
|
||||
if (!Array.isArray(this.form.carFenceId)){
|
||||
this.form.carFenceId=[this.form.carFenceId]
|
||||
}
|
||||
this.form.carFenceId = this.form.carFenceId.map(item => String(item)); // 将每个元素转换为字符串
|
||||
|
||||
//将每个元素转换为字符串
|
||||
this.form.carFenceId = this.form.carFenceId.map(item => String(item)); //
|
||||
//拼接获取到数据的数组,切割
|
||||
this.form.carFenceId = this.selectedFenceIds.join(",");
|
||||
// this.form.carFenceId = this.form.carFenceId.join(",");
|
||||
if (this.form.carId != null) {
|
||||
update(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
|
@ -384,13 +411,6 @@ export default {
|
|||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
// handleExport() {
|
||||
// this.download('system/car/export', {
|
||||
// ...this.queryParams
|
||||
// }, `car_${new Date().getTime()}.xlsx`)
|
||||
// }
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
exportA(this.queryParams).then(response => {
|
||||
// 创建一个 Blob 对象,指定 MIME 类型为 Excel 文件类型
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
<template>
|
||||
<div>
|
||||
<div id="container" style="width: 25%; height: 250px;"></div>
|
||||
<div>
|
||||
{{carData}}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import AMapLoader from "@amap/amap-jsapi-loader";
|
||||
import {getRealTimeDataTwo} from "@/api/system/car";
|
||||
|
||||
|
||||
export default {
|
||||
name: "map-view",
|
||||
data() {
|
||||
return {
|
||||
carPosition: ["116.397428", "39.90923"], // 初始化小汽车位置
|
||||
carMarker: null, // 存储小汽车Marker
|
||||
animationInterval:null,//存储动画定时器
|
||||
lastUpdateTime:0,//上次更新时间
|
||||
animationFramId:null,//存储动画帧的ID
|
||||
carData:[],//小汽车经纬度
|
||||
};
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.initAMap()
|
||||
// this.getRealTimeDataAndUpdatePosition(this.$route.query.carVin); // 添加此行
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearInterval(this.animationInterval);//清除定时器
|
||||
this.map?.destroy();
|
||||
cancelAnimationFrame(this.animationFramId);//取消动画帧请求
|
||||
},
|
||||
methods: {
|
||||
initAMap() {
|
||||
AMapLoader.load({
|
||||
key: "e7398786b61ee782417e1749de1f2b39", // 申请好的Web端开发者Key,首次调用 load 时必填
|
||||
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
||||
plugins: ["AMap.Scale"], // 需要使用的的插件列表,如比例尺'AMap.Scale',支持添加多个如:['...','...']
|
||||
})
|
||||
.then((AMap) => {
|
||||
this.map = new AMap.Map("container", {
|
||||
// 设置地图容器id
|
||||
viewMode: "3D", // 是否为3D地图模式
|
||||
zoom: 11, // 初始化地图级别
|
||||
center: ["116.397428", "39.90923"], // 初始化地图中心点位置
|
||||
});
|
||||
|
||||
// 车辆初始化
|
||||
this.carMarker = new AMap.Marker({
|
||||
position: this.carPosition,
|
||||
icon: 'https://webapi.amap.com/images/car.png',
|
||||
map: this.map, // 将Marker添加到地图上
|
||||
});
|
||||
|
||||
// 在地图初始化完成后启动小车动画
|
||||
this.startCarAnimation();
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
startCarAnimation() {
|
||||
// this.animationInterval = setInterval(() => {
|
||||
// let vin = this.$route.query.carVin;
|
||||
// this.getRealTimeDataAndUpdatePosition(vin);
|
||||
// }, 1000);
|
||||
const animate = () => {
|
||||
const currentTime = Date.now();
|
||||
const deltaTime = currentTime - this.lastUpdateTime;
|
||||
|
||||
if (deltaTime > 1000) {
|
||||
//每秒更新一次位置
|
||||
this.lastUpdateTime = currentTime;
|
||||
let vin = this.$route.query.carVin;
|
||||
this.getRealTimeDataAndUpdatePosition(vin);
|
||||
}
|
||||
this.animationFramId = requestAnimationFrame(animate);
|
||||
};
|
||||
this.animationFramId = requestAnimationFrame(animate);
|
||||
|
||||
|
||||
},
|
||||
getRealTimeDataAndUpdatePosition(vin) {
|
||||
getRealTimeDataTwo(vin)
|
||||
.then(response => {
|
||||
console.log('Response from getRealTimeDataTwo:', response);
|
||||
// this.$message.success('Real-time data:',response);
|
||||
this.carData = response
|
||||
//更新小汽车位置
|
||||
this.carPosition = [this.carData.longitude, this.carData.latitude];
|
||||
//更新小汽车Marker的位置
|
||||
this.carMarker.setPosition(this.carPosition);
|
||||
//显示实时数据
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
</style>
|
Loading…
Reference in New Issue