公式编辑器修改

This commit is contained in:
黎永顺 2023-05-09 09:57:49 +08:00
parent c0b4b2eb4a
commit bc48bc8180
3 changed files with 41 additions and 10 deletions

View File

@ -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 <TreeNode title={name} key={dataType}>
return <TreeNode title={name} disabled={disabled} key={dataType}>
{
_.map(children, (child, childIndex) => {
const { name: childName, chineseName } = child;
return (
<TreeNode
disabled={disabled}
title={
<div className="funcListTitle"
onClick={() => this.props.onFuncSelect(childName)}

View File

@ -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 (
<React.Fragment>
@ -150,7 +152,7 @@ class ExcelEditor extends Component {
<Button title="←" size="small" className="excel-codeBox-keyboard-del"
onClick={this.handleEditorRedo}></Button>
<Button title="C" size="small" className="excel-codeBox-keyboard-clear"
onClick={() => this.setState({ value: "" })}>C</Button>
onClick={() => this.setState({ value: "", isCustomFunctionClick: true })}>C</Button>
</div>
</div>
<Button type="ghost"
@ -161,8 +163,10 @@ class ExcelEditor extends Component {
}
</div>
{/*公式参数列表*/}
<CodeAction groupParams={groupParams} onVariSelect={this.handleVariSelect}
onFuncSelect={this.handleFuncSelect}/>
<CodeAction groupParams={groupParams} isCustomFunction={isCustomFunction} onVariSelect={this.handleVariSelect}
onFuncSelect={this.handleFuncSelect} codeVal={value} isCustomFunctionClick={isCustomFunctionClick}
onChangeCustomFunction={onChangeCustomFunction}
/>
</React.Fragment>
);
}

View File

@ -17,6 +17,7 @@ export default class FormalFormModal extends React.Component {
returnType: "",
value: "",
extendParam: {
isCustomFunction: "0",
sqlReturnKey: "",
openDecrypt: "0",
datasource: {
@ -54,6 +55,7 @@ export default class FormalFormModal extends React.Component {
}
this.setState({
extendParam: {
isCustomFunction: extendParam.isCustomFunction || "1",
sqlReturnKey: extendParam.sqlReturnKey,
openDecrypt: extendParam.openDecrypt,
datasource: {
@ -320,6 +322,15 @@ export default class FormalFormModal extends React.Component {
}
});
};
handleChangeCustomFunction = (isCustomFunction) => {
const { extendParam } = this.state;
this.setState({
extendParam: {
...extendParam,
isCustomFunction
}
});
};
render() {
const { salaryItemStore } = this.props;
@ -428,7 +439,9 @@ export default class FormalFormModal extends React.Component {
</Col>
</Row>
}
<ExcelEditor value={value} groupParams={groupParams} onChange={(value) => this.handleChange(value)}/>
<ExcelEditor value={value} groupParams={groupParams} isCustomFunction={extendParam.isCustomFunction}
onChange={(value) => this.handleChange(value)}
onChangeCustomFunction={this.handleChangeCustomFunction}/>
{/*<div>*/}
{/* <WeaTextarea*/}
{/* ref={(input) => this.contentProps = input}*/}