{`${(this.props.valueType == 2 || this.props.valueType === "FORMULA") ? "函数" : "SQL"}公式`}
{
value &&
]}
className="formula-wrapper"
initLoadCss
onCancel={() => {
- this.setState({ formalua: false });
this.props.onCancel();
}}>
{
@@ -427,66 +428,69 @@ export default class FormalFormModal extends React.Component {
}
-
- this.contentProps = input}
- minRows={8}
- maxRows={8}
- value={value}
- onChange={(value) => this.handleChange(value)}
- noResize={true}
- style={{ fontSize: "14px", lineHeight: 1.2 }}
- onKeyDown={this.triggerKeyDown}
- />
-
-
-
-
-
变量
-
- {
- searchGroup && searchGroup.map(item => {
- return
{
- this.handleItemClick(item);
- }}>
- {item.value}
-
- {item.value} 的字段
-
;
- })
- }
-
-
-
-
- {
- searchFields && searchFields.map(item => {
- return (
-
{
- this.handleFieldClick(item);
- }}>
- {item.name}
-
- );
- })
- }
-
-
+
+ {/*value={value} groupParams={groupParams}*/}
+ {/*onChange={(value) => this.handleChange(value)}*/}
+ {/*
*/}
+ {/* this.contentProps = input}*/}
+ {/* minRows={8}*/}
+ {/* maxRows={8}*/}
+ {/* value={value}*/}
+ {/* onChange={(value) => this.handleChange(value)}*/}
+ {/* noResize={true}*/}
+ {/* style={{ fontSize: "14px", lineHeight: 1.2 }}*/}
+ {/* onKeyDown={this.triggerKeyDown}*/}
+ {/* />*/}
+ {/*
*/}
+ {/*
*/}
+ {/*
*/}
+ {/*
*/}
+ {/*
变量
*/}
+ {/*
*/}
+ {/* {*/}
+ {/* searchGroup && searchGroup.map(item => {*/}
+ {/* return
{*/}
+ {/* this.handleItemClick(item);*/}
+ {/* }}>*/}
+ {/* {item.value}*/}
+ {/* */}
+ {/* {item.value} 的字段*/}
+ {/*
;*/}
+ {/* })*/}
+ {/* }*/}
+ {/*
*/}
+ {/*
*/}
+ {/*
*/}
+ {/*
*/}
+ {/* {*/}
+ {/* searchFields && searchFields.map(item => {*/}
+ {/* return (*/}
+ {/*
{*/}
+ {/* this.handleFieldClick(item);*/}
+ {/* }}>*/}
+ {/* {item.name}*/}
+ {/*
*/}
+ {/* );*/}
+ {/* })*/}
+ {/* }*/}
+ {/*
*/}
+ {/*
*/}
);
From d2f7aa8d0044b6fab373acc0827fdaa886dfb0e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com>
Date: Fri, 28 Apr 2023 10:51:06 +0800
Subject: [PATCH 08/17] =?UTF-8?q?=E4=BA=A7=E5=93=81-=E5=85=AC=E5=BC=8F?=
=?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../hrmSalary/components/excelEditor/index.js | 97 ++-----------------
.../hrmSalary/pages/equationEditor/index.js | 20 +++-
.../pages/salaryItem/formalFormModal.js | 6 +-
3 files changed, 28 insertions(+), 95 deletions(-)
diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.js b/pc4mobx/hrmSalary/components/excelEditor/index.js
index b04ce534..42237ec6 100644
--- a/pc4mobx/hrmSalary/components/excelEditor/index.js
+++ b/pc4mobx/hrmSalary/components/excelEditor/index.js
@@ -1,5 +1,4 @@
import React, { Component } from "react";
-import ReactDOM from "react-dom";
import { Button } from "antd";
import { Controlled as CodeMirror } from "react-codemirror2";
import { keyboardBaseBtns } from "./constants";
@@ -34,71 +33,12 @@ class ExcelEditor extends Component {
insertText = text => {
const cursor = this.editorRef.getCursor();
this.editorRef.replaceRange(text, cursor);
+ this.editorRef.refresh();
+ this.editorRef.focus();
};
- replaceToWidget = (editor, data, value, inlineWidgetOpts) => {
+ replaceToWidget = (editor) => {
editor.getAllMarks().forEach(m => m.clear());
- editor.refresh();
- editor.focus();
- // let posInfos = _.flatMap(_.keys(inlineWidgetOpts), widgetName => {
- // let { regex, render } = inlineWidgetOpts[widgetName];
- // let res = [], newRe = new RegExp(regex, "g"), m;
- // do {
- // m = newRe.exec(value);
- // if (m) {
- // const mountToDom = document.createElement("span");
- // let text = m[0];
- // res.push({
- // widgetName,
- // text,
- // startAt: m.index,
- // endAt: m.index + text.length,
- // render: () => {
- // let x = `((...args) => args)${text.replace(new RegExp(`^${widgetName}`), "")}`;
- // let args = eval(x);
- // return render(...args);
- // },
- // mountToDom: mountToDom
- // });
- // }
- // } while (m);
- // return res;
- // });
- // posInfos.forEach(posInfo => {
- // let from = { line: 0, ch: posInfo.startAt };
- // let to = { line: 0, ch: posInfo.endAt };
- // editor.markText(from, to, {
- // replacedWith: posInfo.mountToDom,
- // clearWhenEmpty: false
- // });
- // });
- // this.setState({
- // widgets: posInfos
- // }, () => {
- // editor.refresh();
- // editor.focus();
- // });
- };
- /*
- * Author: 黎永顺
- * Description:格式化
- * Params:
- * Date: 2023/4/13
- */
- autoFormatSelection = () => {
- let editor = this.editorRef.editor;
- if (this.props.type != "sql") {
- const script_length = editor.getValue().length;
- const startPos = { line: 0, ch: 0, sticky: null };
- const endPos = editor.doc.posFromIndex(script_length);
- // editor.setSelection(startPos, endPos);
- // editor.autoFormatRange(startPos, endPos);
- // editor.commentRange(false, startPos, endPos);
- } else {
- let splCont = "";
- splCont = editor.getValue();
- // editor.setValue(sqlFormatter.format(splCont));
- }
};
handleVariSelect = str => this.insertText(`{${str}}`);
handleFuncSelect = str => {
@@ -107,6 +47,8 @@ class ExcelEditor extends Component {
this.timer = setTimeout(() => {
const { line, ch } = this.editorRef.getCursor();
this.editorRef.setCursor({ line, ch: ch - 1 });
+ this.editorRef.refresh();
+ this.editorRef.focus();
}, 100);
};
handleEditorRedo = () => {
@@ -137,17 +79,6 @@ class ExcelEditor extends Component {
};
render() {
- const inlineWidgetOpts = {
- useObject: {
- regex: /useObject\("[^)]+"\)/,
- render: (objId) => {
- return (
-
{objId}
- );
- }
- }
- };
- const { widgets } = this.state;
const { groupParams = {} } = this.props;
const { referenceType } = groupParams;
return (
@@ -158,10 +89,11 @@ class ExcelEditor extends Component {
editorDidMount={editor => this.editorRef = editor}
value={this.state.value}
onBeforeChange={(editor, data, value) => {
+ console.log(value);
this.setState({ value });
}}
onChange={(editor, data, value) => {
- this.replaceToWidget(editor, data, value, inlineWidgetOpts);
+ this.replaceToWidget(editor, data, value);
}}
options={{
lineNumbers: false,
@@ -179,11 +111,6 @@ class ExcelEditor extends Component {
}}
onKeyDown={(_, { keyCode }) => keyCode === 8 && this.handleBackSpaceRedo()}
/>
- {widgets.map((w, i) => {
- return (
-
- );
- })}
{
referenceType !== "sql" &&
@@ -220,13 +147,3 @@ class ExcelEditor extends Component {
}
export default ExcelEditor;
-
-class Widget extends React.Component {
- render() {
- let { info } = this.props;
- return ReactDOM.createPortal(
- info.render(),
- info.mountToDom
- );
- }
-}
diff --git a/pc4mobx/hrmSalary/pages/equationEditor/index.js b/pc4mobx/hrmSalary/pages/equationEditor/index.js
index e205a1a5..a31d97d1 100644
--- a/pc4mobx/hrmSalary/pages/equationEditor/index.js
+++ b/pc4mobx/hrmSalary/pages/equationEditor/index.js
@@ -1,10 +1,28 @@
import React, { Component } from "react";
+import { Button, Modal } from "antd";
import ExcelEditor from "../../components/excelEditor";
class Index extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ title: "DialogTitle",
+ visible: false,
+ lvisible: false
+ };
+ }
+
render() {
return (
- this.handleChange(value)}/>
{/**/}
{/* this.contentProps = input}*/}
From a1150300722e83c13fa7173498ec4084eb292532 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com>
Date: Fri, 28 Apr 2023 11:30:05 +0800
Subject: [PATCH 09/17] =?UTF-8?q?=E4=BA=A7=E5=93=81-=E5=85=AC=E5=BC=8F?=
=?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../hrmSalary/components/excelEditor/index.js | 20 +++++++++----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.js b/pc4mobx/hrmSalary/components/excelEditor/index.js
index 42237ec6..16a54908 100644
--- a/pc4mobx/hrmSalary/components/excelEditor/index.js
+++ b/pc4mobx/hrmSalary/components/excelEditor/index.js
@@ -12,31 +12,26 @@ class ExcelEditor extends Component {
constructor(props) {
super(props);
this.state = {
- value: "",
- widgets: []
+ value: ""
};
this.editorRef = null;
this.timer = null;
}
+ componentWillReceiveProps(nextProps, nextContext) {
+ if (nextProps.value !== this.props.value && nextProps.value) this.setState({ value: nextProps.value });
+ }
componentWillUnmount() {
if (this.timer) clearInterval(this.timer);
}
- /*
- * Author: 黎永顺
- * Description: 插入字符
- * Params:
- * Date: 2023/4/13
- */
insertText = text => {
const cursor = this.editorRef.getCursor();
this.editorRef.replaceRange(text, cursor);
this.editorRef.refresh();
this.editorRef.focus();
};
-
replaceToWidget = (editor) => {
editor.getAllMarks().forEach(m => m.clear());
};
@@ -64,6 +59,8 @@ class ExcelEditor extends Component {
} else {
this.editorRef.replaceRange("", { line, ch: ch - 1 }, { line, ch });
}
+ this.editorRef.refresh();
+ this.editorRef.focus();
};
handleBackSpaceRedo = () => {
const { ch, line } = this.editorRef.getCursor();
@@ -76,6 +73,8 @@ class ExcelEditor extends Component {
this.editorRef.replaceRange("", { line, ch: codeValue.slice(0, ch).lastIndexOf("{") + 1 }, { line, ch });
}
}
+ this.editorRef.refresh();
+ this.editorRef.focus();
};
render() {
@@ -89,8 +88,7 @@ class ExcelEditor extends Component {
editorDidMount={editor => this.editorRef = editor}
value={this.state.value}
onBeforeChange={(editor, data, value) => {
- console.log(value);
- this.setState({ value });
+ this.setState({ value }, () => this.props.onChange(this.state.value));
}}
onChange={(editor, data, value) => {
this.replaceToWidget(editor, data, value);
From 6f0c1044ad5260da62a8158d59f3702a495dc7f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com>
Date: Fri, 28 Apr 2023 16:11:56 +0800
Subject: [PATCH 10/17] =?UTF-8?q?=E4=BA=A7=E5=93=81-=E5=85=AC=E5=BC=8F?=
=?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../excelEditor/extendCodeMirror.js | 25 ++++++++------
.../hrmSalary/components/excelEditor/index.js | 34 ++++++++++++++++---
.../hrmSalary/pages/equationEditor/index.js | 6 ++--
3 files changed, 46 insertions(+), 19 deletions(-)
diff --git a/pc4mobx/hrmSalary/components/excelEditor/extendCodeMirror.js b/pc4mobx/hrmSalary/components/excelEditor/extendCodeMirror.js
index 342f2761..e1b34b44 100644
--- a/pc4mobx/hrmSalary/components/excelEditor/extendCodeMirror.js
+++ b/pc4mobx/hrmSalary/components/excelEditor/extendCodeMirror.js
@@ -1,11 +1,11 @@
// extendCodeMirror.js
/* eslint-disable */
-import * as CodeMirror from 'codemirror';
+import * as CodeMirror from "codemirror";
CodeMirror.extendMode("css", {
commentStart: "/*",
commentEnd: "*/",
- newlineAfterToken: function(type, content) {
+ newlineAfterToken: function (type, content) {
return /^[;{}]$/.test(content);
}
});
@@ -14,9 +14,9 @@ CodeMirror.extendMode("javascript", {
commentStart: "/*",
commentEnd: "*/",
// FIXME semicolons inside of for
- newlineAfterToken: function(type, content, textAfter, state) {
+ newlineAfterToken: function (type, content, textAfter, state) {
if (this.jsonMode) {
- return /^[\[,{]$/.test(content) || /^}/.test(textAfter)|| /^]/.test(textAfter);
+ return /^[\[,{]$/.test(content) || /^}/.test(textAfter) || /^]/.test(textAfter);
} else {
if (content == ";" && state.lexical && state.lexical.type == ")") return false;
return /^[;{}]$/.test(content) && !/^;/.test(textAfter);
@@ -27,7 +27,7 @@ CodeMirror.extendMode("javascript", {
CodeMirror.extendMode("xml", {
commentStart: "",
- newlineAfterToken: function(type, content, textAfter) {
+ newlineAfterToken: function (type, content, textAfter) {
return type == "tag" && />$/.test(content) || /^ {
+ const { isFormter } = this.state;
+ if (isFormter) {
+ const script_length = this.editorRef.getValue().length;
+ const startPos = { line: 0, ch: 0, sticky: null };
+ const endPos = this.editorRef.doc.posFromIndex(script_length);
+ this.editorRef.setSelection(startPos, endPos);
+ this.editorRef.autoFormatRange(startPos, endPos);
+ this.editorRef.commentRange(true, startPos, endPos);
+ } else {
+ this.editorRef.undo();
+ this.editorRef.undo();
+ }
+ };
insertText = text => {
const cursor = this.editorRef.getCursor();
this.editorRef.replaceRange(text, cursor);
@@ -78,6 +98,7 @@ class ExcelEditor extends Component {
};
render() {
+ const { isFormter } = this.state;
const { groupParams = {} } = this.props;
const { referenceType } = groupParams;
return (
@@ -95,12 +116,11 @@ class ExcelEditor extends Component {
}}
options={{
lineNumbers: false,
- mode: { name: this.props.type === "sql" ? "text/x-sql" : "application/json" },
+ mode: "javascript",
autofocus: false,
styleActiveLine: true,
lineWrapping: true,
- foldGutter: true,
- gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
+ matchBrackets: true,
lint: false,
indentUnit: 2,
cursorHeight: 0.85,
@@ -130,9 +150,13 @@ class ExcelEditor extends Component {
+ onClick={() => this.setState({ value: "" })}>C