diff --git a/example/App.vue b/example/App.vue index d4a468e..ee5b997 100644 --- a/example/App.vue +++ b/example/App.vue @@ -1,3 +1,4 @@ diff --git a/src/config/antd.ts b/src/config/antd.ts index 1672684..a642a28 100644 --- a/src/config/antd.ts +++ b/src/config/antd.ts @@ -1,3 +1,5 @@ +import { makeComponentMap } from '@/utils/makemap' + export interface Rules { trigger: string enum: string @@ -370,3 +372,5 @@ export const layoutComponents = [ } } ] + +export const islayoutComponent = makeComponentMap(layoutComponents) diff --git a/src/config/element.ts b/src/config/element.ts index f6deb6e..3a52d18 100644 --- a/src/config/element.ts +++ b/src/config/element.ts @@ -1,3 +1,5 @@ +import { makeComponentMap } from '@/utils/makemap' + export interface Rules { trigger: string enum: string @@ -362,3 +364,5 @@ export const layoutComponents = [ } } ] + +export const islayoutComponent = makeComponentMap(layoutComponents) diff --git a/src/core/antd/AntdDesignForm.vue b/src/core/antd/AntdDesignForm.vue index 903e782..7f28ca3 100644 --- a/src/core/antd/AntdDesignForm.vue +++ b/src/core/antd/AntdDesignForm.vue @@ -149,7 +149,7 @@ + + diff --git a/src/core/antd/AntdWidgetForm.vue b/src/core/antd/AntdWidgetForm.vue index 3548d0e..43a9588 100644 --- a/src/core/antd/AntdWidgetForm.vue +++ b/src/core/antd/AntdWidgetForm.vue @@ -7,148 +7,28 @@ :labelCol="widgetForm.config.labelCol" :hideRequiredMark="widgetForm.config.hideRequiredMark" > - - - + @handleMoveAdd="handleMoveAdd" + @handleItemClick="handleItemClick" + @handleCopyClick="handleCopyClick" + @handleDeleteClick="handleDeleteClick" + /> + + diff --git a/src/core/antd/components/DraggableForm.vue b/src/core/antd/components/DraggableForm.vue new file mode 100644 index 0000000..4d2c615 --- /dev/null +++ b/src/core/antd/components/DraggableForm.vue @@ -0,0 +1,97 @@ + + + + + diff --git a/src/core/element/ElGenerateForm.vue b/src/core/element/ElGenerateForm.vue index 9e71302..21853b1 100644 --- a/src/core/element/ElGenerateForm.vue +++ b/src/core/element/ElGenerateForm.vue @@ -11,31 +11,11 @@ :hide-required-asterisk="widgetForm.config.hideRequiredAsterisk" > diff --git a/src/core/element/ElWidgetLayoutForm.vue b/src/core/element/ElWidgetLayoutForm.vue new file mode 100644 index 0000000..3f7e2ad --- /dev/null +++ b/src/core/element/ElWidgetLayoutForm.vue @@ -0,0 +1,200 @@ + + + + + diff --git a/src/core/element/components/ElDraggableForm.vue b/src/core/element/components/ElDraggableForm.vue new file mode 100644 index 0000000..c623b4d --- /dev/null +++ b/src/core/element/components/ElDraggableForm.vue @@ -0,0 +1,100 @@ + + + + + diff --git a/src/styles/index.styl b/src/styles/index.styl index 220e20e..308e1e6 100644 --- a/src/styles/index.styl +++ b/src/styles/index.styl @@ -218,7 +218,7 @@ html, body font-size 14px color #fff margin 0 5px - cursor move + cursor pointer .widget-view-drag.widget-col-drag position absolute height 28px diff --git a/src/utils/array.ts b/src/utils/array.ts new file mode 100644 index 0000000..14b2e31 --- /dev/null +++ b/src/utils/array.ts @@ -0,0 +1,34 @@ +export function handleListInsert(key: string, list: any[], obj: any) { + const newList: any[] = [] + list.forEach(item => { + if (item.key === key) { + newList.push(item) + newList.push(obj) + } else { + if (item.columns) { + item.columns = item.columns.map((col: any) => ({ + ...col, + list: handleListInsert(key, col.list, obj) + })) + } + newList.push(item) + } + }) + return newList +} + +export function handleListDelete(key: string, list: any[]) { + const newList: any[] = [] + list.forEach(item => { + if (item.key !== key) { + if (item.columns) { + item.columns = item.columns.map((col: any) => ({ + ...col, + list: handleListDelete(key, col.list) + })) + } + newList.push(item) + } + }) + return newList +} diff --git a/src/utils/makemap.ts b/src/utils/makemap.ts new file mode 100644 index 0000000..68f2aed --- /dev/null +++ b/src/utils/makemap.ts @@ -0,0 +1,9 @@ +export function makeComponentMap( + components: Array +): (key: string) => boolean { + const map: Record = Object.create(null) + for (let i = 0; i < components.length; i++) { + map[components[i].type] = true + } + return val => !!map[val] +} diff --git a/tsconfig.json b/tsconfig.json index a7acb93..e374eef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,7 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "sourceMap": true, + "noImplicitAny": false, "baseUrl": ".", "types": ["webpack-env"], "paths": {