feat: 任务管理
This commit is contained in:
parent
bd2014edf0
commit
e9717c85e2
@ -29,4 +29,19 @@ export function deleteTask(id) {
|
||||
url: `/inspection/task/${id}`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function getWaypointByTaskId(taskId) {
|
||||
return request({
|
||||
url: `/inspection/task/${taskId}/waypoints`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function bindWaypointsToTask(taskId, waypointIds) {
|
||||
return request({
|
||||
url: `/inspection/task/${taskId}/waypoints`,
|
||||
method: 'post',
|
||||
data: waypointIds
|
||||
})
|
||||
}
|
||||
@ -6,8 +6,8 @@
|
||||
<template #one>
|
||||
<el-col :lg="6" :md="12" :sm="24" :xl="6" :xs="24" :xxl="6">
|
||||
<el-form-item label="任务名称" prop="taskName">
|
||||
<el-input v-model="queryParams.taskName" clearable placeholder="请输入任务名称"
|
||||
style="width: 100%" @keyup.enter="handleQuery" />
|
||||
<el-input v-model="queryParams.taskName" clearable placeholder="请输入任务名称" style="width: 100%"
|
||||
@keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="6" :md="12" :sm="24" :xl="6" :xs="24" :xxl="6">
|
||||
@ -86,23 +86,41 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="dialogVisible" title="参数配置" width="1080px">
|
||||
<EditTable></EditTable>
|
||||
<!-- 点位绑定弹窗 -->
|
||||
<el-dialog v-model="dialogVisible" title="点位绑定" width="800px">
|
||||
<el-table ref="pointRef" v-loading="loading" height="100%" :data="pointTableDataList"
|
||||
@row-click="handleRowClick">
|
||||
<el-table-column align="center" type="selection" width="55" />
|
||||
<el-table-column align="center" label="点位名称" prop="waypointName" show-overflow-tooltip />
|
||||
<el-table-column
|
||||
align="center"
|
||||
label="所属地图"
|
||||
prop="mapName"
|
||||
:filters="[
|
||||
{ text: '厂区', value: '3e2116b5e15c4e999079fbe11bbb6392' },
|
||||
{ text: '车间', value: '269a6d3b480f4f11a7d36326885c931b' }
|
||||
]"
|
||||
:filter-method="filterHandler"
|
||||
show-overflow-tooltip />
|
||||
<el-table-column align="center" label="点位描述" prop="remark" show-overflow-tooltip />
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="bindPoint">确 定</el-button>
|
||||
<el-button @click="cancelPoint">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script name="Detect" setup>
|
||||
import { addTask, updateTask, getTaskList, deleteTask } from "../../../api/inspection/task";
|
||||
import { addTask, updateTask, getTaskList, deleteTask, getWaypointByTaskId, bindWaypointsToTask } from "../../../api/inspection/task";
|
||||
import { getPointList } from "../../../api/inspection/point";
|
||||
import TableSearch from "@/components/TableSearch/index.vue";
|
||||
import { listGroup } from "@/api/system/group.js";
|
||||
import { appendParamsToPath } from "@/utils/fn.js";
|
||||
import TableTags from "@/components/TableTags/index.vue";
|
||||
import EditTable from "@/components/EditTable/index.vue";
|
||||
|
||||
import { useContainerHeight } from "@/hooks/tableHeight";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { de } from "element-plus/es/locale/index.mjs";
|
||||
|
||||
const topContainerRef = ref();
|
||||
const containerHeight = useContainerHeight(topContainerRef);
|
||||
@ -221,8 +239,70 @@ function handleDelete(row) {
|
||||
});
|
||||
}
|
||||
|
||||
const handleBindPoint = (row) => {
|
||||
const taskId = ref(null);
|
||||
const handleBindPoint = async (row) => {
|
||||
dialogVisible.value = true;
|
||||
taskId.value = row.id;
|
||||
await getPointTableTable();
|
||||
getBoundPoints(taskId.value);
|
||||
};
|
||||
|
||||
const getBoundPoints = (taskId) => {
|
||||
getWaypointByTaskId(taskId).then((res) => {
|
||||
const boundPointIds = res.data.map((point) => point.id);
|
||||
// 这里需要等点位数据加载完成后再设置选中状态
|
||||
nextTick(() => {
|
||||
if (pointRef.value) {
|
||||
pointRef.value.clearSelection(); // 先清除之前的选择状态
|
||||
pointTableDataList.value.forEach((point) => {
|
||||
if (boundPointIds.includes(point.id)) {
|
||||
pointRef.value.toggleRowSelection(point, true); // 设置选中状态
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const pointTableDataList = ref([]);
|
||||
|
||||
const getPointTableTable = async () => {
|
||||
loading.value = true;
|
||||
const res = await getPointList({
|
||||
pageNum: 1,
|
||||
pageSize: 10000,
|
||||
});
|
||||
if (res.code === 200) {
|
||||
pointTableDataList.value = res.rows;
|
||||
}
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
const pointRef = ref();
|
||||
|
||||
const handleRowClick = (row) => {
|
||||
pointRef.value.toggleRowSelection(row);
|
||||
};
|
||||
|
||||
const filterHandler = (value,row,column) => {
|
||||
return row["mapId"] === value
|
||||
}
|
||||
|
||||
const bindPoint = () => {
|
||||
// 这里可以调用绑定点位的接口,传递ids.value和当前任务的id
|
||||
const rows = pointRef.value.getSelectionRows(); // 绑定完成后清除选择状态
|
||||
const ids = rows.map((row) => row.id);
|
||||
bindWaypointsToTask(taskId.value, ids).then(() => {
|
||||
ElMessage.success("绑定成功");
|
||||
pointRef.value?.clearSelection();
|
||||
cancelPoint();
|
||||
});
|
||||
};
|
||||
|
||||
const cancelPoint = () => {
|
||||
dialogVisible.value = false;
|
||||
taskId.value = null;
|
||||
pointRef.value?.clearFilter()
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user