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,224 @@
|
|
|
1
|
+
import type { UiControl } from "./controller/ui";
|
|
2
|
+
import type { hisContrl } from "./controller/history";
|
|
3
|
+
import type { formContrl } from "./controller/form";
|
|
4
|
+
import type { ActionForm } from "./controller/action";
|
|
5
|
+
import type { shortCut } from "./controller/shortcut";
|
|
6
|
+
import type { FormConfig, fields } from "starfish-form/src/main";
|
|
7
|
+
/**
|
|
8
|
+
* 组件名称枚举
|
|
9
|
+
*/
|
|
10
|
+
type ComponentListEnum = Omit<keyof typeof window.VApp.$formcomponents, "symbol">;
|
|
11
|
+
interface ColumnWidth {
|
|
12
|
+
left: number;
|
|
13
|
+
center: number;
|
|
14
|
+
right: number;
|
|
15
|
+
}
|
|
16
|
+
export interface UiState {
|
|
17
|
+
/**
|
|
18
|
+
* 编辑器各模块宽度
|
|
19
|
+
*/
|
|
20
|
+
columnWidth: ColumnWidth;
|
|
21
|
+
/**
|
|
22
|
+
* 弹窗宽度
|
|
23
|
+
*/
|
|
24
|
+
dialogWidth: number;
|
|
25
|
+
/**
|
|
26
|
+
* 编辑器缩放比例
|
|
27
|
+
*/
|
|
28
|
+
scale: number;
|
|
29
|
+
/**
|
|
30
|
+
* 编辑器是否全屏
|
|
31
|
+
*/
|
|
32
|
+
isFullscreen: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 页面类型
|
|
35
|
+
*/
|
|
36
|
+
pageType: string;
|
|
37
|
+
/**
|
|
38
|
+
* 右侧配置菜单是否隐藏
|
|
39
|
+
*/
|
|
40
|
+
rightClose: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* 左侧表单列表模块是否隐藏
|
|
43
|
+
*/
|
|
44
|
+
leftClose: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface Controls {
|
|
47
|
+
uiControl: UiControl;
|
|
48
|
+
hisContrl: hisContrl;
|
|
49
|
+
formStore: formContrl;
|
|
50
|
+
actionContrl: ActionForm;
|
|
51
|
+
store: shortCut;
|
|
52
|
+
}
|
|
53
|
+
export interface setColumnWidth {
|
|
54
|
+
left?: number;
|
|
55
|
+
center?: number | "auto";
|
|
56
|
+
right?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface GetColumnWidth {
|
|
59
|
+
left: number;
|
|
60
|
+
center: number;
|
|
61
|
+
right: number;
|
|
62
|
+
}
|
|
63
|
+
export interface HistoryState {
|
|
64
|
+
/**
|
|
65
|
+
* 存储的所有历史行为
|
|
66
|
+
*/
|
|
67
|
+
historyList: HistoryItem[];
|
|
68
|
+
/**
|
|
69
|
+
* 当前所在的历史行为
|
|
70
|
+
*/
|
|
71
|
+
index: number;
|
|
72
|
+
/**
|
|
73
|
+
* 是否正在执行后退或前进,是则阻止进入历史快走中
|
|
74
|
+
*/
|
|
75
|
+
historyFlag: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* 历史回退最大步数
|
|
78
|
+
*/
|
|
79
|
+
maxStep: number;
|
|
80
|
+
}
|
|
81
|
+
export interface ShortCutState {
|
|
82
|
+
form: FormState;
|
|
83
|
+
copyContent: AllFormItem | Record<string, any>;
|
|
84
|
+
curList: AllFormItem[];
|
|
85
|
+
}
|
|
86
|
+
export interface HistoryItem {
|
|
87
|
+
allFormList: AllFormItem[];
|
|
88
|
+
currentIndex: number;
|
|
89
|
+
currentId: string;
|
|
90
|
+
curControl: AllFormItem | Record<string, any>;
|
|
91
|
+
}
|
|
92
|
+
export type MenuItem = "delete" | "undo" | "redo" | "tree" | "save" | "preview" | "fullscreen" | "viewport" | "json-export" | "json-import";
|
|
93
|
+
export type MenuRight = "viewport" | "json-export" | "json-import";
|
|
94
|
+
export type MenuBarData = {
|
|
95
|
+
left: MenuItem[];
|
|
96
|
+
right: MenuRight[];
|
|
97
|
+
column: boolean;
|
|
98
|
+
};
|
|
99
|
+
export interface FormState {
|
|
100
|
+
/**
|
|
101
|
+
* 存储所有选择的表单控件
|
|
102
|
+
*/
|
|
103
|
+
allFormList: AllFormItem[];
|
|
104
|
+
/**
|
|
105
|
+
* 选中的表单控件
|
|
106
|
+
*/
|
|
107
|
+
curControl: AllFormItem | Record<string, any>;
|
|
108
|
+
/**
|
|
109
|
+
* 选中的控件的id
|
|
110
|
+
*/
|
|
111
|
+
currentId: string;
|
|
112
|
+
/**
|
|
113
|
+
* 选中的控件的索引
|
|
114
|
+
*/
|
|
115
|
+
currentIndex: number;
|
|
116
|
+
/**
|
|
117
|
+
* 开启预览进行表单验证
|
|
118
|
+
*/
|
|
119
|
+
preview: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* 预览是否展示
|
|
122
|
+
*/
|
|
123
|
+
previewShow: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* 保存
|
|
126
|
+
*/
|
|
127
|
+
save: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* 下一次保存的时候判断表单是否变更了,而不用变更就改变save,但是我们监听了save会形成死循环
|
|
130
|
+
* 判断表单是否更新
|
|
131
|
+
*/
|
|
132
|
+
formUpdate: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* 预览和存储到数据库最终结果
|
|
135
|
+
*/
|
|
136
|
+
AllFormResult: any[];
|
|
137
|
+
/**
|
|
138
|
+
* 用户在动态表单输入的配置结果
|
|
139
|
+
*/
|
|
140
|
+
formResult: Record<string, any>;
|
|
141
|
+
/**
|
|
142
|
+
* 表单全局配置
|
|
143
|
+
*/
|
|
144
|
+
globalDatas: Record<string, any>;
|
|
145
|
+
/**
|
|
146
|
+
* 全局表单配置列表
|
|
147
|
+
*/
|
|
148
|
+
globalFormList: BaseFormConfig[];
|
|
149
|
+
}
|
|
150
|
+
interface FormRule {
|
|
151
|
+
fieldName: any[];
|
|
152
|
+
label: any[];
|
|
153
|
+
}
|
|
154
|
+
export interface AllFormItem {
|
|
155
|
+
/**
|
|
156
|
+
* 组件渲染唯一标识
|
|
157
|
+
*/
|
|
158
|
+
ControlType: ComponentListEnum;
|
|
159
|
+
/**
|
|
160
|
+
* 表单配置所需的表单配置列表
|
|
161
|
+
*/
|
|
162
|
+
controlItems: FormConfig[];
|
|
163
|
+
/**
|
|
164
|
+
* 表单配置
|
|
165
|
+
*/
|
|
166
|
+
data: fields;
|
|
167
|
+
/**
|
|
168
|
+
* 获取配置列表和配置方法列表
|
|
169
|
+
*/
|
|
170
|
+
formConfig: {
|
|
171
|
+
data: () => fields;
|
|
172
|
+
morenConfig: () => FormConfig[];
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* 组件icon图标
|
|
176
|
+
*/
|
|
177
|
+
icon: string;
|
|
178
|
+
/**
|
|
179
|
+
* 组件唯一id
|
|
180
|
+
*/
|
|
181
|
+
id: string;
|
|
182
|
+
/**
|
|
183
|
+
* 组件名称
|
|
184
|
+
*/
|
|
185
|
+
nameCn: string;
|
|
186
|
+
/**
|
|
187
|
+
* 是否是布局表单
|
|
188
|
+
*/
|
|
189
|
+
layout: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* 规则
|
|
192
|
+
*/
|
|
193
|
+
rules: FormRule;
|
|
194
|
+
}
|
|
195
|
+
export interface BaseComponentItem {
|
|
196
|
+
/**
|
|
197
|
+
* 组件渲染唯一标识
|
|
198
|
+
*/
|
|
199
|
+
ControlType: ComponentListEnum;
|
|
200
|
+
/**
|
|
201
|
+
* 组件icon图标
|
|
202
|
+
*/
|
|
203
|
+
icon: string;
|
|
204
|
+
/**
|
|
205
|
+
* 组件名称
|
|
206
|
+
*/
|
|
207
|
+
nameCn: string;
|
|
208
|
+
/**
|
|
209
|
+
* 是否是布局表单
|
|
210
|
+
*/
|
|
211
|
+
layout: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* 规则
|
|
214
|
+
*/
|
|
215
|
+
rules?: FormRule;
|
|
216
|
+
}
|
|
217
|
+
export type RequiredKey<T, K extends keyof T> = Omit<T, K> & {
|
|
218
|
+
[P in K]-?: T[P];
|
|
219
|
+
};
|
|
220
|
+
export type PartialKey<T, K extends keyof T> = Omit<T, K> & {
|
|
221
|
+
[P in K]?: T[P];
|
|
222
|
+
};
|
|
223
|
+
export type BaseFormConfig = FormConfig;
|
|
224
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AllFormItem } from '../type';
|
|
2
|
+
declare class Flex {
|
|
3
|
+
lastClickTime: number;
|
|
4
|
+
openTanc: boolean;
|
|
5
|
+
constructor();
|
|
6
|
+
clickCountLimit(): boolean;
|
|
7
|
+
generateMixed(size?: number): string;
|
|
8
|
+
controlFormRule(controlItems: any[]): any;
|
|
9
|
+
deepClone(target: any): any;
|
|
10
|
+
tryParseJson(json: string): any;
|
|
11
|
+
open(message: string, title?: string, type?: any): void;
|
|
12
|
+
getJsonValidate(): any;
|
|
13
|
+
getDataType(data: any): any;
|
|
14
|
+
/**
|
|
15
|
+
* json转标准数据格式进行收口
|
|
16
|
+
*/
|
|
17
|
+
jsonToForm(item: AllFormItem): AllFormItem;
|
|
18
|
+
/**
|
|
19
|
+
* 完整的表单列表数据进行删减,方便展示
|
|
20
|
+
*/
|
|
21
|
+
initFormToJson(formlist: AllFormItem[]): PartialKey<BaseComponentItem, "icon">[];
|
|
22
|
+
funcExec(action: string, proxy: any, argus?: any): void;
|
|
23
|
+
getField(methods: string): "" | "value, oldValue, subFormData" | "field";
|
|
24
|
+
/**
|
|
25
|
+
* 获取显示条件所有字段列表
|
|
26
|
+
* item: 其他表单数据
|
|
27
|
+
* result 最终的结果
|
|
28
|
+
* fieldName 过滤当前选中表单的字段(显示规则不能根据自身的值进行展示)
|
|
29
|
+
*/
|
|
30
|
+
getFormDataList(item: AllFormItem, result: any, fieldName: string): void;
|
|
31
|
+
}
|
|
32
|
+
declare const _default: Flex;
|
|
33
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function clearCanvas(): void;
|
|
2
|
+
export declare function copy(): void;
|
|
3
|
+
export declare function paste(): void;
|
|
4
|
+
export declare function cut(): void;
|
|
5
|
+
export declare function onDelete(): void;
|
|
6
|
+
export declare function onTop(): void;
|
|
7
|
+
export declare function onBottom(): void;
|
|
8
|
+
declare const result: {
|
|
9
|
+
copy: typeof copy;
|
|
10
|
+
paste: typeof paste;
|
|
11
|
+
cut: typeof cut;
|
|
12
|
+
delete: typeof onDelete;
|
|
13
|
+
onTop: typeof onTop;
|
|
14
|
+
onBottom: typeof onBottom;
|
|
15
|
+
clearCanvas: typeof clearCanvas;
|
|
16
|
+
};
|
|
17
|
+
export type shortCutType = typeof result;
|
|
18
|
+
export default result;
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "starfish-editor-custom",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/starfish-editor.umd.js",
|
|
5
|
+
"style": "dist/style.css",
|
|
6
|
+
"module": "dist/starfish-editor.es.js",
|
|
7
|
+
"types": "dist/types/starfish-editor.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/starfish-editor.es.js"
|
|
11
|
+
},
|
|
12
|
+
"./dist/style.css": {
|
|
13
|
+
"import": "./dist/style.css"
|
|
14
|
+
},
|
|
15
|
+
"./*": "./*"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "vite",
|
|
19
|
+
"build": "vite build"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@babel/core": "^7.18.5",
|
|
23
|
+
"@codemirror/lang-css": "6.0.0",
|
|
24
|
+
"@codemirror/lang-html": "6.1.0",
|
|
25
|
+
"@codemirror/lang-javascript": "6.0.2",
|
|
26
|
+
"@codemirror/lang-json": "6.0.0",
|
|
27
|
+
"clipboard": "^2.0.11",
|
|
28
|
+
"codemirror": "6.0.1",
|
|
29
|
+
"core-js": "^3.6.5",
|
|
30
|
+
"element-plus": "^2.2.12",
|
|
31
|
+
"gesto": "^1.9.0",
|
|
32
|
+
"jsoneditor": "^9.9.0",
|
|
33
|
+
"keycon": "^1.1.2",
|
|
34
|
+
"mitt": "^3.0.0",
|
|
35
|
+
"nanoid": "^4.0.0",
|
|
36
|
+
"starfish-form": "^1.2.9",
|
|
37
|
+
"vue": "^3.2.37",
|
|
38
|
+
"vue-codemirror": "6.1.1",
|
|
39
|
+
"vuedraggable": "^4.1.0",
|
|
40
|
+
"wangeditor": "^4.7.15"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@vitejs/plugin-vue": "^2.3.3",
|
|
44
|
+
"cross-env": "^7.0.3",
|
|
45
|
+
"live-server": "^1.2.2",
|
|
46
|
+
"rollup-plugin-visualizer": "^5.8.3",
|
|
47
|
+
"unplugin-auto-import": "^0.17.5",
|
|
48
|
+
"unplugin-vue-components": "^0.26.0",
|
|
49
|
+
"sass": "^1.42.1",
|
|
50
|
+
"typescript": "^4.3.4",
|
|
51
|
+
"vite": "^2.9.12",
|
|
52
|
+
"vite-plugin-dts": "^1.2.0",
|
|
53
|
+
"vue-tsc": "^0.34.7"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="conditionSelect" :class="result.type">
|
|
3
|
+
<!-- {{ result.type }} -->
|
|
4
|
+
<div class="control" v-show="result.result && result.result.length > 0 && result.type !== 'data'">
|
|
5
|
+
<span class="iconfontui icon-jiahao" v-if="!result.control" @click="handleControl(true)"></span>
|
|
6
|
+
<span class="iconfontui icon-jianhao" v-else @click="handleControl(false)"></span>
|
|
7
|
+
</div>
|
|
8
|
+
<el-select v-model="result.type" placeholder="请选择" @change="onChange">
|
|
9
|
+
<el-option v-for="item in groupSelect" :key="item.value" :label="item.label" :value="item.value"> </el-option>
|
|
10
|
+
</el-select>
|
|
11
|
+
<el-button type="primary" @click="onAddItem" size="small" :disabled="!result.type || result.type == 'data'">增加条件</el-button>
|
|
12
|
+
<el-button type="danger" @click="onDeleteItem" size="small">删除</el-button>
|
|
13
|
+
<el-button type="primary" v-if="result.type == 'data'" @click="onEditData" size="small">编辑</el-button>
|
|
14
|
+
<Transition>
|
|
15
|
+
<div v-show="result.type && result.type !== 'data' && result.control" class="moreCondition">
|
|
16
|
+
<div v-for="(item, index) in result.result" :key="index" class="selectList">
|
|
17
|
+
<ConditionGroup :result="item" @update="handleUpdateForce" @delete="handleDelete" :index="index" :fieldList="fieldList" />
|
|
18
|
+
</div>
|
|
19
|
+
<div class="line" :class="result.type" v-if="result.result && result.result.length >= 2"></div>
|
|
20
|
+
</div>
|
|
21
|
+
</Transition>
|
|
22
|
+
<div v-show="result.type && result.type == 'data'">
|
|
23
|
+
<ConditionTanc ref="ConditionTanc" :data="result.data" :fieldList="fieldList" @end="handleUpdateForce"></ConditionTanc>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
<script>
|
|
28
|
+
import ConditionTanc from "./ConditionTanc.vue";
|
|
29
|
+
export default {
|
|
30
|
+
name: "ConditionGroup",
|
|
31
|
+
components: {
|
|
32
|
+
ConditionTanc,
|
|
33
|
+
},
|
|
34
|
+
props: {
|
|
35
|
+
result: {
|
|
36
|
+
type: Object,
|
|
37
|
+
default() {
|
|
38
|
+
return {};
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
index: {
|
|
42
|
+
type: Number,
|
|
43
|
+
default: 0,
|
|
44
|
+
},
|
|
45
|
+
fieldList: {
|
|
46
|
+
type: Array,
|
|
47
|
+
default() {
|
|
48
|
+
return [];
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
rightField: {
|
|
52
|
+
type: Array,
|
|
53
|
+
default() {
|
|
54
|
+
return [];
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
request: {
|
|
59
|
+
type: Array,
|
|
60
|
+
default() {
|
|
61
|
+
return [];
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
data() {
|
|
66
|
+
return {
|
|
67
|
+
groupSelect: [
|
|
68
|
+
{
|
|
69
|
+
value: "andgroup",
|
|
70
|
+
label: "+并组",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
value: "orgroup",
|
|
74
|
+
label: "+或组",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
value: "data",
|
|
78
|
+
label: "条件",
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
watch: {
|
|
84
|
+
result: {
|
|
85
|
+
handler() {
|
|
86
|
+
this.$forceUpdate();
|
|
87
|
+
},
|
|
88
|
+
deep: true,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
methods: {
|
|
92
|
+
onAddItem() {
|
|
93
|
+
if (!this.result.type) return;
|
|
94
|
+
if (!this.result.result && this.result.type != "data") {
|
|
95
|
+
this.result.result = [];
|
|
96
|
+
}
|
|
97
|
+
if (this.result.type == "data" && !this.result.data) {
|
|
98
|
+
this.result.data = {};
|
|
99
|
+
}
|
|
100
|
+
this.result.control = true;
|
|
101
|
+
|
|
102
|
+
switch (this.result.type) {
|
|
103
|
+
case "orgroup":
|
|
104
|
+
this.result.result.push({ type: "orgroup", result: [] });
|
|
105
|
+
break;
|
|
106
|
+
case "andgroup":
|
|
107
|
+
this.result.result.push({ type: "andgroup", result: [] });
|
|
108
|
+
break;
|
|
109
|
+
case "data":
|
|
110
|
+
this.result.result.push({ type: "data", data: {} });
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
this.handleUpdateForce();
|
|
114
|
+
},
|
|
115
|
+
handleControl(bool) {
|
|
116
|
+
this.result.control = bool;
|
|
117
|
+
this.handleUpdateForce();
|
|
118
|
+
},
|
|
119
|
+
onDeleteItem() {
|
|
120
|
+
if (this.index == 0) {
|
|
121
|
+
delete this.result.data;
|
|
122
|
+
delete this.result.result;
|
|
123
|
+
delete this.result.type;
|
|
124
|
+
this.handleUpdateForce();
|
|
125
|
+
} else {
|
|
126
|
+
this.$emit("delete", this.index);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
handleDelete(index) {
|
|
130
|
+
this.result.result.splice(index, 1);
|
|
131
|
+
this.handleUpdateForce();
|
|
132
|
+
},
|
|
133
|
+
onChange(a) {
|
|
134
|
+
this.result.type = a;
|
|
135
|
+
if (a == "andgroup") {
|
|
136
|
+
this.result.result = [];
|
|
137
|
+
if (this.result.data) {
|
|
138
|
+
delete this.result.data;
|
|
139
|
+
}
|
|
140
|
+
} else if (a == "orgroup") {
|
|
141
|
+
this.result.result = [];
|
|
142
|
+
if (this.result.data) {
|
|
143
|
+
delete this.result.data;
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
this.result.data = {};
|
|
147
|
+
if (this.result.result) {
|
|
148
|
+
delete this.result.result;
|
|
149
|
+
}
|
|
150
|
+
// this.$nextTick(() => {
|
|
151
|
+
// if (this.$refs.ConditionTanc) {
|
|
152
|
+
// this.$refs.ConditionTanc.show();
|
|
153
|
+
// }
|
|
154
|
+
// });
|
|
155
|
+
}
|
|
156
|
+
this.handleUpdateForce();
|
|
157
|
+
},
|
|
158
|
+
handleUpdateForce() {
|
|
159
|
+
this.$forceUpdate();
|
|
160
|
+
this.$emit("update");
|
|
161
|
+
},
|
|
162
|
+
onEditData() {
|
|
163
|
+
this.$refs.ConditionTanc.show(this.result.data);
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
</script>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<CustomDialog ref="maxJsonDialog" dialogclass="conditionModule">
|
|
3
|
+
<el-main style="padding: 0">
|
|
4
|
+
<el-container style="height: 100%">
|
|
5
|
+
<el-main class="my-pageMain">
|
|
6
|
+
<div class="tipContent">满足以下所有条件时,此组件可用</div>
|
|
7
|
+
<div class="conditionContainer">
|
|
8
|
+
<ConditionGroup :result="result" @update="handleUpdateForce" :fieldList="leftField" />
|
|
9
|
+
<!-- :rightField="rightField"
|
|
10
|
+
:request="request" -->
|
|
11
|
+
|
|
12
|
+
<div class="stringlist"><pre v-html="stringLink"></pre></div>
|
|
13
|
+
</div>
|
|
14
|
+
</el-main>
|
|
15
|
+
|
|
16
|
+
<el-footer class="my-Footer" style="height: 60px; padding-top: 10px">
|
|
17
|
+
<el-button type="primary" @click="saveJson">保存</el-button>
|
|
18
|
+
<el-button @click="closeDialog">关闭</el-button>
|
|
19
|
+
</el-footer>
|
|
20
|
+
</el-container>
|
|
21
|
+
</el-main>
|
|
22
|
+
</CustomDialog>
|
|
23
|
+
</template>
|
|
24
|
+
<script>
|
|
25
|
+
import ConditionGroup from "./ConditionGroup.vue";
|
|
26
|
+
import formStore from "@/controller/form";
|
|
27
|
+
import { toRaw } from "vue";
|
|
28
|
+
export default {
|
|
29
|
+
components: {
|
|
30
|
+
ConditionGroup,
|
|
31
|
+
},
|
|
32
|
+
props: {
|
|
33
|
+
data: {
|
|
34
|
+
type: Object,
|
|
35
|
+
default() {
|
|
36
|
+
return {};
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
item: {
|
|
40
|
+
type: Object,
|
|
41
|
+
default() {
|
|
42
|
+
return {};
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
data() {
|
|
47
|
+
return {
|
|
48
|
+
result: {},
|
|
49
|
+
stringLink: "",
|
|
50
|
+
leftField: [],
|
|
51
|
+
rightField: [],
|
|
52
|
+
condition: [],
|
|
53
|
+
request: [],
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
watch: {
|
|
57
|
+
result: {
|
|
58
|
+
handler() {
|
|
59
|
+
console.log(this.result);
|
|
60
|
+
this.$forceUpdate();
|
|
61
|
+
},
|
|
62
|
+
deep: true,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
emits: ["change"],
|
|
66
|
+
methods: {
|
|
67
|
+
async show() {
|
|
68
|
+
this.$refs.maxJsonDialog.init("可用条件", "icon-icon-bianji");
|
|
69
|
+
this.$refs.maxJsonDialog.show();
|
|
70
|
+
await this.$nextTick();
|
|
71
|
+
const allFormList = formStore?.get("allFormList");
|
|
72
|
+
const fieldResult = [];
|
|
73
|
+
toRaw(allFormList)?.forEach((item) => {
|
|
74
|
+
window.VueContext.$Flex.getFormDataList(item, fieldResult, this.data.fieldName);
|
|
75
|
+
});
|
|
76
|
+
this.result = typeof this.data[this.item.data.fieldName] == "string" ? JSON.parse(this.data[this.item.data.fieldName]) : this.data[this.item.data.fieldName];
|
|
77
|
+
console.log(fieldResult);
|
|
78
|
+
this.leftField = fieldResult;
|
|
79
|
+
},
|
|
80
|
+
handleUpdateForce() {
|
|
81
|
+
this.$forceUpdate();
|
|
82
|
+
this.stringLink = this.filterCondition(this.result);
|
|
83
|
+
},
|
|
84
|
+
filterCondition(result) {
|
|
85
|
+
if (result.type == "andgroup" || result.type == "orgroup") {
|
|
86
|
+
const b = result.result.map((item) => this.filterCondition(item)).join(result.type == "andgroup" ? '<span class="and">and</span>' : '<span class="or">or</span>');
|
|
87
|
+
const a = `<span class='kh ${result.type}'>(${b})</span>`;
|
|
88
|
+
return a;
|
|
89
|
+
} else if (result.type == "data") {
|
|
90
|
+
return `<span class='data kh'>${this.getDataConditionRelate(result)}</span>`;
|
|
91
|
+
} else {
|
|
92
|
+
return "";
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
getDataConditionRelate(data) {
|
|
96
|
+
if (Object.keys(data.data).length == 0) return "空";
|
|
97
|
+
const fieldData = data.data;
|
|
98
|
+
const field = fieldData.field;
|
|
99
|
+
let value;
|
|
100
|
+
if (fieldData.type == "选项") {
|
|
101
|
+
const rightField = fieldData.value;
|
|
102
|
+
value = `${JSON.stringify(rightField)}`;
|
|
103
|
+
} else if (fieldData.type == "常量" || fieldData.type == "布尔") {
|
|
104
|
+
value = fieldData.value;
|
|
105
|
+
}
|
|
106
|
+
return `${field} ${fieldData.logic} ${value}`;
|
|
107
|
+
},
|
|
108
|
+
closeDialog() {
|
|
109
|
+
this.$refs.maxJsonDialog.close();
|
|
110
|
+
},
|
|
111
|
+
saveJson() {
|
|
112
|
+
this.$emit("change", this.result);
|
|
113
|
+
// this.data[this.item.data.fieldName] = this.result;
|
|
114
|
+
this.closeDialog();
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
</script>
|