|
@@ -94,10 +94,7 @@
|
|
|
:accept="activedGroup === '组件' ? '.svg' : 'image/*'"
|
|
|
:headers="headers"
|
|
|
:data="{
|
|
|
- directory:
|
|
|
- activedGroup === '图片'
|
|
|
- ? `/大屏/${item.name}`
|
|
|
- : '/大屏/默认',
|
|
|
+ directory: `/大屏/${activedGroup}/${item.name}`,
|
|
|
}"
|
|
|
:auto-upload="true"
|
|
|
:upload-all-files-in-one-request="false"
|
|
@@ -111,7 +108,7 @@
|
|
|
</t-upload>
|
|
|
<template v-if="item.canEdited">
|
|
|
<t-icon
|
|
|
- v-if="activedGroup === '方案' || activedGroup === '模板'"
|
|
|
+ v-if="['组件', '方案', '模板'].includes(activedGroup)"
|
|
|
name="add"
|
|
|
class="hover"
|
|
|
@click="onAdd(item)"
|
|
@@ -191,7 +188,7 @@
|
|
|
value="move"
|
|
|
title="移动到"
|
|
|
v-if="contextmenu.subMenus.length"
|
|
|
- :disabled="contextmenu.component['3d'] || activedGroup === '图片'"
|
|
|
+ :disabled="contextmenu.component['3d']"
|
|
|
>
|
|
|
<t-menu-item
|
|
|
v-for="subMenu in contextmenu.subMenus"
|
|
@@ -280,6 +277,7 @@ import {
|
|
|
getLe5leV,
|
|
|
updateCollection,
|
|
|
getCollectionList,
|
|
|
+ imageDrive,
|
|
|
} from '@/services/api';
|
|
|
import { convertPen } from '@/services/upgrade';
|
|
|
import { isGif } from '@/services/utils';
|
|
@@ -436,9 +434,14 @@ const groupChange = async (name: string) => {
|
|
|
subGroups.value = cases;
|
|
|
lastName = name;
|
|
|
} else {
|
|
|
- subGroups.value = await getUserProjects('le5leV');
|
|
|
+ // subGroups.value = await getUserProjects('le5leV');
|
|
|
+ // groupType.value = 1;
|
|
|
+ // await getPrivateProjects('le5leV');
|
|
|
+ // userLastName = name;
|
|
|
+
|
|
|
+ //用户方案
|
|
|
+ subGroups.value = await getCollectionImageList('方案', 'le5leV');
|
|
|
groupType.value = 1;
|
|
|
- await getPrivateProjects('le5leV');
|
|
|
userLastName = name;
|
|
|
}
|
|
|
break;
|
|
@@ -462,9 +465,12 @@ const groupChange = async (name: string) => {
|
|
|
subGroups.value = templates;
|
|
|
lastName = name;
|
|
|
} else {
|
|
|
- subGroups.value = await getUserProjects('le5leV-template');
|
|
|
+ // subGroups.value = await getUserProjects('le5leV-template');
|
|
|
+ // groupType.value = 1;
|
|
|
+ // await getPrivateProjects('le5leV-template');
|
|
|
+ // userLastName = name;
|
|
|
+ subGroups.value = await getCollectionImageList('模板', 'le5leV');
|
|
|
groupType.value = 1;
|
|
|
- await getPrivateProjects('le5leV-template');
|
|
|
userLastName = name;
|
|
|
}
|
|
|
break;
|
|
@@ -501,9 +507,15 @@ const groupChange = async (name: string) => {
|
|
|
lastName = name;
|
|
|
break;
|
|
|
case '组件':
|
|
|
- subGroups.value = await getUserComponents();
|
|
|
+ // subGroups.value = await getUserComponents();
|
|
|
+ // groupType.value = 1;
|
|
|
+ // await getPrivateGraphics();
|
|
|
+ // userLastName = name;
|
|
|
+ subGroups.value = await getCollectionImageList(
|
|
|
+ '组件',
|
|
|
+ 'le5leV-components'
|
|
|
+ );
|
|
|
groupType.value = 1;
|
|
|
- await getPrivateGraphics();
|
|
|
userLastName = name;
|
|
|
break;
|
|
|
case '图片':
|
|
@@ -534,16 +546,95 @@ const groupChange = async (name: string) => {
|
|
|
searchGraphics();
|
|
|
};
|
|
|
|
|
|
+//获取方案文件夹
|
|
|
+const getCollectionImageList = async (name?: string, collection?: string) => {
|
|
|
+ //1. 获取网盘文件夹
|
|
|
+ const fullpath = `/大屏/${name}`;
|
|
|
+ let ret: { list: any[] } = await axios.post('/api/directory/list', {
|
|
|
+ fullpath,
|
|
|
+ });
|
|
|
+ if (!ret) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ let list = [];
|
|
|
+ for (let i of ret.list) {
|
|
|
+ if (i.fullpath !== fullpath && i.fullpath !== `${fullpath}/默认`) {
|
|
|
+ //不取当前文件夹
|
|
|
+ list.push(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const data = {
|
|
|
+ query: {
|
|
|
+ // folder: '',
|
|
|
+ tags: name !== '组件' ? name : undefined,
|
|
|
+ },
|
|
|
+ projection: {
|
|
|
+ image: 1,
|
|
|
+ _id: 1,
|
|
|
+ name: 1,
|
|
|
+ tags: 1,
|
|
|
+ folder: 1,
|
|
|
+ component: 1,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ const config = {
|
|
|
+ params: {
|
|
|
+ current: 1,
|
|
|
+ pageSize: 1000,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ //2.请求所有图纸/组件数据
|
|
|
+ const res: any = await getCollectionList(collection, data, config);
|
|
|
+
|
|
|
+ //3.将数据对应到云盘文件夹
|
|
|
+ const results = [];
|
|
|
+ const resultsMap = {
|
|
|
+ 默认: [],
|
|
|
+ };
|
|
|
+ for (const item of list) {
|
|
|
+ let folder = item.fullpath.split('/')[3];
|
|
|
+ if (!resultsMap[folder]) {
|
|
|
+ resultsMap[folder] = [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const item of res.list) {
|
|
|
+ if (item.folder && resultsMap[item.folder]) {
|
|
|
+ resultsMap[item.folder].push(item);
|
|
|
+ } else {
|
|
|
+ resultsMap['默认'].push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (const item of list) {
|
|
|
+ let folder = item.fullpath.split('/')[3];
|
|
|
+
|
|
|
+ results.push({
|
|
|
+ name: folder,
|
|
|
+ canEdited: true,
|
|
|
+ _id: item._id,
|
|
|
+ list: resultsMap[folder],
|
|
|
+ });
|
|
|
+ }
|
|
|
+ results.push({
|
|
|
+ name: '默认',
|
|
|
+ list: resultsMap['默认'],
|
|
|
+ });
|
|
|
+
|
|
|
+ return results;
|
|
|
+};
|
|
|
+
|
|
|
const getImageList = async () => {
|
|
|
let ret: { list: any[] } = await axios.post('/api/directory/list', {
|
|
|
- fullpath: '/大屏',
|
|
|
+ fullpath: '/大屏/图片',
|
|
|
});
|
|
|
if (!ret) {
|
|
|
return [];
|
|
|
}
|
|
|
let list = [];
|
|
|
for (let i of ret.list) {
|
|
|
- if (i.fullpath.indexOf('缩略图') === -1) {
|
|
|
+ if (i.fullpath !== '/大屏/图片') {
|
|
|
+ //不取当前文件夹
|
|
|
list.push(i);
|
|
|
}
|
|
|
}
|
|
@@ -573,9 +664,9 @@ const getImageList = async () => {
|
|
|
};
|
|
|
});
|
|
|
return {
|
|
|
- name: secondDir[2],
|
|
|
+ name: secondDir[3],
|
|
|
_id: item._id,
|
|
|
- canEdited: secondDir[2] !== '默认',
|
|
|
+ canEdited: secondDir[3] !== '默认',
|
|
|
list: list,
|
|
|
};
|
|
|
})
|
|
@@ -921,6 +1012,7 @@ const dragStart = async (event: DragEvent | MouseEvent, item: any) => {
|
|
|
if (!Array.isArray(data)) {
|
|
|
data = deepClone([data]);
|
|
|
}
|
|
|
+
|
|
|
!dropped && (meta2d.canvas.addCaches = data);
|
|
|
|
|
|
if (event instanceof DragEvent) {
|
|
@@ -1071,6 +1163,57 @@ const createFoder = async () => {
|
|
|
if (activeAssets.value !== 'user') {
|
|
|
return;
|
|
|
}
|
|
|
+ if (editedFolder.value._id) {
|
|
|
+ const ret: any = await axios.post('/api/directory/update', {
|
|
|
+ oldFullpath: `/大屏/${activedGroup.value}/` + editedFolder.value.oldLabel,
|
|
|
+ newFullpath: `/大屏/${activedGroup.value}/` + editedFolder.value.label,
|
|
|
+ });
|
|
|
+ if (ret) {
|
|
|
+ editedFolder.value.name = editedFolder.value.label;
|
|
|
+ editedFolder.value.edited = false;
|
|
|
+ }
|
|
|
+ //更新图纸的folder
|
|
|
+ if (['组件', '方案', '模板'].includes(activedGroup.value)) {
|
|
|
+ const collection =
|
|
|
+ activedGroup.value === '组件' ? 'le5leV-components' : 'le5leV';
|
|
|
+ editedFolder.value.list?.forEach(async (item) => {
|
|
|
+ item.folder = editedFolder.value.label;
|
|
|
+ await updateCollection(collection, {
|
|
|
+ _id: item._id,
|
|
|
+ folder: editedFolder.value.label,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const ret: any = await axios.post('/api/directory/add', {
|
|
|
+ fullpath: `/大屏/${activedGroup.value}/` + editedFolder.value.label,
|
|
|
+ });
|
|
|
+ if (ret) {
|
|
|
+ editedFolder.value.name = editedFolder.value.label;
|
|
|
+ editedFolder.value._id = ret._id || ret.id;
|
|
|
+ editedFolder.value.edited = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const _createFoder = async () => {
|
|
|
+ if (!editedFolder.value.label) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (editedFolder.value.label === editedFolder.value.name) {
|
|
|
+ editedFolder.value.edited = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const found = subGroups.value.findIndex(
|
|
|
+ (group: any) => group.name === editedFolder.value.label
|
|
|
+ );
|
|
|
+ if (found >= 0) {
|
|
|
+ MessagePlugin.error('已经存在相同名称文件夹');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (activeAssets.value !== 'user') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if (['组件', '方案', '模板'].includes(activedGroup.value)) {
|
|
|
if (editedFolder.value._id) {
|
|
@@ -1136,15 +1279,21 @@ const onAdd = (item: any) => {
|
|
|
item.vType = 'le5leV';
|
|
|
} else if (activedGroup.value === '模板') {
|
|
|
item.vType = 'le5leV-template';
|
|
|
+ } else if (activedGroup.value === '组件') {
|
|
|
+ item.vType = 'le5leV-components';
|
|
|
}
|
|
|
setFolder(item);
|
|
|
+ const query: any = {
|
|
|
+ r: Date.now() + '',
|
|
|
+ folder: item.name,
|
|
|
+ tags: activedGroup.value,
|
|
|
+ };
|
|
|
+ if (activedGroup.value === '组件') {
|
|
|
+ query.c = 1;
|
|
|
+ }
|
|
|
router.push({
|
|
|
path: '/',
|
|
|
- query: {
|
|
|
- r: Date.now() + '',
|
|
|
- folder: item.name,
|
|
|
- tags: activedGroup.value,
|
|
|
- },
|
|
|
+ query,
|
|
|
});
|
|
|
// meta2d.open({
|
|
|
// name: '新建项目',
|
|
@@ -1198,7 +1347,7 @@ const onContextMenu = async (e: MouseEvent, group: any, item: any) => {
|
|
|
|
|
|
contextmenu.subMenus = [];
|
|
|
for (const elem of subGroups.value) {
|
|
|
- if (elem === group || elem.name === '3D') {
|
|
|
+ if (elem === group || elem.name === '默认' || elem.name === '3D') {
|
|
|
continue;
|
|
|
}
|
|
|
contextmenu.subMenus.push(elem);
|
|
@@ -1223,6 +1372,15 @@ const onMenu = async (val: string) => {
|
|
|
}, 500);
|
|
|
switch (val) {
|
|
|
case 'edit':
|
|
|
+ if (
|
|
|
+ contextmenu.component.tags &&
|
|
|
+ contextmenu.component.tags.includes('svg')
|
|
|
+ ) {
|
|
|
+ MessagePlugin.warning('解析的svg图元不允许编辑!');
|
|
|
+ hideContextmenu();
|
|
|
+ contextmenu.activeValue = 0;
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (contextmenu.component.component) {
|
|
|
autoSave();
|
|
|
router.push({
|
|
@@ -1297,33 +1455,45 @@ const onMenu = async (val: string) => {
|
|
|
arr.splice(index, 1);
|
|
|
}
|
|
|
});
|
|
|
- let collection = contextmenu.component.component
|
|
|
- ? 'le5leV-components'
|
|
|
- : 'le5leV';
|
|
|
- // 更新后端组件信息
|
|
|
- let ret = await updateCollection(collection, {
|
|
|
- _id: id,
|
|
|
- folder: val === '默认' ? '' : val,
|
|
|
- });
|
|
|
- if (!ret) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 更新后端源文件夹列表
|
|
|
- if (contextmenu.group.name !== '默认') {
|
|
|
- await axios.post('/api/data/folders/update', {
|
|
|
- _id: contextmenu.group._id || contextmenu.group.id,
|
|
|
- list: contextmenu.group.list,
|
|
|
+ if (activedGroup.value !== '图片') {
|
|
|
+ let collection = contextmenu.component.component
|
|
|
+ ? 'le5leV-components'
|
|
|
+ : 'le5leV';
|
|
|
+ // 更新后端组件信息
|
|
|
+ let ret = await updateCollection(collection, {
|
|
|
+ _id: id,
|
|
|
+ folder: val === '默认' ? '' : val,
|
|
|
});
|
|
|
+ if (!ret) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ // // 更新后端源文件夹列表
|
|
|
+ // if (contextmenu.group.name !== '默认') {
|
|
|
+ // await axios.post('/api/data/folders/update', {
|
|
|
+ // _id: contextmenu.group._id || contextmenu.group.id,
|
|
|
+ // list: contextmenu.group.list,
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
// 更新后端目标文件夹列表
|
|
|
- if (group.name !== '默认') {
|
|
|
- await axios.post('/api/data/folders/update', {
|
|
|
- _id: group._id || group.id,
|
|
|
- list: group.list,
|
|
|
- });
|
|
|
+ // if (group.name !== '默认') {
|
|
|
+ // await axios.post('/api/data/folders/update', {
|
|
|
+ // _id: group._id || group.id,
|
|
|
+ // list: group.list,
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ let filename: string =
|
|
|
+ contextmenu.component.filename || contextmenu.component.image;
|
|
|
+ if (imageDrive && filename.startsWith(imageDrive)) {
|
|
|
+ filename = filename.slice(imageDrive.length);
|
|
|
}
|
|
|
+ //更新缩略图位置
|
|
|
+ await axios.post('/api/files/update', {
|
|
|
+ filenames: [filename],
|
|
|
+ 'metadata.directory': `/大屏/${activedGroup.value}/${val || '默认'}`,
|
|
|
+ });
|
|
|
break;
|
|
|
}
|
|
|
contextmenu.activeValue = 0;
|
|
@@ -1333,7 +1503,7 @@ const hideContextmenu = () => {
|
|
|
contextmenu.visible = false;
|
|
|
};
|
|
|
|
|
|
-const delComponent = async () => {
|
|
|
+const _delComponent = async () => {
|
|
|
// const id = contextmenu.component._id || contextmenu.component.id;
|
|
|
if (['组件', '方案', '模板'].includes(activedGroup.value)) {
|
|
|
let collection = delDialog.contextmenuObj.component.component
|
|
@@ -1400,6 +1570,64 @@ const delComponent = async () => {
|
|
|
MessagePlugin.success('删除成功');
|
|
|
};
|
|
|
|
|
|
+const delComponent = async () => {
|
|
|
+ // const id = contextmenu.component._id || contextmenu.component.id;
|
|
|
+ if (['组件', '方案', '模板'].includes(activedGroup.value)) {
|
|
|
+ let collection = delDialog.contextmenuObj.component.component
|
|
|
+ ? 'le5leV-components'
|
|
|
+ : 'le5leV';
|
|
|
+ const id =
|
|
|
+ delDialog.contextmenuObj.component._id ||
|
|
|
+ delDialog.contextmenuObj.component.id;
|
|
|
+ try {
|
|
|
+ await axios.post(`/api/data/${collection}/delete`, {
|
|
|
+ id,
|
|
|
+ });
|
|
|
+ } catch (e) {
|
|
|
+ console.error(e);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 前端:从源文件夹移出组件
|
|
|
+ delDialog.contextmenuObj.group.list.forEach(
|
|
|
+ (item: any, index: number, arr: any[]) => {
|
|
|
+ if (id === item._id || id === item.id) {
|
|
|
+ arr.splice(index, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ const id =
|
|
|
+ delDialog.contextmenuObj.component._id ||
|
|
|
+ delDialog.contextmenuObj.component.id;
|
|
|
+ delDialog.contextmenuObj.group.list.forEach(
|
|
|
+ (item: any, index: number, arr: any[]) => {
|
|
|
+ if (id && (id === item._id || id === item.id)) {
|
|
|
+ arr.splice(index, 1);
|
|
|
+ }
|
|
|
+ if (!id) {
|
|
|
+ if (item.url === delDialog.contextmenuObj.component.url) {
|
|
|
+ arr.splice(index, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ let filename: string =
|
|
|
+ delDialog.contextmenuObj.component.filename ||
|
|
|
+ delDialog.contextmenuObj.component.image;
|
|
|
+ if (imageDrive && filename.startsWith(imageDrive)) {
|
|
|
+ filename = filename.slice(imageDrive.length);
|
|
|
+ }
|
|
|
+ await axios.post(`/api/files/delete`, {
|
|
|
+ filenames: [filename],
|
|
|
+ physically: false,
|
|
|
+ });
|
|
|
+ delDialog.show = false;
|
|
|
+ delDialog.contextmenuObj = {};
|
|
|
+
|
|
|
+ MessagePlugin.success('删除成功');
|
|
|
+};
|
|
|
+
|
|
|
const drop = (obj: any) => {
|
|
|
dropped = true;
|
|
|
|
|
@@ -1516,6 +1744,7 @@ function processFileObj(fileObj, c) {
|
|
|
let svgText = fileReader.result;
|
|
|
c.componentDatas = parseSvg(svgText as string);
|
|
|
c.component = true;
|
|
|
+ c.tags = ['svg'];
|
|
|
resolve(c);
|
|
|
};
|
|
|
} else {
|
|
@@ -1541,22 +1770,23 @@ const fileSuccessed = async (content: any) => {
|
|
|
);
|
|
|
const ret: any = await addCollection('le5leV-components', rst);
|
|
|
c._id = ret._id || ret.id;
|
|
|
- if (ret && uploadGroup.name !== '默认') {
|
|
|
- if (!uploadGroup.list) {
|
|
|
- uploadGroup.list = [];
|
|
|
- }
|
|
|
-
|
|
|
- uploadGroup.list.push(c);
|
|
|
- await axios.post('/api/data/folders/update', {
|
|
|
- _id: uploadGroup._id || uploadGroup.id,
|
|
|
- list: uploadGroup.list,
|
|
|
- });
|
|
|
- } else {
|
|
|
- if (!uploadGroup.list) {
|
|
|
- uploadGroup.list = [];
|
|
|
- }
|
|
|
- uploadGroup.list.push(c);
|
|
|
- }
|
|
|
+ // if (ret && uploadGroup.name !== '默认') {
|
|
|
+ // if (!uploadGroup.list) {
|
|
|
+ // uploadGroup.list = [];
|
|
|
+ // }
|
|
|
+
|
|
|
+ // uploadGroup.list.push(c);
|
|
|
+ // await axios.post('/api/data/folders/update', {
|
|
|
+ // _id: uploadGroup._id || uploadGroup.id,
|
|
|
+ // list: uploadGroup.list,
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // if (!uploadGroup.list) {
|
|
|
+ // uploadGroup.list = [];
|
|
|
+ // }
|
|
|
+ // uploadGroup.list.push(c);
|
|
|
+ // }
|
|
|
+ uploadGroup.list.push(c);
|
|
|
} else if (activedGroup.value === '图片') {
|
|
|
uploadGroup.list.push({
|
|
|
...content.response,
|
|
@@ -1582,15 +1812,19 @@ const delFolder = async (item: any) => {
|
|
|
if (activeAssets.value !== 'user') {
|
|
|
return;
|
|
|
}
|
|
|
- if (['组件', '方案', '模板'].includes(activedGroup.value)) {
|
|
|
- ret = await axios.post('/api/data/folders/delete', {
|
|
|
- id,
|
|
|
- });
|
|
|
- } else if (activedGroup.value === '图片') {
|
|
|
- ret = await axios.post('/api/directory/delete', {
|
|
|
- fullpaths: [`/大屏/${item.name}`],
|
|
|
- });
|
|
|
- }
|
|
|
+ // if (['组件', '方案', '模板'].includes(activedGroup.value)) {
|
|
|
+ // ret = await axios.post('/api/data/folders/delete', {
|
|
|
+ // id,
|
|
|
+ // });
|
|
|
+ // } else if (activedGroup.value === '图片') {
|
|
|
+ // ret = await axios.post('/api/directory/delete', {
|
|
|
+ // fullpaths: [`/大屏/${item.name}`],
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
+ ret = await axios.post('/api/directory/delete', {
|
|
|
+ fullpaths: [`/大屏/${activedGroup.value}/${item.name}`],
|
|
|
+ });
|
|
|
if (ret) {
|
|
|
const i = subGroups.value.findIndex(
|
|
|
(elem: any) => id === elem._id || id === elem.id
|