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