starfish-editor-custom 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/auto-imports.d.ts +10 -0
- package/babel.config.js +8 -0
- package/components.d.ts +46 -0
- package/dist/ConditionModule.js +892 -0
- package/dist/ConditionSelect.js +483 -0
- package/dist/CustomDialog.js +105 -0
- package/dist/formStyle.js +245 -0
- package/dist/globalFormList.js +59 -0
- package/dist/jsonCode.js +74 -0
- package/dist/jsonEditor.js +71 -0
- package/dist/main.js +3319 -0
- package/dist/starfish-editor.es.js +30 -0
- package/dist/style.css +1 -0
- package/dist/types/editor/src/common/ConditionSelect/ConditionGroup.vue.d.ts +61 -0
- package/dist/types/editor/src/common/ConditionSelect/ConditionModule.vue.d.ts +43 -0
- package/dist/types/editor/src/common/ConditionSelect/ConditionTanc.vue.d.ts +48 -0
- package/dist/types/editor/src/common/ConditionSelect.vue.d.ts +72 -0
- package/dist/types/editor/src/common/CustomDialog.vue.d.ts +25 -0
- package/dist/types/editor/src/common/Loading.vue.d.ts +3 -0
- package/dist/types/editor/src/common/formJson.d.ts +80 -0
- package/dist/types/editor/src/common/jsonCode.vue.d.ts +110 -0
- package/dist/types/editor/src/components/ComponentList.vue.d.ts +32 -0
- package/dist/types/editor/src/components/FormPreview.vue.d.ts +25 -0
- package/dist/types/editor/src/components/Nav.vue.d.ts +9 -0
- package/dist/types/editor/src/components/PropsPanel.vue.d.ts +53 -0
- package/dist/types/editor/src/components/Shape.vue.d.ts +40 -0
- package/dist/types/editor/src/components/Workspace.vue.d.ts +22 -0
- package/dist/types/editor/src/components/globalFormList.vue.d.ts +6 -0
- package/dist/types/editor/src/components/jsonEditor.vue.d.ts +6 -0
- package/dist/types/editor/src/controller/action.d.ts +18 -0
- package/dist/types/editor/src/controller/form.d.ts +24 -0
- package/dist/types/editor/src/controller/history.d.ts +12 -0
- package/dist/types/editor/src/controller/shortcut.d.ts +20 -0
- package/dist/types/editor/src/controller/ui.d.ts +10 -0
- package/dist/types/editor/src/layouts/ControlEditSize.vue.d.ts +17 -0
- package/dist/types/editor/src/layouts/Framework.vue.d.ts +33 -0
- package/dist/types/editor/src/layouts/Resizer.vue.d.ts +13 -0
- package/dist/types/editor/src/layouts/ShortcutKey.vue.d.ts +8 -0
- package/dist/types/editor/src/main.d.ts +5 -0
- package/dist/types/editor/src/shims-vue.d.ts +23 -0
- package/dist/types/editor/src/starfish-editor.vue.d.ts +109 -0
- package/dist/types/editor/src/type.d.ts +224 -0
- package/dist/types/editor/src/utils/_.d.ts +33 -0
- package/dist/types/editor/src/utils/formKeycon.d.ts +18 -0
- package/dist/types/editor/src/utils/shortcutKey.d.ts +3 -0
- package/dist/types/editor/src/utils/vm.d.ts +3 -0
- package/dist/types/starfish-editor.d.ts +3 -0
- package/package.json +55 -0
- package/src/common/ConditionSelect/ConditionGroup.vue +167 -0
- package/src/common/ConditionSelect/ConditionModule.vue +118 -0
- package/src/common/ConditionSelect/ConditionTanc.vue +319 -0
- package/src/common/ConditionSelect.vue +268 -0
- package/src/common/CustomDialog.vue +77 -0
- package/src/common/Loading.vue +10 -0
- package/src/common/formJson.ts +143 -0
- package/src/common/formStyle.vue +170 -0
- package/src/common/jsonCode.vue +45 -0
- package/src/components/ComponentList.vue +156 -0
- package/src/components/FormPreview.vue +197 -0
- package/src/components/Nav.vue +128 -0
- package/src/components/NavList.vue +560 -0
- package/src/components/PropsPanel.vue +376 -0
- package/src/components/Shape.vue +178 -0
- package/src/components/Workspace.vue +258 -0
- package/src/components/globalFormList.vue +30 -0
- package/src/components/jsonEditor.vue +41 -0
- package/src/controller/action.ts +37 -0
- package/src/controller/form.ts +207 -0
- package/src/controller/history.ts +57 -0
- package/src/controller/shortcut.ts +81 -0
- package/src/controller/ui.ts +91 -0
- package/src/layouts/ControlEditSize.vue +52 -0
- package/src/layouts/Framework.vue +76 -0
- package/src/layouts/Resizer.vue +54 -0
- package/src/layouts/ShortcutKey.vue +61 -0
- package/src/main.ts +56 -0
- package/src/shims-vue.d.ts +23 -0
- package/src/starfish-editor.vue +176 -0
- package/src/styles/common/normalize.css +455 -0
- package/src/styles/component-list.scss +64 -0
- package/src/styles/condition-select.scss +176 -0
- package/src/styles/control_edit_size.scss +36 -0
- package/src/styles/custom-dialog.scss +110 -0
- package/src/styles/form-preview.scss +47 -0
- package/src/styles/framework.scss +150 -0
- package/src/styles/iconfont/iconfont.css +247 -0
- package/src/styles/iconfont/iconfont.js +1 -0
- package/src/styles/iconfont/iconfont.json +415 -0
- package/src/styles/iconfont/iconfont.ttf +0 -0
- package/src/styles/iconfont/iconfont.woff +0 -0
- package/src/styles/iconfont/iconfont.woff2 +0 -0
- package/src/styles/index.scss +18 -0
- package/src/styles/nav-list.scss +59 -0
- package/src/styles/nav.scss +46 -0
- package/src/styles/props-panel.scss +115 -0
- package/src/styles/resizer.scss +15 -0
- package/src/styles/shape.scss +101 -0
- package/src/styles/shortcutkey.scss +44 -0
- package/src/styles/variables.scss +36 -0
- package/src/styles/work-space.scss +126 -0
- package/src/type.ts +240 -0
- package/src/utils/_.ts +349 -0
- package/src/utils/formKeycon.ts +42 -0
- package/src/utils/shortcutKey.ts +46 -0
- package/src/utils/vm.ts +3 -0
- package/stats.html +4949 -0
- package/tsconfig.json +19 -0
- package/vite.config.ts +111 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="editor_pages_right editor_pages_right_visible" ref="editRight">
|
|
3
|
+
<!-- 交互 -->
|
|
4
|
+
<div class="editor_container" @mousedown="handleMouseDown" v-if="column">
|
|
5
|
+
<ControllEditSize />
|
|
6
|
+
</div>
|
|
7
|
+
<el-tabs
|
|
8
|
+
v-model="activeName"
|
|
9
|
+
class="demo-tabs"
|
|
10
|
+
@tab-click="handleClick"
|
|
11
|
+
style="height: 100%"
|
|
12
|
+
>
|
|
13
|
+
<el-tab-pane label="组件配置" name="form" v-if="panel.includes('form')">
|
|
14
|
+
<el-scrollbar class="dynamic">
|
|
15
|
+
<el-form
|
|
16
|
+
ref="ruleForm"
|
|
17
|
+
:model="curControl && (curControl.data || {})"
|
|
18
|
+
:rules="curControl && curControl.rules"
|
|
19
|
+
label-width="120px"
|
|
20
|
+
:status-icon="true"
|
|
21
|
+
>
|
|
22
|
+
<el-form-item
|
|
23
|
+
v-for="item in controlItems"
|
|
24
|
+
:key="item.id"
|
|
25
|
+
:control="item.ControlType"
|
|
26
|
+
:prop="item.data.fieldName"
|
|
27
|
+
>
|
|
28
|
+
<component
|
|
29
|
+
:drag="false"
|
|
30
|
+
:is="item.ControlType"
|
|
31
|
+
:data="curControl.data"
|
|
32
|
+
:item="item"
|
|
33
|
+
:size="globalDatas.size"
|
|
34
|
+
:labelWidth="globalDatas.labelWidth"
|
|
35
|
+
:labelalign="globalDatas.labelalign"
|
|
36
|
+
v-if="
|
|
37
|
+
(show && item.ControlType === 'JsonEditor') ||
|
|
38
|
+
item.ControlType !== 'JsonEditor'
|
|
39
|
+
"
|
|
40
|
+
></component>
|
|
41
|
+
</el-form-item>
|
|
42
|
+
</el-form>
|
|
43
|
+
<el-empty
|
|
44
|
+
:image-size="200"
|
|
45
|
+
v-if="!curControl || !curControl.data"
|
|
46
|
+
description="没有选中表单控件"
|
|
47
|
+
></el-empty>
|
|
48
|
+
</el-scrollbar>
|
|
49
|
+
</el-tab-pane>
|
|
50
|
+
<el-tab-pane label="JSON配置" name="json" v-if="panel.includes('json')">
|
|
51
|
+
<div class="json" v-if="activeName == 'json'">
|
|
52
|
+
<!-- <div ref="jsonCenter"></div> -->
|
|
53
|
+
<jsonEnter ref="jsonCenter" @editor="onEditor" />
|
|
54
|
+
</div>
|
|
55
|
+
</el-tab-pane>
|
|
56
|
+
<el-tab-pane
|
|
57
|
+
label="表单配置"
|
|
58
|
+
name="global"
|
|
59
|
+
v-if="panel.includes('global')"
|
|
60
|
+
>
|
|
61
|
+
<el-scrollbar class="form_tab3" v-if="activeName == 'global'">
|
|
62
|
+
<globalFormComponent />
|
|
63
|
+
</el-scrollbar>
|
|
64
|
+
</el-tab-pane>
|
|
65
|
+
</el-tabs>
|
|
66
|
+
|
|
67
|
+
<div class="editor_right_accept" @click="handleEditBtn">
|
|
68
|
+
<i
|
|
69
|
+
class="iconfontui icon-jiantou_xiangyouliangci"
|
|
70
|
+
:class="
|
|
71
|
+
moduleIsHidden
|
|
72
|
+
? 'icon-jiantou_xiangyouliangci'
|
|
73
|
+
: 'icon-jiantou_xiangzuoliangci'
|
|
74
|
+
"
|
|
75
|
+
></i>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
</template>
|
|
79
|
+
<script lang="ts">
|
|
80
|
+
import {
|
|
81
|
+
computed,
|
|
82
|
+
defineComponent,
|
|
83
|
+
ref,
|
|
84
|
+
watch,
|
|
85
|
+
nextTick,
|
|
86
|
+
getCurrentInstance,
|
|
87
|
+
inject,
|
|
88
|
+
toRaw,
|
|
89
|
+
ComputedRef,
|
|
90
|
+
defineAsyncComponent,
|
|
91
|
+
} from "vue";
|
|
92
|
+
import ControllEditSize from "@/layouts/ControlEditSize.vue";
|
|
93
|
+
import { globalFormList } from "@/common/formJson";
|
|
94
|
+
import type {
|
|
95
|
+
Controls,
|
|
96
|
+
AllFormItem,
|
|
97
|
+
BaseComponentItem,
|
|
98
|
+
BaseFormConfig,
|
|
99
|
+
} from "@/type";
|
|
100
|
+
import type { TabPaneInstance } from "element-plus";
|
|
101
|
+
import Loading from "@/common/Loading.vue";
|
|
102
|
+
|
|
103
|
+
export default defineComponent({
|
|
104
|
+
props: {
|
|
105
|
+
column: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
default: true,
|
|
108
|
+
},
|
|
109
|
+
panel: {
|
|
110
|
+
type: Array,
|
|
111
|
+
default: () => ["form", "json", "global"],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
components: {
|
|
115
|
+
ControllEditSize,
|
|
116
|
+
jsonEnter: defineAsyncComponent({
|
|
117
|
+
loader: () => import("./jsonEditor.vue"),
|
|
118
|
+
loadingComponent: Loading,
|
|
119
|
+
}),
|
|
120
|
+
globalFormComponent: defineAsyncComponent({
|
|
121
|
+
loader: () => import("./globalFormList.vue"),
|
|
122
|
+
loadingComponent: Loading,
|
|
123
|
+
}),
|
|
124
|
+
},
|
|
125
|
+
setup(props, { emit }) {
|
|
126
|
+
const { proxy } = getCurrentInstance() as any;
|
|
127
|
+
const { uiControl, hisContrl, formStore } =
|
|
128
|
+
inject<Controls>("control") || {};
|
|
129
|
+
// 该模块是否隐藏 默认显示
|
|
130
|
+
const moduleIsHidden = ref(true);
|
|
131
|
+
const show = ref(true);
|
|
132
|
+
const ruleForm = ref();
|
|
133
|
+
const editRight = ref();
|
|
134
|
+
const activeName = ref("form");
|
|
135
|
+
const jsonCenter = ref();
|
|
136
|
+
let jsonEditor: any = null;
|
|
137
|
+
const isTransition = ref(true); // 默认有补间动画
|
|
138
|
+
const controlItems = computed(() => formStore?.getControlItems());
|
|
139
|
+
const curControl = computed(() => formStore?.get("curControl"));
|
|
140
|
+
const newCurControl = computed(() =>
|
|
141
|
+
proxy.$Flex.deepClone(formStore?.get("curControl"))
|
|
142
|
+
);
|
|
143
|
+
const historyFlag = computed(() => hisContrl?.get("historyFlag"));
|
|
144
|
+
const save = computed(() => formStore?.get("save"));
|
|
145
|
+
const currentIndex = computed(() => formStore?.get("currentIndex"));
|
|
146
|
+
const handleEditBtn = () => {
|
|
147
|
+
moduleIsHidden.value = !moduleIsHidden.value;
|
|
148
|
+
if (moduleIsHidden.value) {
|
|
149
|
+
uiControl?.set("columnWidth", { right: undefined });
|
|
150
|
+
} else {
|
|
151
|
+
uiControl?.set("columnWidth", { right: 0 });
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 表单配置
|
|
157
|
+
*/
|
|
158
|
+
const globalData = formStore?.getDynamicForm(globalFormList);
|
|
159
|
+
formStore?.set("globalDatas", globalData);
|
|
160
|
+
formStore?.set("globalFormList", globalFormList);
|
|
161
|
+
const globalFormLists = computed(() => formStore?.get("globalFormList"));
|
|
162
|
+
const globalDatas = computed(() => formStore?.get("globalDatas"));
|
|
163
|
+
|
|
164
|
+
// 鼠标落下
|
|
165
|
+
const handleMouseDown = async () => {
|
|
166
|
+
formStore?.setFormCurrentId("");
|
|
167
|
+
formStore?.setFormCurrentIndex(-1);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// 预览或保存时验证所有表单是否输入正确
|
|
171
|
+
const preview = computed(() => formStore?.get("preview"));
|
|
172
|
+
const allFormList: ComputedRef<AllFormItem[] | undefined> = computed(() =>
|
|
173
|
+
formStore?.getAllFormList()
|
|
174
|
+
);
|
|
175
|
+
const checkNowFormValidate = function (content: string) {
|
|
176
|
+
return new Promise((resolve) => {
|
|
177
|
+
ruleForm.value.validate((valid: boolean) => {
|
|
178
|
+
if (!valid) {
|
|
179
|
+
ElNotification({
|
|
180
|
+
title: "Error",
|
|
181
|
+
message: content,
|
|
182
|
+
type: "error",
|
|
183
|
+
});
|
|
184
|
+
resolve(false);
|
|
185
|
+
} else {
|
|
186
|
+
resolve(true);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
function checkLayoutForm(curControl: AllFormItem): boolean {
|
|
193
|
+
if (curControl.ControlType == "TableLayout") {
|
|
194
|
+
const trs = curControl.data.trs || [];
|
|
195
|
+
for (let i = 0; i < trs.length; i++) {
|
|
196
|
+
const tds = trs[i].tds;
|
|
197
|
+
for (let j = 0; j < tds.length; j++) {
|
|
198
|
+
const state = checkFormValidate(tds[j].list);
|
|
199
|
+
if (!state) {
|
|
200
|
+
return state;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
} else if (curControl.ControlType == "Grid") {
|
|
205
|
+
const columns = curControl.data.columns || [];
|
|
206
|
+
for (let i = 0; i < columns.length; i++) {
|
|
207
|
+
const list = columns[i].list;
|
|
208
|
+
const state = checkFormValidate(list);
|
|
209
|
+
if (!state) {
|
|
210
|
+
return state;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const checkFormValidate = async (list: AllFormItem[] | undefined) => {
|
|
218
|
+
if (!list) return;
|
|
219
|
+
const len = list.length;
|
|
220
|
+
for (let i = 0; i < len; ++i) {
|
|
221
|
+
let validate = true;
|
|
222
|
+
const curControl: any = list[i];
|
|
223
|
+
curControl.controlItems?.forEach((item: BaseFormConfig) => {
|
|
224
|
+
if (item.data.required) {
|
|
225
|
+
validate = !!curControl.data[item.data.fieldName];
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
if (validate && curControl.layout) {
|
|
229
|
+
validate = checkLayoutForm(curControl);
|
|
230
|
+
}
|
|
231
|
+
if (!validate) {
|
|
232
|
+
formStore?.setFormCurrentId(curControl.id);
|
|
233
|
+
activeName.value = "form";
|
|
234
|
+
await nextTick();
|
|
235
|
+
const valid = await checkNowFormValidate(
|
|
236
|
+
"请检查动态表单输入格式问题"
|
|
237
|
+
);
|
|
238
|
+
if (!valid) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return true;
|
|
244
|
+
};
|
|
245
|
+
const formUpdate = computed(() => formStore?.get("formUpdate"));
|
|
246
|
+
const newAllmainlist = computed(() =>
|
|
247
|
+
proxy.$Flex.deepClone(formStore?.get("allFormList"))
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
const checkValidates = async (formSave = false, type?: string) => {
|
|
251
|
+
const curControlIndex = formStore?.get("currentIndex");
|
|
252
|
+
// 预览模式下不自动保存
|
|
253
|
+
if (type && preview.value) return;
|
|
254
|
+
if (preview.value || save.value || formUpdate.value) {
|
|
255
|
+
const ispreview = await checkFormValidate(allFormList.value);
|
|
256
|
+
if (ispreview) {
|
|
257
|
+
formStore?.setFormCurrentIndex(curControlIndex);
|
|
258
|
+
}
|
|
259
|
+
formStore?.setSave(true);
|
|
260
|
+
formStore?.setFormUpdate(false);
|
|
261
|
+
if (ispreview) {
|
|
262
|
+
const result: BaseComponentItem[] = initFormToJson(allFormList.value);
|
|
263
|
+
formStore?.set("AllFormResult", result);
|
|
264
|
+
formStore?.handleDynamicForm();
|
|
265
|
+
emit("save");
|
|
266
|
+
}
|
|
267
|
+
if (!formSave) {
|
|
268
|
+
formStore?.set("previewShow", ispreview);
|
|
269
|
+
formStore?.set("preview", false);
|
|
270
|
+
} else if (ispreview) {
|
|
271
|
+
ElNotification({
|
|
272
|
+
title: "Success",
|
|
273
|
+
message: type ? "已自动保存" : "保存成功",
|
|
274
|
+
type: "success",
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
const initFormToJson = (formlist: AllFormItem[] | undefined) => {
|
|
280
|
+
return window.VueContext.$Flex.initFormToJson(toRaw(formlist));
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
function complareControl(newControl: any, oldContrl: any) {
|
|
284
|
+
if (newControl !== oldContrl) return false;
|
|
285
|
+
let same = true;
|
|
286
|
+
for (const key in newControl) {
|
|
287
|
+
if (newControl[key] !== oldContrl[key]) {
|
|
288
|
+
same = false;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return same;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function initJsonToForm(list: BaseComponentItem[]) {
|
|
295
|
+
return toRaw(list).map((item: BaseComponentItem) => {
|
|
296
|
+
return proxy.$Flex.jsonToForm(item);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function handleClick(tab: TabPaneInstance) {
|
|
301
|
+
if (tab.props.name == "json" && jsonCenter.value) {
|
|
302
|
+
jsonEditor = jsonCenter.value.initJsonCenter();
|
|
303
|
+
} else if (tab.props.name == "form" && jsonEditor) {
|
|
304
|
+
try {
|
|
305
|
+
const list = proxy.$Flex.tryParseJson(jsonEditor.getText());
|
|
306
|
+
let newAllList: AllFormItem[] = [];
|
|
307
|
+
newAllList = initJsonToForm(list);
|
|
308
|
+
formStore?.updateAllFormList(newAllList);
|
|
309
|
+
} catch (e) {
|
|
310
|
+
console.error(e);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function onEditor(editor: any) {
|
|
316
|
+
jsonEditor = editor;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
proxy.$EventBus.on("openPreview", async () => {
|
|
320
|
+
checkValidates();
|
|
321
|
+
});
|
|
322
|
+
proxy.$EventBus.on("setSave", async (type?: string) => {
|
|
323
|
+
checkValidates(true, type);
|
|
324
|
+
});
|
|
325
|
+
watch(
|
|
326
|
+
() => [newAllmainlist.value, newCurControl.value?.data],
|
|
327
|
+
([, b], [, d]) => {
|
|
328
|
+
if (activeName.value == "json" && jsonCenter.value) {
|
|
329
|
+
jsonCenter.value.initJsonCenter();
|
|
330
|
+
}
|
|
331
|
+
if (historyFlag.value) {
|
|
332
|
+
hisContrl?.set("historyFlag", false);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (!complareControl(b, d)) {
|
|
336
|
+
formStore?.setHistory();
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
deep: true,
|
|
341
|
+
}
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
watch(
|
|
345
|
+
() => curControl.value?.data,
|
|
346
|
+
async () => {
|
|
347
|
+
if (!formUpdate.value) {
|
|
348
|
+
// store.commit("setFormUpdate", true);
|
|
349
|
+
formStore?.setFormUpdate(true);
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
{ deep: true }
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
return {
|
|
356
|
+
globalFormLists,
|
|
357
|
+
globalDatas,
|
|
358
|
+
jsonCenter,
|
|
359
|
+
handleClick,
|
|
360
|
+
jsonEditor,
|
|
361
|
+
onEditor,
|
|
362
|
+
activeName,
|
|
363
|
+
handleMouseDown,
|
|
364
|
+
moduleIsHidden,
|
|
365
|
+
handleEditBtn,
|
|
366
|
+
isTransition,
|
|
367
|
+
editRight,
|
|
368
|
+
controlItems,
|
|
369
|
+
curControl,
|
|
370
|
+
ruleForm,
|
|
371
|
+
show,
|
|
372
|
+
currentIndex,
|
|
373
|
+
};
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
</script>
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="shape"
|
|
4
|
+
:class="
|
|
5
|
+
active
|
|
6
|
+
? layout
|
|
7
|
+
? 'shape_border shape_border_layout'
|
|
8
|
+
: 'shape_border'
|
|
9
|
+
: layout
|
|
10
|
+
? 'noactive_layout'
|
|
11
|
+
: ''
|
|
12
|
+
"
|
|
13
|
+
@contextmenu="handleShortCut"
|
|
14
|
+
@click="handleMenu"
|
|
15
|
+
:style="{ display: inline ? 'inline-block' : 'block' }"
|
|
16
|
+
>
|
|
17
|
+
<transition name="fade" mode="out-in" appear>
|
|
18
|
+
<div class="editForm" v-show="isShow && active" ref="editForm">
|
|
19
|
+
<span @click="handleActive('copy')">复制</span>
|
|
20
|
+
<span @click="handleActive('cut')">剪切</span>
|
|
21
|
+
<span @click="handleActive('delete')">删除</span>
|
|
22
|
+
<span v-if="copyContent" @click="handleActive('paste')">粘贴</span>
|
|
23
|
+
<span @click="handleActive('top')" v-if="currentIndex != 0">上移</span>
|
|
24
|
+
<span @click="handleActive('bottom')" v-if="currentIndex != len - 1"
|
|
25
|
+
>下移</span
|
|
26
|
+
>
|
|
27
|
+
</div>
|
|
28
|
+
</transition>
|
|
29
|
+
<slot></slot>
|
|
30
|
+
<div class="editbar" v-if="active">
|
|
31
|
+
<span
|
|
32
|
+
class="iconfontui icon-xiangshang1"
|
|
33
|
+
v-if="currentIndex != 0"
|
|
34
|
+
@click.stop="handleActive('top')"
|
|
35
|
+
></span>
|
|
36
|
+
<span
|
|
37
|
+
class="iconfontui icon-xiangxia1"
|
|
38
|
+
v-if="currentIndex != len - 1"
|
|
39
|
+
@click.stop="handleActive('bottom')"
|
|
40
|
+
></span>
|
|
41
|
+
<span
|
|
42
|
+
class="iconfontui icon--charulie"
|
|
43
|
+
v-if="item && item.ControlType == 'TableLayout'"
|
|
44
|
+
@click="handleRow"
|
|
45
|
+
></span>
|
|
46
|
+
<span
|
|
47
|
+
class="iconfontui icon--charuhang"
|
|
48
|
+
v-if="item && item.ControlType == 'TableLayout'"
|
|
49
|
+
@click="handleColumn"
|
|
50
|
+
></span>
|
|
51
|
+
<span class="iconfontui icon-fuzhi" @click.stop="handleCopyAndPaste"></span>
|
|
52
|
+
<span
|
|
53
|
+
class="iconfontui icon-shanchu1"
|
|
54
|
+
@click.stop="handleActive('delete')"
|
|
55
|
+
></span>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</template>
|
|
59
|
+
<script lang="ts">
|
|
60
|
+
import { defineComponent, ref, nextTick, watch, computed, inject } from "vue";
|
|
61
|
+
import {
|
|
62
|
+
copy,
|
|
63
|
+
paste,
|
|
64
|
+
onDelete,
|
|
65
|
+
cut,
|
|
66
|
+
onTop,
|
|
67
|
+
onBottom,
|
|
68
|
+
} from "@/utils/formKeycon";
|
|
69
|
+
import type { Controls } from "@/type";
|
|
70
|
+
export default defineComponent({
|
|
71
|
+
props: {
|
|
72
|
+
active: Boolean,
|
|
73
|
+
currentIndex: Number,
|
|
74
|
+
len: {
|
|
75
|
+
type: Number,
|
|
76
|
+
default: 0,
|
|
77
|
+
},
|
|
78
|
+
inline: Boolean,
|
|
79
|
+
layout: Boolean,
|
|
80
|
+
currentId: String,
|
|
81
|
+
item: Object,
|
|
82
|
+
},
|
|
83
|
+
setup(props, context) {
|
|
84
|
+
const isShow = ref(false);
|
|
85
|
+
const editForm = ref();
|
|
86
|
+
const { store } = inject<Controls>("control") || {};
|
|
87
|
+
const { emit } = context;
|
|
88
|
+
const copyContent = computed(() => store?.get("copyContent"));
|
|
89
|
+
const handleShortCut = (e: MouseEvent) => {
|
|
90
|
+
if (props.active) {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
isShow.value = true;
|
|
93
|
+
const x = e.offsetX;
|
|
94
|
+
const y = e.offsetY;
|
|
95
|
+
nextTick(() => {
|
|
96
|
+
editForm.value.style.left = x + "px";
|
|
97
|
+
editForm.value.style.top = y + "px";
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
watch(
|
|
102
|
+
() => props.active,
|
|
103
|
+
() => {
|
|
104
|
+
if (!props.active) {
|
|
105
|
+
isShow.value = props.active;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
const handleMenu = () => {
|
|
110
|
+
isShow.value = false;
|
|
111
|
+
};
|
|
112
|
+
const handleActive = (type: string) => {
|
|
113
|
+
if (type === "copy") {
|
|
114
|
+
copy();
|
|
115
|
+
} else if (type === "paste") {
|
|
116
|
+
emit("paste");
|
|
117
|
+
paste();
|
|
118
|
+
} else if (type === "cut") {
|
|
119
|
+
cut();
|
|
120
|
+
} else if (type === "delete") {
|
|
121
|
+
onDelete();
|
|
122
|
+
} else if (type === "top") {
|
|
123
|
+
onTop();
|
|
124
|
+
} else if (type === "bottom") {
|
|
125
|
+
onBottom();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const handleCopyAndPaste = () => {
|
|
129
|
+
copy();
|
|
130
|
+
emit("paste");
|
|
131
|
+
paste();
|
|
132
|
+
};
|
|
133
|
+
document.addEventListener('click', () => {
|
|
134
|
+
isShow.value =false;
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
const handleColumn = () => {
|
|
138
|
+
const td = {
|
|
139
|
+
tds: [
|
|
140
|
+
{
|
|
141
|
+
colspan: 1,
|
|
142
|
+
rowspan: 1,
|
|
143
|
+
list: [],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
colspan: 1,
|
|
147
|
+
rowspan: 1,
|
|
148
|
+
list: [],
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
};
|
|
152
|
+
props.item?.data.trs.push(td);
|
|
153
|
+
};
|
|
154
|
+
const handleRow = () => {
|
|
155
|
+
props.item?.data.trs.forEach((trs: { tds: any[] }) => {
|
|
156
|
+
trs.tds.push({
|
|
157
|
+
colspan: 1,
|
|
158
|
+
rowspan: 1,
|
|
159
|
+
list: [],
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
isShow,
|
|
166
|
+
handleShortCut,
|
|
167
|
+
handleMenu,
|
|
168
|
+
editForm,
|
|
169
|
+
handleActive,
|
|
170
|
+
handleCopyAndPaste,
|
|
171
|
+
copyContent,
|
|
172
|
+
handleColumn,
|
|
173
|
+
handleRow,
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
</script>
|
|
178
|
+
|