cloud-web-corejs 1.0.54-dev.434 → 1.0.54-dev.436

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.
@@ -0,0 +1,971 @@
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
+ default-expand-all
66
+ >
67
+ <template #default="{ node, data }">
68
+ <span class="custom-tree-node">
69
+ <el-tooltip effect="dark" :content="node.label" placement="right">
70
+ <span>{{ node.label }}</span>
71
+ </el-tooltip>
72
+ </span>
73
+ </template>
74
+ </el-tree>
75
+ </div>
76
+ </div>
77
+ </el-col>
78
+ <el-col :span="6">
79
+ <el-row>
80
+ <el-col :span="24">
81
+ <div class="group-item-right-top">
82
+ <div class="item-header">
83
+ {{ i18nt("designer.hint.formulaFunctionList") }}
84
+ </div>
85
+ <div class="function-list">
86
+ <el-collapse v-model="funcActiveCollapseNames">
87
+ <template v-for="(item, index) in funcList">
88
+ <el-collapse-item
89
+ :key="index"
90
+ :title="i18nt(item.fClass)"
91
+ :name="index"
92
+ v-if="index < 2"
93
+ >
94
+ <div
95
+ v-for="(info, i) in item.flist"
96
+ :key="i"
97
+ class="field-item"
98
+ @click="insertFunction(info.fName + '(')"
99
+ @mouseenter="
100
+ showIntro(
101
+ i18nt(info.fName),
102
+ i18nt(item.fClass),
103
+ i18nt(info.fIntro)
104
+ )
105
+ "
106
+ v-on:mouseleave="resetIntro"
107
+ >
108
+ <span>{{ info.fName }}</span>
109
+ <el-tag :type="getClass(info.fType)"
110
+ >{{ i18nt(info.fType) }}
111
+ </el-tag>
112
+ </div>
113
+ </el-collapse-item>
114
+ </template>
115
+ </el-collapse>
116
+ </div>
117
+ </div>
118
+ </el-col>
119
+ </el-row>
120
+ </el-col>
121
+ <el-col :span="12">
122
+ <div class="group-item-right-bottom">
123
+ <div class="item-header">{{ introTitle }}</div>
124
+ <div class="item-body-right-bottom">
125
+ <ul>
126
+ <li
127
+ v-if="introduction.title !== ''"
128
+ style="font-size: 16px; color: #0a5d7c"
129
+ >
130
+ {{ introduction.title }}
131
+ </li>
132
+ <li>
133
+ <div class="intro-content" v-html="introduction.content"></div>
134
+ </li>
135
+ </ul>
136
+ </div>
137
+ </div>
138
+ </el-col>
139
+ </el-row>
140
+ </div>
141
+ <div class="dialog-footer" slot="footer">
142
+ <el-button
143
+ @click="formulaDialogVisible = false"
144
+ class="button-sty"
145
+ icon="el-icon-close"
146
+ >
147
+ {{ i18nt("designer.hint.cancel") }}
148
+ </el-button>
149
+ <el-button
150
+ type="primary"
151
+ @click="saveFormula"
152
+ class="button-sty"
153
+ icon="el-icon-check"
154
+ >
155
+ {{ i18nt("designer.hint.confirm") }}
156
+ </el-button>
157
+ </div>
158
+ </el-dialog>
159
+ </template>
160
+
161
+ <script>
162
+ import { basicSetup, EditorView } from "codemirror";
163
+ import { javascript } from "@codemirror/lang-javascript";
164
+ import { EditorState } from "@codemirror/state";
165
+ import i18n from "@base/components/xform/utils/i18n";
166
+ import {
167
+ deepClone,
168
+ getAllContainerWidgets,
169
+ getAllFieldWidgets,
170
+ getFieldWidgetById,
171
+ traverseFieldWidgetsOfContainer,
172
+ loopHandleWidget,
173
+ traverseAllWidgetsNew,
174
+ } from "@base/components/xform/utils/util";
175
+ import {
176
+ placeholders,
177
+ baseTheme,
178
+ formulas,
179
+ FORMULA_REG_EXP,
180
+ } from "@base/components/xform/utils/formula-util";
181
+
182
+ export default {
183
+ name: "formula-editor2",
184
+ mixins: [i18n],
185
+ components: {},
186
+ props: {
187
+ option: Object,
188
+ },
189
+ computed: {
190
+ formulaForView() {
191
+ const matchResult = this.formula.match(FORMULA_REG_EXP);
192
+ if (!matchResult) {
193
+ return this.formula;
194
+ }
195
+
196
+ let resultFormula = this.formula;
197
+ matchResult.forEach((mi) => {
198
+ const secondPart = mi.split(".")[1];
199
+ resultFormula = resultFormula.replaceAll(mi, secondPart);
200
+ });
201
+
202
+ return resultFormula;
203
+ },
204
+ },
205
+ watch: {
206
+ filterText(val) {
207
+ this.$refs.fieldTree.filter(val);
208
+ },
209
+ },
210
+ data() {
211
+ return {
212
+ codeMirror: null,
213
+ formula: "",
214
+ tags: [], // 公式页签集合
215
+ fieldTreeData: [], // 设计器字段树
216
+ filterText: "",
217
+ formulaDialogVisible: true,
218
+ operate: ["+", "-", "*", "/", "!=", "==", "<", ">", "<=", ">=", "(", ")", ","],
219
+ insertNum: 0,
220
+ insertStr: "",
221
+ activeNames: ["1"],
222
+ widgetSizes: [
223
+ {
224
+ label: this.i18nt("designer.hint.formulaSizeLarge"),
225
+ value: "large",
226
+ },
227
+ {
228
+ label: this.i18nt("designer.hint.formulaSizeMedium"),
229
+ value: "default",
230
+ },
231
+ {
232
+ label: this.i18nt("designer.hint.formulaSizeSmall"),
233
+ value: "small",
234
+ },
235
+ {
236
+ label: this.i18nt("designer.hint.formulaSizeMini"),
237
+ value: "small",
238
+ },
239
+ ],
240
+ introTitle: this.i18nt("designer.hint.formulaFunctionExplain"),
241
+ introduction: {
242
+ title: this.i18nt("designer.hint.formulaPleaseSelect"),
243
+ content:
244
+ '<span class="cg">' +
245
+ this.i18nt("designer.hint.formulaSample") +
246
+ ':</span><span class="fname">SUM</span><span class="cg">(</span><span class="cs">' +
247
+ this.i18nt("designer.hint.formulaPara") +
248
+ '1</span><span class="cg">,</span><span class="cs">' +
249
+ this.i18nt("designer.hint.formulaPara") +
250
+ '2</span><span class="cg">)</span>',
251
+ },
252
+ funcList: formulas,
253
+ funcActiveCollapseNames: [0],
254
+
255
+ targetFormTemplate: null,
256
+ targetFormJson: null,
257
+ };
258
+ },
259
+ created() {
260
+ this.editFormula();
261
+ },
262
+ mounted() {},
263
+ methods: {
264
+ dialogClose() {
265
+ this.formulaDialogVisible = false;
266
+ this.$emit("update:visiable", false);
267
+ },
268
+ clearFormula(event) {
269
+ this.formula = ""; //CodeMirror 模式
270
+ this.tags = []; //el-tag模式
271
+ this.codeMirror.dispatch({
272
+ changes: { from: 0, to: this.codeMirror.state.doc.length, insert: "" },
273
+ });
274
+ },
275
+
276
+ /** 删除字符串str中的第n个subStr
277
+ * @param {Object} str
278
+ * @param {Object} subStr
279
+ * @param {Object} n
280
+ */
281
+ deleteChar(str, subStr, n) {
282
+ let num = -1;
283
+ return str.replace(/a/g, (item) => {
284
+ num++;
285
+ return num === n ? "" : item;
286
+ });
287
+ },
288
+
289
+ filterNode(value, data) {
290
+ if (!value) return true;
291
+ return data.label.indexOf(value) !== -1;
292
+ },
293
+ handleTableConfigData(widget, callback) {
294
+ callback(widget);
295
+ },
296
+ initHandleFields() {
297
+ let option = this.option;
298
+ let formWidgetNames = option.formWidgetNames || [];
299
+ let itemWidgets = option.itemWidgets || [];
300
+ let tableWidgetNames = itemWidgets.map((item) => item.widgetName);
301
+
302
+ let tableWidgetMap0 = itemWidgets.map((item) => {
303
+ return {
304
+ [item.widgetName]: item.columnWidgetNames,
305
+ };
306
+ });
307
+
308
+ let formWidgetMap = {};
309
+ let tableWidgetMap = itemWidgets.map((item) => {
310
+ let columnWidgetMap = {};
311
+ item.columnWidgetNames.forEach((columnWidgetName) => {
312
+ return (columnWidgetMap[columnWidgetName] = null);
313
+ });
314
+ return {
315
+ [item.widgetName]: {
316
+ tableWidget: null,
317
+ columnWidgetMap,
318
+ },
319
+ };
320
+ });
321
+
322
+ traverseAllWidgetsNew(this.targetFormJson.widgetList, (widget, pWidget) => {
323
+ if (pWidget && pWidget.type === "data-table") {
324
+ if (tableWidgetNames.includes(pWidget.options.name)) {
325
+ let tableItems = tableWidgetMap0[pWidget.options.name];
326
+ if (
327
+ widget.formItemFlag &&
328
+ widget.options.label &&
329
+ tableItems.includes(widget.options.label)
330
+ ) {
331
+ tableWidgetMap[pWidget.options.name].columnWidgetMap[
332
+ widget.options.label
333
+ ] = widget;
334
+ }
335
+ tableWidgetMap[pWidget.options.name].tableWidget = widget;
336
+ }
337
+ formWidgetNames.push(widget.widgetName);
338
+ itemWidgets.push(widget);
339
+ } else if (
340
+ widget.formItemFlag &&
341
+ widget.options.label &&
342
+ formWidgetNames.includes(widget.options.label)
343
+ ) {
344
+ formWidgetMap[widget.options.label] = widget;
345
+ }
346
+ });
347
+ },
348
+ getReportTemplate(formCode, callback) {
349
+ let url, data;
350
+ url = USER_PREFIX + `/formTemplate/getByFormCode`;
351
+ data = { stringOne: formCode };
352
+ return this.$http({
353
+ // aes: true,
354
+ url: url,
355
+ method: `post`,
356
+ data: data,
357
+ isLoading: true,
358
+ // loadingTarget: document.body,
359
+ // modalStrictly: true,
360
+ success: (res) => {
361
+ let formTemplate = res.objx || {};
362
+ this.targetFormTemplate = formTemplate;
363
+ this.targetFormJson = formTemplate.formViewContent
364
+ ? JSON.parse(formTemplate.formViewContent)
365
+ : {};
366
+ callback && callback();
367
+ },
368
+ });
369
+ },
370
+ getTargetWidgetList() {
371
+ let widgetList = this.targetFormJson.widgetList;
372
+ return widgetList;
373
+ },
374
+ loadFieldListToTree() {
375
+ let option = this.option;
376
+ let formWidgetNames = option.formWidgetNames || [];
377
+ let itemWidgets = option.itemWidgets || [];
378
+ let tableWidgetNames = itemWidgets.map((item) => item.widgetName);
379
+ let tableWidgetMap = {};
380
+ itemWidgets.forEach((item) => {
381
+ tableWidgetMap[item.widgetName] = item.columnWidgetNames;
382
+ });
383
+
384
+ this.fieldTreeData.length = 0; //先清空
385
+
386
+ let widgetList = this.getTargetWidgetList();
387
+
388
+ const allFields = getAllFieldWidgets(widgetList);
389
+ const allContainers = getAllContainerWidgets(widgetList);
390
+
391
+ const subFormArray = [];
392
+ let sfFieldArray = [];
393
+ const subFormFieldMap = {};
394
+
395
+ //获取子表单容器内部的字段
396
+ allContainers.forEach((con) => {
397
+ if (con.type === "data-table") {
398
+ if (tableWidgetNames.includes(con.container.options.name)) {
399
+ subFormArray.push(con.container);
400
+ const tmpFieldArray = [];
401
+ const fwHandler = (fw) => {
402
+ /* if (!!fw.formItemFlag && fw.type === "number") {
403
+ tmpFieldArray.push(fw);
404
+ } */
405
+ if (tableWidgetMap[con.container.options.name]?.includes(fw.options.name)) {
406
+ tmpFieldArray.push(fw);
407
+ }
408
+ };
409
+
410
+ // this.traverseFieldWidgetsOfTableDataWidget(con.container, fwHandler);
411
+ traverseFieldWidgetsOfContainer(con.container, fwHandler);
412
+ subFormFieldMap[con.container.options.name] = tmpFieldArray;
413
+ sfFieldArray = sfFieldArray.concat(tmpFieldArray);
414
+ }
415
+ }
416
+ });
417
+
418
+ //加载到树形组件数据对象
419
+ allFields.forEach((fld) => {
420
+ let flag1 = !sfFieldArray.find((item) => item.id === fld.field.id);
421
+ let flag2 =
422
+ fld.field.options.label && formWidgetNames.includes(fld.field.options.name);
423
+ let flag = flag2;
424
+ if (flag) {
425
+ //排除子表单字段
426
+ const fieldNode = {
427
+ id: fld.field.id,
428
+ name: fld.field.options.name,
429
+ label: fld.field.options.label,
430
+ type: fld.field.type,
431
+ formItemFlag: true,
432
+ };
433
+ this.fieldTreeData.push(fieldNode);
434
+ }
435
+ });
436
+
437
+ subFormArray.forEach((sf) => {
438
+ const subFormNode = {
439
+ id: sf.id,
440
+ name: sf.options.name,
441
+ label: sf.options.label || sf.options.name,
442
+ type: sf.type,
443
+ formItemFlag: false,
444
+ children: [],
445
+ };
446
+
447
+ subFormFieldMap[sf.options.name].forEach((fld) => {
448
+ const fieldNode = {
449
+ id: fld.id,
450
+ name: fld.options.name,
451
+ label: fld.options.label,
452
+ type: fld.type,
453
+ formItemFlag: true,
454
+ };
455
+ subFormNode.children.push(fieldNode);
456
+ });
457
+
458
+ this.fieldTreeData.push(subFormNode);
459
+ });
460
+ },
461
+
462
+ // 插入字段
463
+ insertField(obj, node, self) {
464
+ if (!!obj.formItemFlag) {
465
+ let fieldId = obj.id + "";
466
+ let fieldLabel = "[" + obj.label + "]";
467
+ this.updateCodeMirror(fieldId, fieldLabel, "field");
468
+ }
469
+ },
470
+
471
+ // 插入符号
472
+ insertSymbol(opt) {
473
+ this.updateCodeMirror(opt, opt, null);
474
+ },
475
+
476
+ // 插入函数
477
+ insertFunction(opt) {
478
+ const val = opt.substring(0, opt.length - 1);
479
+ this.updateCodeMirror(val, val, "func");
480
+ },
481
+ getFunStr(funcName) {
482
+ let map = {
483
+ SUMIF: `([],"",[])`,
484
+ SUMIFS: `([],[],"")`,
485
+ };
486
+ return map[funcName] || "()";
487
+ },
488
+ updateCodeMirror(field, text, type = null) {
489
+ if (type) {
490
+ let obj = {
491
+ field: field,
492
+ text: text,
493
+ type: type,
494
+ };
495
+ let selectionLet = obj.field.length + obj.text.length + obj.type.length; //光标位置;
496
+ let code = `{{${obj.field}.${obj.text}.${obj.type}}}`;
497
+ if (type === "func") {
498
+ // code += "()";
499
+ // selectionLet = selectionLet + 7;
500
+ let funStr = this.getFunStr(text);
501
+ code += funStr;
502
+ let num = "()" === funStr ? 7 : 7 - 1 + funStr.length;
503
+ selectionLet = selectionLet + num;
504
+ } else {
505
+ selectionLet = selectionLet + 6;
506
+ }
507
+
508
+ if (code) {
509
+ this.codeMirror.dispatch({
510
+ changes: {
511
+ from: this.codeMirror.state.selection.main.head,
512
+ to: this.codeMirror.state.selection.main.head,
513
+ insert: code,
514
+ },
515
+ selection: {
516
+ anchor: this.codeMirror.state.selection.main.head + selectionLet,
517
+ },
518
+ });
519
+ }
520
+ } else {
521
+ this.codeMirror.dispatch({
522
+ changes: {
523
+ from: this.codeMirror.state.selection.main.head,
524
+ to: this.codeMirror.state.selection.main.head,
525
+ insert: text,
526
+ },
527
+ selection: {
528
+ anchor: this.codeMirror.state.selection.main.head + text.length,
529
+ },
530
+ });
531
+ }
532
+ },
533
+
534
+ // 在字符串中查找[开始]结尾的字符串,并删除
535
+ removeStr(str) {
536
+ let a = str.indexOf("[");
537
+ if (a === -1) {
538
+ return str;
539
+ }
540
+ let b = str.indexOf("]", a) + 1;
541
+ let c = str.substring(a, b);
542
+ let strArr = str.split(c);
543
+ let newStr = "";
544
+ for (let i = 0; i < strArr.length; i++) {
545
+ newStr += strArr[i];
546
+ }
547
+ return this.removeStr(newStr);
548
+ },
549
+ extractFieldNames(formula) {
550
+ if (!formula) return [];
551
+ const fieldArray = [];
552
+ let tempFormula = formula;
553
+
554
+ // 循环查找所有 [字段名] 格式的引用
555
+ while (true) {
556
+ const startIndex = tempFormula.indexOf("[");
557
+ if (startIndex === -1) {
558
+ break; // 没有更多字段引用了
559
+ }
560
+
561
+ const endIndex = tempFormula.indexOf("]", startIndex);
562
+ if (endIndex === -1) {
563
+ break; // 格式不正确,没有匹配的右括号
564
+ }
565
+
566
+ // 提取字段名(不包含方括号)
567
+ const fieldName = tempFormula.substring(startIndex + 1, endIndex);
568
+
569
+ // 避免重复添加相同的字段名
570
+ if (!fieldArray.includes(fieldName)) {
571
+ fieldArray.push(fieldName);
572
+ }
573
+
574
+ // 从剩余部分继续查找
575
+ tempFormula = tempFormula.substring(endIndex + 1);
576
+ }
577
+
578
+ return fieldArray;
579
+ },
580
+ /**
581
+ * 字段label可能在公式保存后再次被修改,当编辑公式时需要再次刷新公式中的字段label(不刷新也不会影响公式计算结果)
582
+ */
583
+ refreshFormula() {
584
+ const matchResult = this.option.formula?.match(FORMULA_REG_EXP);
585
+ if (!matchResult) {
586
+ return this.option.formula;
587
+ }
588
+
589
+ matchResult.forEach((mi) => {
590
+ const firstPart = mi.split(".")[0];
591
+ const secondPart = mi.split(".")[1];
592
+ const thirdPart = mi.split(".")[2];
593
+ const nodeType = thirdPart.substring(0, thirdPart.length - 2);
594
+ if (nodeType === "func") {
595
+ return;
596
+ }
597
+
598
+ const fieldId = firstPart.substring(2, firstPart.length);
599
+ const fieldSchema = getFieldWidgetById(
600
+ // this.designer.widgetList,
601
+ this.getTargetWidgetList(),
602
+ fieldId,
603
+ false
604
+ );
605
+ if (!!fieldSchema) {
606
+ const newLabel = fieldSchema.options.label || fieldSchema.options.name;
607
+ this.option.formula = this.option.formula.replace(
608
+ mi,
609
+ firstPart + ".[" + newLabel + "]." + thirdPart
610
+ );
611
+ } else {
612
+ this.$message.error(
613
+ this.i18nt("designer.hint.deletedFieldInFormula") + secondPart
614
+ );
615
+ }
616
+ });
617
+ },
618
+
619
+ // 打开编辑公式弹窗
620
+ editFormula() {
621
+ this.formula = this.option.formula ?? null;
622
+ this.fieldTreeData.length = 0;
623
+ // 初始化字段树
624
+
625
+ // this.loadFieldListToTree();
626
+
627
+ let option = this.option;
628
+ let formCode = option.formCode;
629
+ if (formCode) {
630
+ this.getReportTemplate(formCode, () => {
631
+ this.loadFieldListToTree();
632
+ console.log("设计器字段===>", this.fieldTreeData);
633
+
634
+ // 加载当前字段计算公式tags
635
+ this.refreshFormula();
636
+ const code = this.formula;
637
+ this.formulaDialogVisible = true;
638
+
639
+ //==== codeMirror 挂载视图 ====
640
+ this.$nextTick(() => {
641
+ this.codeMirror = new EditorView({
642
+ state: EditorState.create({
643
+ doc: code,
644
+ extensions: [basicSetup, javascript(), [baseTheme, [], placeholders]],
645
+ }),
646
+ parent: this.$refs.cmRef,
647
+ });
648
+ console.log("编辑器实例==>", this.codeMirror);
649
+ });
650
+ });
651
+ }
652
+ },
653
+
654
+ // 保存计算公式
655
+ getFormulaForView(formula) {
656
+ const matchResult = formula?.match(FORMULA_REG_EXP);
657
+ if (!matchResult) {
658
+ return {
659
+ formula: formula,
660
+ showFormula: formula,
661
+ };
662
+ }
663
+
664
+ return {
665
+ showFormula: this.formulaForView,
666
+ formula: formula,
667
+ };
668
+ },
669
+ saveFormula() {
670
+ this.formula = this.codeMirror.state.doc.text.join("");
671
+ let resultObj = this.getFormulaForView(this.formula);
672
+ this.option.confirm && this.option.confirm(resultObj);
673
+ this.dialogClose();
674
+ },
675
+ getClass(type) {
676
+ if (type === this.i18nt("designer.hint.formulaNumber")) {
677
+ return "warning";
678
+ }
679
+ if (type === this.i18nt("designer.hint.formulaChar")) {
680
+ return "";
681
+ }
682
+ if (type === this.i18nt("designer.hint.formulaObject")) {
683
+ return "danger";
684
+ }
685
+ },
686
+
687
+ resetIntro() {
688
+ this.introTitle = this.i18nt("designer.hint.formulaFunctionExplain");
689
+ this.introduction = {
690
+ title: this.i18nt("designer.hint.formulaPleaseSelect"),
691
+ content:
692
+ '<span class="cg">' +
693
+ this.i18nt("designer.hint.formulaSample") +
694
+ ':</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>',
695
+ };
696
+ },
697
+
698
+ showIntro(name, title, content) {
699
+ content = '<span class="cg">' + content + "</span>";
700
+ this.introduction = {
701
+ title: title,
702
+ content: content,
703
+ };
704
+ this.introTitle = name;
705
+ },
706
+
707
+ /**
708
+ * 校验计算公式是否正确
709
+ * @param s
710
+ * @returns {boolean}
711
+ */
712
+ isValid(s) {
713
+ let a = []; //存储左括号出现的地方
714
+ let l = s.length;
715
+ let k = 0;
716
+ let flag = 1;
717
+ let j;
718
+ for (let i = 0; i < l && flag; i++) {
719
+ switch (s[i]) {
720
+ case "(":
721
+ a[k] = i;
722
+ k++;
723
+ break;
724
+ case ")":
725
+ j = a[k - 1];
726
+ if (s[j] === "(") {
727
+ a[k] = 0;
728
+ k--;
729
+ } else {
730
+ flag = 0;
731
+ }
732
+ break;
733
+ case "{":
734
+ a[k] = i;
735
+ k++;
736
+ break;
737
+ case "}":
738
+ j = a[k - 1];
739
+ if (s[j] === "{") {
740
+ a[k] = 0;
741
+ k--;
742
+ } else {
743
+ flag = 0;
744
+ }
745
+ break;
746
+ case "[":
747
+ a[k] = i;
748
+ k++;
749
+ break;
750
+ case "]":
751
+ j = a[k - 1];
752
+ if (s[j] === "[") {
753
+ a[k] = 0;
754
+ k--;
755
+ } else {
756
+ flag = 0;
757
+ }
758
+ break;
759
+ }
760
+ }
761
+ if (k !== 0) {
762
+ flag = 0;
763
+ }
764
+ return flag !== 0;
765
+ },
766
+ },
767
+ };
768
+ </script>
769
+
770
+ <style lang="scss" scoped>
771
+ :deep(.cm-editor) {
772
+ height: 100%;
773
+ }
774
+
775
+ li {
776
+ list-style: none;
777
+ }
778
+
779
+ /*去掉li前面的点*/
780
+ .el-input-group {
781
+ cursor: pointer;
782
+ }
783
+
784
+ .header {
785
+ width: 97%;
786
+ border: 1px solid #ccc;
787
+ border-top-left-radius: 10px;
788
+ border-top-right-radius: 10px;
789
+ height: 31px;
790
+ line-height: 31px;
791
+ padding-left: 15px;
792
+ }
793
+
794
+ .editor {
795
+ margin-left: 10px;
796
+ margin-right: 10px;
797
+ height: 200px;
798
+ border: 1px solid #ccc;
799
+ border-radius: 6px;
800
+ }
801
+
802
+ .editor-top {
803
+ //margin-left: 10px;
804
+ height: 130px;
805
+ width: 100%;
806
+ padding: 8px;
807
+ position: relative;
808
+ overflow-x: hidden;
809
+ overflow-y: scroll;
810
+ }
811
+
812
+ .editor-bottom {
813
+ border-left: 1px solid #ccc;
814
+ display: flex;
815
+ flex-wrap: wrap;
816
+ padding: 5px;
817
+ align-content: flex-start;
818
+ }
819
+
820
+ .body-right-button {
821
+ width: 60px;
822
+ height: 40px;
823
+ }
824
+
825
+ .group-form {
826
+ margin-top: 15px;
827
+ display: flex;
828
+ justify-content: space-between;
829
+ height: 350px;
830
+ }
831
+
832
+ .group-item-left {
833
+ height: 350px;
834
+ border: 1px solid #ccc;
835
+ border-top-left-radius: 6px;
836
+ border-bottom-left-radius: 6px;
837
+ margin-bottom: 5px;
838
+ padding: 0;
839
+ width: 100%;
840
+ }
841
+
842
+ .group-item-right-top {
843
+ height: 350px;
844
+ border: 1px solid #ccc;
845
+ border-radius: 0;
846
+ margin-bottom: 5px;
847
+ width: 100%;
848
+ }
849
+
850
+ .group-item-right-bottom {
851
+ height: 350px;
852
+ border: 1px solid #ccc;
853
+ border-top-right-radius: 6px;
854
+ border-bottom-right-radius: 6px;
855
+ margin-bottom: 5px;
856
+ width: 100%;
857
+ }
858
+
859
+ .item-header {
860
+ border-bottom: 1px solid #ccc;
861
+ height: 29px;
862
+ line-height: 29px;
863
+ padding-left: 15px;
864
+ font-weight: bold;
865
+ }
866
+
867
+ .item-body-left {
868
+ height: 320px;
869
+ overflow-y: auto;
870
+ }
871
+
872
+ .function-list {
873
+ height: 320px;
874
+ overflow-y: auto;
875
+
876
+ :deep(.el-collapse-item__header) {
877
+ font-weight: normal !important;
878
+ }
879
+ }
880
+
881
+ .item-body-right-bottom {
882
+ height: 152px;
883
+ overflow-y: auto;
884
+ }
885
+
886
+ .el-collapse {
887
+ border: none;
888
+ }
889
+
890
+ :deep(.el-dialog) {
891
+ margin-top: 10px !important;
892
+ }
893
+
894
+ :deep(.el-collapse-item__header) {
895
+ padding-left: 10px;
896
+ border: none;
897
+ }
898
+
899
+ :deep(.el-collapse-item__wrap) {
900
+ border: none;
901
+ }
902
+
903
+ :deep(.el-collapse-item__arrow) {
904
+ margin-left: 8px;
905
+ }
906
+
907
+ .field-item {
908
+ display: flex;
909
+ justify-content: space-between;
910
+ align-items: center;
911
+ height: 32px;
912
+ padding-left: 30px;
913
+ padding-right: 15px;
914
+ cursor: pointer;
915
+ }
916
+
917
+ .field-item:hover {
918
+ background-color: #f8f8f8;
919
+ }
920
+
921
+ p::before {
922
+ content: "● ";
923
+ color: #0a5d7c;
924
+ }
925
+
926
+ p {
927
+ height: 24px;
928
+ line-height: 24px;
929
+ padding: 0 15px;
930
+ font-size: 16px;
931
+ color: #0a5d7c;
932
+ }
933
+
934
+ .intro-content {
935
+ padding-left: 30px;
936
+ }
937
+
938
+ .cg {
939
+ color: #0a5d7c;
940
+ }
941
+
942
+ .fname {
943
+ display: inline-block;
944
+ border-radius: 2px;
945
+ padding: 0 5px;
946
+ margin: 1px;
947
+ font-size: 12px;
948
+ line-height: 20px;
949
+ color: #708;
950
+ background: #fff;
951
+ }
952
+
953
+ .cs {
954
+ display: inline-block;
955
+ border-radius: 2px;
956
+ padding: 0 5px;
957
+ margin: 1px;
958
+ color: #fff;
959
+ font-size: 12px;
960
+ line-height: 20px;
961
+ background: #178cdf;
962
+ }
963
+
964
+ :deep(.el-dialog__body) {
965
+ padding: 0;
966
+ }
967
+
968
+ .small-padding-dialog {
969
+ /* margin-top: 0px; */
970
+ }
971
+ </style>