萤石摄像头

This commit is contained in:
Teo
2025-06-17 09:49:15 +08:00
parent f122dc30d2
commit 0ff1e74157
17 changed files with 1614 additions and 85 deletions

View File

@ -332,7 +332,7 @@ const handleMenuItemClick = (option: string, index: number) => {
if (selectLayer.value.some((item) => item.location.name === contextMenu.value.name)) {
return proxy?.$modal.msgError('已选择该图层,请勿重复选择');
}
if (selectLayer.value.some((item) => item.option !== '名称' && item.option !== '箱变')) {
if (selectLayer.value.some((item) => item.option !== '名称' && item.option !== '箱变' && item.option !== '光伏板')) {
if (option !== '名称' && option !== '箱变') return proxy?.$modal.msgError('只能选择一个类型');
}
selectLayer.value.push({ location: contextMenu.value, option });
@ -411,7 +411,7 @@ const getGeoJsonData = (nameOption = '名称', secondOption: string): { nameGeoJ
const handleTwoLayerUpload = async (optionB: string, apiFunc: (data: any) => Promise<any>) => {
const geoJson = getGeoJsonData('名称', optionB);
if (!geoJson) return;
if (optionB == '光伏板') return uploadPhotovoltaic(geoJson, apiFunc);
const data = {
projectId: props.projectId,
nameGeoJson: geoJson.nameGeoJson,
@ -423,6 +423,57 @@ const handleTwoLayerUpload = async (optionB: string, apiFunc: (data: any) => Pro
await apiFunc(data);
await showSuccess('添加成功');
};
//上传光伏板
const uploadPhotovoltaic = async (geoJson: { nameGeoJson: any[]; locationGeoJson: any }, apiFunc: (data: any) => Promise<any>) => {
// 提取原始 features
let rawNameFeatures = geoJson.nameGeoJson || [];
let rawLocationFeatures = geoJson.locationGeoJson || [];
console.log('🚀 nameGeoJson:', rawNameFeatures);
console.log('🚀 locationGeoJson:', rawLocationFeatures);
// 扁平化处理 FeatureCollection
const nameFeatures = rawNameFeatures.flatMap((fc) => fc.features || []).map((f) => ({ ...f, __source: 'name' }));
const locationFeatures = rawLocationFeatures.flatMap((fc) => fc.features).map((f) => ({ ...f, __source: 'location' }));
// 配对成上传单元
type FeaturePair = { nameFeature: any; locationFeature: any };
const pairedFeatures: FeaturePair[] = nameFeatures.map((name, i) => ({
nameFeature: name,
locationFeature: locationFeatures[i]
}));
// 启动上传
loading.value = true;
const sessionId = new Date().getTime().toString(36) + Math.random().toString(36).substring(2, 15);
const uploader = new BatchUploader({
dataList: pairedFeatures,
chunkSize: 3000, // 一次上传3000对
delay: 200,
uploadFunc: async (chunk, batchNum, totalBatch) => {
const chunkNameFeatures = chunk.map((pair) => pair.nameFeature);
const chunkLocationFeatures = chunk.map((pair) => pair.locationFeature);
console.log(`🚀 上传第 ${batchNum}/${totalBatch} 批,条数:`, chunk.length);
await apiFunc({
projectId: props.projectId,
nameGeoJson: [{ type: 'FeatureCollection', features: chunkNameFeatures }],
locationGeoJson: [{ type: 'FeatureCollection', features: chunkLocationFeatures }],
pointGeoJson: null,
sessionId,
totalBatch,
batchNum
});
},
onComplete: () => {
showSuccess('图层上传完成');
loading.value = false;
}
});
await uploader.start();
};
const handlePointUpload = async () => {
if (selectLayer.value.length > 1) return showError('最多选择一个桩点/支架');