feat: 测试集合环境变量样式

This commit is contained in:
gaoxiaolin.gao 2018-05-22 10:54:56 +08:00
parent 5f99f4368f
commit 52d1b51810
4 changed files with 406 additions and 462 deletions

View File

@ -2,123 +2,90 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Select, Row, Col } from 'antd';
import { Select, Row, Col, Collapse, Icon, Tooltip } from 'antd';
const Option = Select.Option;
import './index.scss'
// import { connect } from 'react-redux';
const Panel = Collapse.Panel;
import './index.scss';
// 数组去重
// function unique(array, compare) {
// let hash = {};
// let arr = array.reduce(function(item, next) {
// hash[next[compare]] ? '' : (hash[next[compare]] = true && item.push(next));
// // console.log('item',item.project_id)
// return item;
// }, []);
// // 输出去重以后的project_id
// return arr.map(item => {
// return item[compare]
// })
// }
// function checkProjectIsExistInArray(project_id, arr) {
// let isRepeat = false;
// for (let i = 0; i < arr.length; i++) {
// let item = arr[i];
// if (item.project_id === project_id) {
// isRepeat = true;
// break;
// }
// }
// return isRepeat;
// }
// @connect(
// state => {
// return {
// projectList: state.project.projectList
// }
// },
// {
// }
// )
export default class CaseEnv extends React.Component {
constructor(props) {
super(props);
// this.state = {
// envList: []
// };
// this.state = { envList: [] };
}
static propTypes = {
envList: PropTypes.array,
currProjectEnvChange: PropTypes.func
// fetchProjectList: PropTypes.func
};
// componentWillReceiveProps(nextProps) {
// // console.log('next',nextProps.projectList)
// if (nextProps.projectList.length > 0) {
// this.handleProjectList(nextProps.data);
// // console.log('data',nextProps.data)
// // if(this.props.data !== nextProps.data) {
// // console.log(111)
// // this.handleProjectList(nextProps.data);
// // }
// }
// }
// handleProjectList = async data => {
// let envList = [];
// this.props.projectList.forEach(item => {
// if (checkProjectIsExistInArray(item._id, data)) {
// envList.push(item);
// }
// });
// console.log('env', envList);
// this.setState({
// envList
// });
// };
// handleChange = (val, id) => {
// console.log(val);
// console.log(id)
// };
render() {
return (
<div className="case-env">
{this.props.envList.length > 0 && (
<div>
{this.props.envList.map(item => {
return (
<Row key={item._id} type="flex" justify="space-around" align="middle" className="env-item">
<Col span={6} className="label">{item.name} :</Col>
<Col span={18}>
<Select style={{ width: 300 }} defaultValue="" onChange={(val) => this.props.currProjectEnvChange(val, item._id)}>
<Option key="default" value="">默认环境</Option>
{item.env.map(key => {
return (
<Option value={key.name} key={key._id}>
{key.name + ": " + key.domain}
<Collapse
style={{
margin: 0,
marginBottom: '16px'
}}
>
<Panel
header={
<span>
{' '}
选择测试用例环境
<Tooltip title="默认使用测试用例选择的环境">
{' '}
<Icon type="question-circle-o" />{' '}
</Tooltip>
</span>
}
key="1"
>
<div className="case-env">
{this.props.envList.length > 0 && (
<div>
{this.props.envList.map(item => {
return (
<Row
key={item._id}
type="flex"
justify="space-around"
align="middle"
className="env-item"
>
<Col span={6} className="label">
{item.name}
:
</Col>
<Col span={18}>
<Select
style={{
width: '100%'
}}
defaultValue=""
onChange={val => this.props.currProjectEnvChange(val, item._id)}
>
<Option key="default" value="">
默认环境
</Option>
);
})}
</Select>
</Col>
</Row>
);
})}
{item.env.map(key => {
return (
<Option value={key.name} key={key._id}>
{key.name + ': ' + key.domain}
</Option>
);
})}
</Select>
</Col>
</Row>
);
})}
</div>
)}
</div>
)}
</div>
</Panel>
</Collapse>
);
}
}

View File

@ -169,7 +169,7 @@ class interfaceColController extends baseController {
}
}
// let caseList= await yapi.commons.getCaseList(id);
// 通过col_id 找到 caseList
let projectList = await this.caseModel.list(id, 'project_id')
// 对projectList 进行去重处理

View File

@ -145,8 +145,7 @@ class openController extends baseController {
const testList = [];
let id = ctx.params.id;
let curEnvList = this.handleEvnParams(ctx.params);
// console.log('curEnvList', curEnvList);
// let curEnv = ctx.params.env_name;
let colData = await this.interfaceColModel.get(id);
if (!colData) {
return (ctx.body = yapi.commons.resReturn(null, 40022, 'id值不存在'));
@ -187,7 +186,7 @@ class openController extends baseController {
params: result.params,
body: result.res_body
};
testList.push(result);
testList.push(result);
}
function getMessage(testList) {