From fd5b347856ad2dfc58205d99f07d0c745d52436c Mon Sep 17 00:00:00 2001 From: "gaoxiaolin.gao" Date: Mon, 20 Nov 2017 19:07:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E6=9E=84MethodsList?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/ModalPostman/MethodsList.js | 102 +++++++----------- 1 file changed, 39 insertions(+), 63 deletions(-) diff --git a/client/components/ModalPostman/MethodsList.js b/client/components/ModalPostman/MethodsList.js index 9e112010..81de6cde 100644 --- a/client/components/ModalPostman/MethodsList.js +++ b/client/components/ModalPostman/MethodsList.js @@ -7,68 +7,20 @@ const RadioButton = Radio.Button; const RadioGroup = Radio.Group; -const inputComponent = (props) => { - let index = props.index - return props.paramsInput(e.target.value, index)} /> -} - -inputComponent.propTypes = { - paramsInput: PropTypes.func, - index: PropTypes.number, - disabled: PropTypes.bool -} - -const selectComponent = (props) => { - const subname = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512']; - let index = props.index; - return -} -selectComponent.propTypes = { - paramsInput: PropTypes.func, - index: PropTypes.number, - disabled: PropTypes.bool -} - - -// const handleChange = (v) => { -// console.log('value', v); -// } - const METHODS_LIST = [ { name: 'md5', type: false }, { name: 'lower', type: false }, { name: 'length', type: false }, { name: 'substr', type: true }, - { name: 'sha', type: true, component: selectComponent, subname: ['sha1', 'sha224', 'sha256', 'sha384', 'sha512'] }, + { name: 'sha', type: true, component: "select", subname: ['sha1', 'sha224', 'sha256', 'sha384', 'sha512'] }, { name: 'base64', type: false }, { name: 'unbase64', type: false }, - { name: 'concat', type: true, component: inputComponent }, - { name: 'lconcat', type: true, component: inputComponent }, + { name: 'concat', type: true, component: "input" }, + { name: 'lconcat', type: true, component: "input" }, { name: 'upper', type: false } ] -const MethodsListSource = (props) => { - // console.log("disabled",props.disabled); - return
- {props.component && } -
-} - - -MethodsListSource.propTypes = { - component: PropTypes.any, - paramsInput: PropTypes.func, - paramsIndex: PropTypes.number, - disabled: PropTypes.bool - -} class MethodsList extends Component { static propTypes = { @@ -82,7 +34,6 @@ class MethodsList extends Component { constructor(props) { super(props) this.state = { - filter: '', list: METHODS_LIST.slice(0, 4), moreFlag: true } @@ -99,11 +50,26 @@ class MethodsList extends Component { } - // handleSelectMethod = (methodName)=>{ - // return ()=>{ + inputComponent = (props) => { + let index = props.index + return props.paramsInput(e.target.value, index)} /> + } - // } - // } + selectComponent = (props) => { + const subname = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512']; + let index = props.index; + return + } + + handleParamsChange(){ + + } // unshowMore = () => { @@ -113,6 +79,22 @@ class MethodsList extends Component { // }) // } + handleComponent(item, paramsInput, clickIndex) { + let query = { + disabled: item.name === this.props.clickValue, + paramsInput: paramsInput, + index: clickIndex + } + switch (item.component) { + case 'select': + return this.selectComponent(query); + case 'input': + return this.inputComponent(query); + default: + break; + } + } + render() { const { list, moreFlag } = this.state; const { click, paramsInput, clickValue, clickIndex } = this.props; @@ -128,13 +110,7 @@ class MethodsList extends Component { {item.name} - {item.type && - - } + {item.type && this.handleComponent(item, paramsInput, clickIndex)}