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,143 @@
|
|
|
1
|
+
const globalFormList = [
|
|
2
|
+
{
|
|
3
|
+
ControlType: "RadioGroup",
|
|
4
|
+
nameCn: "选择器",
|
|
5
|
+
data: {
|
|
6
|
+
fieldName: "labelalign",
|
|
7
|
+
label: "标签对齐方式",
|
|
8
|
+
showRule: "{}",
|
|
9
|
+
rule: "[]",
|
|
10
|
+
itemConfig: {
|
|
11
|
+
value: "right",
|
|
12
|
+
items: [
|
|
13
|
+
{
|
|
14
|
+
label: "Top",
|
|
15
|
+
value: "top",
|
|
16
|
+
select: true,
|
|
17
|
+
id: 1,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: "Left",
|
|
21
|
+
value: "left",
|
|
22
|
+
id: 2,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: "Right",
|
|
26
|
+
value: "right",
|
|
27
|
+
select: false,
|
|
28
|
+
id: 4,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
id: 4,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
ControlType: "RadioGroup",
|
|
37
|
+
nameCn: "选择器",
|
|
38
|
+
data: {
|
|
39
|
+
fieldName: "size",
|
|
40
|
+
label: "组件尺寸",
|
|
41
|
+
showRule: "{}",
|
|
42
|
+
rule: "[]",
|
|
43
|
+
itemConfig: {
|
|
44
|
+
value: "small",
|
|
45
|
+
items: [
|
|
46
|
+
{
|
|
47
|
+
label: "large",
|
|
48
|
+
value: "large",
|
|
49
|
+
select: false,
|
|
50
|
+
id: 1,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: "default",
|
|
54
|
+
value: "default",
|
|
55
|
+
select: false,
|
|
56
|
+
id: 2,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: "small",
|
|
60
|
+
value: "small",
|
|
61
|
+
select: true,
|
|
62
|
+
id: 3,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
id: 3,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
ControlType: "InputNumber",
|
|
71
|
+
data: {
|
|
72
|
+
fieldName: "labelWidth",
|
|
73
|
+
label: "标签宽度",
|
|
74
|
+
tip: "",
|
|
75
|
+
showRule: "{}",
|
|
76
|
+
required: false,
|
|
77
|
+
rule: "[]",
|
|
78
|
+
default: 100,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
ControlType: "Text",
|
|
83
|
+
nameCn: "文本框",
|
|
84
|
+
data: {
|
|
85
|
+
fieldName: "suffix",
|
|
86
|
+
label: "表单项后缀",
|
|
87
|
+
tip: "",
|
|
88
|
+
placeholder: "",
|
|
89
|
+
showRule: "{}",
|
|
90
|
+
required: false,
|
|
91
|
+
rule: "[]",
|
|
92
|
+
default: ":",
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
ControlType: "FormStyle",
|
|
97
|
+
nameCn: "文本框",
|
|
98
|
+
data: {
|
|
99
|
+
fieldName: "styles",
|
|
100
|
+
label: "表单样式表",
|
|
101
|
+
tip: "",
|
|
102
|
+
placeholder: "",
|
|
103
|
+
showRule: "{}",
|
|
104
|
+
required: false,
|
|
105
|
+
rule: "[]",
|
|
106
|
+
default: "",
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
ControlType: "Selecteds",
|
|
111
|
+
nameCn: "文本框",
|
|
112
|
+
dynamic: true,
|
|
113
|
+
data: {
|
|
114
|
+
fieldName: "csslist",
|
|
115
|
+
label: "自定义Class",
|
|
116
|
+
tip: "",
|
|
117
|
+
placeholder: "",
|
|
118
|
+
showRule: "{}",
|
|
119
|
+
required: false,
|
|
120
|
+
rule: "[]",
|
|
121
|
+
itemConfig: {
|
|
122
|
+
value: [],
|
|
123
|
+
items: [],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
// {
|
|
128
|
+
// ControlType: "FormAction",
|
|
129
|
+
// nameCn: "文本框",
|
|
130
|
+
// data: {
|
|
131
|
+
// fieldName: "action",
|
|
132
|
+
// label: "动作面板",
|
|
133
|
+
// tip: "",
|
|
134
|
+
// placeholder: "",
|
|
135
|
+
// showRule: "{}",
|
|
136
|
+
// required: false,
|
|
137
|
+
// rule: "[]",
|
|
138
|
+
// default: [],
|
|
139
|
+
// },
|
|
140
|
+
// },
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
export { globalFormList };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="starfish-formitem">
|
|
3
|
+
<div class="label">
|
|
4
|
+
<label>{{ item.data.label }}</label>
|
|
5
|
+
<span v-if="item.data.required" class="item_require">*</span>
|
|
6
|
+
<el-tooltip
|
|
7
|
+
v-if="item.data.tip"
|
|
8
|
+
class="item"
|
|
9
|
+
effect="dark"
|
|
10
|
+
:content="item.data.tip"
|
|
11
|
+
placement="top"
|
|
12
|
+
>
|
|
13
|
+
<span class="tip iconfontui icon-tishi"></span>
|
|
14
|
+
</el-tooltip>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="control">
|
|
17
|
+
<el-button
|
|
18
|
+
style="width: 100%"
|
|
19
|
+
@click="onStyleSet"
|
|
20
|
+
:type="code ? 'primary' : ''"
|
|
21
|
+
>{{ code ? "已设置" : "设置" }}</el-button
|
|
22
|
+
>
|
|
23
|
+
<custom-dialog ref="codeDialog" dialogclass="codeDialog" width="1000">
|
|
24
|
+
<div class="custom_code">
|
|
25
|
+
<codemirror
|
|
26
|
+
v-model="code"
|
|
27
|
+
placeholder=".starfish-form-css{}"
|
|
28
|
+
:style="{ height: '400px' }"
|
|
29
|
+
:autofocus="true"
|
|
30
|
+
:extensions="extensions"
|
|
31
|
+
:indent-with-tab="true"
|
|
32
|
+
:tab-size="2"
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
<el-footer class="my-Footer" style="text-align: center">
|
|
36
|
+
<el-button type="primary" @click="saveCssStyle">确定</el-button>
|
|
37
|
+
<el-button @click="closeCodeDialog">关闭</el-button>
|
|
38
|
+
</el-footer>
|
|
39
|
+
</custom-dialog>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
<script lang="ts">
|
|
44
|
+
import { defineComponent, ref, getCurrentInstance } from "vue";
|
|
45
|
+
import { css } from "@codemirror/lang-css";
|
|
46
|
+
import {Codemirror} from 'vue-codemirror';
|
|
47
|
+
export default defineComponent({
|
|
48
|
+
ControlType: "FormStyle", // 必须与文件名匹配
|
|
49
|
+
isHide: true,
|
|
50
|
+
props: {
|
|
51
|
+
item: {
|
|
52
|
+
type: Object,
|
|
53
|
+
default: () => ({}),
|
|
54
|
+
},
|
|
55
|
+
data: {
|
|
56
|
+
type: Object,
|
|
57
|
+
default: () => ({}),
|
|
58
|
+
},
|
|
59
|
+
controlItems: {
|
|
60
|
+
type: Array,
|
|
61
|
+
default: () => [],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
components: {
|
|
65
|
+
Codemirror,
|
|
66
|
+
},
|
|
67
|
+
setup(props) {
|
|
68
|
+
const extensions = [css()];
|
|
69
|
+
const codeDialog = ref();
|
|
70
|
+
const code = ref();
|
|
71
|
+
const { proxy } = getCurrentInstance() as any;
|
|
72
|
+
return {
|
|
73
|
+
code,
|
|
74
|
+
extensions,
|
|
75
|
+
codeDialog,
|
|
76
|
+
onStyleSet() {
|
|
77
|
+
codeDialog.value.init("表单样式表", "icon-biaodan");
|
|
78
|
+
codeDialog.value.show();
|
|
79
|
+
},
|
|
80
|
+
saveCssStyle() {
|
|
81
|
+
props.data[props.item.data.fieldName] = code.value;
|
|
82
|
+
proxy.extractCssClass();
|
|
83
|
+
proxy.insertCustomCssToHead(code.value);
|
|
84
|
+
codeDialog.value.close();
|
|
85
|
+
},
|
|
86
|
+
closeCodeDialog() {
|
|
87
|
+
codeDialog.value.close();
|
|
88
|
+
},
|
|
89
|
+
extractCssClass() {
|
|
90
|
+
const regExp = /\..*{/g;
|
|
91
|
+
const result = code.value.match(regExp);
|
|
92
|
+
const cssNameArray: any[] = [];
|
|
93
|
+
if (!!result && result.length > 0) {
|
|
94
|
+
result.forEach((rItem: any) => {
|
|
95
|
+
const classArray = rItem.split(","); //切分逗号分割的多个class
|
|
96
|
+
if (classArray.length > 0) {
|
|
97
|
+
classArray.forEach((cItem: any) => {
|
|
98
|
+
const caItem = cItem.trim();
|
|
99
|
+
if (caItem.indexOf(".", 1) !== -1) {
|
|
100
|
+
//查找第二个.位置
|
|
101
|
+
const newClass = caItem.substring(
|
|
102
|
+
caItem.indexOf(".") + 1,
|
|
103
|
+
caItem.indexOf(".", 1)
|
|
104
|
+
); //仅截取第一、二个.号之间的class
|
|
105
|
+
if (newClass) {
|
|
106
|
+
cssNameArray.push(newClass.trim());
|
|
107
|
+
}
|
|
108
|
+
} else if (caItem.indexOf(" ") !== -1) {
|
|
109
|
+
//查找第一个空格位置
|
|
110
|
+
const newClass = caItem.substring(
|
|
111
|
+
caItem.indexOf(".") + 1,
|
|
112
|
+
caItem.indexOf(" ")
|
|
113
|
+
); //仅截取第一、二个.号之间的class
|
|
114
|
+
if (newClass) {
|
|
115
|
+
cssNameArray.push(newClass.trim());
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
if (caItem.indexOf("{") !== -1) {
|
|
119
|
+
//查找第一个{位置
|
|
120
|
+
const newClass = caItem.substring(
|
|
121
|
+
caItem.indexOf(".") + 1,
|
|
122
|
+
caItem.indexOf("{")
|
|
123
|
+
);
|
|
124
|
+
cssNameArray.push(newClass.trim());
|
|
125
|
+
} else {
|
|
126
|
+
const newClass = caItem.substring(caItem.indexOf(".") + 1);
|
|
127
|
+
cssNameArray.push(newClass.trim());
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
props.controlItems.find((item: any) => {
|
|
135
|
+
if (item.data.fieldName == "csslist") {
|
|
136
|
+
item.data.itemConfig.items = [];
|
|
137
|
+
cssNameArray.forEach((cssName: string, index: number) => {
|
|
138
|
+
item.data.itemConfig.items.push({
|
|
139
|
+
label: cssName,
|
|
140
|
+
value: cssName,
|
|
141
|
+
select: false,
|
|
142
|
+
id: index + 1,
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
return item;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
insertCustomCssToHead(cssCode: string) {
|
|
150
|
+
const head = document.getElementsByTagName("head")[0];
|
|
151
|
+
const oldStyle = document.getElementById("starfish-custom-css");
|
|
152
|
+
if (oldStyle) {
|
|
153
|
+
head.removeChild(oldStyle); //先清除后插入!!
|
|
154
|
+
}
|
|
155
|
+
const newStyle: any = document.createElement("style");
|
|
156
|
+
newStyle.type = "text/css";
|
|
157
|
+
newStyle.rel = "stylesheet";
|
|
158
|
+
newStyle.id = "starfish-custom-css";
|
|
159
|
+
try {
|
|
160
|
+
newStyle.appendChild(document.createTextNode(cssCode));
|
|
161
|
+
} catch (ex) {
|
|
162
|
+
newStyle.styleSheet.cssText = cssCode;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
head.appendChild(newStyle);
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
</script>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<codemirror
|
|
4
|
+
v-model="internalValue"
|
|
5
|
+
@input="onUpdateValue($event.target.innerText)"
|
|
6
|
+
placeholder="json导入"
|
|
7
|
+
mode="text/json"
|
|
8
|
+
:style="{ height: '400px' }"
|
|
9
|
+
:extensions="extensions"
|
|
10
|
+
/>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
<script>
|
|
14
|
+
import { defineComponent, ref } from "vue";
|
|
15
|
+
import { json } from "@codemirror/lang-json";
|
|
16
|
+
import {Codemirror} from "vue-codemirror";
|
|
17
|
+
export default defineComponent({
|
|
18
|
+
components: {
|
|
19
|
+
Codemirror,
|
|
20
|
+
},
|
|
21
|
+
props: {
|
|
22
|
+
value: String, // 接收外部传递的值
|
|
23
|
+
},
|
|
24
|
+
emits: ["update:value"], // 定义emit事件名称
|
|
25
|
+
setup(props, context) {
|
|
26
|
+
const extensions = [json()];
|
|
27
|
+
const internalValue = ref(props.value); // 内部状态变量
|
|
28
|
+
|
|
29
|
+
function updateInternalValue(newVal) {
|
|
30
|
+
internalValue.value = newVal;
|
|
31
|
+
|
|
32
|
+
if (context.attrs["onUpdate"]) {
|
|
33
|
+
context.attrs["onUpdate"](newVal); // 调用外部传递的onUpdate函数
|
|
34
|
+
} else {
|
|
35
|
+
context.emit("update:value", newVal); // 或者直接触发emit事件
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
extensions,
|
|
40
|
+
internalValue,
|
|
41
|
+
onUpdateValue: updateInternalValue,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
</script>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-scrollbar class="editor_pages_left">
|
|
3
|
+
<div class="filter">
|
|
4
|
+
<el-input
|
|
5
|
+
placeholder="请输入关键词进行过滤"
|
|
6
|
+
size=""
|
|
7
|
+
v-model="filterContent"
|
|
8
|
+
/>
|
|
9
|
+
</div>
|
|
10
|
+
<el-button text v-if="newcomponentlist.length > 0">基础控件</el-button>
|
|
11
|
+
<draggable
|
|
12
|
+
class="dragArea list-group"
|
|
13
|
+
:list="newcomponentlist"
|
|
14
|
+
:group="{ name: 'starfish-form', pull: 'clone', put: false }"
|
|
15
|
+
:sort="false"
|
|
16
|
+
item-key="id"
|
|
17
|
+
>
|
|
18
|
+
<template #item="{ element }">
|
|
19
|
+
<div
|
|
20
|
+
class="list-group-item"
|
|
21
|
+
:alt="element.nameCn"
|
|
22
|
+
@click.stop="clickAddControl(element)"
|
|
23
|
+
>
|
|
24
|
+
<div class="form-item">
|
|
25
|
+
<span class="iconfontui" :class="element.icon"></span>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="item-text">{{ element.nameCn }}</div>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
</draggable>
|
|
31
|
+
<el-button text v-if="layoutList.length > 0">布局控件</el-button>
|
|
32
|
+
<draggable
|
|
33
|
+
class="dragArea list-group"
|
|
34
|
+
:list="layoutList"
|
|
35
|
+
:group="{ name: 'starfish-form', pull: 'clone', put: false }"
|
|
36
|
+
:sort="false"
|
|
37
|
+
item-key="id"
|
|
38
|
+
>
|
|
39
|
+
<template #item="{ element }">
|
|
40
|
+
<div
|
|
41
|
+
class="list-group-item"
|
|
42
|
+
:alt="element.nameCn"
|
|
43
|
+
@click.stop="clickAddControl(element)"
|
|
44
|
+
>
|
|
45
|
+
<div class="form-item">
|
|
46
|
+
<span class="iconfontui" :class="element.icon"></span>
|
|
47
|
+
</div>
|
|
48
|
+
<div class="item-text">{{ element.nameCn }}</div>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
</draggable>
|
|
52
|
+
</el-scrollbar>
|
|
53
|
+
</template>
|
|
54
|
+
<script lang="ts">
|
|
55
|
+
import { defineComponent } from "vue";
|
|
56
|
+
import formStore from "@/controller/form";
|
|
57
|
+
import { BaseComponentItem } from "@/type";
|
|
58
|
+
export default defineComponent({
|
|
59
|
+
props: {
|
|
60
|
+
basicFields: {
|
|
61
|
+
type: Array,
|
|
62
|
+
default() {
|
|
63
|
+
return [];
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
layoutFields: {
|
|
67
|
+
type: Array,
|
|
68
|
+
default() {
|
|
69
|
+
return [];
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
data() {
|
|
74
|
+
const formcomponents: any = this.$formcomponents;
|
|
75
|
+
const lastFormComponents = [];
|
|
76
|
+
for (const key in formcomponents) {
|
|
77
|
+
const item = formcomponents[key];
|
|
78
|
+
if (item.isHide) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const model: BaseComponentItem | Record<string, any> = {};
|
|
82
|
+
model.ControlType = item.ControlType;
|
|
83
|
+
model.icon = item.icon;
|
|
84
|
+
model.nameCn = item.nameCn;
|
|
85
|
+
model.layout = !!item.layout;
|
|
86
|
+
// 有json编辑器时,验证格式有固定的规则
|
|
87
|
+
if (item.rule) {
|
|
88
|
+
model.rule = item.rule;
|
|
89
|
+
}
|
|
90
|
+
lastFormComponents.push(model);
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
formcomponents: lastFormComponents,
|
|
94
|
+
filterContent: "",
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
computed: {
|
|
98
|
+
newcomponentlist() {
|
|
99
|
+
return (this as any).formcomponents.filter((item: BaseComponentItem) => {
|
|
100
|
+
if (
|
|
101
|
+
item.nameCn &&
|
|
102
|
+
item.nameCn.indexOf(this.filterContent) != -1 &&
|
|
103
|
+
!item.layout
|
|
104
|
+
) {
|
|
105
|
+
if (this.basicFields.length == 0) {
|
|
106
|
+
return true;
|
|
107
|
+
} else if (this.basicFields.length > 0) {
|
|
108
|
+
let isHave = false;
|
|
109
|
+
this.basicFields.find((fieldItem: any) => {
|
|
110
|
+
if (
|
|
111
|
+
fieldItem.toLocaleLowerCase() ==
|
|
112
|
+
(item.ControlType as string).toLocaleLowerCase()
|
|
113
|
+
) {
|
|
114
|
+
isHave = true;
|
|
115
|
+
return fieldItem;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return isHave;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
layoutList() {
|
|
124
|
+
return (this as any).formcomponents.filter((item: any) => {
|
|
125
|
+
if (
|
|
126
|
+
item.nameCn &&
|
|
127
|
+
item.nameCn.indexOf(this.filterContent) != -1 &&
|
|
128
|
+
item.layout
|
|
129
|
+
) {
|
|
130
|
+
if (this.layoutFields.length == 0) {
|
|
131
|
+
return true;
|
|
132
|
+
} else if (this.layoutFields.length > 0) {
|
|
133
|
+
let isHave = false;
|
|
134
|
+
this.layoutFields.find((fieldItem: any) => {
|
|
135
|
+
if (
|
|
136
|
+
fieldItem.toLocaleLowerCase() ==
|
|
137
|
+
item.ControlType.toLocaleLowerCase()
|
|
138
|
+
) {
|
|
139
|
+
isHave = true;
|
|
140
|
+
return fieldItem;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return isHave;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
methods: {
|
|
150
|
+
clickAddControl(item: any) {
|
|
151
|
+
formStore.setAllFormList((this as any).$Flex.jsonToForm(item));
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
</script>
|
|
156
|
+
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<CustomDialog
|
|
3
|
+
ref="previewDialog"
|
|
4
|
+
:showDialog="previewShow"
|
|
5
|
+
@close="handlePreviewShow"
|
|
6
|
+
dialogclass="previewDialog"
|
|
7
|
+
>
|
|
8
|
+
<!-- <div class="previewList">
|
|
9
|
+
<div> -->
|
|
10
|
+
<!-- </div> -->
|
|
11
|
+
<!-- <div>
|
|
12
|
+
<div ref="JsonViewerDialog" ></div>
|
|
13
|
+
</div> -->
|
|
14
|
+
<!-- </div> -->
|
|
15
|
+
<div class="page_box" :class="pageType + '_layout'">
|
|
16
|
+
<dynamicform
|
|
17
|
+
:formResult="formResult"
|
|
18
|
+
:allFormList="allFormList"
|
|
19
|
+
:globalConfig="globalDatas"
|
|
20
|
+
ref="dynamicform"
|
|
21
|
+
/>
|
|
22
|
+
</div>
|
|
23
|
+
<el-footer class="my-Footer" style="text-align: center">
|
|
24
|
+
<el-button type="primary" @click="resetForm">重置表单</el-button>
|
|
25
|
+
<el-button type="primary" @click="getData">获取数据</el-button>
|
|
26
|
+
<el-button @click="closeDialog">关闭</el-button>
|
|
27
|
+
</el-footer>
|
|
28
|
+
<custom-dialog ref="codeDialog" dialogclass="codeDialog" width="1000">
|
|
29
|
+
<div class="custom_code">
|
|
30
|
+
<!-- <codemirror
|
|
31
|
+
v-model="code"
|
|
32
|
+
placeholder="Code goes here..."
|
|
33
|
+
mode="text/json"
|
|
34
|
+
:style="{ height: '400px' }"
|
|
35
|
+
:extensions="extensions"
|
|
36
|
+
:autofocus="true"
|
|
37
|
+
:indent-with-tab="true"
|
|
38
|
+
:tab-size="2"
|
|
39
|
+
/> -->
|
|
40
|
+
<JsonCode v-model:value="code" />
|
|
41
|
+
</div>
|
|
42
|
+
<el-footer
|
|
43
|
+
class="my-Footer"
|
|
44
|
+
style="
|
|
45
|
+
text-align: center;
|
|
46
|
+
position: absolute;
|
|
47
|
+
bottom: 0;
|
|
48
|
+
width: 100%;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
"
|
|
52
|
+
>
|
|
53
|
+
<el-button
|
|
54
|
+
type="primary"
|
|
55
|
+
@click="copyJson"
|
|
56
|
+
class="copy_btn"
|
|
57
|
+
data-clipboard-action="copy"
|
|
58
|
+
:data-clipboard-text="code"
|
|
59
|
+
>复制json</el-button
|
|
60
|
+
>
|
|
61
|
+
<el-button type="primary" @click="saveFile">保存为文件</el-button>
|
|
62
|
+
<el-button @click="closeCodeDialog">关闭</el-button>
|
|
63
|
+
</el-footer>
|
|
64
|
+
</custom-dialog>
|
|
65
|
+
</CustomDialog>
|
|
66
|
+
</template>
|
|
67
|
+
<script lang="ts">
|
|
68
|
+
import {
|
|
69
|
+
computed,
|
|
70
|
+
defineComponent,
|
|
71
|
+
defineAsyncComponent,
|
|
72
|
+
ref,
|
|
73
|
+
watch,
|
|
74
|
+
} from "vue";
|
|
75
|
+
import formStore from "@/controller/form";
|
|
76
|
+
import { Dynamicform } from "starfish-form";
|
|
77
|
+
import uiControl from "@/controller/ui";
|
|
78
|
+
import Clipboard from "clipboard";
|
|
79
|
+
// import { json } from "@codemirror/lang-json";
|
|
80
|
+
// import Codemirror from 'vue-codemirror'
|
|
81
|
+
export default defineComponent({
|
|
82
|
+
components: {
|
|
83
|
+
Dynamicform,
|
|
84
|
+
// Codemirror,
|
|
85
|
+
JsonCode: defineAsyncComponent(() => import("@/common/jsonCode.vue")),
|
|
86
|
+
},
|
|
87
|
+
setup() {
|
|
88
|
+
const previewShow = computed(() => formStore.get("previewShow"));
|
|
89
|
+
const allFormList = computed(() => formStore.get("AllFormResult"));
|
|
90
|
+
const formResult = computed(() => formStore.get("formResult"));
|
|
91
|
+
const globalDatas = computed(() => formStore?.get("globalDatas"));
|
|
92
|
+
const pageType = computed(() => uiControl?.get("pageType"));
|
|
93
|
+
// const extensions = [json()];
|
|
94
|
+
const codeDialog = ref();
|
|
95
|
+
const code = ref();
|
|
96
|
+
let clipboard: Clipboard;
|
|
97
|
+
const dynamicform = ref();
|
|
98
|
+
const previewDialog = ref<any>();
|
|
99
|
+
// let editor: any = null;
|
|
100
|
+
const handlePreviewShow = () => {
|
|
101
|
+
formStore.set("previewShow", false);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
watch(previewShow, async () => {
|
|
105
|
+
if (!previewShow.value) {
|
|
106
|
+
previewDialog.value.close();
|
|
107
|
+
} else {
|
|
108
|
+
previewDialog.value.init("表单预览", "icon-biaodan");
|
|
109
|
+
previewDialog.value.show();
|
|
110
|
+
previewDialog.value.isFullScreen = true;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
const JsonViewerDialog = ref();
|
|
114
|
+
return {
|
|
115
|
+
// extensions,
|
|
116
|
+
code,
|
|
117
|
+
pageType,
|
|
118
|
+
codeDialog,
|
|
119
|
+
globalDatas,
|
|
120
|
+
dialogWidth: computed(() => uiControl?.get("dialogWidth")),
|
|
121
|
+
previewShow,
|
|
122
|
+
previewDialog,
|
|
123
|
+
handlePreviewShow,
|
|
124
|
+
JsonViewerDialog,
|
|
125
|
+
allFormList,
|
|
126
|
+
formResult,
|
|
127
|
+
dynamicform,
|
|
128
|
+
resetForm() {
|
|
129
|
+
dynamicform.value.reset();
|
|
130
|
+
},
|
|
131
|
+
closeDialog() {
|
|
132
|
+
previewDialog.value.close();
|
|
133
|
+
},
|
|
134
|
+
getData() {
|
|
135
|
+
dynamicform.value?.getValidate().then((valide: boolean) => {
|
|
136
|
+
if (valide) {
|
|
137
|
+
console.log("formResult", formResult.value);
|
|
138
|
+
code.value = JSON.stringify(formResult?.value || {}, null, 4);
|
|
139
|
+
codeDialog.value.show();
|
|
140
|
+
codeDialog.value.init("表单数据", "icon-biaodan");
|
|
141
|
+
} else {
|
|
142
|
+
ElMessage({
|
|
143
|
+
type: "error",
|
|
144
|
+
message: "校验失败",
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
closeCodeDialog() {
|
|
150
|
+
codeDialog.value.close();
|
|
151
|
+
},
|
|
152
|
+
copyJson() {
|
|
153
|
+
if (!clipboard) {
|
|
154
|
+
clipboard = new Clipboard(".copy_btn");
|
|
155
|
+
}
|
|
156
|
+
clipboard.on("success", () => {
|
|
157
|
+
ElMessage({
|
|
158
|
+
type: "success",
|
|
159
|
+
message: "复制成功",
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
clipboard.on("error", () => {
|
|
163
|
+
ElMessage({
|
|
164
|
+
type: "error",
|
|
165
|
+
message: "复制失败",
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
setTimeout(() => {
|
|
169
|
+
// 销毁实例
|
|
170
|
+
clipboard.destroy();
|
|
171
|
+
}, 20000);
|
|
172
|
+
},
|
|
173
|
+
saveFile(fileName = "demo.json") {
|
|
174
|
+
let content = "data:application/json;charset=utf-8,";
|
|
175
|
+
try {
|
|
176
|
+
const result = code.value;
|
|
177
|
+
content += result;
|
|
178
|
+
const encodedUri = encodeURI(content);
|
|
179
|
+
const actions = document.createElement("a");
|
|
180
|
+
actions.setAttribute("href", encodedUri);
|
|
181
|
+
actions.setAttribute("download", fileName);
|
|
182
|
+
actions.click();
|
|
183
|
+
ElMessage({
|
|
184
|
+
type: "success",
|
|
185
|
+
message: "文件保存成功",
|
|
186
|
+
});
|
|
187
|
+
} catch (e) {
|
|
188
|
+
ElMessage({
|
|
189
|
+
type: "error",
|
|
190
|
+
message: "文件保存失败",
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
</script>
|