cloud-web-corejs 1.0.163 → 1.0.165
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/package.json +2 -1
- package/src/components/vb-tabs/x-tabs.vue +30 -13
- package/src/components/xform/form-designer/designer.js +1 -1
- package/src/components/xform/form-designer/form-widget/components/gantt/index.vue +419 -0
- package/src/components/xform/form-designer/form-widget/container-widget/data-table-mixin.js +1 -1
- package/src/components/xform/form-designer/form-widget/dialog/baseFormulaDialog copy.vue +971 -0
- package/src/components/xform/form-designer/form-widget/dialog/baseFormulaDialog.vue +971 -0
- package/src/components/xform/form-designer/form-widget/dialog/formDialog.vue +71 -50
- package/src/components/xform/form-designer/form-widget/dialog/formulaDialog.vue +799 -0
- package/src/components/xform/form-designer/form-widget/dialog/importDialogMixin - /345/211/257/346/234/254.js" +1639 -0
- package/src/components/xform/form-designer/form-widget/dialog/searchFormDialog.vue +102 -73
- package/src/components/xform/form-designer/form-widget/field-widget/cascader-widget.vue +19 -1
- package/src/components/xform/form-designer/form-widget/field-widget/census-widget.vue +41 -27
- package/src/components/xform/form-designer/form-widget/field-widget/checkbox-widget.vue +4 -1
- package/src/components/xform/form-designer/form-widget/field-widget/color-widget.vue +4 -1
- package/src/components/xform/form-designer/form-widget/field-widget/date-range-widget.vue +13 -2
- package/src/components/xform/form-designer/form-widget/field-widget/date-widget.vue +9 -2
- package/src/components/xform/form-designer/form-widget/field-widget/download-button-widget.vue +133 -0
- package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +2 -1
- package/src/components/xform/form-designer/form-widget/field-widget/gantt-widget.vue +962 -0
- package/src/components/xform/form-designer/form-widget/field-widget/input-widget.vue +7 -2
- package/src/components/xform/form-designer/form-widget/field-widget/multiSearch-widget.vue +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/number-widget.vue +7 -0
- package/src/components/xform/form-designer/form-widget/field-widget/oplog-widget.vue +1 -0
- package/src/components/xform/form-designer/form-widget/field-widget/print-button-widget.vue +44 -27
- package/src/components/xform/form-designer/form-widget/field-widget/print-detail-button-widget.vue +19 -11
- package/src/components/xform/form-designer/form-widget/field-widget/project-tag-widget.vue +19 -1
- package/src/components/xform/form-designer/form-widget/field-widget/radio-widget.vue +11 -7
- package/src/components/xform/form-designer/form-widget/field-widget/select-widget.vue +11 -8
- package/src/components/xform/form-designer/form-widget/field-widget/singerSearch-widget.vue +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/table-export-button-widget.vue +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/vabSearch-widget.vue +1 -1
- package/src/components/xform/form-designer/setting-panel/form-setting.vue +106 -76
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/data-table-editor.vue +13 -263
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/table-column-dialog.vue +47 -81
- package/src/components/xform/form-designer/setting-panel/property-editor/downloadButtonFlag-editor.vue +32 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/event-handler/onClick-editor.vue +14 -7
- package/src/components/xform/form-designer/setting-panel/property-editor/field-gantt/gantt-editor.vue +36 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/field-print-button/print-button-editor.vue +37 -16
- package/src/components/xform/form-designer/setting-panel/property-editor/field-print-button/print-detail-button-editor.vue +42 -18
- package/src/components/xform/form-designer/setting-panel/property-editor/field-vabUpload/field-vabUpload-editor.vue +2 -2
- package/src/components/xform/form-designer/setting-panel/property-editor/formScriptEnabled-editor.vue +57 -34
- package/src/components/xform/form-designer/setting-panel/property-editor/project-tag-editor.vue +84 -53
- package/src/components/xform/form-designer/setting-panel/property-editor/wfFlag-editor.vue +35 -44
- package/src/components/xform/form-designer/setting-panel/propertyRegister.js +2 -0
- package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +68 -3
- package/src/components/xform/form-render/container-item/containerItemMixin.js +2 -2
- package/src/components/xform/form-render/container-item/data-table-mixin.js +1 -1
- package/src/components/xform/form-render/container-item/tab-item.vue +64 -32
- package/src/components/xform/form-render/index.vue +69 -23
- package/src/components/xform/form-render/indexMixin.js +18 -17
- package/src/components/xform/lang/zh-CN.js +8 -2
- package/src/components/xform/utils/formula-util.js +306 -5
- package/src/components/xform/utils/util.js +1 -1
- package/src/components/xform/utils/vue2js-generator.js +2 -2
- package/src/utils/request.js +1 -1
- package/src/utils/vab.js +1 -1
- package/src/views/bd/setting/config_manage/list.vue +7 -0
- package/src/views/user/area/dialog.vue +223 -116
- package/src/views/user/area/list.vue +318 -0
- package/src/views/user/form/vform/render.vue +54 -36
- package/src/views/user/form/view/list.vue +103 -10
- package/src/views/user/menu/list.vue +24 -1
- package/src/views/user/role/authConfig.vue +89 -0
- package/src/views/user/role/dialog.vue +70 -48
- package/src/views/user/role/edit.vue +114 -4
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-dialog
|
|
3
|
+
:visible.sync="formulaDialogVisible"
|
|
4
|
+
:title="i18nt('designer.hint.formulaSetting')"
|
|
5
|
+
custom-class="dialog-style list-dialog"
|
|
6
|
+
:close-on-click-modal="false"
|
|
7
|
+
:close-on-press-escape="false"
|
|
8
|
+
:destroy-on-close="true"
|
|
9
|
+
:append-to-body="true"
|
|
10
|
+
width="70%"
|
|
11
|
+
top="0px"
|
|
12
|
+
ref="colFormulaDialog"
|
|
13
|
+
@close="dialogClose"
|
|
14
|
+
>
|
|
15
|
+
<div class="cont">
|
|
16
|
+
<el-row>
|
|
17
|
+
<el-col :span="24">
|
|
18
|
+
<div class="editor">
|
|
19
|
+
<div class="editor-top">
|
|
20
|
+
<el-row>
|
|
21
|
+
<el-col :span="22">
|
|
22
|
+
<div style="font-weight: bold">value =</div>
|
|
23
|
+
</el-col>
|
|
24
|
+
<!-- el-tag 模式 按钮 end -->
|
|
25
|
+
<el-col :span="2">
|
|
26
|
+
<el-button size="small" @click="clearFormula" type="danger" plain>
|
|
27
|
+
{{ i18nt("designer.hint.formulaClear") }}
|
|
28
|
+
</el-button>
|
|
29
|
+
</el-col>
|
|
30
|
+
</el-row>
|
|
31
|
+
<div ref="cmRef" style="height: 83px; width: 100%"></div>
|
|
32
|
+
</div>
|
|
33
|
+
<!-- -->
|
|
34
|
+
<div class="editor-bottom">
|
|
35
|
+
<el-button
|
|
36
|
+
v-on:click="insertSymbol(item)"
|
|
37
|
+
size="default"
|
|
38
|
+
v-for="(item, idx) in operate"
|
|
39
|
+
:key="idx"
|
|
40
|
+
>
|
|
41
|
+
{{ item }}
|
|
42
|
+
</el-button>
|
|
43
|
+
</div>
|
|
44
|
+
<!-- -->
|
|
45
|
+
</div>
|
|
46
|
+
</el-col>
|
|
47
|
+
</el-row>
|
|
48
|
+
<el-row style="margin: 10px">
|
|
49
|
+
<el-col :span="6">
|
|
50
|
+
<div class="group-item-left">
|
|
51
|
+
<div class="item-header">
|
|
52
|
+
{{ i18nt("designer.hint.formulaWidgetList") }}
|
|
53
|
+
</div>
|
|
54
|
+
<el-input
|
|
55
|
+
:placeholder="i18nt('designer.hint.formulaSearch')"
|
|
56
|
+
v-model="filterText"
|
|
57
|
+
clearable
|
|
58
|
+
></el-input>
|
|
59
|
+
<div class="item-body-left">
|
|
60
|
+
<el-tree
|
|
61
|
+
ref="fieldTree"
|
|
62
|
+
:data="fieldTreeData"
|
|
63
|
+
:filter-node-method="filterNode"
|
|
64
|
+
@node-click="insertField"
|
|
65
|
+
>
|
|
66
|
+
<template #default="{ node, data }">
|
|
67
|
+
<span class="custom-tree-node">
|
|
68
|
+
<el-tooltip effect="dark" :content="node.label" placement="right">
|
|
69
|
+
<span>{{ node.label }}</span>
|
|
70
|
+
</el-tooltip>
|
|
71
|
+
</span>
|
|
72
|
+
</template>
|
|
73
|
+
</el-tree>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</el-col>
|
|
77
|
+
<el-col :span="6">
|
|
78
|
+
<el-row>
|
|
79
|
+
<el-col :span="24">
|
|
80
|
+
<div class="group-item-right-top">
|
|
81
|
+
<div class="item-header">
|
|
82
|
+
{{ i18nt("designer.hint.formulaFunctionList") }}
|
|
83
|
+
</div>
|
|
84
|
+
<div class="function-list">
|
|
85
|
+
<el-collapse v-model="funcActiveCollapseNames">
|
|
86
|
+
<template v-for="(item, index) in funcList">
|
|
87
|
+
<el-collapse-item
|
|
88
|
+
:key="index"
|
|
89
|
+
:title="i18nt(item.fClass)"
|
|
90
|
+
:name="index"
|
|
91
|
+
v-if="index < 2"
|
|
92
|
+
>
|
|
93
|
+
<div
|
|
94
|
+
v-for="(info, i) in item.flist"
|
|
95
|
+
:key="i"
|
|
96
|
+
class="field-item"
|
|
97
|
+
@click="insertFunction(info.fName + '(')"
|
|
98
|
+
@mouseenter="
|
|
99
|
+
showIntro(
|
|
100
|
+
i18nt(info.fName),
|
|
101
|
+
i18nt(item.fClass),
|
|
102
|
+
i18nt(info.fIntro)
|
|
103
|
+
)
|
|
104
|
+
"
|
|
105
|
+
v-on:mouseleave="resetIntro"
|
|
106
|
+
>
|
|
107
|
+
<span>{{ info.fName }}</span>
|
|
108
|
+
<el-tag :type="getClass(info.fType)"
|
|
109
|
+
>{{ i18nt(info.fType) }}
|
|
110
|
+
</el-tag>
|
|
111
|
+
</div>
|
|
112
|
+
</el-collapse-item>
|
|
113
|
+
</template>
|
|
114
|
+
</el-collapse>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
</el-col>
|
|
118
|
+
</el-row>
|
|
119
|
+
</el-col>
|
|
120
|
+
<el-col :span="12">
|
|
121
|
+
<div class="group-item-right-bottom">
|
|
122
|
+
<div class="item-header">{{ introTitle }}</div>
|
|
123
|
+
<div class="item-body-right-bottom">
|
|
124
|
+
<ul>
|
|
125
|
+
<li
|
|
126
|
+
v-if="introduction.title !== ''"
|
|
127
|
+
style="font-size: 16px; color: #0a5d7c"
|
|
128
|
+
>
|
|
129
|
+
{{ introduction.title }}
|
|
130
|
+
</li>
|
|
131
|
+
<li>
|
|
132
|
+
<div class="intro-content" v-html="introduction.content"></div>
|
|
133
|
+
</li>
|
|
134
|
+
</ul>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</el-col>
|
|
138
|
+
</el-row>
|
|
139
|
+
</div>
|
|
140
|
+
<div class="dialog-footer" slot="footer">
|
|
141
|
+
<el-button
|
|
142
|
+
@click="formulaDialogVisible = false"
|
|
143
|
+
class="button-sty"
|
|
144
|
+
icon="el-icon-close"
|
|
145
|
+
>
|
|
146
|
+
{{ i18nt("designer.hint.cancel") }}
|
|
147
|
+
</el-button>
|
|
148
|
+
<el-button
|
|
149
|
+
type="primary"
|
|
150
|
+
@click="saveFormula"
|
|
151
|
+
class="button-sty"
|
|
152
|
+
icon="el-icon-check"
|
|
153
|
+
>
|
|
154
|
+
{{ i18nt("designer.hint.confirm") }}
|
|
155
|
+
</el-button>
|
|
156
|
+
</div>
|
|
157
|
+
</el-dialog>
|
|
158
|
+
</template>
|
|
159
|
+
|
|
160
|
+
<script>
|
|
161
|
+
import { basicSetup, EditorView } from "codemirror";
|
|
162
|
+
import { javascript } from "@codemirror/lang-javascript";
|
|
163
|
+
import { EditorState } from "@codemirror/state";
|
|
164
|
+
import i18n from "@base/components/xform/utils/i18n";
|
|
165
|
+
import {
|
|
166
|
+
deepClone,
|
|
167
|
+
getAllContainerWidgets,
|
|
168
|
+
getAllFieldWidgets,
|
|
169
|
+
getFieldWidgetById,
|
|
170
|
+
traverseFieldWidgetsOfContainer,
|
|
171
|
+
loopHandleWidget,
|
|
172
|
+
} from "@base/components/xform/utils/util";
|
|
173
|
+
import {
|
|
174
|
+
placeholders,
|
|
175
|
+
baseTheme,
|
|
176
|
+
formulas,
|
|
177
|
+
FORMULA_REG_EXP,
|
|
178
|
+
} from "@base/components/xform/utils/formula-util";
|
|
179
|
+
|
|
180
|
+
export default {
|
|
181
|
+
name: "formula-editor",
|
|
182
|
+
mixins: [i18n],
|
|
183
|
+
components: {},
|
|
184
|
+
props: {
|
|
185
|
+
option: Object,
|
|
186
|
+
},
|
|
187
|
+
computed: {
|
|
188
|
+
formulaForView() {
|
|
189
|
+
const matchResult = this.formula.match(FORMULA_REG_EXP);
|
|
190
|
+
if (!matchResult) {
|
|
191
|
+
return this.formula;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
let resultFormula = this.formula;
|
|
195
|
+
matchResult.forEach((mi) => {
|
|
196
|
+
const secondPart = mi.split(".")[1];
|
|
197
|
+
resultFormula = resultFormula.replaceAll(mi, secondPart);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
return resultFormula;
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
watch: {
|
|
204
|
+
filterText(val) {
|
|
205
|
+
this.$refs.fieldTree.filter(val);
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
data() {
|
|
209
|
+
return {
|
|
210
|
+
codeMirror: null,
|
|
211
|
+
formula: "",
|
|
212
|
+
tags: [], // 公式页签集合
|
|
213
|
+
fieldTreeData: [], // 设计器字段树
|
|
214
|
+
filterText: "",
|
|
215
|
+
formulaDialogVisible: true,
|
|
216
|
+
operate: ["+", "-", "*", "/", "!=", "==", "<", ">", "<=", ">=", "(", ")", ","],
|
|
217
|
+
insertNum: 0,
|
|
218
|
+
insertStr: "",
|
|
219
|
+
activeNames: ["1"],
|
|
220
|
+
widgetSizes: [
|
|
221
|
+
{
|
|
222
|
+
label: this.i18nt("designer.hint.formulaSizeLarge"),
|
|
223
|
+
value: "large",
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
label: this.i18nt("designer.hint.formulaSizeMedium"),
|
|
227
|
+
value: "default",
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
label: this.i18nt("designer.hint.formulaSizeSmall"),
|
|
231
|
+
value: "small",
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
label: this.i18nt("designer.hint.formulaSizeMini"),
|
|
235
|
+
value: "small",
|
|
236
|
+
},
|
|
237
|
+
],
|
|
238
|
+
introTitle: this.i18nt("designer.hint.formulaFunctionExplain"),
|
|
239
|
+
introduction: {
|
|
240
|
+
title: this.i18nt("designer.hint.formulaPleaseSelect"),
|
|
241
|
+
content:
|
|
242
|
+
'<span class="cg">' +
|
|
243
|
+
this.i18nt("designer.hint.formulaSample") +
|
|
244
|
+
':</span><span class="fname">SUM</span><span class="cg">(</span><span class="cs">' +
|
|
245
|
+
this.i18nt("designer.hint.formulaPara") +
|
|
246
|
+
'1</span><span class="cg">,</span><span class="cs">' +
|
|
247
|
+
this.i18nt("designer.hint.formulaPara") +
|
|
248
|
+
'2</span><span class="cg">)</span>',
|
|
249
|
+
},
|
|
250
|
+
funcList: formulas,
|
|
251
|
+
funcActiveCollapseNames: [0],
|
|
252
|
+
};
|
|
253
|
+
},
|
|
254
|
+
created() {
|
|
255
|
+
this.editFormula();
|
|
256
|
+
},
|
|
257
|
+
mounted() {},
|
|
258
|
+
methods: {
|
|
259
|
+
dialogClose() {
|
|
260
|
+
this.formulaDialogVisible = false;
|
|
261
|
+
this.$emit("update:visiable", false);
|
|
262
|
+
},
|
|
263
|
+
clearFormula(event) {
|
|
264
|
+
this.formula = ""; //CodeMirror 模式
|
|
265
|
+
this.tags = []; //el-tag模式
|
|
266
|
+
this.codeMirror.dispatch({
|
|
267
|
+
changes: { from: 0, to: this.codeMirror.state.doc.length, insert: "" },
|
|
268
|
+
});
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
/** 删除字符串str中的第n个subStr
|
|
272
|
+
* @param {Object} str
|
|
273
|
+
* @param {Object} subStr
|
|
274
|
+
* @param {Object} n
|
|
275
|
+
*/
|
|
276
|
+
deleteChar(str, subStr, n) {
|
|
277
|
+
let num = -1;
|
|
278
|
+
return str.replace(/a/g, (item) => {
|
|
279
|
+
num++;
|
|
280
|
+
return num === n ? "" : item;
|
|
281
|
+
});
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
filterNode(value, data) {
|
|
285
|
+
if (!value) return true;
|
|
286
|
+
return data.label.indexOf(value) !== -1;
|
|
287
|
+
},
|
|
288
|
+
handleTableConfigData(widget, callback) {
|
|
289
|
+
callback(widget);
|
|
290
|
+
},
|
|
291
|
+
loadFieldListToTree() {
|
|
292
|
+
this.fieldTreeData.length = 0; //先清空
|
|
293
|
+
let newItems = this.option.fieldData.map((item) => {
|
|
294
|
+
const fieldNode = {
|
|
295
|
+
id: item.id,
|
|
296
|
+
name: item.label,
|
|
297
|
+
label: item.label,
|
|
298
|
+
type: "input",
|
|
299
|
+
formItemFlag: true,
|
|
300
|
+
};
|
|
301
|
+
return fieldNode;
|
|
302
|
+
});
|
|
303
|
+
this.fieldTreeData.push(...newItems);
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
// 插入字段
|
|
307
|
+
insertField(obj, node, self) {
|
|
308
|
+
if (!!obj.formItemFlag) {
|
|
309
|
+
let fieldId = obj.id + "";
|
|
310
|
+
let fieldLabel = "[" + obj.label + "]";
|
|
311
|
+
this.updateCodeMirror(fieldId, fieldLabel, "field");
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
// 插入符号
|
|
316
|
+
insertSymbol(opt) {
|
|
317
|
+
this.updateCodeMirror(opt, opt, null);
|
|
318
|
+
},
|
|
319
|
+
|
|
320
|
+
// 插入函数
|
|
321
|
+
insertFunction(opt) {
|
|
322
|
+
const val = opt.substring(0, opt.length - 1);
|
|
323
|
+
this.updateCodeMirror(val, val, "func");
|
|
324
|
+
},
|
|
325
|
+
|
|
326
|
+
updateCodeMirror(field, text, type = null) {
|
|
327
|
+
if (type) {
|
|
328
|
+
let obj = {
|
|
329
|
+
field: field,
|
|
330
|
+
text: text,
|
|
331
|
+
type: type,
|
|
332
|
+
};
|
|
333
|
+
let selectionLet = obj.field.length + obj.text.length + obj.type.length; //光标位置;
|
|
334
|
+
let code = `{{${obj.field}.${obj.text}.${obj.type}}}`;
|
|
335
|
+
if (type === "func") {
|
|
336
|
+
code += "()";
|
|
337
|
+
selectionLet = selectionLet + 7;
|
|
338
|
+
} else {
|
|
339
|
+
selectionLet = selectionLet + 6;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (code) {
|
|
343
|
+
this.codeMirror.dispatch({
|
|
344
|
+
changes: {
|
|
345
|
+
from: this.codeMirror.state.selection.main.head,
|
|
346
|
+
to: this.codeMirror.state.selection.main.head,
|
|
347
|
+
insert: code,
|
|
348
|
+
},
|
|
349
|
+
selection: {
|
|
350
|
+
anchor: this.codeMirror.state.selection.main.head + selectionLet,
|
|
351
|
+
},
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
} else {
|
|
355
|
+
this.codeMirror.dispatch({
|
|
356
|
+
changes: {
|
|
357
|
+
from: this.codeMirror.state.selection.main.head,
|
|
358
|
+
to: this.codeMirror.state.selection.main.head,
|
|
359
|
+
insert: text,
|
|
360
|
+
},
|
|
361
|
+
selection: {
|
|
362
|
+
anchor: this.codeMirror.state.selection.main.head + text.length,
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
|
|
368
|
+
// 在字符串中查找[开始]结尾的字符串,并删除
|
|
369
|
+
removeStr(str) {
|
|
370
|
+
let a = str.indexOf("[");
|
|
371
|
+
if (a === -1) {
|
|
372
|
+
return str;
|
|
373
|
+
}
|
|
374
|
+
let b = str.indexOf("]", a) + 1;
|
|
375
|
+
let c = str.substring(a, b);
|
|
376
|
+
let strArr = str.split(c);
|
|
377
|
+
let newStr = "";
|
|
378
|
+
for (let i = 0; i < strArr.length; i++) {
|
|
379
|
+
newStr += strArr[i];
|
|
380
|
+
}
|
|
381
|
+
return this.removeStr(newStr);
|
|
382
|
+
},
|
|
383
|
+
extractFieldNames(formula) {
|
|
384
|
+
if (!formula) return [];
|
|
385
|
+
const fieldArray = [];
|
|
386
|
+
let tempFormula = formula;
|
|
387
|
+
|
|
388
|
+
// 循环查找所有 [字段名] 格式的引用
|
|
389
|
+
while (true) {
|
|
390
|
+
const startIndex = tempFormula.indexOf("[");
|
|
391
|
+
if (startIndex === -1) {
|
|
392
|
+
break; // 没有更多字段引用了
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const endIndex = tempFormula.indexOf("]", startIndex);
|
|
396
|
+
if (endIndex === -1) {
|
|
397
|
+
break; // 格式不正确,没有匹配的右括号
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// 提取字段名(不包含方括号)
|
|
401
|
+
const fieldName = tempFormula.substring(startIndex + 1, endIndex);
|
|
402
|
+
|
|
403
|
+
// 避免重复添加相同的字段名
|
|
404
|
+
if (!fieldArray.includes(fieldName)) {
|
|
405
|
+
fieldArray.push(fieldName);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// 从剩余部分继续查找
|
|
409
|
+
tempFormula = tempFormula.substring(endIndex + 1);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return fieldArray;
|
|
413
|
+
},
|
|
414
|
+
/**
|
|
415
|
+
* 字段label可能在公式保存后再次被修改,当编辑公式时需要再次刷新公式中的字段label(不刷新也不会影响公式计算结果)
|
|
416
|
+
*/
|
|
417
|
+
refreshFormula() {
|
|
418
|
+
let formula = this.option.formula;
|
|
419
|
+
|
|
420
|
+
let fieldTreeData = this.fieldTreeData;
|
|
421
|
+
let paramCodes = this.extractFieldNames(formula);
|
|
422
|
+
paramCodes.forEach((paramCode) => {
|
|
423
|
+
let fieldNode = fieldTreeData.find((item) => item.id === paramCode);
|
|
424
|
+
if (!!fieldNode) {
|
|
425
|
+
let newParamCode = `{{${fieldNode.id}.[${fieldNode.label}].field}}`;
|
|
426
|
+
formula = formula.replaceAll(`[${paramCode}]`, newParamCode);
|
|
427
|
+
} else {
|
|
428
|
+
let newParamCode = `{{${paramCode}.[paramCode(未定义)].field}}`;
|
|
429
|
+
formula = formula.replaceAll(`[${paramCode}]`, newParamCode);
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
this.formula = formula;
|
|
433
|
+
},
|
|
434
|
+
|
|
435
|
+
// 打开编辑公式弹窗
|
|
436
|
+
editFormula() {
|
|
437
|
+
this.fieldTreeData.length = 0;
|
|
438
|
+
// 初始化字段树
|
|
439
|
+
|
|
440
|
+
this.loadFieldListToTree();
|
|
441
|
+
|
|
442
|
+
console.log("设计器字段===>", this.fieldTreeData);
|
|
443
|
+
|
|
444
|
+
// 加载当前字段计算公式tags
|
|
445
|
+
this.refreshFormula();
|
|
446
|
+
const code = this.formula;
|
|
447
|
+
this.formulaDialogVisible = true;
|
|
448
|
+
|
|
449
|
+
//==== codeMirror 挂载视图 ====
|
|
450
|
+
this.$nextTick(() => {
|
|
451
|
+
this.codeMirror = new EditorView({
|
|
452
|
+
state: EditorState.create({
|
|
453
|
+
doc: code,
|
|
454
|
+
extensions: [basicSetup, javascript(), [baseTheme, [], placeholders]],
|
|
455
|
+
}),
|
|
456
|
+
parent: this.$refs.cmRef,
|
|
457
|
+
});
|
|
458
|
+
console.log("编辑器实例==>", this.codeMirror);
|
|
459
|
+
});
|
|
460
|
+
},
|
|
461
|
+
|
|
462
|
+
// 保存计算公式
|
|
463
|
+
getFormulaForView(formula) {
|
|
464
|
+
const matchResult = formula.match(FORMULA_REG_EXP);
|
|
465
|
+
if (!matchResult) {
|
|
466
|
+
return {
|
|
467
|
+
formula: formula,
|
|
468
|
+
showFormula: formula,
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
let fullFormula = this.formula;
|
|
473
|
+
let showFormula = this.formula;
|
|
474
|
+
let realFormula = this.formula;
|
|
475
|
+
matchResult.forEach((mi) => {
|
|
476
|
+
let arr = mi.split(".");
|
|
477
|
+
const firstPart = arr[0];
|
|
478
|
+
const secondPart = arr[1];
|
|
479
|
+
const thirdPart = arr[2];
|
|
480
|
+
const fieldId = firstPart.substring(2, firstPart.length);
|
|
481
|
+
const nodeType = thirdPart.substring(0, thirdPart.length - 2);
|
|
482
|
+
|
|
483
|
+
showFormula = showFormula.replaceAll(mi, secondPart);
|
|
484
|
+
if (nodeType == "field") {
|
|
485
|
+
realFormula = realFormula.replaceAll(mi, `[${fieldId}]`);
|
|
486
|
+
} else {
|
|
487
|
+
realFormula = realFormula.replaceAll(mi, secondPart);
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
return {
|
|
492
|
+
showFormula,
|
|
493
|
+
fullFormula,
|
|
494
|
+
formula: realFormula,
|
|
495
|
+
};
|
|
496
|
+
},
|
|
497
|
+
saveFormula() {
|
|
498
|
+
this.formula = this.codeMirror.state.doc.text.join("");
|
|
499
|
+
let resultObj = this.getFormulaForView(this.formula);
|
|
500
|
+
this.option.confirm && this.option.confirm(resultObj);
|
|
501
|
+
this.dialogClose();
|
|
502
|
+
},
|
|
503
|
+
getClass(type) {
|
|
504
|
+
if (type === this.i18nt("designer.hint.formulaNumber")) {
|
|
505
|
+
return "warning";
|
|
506
|
+
}
|
|
507
|
+
if (type === this.i18nt("designer.hint.formulaChar")) {
|
|
508
|
+
return "";
|
|
509
|
+
}
|
|
510
|
+
if (type === this.i18nt("designer.hint.formulaObject")) {
|
|
511
|
+
return "danger";
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
|
|
515
|
+
resetIntro() {
|
|
516
|
+
this.introTitle = this.i18nt("designer.hint.formulaFunctionExplain");
|
|
517
|
+
this.introduction = {
|
|
518
|
+
title: this.i18nt("designer.hint.formulaPleaseSelect"),
|
|
519
|
+
content:
|
|
520
|
+
'<span class="cg">' +
|
|
521
|
+
this.i18nt("designer.hint.formulaSample") +
|
|
522
|
+
':</span><span class="fname">SUM</span><span class="cg">(</span><span class="cs">参数1</span><span class="cg">,</span><span class="cs">参数2</span><span class="cg">)</span>',
|
|
523
|
+
};
|
|
524
|
+
},
|
|
525
|
+
|
|
526
|
+
showIntro(name, title, content) {
|
|
527
|
+
content = '<span class="cg">' + content + "</span>";
|
|
528
|
+
this.introduction = {
|
|
529
|
+
title: title,
|
|
530
|
+
content: content,
|
|
531
|
+
};
|
|
532
|
+
this.introTitle = name;
|
|
533
|
+
},
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* 校验计算公式是否正确
|
|
537
|
+
* @param s
|
|
538
|
+
* @returns {boolean}
|
|
539
|
+
*/
|
|
540
|
+
isValid(s) {
|
|
541
|
+
let a = []; //存储左括号出现的地方
|
|
542
|
+
let l = s.length;
|
|
543
|
+
let k = 0;
|
|
544
|
+
let flag = 1;
|
|
545
|
+
let j;
|
|
546
|
+
for (let i = 0; i < l && flag; i++) {
|
|
547
|
+
switch (s[i]) {
|
|
548
|
+
case "(":
|
|
549
|
+
a[k] = i;
|
|
550
|
+
k++;
|
|
551
|
+
break;
|
|
552
|
+
case ")":
|
|
553
|
+
j = a[k - 1];
|
|
554
|
+
if (s[j] === "(") {
|
|
555
|
+
a[k] = 0;
|
|
556
|
+
k--;
|
|
557
|
+
} else {
|
|
558
|
+
flag = 0;
|
|
559
|
+
}
|
|
560
|
+
break;
|
|
561
|
+
case "{":
|
|
562
|
+
a[k] = i;
|
|
563
|
+
k++;
|
|
564
|
+
break;
|
|
565
|
+
case "}":
|
|
566
|
+
j = a[k - 1];
|
|
567
|
+
if (s[j] === "{") {
|
|
568
|
+
a[k] = 0;
|
|
569
|
+
k--;
|
|
570
|
+
} else {
|
|
571
|
+
flag = 0;
|
|
572
|
+
}
|
|
573
|
+
break;
|
|
574
|
+
case "[":
|
|
575
|
+
a[k] = i;
|
|
576
|
+
k++;
|
|
577
|
+
break;
|
|
578
|
+
case "]":
|
|
579
|
+
j = a[k - 1];
|
|
580
|
+
if (s[j] === "[") {
|
|
581
|
+
a[k] = 0;
|
|
582
|
+
k--;
|
|
583
|
+
} else {
|
|
584
|
+
flag = 0;
|
|
585
|
+
}
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
if (k !== 0) {
|
|
590
|
+
flag = 0;
|
|
591
|
+
}
|
|
592
|
+
return flag !== 0;
|
|
593
|
+
},
|
|
594
|
+
},
|
|
595
|
+
};
|
|
596
|
+
</script>
|
|
597
|
+
|
|
598
|
+
<style lang="scss" scoped>
|
|
599
|
+
:deep(.cm-editor) {
|
|
600
|
+
height: 100%;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
li {
|
|
604
|
+
list-style: none;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/*去掉li前面的点*/
|
|
608
|
+
.el-input-group {
|
|
609
|
+
cursor: pointer;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
.header {
|
|
613
|
+
width: 97%;
|
|
614
|
+
border: 1px solid #ccc;
|
|
615
|
+
border-top-left-radius: 10px;
|
|
616
|
+
border-top-right-radius: 10px;
|
|
617
|
+
height: 31px;
|
|
618
|
+
line-height: 31px;
|
|
619
|
+
padding-left: 15px;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
.editor {
|
|
623
|
+
margin-left: 10px;
|
|
624
|
+
margin-right: 10px;
|
|
625
|
+
height: 200px;
|
|
626
|
+
border: 1px solid #ccc;
|
|
627
|
+
border-radius: 6px;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
.editor-top {
|
|
631
|
+
//margin-left: 10px;
|
|
632
|
+
height: 130px;
|
|
633
|
+
width: 100%;
|
|
634
|
+
padding: 8px;
|
|
635
|
+
position: relative;
|
|
636
|
+
overflow-x: hidden;
|
|
637
|
+
overflow-y: scroll;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
.editor-bottom {
|
|
641
|
+
border-left: 1px solid #ccc;
|
|
642
|
+
display: flex;
|
|
643
|
+
flex-wrap: wrap;
|
|
644
|
+
padding: 5px;
|
|
645
|
+
align-content: flex-start;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
.body-right-button {
|
|
649
|
+
width: 60px;
|
|
650
|
+
height: 40px;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
.group-form {
|
|
654
|
+
margin-top: 15px;
|
|
655
|
+
display: flex;
|
|
656
|
+
justify-content: space-between;
|
|
657
|
+
height: 350px;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.group-item-left {
|
|
661
|
+
height: 350px;
|
|
662
|
+
border: 1px solid #ccc;
|
|
663
|
+
border-top-left-radius: 6px;
|
|
664
|
+
border-bottom-left-radius: 6px;
|
|
665
|
+
margin-bottom: 5px;
|
|
666
|
+
padding: 0;
|
|
667
|
+
width: 100%;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
.group-item-right-top {
|
|
671
|
+
height: 350px;
|
|
672
|
+
border: 1px solid #ccc;
|
|
673
|
+
border-radius: 0;
|
|
674
|
+
margin-bottom: 5px;
|
|
675
|
+
width: 100%;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
.group-item-right-bottom {
|
|
679
|
+
height: 350px;
|
|
680
|
+
border: 1px solid #ccc;
|
|
681
|
+
border-top-right-radius: 6px;
|
|
682
|
+
border-bottom-right-radius: 6px;
|
|
683
|
+
margin-bottom: 5px;
|
|
684
|
+
width: 100%;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
.item-header {
|
|
688
|
+
border-bottom: 1px solid #ccc;
|
|
689
|
+
height: 29px;
|
|
690
|
+
line-height: 29px;
|
|
691
|
+
padding-left: 15px;
|
|
692
|
+
font-weight: bold;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
.item-body-left {
|
|
696
|
+
height: 320px;
|
|
697
|
+
overflow-y: auto;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
.function-list {
|
|
701
|
+
height: 320px;
|
|
702
|
+
overflow-y: auto;
|
|
703
|
+
|
|
704
|
+
:deep(.el-collapse-item__header) {
|
|
705
|
+
font-weight: normal !important;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
.item-body-right-bottom {
|
|
710
|
+
height: 152px;
|
|
711
|
+
overflow-y: auto;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
.el-collapse {
|
|
715
|
+
border: none;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
:deep(.el-dialog) {
|
|
719
|
+
margin-top: 10px !important;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
:deep(.el-collapse-item__header) {
|
|
723
|
+
padding-left: 10px;
|
|
724
|
+
border: none;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
:deep(.el-collapse-item__wrap) {
|
|
728
|
+
border: none;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
:deep(.el-collapse-item__arrow) {
|
|
732
|
+
margin-left: 8px;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
.field-item {
|
|
736
|
+
display: flex;
|
|
737
|
+
justify-content: space-between;
|
|
738
|
+
align-items: center;
|
|
739
|
+
height: 32px;
|
|
740
|
+
padding-left: 30px;
|
|
741
|
+
padding-right: 15px;
|
|
742
|
+
cursor: pointer;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
.field-item:hover {
|
|
746
|
+
background-color: #f8f8f8;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
p::before {
|
|
750
|
+
content: "● ";
|
|
751
|
+
color: #0a5d7c;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
p {
|
|
755
|
+
height: 24px;
|
|
756
|
+
line-height: 24px;
|
|
757
|
+
padding: 0 15px;
|
|
758
|
+
font-size: 16px;
|
|
759
|
+
color: #0a5d7c;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
.intro-content {
|
|
763
|
+
padding-left: 30px;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
.cg {
|
|
767
|
+
color: #0a5d7c;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
.fname {
|
|
771
|
+
display: inline-block;
|
|
772
|
+
border-radius: 2px;
|
|
773
|
+
padding: 0 5px;
|
|
774
|
+
margin: 1px;
|
|
775
|
+
font-size: 12px;
|
|
776
|
+
line-height: 20px;
|
|
777
|
+
color: #708;
|
|
778
|
+
background: #fff;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
.cs {
|
|
782
|
+
display: inline-block;
|
|
783
|
+
border-radius: 2px;
|
|
784
|
+
padding: 0 5px;
|
|
785
|
+
margin: 1px;
|
|
786
|
+
color: #fff;
|
|
787
|
+
font-size: 12px;
|
|
788
|
+
line-height: 20px;
|
|
789
|
+
background: #178cdf;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
:deep(.el-dialog__body) {
|
|
793
|
+
padding: 0;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
.small-padding-dialog {
|
|
797
|
+
/* margin-top: 0px; */
|
|
798
|
+
}
|
|
799
|
+
</style>
|