2.10
This commit is contained in:
parent
b1e9b058f0
commit
3eac2eed00
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<div class="button-group">
|
<div class="button-group">
|
||||||
<el-button type="primary" @click="handleChangePassword">确认修改</el-button>
|
<el-button type="primary" @click="handleChangePassword">确认修改</el-button>
|
||||||
<el-button @click="$router.push('/login')">返回登录</el-button>
|
<el-button @click="$router.push('/')">返回登录</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
@ -129,32 +129,72 @@
|
|||||||
|
|
||||||
<el-tabs v-if="activeMenu === '2-2'">
|
<el-tabs v-if="activeMenu === '2-2'">
|
||||||
<!-- 新增方案 -->
|
<!-- 新增方案 -->
|
||||||
<el-tab-pane label="新增方案">
|
<el-tab-pane label="方案列表">
|
||||||
|
<div class="plan-list-header">
|
||||||
|
<div style="display: flex; justify-content: flex-end;">
|
||||||
|
<el-button type="primary" @click="showAddPlanDialog">新增方案</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-table :data="plans" empty-text="暂无数据" border style="width: 100%; margin-bottom: 20px;">
|
||||||
|
<el-table-column type="index" label="序号" width="60" align="center"></el-table-column>
|
||||||
|
<el-table-column prop="name" label="方案名称" min-width="15%" align="center"></el-table-column>
|
||||||
|
<el-table-column prop="timeRange" label="时间段" min-width="15%" align="center"></el-table-column>
|
||||||
|
<el-table-column prop="selectedMode" label="车道模式" min-width="15%" align="center"></el-table-column>
|
||||||
|
<el-table-column prop="lanes" label="开放车道" min-width="15%" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<span v-for="(lane, index) in scope.row.lanes" :key="index">
|
||||||
|
{{ lane }}<span v-if="index < scope.row.lanes.length - 1">, </span>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="repeatDays" label="重复日期" min-width="15%" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<span v-for="(day, index) in scope.row.repeatDays" :key="day">
|
||||||
|
{{ ['周一', '周二', '周三', '周四', '周五', '周六', '周日'][day] }}
|
||||||
|
<span v-if="index < scope.row.repeatDays.length - 1">, </span>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="使能" width="80" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-switch
|
||||||
|
v-model="scope.row.enabled"
|
||||||
|
@change="(val) => handleStatusChange(val, scope.row)"
|
||||||
|
></el-switch>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="120" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button type="primary" size="small" @click="editPlan(scope.row)">编辑</el-button>
|
||||||
|
<el-button type="danger" size="small" @click="deletePlan(scope.row)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<!-- 新增/编辑方案弹窗 -->
|
||||||
|
<el-dialog :title="dialogTitle" v-model="planDialogVisible" width="650px">
|
||||||
<el-form :model="newPlan" label-width="120px">
|
<el-form :model="newPlan" label-width="120px">
|
||||||
<el-form-item label="方案名称">
|
<el-form-item label="方案名称">
|
||||||
<el-input v-model="newPlan.name" placeholder="请输入方案名称" style="width: 30rem"></el-input>
|
<el-input v-model="newPlan.name" placeholder="请输入方案名称"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
|
||||||
<el-form-item label="车道模式">
|
<el-form-item label="车道模式">
|
||||||
<el-select v-model="newPlan.selectedMode" placeholder="请选择车道模式" style="width: 30rem">
|
<el-select v-model="newPlan.selectedMode" placeholder="请选择车道模式">
|
||||||
<el-option label="左转 直行" value="leftTurn"></el-option>
|
<el-option label="左转 直行" value="0"></el-option>
|
||||||
<el-option label="右转 直行" value="rightTurn"></el-option>
|
<el-option label="右转 直行" value="1"></el-option>
|
||||||
<!-- <el-option label="直行 左转" value="straight"></el-option>
|
|
||||||
<el-option label="掉头 直行" value="uTurn"></el-option> -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
|
||||||
<el-form-item label="时间段设置">
|
<el-form-item label="时间段设置">
|
||||||
<div style="width: 30rem;">
|
<el-time-picker
|
||||||
<el-time-picker v-model="newPlan.timeRange" is-range range-separator="To"
|
v-model="newPlan.timeRange"
|
||||||
start-placeholder="开始时间" end-placeholder="结束时间" style="width: 30rem;" />
|
is-range
|
||||||
</div>
|
range-separator="至"
|
||||||
|
start-placeholder="开始时间"
|
||||||
|
end-placeholder="结束时间"
|
||||||
|
style="width: 350px;"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="开放车道">
|
<el-form-item label="开放车道">
|
||||||
@ -166,7 +206,6 @@
|
|||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 添加重复日期选择 -->
|
|
||||||
<el-form-item label="重复日期">
|
<el-form-item label="重复日期">
|
||||||
<el-checkbox-group v-model="newPlan.repeatDays">
|
<el-checkbox-group v-model="newPlan.repeatDays">
|
||||||
<el-checkbox label="0">周一</el-checkbox>
|
<el-checkbox label="0">周一</el-checkbox>
|
||||||
@ -178,64 +217,14 @@
|
|||||||
<el-checkbox label="6">周日</el-checkbox>
|
<el-checkbox label="6">周日</el-checkbox>
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item>
|
|
||||||
<div style="margin-left: 120px;">
|
|
||||||
<el-button type="primary" @click="addPlan">保存方案</el-button>
|
|
||||||
<el-button @click="resetNewPlan">重置</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
</el-form>
|
||||||
<el-table :data="plans" empty-text="暂无数据" border style="width: 58%">
|
<template #footer>
|
||||||
<el-table-column prop="name" label="方案名称" width="200" align="center"></el-table-column>
|
<span class="dialog-footer">
|
||||||
<el-table-column prop="timeRange" label="时间段" width="210" align="center"></el-table-column>
|
<el-button @click="planDialogVisible = false">取消</el-button>
|
||||||
<el-table-column prop="selectedMode" label="车道模式" width="210"
|
<el-button type="primary" @click="handlePlanSubmit">确定</el-button>
|
||||||
align="center"></el-table-column>
|
|
||||||
<el-table-column prop="lanes" label="开放车道" width="200" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<span v-for="(lane, index) in scope.row.lanes" :key="index">
|
|
||||||
{{ lane }}<span v-if="index < scope.row.lanes.length - 1">, </span>
|
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" width="200" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button type="primary" size="small" @click="editPlan(scope.row)">编辑</el-button>
|
|
||||||
<el-button type="danger" size="small" @click="deletePlan(scope.row)">删除</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<!-- 编辑方案弹窗 -->
|
|
||||||
<el-dialog title="编辑方案" :visible.sync="editDialogVisible">
|
|
||||||
<el-form :model="editPlanData" label-width="120px">
|
|
||||||
<el-form-item label="方案名称">
|
|
||||||
<el-input v-model="editPlanData.name"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="时间段设置">
|
|
||||||
<el-time-picker v-model="editPlanData.startTime" placeholder="开始时间">
|
|
||||||
</el-time-picker>
|
|
||||||
<span>至</span>
|
|
||||||
<el-time-picker v-model="editPlanData.endTime" placeholder="结束时间">
|
|
||||||
</el-time-picker>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="开放车道">
|
|
||||||
<el-checkbox-group v-model="editPlanData.lanes">
|
|
||||||
<el-checkbox :label="'车道1'">车道1</el-checkbox>
|
|
||||||
<el-checkbox :label="'车道2'">车道2</el-checkbox>
|
|
||||||
<el-checkbox :label="'车道3'">车道3</el-checkbox>
|
|
||||||
<el-checkbox :label="'车道4'">车道4</el-checkbox>
|
|
||||||
</el-checkbox-group>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
</el-form>
|
|
||||||
<div slot="footer" class="dialog-footer">
|
|
||||||
<el-button @click="editDialogVisible = false">取消</el-button>
|
|
||||||
<el-button type="primary" @click="saveEditPlan">保存</el-button>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="默认设置">
|
<el-tab-pane label="默认设置">
|
||||||
<el-form label-width="120px">
|
<el-form label-width="120px">
|
||||||
@ -288,7 +277,33 @@ export default {
|
|||||||
repeatDays: [], // 添加重复日期数组
|
repeatDays: [], // 添加重复日期数组
|
||||||
},
|
},
|
||||||
plans: [
|
plans: [
|
||||||
|
// {
|
||||||
|
// id: 1,
|
||||||
|
// name: '早高峰方案',
|
||||||
|
// timeRange: '07:30 - 09:30',
|
||||||
|
// selectedMode: '0', // 左转直行
|
||||||
|
// lanes: ['车道1', '车道2'],
|
||||||
|
// repeatDays: [0, 1, 2, 3, 4], // 周一到周五
|
||||||
|
// enabled: true
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id: 2,
|
||||||
|
// name: '晚高峰方案',
|
||||||
|
// timeRange: '17:00 - 19:00',
|
||||||
|
// selectedMode: '1', // 右转直行
|
||||||
|
// lanes: ['车道2', '车道3', '车道4'],
|
||||||
|
// repeatDays: [0, 1, 2, 3, 4],
|
||||||
|
// enabled: false
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id: 3,
|
||||||
|
// name: '周末方案',
|
||||||
|
// timeRange: '09:00 - 18:00',
|
||||||
|
// selectedMode: '0',
|
||||||
|
// lanes: ['车道1', '车道2', '车道3'],
|
||||||
|
// repeatDays: [5, 6], // 周六周日
|
||||||
|
// enabled: true
|
||||||
|
// }
|
||||||
],
|
],
|
||||||
editDialogVisible: false,
|
editDialogVisible: false,
|
||||||
editPlanData: {},
|
editPlanData: {},
|
||||||
@ -315,6 +330,10 @@ export default {
|
|||||||
lane3: [],
|
lane3: [],
|
||||||
lane4: []
|
lane4: []
|
||||||
},
|
},
|
||||||
|
planDialogVisible: false,
|
||||||
|
dialogTitle: '新增方案',
|
||||||
|
isEdit: false,
|
||||||
|
currentEditId: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -322,13 +341,13 @@ export default {
|
|||||||
resetNewPlan() {
|
resetNewPlan() {
|
||||||
this.newPlan = {
|
this.newPlan = {
|
||||||
name: '',
|
name: '',
|
||||||
startTime: '',
|
|
||||||
endTime: '',
|
|
||||||
lanes: [],
|
|
||||||
timeRange: [],
|
|
||||||
selectedMode: '',
|
selectedMode: '',
|
||||||
repeatDays: [], // 重置重复日期
|
timeRange: [],
|
||||||
|
lanes: [],
|
||||||
|
repeatDays: []
|
||||||
};
|
};
|
||||||
|
this.isEdit = false;
|
||||||
|
this.currentEditId = null;
|
||||||
},
|
},
|
||||||
// 模式设置
|
// 模式设置
|
||||||
async applySettings() {
|
async applySettings() {
|
||||||
@ -407,37 +426,22 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [startTime, endTime] = this.newPlan.timeRange || [null, null];
|
|
||||||
if (!startTime || !endTime) {
|
|
||||||
ElMessage({
|
|
||||||
message: '请选择时间范围',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.newPlan.lanes || this.newPlan.lanes.length === 0) {
|
|
||||||
ElMessage({
|
|
||||||
message: '请选择至少一个车道',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.newPlan.repeatDays || this.newPlan.repeatDays.length === 0) {
|
|
||||||
ElMessage({
|
|
||||||
message: '请选择重复日期',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const formatTime = (date) => {
|
const formatTime = (date) => {
|
||||||
|
if (typeof date === 'string') return date;
|
||||||
return date.toTimeString().slice(0, 5);
|
return date.toTimeString().slice(0, 5);
|
||||||
};
|
};
|
||||||
|
|
||||||
const lanes = this.newPlan.lanes.map(lane => {
|
// 处理时间范围
|
||||||
return lane.replace('车道', '') - 1;
|
let startTime, endTime;
|
||||||
|
if (Array.isArray(this.newPlan.timeRange)) {
|
||||||
|
[startTime, endTime] = this.newPlan.timeRange;
|
||||||
|
} else if (typeof this.newPlan.timeRange === 'string') {
|
||||||
|
[startTime, endTime] = this.newPlan.timeRange.split(' - ');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理车道
|
||||||
|
const lanes = (this.newPlan.lanes || []).map(lane => {
|
||||||
|
return String(lane.replace('车道', '') - 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
const planData = {
|
const planData = {
|
||||||
@ -445,15 +449,15 @@ export default {
|
|||||||
command: "set_scheme",
|
command: "set_scheme",
|
||||||
parameters: {
|
parameters: {
|
||||||
scheme: [{
|
scheme: [{
|
||||||
id: this.plans.length + 1,
|
id: this.isEdit ? this.currentEditId : (this.plans.length + 1),
|
||||||
name: this.newPlan.name,
|
name: this.newPlan.name,
|
||||||
selectedMode: String(this.modeMap[this.newPlan.selectedMode]),
|
selectedMode: this.newPlan.selectedMode,
|
||||||
timeRange: {
|
timeRange: {
|
||||||
start: formatTime(startTime),
|
start: formatTime(startTime),
|
||||||
end: formatTime(endTime)
|
end: formatTime(endTime)
|
||||||
},
|
},
|
||||||
lanes: lanes.map(String),
|
lanes: lanes,
|
||||||
repeatDays: this.newPlan.repeatDays // 添加重复日期
|
repeatDays: this.newPlan.repeatDays.map(day => Number(day))
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -469,7 +473,26 @@ export default {
|
|||||||
console.log('收到方案添加响应:', JSON.stringify(response.data, null, 2));
|
console.log('收到方案添加响应:', JSON.stringify(response.data, null, 2));
|
||||||
|
|
||||||
if (response.data?.parameters?.status === 0) {
|
if (response.data?.parameters?.status === 0) {
|
||||||
this.plans.push({ ...this.newPlan });
|
const newPlanData = {
|
||||||
|
id: planData.parameters.scheme[0].id,
|
||||||
|
name: this.newPlan.name,
|
||||||
|
timeRange: `${formatTime(startTime)} - ${formatTime(endTime)}`,
|
||||||
|
selectedMode: this.newPlan.selectedMode,
|
||||||
|
lanes: this.newPlan.lanes,
|
||||||
|
repeatDays: this.newPlan.repeatDays.map(day => Number(day)),
|
||||||
|
enabled: true
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.isEdit) {
|
||||||
|
const index = this.plans.findIndex(p => p.id === this.currentEditId);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.plans.splice(index, 1, newPlanData);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.plans.push(newPlanData);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.planDialogVisible = false;
|
||||||
this.resetNewPlan();
|
this.resetNewPlan();
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: response.data?.parameters?.message || '方案添加成功',
|
message: response.data?.parameters?.message || '方案添加成功',
|
||||||
@ -545,7 +568,8 @@ export default {
|
|||||||
name: scheme.name,
|
name: scheme.name,
|
||||||
timeRange: `${scheme.timeRange.start} - ${scheme.timeRange.end}`,
|
timeRange: `${scheme.timeRange.start} - ${scheme.timeRange.end}`,
|
||||||
selectedMode: scheme.selectedMode,
|
selectedMode: scheme.selectedMode,
|
||||||
lanes: scheme.lanes.map(lane => `车道${parseInt(lane) + 1}`)
|
lanes: scheme.lanes.map(lane => `车道${parseInt(lane) + 1}`),
|
||||||
|
repeatDays: scheme.repeatDays || [] // 添加重复日期
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,29 +683,24 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const deleteData = {
|
const deleteData = {
|
||||||
JSON_id: getNextJsonId(),
|
JSON_id: getNextJsonId(),
|
||||||
command: "set_scheme",
|
command: "delete_scheme",
|
||||||
parameters: {
|
parameters: {
|
||||||
scheme: [{
|
id: plan.id
|
||||||
id: plan.id,
|
|
||||||
name: plan.name,
|
|
||||||
selectedMode: "0", // 特殊值表示删除
|
|
||||||
timeRange: {
|
|
||||||
start: "00:00",
|
|
||||||
end: "00:00"
|
|
||||||
},
|
|
||||||
lanes: []
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('发送删除方案请求:', JSON.stringify(deleteData, null, 2));
|
||||||
|
|
||||||
const response = await axios.post('/communication', deleteData, {
|
const response = await axios.post('/communication', deleteData, {
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/json"
|
"content-type": "application/json"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('收到删除方案响应:', JSON.stringify(response.data, null, 2));
|
||||||
|
|
||||||
if (response.data?.parameters?.status === 0) {
|
if (response.data?.parameters?.status === 0) {
|
||||||
this.plans = this.plans.filter(p => p !== plan);
|
this.plans = this.plans.filter(p => p.id !== plan.id);
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: response.data?.parameters?.message || '方案删除成功',
|
message: response.data?.parameters?.message || '方案删除成功',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
@ -699,46 +718,106 @@ export default {
|
|||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.getAllInfo();
|
||||||
},
|
},
|
||||||
|
|
||||||
// 编辑方案
|
// 编辑方案
|
||||||
editPlan(plan) {
|
editPlan(plan) {
|
||||||
this.editPlanData = { ...plan };
|
this.isEdit = true;
|
||||||
this.editDialogVisible = true;
|
this.dialogTitle = '编辑方案';
|
||||||
|
this.currentEditId = plan.id;
|
||||||
|
|
||||||
|
// 处理时间范围
|
||||||
|
let [startTime, endTime] = plan.timeRange.split(' - ');
|
||||||
|
|
||||||
|
// 创建今天的日期对象,并设置时间
|
||||||
|
const today = new Date();
|
||||||
|
const [startHour, startMinute] = startTime.split(':');
|
||||||
|
const [endHour, endMinute] = endTime.split(':');
|
||||||
|
|
||||||
|
const startDate = new Date(today);
|
||||||
|
startDate.setHours(parseInt(startHour), parseInt(startMinute), 0);
|
||||||
|
|
||||||
|
const endDate = new Date(today);
|
||||||
|
endDate.setHours(parseInt(endHour), parseInt(endMinute), 0);
|
||||||
|
|
||||||
|
this.newPlan = {
|
||||||
|
name: plan.name,
|
||||||
|
selectedMode: plan.selectedMode,
|
||||||
|
timeRange: [startDate, endDate], // 使用 Date 对象
|
||||||
|
lanes: [...(plan.lanes || [])],
|
||||||
|
repeatDays: [...(plan.repeatDays || [])].map(String)
|
||||||
|
};
|
||||||
|
|
||||||
|
this.planDialogVisible = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
// 保存编辑的方案
|
// 保存编辑的方案
|
||||||
async saveEditPlan() {
|
async saveEditPlan() {
|
||||||
try {
|
try {
|
||||||
|
const formatTime = (date) => {
|
||||||
|
if (typeof date === 'string') return date;
|
||||||
|
return date.toTimeString().slice(0, 5);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理时间范围
|
||||||
|
let startTime, endTime;
|
||||||
|
if (Array.isArray(this.newPlan.timeRange)) {
|
||||||
|
[startTime, endTime] = this.newPlan.timeRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理车道
|
||||||
|
const lanes = (this.newPlan.lanes || []).map(lane => {
|
||||||
|
return String(lane.replace('车道', '') - 1);
|
||||||
|
});
|
||||||
|
|
||||||
const editedPlan = {
|
const editedPlan = {
|
||||||
JSON_id: getNextJsonId(),
|
JSON_id: getNextJsonId(),
|
||||||
command: "set_scheme",
|
command: "set_scheme",
|
||||||
parameters: {
|
parameters: {
|
||||||
scheme: [{
|
scheme: [{
|
||||||
id: this.editPlanData.id,
|
id: this.currentEditId,
|
||||||
name: this.editPlanData.name,
|
name: this.newPlan.name,
|
||||||
selectedMode: String(this.editPlanData.selectedMode),
|
selectedMode: this.newPlan.selectedMode,
|
||||||
timeRange: {
|
timeRange: {
|
||||||
start: this.editPlanData.startTime,
|
start: formatTime(startTime),
|
||||||
end: this.editPlanData.endTime
|
end: formatTime(endTime)
|
||||||
},
|
},
|
||||||
lanes: this.editPlanData.lanes.map(lane => lane.replace('车道', '') - 1).map(String)
|
lanes: lanes,
|
||||||
|
repeatDays: this.newPlan.repeatDays.map(day => Number(day))
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('发送方案编辑请求:', JSON.stringify(editedPlan, null, 2));
|
||||||
|
|
||||||
const response = await axios.post('/communication', editedPlan, {
|
const response = await axios.post('/communication', editedPlan, {
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/json"
|
"content-type": "application/json"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('收到方案编辑响应:', JSON.stringify(response.data, null, 2));
|
||||||
|
|
||||||
if (response.data?.parameters?.status === 0) {
|
if (response.data?.parameters?.status === 0) {
|
||||||
const index = this.plans.findIndex(p => p.id === this.editPlanData.id);
|
const newPlanData = {
|
||||||
|
id: this.currentEditId,
|
||||||
|
name: this.newPlan.name,
|
||||||
|
timeRange: `${formatTime(startTime)} - ${formatTime(endTime)}`,
|
||||||
|
selectedMode: this.newPlan.selectedMode,
|
||||||
|
lanes: this.newPlan.lanes,
|
||||||
|
repeatDays: this.newPlan.repeatDays.map(day => Number(day)),
|
||||||
|
enabled: true
|
||||||
|
};
|
||||||
|
|
||||||
|
const index = this.plans.findIndex(p => p.id === this.currentEditId);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
this.plans.splice(index, 1, { ...this.editPlanData });
|
this.plans.splice(index, 1, newPlanData);
|
||||||
}
|
}
|
||||||
this.editDialogVisible = false;
|
|
||||||
|
this.planDialogVisible = false;
|
||||||
|
this.resetNewPlan();
|
||||||
|
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: response.data?.parameters?.message || '方案编辑成功',
|
message: response.data?.parameters?.message || '方案编辑成功',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
@ -798,8 +877,49 @@ export default {
|
|||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// 显示新增方案弹窗
|
||||||
|
showAddPlanDialog() {
|
||||||
|
this.isEdit = false;
|
||||||
|
this.dialogTitle = '新增方案';
|
||||||
|
this.resetNewPlan();
|
||||||
|
this.planDialogVisible = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
// 处理方案提交
|
||||||
|
handlePlanSubmit() {
|
||||||
|
if (this.isEdit) {
|
||||||
|
this.saveEditPlan();
|
||||||
|
} else {
|
||||||
|
this.addPlan();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 处理状态改变
|
||||||
|
async handleStatusChange(val, row) {
|
||||||
|
try {
|
||||||
|
const statusData = {
|
||||||
|
JSON_id: getNextJsonId(),
|
||||||
|
command: "set_scheme_status",
|
||||||
|
parameters: {
|
||||||
|
id: row.id,
|
||||||
|
enabled: val
|
||||||
|
}
|
||||||
|
};
|
||||||
|
console.log('发送状态更新请求:', JSON.stringify(statusData, null, 2));
|
||||||
|
const response = await axios.post('/communication', statusData);
|
||||||
|
if (response.data?.parameters?.status === 0) {
|
||||||
|
ElMessage.success('状态更新成功');
|
||||||
|
} else {
|
||||||
|
row.enabled = !val; // 恢复原状态
|
||||||
|
ElMessage.error('状态更新失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
row.enabled = !val; // 恢复原状态
|
||||||
|
ElMessage.error('状态更新失败');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
// 组件挂载时获取设备信息和所有信息
|
// 组件挂载时获取设备信息和所有信息
|
||||||
this.getDeviceInfo();
|
this.getDeviceInfo();
|
||||||
@ -913,4 +1033,36 @@ export default {
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
color: #303133;
|
color: #303133;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.plan-list-header {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-footer {
|
||||||
|
text-align: right;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 添加表格相关样式 */
|
||||||
|
.el-table {
|
||||||
|
margin: 0 auto;
|
||||||
|
background-color: #ffffff;
|
||||||
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-table th {
|
||||||
|
background-color: #f5f7fa !important;
|
||||||
|
color: #606266;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-table td {
|
||||||
|
padding: 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 调整按钮间距 */
|
||||||
|
.el-button + .el-button {
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -131,6 +131,8 @@
|
|||||||
"compileTime": "2025-01-14T10:30:00Z"
|
"compileTime": "2025-01-14T10:30:00Z"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
获取所有信息
|
获取所有信息
|
||||||
|
|
||||||
(Web → 单片机)
|
(Web → 单片机)
|
||||||
@ -156,14 +158,15 @@
|
|||||||
"lanes": [
|
"lanes": [
|
||||||
"0",
|
"0",
|
||||||
"1"
|
"1"
|
||||||
]
|
],
|
||||||
|
"repeatDays": [0, 1, 2, 3, 4, 5, 6] // 表示周一到周日每天都重复执行该方案
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"laneSetting": {
|
"laneSetting": {
|
||||||
"lane1": ["0"], //0左转直行 1右转直行
|
"lane1": "0", //0左转直行 1右转直行
|
||||||
"lane2": ["1"],
|
"lane2": "1",
|
||||||
"lane3": ["0"],
|
"lane3": "0",
|
||||||
"lane4": ["1"]
|
"lane4": "1"
|
||||||
|
|
||||||
},
|
},
|
||||||
"deviceInfo": {
|
"deviceInfo": {
|
||||||
@ -175,13 +178,14 @@
|
|||||||
}
|
}
|
||||||
默认车道设置
|
默认车道设置
|
||||||
(Web → 单片机)
|
(Web → 单片机)
|
||||||
|
|
||||||
{
|
{
|
||||||
"command": "default_lane_setting",
|
"command": "default_lane_setting",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"lane1": ["0"], //0左转直行 1右转直行
|
"lane1": "0", //0左转直行 1右转直行
|
||||||
"lane2": ["1"],
|
"lane2": "1",
|
||||||
"lane3": ["2"],
|
"lane3": "2",
|
||||||
"lane4": ["3"]
|
"lane4": "3"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,3 +198,41 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
使能部分
|
||||||
|
(Web → 单片机)
|
||||||
|
{
|
||||||
|
"JSON_id": 30,
|
||||||
|
"command": "set_scheme_status",
|
||||||
|
"parameters": {
|
||||||
|
"id": 1,
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(单片机 → Web)
|
||||||
|
{
|
||||||
|
"command": "set_scheme_status_response",
|
||||||
|
"parameters": {
|
||||||
|
"status": 0, // 0: 成功, 1: 失败
|
||||||
|
"message": "Set successfully"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
删除方案
|
||||||
|
(Web → 单片机)
|
||||||
|
{
|
||||||
|
"command": "delete_scheme",
|
||||||
|
"parameters": {
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(单片机 → Web)
|
||||||
|
{
|
||||||
|
"command": "delete_scheme_response",
|
||||||
|
"parameters": {
|
||||||
|
"status": 0, // 0: 成功, 1: 失败
|
||||||
|
"message": "Delete successfully"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user