From 644113efcbd606e4b3134fac7142b3491ce8bc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Thu, 13 Apr 2023 10:00:24 +0800 Subject: [PATCH 01/17] =?UTF-8?q?=E5=85=AC=E5=BC=8F=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E7=BB=84=E4=BB=B6=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/excelEditor/constants.js | 16 + .../excelEditor/extendCodeMirror.js | 111 +++++ .../hrmSalary/components/excelEditor/index.js | 112 +++++ .../components/excelEditor/index.less | 450 ++++++++++++++++++ pc4mobx/hrmSalary/index.js | 2 + .../hrmSalary/pages/equationEditor/index.js | 12 + 6 files changed, 703 insertions(+) create mode 100644 pc4mobx/hrmSalary/components/excelEditor/constants.js create mode 100644 pc4mobx/hrmSalary/components/excelEditor/extendCodeMirror.js create mode 100644 pc4mobx/hrmSalary/components/excelEditor/index.js create mode 100644 pc4mobx/hrmSalary/components/excelEditor/index.less create mode 100644 pc4mobx/hrmSalary/pages/equationEditor/index.js diff --git a/pc4mobx/hrmSalary/components/excelEditor/constants.js b/pc4mobx/hrmSalary/components/excelEditor/constants.js new file mode 100644 index 00000000..a113371b --- /dev/null +++ b/pc4mobx/hrmSalary/components/excelEditor/constants.js @@ -0,0 +1,16 @@ +export const keyboardBaseBtns=[ + { key:"1", label: "+" }, + { key:"2", label: "-" }, + { key:"3", label: ">" }, + { key:"4", label: ">=" }, + { key:"5", label: "=" }, + { key:"6", label: "*" }, + { key:"7", label: "/" }, + { key:"8", label: "<" }, + { key:"9", label: "<=" }, + { key:"10", label: "!=" }, + { key:"11", label: "(" }, + { key:"12", label: ")" }, + { key:"13", label: "%" }, + { key:"space", label: "space" }, +] diff --git a/pc4mobx/hrmSalary/components/excelEditor/extendCodeMirror.js b/pc4mobx/hrmSalary/components/excelEditor/extendCodeMirror.js new file mode 100644 index 00000000..342f2761 --- /dev/null +++ b/pc4mobx/hrmSalary/components/excelEditor/extendCodeMirror.js @@ -0,0 +1,111 @@ +// extendCodeMirror.js +/* eslint-disable */ +import * as CodeMirror from 'codemirror'; + +CodeMirror.extendMode("css", { + commentStart: "/*", + commentEnd: "*/", + newlineAfterToken: function(type, content) { + return /^[;{}]$/.test(content); + } +}); + +CodeMirror.extendMode("javascript", { + commentStart: "/*", + commentEnd: "*/", +// FIXME semicolons inside of for + newlineAfterToken: function(type, content, textAfter, state) { + if (this.jsonMode) { + return /^[\[,{]$/.test(content) || /^}/.test(textAfter)|| /^]/.test(textAfter); + } else { + if (content == ";" && state.lexical && state.lexical.type == ")") return false; + return /^[;{}]$/.test(content) && !/^;/.test(textAfter); + } + } +}); + +CodeMirror.extendMode("xml", { + commentStart: "", + newlineAfterToken: function(type, content, textAfter) { + return type == "tag" && />$/.test(content) || /^ -1 && endIndex > -1 && endIndex > startIndex) { + // Take string till comment start + selText = selText.substr(0, startIndex) + // From comment start till comment end + + selText.substring(startIndex + curMode.commentStart.length, endIndex) + // From comment end till string end + + selText.substr(endIndex + curMode.commentEnd.length); + } + cm.replaceRange(selText, from, to); + } + }); +}); + +// Applies automatic mode-aware indentation to the specified range +CodeMirror.defineExtension("autoIndentRange", function (from, to) { + var cmInstance = this; + this.operation(function () { + for (var i = from.line; i <= to.line; i++) { + cmInstance.indentLine(i, "smart"); + } + }); +}); + +// Applies automatic formatting to the specified range +CodeMirror.defineExtension("autoFormatRange", function (from, to) { + var cm = this; + var outer = cm.getMode(), text = cm.getRange(from, to).split("\n"); + var state = CodeMirror.copyState(outer, cm.getTokenAt(from).state); + var tabSize = cm.getOption("tabSize"); + + var out = "", lines = 0, atSol = from.ch == 0; + function newline() { + out += "\n"; + atSol = true; + ++lines; + } + + for (var i = 0; i < text.length; ++i) { + var stream = new CodeMirror.StringStream(text[i], tabSize); + while (!stream.eol()) { + var inner = CodeMirror.innerMode(outer, state); + var style = outer.token(stream, state), cur = stream.current(); + stream.start = stream.pos; + if (!atSol || /\S/.test(cur)) { + out += cur; + atSol = false; + } + if (!atSol && inner.mode.newlineAfterToken && + inner.mode.newlineAfterToken(style, cur, stream.string.slice(stream.pos) || text[i+1] || "", inner.state)) + newline(); + } + if (!stream.pos && outer.blankLine) outer.blankLine(state); + if (!atSol) newline(); + } + + cm.operation(function () { + cm.replaceRange(out, from, to); + for (var cur = from.line + 1, end = from.line + lines; cur <= end; ++cur) + cm.indentLine(cur, "smart"); + cm.setSelection(from, cm.getCursor(false)); + }); +}); +// console.log("初始化CodeMirror完成"); +export default CodeMirror; diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.js b/pc4mobx/hrmSalary/components/excelEditor/index.js new file mode 100644 index 00000000..6d9db2d2 --- /dev/null +++ b/pc4mobx/hrmSalary/components/excelEditor/index.js @@ -0,0 +1,112 @@ +import React, { Component } from "react"; +import { Button } from "antd"; +import { UnControlled as CodeMirror } from "react-codemirror2"; +import { keyboardBaseBtns } from "./constants"; +import cs from "classnames"; +import "./index.less"; + +import "codemirror/lib/codemirror.css"; +import "codemirror/lib/codemirror.js"; + +import "codemirror/theme/dracula.css"; //主题 +//代码折叠 +import "codemirror/addon/fold/foldgutter.css"; +import "codemirror/addon/lint/lint.css"; +import "codemirror/addon/fold/foldcode.js"; +import "codemirror/addon/fold/foldgutter.js"; +import "codemirror/addon/fold/brace-fold.js"; +import "codemirror/addon/hint/javascript-hint.js"; +import "codemirror/addon/hint/show-hint.js"; +import "codemirror/addon/lint/lint.js"; +import "codemirror/addon/lint/json-lint.js"; +import "codemirror/addon/lint/javascript-lint.js"; +import "codemirror/addon/display/placeholder.js"; +import "codemirror/mode/javascript/javascript.js"; +import "codemirror/mode/sql/sql.js"; + +// const sqlFormatter = require('sql-formatter'); + +class ExcelEditor extends Component { + constructor(props) { + super(props); + this.state = { + value: "" + }; + } + + + render() { + return ( + +
+
+ { + this.setState({ value }); + }} + onChange={(editor, value) => { + console.log("controlled", { value }); + }} + options={{ + lineNumbers: false, + mode: { name: this.props.type === "sql" ? "text/x-sql" : "application/json" }, + autofocus: false, + styleActiveLine: true, + lineWrapping: true, + foldGutter: true, + gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], + lint: false, + indentUnit: 2, + cursorHeight: 0.85, + placeholder: "" + }} + /> +
+
+
+
+ { + _.map(keyboardBaseBtns, item => { + const { key, label } = item; + return ; + }) + } +
+
+ + +
+
+
+
+
+
+
+
变量
+
+
+
+
+
+
函数
+
+
+
+
+
+
提示
+
+
+
+
+
+ ); + } +} + +export default ExcelEditor; diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.less b/pc4mobx/hrmSalary/components/excelEditor/index.less new file mode 100644 index 00000000..0cb45a6b --- /dev/null +++ b/pc4mobx/hrmSalary/components/excelEditor/index.less @@ -0,0 +1,450 @@ +.excel-codeWrap { + width: 100%; + display: flex; + justify-content: space-around; + padding: 0 0 8px; + + .excel-codeBox { + flex: 1; + overflow: auto; + background: #fff; + box-sizing: content-box; + border: 1px solid #e5e5e5; + + .esb-algorithm-sourceContent { + .CodeMirror { + } + } + } + + .excel-codeBox-keyboard { + width: 272px; + min-height: 232px; + padding: 20px; + background: #fff; + border: 1px solid #e5e5e5; + border-left: none; + + .excel-codeBox-keyboard-operate { + display: flex; + + .excel-codeBox-keyboard-operate-content { + display: flex; + flex-wrap: wrap; + flex: 1; + + .excel-codeBox-keyboard-base { + width: 30px; + height: 30px; + text-align: center; + margin: 0 10px 10px 0; + } + + .excel-codeBox-keyboard-space { + width: 70px; + height: 30px; + } + } + + .excel-codeBox-keyboard-operate-clear { + width: 30px; + + .excel-codeBox-keyboard-del { + width: 30px; + height: 70px; + } + + .excel-codeBox-keyboard-clear { + width: 30px; + height: 30px; + margin-top: 10px; + } + } + } + } +} + +.excel-codeAction { + width: 100%; + display: flex; + justify-content: space-between; + + .excel-codeAction-item:last-child { + margin-right: 0; + + .excel-codeAction-header-title { + color: rgb(217, 82, 189); + } + } + + .excel-codeAction-item { + width: 33%; + min-height: 317px; + flex: 1; + background: #fff; + border: 1px solid #e5e5e5; + margin-right: 16px; + + .excel-codeAction-header { + display: flex; + padding: 10px 16px; + border-bottom: 1px solid #e5e5e5; + + .excel-codeAction-header-title { + flex: 1; + font-weight: 600; + } + } + } +} +// +///* BASICS */ +// +//.CodeMirror { +// /* Set height, width, borders, and global font properties here */ +// font-family: monospace; +// height: 300px; +// color: black; +// direction: ltr; +//} +// +///* PADDING */ +// +//.CodeMirror-lines { +// padding: 4px 0; /* Vertical padding around content */ +//} +//.CodeMirror pre.CodeMirror-line, +//.CodeMirror pre.CodeMirror-line-like { +// padding: 0 4px; /* Horizontal padding of content */ +//} +// +//.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { +// background-color: white; /* The little square between H and V scrollbars */ +//} +// +///* GUTTER */ +// +//.CodeMirror-gutters { +// border-right: 1px solid #ddd; +// background-color: #f7f7f7; +// white-space: nowrap; +//} +//.CodeMirror-linenumbers {} +//.CodeMirror-linenumber { +// padding: 0 3px 0 5px; +// min-width: 20px; +// text-align: right; +// color: #999; +// white-space: nowrap; +//} +// +//.CodeMirror-guttermarker { color: black; } +//.CodeMirror-guttermarker-subtle { color: #999; } +// +///* CURSOR */ +// +//.CodeMirror-cursor { +// border-left: 1px solid black; +// border-right: none; +// width: 0; +//} +///* Shown when moving in bi-directional text */ +//.CodeMirror div.CodeMirror-secondarycursor { +// border-left: 1px solid silver; +//} +//.cm-fat-cursor .CodeMirror-cursor { +// width: auto; +// border: 0 !important; +// background: #7e7; +//} +//.cm-fat-cursor div.CodeMirror-cursors { +// z-index: 1; +//} +//.cm-fat-cursor-mark { +// background-color: rgba(20, 255, 20, 0.5); +// -webkit-animation: blink 1.06s steps(1) infinite; +// -moz-animation: blink 1.06s steps(1) infinite; +// animation: blink 1.06s steps(1) infinite; +//} +//.cm-animate-fat-cursor { +// width: auto; +// border: 0; +// -webkit-animation: blink 1.06s steps(1) infinite; +// -moz-animation: blink 1.06s steps(1) infinite; +// animation: blink 1.06s steps(1) infinite; +// background-color: #7e7; +//} +//@-moz-keyframes blink { +// 0% {} +// 50% { background-color: transparent; } +// 100% {} +//} +//@-webkit-keyframes blink { +// 0% {} +// 50% { background-color: transparent; } +// 100% {} +//} +//@keyframes blink { +// 0% {} +// 50% { background-color: transparent; } +// 100% {} +//} +// +///* Can style cursor different in overwrite (non-insert) mode */ +//.CodeMirror-overwrite .CodeMirror-cursor {} +// +//.cm-tab { display: inline-block; text-decoration: inherit; } +// +//.CodeMirror-rulers { +// position: absolute; +// left: 0; right: 0; top: -50px; bottom: 0; +// overflow: hidden; +//} +//.CodeMirror-ruler { +// border-left: 1px solid #ccc; +// top: 0; bottom: 0; +// position: absolute; +//} +// +///* DEFAULT THEME */ +// +//.cm-s-default .cm-header {color: blue;} +//.cm-s-default .cm-quote {color: #090;} +//.cm-negative {color: #d44;} +//.cm-positive {color: #292;} +//.cm-header, .cm-strong {font-weight: bold;} +//.cm-em {font-style: italic;} +//.cm-link {text-decoration: underline;} +//.cm-strikethrough {text-decoration: line-through;} +// +//.cm-s-default .cm-keyword {color: #708;} +//.cm-s-default .cm-atom {color: #219;} +//.cm-s-default .cm-number {color: #164;} +//.cm-s-default .cm-def {color: #00f;} +//.cm-s-default .cm-variable, +//.cm-s-default .cm-punctuation, +//.cm-s-default .cm-property, +//.cm-s-default .cm-operator {} +//.cm-s-default .cm-variable-2 {color: #05a;} +//.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;} +//.cm-s-default .cm-comment {color: #a50;} +//.cm-s-default .cm-string {color: #a11;} +//.cm-s-default .cm-string-2 {color: #f50;} +//.cm-s-default .cm-meta {color: #555;} +//.cm-s-default .cm-qualifier {color: #555;} +//.cm-s-default .cm-builtin {color: #30a;} +//.cm-s-default .cm-bracket {color: #997;} +//.cm-s-default .cm-tag {color: #170;} +//.cm-s-default .cm-attribute {color: #00c;} +//.cm-s-default .cm-hr {color: #999;} +//.cm-s-default .cm-link {color: #00c;} +// +//.cm-s-default .cm-error {color: #f00;} +//.cm-invalidchar {color: #f00;} +// +//.CodeMirror-composing { border-bottom: 2px solid; } +// +///* Default styles for common addons */ +// +//div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;} +//div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} +//.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); } +//.CodeMirror-activeline-background {background: #e8f2ff;} +// +///* STOP */ +// +///* The rest of this file contains styles related to the mechanics of +// the editor. You probably shouldn't touch them. */ +// +//.CodeMirror { +// position: relative; +// overflow: hidden; +// background: white; +//} +// +//.CodeMirror-scroll { +// overflow: scroll !important; /* Things will break if this is overridden */ +// /* 50px is the magic margin used to hide the element's real scrollbars */ +// /* See overflow: hidden in .CodeMirror */ +// margin-bottom: -50px; margin-right: -50px; +// padding-bottom: 50px; +// height: 100%; +// outline: none; /* Prevent dragging from highlighting the element */ +// position: relative; +//} +//.CodeMirror-sizer { +// position: relative; +// border-right: 50px solid transparent; +//} +// +///* The fake, visible scrollbars. Used to force redraw during scrolling +// before actual scrolling happens, thus preventing shaking and +// flickering artifacts. */ +//.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { +// position: absolute; +// z-index: 6; +// display: none; +// outline: none; +//} +//.CodeMirror-vscrollbar { +// right: 0; top: 0; +// overflow-x: hidden; +// overflow-y: scroll; +//} +//.CodeMirror-hscrollbar { +// bottom: 0; left: 0; +// overflow-y: hidden; +// overflow-x: scroll; +//} +//.CodeMirror-scrollbar-filler { +// right: 0; bottom: 0; +//} +//.CodeMirror-gutter-filler { +// left: 0; bottom: 0; +//} +// +//.CodeMirror-gutters { +// position: absolute; left: 0; top: 0; +// min-height: 100%; +// z-index: 3; +//} +//.CodeMirror-gutter { +// white-space: normal; +// height: 100%; +// display: inline-block; +// vertical-align: top; +// margin-bottom: -50px; +//} +//.CodeMirror-gutter-wrapper { +// position: absolute; +// z-index: 4; +// background: none !important; +// border: none !important; +//} +//.CodeMirror-gutter-background { +// position: absolute; +// top: 0; bottom: 0; +// z-index: 4; +//} +//.CodeMirror-gutter-elt { +// position: absolute; +// cursor: default; +// z-index: 4; +//} +//.CodeMirror-gutter-wrapper ::selection { background-color: transparent } +//.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent } +// +//.CodeMirror-lines { +// cursor: text; +// min-height: 1px; /* prevents collapsing before first draw */ +//} +//.CodeMirror pre.CodeMirror-line, +//.CodeMirror pre.CodeMirror-line-like { +// /* Reset some styles that the rest of the page might have set */ +// -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; +// border-width: 0; +// background: transparent; +// font-family: inherit; +// font-size: inherit; +// margin: 0; +// white-space: pre; +// word-wrap: normal; +// line-height: inherit; +// color: inherit; +// z-index: 2; +// position: relative; +// overflow: visible; +// -webkit-tap-highlight-color: transparent; +// -webkit-font-variant-ligatures: contextual; +// font-variant-ligatures: contextual; +//} +//.CodeMirror-wrap pre.CodeMirror-line, +//.CodeMirror-wrap pre.CodeMirror-line-like { +// word-wrap: break-word; +// white-space: pre-wrap; +// word-break: normal; +//} +// +//.CodeMirror-linebackground { +// position: absolute; +// left: 0; right: 0; top: 0; bottom: 0; +// z-index: 0; +//} +// +//.CodeMirror-linewidget { +// position: relative; +// z-index: 2; +// padding: 0.1px; /* Force widget margins to stay inside of the container */ +//} +// +//.CodeMirror-widget {} +// +//.CodeMirror-rtl pre { direction: rtl; } +// +//.CodeMirror-code { +// outline: none; +//} +// +///* Force content-box sizing for the elements where we expect it */ +//.CodeMirror-scroll, +//.CodeMirror-sizer, +//.CodeMirror-gutter, +//.CodeMirror-gutters, +//.CodeMirror-linenumber { +// -moz-box-sizing: content-box; +// box-sizing: content-box; +//} +// +//.CodeMirror-measure { +// position: absolute; +// width: 100%; +// height: 0; +// overflow: hidden; +// visibility: hidden; +//} +// +//.CodeMirror-cursor { +// position: absolute; +// pointer-events: none; +//} +//.CodeMirror-measure pre { position: static; } +// +//div.CodeMirror-cursors { +// visibility: hidden; +// position: relative; +// z-index: 3; +//} +//div.CodeMirror-dragcursors { +// visibility: visible; +//} +// +//.CodeMirror-focused div.CodeMirror-cursors { +// visibility: visible; +//} +// +//.CodeMirror-selected { background: #d9d9d9; } +//.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } +//.CodeMirror-crosshair { cursor: crosshair; } +//.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; } +//.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; } +// +//.cm-searching { +// background-color: #ffa; +// background-color: rgba(255, 255, 0, .4); +//} +// +///* Used to force a border model for a node */ +//.cm-force-border { padding-right: .1px; } +// +//@media print { +// /* Hide the cursor when printing */ +// .CodeMirror div.CodeMirror-cursors { +// visibility: hidden; +// } +//} +// +///* See issue #2901 */ +//.cm-tab-wrap-hack:after { content: ''; } +// +///* Help users use markselection to safely style text background */ +//span.CodeMirror-selectedtext { background: none; } diff --git a/pc4mobx/hrmSalary/index.js b/pc4mobx/hrmSalary/index.js index b59a534a..64a4f803 100644 --- a/pc4mobx/hrmSalary/index.js +++ b/pc4mobx/hrmSalary/index.js @@ -32,6 +32,7 @@ import SysConfig from "./pages/sysConfig"; import RuleConfig from "./pages/ruleConfig"; import Appconfig from "./pages/appConfig"; import FieldManagement from "./pages/fieldManagement"; +import EquationEditor from "./pages/equationEditor"; import stores from "./stores"; import "./style/index"; @@ -150,6 +151,7 @@ const Routes = ( + ); diff --git a/pc4mobx/hrmSalary/pages/equationEditor/index.js b/pc4mobx/hrmSalary/pages/equationEditor/index.js new file mode 100644 index 00000000..e205a1a5 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/equationEditor/index.js @@ -0,0 +1,12 @@ +import React, { Component } from "react"; +import ExcelEditor from "../../components/excelEditor"; + +class Index extends Component { + render() { + return ( + + ); + } +} + +export default Index; From 247432ebdeb3e285a9d3f9d75840e1feb9be6f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Thu, 13 Apr 2023 13:26:43 +0800 Subject: [PATCH 02/17] =?UTF-8?q?=E5=85=AC=E5=BC=8F=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E7=BB=84=E4=BB=B6=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hrmSalary/components/excelEditor/index.js | 89 ++++- .../components/excelEditor/index.less | 368 +----------------- 2 files changed, 97 insertions(+), 360 deletions(-) diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.js b/pc4mobx/hrmSalary/components/excelEditor/index.js index 6d9db2d2..6f69e51c 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/index.js +++ b/pc4mobx/hrmSalary/components/excelEditor/index.js @@ -1,6 +1,6 @@ import React, { Component } from "react"; import { Button } from "antd"; -import { UnControlled as CodeMirror } from "react-codemirror2"; +import { Controlled as CodeMirror } from "react-codemirror2"; import { keyboardBaseBtns } from "./constants"; import cs from "classnames"; import "./index.less"; @@ -8,7 +8,6 @@ import "./index.less"; import "codemirror/lib/codemirror.css"; import "codemirror/lib/codemirror.js"; -import "codemirror/theme/dracula.css"; //主题 //代码折叠 import "codemirror/addon/fold/foldgutter.css"; import "codemirror/addon/lint/lint.css"; @@ -30,24 +29,102 @@ class ExcelEditor extends Component { constructor(props) { super(props); this.state = { - value: "" + value: "", + widgets: [] }; + this.editorRef = null; } + replaceToWidget = (editor, data, value, inlineWidgetOpts) => { + editor.getAllMarks().forEach(m => m.clear()); + 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)); + } + }; render() { + const inlineWidgetOpts = { + useObject: { + regex: /useObject\("[^)]+"\)/, + render: (objId) => { + return ( +
alert(objId)} + >{objId}
+ ); + } + } + }; return (
this.editorRef = editor} value={this.state.value} onBeforeChange={(editor, data, value) => { this.setState({ value }); }} - onChange={(editor, value) => { - console.log("controlled", { value }); + onChange={(editor, data, value) => { + this.replaceToWidget(editor, data, value, inlineWidgetOpts); }} options={{ lineNumbers: false, diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.less b/pc4mobx/hrmSalary/components/excelEditor/index.less index 0cb45a6b..964e9395 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/index.less +++ b/pc4mobx/hrmSalary/components/excelEditor/index.less @@ -11,9 +11,20 @@ box-sizing: content-box; border: 1px solid #e5e5e5; - .esb-algorithm-sourceContent { - .CodeMirror { - } + .CodeMirror-scroll { + overflow-x: visible !important; + padding: 4px; + } + + .CodeMirror-sizer { + margin-left: 0 !important; + } + + .CodeMirror-gutters { + border-right: none; + background-color: #f7f7f7; + opacity: 0; + display: none; } } @@ -97,354 +108,3 @@ } } } -// -///* BASICS */ -// -//.CodeMirror { -// /* Set height, width, borders, and global font properties here */ -// font-family: monospace; -// height: 300px; -// color: black; -// direction: ltr; -//} -// -///* PADDING */ -// -//.CodeMirror-lines { -// padding: 4px 0; /* Vertical padding around content */ -//} -//.CodeMirror pre.CodeMirror-line, -//.CodeMirror pre.CodeMirror-line-like { -// padding: 0 4px; /* Horizontal padding of content */ -//} -// -//.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { -// background-color: white; /* The little square between H and V scrollbars */ -//} -// -///* GUTTER */ -// -//.CodeMirror-gutters { -// border-right: 1px solid #ddd; -// background-color: #f7f7f7; -// white-space: nowrap; -//} -//.CodeMirror-linenumbers {} -//.CodeMirror-linenumber { -// padding: 0 3px 0 5px; -// min-width: 20px; -// text-align: right; -// color: #999; -// white-space: nowrap; -//} -// -//.CodeMirror-guttermarker { color: black; } -//.CodeMirror-guttermarker-subtle { color: #999; } -// -///* CURSOR */ -// -//.CodeMirror-cursor { -// border-left: 1px solid black; -// border-right: none; -// width: 0; -//} -///* Shown when moving in bi-directional text */ -//.CodeMirror div.CodeMirror-secondarycursor { -// border-left: 1px solid silver; -//} -//.cm-fat-cursor .CodeMirror-cursor { -// width: auto; -// border: 0 !important; -// background: #7e7; -//} -//.cm-fat-cursor div.CodeMirror-cursors { -// z-index: 1; -//} -//.cm-fat-cursor-mark { -// background-color: rgba(20, 255, 20, 0.5); -// -webkit-animation: blink 1.06s steps(1) infinite; -// -moz-animation: blink 1.06s steps(1) infinite; -// animation: blink 1.06s steps(1) infinite; -//} -//.cm-animate-fat-cursor { -// width: auto; -// border: 0; -// -webkit-animation: blink 1.06s steps(1) infinite; -// -moz-animation: blink 1.06s steps(1) infinite; -// animation: blink 1.06s steps(1) infinite; -// background-color: #7e7; -//} -//@-moz-keyframes blink { -// 0% {} -// 50% { background-color: transparent; } -// 100% {} -//} -//@-webkit-keyframes blink { -// 0% {} -// 50% { background-color: transparent; } -// 100% {} -//} -//@keyframes blink { -// 0% {} -// 50% { background-color: transparent; } -// 100% {} -//} -// -///* Can style cursor different in overwrite (non-insert) mode */ -//.CodeMirror-overwrite .CodeMirror-cursor {} -// -//.cm-tab { display: inline-block; text-decoration: inherit; } -// -//.CodeMirror-rulers { -// position: absolute; -// left: 0; right: 0; top: -50px; bottom: 0; -// overflow: hidden; -//} -//.CodeMirror-ruler { -// border-left: 1px solid #ccc; -// top: 0; bottom: 0; -// position: absolute; -//} -// -///* DEFAULT THEME */ -// -//.cm-s-default .cm-header {color: blue;} -//.cm-s-default .cm-quote {color: #090;} -//.cm-negative {color: #d44;} -//.cm-positive {color: #292;} -//.cm-header, .cm-strong {font-weight: bold;} -//.cm-em {font-style: italic;} -//.cm-link {text-decoration: underline;} -//.cm-strikethrough {text-decoration: line-through;} -// -//.cm-s-default .cm-keyword {color: #708;} -//.cm-s-default .cm-atom {color: #219;} -//.cm-s-default .cm-number {color: #164;} -//.cm-s-default .cm-def {color: #00f;} -//.cm-s-default .cm-variable, -//.cm-s-default .cm-punctuation, -//.cm-s-default .cm-property, -//.cm-s-default .cm-operator {} -//.cm-s-default .cm-variable-2 {color: #05a;} -//.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;} -//.cm-s-default .cm-comment {color: #a50;} -//.cm-s-default .cm-string {color: #a11;} -//.cm-s-default .cm-string-2 {color: #f50;} -//.cm-s-default .cm-meta {color: #555;} -//.cm-s-default .cm-qualifier {color: #555;} -//.cm-s-default .cm-builtin {color: #30a;} -//.cm-s-default .cm-bracket {color: #997;} -//.cm-s-default .cm-tag {color: #170;} -//.cm-s-default .cm-attribute {color: #00c;} -//.cm-s-default .cm-hr {color: #999;} -//.cm-s-default .cm-link {color: #00c;} -// -//.cm-s-default .cm-error {color: #f00;} -//.cm-invalidchar {color: #f00;} -// -//.CodeMirror-composing { border-bottom: 2px solid; } -// -///* Default styles for common addons */ -// -//div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;} -//div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} -//.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); } -//.CodeMirror-activeline-background {background: #e8f2ff;} -// -///* STOP */ -// -///* The rest of this file contains styles related to the mechanics of -// the editor. You probably shouldn't touch them. */ -// -//.CodeMirror { -// position: relative; -// overflow: hidden; -// background: white; -//} -// -//.CodeMirror-scroll { -// overflow: scroll !important; /* Things will break if this is overridden */ -// /* 50px is the magic margin used to hide the element's real scrollbars */ -// /* See overflow: hidden in .CodeMirror */ -// margin-bottom: -50px; margin-right: -50px; -// padding-bottom: 50px; -// height: 100%; -// outline: none; /* Prevent dragging from highlighting the element */ -// position: relative; -//} -//.CodeMirror-sizer { -// position: relative; -// border-right: 50px solid transparent; -//} -// -///* The fake, visible scrollbars. Used to force redraw during scrolling -// before actual scrolling happens, thus preventing shaking and -// flickering artifacts. */ -//.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { -// position: absolute; -// z-index: 6; -// display: none; -// outline: none; -//} -//.CodeMirror-vscrollbar { -// right: 0; top: 0; -// overflow-x: hidden; -// overflow-y: scroll; -//} -//.CodeMirror-hscrollbar { -// bottom: 0; left: 0; -// overflow-y: hidden; -// overflow-x: scroll; -//} -//.CodeMirror-scrollbar-filler { -// right: 0; bottom: 0; -//} -//.CodeMirror-gutter-filler { -// left: 0; bottom: 0; -//} -// -//.CodeMirror-gutters { -// position: absolute; left: 0; top: 0; -// min-height: 100%; -// z-index: 3; -//} -//.CodeMirror-gutter { -// white-space: normal; -// height: 100%; -// display: inline-block; -// vertical-align: top; -// margin-bottom: -50px; -//} -//.CodeMirror-gutter-wrapper { -// position: absolute; -// z-index: 4; -// background: none !important; -// border: none !important; -//} -//.CodeMirror-gutter-background { -// position: absolute; -// top: 0; bottom: 0; -// z-index: 4; -//} -//.CodeMirror-gutter-elt { -// position: absolute; -// cursor: default; -// z-index: 4; -//} -//.CodeMirror-gutter-wrapper ::selection { background-color: transparent } -//.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent } -// -//.CodeMirror-lines { -// cursor: text; -// min-height: 1px; /* prevents collapsing before first draw */ -//} -//.CodeMirror pre.CodeMirror-line, -//.CodeMirror pre.CodeMirror-line-like { -// /* Reset some styles that the rest of the page might have set */ -// -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; -// border-width: 0; -// background: transparent; -// font-family: inherit; -// font-size: inherit; -// margin: 0; -// white-space: pre; -// word-wrap: normal; -// line-height: inherit; -// color: inherit; -// z-index: 2; -// position: relative; -// overflow: visible; -// -webkit-tap-highlight-color: transparent; -// -webkit-font-variant-ligatures: contextual; -// font-variant-ligatures: contextual; -//} -//.CodeMirror-wrap pre.CodeMirror-line, -//.CodeMirror-wrap pre.CodeMirror-line-like { -// word-wrap: break-word; -// white-space: pre-wrap; -// word-break: normal; -//} -// -//.CodeMirror-linebackground { -// position: absolute; -// left: 0; right: 0; top: 0; bottom: 0; -// z-index: 0; -//} -// -//.CodeMirror-linewidget { -// position: relative; -// z-index: 2; -// padding: 0.1px; /* Force widget margins to stay inside of the container */ -//} -// -//.CodeMirror-widget {} -// -//.CodeMirror-rtl pre { direction: rtl; } -// -//.CodeMirror-code { -// outline: none; -//} -// -///* Force content-box sizing for the elements where we expect it */ -//.CodeMirror-scroll, -//.CodeMirror-sizer, -//.CodeMirror-gutter, -//.CodeMirror-gutters, -//.CodeMirror-linenumber { -// -moz-box-sizing: content-box; -// box-sizing: content-box; -//} -// -//.CodeMirror-measure { -// position: absolute; -// width: 100%; -// height: 0; -// overflow: hidden; -// visibility: hidden; -//} -// -//.CodeMirror-cursor { -// position: absolute; -// pointer-events: none; -//} -//.CodeMirror-measure pre { position: static; } -// -//div.CodeMirror-cursors { -// visibility: hidden; -// position: relative; -// z-index: 3; -//} -//div.CodeMirror-dragcursors { -// visibility: visible; -//} -// -//.CodeMirror-focused div.CodeMirror-cursors { -// visibility: visible; -//} -// -//.CodeMirror-selected { background: #d9d9d9; } -//.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } -//.CodeMirror-crosshair { cursor: crosshair; } -//.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; } -//.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; } -// -//.cm-searching { -// background-color: #ffa; -// background-color: rgba(255, 255, 0, .4); -//} -// -///* Used to force a border model for a node */ -//.cm-force-border { padding-right: .1px; } -// -//@media print { -// /* Hide the cursor when printing */ -// .CodeMirror div.CodeMirror-cursors { -// visibility: hidden; -// } -//} -// -///* See issue #2901 */ -//.cm-tab-wrap-hack:after { content: ''; } -// -///* Help users use markselection to safely style text background */ -//span.CodeMirror-selectedtext { background: none; } From 7bdf55be6affb82b8cbb96c09c1d294cb8b5d61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Thu, 13 Apr 2023 16:42:57 +0800 Subject: [PATCH 03/17] =?UTF-8?q?=E5=85=AC=E5=BC=8F=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E7=BB=84=E4=BB=B6=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/excelEditor/constants.js | 28 ++--- .../hrmSalary/components/excelEditor/index.js | 118 +++++++++++------- .../components/excelEditor/index.less | 10 ++ 3 files changed, 98 insertions(+), 58 deletions(-) diff --git a/pc4mobx/hrmSalary/components/excelEditor/constants.js b/pc4mobx/hrmSalary/components/excelEditor/constants.js index a113371b..2bb11e58 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/constants.js +++ b/pc4mobx/hrmSalary/components/excelEditor/constants.js @@ -1,16 +1,16 @@ export const keyboardBaseBtns=[ - { key:"1", label: "+" }, - { key:"2", label: "-" }, - { key:"3", label: ">" }, - { key:"4", label: ">=" }, - { key:"5", label: "=" }, - { key:"6", label: "*" }, - { key:"7", label: "/" }, - { key:"8", label: "<" }, - { key:"9", label: "<=" }, - { key:"10", label: "!=" }, - { key:"11", label: "(" }, - { key:"12", label: ")" }, - { key:"13", label: "%" }, - { key:"space", label: "space" }, + { key:"+", label: "+" }, + { key:"-", label: "-" }, + { key:">", label: ">" }, + { key:">=", label: ">=" }, + { key:"=", label: "=" }, + { key:"*", label: "*" }, + { key:"/", label: "/" }, + { key:"<", label: "<" }, + { key:"<=", label: "<=" }, + { key:"!=", label: "!=" }, + { key:"()", label: "(" }, + { key:")", label: ")" }, + { key:"%", label: "%" }, + { key:" ", label: "space" }, ] diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.js b/pc4mobx/hrmSalary/components/excelEditor/index.js index 6f69e51c..639e3ac4 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/index.js +++ b/pc4mobx/hrmSalary/components/excelEditor/index.js @@ -1,4 +1,5 @@ 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"; @@ -35,46 +36,60 @@ class ExcelEditor extends Component { this.editorRef = null; } + /* + * Author: 黎永顺 + * Description: 插入字符 + * Params: + * Date: 2023/4/13 + */ + insertText = text => { + let cursor = this.editorRef.getCursor(); + console.log(cursor); + this.editorRef.replaceRange(text, cursor); + }; + replaceToWidget = (editor, data, value, inlineWidgetOpts) => { editor.getAllMarks().forEach(m => m.clear()); - 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(); - }); + // 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: 黎永顺 @@ -104,15 +119,12 @@ class ExcelEditor extends Component { regex: /useObject\("[^)]+"\)/, render: (objId) => { return ( -
alert(objId)} - >{objId}
+ {objId} ); } } }; + const { widgets } = this.state; return (
@@ -140,6 +152,11 @@ class ExcelEditor extends Component { placeholder: "" }} /> + {widgets.map((w, i) => { + return ( + + ); + })}
@@ -149,14 +166,17 @@ class ExcelEditor extends Component { const { key, label } = item; return ; }) }
- - + +
@@ -187,3 +207,13 @@ 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/components/excelEditor/index.less b/pc4mobx/hrmSalary/components/excelEditor/index.less index 964e9395..064ecd12 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/index.less +++ b/pc4mobx/hrmSalary/components/excelEditor/index.less @@ -11,6 +11,16 @@ box-sizing: content-box; border: 1px solid #e5e5e5; + span { + font-family: Liberation Mono, LiberationMonoRegular, Courier New, monospace; + } + + .CodeMirror-code { + font-size: 16px; + + + } + .CodeMirror-scroll { overflow-x: visible !important; padding: 4px; From 3fda510b579950c213fe73c2f7220a6271867ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Wed, 26 Apr 2023 15:08:03 +0800 Subject: [PATCH 04/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=E7=BB=84=E4=BB=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/item.js | 4 + .../excelEditor/components/codeAction.js | 234 ++++++++++++++++++ .../hrmSalary/components/excelEditor/index.js | 68 +++-- .../components/excelEditor/index.less | 79 ++++++ 4 files changed, 360 insertions(+), 25 deletions(-) create mode 100644 pc4mobx/hrmSalary/components/excelEditor/components/codeAction.js diff --git a/pc4mobx/hrmSalary/apis/item.js b/pc4mobx/hrmSalary/apis/item.js index 128cd24f..ccf93af9 100644 --- a/pc4mobx/hrmSalary/apis/item.js +++ b/pc4mobx/hrmSalary/apis/item.js @@ -107,6 +107,10 @@ export const saveSysItem = params => { export const getItemTypeOption = params => { return WeaTools.callApi('/api/bs/hrmsalary/salaryitem/listSalaryItemTypeOption', 'GET', params); } +//获取公式描述 +export const getFormulaDes = params => { + return WeaTools.callApi('/api/bs/hrmsalary/formula/des', 'GET', params); +} // *** 公式 start *** // 获取公式变量类型 diff --git a/pc4mobx/hrmSalary/components/excelEditor/components/codeAction.js b/pc4mobx/hrmSalary/components/excelEditor/components/codeAction.js new file mode 100644 index 00000000..2458fd57 --- /dev/null +++ b/pc4mobx/hrmSalary/components/excelEditor/components/codeAction.js @@ -0,0 +1,234 @@ +/* + * Author: 黎永顺 + * name: 公式列表 + * Description: + * Date: 2023/4/25 + */ +import React, { Component } from "react"; +import { WeaInputSearch, WeaLocaleProvider } from "ecCom"; +import { Tree } from "antd"; +import { formualSearchField, formualSearchGroup, getFormulaDes } from "../../../apis/item"; +import "../index.less"; + +const TreeNode = Tree.TreeNode; +const getLabel = WeaLocaleProvider.getLabel; + +class CodeAction extends Component { + constructor(props) { + super(props); + this.state = { + variableText: "", + funcText: "", + variItemText: "", + variableList: [], //变量列表 + variableExpandedKeys: [], //变量展开的节点 + funcList: [], //函数列表 + funcExpandedKeys: [], //函数展开的节点 + funcHoverItem: {} //选中的函数节点 + }; + } + + componentDidMount() { + const { formualPayload = {} } = this.props; + this.getFormulaDes(); + this.formualSearchGroup(formualPayload); + } + + getFormulaDes = () => { + getFormulaDes().then(({ data }) => { + if (!_.isEmpty(data)) this.setState({ funcList: data }); + }); + }; + formualSearchGroup = (payload) => { + formualSearchGroup(payload).then(({ status, data }) => { + if (status) this.setState({ + variableList: _.map(data, item => ({ + ...item, + children: [{ name: "", fieldId: "searchInput" }] + })) + }); + }); + }; + formualSearchField = (sourceId) => { + const { variableList } = this.state; + formualSearchField({ sourceId }).then(({ status, data }) => { + if (status) { + this.setState({ + variableList: _.map(variableList, it => ({ + ...it, + children: sourceId === it.key ? [...it.children, ...data] : [...it.children] + })) + }); + } + }); + }; + handleExpandVari = (variableExpandedKeys, { expanded, node }) => { + const { props: { eventKey } } = node; + const { variableList } = this.state; + this.setState({ variableExpandedKeys }); + if (expanded) { + this.formualSearchField(eventKey); + } else { + this.setState({ + variableList: _.map(variableList, it => ({ + ...it, + children: eventKey === it.key ? [{ name: "", fieldId: "searchInput" }] : [...it.children] + })) + }); + } + }; + handleVariNode = (selectedKeys) => { + const { onVariSelect } = this.props; + const { variableList } = this.state; + const parentNode = _.map(variableList, it => it.key); + if (selectedKeys.join() && selectedKeys.join().indexOf("searchInput") === -1 && + !parentNode.includes(selectedKeys.join())) { + const selectParentNodeKey = selectedKeys.join().split("_")[0]; + const convertStr = _.reduce(variableList, (pre, cur) => { + if (cur.key === selectParentNodeKey) { + return pre + cur.value + "." + _.find(cur.children, child => child.fieldId === selectedKeys.join()).name; + } + return pre; + }, ""); + onVariSelect(convertStr); + } + }; + + render() { + const { + variableList, variableExpandedKeys, variableText, variItemText, + funcList, funcText, funcExpandedKeys, funcHoverItem + } = this.state; + const variableDatalist = _.filter(variableList, it => it.value.indexOf(variableText) !== -1); + const funcDatalist = _.map(funcList, it => ({ + ...it, + children: _.filter(it.children, child => _.lowerCase(child.name).indexOf(funcText) !== -1) + })); + return ( +
+
+
+
{getLabel(111, "变量")}
+
+
+ this.setState({ variableText })}/> + + { + _.map(variableDatalist, item => { + const { key, value, children = [] } = item; + const itemChildren = _.filter(children.slice(1), it => it.name.indexOf(variItemText) !== -1); + return + { + _.map([...children.slice(0, 1), ...itemChildren], (child, childIndex) => { + const { name, fieldId } = child; + return ( + fieldId === "searchInput" ? + this.setState({ variItemText })} + /> + } + key={fieldId + "_" + childIndex}/> : + + ); + }) + } + ; + }) + } + +
+
+
+
+
{getLabel(111, "函数")}
+
+
+ this.setState({ funcText })}/> + this.setState({ funcExpandedKeys })} + > + { + _.map(funcDatalist, item => { + const { name, dataType, children = [] } = item; + return + { + _.map(children, (child, childIndex) => { + const { name: childName, chineseName } = child; + return ( + this.props.onFuncSelect(childName)} + onMouseEnter={() => this.setState({ funcHoverItem: child })}> + {childName} + {chineseName} +
+ } + key={childIndex} + /> + ); + }) + } + ; + }) + } + +
+
+
+
+
+ {!_.isEmpty(funcHoverItem) ? funcHoverItem.name : getLabel(111, "提示")} +
+
+
+
+
+ ); + } +} + +export default CodeAction; + +const TipList = (props) => { + const { tips } = props; + const { paramDescs = [], formatString, description, example, result } = tips; + return _.isEmpty(tips) ?
+
+
{getLabel(111, "{C:选项} 用来选择特定选项字段下的备选项")}
+
{getLabel(111, "{U:姓名} 用来选择工作区成员")}
+
{getLabel(111, "{D:数据} 用来选择一个部门")}
+
+
:
+
+
{getLabel(111, "语法")}
+
+
{formatString}
+
{description}
+
+
{getLabel(111, "参数")}
+ { + _.map(paramDescs, it => { + return
+ . + {it} +
; + }) + } +
{getLabel(111, "示例")}
+ {example} +
{getLabel(111, "结果")}
+ {result} +
+
; +}; diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.js b/pc4mobx/hrmSalary/components/excelEditor/index.js index 639e3ac4..940354e1 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/index.js +++ b/pc4mobx/hrmSalary/components/excelEditor/index.js @@ -3,6 +3,7 @@ import ReactDOM from "react-dom"; import { Button } from "antd"; import { Controlled as CodeMirror } from "react-codemirror2"; import { keyboardBaseBtns } from "./constants"; +import CodeAction from "./components/codeAction"; import cs from "classnames"; import "./index.less"; @@ -36,6 +37,23 @@ class ExcelEditor extends Component { this.editorRef = null; } + // componentDidMount() { + // window.addEventListener("keydown", this.onkeyDown, { passive: false }); + // } + // + // componentWillUnmount() { + // window.removeEventListener("keydown", this.onkeyDown); + // } + // + // onkeyDown = (e) => { + // if (e.keyCode === 8) { + // console.log(e); + // e.nativeEvent.stopImmediatePropagation() + // e.preventDefault(); + // // this.handleEditorRedo(); + // } + // }; + /* * Author: 黎永顺 * Description: 插入字符 @@ -43,15 +61,14 @@ class ExcelEditor extends Component { * Date: 2023/4/13 */ insertText = text => { - let cursor = this.editorRef.getCursor(); - console.log(cursor); + const cursor = this.editorRef.getCursor(); this.editorRef.replaceRange(text, cursor); }; replaceToWidget = (editor, data, value, inlineWidgetOpts) => { editor.getAllMarks().forEach(m => m.clear()); - editor.refresh(); - editor.focus(); + editor.refresh(); + editor.focus(); // let posInfos = _.flatMap(_.keys(inlineWidgetOpts), widgetName => { // let { regex, render } = inlineWidgetOpts[widgetName]; // let res = [], newRe = new RegExp(regex, "g"), m; @@ -112,6 +129,25 @@ class ExcelEditor extends Component { // editor.setValue(sqlFormatter.format(splCont)); } }; + handleVariSelect = str => this.insertText(`{${str}}`); + handleFuncSelect = str => { + const cursor = this.editorRef.getCursor(); + this.editorRef.replaceRange(`${str}()`, cursor); + }; + handleEditorRedo = () => { + const { ch, line } = this.editorRef.getCursor(); + const delStr = this.editorRef.getRange({ line, ch: ch - 1 }, { line, ch }); + const codeValue = this.editorRef.getValue(); + if (delStr === "}") { + if (codeValue.slice(0, ch).lastIndexOf("{") === -1) { + this.editorRef.replaceRange("", { line, ch: ch - 1 }, { line, ch }); + } else { + this.editorRef.replaceRange("", { line, ch: codeValue.slice(0, ch).lastIndexOf("{") }, { line, ch }); + } + } else { + this.editorRef.replaceRange("", { line, ch: ch - 1 }, { line, ch }); + } + }; render() { const inlineWidgetOpts = { @@ -174,33 +210,15 @@ class ExcelEditor extends Component {
+ onClick={this.handleEditorRedo}>←
-
-
-
-
变量
-
-
-
-
-
-
函数
-
-
-
-
-
-
提示
-
-
-
-
+ {/*公式参数列表*/} +
); } diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.less b/pc4mobx/hrmSalary/components/excelEditor/index.less index 064ecd12..0ea0081a 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/index.less +++ b/pc4mobx/hrmSalary/components/excelEditor/index.less @@ -105,6 +105,8 @@ background: #fff; border: 1px solid #e5e5e5; margin-right: 16px; + display: flex; + flex-direction: column; .excel-codeAction-header { display: flex; @@ -116,5 +118,82 @@ font-weight: 600; } } + + .excel-codeAction-content { + flex: 1; + overflow: hidden auto; + padding: 0 16px; + max-height: 280px; + position: relative; + + .variableOuterInput { + width: 100%; + margin-top: 10px; + position: sticky; + top: 10px; + background-color: #fff; + z-index: 1; + } + + .variableTree { + li a:hover, li a.ant-tree-node-selected { + background: transparent; + } + + li:first-child { + a { + padding: 2px 5px; + } + } + + li a { + width: calc(100% - 16px); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + + .ant-tree-title { + display: inline-block; + width: 100%; + + .funcListTitle { + width: 100%; + display: flex; + justify-content: space-between; + + & > span { + display: inline-block; + flex: 1 1; + overflow: hidden; + text-overflow: ellipsis; + word-break: keep-all; + white-space: nowrap; + } + + .functionName { + max-width: 100px; + } + + .functionDesc { + max-width: 100px; + text-align: right; + color: #999; + } + } + } + } + } + + .code-action-list { + padding: 10px 0; + .code-action-tips-title{ + height: 22px; + line-height: 22px; + } + .code-action-tips-info{ + color: #999 + } + } + } } } From 159eadc1644cb536ad9f70b5f4af0707a117efb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Thu, 27 Apr 2023 09:34:19 +0800 Subject: [PATCH 05/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=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hrmSalary/components/excelEditor/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.js b/pc4mobx/hrmSalary/components/excelEditor/index.js index 940354e1..3801b878 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/index.js +++ b/pc4mobx/hrmSalary/components/excelEditor/index.js @@ -133,6 +133,7 @@ class ExcelEditor extends Component { handleFuncSelect = str => { const cursor = this.editorRef.getCursor(); this.editorRef.replaceRange(`${str}()`, cursor); + this.editorRef.goColumnLeft(); }; handleEditorRedo = () => { const { ch, line } = this.editorRef.getCursor(); @@ -148,6 +149,20 @@ class ExcelEditor extends Component { this.editorRef.replaceRange("", { line, ch: ch - 1 }, { line, ch }); } }; + handleBackSpaceRedo = () => { + const { ch, line } = this.editorRef.getCursor(); + const delStr = this.editorRef.getRange({ line, ch: ch - 1 }, { line, ch }); + const codeValue = this.editorRef.getValue(); + if (delStr === "}") { + console.log(ch); + console.log(codeValue.slice(0, ch).lastIndexOf("{")); + if (codeValue.slice(0, ch).lastIndexOf("{") === -1) { + this.editorRef.replaceRange("", { line, ch: ch - 1 }, { line, ch }); + } else { + this.editorRef.replaceRange("", { line, ch: codeValue.slice(0, ch).lastIndexOf("{") }, { line, ch }); + } + } + }; render() { const inlineWidgetOpts = { @@ -187,6 +202,7 @@ class ExcelEditor extends Component { cursorHeight: 0.85, placeholder: "" }} + onKeyDown={(_, { keyCode }) => keyCode === 8 && this.handleBackSpaceRedo()} /> {widgets.map((w, i) => { return ( @@ -210,7 +226,8 @@ class ExcelEditor extends Component {
+ // this.handleEditorRedo + onClick={() => this.editorRef.delCharBefore()}>←
From 11e1cc89a9d516da2cccddf2a8e8c975eaff400d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Thu, 27 Apr 2023 10:01:57 +0800 Subject: [PATCH 06/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=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/components/excelEditor/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.js b/pc4mobx/hrmSalary/components/excelEditor/index.js index 3801b878..0d38e51a 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/index.js +++ b/pc4mobx/hrmSalary/components/excelEditor/index.js @@ -133,7 +133,9 @@ class ExcelEditor extends Component { handleFuncSelect = str => { const cursor = this.editorRef.getCursor(); this.editorRef.replaceRange(`${str}()`, cursor); - this.editorRef.goColumnLeft(); + console.log(this.editorRef); + console.log(this.editorRef.doc); + this.editorRef.doc.goColumnLeft(); }; handleEditorRedo = () => { const { ch, line } = this.editorRef.getCursor(); @@ -154,12 +156,10 @@ class ExcelEditor extends Component { const delStr = this.editorRef.getRange({ line, ch: ch - 1 }, { line, ch }); const codeValue = this.editorRef.getValue(); if (delStr === "}") { - console.log(ch); - console.log(codeValue.slice(0, ch).lastIndexOf("{")); if (codeValue.slice(0, ch).lastIndexOf("{") === -1) { this.editorRef.replaceRange("", { line, ch: ch - 1 }, { line, ch }); } else { - this.editorRef.replaceRange("", { line, ch: codeValue.slice(0, ch).lastIndexOf("{") }, { line, ch }); + this.editorRef.replaceRange("", { line, ch: codeValue.slice(0, ch).lastIndexOf("{") + 1 }, { line, ch }); } } }; @@ -200,7 +200,8 @@ class ExcelEditor extends Component { lint: false, indentUnit: 2, cursorHeight: 0.85, - placeholder: "" + placeholder: "", + showCursorWhenSelecting: true }} onKeyDown={(_, { keyCode }) => keyCode === 8 && this.handleBackSpaceRedo()} /> @@ -226,8 +227,7 @@ class ExcelEditor extends Component {
+ onClick={this.handleEditorRedo}>←
From f1ef12f869d8587a87b7e1840e5527a506fc3508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Thu, 27 Apr 2023 14:52:03 +0800 Subject: [PATCH 07/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=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../excelEditor/components/codeAction.js | 103 +++++----- .../hrmSalary/components/excelEditor/index.js | 94 ++++----- .../pages/salaryItem/formalFormModal.js | 178 +++++++++--------- 3 files changed, 182 insertions(+), 193 deletions(-) diff --git a/pc4mobx/hrmSalary/components/excelEditor/components/codeAction.js b/pc4mobx/hrmSalary/components/excelEditor/components/codeAction.js index 2458fd57..44e9783d 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/components/codeAction.js +++ b/pc4mobx/hrmSalary/components/excelEditor/components/codeAction.js @@ -29,9 +29,9 @@ class CodeAction extends Component { } componentDidMount() { - const { formualPayload = {} } = this.props; + const { groupParams = {} } = this.props; this.getFormulaDes(); - this.formualSearchGroup(formualPayload); + this.formualSearchGroup(groupParams); } getFormulaDes = () => { @@ -99,6 +99,8 @@ class CodeAction extends Component { variableList, variableExpandedKeys, variableText, variItemText, funcList, funcText, funcExpandedKeys, funcHoverItem } = this.state; + const { groupParams = {} } = this.props; + const { referenceType } = groupParams; const variableDatalist = _.filter(variableList, it => it.value.indexOf(variableText) !== -1); const funcDatalist = _.map(funcList, it => ({ ...it, @@ -146,53 +148,58 @@ class CodeAction extends Component { -
-
-
{getLabel(111, "函数")}
-
-
- this.setState({ funcText })}/> - this.setState({ funcExpandedKeys })} - > - { - _.map(funcDatalist, item => { - const { name, dataType, children = [] } = item; - return - { - _.map(children, (child, childIndex) => { - const { name: childName, chineseName } = child; - return ( - this.props.onFuncSelect(childName)} - onMouseEnter={() => this.setState({ funcHoverItem: child })}> - {childName} - {chineseName} -
- } - key={childIndex} - /> - ); - }) - } - ; - }) - } - -
- -
-
-
- {!_.isEmpty(funcHoverItem) ? funcHoverItem.name : getLabel(111, "提示")} + { + referenceType !== "sql" && + +
+
+
{getLabel(111, "函数")}
+
+
+ this.setState({ funcText })}/> + this.setState({ funcExpandedKeys })} + > + { + _.map(funcDatalist, item => { + const { name, dataType, children = [] } = item; + return + { + _.map(children, (child, childIndex) => { + const { name: childName, chineseName } = child; + return ( + this.props.onFuncSelect(childName)} + onMouseEnter={() => this.setState({ funcHoverItem: child })}> + {childName} + {chineseName} +
+ } + key={childIndex} + /> + ); + }) + } + ; + }) + } + +
-
-
-
+
+
+
+ {!_.isEmpty(funcHoverItem) ? funcHoverItem.name : getLabel(111, "提示")} +
+
+
+
+ + } ); } diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.js b/pc4mobx/hrmSalary/components/excelEditor/index.js index 0d38e51a..b04ce534 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/index.js +++ b/pc4mobx/hrmSalary/components/excelEditor/index.js @@ -6,27 +6,9 @@ import { keyboardBaseBtns } from "./constants"; import CodeAction from "./components/codeAction"; import cs from "classnames"; import "./index.less"; - import "codemirror/lib/codemirror.css"; import "codemirror/lib/codemirror.js"; -//代码折叠 -import "codemirror/addon/fold/foldgutter.css"; -import "codemirror/addon/lint/lint.css"; -import "codemirror/addon/fold/foldcode.js"; -import "codemirror/addon/fold/foldgutter.js"; -import "codemirror/addon/fold/brace-fold.js"; -import "codemirror/addon/hint/javascript-hint.js"; -import "codemirror/addon/hint/show-hint.js"; -import "codemirror/addon/lint/lint.js"; -import "codemirror/addon/lint/json-lint.js"; -import "codemirror/addon/lint/javascript-lint.js"; -import "codemirror/addon/display/placeholder.js"; -import "codemirror/mode/javascript/javascript.js"; -import "codemirror/mode/sql/sql.js"; - -// const sqlFormatter = require('sql-formatter'); - class ExcelEditor extends Component { constructor(props) { super(props); @@ -35,24 +17,13 @@ class ExcelEditor extends Component { widgets: [] }; this.editorRef = null; + this.timer = null; } - // componentDidMount() { - // window.addEventListener("keydown", this.onkeyDown, { passive: false }); - // } - // - // componentWillUnmount() { - // window.removeEventListener("keydown", this.onkeyDown); - // } - // - // onkeyDown = (e) => { - // if (e.keyCode === 8) { - // console.log(e); - // e.nativeEvent.stopImmediatePropagation() - // e.preventDefault(); - // // this.handleEditorRedo(); - // } - // }; + + componentWillUnmount() { + if (this.timer) clearInterval(this.timer); + } /* * Author: 黎永顺 @@ -133,9 +104,10 @@ class ExcelEditor extends Component { handleFuncSelect = str => { const cursor = this.editorRef.getCursor(); this.editorRef.replaceRange(`${str}()`, cursor); - console.log(this.editorRef); - console.log(this.editorRef.doc); - this.editorRef.doc.goColumnLeft(); + this.timer = setTimeout(() => { + const { line, ch } = this.editorRef.getCursor(); + this.editorRef.setCursor({ line, ch: ch - 1 }); + }, 100); }; handleEditorRedo = () => { const { ch, line } = this.editorRef.getCursor(); @@ -176,6 +148,8 @@ class ExcelEditor extends Component { } }; const { widgets } = this.state; + const { groupParams = {} } = this.props; + const { referenceType } = groupParams; return (
@@ -211,31 +185,35 @@ class ExcelEditor extends Component { ); })}
-
-
-
- { - _.map(keyboardBaseBtns, item => { - const { key, label } = item; - return ; - }) - } -
-
- - + { + referenceType !== "sql" && +
+
+
+ { + _.map(keyboardBaseBtns, item => { + const { key, label } = item; + return ; + }) + } +
+
+ + +
-
+ }
{/*公式参数列表*/} - + ); } diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js index 3bf2d4a9..20001e4e 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js @@ -1,9 +1,10 @@ import React from "react"; -import { Button, Col, Icon, message, Modal, Row } from "antd"; -import { WeaCheckbox, WeaDialog, WeaFormItem, WeaHelpfulTip, WeaInput, WeaSelect, WeaTextarea } from "ecCom"; +import { Button, Col, message, Modal, Row } from "antd"; +import { WeaCheckbox, WeaDialog, WeaFormItem, WeaHelpfulTip, WeaInput, WeaSelect } from "ecCom"; import { inject, observer } from "mobx-react"; import { testFormual } from "../../apis/item"; import TestModal from "./testModal"; +import ExcelEditor from "../../components/excelEditor"; import "./index.less"; @inject("salaryItemStore") @@ -12,7 +13,6 @@ export default class FormalFormModal extends React.Component { constructor(props) { super(props); this.state = { - formalua: false, //是否删除操作过公式数据 validateType: "", returnType: "", value: "", @@ -26,7 +26,8 @@ export default class FormalFormModal extends React.Component { returnValue: "", formulaDatasourceList: [], testVisible: false, - showTestVal: "" + showTestVal: "", + groupParams: {} }; this.group = {}; this.field = {}; @@ -41,11 +42,6 @@ export default class FormalFormModal extends React.Component { setSearchFields([]); if (!!this.props.formulaId && this.props.formulaId != 0) { detailFormual(this.props.formulaId).then(data => { - this.setState({ - value: data.formula, - returnType: data.returnType, - validateType: data.validateType - }); this.parameters = data.parameters; this.referenceType = data.referenceType; this.extendParam = data.extendParam; @@ -66,14 +62,20 @@ export default class FormalFormModal extends React.Component { } }); } - let groupParams = {}; - if (this.referenceType == "sql") { - groupParams = { "referenceType": "sql" }; - } else { - groupParams = this.props.backCalcType === "issuedItems" ? { "referenceType": "backCalc" } : {}; - } - salaryAcctImportTemplateParam(groupParams); + this.setState({ + value: data.formula, + returnType: data.returnType, + validateType: data.validateType, + }); + // salaryAcctImportTemplateParam(groupParams); }); + let groupParams = {}; + if (this.props.valueType == "3") { + groupParams = { "referenceType": "sql" }; + } else { + groupParams = this.props.backCalcType === "issuedItems" ? { "referenceType": "backCalc" } : {}; + } + this.setState({ groupParams }); } else { let groupParams = {}; if (this.props.valueType == "3") { @@ -85,7 +87,8 @@ export default class FormalFormModal extends React.Component { value: this.props.formulaContent }); } - salaryAcctImportTemplateParam(groupParams); + this.setState({ groupParams }); + // salaryAcctImportTemplateParam(groupParams); } } @@ -108,7 +111,6 @@ export default class FormalFormModal extends React.Component { const index = value.lastIndexOf("{", end - 1); const currentValue = value.substring(index, end); this.setState({ - formalua: true, value: value.replace(currentValue, "") }, () => { if (propsTextarea.setSelectionRange) { @@ -138,14 +140,14 @@ export default class FormalFormModal extends React.Component { }; // 多行文本编辑 - handleChange(value) { + handleChange = (value) => { if (value && value.trim() == "") { this.parameters = []; } this.setState({ - value, formalua: true + value }); - } + }; // 获取光标位置 getPositionForTextArea(ctrl) { @@ -206,12 +208,11 @@ export default class FormalFormModal extends React.Component { returnType: this.props.dataType || this.state.returnType, validateType: this.props.dataType || this.state.returnType, extendParam: JSON.stringify(this.state.extendParam), - formula: this.state.value, + formula: this.state.value.replace(/[\r\n]/g, ""), parameters: this.parameters, referenceType: this.referenceType == "" ? this.props.valueType == "2" ? "formula" : this.props.valueType == "3" ? "sql" : "" : this.referenceType }; saveFormual(params).then(data => { - this.setState({ formalua: false }); this.props.onSaveFormal(data); this.props.onCancel(); }); @@ -323,13 +324,13 @@ export default class FormalFormModal extends React.Component { render() { const { salaryItemStore } = this.props; const { searchGroup, searchFields } = salaryItemStore; - const { value, formulaDatasourceList, extendParam, testVisible, showTestVal, formalua } = this.state; + const { value, formulaDatasourceList, extendParam, testVisible, showTestVal, groupParams } = this.state; const title =
{`${(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.setState({ visible: false })} + > + + +
); } } diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js index 20001e4e..719b103b 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js @@ -65,7 +65,7 @@ export default class FormalFormModal extends React.Component { this.setState({ value: data.formula, returnType: data.returnType, - validateType: data.validateType, + validateType: data.validateType }); // salaryAcctImportTemplateParam(groupParams); }); @@ -428,9 +428,7 @@ export default class FormalFormModal extends React.Component { } - - {/*value={value} groupParams={groupParams}*/} - {/*onChange={(value) => this.handleChange(value)}*/} + 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
+ } diff --git a/pc4mobx/hrmSalary/pages/equationEditor/index.js b/pc4mobx/hrmSalary/pages/equationEditor/index.js index a31d97d1..ffcc361c 100644 --- a/pc4mobx/hrmSalary/pages/equationEditor/index.js +++ b/pc4mobx/hrmSalary/pages/equationEditor/index.js @@ -15,12 +15,12 @@ class Index extends Component { render() { return (
- + {}}/> this.setState({ visible: false })} + onCancel={() => this.setState({ visible: false })} > - + {}}/>
); From 5c56b8ced42e7cfbb95fe2e612d0a346ee07730c 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:13:03 +0800 Subject: [PATCH 11/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 --- .../components/excelEditor/extendCodeMirror.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pc4mobx/hrmSalary/components/excelEditor/extendCodeMirror.js b/pc4mobx/hrmSalary/components/excelEditor/extendCodeMirror.js index e1b34b44..e70c6967 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/extendCodeMirror.js +++ b/pc4mobx/hrmSalary/components/excelEditor/extendCodeMirror.js @@ -11,8 +11,8 @@ CodeMirror.extendMode("css", { }); CodeMirror.extendMode("javascript", { - commentStart: "/*", - commentEnd: "*/", + commentStart: "", + commentEnd: "", // FIXME semicolons inside of for newlineAfterToken: function (type, content, textAfter, state) { if (this.jsonMode) { @@ -37,10 +37,8 @@ CodeMirror.defineExtension("commentRange", function (isComment, from, to) { var cm = this, curMode = CodeMirror.innerMode(cm.getMode(), cm.getTokenAt(from).state).mode; cm.operation(function () { if (isComment) { // Comment range - cm.replaceRange("", to); - // cm.replaceRange(curMode.commentEnd, to); - cm.replaceRange("", from); - // cm.replaceRange(curMode.commentStart, from); + cm.replaceRange(curMode.commentEnd, to); + cm.replaceRange(curMode.commentStart, from); if (from.line == to.line && from.ch == to.ch) // An empty comment inserted - put cursor inside cm.setCursor(from.line, from.ch + curMode.commentStart.length); } else { // Uncomment range From 36ca75ed6c784c6a934a8b13f32972007cc68532 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, 5 May 2023 10:03:49 +0800 Subject: [PATCH 12/17] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../standingBookDetail/components/regList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/regList.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/regList.js index 32168268..af76517c 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/regList.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/regList.js @@ -58,7 +58,7 @@ class RegList extends Component { } }; postMessageToChild = () => { - const paymentStatus = "3"; + const paymentStatus = this.props.type === "difference" ? "4" : "3"; const creator = Number(getQueryString("creator")); const billMonth = getQueryString("billMonth"); const paymentOrganization = getQueryString("paymentOrganization"); From 108750431f773a46aa624333e47bdd7c06f8636e 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, 5 May 2023 14:09:06 +0800 Subject: [PATCH 13/17] =?UTF-8?q?=E4=BA=A7=E5=93=81-=E7=A4=BE=E4=BF=9D?= =?UTF-8?q?=E7=A6=8F=E5=88=A9=E5=8F=B0=E8=B4=A6bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../standingBookDetail/components/regList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/regList.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/regList.js index af76517c..849cb407 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/regList.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/standingBookDetail/components/regList.js @@ -91,7 +91,7 @@ class RegList extends Component { const billMonth = getQueryString("billMonth"); const paymentOrganization = getQueryString("paymentOrganization"); const creator = Number(getQueryString("creator")); - const paymentStatus = "3"; + const paymentStatus = type === "difference" ? "4" : "3"; const payload = { billMonth, paymentStatus, creator, paymentOrganization, From bc48bc8180378a836bbca64b709943e0d04d7fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Tue, 9 May 2023 09:57:49 +0800 Subject: [PATCH 14/17] =?UTF-8?q?=E5=85=AC=E5=BC=8F=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../excelEditor/components/codeAction.js | 20 ++++++++++++++++--- .../hrmSalary/components/excelEditor/index.js | 16 +++++++++------ .../pages/salaryItem/formalFormModal.js | 15 +++++++++++++- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/pc4mobx/hrmSalary/components/excelEditor/components/codeAction.js b/pc4mobx/hrmSalary/components/excelEditor/components/codeAction.js index 44e9783d..3daabe83 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/components/codeAction.js +++ b/pc4mobx/hrmSalary/components/excelEditor/components/codeAction.js @@ -17,6 +17,7 @@ class CodeAction extends Component { constructor(props) { super(props); this.state = { + disabled: false, variableText: "", funcText: "", variItemText: "", @@ -34,6 +35,17 @@ class CodeAction extends Component { this.formualSearchGroup(groupParams); } + componentWillReceiveProps(nextProps, nextContext) { + const { isCustomFunction, isCustomFunctionClick, onChangeCustomFunction } = nextProps; + if (isCustomFunction === "1" && !isCustomFunctionClick) { + this.setState({ disabled: true }); + } else { + this.setState({ disabled: false }, () => { + isCustomFunction === "1" && onChangeCustomFunction("0"); + }); + } + } + getFormulaDes = () => { getFormulaDes().then(({ data }) => { if (!_.isEmpty(data)) this.setState({ funcList: data }); @@ -50,8 +62,9 @@ class CodeAction extends Component { }); }; formualSearchField = (sourceId) => { + const { groupParams } = this.props; const { variableList } = this.state; - formualSearchField({ sourceId }).then(({ status, data }) => { + formualSearchField({ sourceId, extendParam: { ...groupParams } }).then(({ status, data }) => { if (status) { this.setState({ variableList: _.map(variableList, it => ({ @@ -97,7 +110,7 @@ class CodeAction extends Component { render() { const { variableList, variableExpandedKeys, variableText, variItemText, - funcList, funcText, funcExpandedKeys, funcHoverItem + funcList, funcText, funcExpandedKeys, funcHoverItem, disabled } = this.state; const { groupParams = {} } = this.props; const { referenceType } = groupParams; @@ -165,12 +178,13 @@ class CodeAction extends Component { { _.map(funcDatalist, item => { const { name, dataType, children = [] } = item; - return + return { _.map(children, (child, childIndex) => { const { name: childName, chineseName } = child; return ( this.props.onFuncSelect(childName)} diff --git a/pc4mobx/hrmSalary/components/excelEditor/index.js b/pc4mobx/hrmSalary/components/excelEditor/index.js index ff953d4a..1d1cd89f 100644 --- a/pc4mobx/hrmSalary/components/excelEditor/index.js +++ b/pc4mobx/hrmSalary/components/excelEditor/index.js @@ -18,7 +18,8 @@ class ExcelEditor extends Component { super(props); this.state = { value: "", - isFormter: false + isFormter: false, + isCustomFunctionClick: false }; this.editorRef = null; this.timer = null; @@ -30,6 +31,7 @@ class ExcelEditor extends Component { componentWillUnmount() { if (this.timer) clearInterval(this.timer); + this.setState({ isCustomFunctionClick: false }); } autoFormatSelection = () => { @@ -98,8 +100,8 @@ class ExcelEditor extends Component { }; render() { - const { isFormter } = this.state; - const { groupParams = {} } = this.props; + const { isFormter, isCustomFunctionClick } = this.state; + const { groupParams = {}, isCustomFunction, value, onChangeCustomFunction } = this.props; const { referenceType } = groupParams; return ( @@ -150,7 +152,7 @@ class ExcelEditor extends Component { + onClick={() => this.setState({ value: "", isCustomFunctionClick: true })}>C