From 5808f76456ca0d40de5074f132b73a5a488e3e13 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Tue, 09 Dec 2025 09:12:03 +0800
Subject: [PATCH] Merge branch 'refs/heads/feature/v9.0/9.0.1' into test
---
src/views/layerManagement/components/leftList.vue | 482 +++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 409 insertions(+), 73 deletions(-)
diff --git a/src/views/layerManagement/components/leftList.vue b/src/views/layerManagement/components/leftList.vue
index f55a09a..20e4163 100644
--- a/src/views/layerManagement/components/leftList.vue
+++ b/src/views/layerManagement/components/leftList.vue
@@ -2,7 +2,7 @@
<div class="table-overlay">
<div class="searchBox">
<el-input
- class="ztzf-input inputName"
+ class="ztzf-layer-input inputName"
v-model="formData.dkbh"
placeholder="输入名称模糊搜索"
></el-input>
@@ -12,108 +12,407 @@
</div>
</div>
<div class="btnGroups">
- <el-button class="ztzf-button">新增围栏</el-button>
- <el-button class="ztzf-button">新增文件夹</el-button>
- <el-button class="ztzf-button" @click="selectAll">全选</el-button>
+ <el-button v-if="activeName !== '国土空间规划'" class="ztzf-button" @click="addFence">{{
+ props.activeName === '自定义识别区' ? '新增识别区' : '新增禁飞区'
+ }}</el-button>
+ <el-button v-if="activeName !== '国土空间规划'" class="ztzf-button" @click="addFolder"
+ >新增文件夹</el-button
+ >
+ <el-upload
+ v-if="activeName === '国土空间规划'"
+ action="#"
+ :show-file-list="false"
+ :before-upload="e => uploadFlightFile(e, '1')"
+ accept=".zip"
+ >
+ <el-button class="ztzf-button"> 上传 </el-button>
+ </el-upload>
+
+ <!-- <template v-if="activeName === '自定义禁飞区'">
+ <template v-if="failuresInfo.length">
+ <el-button class="ztzf-button" @click="synchronize"> 继续同步 </el-button>
+ <el-button class="ztzf-button" @click="failuresDel"> 取消同步 </el-button>
+ </template>
+ <el-button v-else class="ztzf-button" @click="synchronize"> 同步 </el-button>
+ </template> -->
+
+ <!-- <el-button class="ztzf-button" @click="selectAll">全选</el-button> -->
+ <el-button class="ztzf-button" @click="selectAll">
+ {{ checkedKeys.length === getAllFenceKeys().length ? '取消全选' : '全选' }}
+</el-button>
</div>
- <div class="tableListBox">
+ <div
+ class="tableListBox"
+ v-loading="loading"
+ element-loading-background="rgba(0, 0, 0, 0.2)"
+ element-loading-text="加载中..."
+ >
<el-tree
class="ztzf-el-tree"
+ :class="{ isTheTerritory: activeName === '国土空间规划' }"
ref="treeRef"
v-model="checkedKeys"
:data="treeData"
show-checkbox
node-key="id"
default-expand-all
+ :expand-on-click-node="false"
+ :check-on-click-node="false"
+ :filter-node-method="filterNode"
+ highlight-current
@check="handleCheck"
:props="{
label: 'name',
children: 'children',
}"
- />
+ >
+ <!-- 自定义节点内容 -->
+ <template #default="{ node }">
+ <div class="tree-node">
+ <!-- 节点名称 -->
+ <span class="nodeName">{{ node.label }}</span>
+ <!-- 操作按钮组 -->
+ <div class="tree-node-actions">
+ <el-button
+ link
+ icon="el-icon-location"
+ @click.stop="handleLocation(node)"
+ :disabled="node.data.level === 2 && (!node.data.children || node.data.children.length === 0)"
+ class="location-btn"
+ ></el-button>
+ <el-button icon="el-icon-edit" link @click.stop="handleEdit(node)"></el-button>
+ <el-button icon="el-icon-delete" link @click.stop="handleDelete(node)"></el-button>
+ </div>
+ </div>
+ </template>
+ </el-tree>
</div>
</div>
</template>
<script setup>
-import { treeDataApi } from '@/api/layer/index';
-import { onMounted } from 'vue';
-const emit = defineEmits(['update:coverData']);
+import { ElMessage, ElMessageBox } from 'element-plus';
+import {
+ treeDataApi,
+ deleteFenceApi,
+ deleteFolderApi,
+ spatialPlanningApi,
+ failuresListApi,
+ failuresDelApi,
+ areasUpdateApi,
+} from '@/api/layer/index';
+import { inject, nextTick, onMounted, watch } from 'vue';
+const emit = defineEmits(['update:coverData', 'update:deitData', 'newFencesMethods']);
+import EventBus from '@/utils/eventBus';
const coverData = ref();
-const props = defineProps(['activeName']);
-const formData = {
+const layerParams = inject('layerParams');
+const checkedKeys = ref([]); // 存储勾选的节点key
+const treeRef = ref(null); // 获取tree实例
+const checkedNodes = ref([]); // 存储勾选的节点数据
+const props = defineProps(['activeName','resetCheck']);
+const formData = ref({
isPush: undefined,
page: 1,
isGenerated: undefined,
pageSize: 17,
dkbh: '',
patchesName: '',
-};
-const reset = () => {};
-const search = () => {};
+});
+const loading = ref(false);
const treeData = ref([]);
const treeAllData = ref([]);
// 获取数据
const gettreeDataApi = async () => {
try {
- const res = await treeDataApi();
+ loading.value = true;
+ const res = await treeDataApi({filterExpired:false});
treeAllData.value = res.data.data;
- // console.log('接口获取数据', treeAllData.value);
+ if(coverData.value.length===0){
+ checkedKeys.value = [];
+ checkedNodes.value = [];
+ coverData.value = [];
+ nextTick(() => {
+ if (treeRef.value) {
+ treeRef.value.setCheckedKeys([]);
+ }
+ });
+ }
+
setupWatch();
} catch (error) {
console.error('获取数据失败:', error);
+ } finally {
+ loading.value = false;
}
};
+
const setupWatch = () => {
watch(
() => props.activeName,
newVal => {
const matchedCategory = treeAllData.value.find(item => item.name === newVal);
treeData.value = matchedCategory.children;
+ nextTick(search);
+ if (treeData.value && treeData.value.length > 0) {
+ const folderNode = treeData.value[0];
+ // 赋值给 layerParams
+ layerParams.value.total_count = folderNode.total_count ? folderNode.total_count : 0;
+ layerParams.value.total_area = folderNode.total_area ? folderNode.total_area : 0;
+ }
},
{ immediate: true }
);
};
-const checkedKeys = ref([]); // 存储勾选的节点key
-const treeRef = ref(null); // 获取tree实例
-
-const checkedNodes = ref([]); // 存储勾选的节点数据
-
const handleCheck = (checkedNodesData, checkedKeysData) => {
- checkedNodes.value = checkedNodesData.checkedNodes;
-
- coverData.value = checkedKeysData.checkedNodes;
-
+layerParams.value.isSingleLocating = false
+ const filteredNodes = checkedKeysData.checkedNodes.filter(node => node.level === 3);
+ checkedNodes.value = filteredNodes
+ checkedKeys.value = filteredNodes.map(node => node.id);
+ coverData.value = filteredNodes;
emit('update:coverData', coverData.value);
- // console.log('选中的节点数据:', checkedKeysData);
};
// 全选方法
+const getAllFenceKeys = () => {
+ return treeData.value.flatMap(
+ folder => folder.children.map(fence => fence.id)
+ );
+};
const selectAll = () => {
+ layerParams.value.currentLocationFolderId = null;
+layerParams.value.isSingleLocating = false
if (treeRef.value) {
- // 获取所有节点的key
- const allKeys = treeData.value.flatMap(item => [
- item.id,
- ...item.children.map(child => child.id),
- ]);
-
- if (checkedKeys.value.length === allKeys.length) {
- // 如果已经全选,则取消全选
+ const allFenceKeys = getAllFenceKeys();
+ const allFenceNodes = treeData.value.flatMap(folder => folder.children);
+ if (checkedKeys.value.length === allFenceKeys.length) {
+ // 取消全选
treeRef.value.setCheckedKeys([]);
+ checkedKeys.value = [];
checkedNodes.value = [];
+ coverData.value = [];
+ emit('update:coverData', coverData.value);
} else {
- // 否则全选
- treeRef.value.setCheckedKeys(allKeys);
- // 获取所有节点数据
- checkedNodes.value = treeData.value.flatMap(item => [ ...item.children]);
- console.log('所有数据', checkedNodes.value);
+ // 全选
+ treeRef.value.setCheckedKeys(allFenceKeys);
+ checkedKeys.value = allFenceKeys;
+ checkedNodes.value = allFenceNodes;
+ coverData.value = allFenceNodes;
+ emit('update:coverData', coverData.value);
+
}
+
+ }
+};
+// 定位按钮事件
+const handleLocation = node => {
+ const currentKey = treeRef.value.getCurrentKey();
+ if (currentKey === node.data.id) {
+ treeRef.value.setCurrentKey(null); // 取消高亮
+ } else {
+ treeRef.value.setCurrentKey(node.data.id); // 高亮当前节点
+ }
+ if (node.data.level === 2) {
+ layerParams.value.isSingleLocating = false;
+ // 新增:标记当前定位的文件夹ID
+ layerParams.value.currentLocationFolderId = node.data.id;
+ } else if (node.data.level === 3) {
+ layerParams.value.isSingleLocating = true;
+ // 清空文件夹定位标识
+ layerParams.value.currentLocationFolderId = null;
+ }
+
+ const currentCheckedKeys = [...checkedKeys.value];
+ const currentCheckedNodes = [...checkedNodes.value];
+ EventBus.emit('focusOnNode', node.data);
+ if (node.data.level === 2) {
+ const folderChildren = node.data.children || [];
+ const childrenIds = folderChildren.map(child => child.id);
+ const newChildrenIds = childrenIds.filter(id => !currentCheckedKeys.includes(id));
+ const newChildrenNodes = folderChildren.filter(child => newChildrenIds.includes(child.id));
+
+ const newCheckedKeys = [...new Set([...currentCheckedKeys, ...newChildrenIds])];
+ const newCheckedNodes = [...currentCheckedNodes, ...newChildrenNodes];
+
+ treeRef.value.setCheckedKeys(newCheckedKeys);
+ checkedKeys.value = newCheckedKeys;
+ checkedNodes.value = newCheckedNodes;
+ coverData.value = newCheckedNodes;
+ emit('update:coverData', coverData.value);
+ } else if (!currentCheckedKeys.includes(node.data.id)) {
+ layerParams.value.isSingleLocating = true;
+ currentCheckedKeys.push(node.data.id);
+ currentCheckedNodes.push(node.data);
+ treeRef.value.setCheckedKeys(currentCheckedKeys);
+ checkedKeys.value = currentCheckedKeys;
+ checkedNodes.value = currentCheckedNodes;
+ coverData.value = currentCheckedNodes;
+ emit('update:coverData', coverData.value);
+ }
+};
+// 编辑按钮事件
+const handleEdit = node => {
+ if (node.data.level == 2) {
+ layerParams.value.editFolder = true;
+ layerParams.value.addAnEditingFolder = 2;
+ if (props.activeName === '自定义识别区') {
+ layerParams.value.fileType = 1;
+ } else if (props.activeName === '自定义禁飞区') {
+ layerParams.value.fileType = 2;
+ }
+ emit('update:editFolder', node.data);
+ } else if (node.data.level === 3) {
+ checkedKeys.value = [];
+ checkedNodes.value = [];
+ coverData.value = [];
+ layerParams.value.editNest = true;
+ layerParams.value.decideWhetherToAddOrEdit = 2;
+ if (props.activeName === '自定义识别区') {
+ layerParams.value.fenceType = 1; // 电子围栏类型标识
+ } else if (props.activeName === '自定义禁飞区') {
+ layerParams.value.fenceType = 2; // 自定义禁飞区类型标识
+ }
+ emit('update:deitData', node.data);
}
};
+// 删除按钮事件
+const handleDelete = node => {
+
+ let id = node.data.id;
+ ElMessageBox.confirm('确定要删除该内容吗?', '提示', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning',
+ })
+ .then(() => {
+ if (node.data.level === 2) {
+ // 删除文件夹
+ deleteFolderApi(id).then(res => {
+ ElMessage.success('删除成功');
+ gettreeDataApi();
+ EventBus.emit('deleteMapEntitiesByFolderId', id);
+ });
+ } else if (node.data.level === 3) {
+ // 删除单个围栏/禁飞区
+ deleteFenceApi(id).then(res => {
+ ElMessage.success('删除成功');
+ gettreeDataApi();
+ EventBus.emit('deleteMapEntityById', id);
+ });
+ }
+ })
+ .catch(() => {
+
+ });
+};
+// 新增围栏
+const addFence = () => {
+ layerParams.value.addNest = true;
+ layerParams.value.decideWhetherToAddOrEdit = 1;
+ if (props.activeName === '自定义识别区') {
+ layerParams.value.fenceType = 1; // 电子围栏类型标识
+ } else if (props.activeName === '自定义禁飞区') {
+ layerParams.value.fenceType = 2; // 自定义禁飞区类型标识
+ }
+ emit('newFencesMethods');
+};
+// 新增文件夹
+const addFolder = () => {
+ layerParams.value.addFolder = true;
+ layerParams.value.addAnEditingFolder = 1;
+ if (props.activeName === '自定义识别区') {
+ layerParams.value.fileType = 1;
+ } else if (props.activeName === '自定义禁飞区') {
+ layerParams.value.fileType = 2;
+ }
+};
+function uploadFlightFile(file, t) {
+ const fileSuffix = file.name.substring(file.name.lastIndexOf('.') + 1);
+ if (!['zip'].includes(fileSuffix)) {
+ return ElMessage.error('请上传zip格式的文件');
+ }
+ let data = new FormData();
+ const params = {
+ file: file,
+ fileName: file.name,
+ };
+ Object.keys(params).forEach(key => {
+ data.append(key, params[key]);
+ });
+ spatialPlanningApi(data).then(res => {
+ ElMessage.success('上传成功');
+ gettreeDataApi();
+ });
+}
+
+function search() {
+ treeRef.value?.filter(formData.value.dkbh);
+}
+function reset() {
+ formData.value.dkbh = '';
+ treeRef.value?.filter('');
+}
+function filterNode(value, data) {
+ if (props.activeName === '国土空间规划') {
+ if (!value) return data.level === 2 || data.level === 1;
+ return (data.level === 2 || data.level === 1) && data.name.includes(value);
+ }
+ if (!value) return true;
+ return data.name.includes(value);
+}
+
+// 同步信息
+const failuresInfo = ref([]);
+function failuresList() {
+ failuresListApi().then(res => {
+ failuresInfo.value = res.data.data || [];
+ });
+}
+
+// 同步
+function synchronize() {
+ const data = failuresInfo.value.map(item => item.device_sn);
+ areasUpdateApi(data).then(res => {
+ if (res.data.data.length) {
+ let stringVal = res.data.data.reduce((acc, cur) => {
+ return acc + cur.nickname + '(' + cur.reason + ')' + ',';
+ }, '');
+ stringVal = stringVal.slice(0, -1);
+ ElMessageBox.alert(stringVal, '同步失败', {
+ confirmButtonText: '确定',
+ });
+ } else {
+ ElMessage.success('同步成功');
+ }
+ });
+}
+
+// 取消同步
+function failuresDel() {
+ failuresDelApi().then(res => {
+ ElMessage.success('取消同步成功');
+ });
+}
+// 切换tab清空复选框的数据
+watch(
+ () => props.resetCheck,
+ (newVal) => {
+ if (newVal !== undefined) {
+ checkedKeys.value = [];
+ checkedNodes.value = [];
+ coverData.value = [];
+ treeRef.value?.setCheckedKeys([]);
+ }
+ },
+ { immediate: true }
+);
onMounted(() => {
+ failuresList();
gettreeDataApi();
+ EventBus.on('gettreeDataApi', gettreeDataApi);
});
-const changeClick = val => {};
+onBeforeUnmount(() => {
+ EventBus.off('gettreeDataApi', gettreeDataApi);
+});
</script>
<style scoped lang="scss">
@@ -121,21 +420,24 @@
position: absolute;
top: 0;
left: 0;
- height: 95%;
+height: calc(100% - 32px);
z-index: 99;
- width: 392px;
-
+ width: 332px;
overflow: hidden;
- background: rgba(0, 0, 0, 0.51);
+ background: rgba(0,0,0,0.51);
+ backdrop-filter: blur(4px);
border-radius: 8px 8px 8px 8px;
- padding: 16px 12px;
+ padding: 16px 0 16px 12px;
+ display: flex;
+ flex-direction: column;
}
.searchBox {
display: flex;
margin-top: 10px;
+padding-right: 12px;
.inputName {
- width: 184px;
+ width: 140px;
height: 32px;
}
.searchAndReset {
@@ -144,40 +446,74 @@
justify-content: right;
align-items: center;
margin-right: 10px;
- .reset,
- .search {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 46px;
- height: 32px;
- cursor: pointer;
- }
- .reset {
- margin-left: 12px;
- background: #0d2b38;
- border-radius: 4px 4px 4px 4px;
- border: 1px solid #84cbd3;
- font-weight: 400;
- font-size: 14px;
- color: #ffffff;
- }
-
- .search {
- background: #1e2d51;
- border-radius: 4px 4px 4px 4px;
- border: 1px solid #c5d6ff;
- font-weight: 400;
- font-size: 14px;
- color: #ffffff;
- }
}
}
.btnGroups {
margin: 12px 0 14px 0;
display: flex;
+ gap: 0 10px;
+padding-right: 12px;
+ .el-button {
+ margin: 0 !important;
+ }
}
.tableListBox {
+ overflow-y: scroll;
+ height: 0;
+ flex-grow: 1;
+ // padding-right: 12px;
+ :deep(.el-tree-node__content) {
+ height: 45px !important;
+ line-height: 45px !important;
+ // padding-left: 0 !important;
+ border-bottom: 1px dotted rgba(255,255,255,0.1);
+ }
+ // 定位选中节点的背景色样式
+ ::v-deep(.el-tree-node.is-current > .el-tree-node__content) {
+ background-color: rgba(64, 158, 255, 0.2) !important; // 浅蓝色半透明背景
+ }
+ .isTheTerritory {
+ :deep() {
+ .el-tree-node__expand-icon {
+ visibility: hidden;
+ }
+ }
+ }
+
+ :deep() {
+ .el-checkbox {
+ --el-checkbox-bg-color: transparent !important;
+ }
+ }
+ .tree-node {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding-right: 12px;
+ width: 100%;
+ .nodeName {
+ font-size: 12px !important;
+ }
+ }
+
+ .tree-node-actions {
+ display: flex;
+ // gap: 8px;
+
+ button {
+ padding: 0;
+ color: #fff;
+ width: 17px;
+ height: 17px;
+ // color: #409eff;
+ // &:hover {
+ // color: #409eff;
+ // }
+ }
+ }
+ ::v-deep(.location-btn.el-button.is-link.is-disabled) {
+ color: #999 !important;
+}
}
</style>
--
Gitblit v1.9.3