|
@@ -191,7 +191,12 @@ import axios from 'axios';
|
|
|
|
|
|
import { cases, shapes, charts, formComponents } from '@/services/defaults';
|
|
import { cases, shapes, charts, formComponents } from '@/services/defaults';
|
|
import { getFolders, getFiles, getIcons } from '@/services/png';
|
|
import { getFolders, getFiles, getIcons } from '@/services/png';
|
|
-import { getComponents, getComponentsList, getLe5leV } from '@/services/api';
|
|
|
|
|
|
+import {
|
|
|
|
+ getComponents,
|
|
|
|
+ getComponentsList,
|
|
|
|
+ getLe5leV,
|
|
|
|
+ updateCollection,
|
|
|
|
+} from '@/services/api';
|
|
import { convertPen } from '@/services/upgrade';
|
|
import { convertPen } from '@/services/upgrade';
|
|
import { deepClone } from '@meta2d/core';
|
|
import { deepClone } from '@meta2d/core';
|
|
import { isGif } from '@/services/utils';
|
|
import { isGif } from '@/services/utils';
|
|
@@ -365,6 +370,7 @@ const getPrivateGroups = async () => {
|
|
query: {
|
|
query: {
|
|
type: `le5leV-components`,
|
|
type: `le5leV-components`,
|
|
},
|
|
},
|
|
|
|
+ sort: { createdAt: 1 },
|
|
},
|
|
},
|
|
config
|
|
config
|
|
);
|
|
);
|
|
@@ -631,9 +637,15 @@ const onKeyHeader = (text: string, event: any) => {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+// 我的组件右键菜单
|
|
const contextmenu = reactive<any>({
|
|
const contextmenu = reactive<any>({
|
|
visible: false,
|
|
visible: false,
|
|
style: {},
|
|
style: {},
|
|
|
|
+ // 子分类
|
|
|
|
+ group: undefined,
|
|
|
|
+ // 组件图纸
|
|
|
|
+ component: undefined,
|
|
|
|
+ // 右键二级子菜单
|
|
subMenus: [],
|
|
subMenus: [],
|
|
});
|
|
});
|
|
const contextmenuDom = ref<any>(null);
|
|
const contextmenuDom = ref<any>(null);
|
|
@@ -678,9 +690,10 @@ const onContextMenu = async (e: MouseEvent, group: string, item: any) => {
|
|
const delDialog = reactive<any>({});
|
|
const delDialog = reactive<any>({});
|
|
|
|
|
|
const onMenu = async (val: string) => {
|
|
const onMenu = async (val: string) => {
|
|
|
|
+ const id = contextmenu.component._id || contextmenu.component.id;
|
|
|
|
+
|
|
switch (val) {
|
|
switch (val) {
|
|
case 'edit':
|
|
case 'edit':
|
|
- const id = contextmenu.component._id || contextmenu.component.id;
|
|
|
|
autoSave();
|
|
autoSave();
|
|
router.push({
|
|
router.push({
|
|
path: '/',
|
|
path: '/',
|
|
@@ -695,12 +708,81 @@ const onMenu = async (val: string) => {
|
|
case 'del':
|
|
case 'del':
|
|
delDialog.show = true;
|
|
delDialog.show = true;
|
|
break;
|
|
break;
|
|
|
|
+ default:
|
|
|
|
+ if (val.indexOf('move:')) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ val = val.replace('move:', '');
|
|
|
|
+ const group = contextmenu.subMenus.find(
|
|
|
|
+ (element: any) => element.name === val
|
|
|
|
+ );
|
|
|
|
+ if (!group) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 前端: 添加组件到目标文件夹
|
|
|
|
+ group.list.push(contextmenu.component);
|
|
|
|
+ // 前端:从源文件夹移出组件
|
|
|
|
+ contextmenu.group.list.forEach((item: any, index: number, arr: any[]) => {
|
|
|
|
+ if (id === item._id || id === item.id) {
|
|
|
|
+ arr.splice(index, 1);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 更新后端组件信息
|
|
|
|
+ let ret = await updateCollection('le5leV-components', {
|
|
|
|
+ _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,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
contextmenu.visible = false;
|
|
contextmenu.visible = false;
|
|
};
|
|
};
|
|
|
|
|
|
-const delComponet = () => {
|
|
|
|
|
|
+const delComponet = async () => {
|
|
|
|
+ const id = contextmenu.component._id || contextmenu.component.id;
|
|
|
|
+ const ret = await axios.post(`/api/data/le5leV-components/delete`, {
|
|
|
|
+ id,
|
|
|
|
+ });
|
|
|
|
+ if (!ret) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 前端:从源文件夹移出组件
|
|
|
|
+ contextmenu.group.list.forEach((item: any, index: number, arr: any[]) => {
|
|
|
|
+ if (id === item._id || id === item.id) {
|
|
|
|
+ arr.splice(index, 1);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 更新后端源文件夹列表
|
|
|
|
+ if (contextmenu.group.name !== '我的组件') {
|
|
|
|
+ await axios.post('/api/data/folders/update', {
|
|
|
|
+ _id: contextmenu.group._id || contextmenu.group.id,
|
|
|
|
+ list: contextmenu.group.list,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
delDialog.show = false;
|
|
delDialog.show = false;
|
|
};
|
|
};
|
|
|
|
|