@ibiz-template/vue3-components 0.7.30 → 0.7.31-alpha.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/dist/chart-0UV2FAN6.js +1 -0
- package/dist/index-maJGu4b8.js +4 -0
- package/dist/index.min.css +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/{xlsx-util-sKVlHqdj.js → xlsx-util-OUxT4A8O.js} +1 -1
- package/es/common/index.mjs +2 -0
- package/es/common/pql-editor/components/index.d.ts +1 -0
- package/es/common/pql-editor/components/index.mjs +3 -0
- package/es/common/pql-editor/components/pql-editor-suggestion/pql-editor-suggestion.css +1 -0
- package/es/common/pql-editor/components/pql-editor-suggestion/pql-editor-suggestion.d.ts +28 -0
- package/es/common/pql-editor/components/pql-editor-suggestion/pql-editor-suggestion.mjs +49 -0
- package/es/common/pql-editor/pql-editor.css +1 -0
- package/es/common/pql-editor/pql-editor.d.ts +68 -0
- package/es/common/pql-editor/pql-editor.mjs +606 -0
- package/es/common/pql-editor/pql-editor.module.d.ts +47 -0
- package/es/common/pql-editor/pql-editor.module.mjs +176 -0
- package/es/common/pql-editor/utils/index.d.ts +15 -0
- package/es/common/pql-editor/utils/index.mjs +270 -0
- package/es/control/chart/chart.mjs +32 -19
- package/es/control/dashboard/portlet/portlet-layout/portlet-layout.css +1 -1
- package/es/control/dashboard/portlet/portlet-layout/portlet-layout.d.ts +8 -0
- package/es/control/dashboard/portlet/portlet-layout/portlet-layout.mjs +12 -2
- package/es/control/dashboard/portlet/report-portlet/index.d.ts +1 -0
- package/es/control/dashboard/portlet/report-portlet/report-portlet.d.ts +1 -0
- package/es/control/dashboard/portlet/report-portlet/report-portlet.mjs +10 -2
- package/es/control/grid/grid/grid.mjs +2 -2
- package/es/control/grid/grid-column/grid-field-column/grid-field-column.d.ts +4 -2
- package/es/control/grid/grid-column/grid-field-column/grid-field-column.mjs +32 -2
- package/es/control/grid/grid-column/grid-field-column/index.d.ts +4 -0
- package/es/control/search-bar/filter-tree/filter-tree.css +1 -1
- package/es/control/search-bar/filter-tree/filter-tree.d.ts +30 -3
- package/es/control/search-bar/filter-tree/filter-tree.mjs +83 -9
- package/es/control/search-bar/search-bar.mjs +10 -1
- package/es/editor/array/ibiz-array/ibiz-array.d.ts +1 -1
- package/es/editor/autocomplete/ibiz-autocomplete/ibiz-autocomplete.d.ts +1 -1
- package/es/editor/carousel/ibiz-carousel/ibiz-carousel.d.ts +1 -1
- package/es/editor/cascader/ibiz-cascader/ibiz-cascader.d.ts +1 -1
- package/es/editor/check-box/ibiz-checkbox/ibiz-checkbox.d.ts +1 -1
- package/es/editor/check-box-list/checkbox-list-editor.controller.d.ts +7 -0
- package/es/editor/check-box-list/checkbox-list-editor.controller.mjs +11 -0
- package/es/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.css +1 -1
- package/es/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.d.ts +1 -1
- package/es/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.mjs +2 -1
- package/es/editor/code/monaco-editor/monaco-editor.d.ts +1 -1
- package/es/editor/color-picker/ibiz-color-picker/ibiz-color-picker.d.ts +1 -1
- package/es/editor/data-picker/ibiz-mpicker/ibiz-mpicker.d.ts +1 -1
- package/es/editor/data-picker/ibiz-picker/ibiz-picker.d.ts +1 -1
- package/es/editor/data-picker/ibiz-picker-dropdown/ibiz-picker-dropdown.d.ts +1 -1
- package/es/editor/data-picker/ibiz-picker-embed-view/ibiz-picker-embed-view.d.ts +1 -1
- package/es/editor/data-picker/ibiz-picker-link/ibiz-picker-link.d.ts +1 -1
- package/es/editor/data-picker/ibiz-picker-select-view/ibiz-picker-select-view.d.ts +1 -1
- package/es/editor/date-picker/ibiz-date-picker/ibiz-date-picker.d.ts +1 -1
- package/es/editor/date-range/ibiz-date-range-picker/ibiz-date-range-picker.d.ts +1 -1
- package/es/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.d.ts +1 -1
- package/es/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.mjs +1 -1
- package/es/editor/dropdown-list/ibiz-emoji-picker/ibiz-emoji-picker.d.ts +1 -1
- package/es/editor/html/wang-editor/wang-editor.d.ts +1 -1
- package/es/editor/list-box/ibiz-list-box/ibiz-list-box.d.ts +1 -1
- package/es/editor/number-range/ibiz-number-range-picker/ibiz-number-range-picker.d.ts +1 -1
- package/es/editor/preset/preset-rawitem/ibiz-preset-rawitem/ibiz-preset-rawitem.d.ts +1 -1
- package/es/editor/radio-button-list/ibiz-radio/ibiz-radio.css +1 -1
- package/es/editor/radio-button-list/ibiz-radio/ibiz-radio.d.ts +1 -1
- package/es/editor/radio-button-list/ibiz-radio/ibiz-radio.mjs +2 -1
- package/es/editor/radio-button-list/radio-button-list.controller.d.ts +8 -0
- package/es/editor/radio-button-list/radio-button-list.controller.mjs +23 -0
- package/es/editor/rate/ibiz-rate/ibiz-rate.d.ts +1 -1
- package/es/editor/raw/ibiz-raw/ibiz-raw.d.ts +1 -1
- package/es/editor/slider/ibiz-slider/ibiz-slider.d.ts +1 -1
- package/es/editor/span/span/span.css +1 -1
- package/es/editor/span/span/span.d.ts +1 -1
- package/es/editor/span/span/span.mjs +2 -1
- package/es/editor/span/span-link/span-link.d.ts +1 -1
- package/es/editor/stepper/ibiz-stepper/ibiz-stepper.d.ts +1 -1
- package/es/editor/switch/ibiz-switch/ibiz-switch.d.ts +1 -1
- package/es/editor/text-box/ibiz-input-ip/ibiz-input-ip.d.ts +1 -1
- package/es/editor/text-box/ibiz-input-number/ibiz-input-number.d.ts +1 -1
- package/es/editor/text-box/input/input.d.ts +1 -1
- package/es/editor/upload/ibiz-file-upload/ibiz-file-upload.d.ts +1 -1
- package/es/editor/upload/ibiz-image-preview/ibiz-image-preview.d.ts +1 -1
- package/es/editor/upload/ibiz-image-upload/ibiz-image-upload.d.ts +1 -1
- package/es/editor/user/ibiz-searchcond-edit/ibiz-searchcond-edit.d.ts +1 -1
- package/es/interface/i-pql-item.d.ts +52 -0
- package/es/interface/i-pql-item.mjs +1 -0
- package/es/interface/i-pql-node.d.ts +37 -0
- package/es/interface/i-pql-node.mjs +1 -0
- package/es/interface/i-schema-field.d.ts +51 -0
- package/es/interface/i-schema-field.mjs +1 -0
- package/es/interface/index.d.ts +3 -0
- package/es/interface/index.mjs +5 -0
- package/lib/common/index.cjs +2 -0
- package/lib/common/pql-editor/components/index.cjs +7 -0
- package/lib/common/pql-editor/components/pql-editor-suggestion/pql-editor-suggestion.cjs +51 -0
- package/lib/common/pql-editor/components/pql-editor-suggestion/pql-editor-suggestion.css +1 -0
- package/lib/common/pql-editor/pql-editor.cjs +608 -0
- package/lib/common/pql-editor/pql-editor.css +1 -0
- package/lib/common/pql-editor/pql-editor.module.cjs +182 -0
- package/lib/common/pql-editor/utils/index.cjs +280 -0
- package/lib/control/chart/chart.cjs +31 -18
- package/lib/control/dashboard/portlet/portlet-layout/portlet-layout.cjs +12 -2
- package/lib/control/dashboard/portlet/portlet-layout/portlet-layout.css +1 -1
- package/lib/control/dashboard/portlet/report-portlet/report-portlet.cjs +9 -1
- package/lib/control/grid/grid/grid.cjs +2 -2
- package/lib/control/grid/grid-column/grid-field-column/grid-field-column.cjs +32 -2
- package/lib/control/search-bar/filter-tree/filter-tree.cjs +82 -8
- package/lib/control/search-bar/filter-tree/filter-tree.css +1 -1
- package/lib/control/search-bar/search-bar.cjs +10 -1
- package/lib/editor/check-box-list/checkbox-list-editor.controller.cjs +11 -0
- package/lib/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.cjs +2 -1
- package/lib/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.css +1 -1
- package/lib/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.cjs +1 -1
- package/lib/editor/radio-button-list/ibiz-radio/ibiz-radio.cjs +2 -1
- package/lib/editor/radio-button-list/ibiz-radio/ibiz-radio.css +1 -1
- package/lib/editor/radio-button-list/radio-button-list.controller.cjs +23 -0
- package/lib/editor/span/span/span.cjs +2 -1
- package/lib/editor/span/span/span.css +1 -1
- package/lib/interface/i-pql-item.cjs +3 -0
- package/lib/interface/i-pql-node.cjs +3 -0
- package/lib/interface/i-schema-field.cjs +3 -0
- package/lib/interface/index.cjs +7 -0
- package/package.json +6 -6
- package/dist/chart-J-0VPQfg.js +0 -1
- package/dist/index-5Hb8nfPm.js +0 -4
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
import { ref, createVNode, watch, onMounted, onUnmounted, defineComponent } from 'vue';
|
|
2
|
+
import { useNamespace } from '@ibiz-template/vue3-util';
|
|
3
|
+
import { listenJSEvent } from '@ibiz-template/core';
|
|
4
|
+
import { DomEditor, SlatePath, SlateEditor, Boot, createEditor } from '@wangeditor/editor';
|
|
5
|
+
import { PqlModule } from './pql-editor.module.mjs';
|
|
6
|
+
import './components/index.mjs';
|
|
7
|
+
import { FilterModes, ExcludeOPs, parseCustomCond, pqlItemsToPqlNodes, pqlNodesToHtml, generateItems, generateCustomCond, isMove } from './utils/index.mjs';
|
|
8
|
+
import './pql-editor.css';
|
|
9
|
+
import { IBizPqlEditorSuggestion } from './components/pql-editor-suggestion/pql-editor-suggestion.mjs';
|
|
10
|
+
|
|
11
|
+
"use strict";
|
|
12
|
+
const IBizPqlEditor = /* @__PURE__ */ defineComponent({
|
|
13
|
+
name: "IBizPqlEditor",
|
|
14
|
+
props: {
|
|
15
|
+
fields: {
|
|
16
|
+
type: Array,
|
|
17
|
+
default: () => []
|
|
18
|
+
},
|
|
19
|
+
value: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: ""
|
|
22
|
+
},
|
|
23
|
+
readonly: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false
|
|
26
|
+
},
|
|
27
|
+
placeholder: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: ""
|
|
30
|
+
},
|
|
31
|
+
context: {
|
|
32
|
+
type: Object,
|
|
33
|
+
required: true
|
|
34
|
+
},
|
|
35
|
+
renderItem: {
|
|
36
|
+
type: Function
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
emits: {
|
|
40
|
+
change: (_value) => true
|
|
41
|
+
},
|
|
42
|
+
setup(props, {
|
|
43
|
+
emit
|
|
44
|
+
}) {
|
|
45
|
+
const ns = useNamespace("pql-editor");
|
|
46
|
+
const editorRef = ref();
|
|
47
|
+
let editor;
|
|
48
|
+
let overlayPopover;
|
|
49
|
+
const connectionList = [{
|
|
50
|
+
type: "pql-field-connection",
|
|
51
|
+
label: "and",
|
|
52
|
+
value: "and"
|
|
53
|
+
}, {
|
|
54
|
+
type: "pql-field-connection",
|
|
55
|
+
label: "or",
|
|
56
|
+
value: "or"
|
|
57
|
+
}];
|
|
58
|
+
const getCodeListItems = async (appCodeListId) => {
|
|
59
|
+
if (!props.context) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
const app = ibiz.hub.getApp(props.context.srfappid);
|
|
63
|
+
const items = await app.codeList.get(appCodeListId, props.context);
|
|
64
|
+
return items;
|
|
65
|
+
};
|
|
66
|
+
const getPreviousNode = (node) => {
|
|
67
|
+
var _a;
|
|
68
|
+
if (!editor || !node) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const path = DomEditor.findPath(editor, node);
|
|
72
|
+
if (path && SlatePath.hasPrevious(path)) {
|
|
73
|
+
const slateNode = (_a = SlateEditor.node(editor, SlatePath.previous(path))) == null ? void 0 : _a[0];
|
|
74
|
+
if (slateNode) {
|
|
75
|
+
if (slateNode.type || slateNode.text) {
|
|
76
|
+
return slateNode;
|
|
77
|
+
}
|
|
78
|
+
return getPreviousNode(slateNode);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const getCurrentNode = () => {
|
|
83
|
+
var _a;
|
|
84
|
+
if (!editor) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const selection = editor.selection;
|
|
88
|
+
if (selection) {
|
|
89
|
+
const slateNode = (_a = SlateEditor.node(editor, selection)) == null ? void 0 : _a[0];
|
|
90
|
+
if (slateNode) {
|
|
91
|
+
if (slateNode.type || slateNode.text) {
|
|
92
|
+
return slateNode;
|
|
93
|
+
}
|
|
94
|
+
return getPreviousNode(slateNode);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const getSuggestionItems = async () => {
|
|
99
|
+
var _a, _b, _c, _d, _e;
|
|
100
|
+
if (!editor) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
const currenNode = getCurrentNode();
|
|
104
|
+
const nodes = ((_a = editor.children[0]) == null ? void 0 : _a.children) || [];
|
|
105
|
+
const children = nodes.filter((node) => node.type || node.text);
|
|
106
|
+
if (!currenNode && children.length) {
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
if (editor.selection) {
|
|
110
|
+
const node = SlateEditor.node(editor, editor.selection);
|
|
111
|
+
if (node && ((_b = node[0]) == null ? void 0 : _b.type)) {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (currenNode && currenNode.type === "pql-field") {
|
|
116
|
+
const field = props.fields.find((item) => item.appDEFieldId === currenNode.value);
|
|
117
|
+
if (field && field.valueOPs) {
|
|
118
|
+
return FilterModes.filter((mode) => field.valueOPs.includes(mode.valueOP)).map((item) => {
|
|
119
|
+
return {
|
|
120
|
+
type: "pql-field-operator",
|
|
121
|
+
label: item.label,
|
|
122
|
+
value: item.valueOP
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
if (currenNode && currenNode.type === "pql-field-value") {
|
|
129
|
+
return connectionList;
|
|
130
|
+
}
|
|
131
|
+
if (currenNode && currenNode.type === "pql-field-operator") {
|
|
132
|
+
const mode = FilterModes.find((_mode) => _mode.valueOP === currenNode.value);
|
|
133
|
+
if (mode) {
|
|
134
|
+
if (ExcludeOPs.includes(mode.valueOP)) {
|
|
135
|
+
return connectionList;
|
|
136
|
+
}
|
|
137
|
+
const previousNode = getPreviousNode(currenNode);
|
|
138
|
+
if (previousNode && previousNode.type === "pql-field") {
|
|
139
|
+
const field = props.fields.find((item) => item.appDEFieldId === previousNode.value);
|
|
140
|
+
if (field && field.appCodeListId) {
|
|
141
|
+
const items = await getCodeListItems(field.appCodeListId);
|
|
142
|
+
return items.map((item) => {
|
|
143
|
+
return {
|
|
144
|
+
type: "pql-field-value",
|
|
145
|
+
label: item.text,
|
|
146
|
+
value: item.value
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
if (currenNode && currenNode.type === "pql-field-connection") {
|
|
155
|
+
return props.fields.map((item) => {
|
|
156
|
+
return {
|
|
157
|
+
type: "pql-field",
|
|
158
|
+
label: item.caption,
|
|
159
|
+
value: item.appDEFieldId
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (currenNode && !currenNode.type) {
|
|
164
|
+
const previousNode = getPreviousNode(currenNode);
|
|
165
|
+
if (previousNode && previousNode.type === "pql-field-operator") {
|
|
166
|
+
if (((_c = editor.selection) == null ? void 0 : _c.focus.offset) !== 0) {
|
|
167
|
+
return connectionList;
|
|
168
|
+
}
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
if (previousNode && previousNode.type === "pql-field") {
|
|
172
|
+
if (((_d = editor.selection) == null ? void 0 : _d.focus.offset) !== 0) {
|
|
173
|
+
return connectionList;
|
|
174
|
+
}
|
|
175
|
+
const field = props.fields.find((item) => item.appDEFieldId === previousNode.value);
|
|
176
|
+
if (field && field.valueOPs) {
|
|
177
|
+
return FilterModes.filter((mode) => field.valueOPs.includes(mode.valueOP)).map((item) => {
|
|
178
|
+
return {
|
|
179
|
+
type: "pql-field-operator",
|
|
180
|
+
label: item.label,
|
|
181
|
+
value: item.valueOP
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (previousNode && previousNode.type === "pql-field-connection") {
|
|
187
|
+
if (((_e = editor.selection) == null ? void 0 : _e.focus.offset) !== 0) {
|
|
188
|
+
return connectionList;
|
|
189
|
+
}
|
|
190
|
+
return props.fields.map((item) => {
|
|
191
|
+
return {
|
|
192
|
+
type: "pql-field",
|
|
193
|
+
label: item.caption,
|
|
194
|
+
value: item.appDEFieldId
|
|
195
|
+
};
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
if (previousNode && previousNode.type === "pql-field-value") {
|
|
199
|
+
return connectionList;
|
|
200
|
+
}
|
|
201
|
+
return [];
|
|
202
|
+
}
|
|
203
|
+
return props.fields.map((item) => {
|
|
204
|
+
return {
|
|
205
|
+
type: "pql-field",
|
|
206
|
+
label: item.caption,
|
|
207
|
+
value: item.appDEFieldId
|
|
208
|
+
};
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
const handelSuggestionSelect = (item) => {
|
|
212
|
+
if (!editor) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
editor.restoreSelection();
|
|
216
|
+
if (!item.type) {
|
|
217
|
+
editor.insertText(item.label);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const node = {
|
|
221
|
+
type: item.type,
|
|
222
|
+
label: item.label,
|
|
223
|
+
value: item.value,
|
|
224
|
+
children: [{
|
|
225
|
+
text: ""
|
|
226
|
+
}]
|
|
227
|
+
};
|
|
228
|
+
editor.insertNode(node);
|
|
229
|
+
editor.move(1);
|
|
230
|
+
};
|
|
231
|
+
const showSuggestion = async () => {
|
|
232
|
+
if (!editor) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const popover = overlayPopover;
|
|
236
|
+
overlayPopover = void 0;
|
|
237
|
+
await (popover == null ? void 0 : popover.dismiss());
|
|
238
|
+
const selection = window.getSelection();
|
|
239
|
+
if (!selection) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const {
|
|
243
|
+
focusNode
|
|
244
|
+
} = selection;
|
|
245
|
+
if (!focusNode || !focusNode.parentNode) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const items = await getSuggestionItems();
|
|
249
|
+
if (!items || !items.length) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
overlayPopover = ibiz.overlay.createPopover(() => {
|
|
253
|
+
return createVNode(IBizPqlEditorSuggestion, {
|
|
254
|
+
"items": items,
|
|
255
|
+
"renderItem": props.renderItem,
|
|
256
|
+
"onSelect": handelSuggestionSelect
|
|
257
|
+
}, null);
|
|
258
|
+
}, void 0, {
|
|
259
|
+
placement: "bottom-start",
|
|
260
|
+
autoClose: true,
|
|
261
|
+
width: "200px",
|
|
262
|
+
noArrow: true
|
|
263
|
+
});
|
|
264
|
+
await overlayPopover.present(focusNode.parentNode);
|
|
265
|
+
await overlayPopover.onWillDismiss();
|
|
266
|
+
overlayPopover = void 0;
|
|
267
|
+
};
|
|
268
|
+
const errorMsg = ref();
|
|
269
|
+
const errorMsgEl = ref();
|
|
270
|
+
const verifyNode = () => {
|
|
271
|
+
var _a;
|
|
272
|
+
if (!editor) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const nodes = ((_a = editor.children[0]) == null ? void 0 : _a.children) || [];
|
|
276
|
+
const children = nodes.filter((node) => node.type || node.text);
|
|
277
|
+
if (!children.length) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
let last = {
|
|
281
|
+
type: "pql-field-connection"
|
|
282
|
+
};
|
|
283
|
+
for (let i = 0; i < children.length; i++) {
|
|
284
|
+
const child = children[i];
|
|
285
|
+
if (last.type === "pql-field-connection") {
|
|
286
|
+
if (child.type === "pql-field") {
|
|
287
|
+
last = child;
|
|
288
|
+
} else if (child.type === "pql-field-operator") {
|
|
289
|
+
return {
|
|
290
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u5DE6\u503C\u3002",
|
|
291
|
+
child
|
|
292
|
+
};
|
|
293
|
+
} else if (child.type === "pql-field-value" || child.text) {
|
|
294
|
+
return {
|
|
295
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u5DE6\u503C\u3002",
|
|
296
|
+
child
|
|
297
|
+
};
|
|
298
|
+
} else if (child.type === "pql-field-connection") {
|
|
299
|
+
return {
|
|
300
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8FDE\u63A5\u7B26\u7F3A\u5931\u8868\u8FBE\u5F0F",
|
|
301
|
+
child
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
} else if (last.type === "pql-field") {
|
|
305
|
+
if (child.type === "pql-field") {
|
|
306
|
+
return {
|
|
307
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u64CD\u4F5C\u7B26\u3002",
|
|
308
|
+
child: children[i - 1] || child
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
if (child.type === "pql-field-operator") {
|
|
312
|
+
last = child;
|
|
313
|
+
} else if (child.type === "pql-field-value" || child.text) {
|
|
314
|
+
return {
|
|
315
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u64CD\u4F5C\u7B26\u3002",
|
|
316
|
+
child
|
|
317
|
+
};
|
|
318
|
+
} else if (child.type === "pql-field-connection") {
|
|
319
|
+
return {
|
|
320
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u64CD\u4F5C\u7B26\u3002",
|
|
321
|
+
child: children[i - 1] || child
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
} else if (last.type === "pql-field-operator") {
|
|
325
|
+
if (last.value && ExcludeOPs.includes(last.value)) {
|
|
326
|
+
if (child.type === "pql-field") {
|
|
327
|
+
return {
|
|
328
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u8FDE\u63A5\u7B26\u3002",
|
|
329
|
+
child
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
if (child.type === "pql-field-operator") {
|
|
333
|
+
return {
|
|
334
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u8FDE\u63A5\u7B26\u3002",
|
|
335
|
+
child
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
if (child.type === "pql-field-value" || child.text) {
|
|
339
|
+
return {
|
|
340
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u8FDE\u63A5\u7B26\u3002",
|
|
341
|
+
child
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
if (child.type === "pql-field-connection") {
|
|
345
|
+
last = child;
|
|
346
|
+
}
|
|
347
|
+
} else if (child.type === "pql-field") {
|
|
348
|
+
return {
|
|
349
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u53F3\u503C\u3002",
|
|
350
|
+
child: children[i - 1] || child
|
|
351
|
+
};
|
|
352
|
+
} else if (child.type === "pql-field-operator") {
|
|
353
|
+
return {
|
|
354
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u53F3\u503C\u3002",
|
|
355
|
+
child: children[i - 1] || child
|
|
356
|
+
};
|
|
357
|
+
} else if (child.type === "pql-field-value" || child.text) {
|
|
358
|
+
last = child;
|
|
359
|
+
} else if (child.type === "pql-field-connection") {
|
|
360
|
+
return {
|
|
361
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u53F3\u503C\u3002",
|
|
362
|
+
child: children[i - 1] || child
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
} else if (last.type === "pql-field-value" || last.text) {
|
|
366
|
+
if (child.type === "pql-field") {
|
|
367
|
+
return {
|
|
368
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u8FDE\u63A5\u7B26\u3002",
|
|
369
|
+
child
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
if (child.type === "pql-field-operator") {
|
|
373
|
+
return {
|
|
374
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u8FDE\u63A5\u7B26\u3002",
|
|
375
|
+
child
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
if (child.type === "pql-field-value" || child.text) {
|
|
379
|
+
return {
|
|
380
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u8FDE\u63A5\u7B26\u3002",
|
|
381
|
+
child
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
if (child.type === "pql-field-connection") {
|
|
385
|
+
last = child;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
if (last.type !== "pql-field-value" || !last.text) {
|
|
390
|
+
if (last.type === "pql-field") {
|
|
391
|
+
return {
|
|
392
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u64CD\u4F5C\u7B26\u3002",
|
|
393
|
+
child: children[children.length - 1]
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
if (last.type === "pql-field-operator") {
|
|
397
|
+
if (last.value && ExcludeOPs.includes(last.value)) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
return {
|
|
401
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u53F3\u503C\u3002",
|
|
402
|
+
child: children[children.length - 1]
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
if (last.type === "pql-field-connection") {
|
|
406
|
+
return {
|
|
407
|
+
msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8FDE\u63A5\u7B26\u7F3A\u5931\u8868\u8FBE\u5F0F\u3002",
|
|
408
|
+
child: children[children.length - 1]
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
const verify = () => {
|
|
414
|
+
if (errorMsg.value) {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
return true;
|
|
418
|
+
};
|
|
419
|
+
const currentValue = ref("");
|
|
420
|
+
const htmlText = ref("");
|
|
421
|
+
watch(() => props.value, async () => {
|
|
422
|
+
if (props.value === currentValue.value) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
if (!props.value) {
|
|
426
|
+
currentValue.value = "";
|
|
427
|
+
htmlText.value = "";
|
|
428
|
+
editor == null ? void 0 : editor.clear();
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
const pqlItems = parseCustomCond(props.value);
|
|
432
|
+
if (pqlItems) {
|
|
433
|
+
const nodes = await pqlItemsToPqlNodes(pqlItems, props.fields, getCodeListItems);
|
|
434
|
+
if (nodes && nodes.length) {
|
|
435
|
+
const html = pqlNodesToHtml(nodes);
|
|
436
|
+
currentValue.value = props.value;
|
|
437
|
+
htmlText.value = html;
|
|
438
|
+
editor == null ? void 0 : editor.setHtml(html);
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
currentValue.value = "";
|
|
443
|
+
htmlText.value = "";
|
|
444
|
+
editor == null ? void 0 : editor.clear();
|
|
445
|
+
}, {
|
|
446
|
+
immediate: true
|
|
447
|
+
});
|
|
448
|
+
watch(() => props.fields, async () => {
|
|
449
|
+
if (!props.value) {
|
|
450
|
+
currentValue.value = "";
|
|
451
|
+
htmlText.value = "";
|
|
452
|
+
editor == null ? void 0 : editor.clear();
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
const pqlItems = parseCustomCond(props.value);
|
|
456
|
+
if (pqlItems) {
|
|
457
|
+
const nodes = await pqlItemsToPqlNodes(pqlItems, props.fields, getCodeListItems);
|
|
458
|
+
if (nodes && nodes.length) {
|
|
459
|
+
const html = pqlNodesToHtml(nodes);
|
|
460
|
+
currentValue.value = props.value;
|
|
461
|
+
htmlText.value = html;
|
|
462
|
+
editor == null ? void 0 : editor.setHtml(html);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
currentValue.value = "";
|
|
467
|
+
htmlText.value = "";
|
|
468
|
+
editor == null ? void 0 : editor.clear();
|
|
469
|
+
}, {
|
|
470
|
+
immediate: true
|
|
471
|
+
});
|
|
472
|
+
const handleChange = () => {
|
|
473
|
+
var _a;
|
|
474
|
+
if (!editor) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
const nodes = ((_a = editor.children[0]) == null ? void 0 : _a.children) || [];
|
|
478
|
+
const children = nodes.filter((node) => node.type || node.text);
|
|
479
|
+
setTimeout(() => {
|
|
480
|
+
var _a2;
|
|
481
|
+
if (!editor) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const {
|
|
485
|
+
msg,
|
|
486
|
+
child
|
|
487
|
+
} = verifyNode() || {};
|
|
488
|
+
errorMsg.value = msg || "";
|
|
489
|
+
(_a2 = errorMsgEl.value) == null ? void 0 : _a2.classList.remove(ns.b("error-msg"));
|
|
490
|
+
if (child) {
|
|
491
|
+
const el = editor.toDOMNode(child);
|
|
492
|
+
if (el) {
|
|
493
|
+
errorMsgEl.value = el;
|
|
494
|
+
el.classList.add(ns.b("error-msg"));
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
if (!msg) {
|
|
498
|
+
try {
|
|
499
|
+
const items = generateItems(children);
|
|
500
|
+
const customCond = generateCustomCond(items, props.fields);
|
|
501
|
+
currentValue.value = customCond;
|
|
502
|
+
emit("change", customCond);
|
|
503
|
+
} catch (err) {
|
|
504
|
+
ibiz.log.error(err == null ? void 0 : err.message);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}, 10);
|
|
508
|
+
};
|
|
509
|
+
let cleanupKeydown = () => {
|
|
510
|
+
};
|
|
511
|
+
let cleanupClick = () => {
|
|
512
|
+
};
|
|
513
|
+
onMounted(() => {
|
|
514
|
+
if (!editorRef.value) {
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
if (!window.PqlModule) {
|
|
518
|
+
Boot.registerModule(PqlModule);
|
|
519
|
+
window.PqlModule = true;
|
|
520
|
+
}
|
|
521
|
+
const editorConfig = {
|
|
522
|
+
autoFocus: false,
|
|
523
|
+
readOnly: props.readonly,
|
|
524
|
+
placeholder: props.placeholder,
|
|
525
|
+
EXTEND_CONF: {
|
|
526
|
+
pql: {
|
|
527
|
+
showSuggestion
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
onFocus: () => {
|
|
531
|
+
setTimeout(() => {
|
|
532
|
+
showSuggestion();
|
|
533
|
+
}, 10);
|
|
534
|
+
},
|
|
535
|
+
onChange: handleChange
|
|
536
|
+
};
|
|
537
|
+
editor = createEditor({
|
|
538
|
+
selector: editorRef.value,
|
|
539
|
+
config: editorConfig,
|
|
540
|
+
mode: "simple"
|
|
541
|
+
});
|
|
542
|
+
editor.setHtml(htmlText.value);
|
|
543
|
+
cleanupKeydown = listenJSEvent(editorRef.value, "keydown", (event) => {
|
|
544
|
+
setTimeout(() => {
|
|
545
|
+
if ((event.key === "ArrowLeft" || event.key === "ArrowRight") && editor) {
|
|
546
|
+
const {
|
|
547
|
+
selection
|
|
548
|
+
} = editor;
|
|
549
|
+
if (selection && selection.focus.offset === 0) {
|
|
550
|
+
const node = SlateEditor.node(editor, selection)[0];
|
|
551
|
+
if (node) {
|
|
552
|
+
const el = editor.toDOMNode(node);
|
|
553
|
+
if (isMove(el)) {
|
|
554
|
+
if (event.key === "ArrowLeft") {
|
|
555
|
+
editor.moveReverse(1);
|
|
556
|
+
}
|
|
557
|
+
if (event.key === "ArrowRight") {
|
|
558
|
+
editor.move(1);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
setTimeout(() => {
|
|
564
|
+
showSuggestion();
|
|
565
|
+
}, 10);
|
|
566
|
+
}
|
|
567
|
+
}, 10);
|
|
568
|
+
if (event.key === "Escape") {
|
|
569
|
+
event.stopPropagation();
|
|
570
|
+
overlayPopover == null ? void 0 : overlayPopover.dismiss();
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
if (!props.readonly) {
|
|
574
|
+
cleanupClick = listenJSEvent(editorRef.value, "click", () => {
|
|
575
|
+
setTimeout(() => {
|
|
576
|
+
showSuggestion();
|
|
577
|
+
}, 10);
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
onUnmounted(() => {
|
|
582
|
+
cleanupKeydown();
|
|
583
|
+
cleanupClick();
|
|
584
|
+
overlayPopover == null ? void 0 : overlayPopover.dismiss();
|
|
585
|
+
});
|
|
586
|
+
return {
|
|
587
|
+
ns,
|
|
588
|
+
editorRef,
|
|
589
|
+
editor,
|
|
590
|
+
errorMsg,
|
|
591
|
+
verify
|
|
592
|
+
};
|
|
593
|
+
},
|
|
594
|
+
render() {
|
|
595
|
+
return createVNode("div", {
|
|
596
|
+
"class": this.ns.b()
|
|
597
|
+
}, [createVNode("div", {
|
|
598
|
+
"ref": "editorRef",
|
|
599
|
+
"class": this.ns.b("content")
|
|
600
|
+
}, null), createVNode("div", {
|
|
601
|
+
"class": this.ns.b("footer")
|
|
602
|
+
}, [this.errorMsg])]);
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
export { IBizPqlEditor };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IDomEditor, IModuleConf, SlateElement } from '@wangeditor/editor';
|
|
2
|
+
import { VNode } from 'snabbdom';
|
|
3
|
+
/**
|
|
4
|
+
* PQL插件
|
|
5
|
+
*
|
|
6
|
+
* @author zhanghengfeng
|
|
7
|
+
* @date 2024-06-28 20:06:39
|
|
8
|
+
* @export
|
|
9
|
+
* @template T
|
|
10
|
+
* @param {T} editor
|
|
11
|
+
* @return {*}
|
|
12
|
+
*/
|
|
13
|
+
export declare function withPqlPlugin<T extends IDomEditor>(editor: T): T;
|
|
14
|
+
/**
|
|
15
|
+
* 渲染PQL元素
|
|
16
|
+
*
|
|
17
|
+
* @author zhanghengfeng
|
|
18
|
+
* @date 2024-06-28 20:06:14
|
|
19
|
+
* @export
|
|
20
|
+
* @param {IData} el
|
|
21
|
+
* @return {*} {VNode}
|
|
22
|
+
*/
|
|
23
|
+
export declare function renderPqlElement(el: IData): VNode;
|
|
24
|
+
/**
|
|
25
|
+
* 转换PQL元素为html
|
|
26
|
+
*
|
|
27
|
+
* @author zhanghengfeng
|
|
28
|
+
* @date 2024-06-28 20:06:38
|
|
29
|
+
* @param {IData} el
|
|
30
|
+
* @return {*} {string}
|
|
31
|
+
*/
|
|
32
|
+
export declare function pqlToHtml(el: IData): string;
|
|
33
|
+
/**
|
|
34
|
+
* 转换html为PQL元素
|
|
35
|
+
*
|
|
36
|
+
* @author zhanghengfeng
|
|
37
|
+
* @date 2024-06-28 20:06:32
|
|
38
|
+
* @export
|
|
39
|
+
* @param {Element} domElem
|
|
40
|
+
* @return {*} {SlateElement}
|
|
41
|
+
*/
|
|
42
|
+
export declare function parsePqlHtml(domElem: Element): SlateElement;
|
|
43
|
+
/**
|
|
44
|
+
* PQL模块
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
export declare const PqlModule: Partial<IModuleConf>;
|