mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-15 05:10:47 +08:00
fix: 点击重构前
This commit is contained in:
parent
7d065c5f2a
commit
77a75f4585
@ -38,7 +38,8 @@ class MethodsList extends Component {
|
|||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
list: METHODS_LIST,
|
list: METHODS_LIST,
|
||||||
moreFlag: true
|
moreFlag: true,
|
||||||
|
index: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +59,12 @@ class MethodsList extends Component {
|
|||||||
inputComponent = (props) => {
|
inputComponent = (props) => {
|
||||||
let clickIndex = props.clickIndex;
|
let clickIndex = props.clickIndex;
|
||||||
let paramsIndex = props.paramsIndex;
|
let paramsIndex = props.paramsIndex;
|
||||||
return <Input size="small" placeholder="请输入参数" disabled={!props.disabled} onChange={(e) => this.handleParamsChange(e.target.value, clickIndex, paramsIndex)} />
|
return <Input
|
||||||
|
size="small"
|
||||||
|
placeholder="请输入参数"
|
||||||
|
disabled={!props.disabled}
|
||||||
|
onChange={(e) => this.handleParamsChange(e.target.value, clickIndex, paramsIndex)}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
|
||||||
selectComponent = (props) => {
|
selectComponent = (props) => {
|
||||||
@ -83,7 +89,7 @@ class MethodsList extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
list: newList
|
list: newList
|
||||||
})
|
})
|
||||||
console.log('list', this.state.list);
|
// console.log('list', this.state.list);
|
||||||
this.props.paramsInput(value, clickIndex);
|
this.props.paramsInput(value, clickIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,19 +111,32 @@ class MethodsList extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleRadioChange = (e) => {
|
||||||
|
console.log(e);
|
||||||
|
this.state.list.forEach(item=>{
|
||||||
|
if(item.name === clickValue) {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.props.click(e);
|
||||||
|
// console.log('state', this.state.index);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { list, moreFlag } = this.state;
|
const { list, moreFlag, index } = this.state;
|
||||||
const { click, clickValue, clickIndex } = this.props;
|
const { click,clickValue, clickIndex } = this.props;
|
||||||
// console.log('click', clickValue);
|
console.log('click', clickValue);
|
||||||
let showList = moreFlag ? list.slice(0,4) :list;
|
console.log('state', this.state.index);
|
||||||
|
let showList = moreFlag ? list.slice(0, 4) : list;
|
||||||
return (
|
return (
|
||||||
<div className="modal-postman-form-method">
|
<div className="modal-postman-form-method">
|
||||||
<h3 className="methods-title title">方法</h3>
|
<h3 className="methods-title title">方法</h3>
|
||||||
<RadioGroup onChange={click} value={clickValue}>
|
<RadioGroup onChange={(e) => this.handleRadioChange(e} value={clickValue}>
|
||||||
{
|
{
|
||||||
showList.map((item, index) => {
|
showList.map((item, index) => {
|
||||||
return <Row key={index} type="flex" align="middle" className="row methods-row">
|
return <Row key={index} type="flex" align="middle" className="row methods-row">
|
||||||
<RadioButton value={item.name}>
|
<RadioButton value={item.name} onClick={click}>
|
||||||
<span>{item.name}</span>
|
<span>{item.name}</span>
|
||||||
<span className="input-component">
|
<span className="input-component">
|
||||||
{item.type && this.handleComponent(item, clickIndex, index)}
|
{item.type && this.handleComponent(item, clickIndex, index)}
|
||||||
|
@ -13,16 +13,19 @@ function deepEqual(state) {
|
|||||||
return JSON.parse(JSON.stringify(state))
|
return JSON.parse(JSON.stringify(state))
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeRightTabsAndAddNewTab(arr, index, curname) {
|
function closeRightTabsAndAddNewTab(arr, index, curname, params) {
|
||||||
|
console.log(params);
|
||||||
let newParamsList = [].concat(arr);
|
let newParamsList = [].concat(arr);
|
||||||
newParamsList.splice(index + 1, newParamsList.length - index);
|
newParamsList.splice(index + 1, newParamsList.length - index);
|
||||||
newParamsList.push({
|
newParamsList.push({
|
||||||
name: '', params: []
|
name: '', params: []
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let curParams = params&¶ms.name ===curname ? params.params:[];
|
||||||
newParamsList[index] = {
|
newParamsList[index] = {
|
||||||
...newParamsList[index],
|
...newParamsList[index],
|
||||||
name: curname,
|
name: curname,
|
||||||
params: []
|
params: curParams
|
||||||
}
|
}
|
||||||
return newParamsList;
|
return newParamsList;
|
||||||
|
|
||||||
@ -53,9 +56,10 @@ class ModalPostman extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mockClick(index) {
|
mockClick(index) {
|
||||||
return (e) => {
|
return (e, params) => {
|
||||||
|
console.log('value', params);
|
||||||
let curname = e.target.value;
|
let curname = e.target.value;
|
||||||
let newParamsList = closeRightTabsAndAddNewTab(this.state.methodsParamsList, index, curname)
|
let newParamsList = closeRightTabsAndAddNewTab(this.state.methodsParamsList, index, curname, params)
|
||||||
this.setState({
|
this.setState({
|
||||||
methodsParamsList: newParamsList
|
methodsParamsList: newParamsList
|
||||||
})
|
})
|
||||||
@ -84,9 +88,9 @@ class ModalPostman extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { visible, handleCancel, handleOk } = this.props
|
const { visible, handleCancel, handleOk } = this.props
|
||||||
const { methodsParamsList } = this.state;
|
const { methodsParamsList } = this.state;
|
||||||
const { name } = methodsParamsList[0];
|
const { name } = methodsParamsList[0];
|
||||||
// console.log('list', this.state.methodsParamsList);
|
console.log('list', this.state.methodsParamsList);
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={<p><Icon type="edit" /> 高级参数设置</p>}
|
title={<p><Icon type="edit" /> 高级参数设置</p>}
|
||||||
@ -119,7 +123,7 @@ class ModalPostman extends Component {
|
|||||||
{
|
{
|
||||||
methodsParamsList.map((item, index) => {
|
methodsParamsList.map((item, index) => {
|
||||||
return item.name &&
|
return item.name &&
|
||||||
<span className="expression-item" key={index}>{item.name}({item.params})</span>
|
<span className="expression-item" key={index}>{item.name}({item.params})</span>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
<span>{'}'}</span>
|
<span>{'}'}</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user