update test case tip

chromesetting
tangjiang 5 years ago
parent f96f984386
commit ec4eba76ce

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 16:35:46
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-20 18:46:00
* @LastEditTime: 2019-12-20 19:54:09
*/
import types from './actionTypes';
import CONST from '../../constants';
@ -135,22 +135,22 @@ export const validateOjForm = (props, type) => {
} else {
// 唯一性校验
const bool = testCases.some((item, j) => {
if (i !== j) {
if (i > j && key === 'input') {
return (item[key] === value);
} else {
return false;
}
});
// if (bool) {
// hasSuccess = false;
// validateResult = {
// [key]: {
// validateStatus: 'error',
// errMsg: key === 'input' ? '输入值必须是唯一的' : '输出值必须是唯一的'
// }
// };
// }
if (bool) {
hasSuccess = false;
validateResult = {
[key]: {
validateStatus: 'error',
errMsg: `与测试用例${i}的输入值重复了,请重新填写`
}
};
}
}
Object.assign(tempObj, validateResult);
});
@ -481,48 +481,48 @@ export const testCaseInputChange = (value, index) => {
// 测试用例输出值改变时
export const testCaseOutputChange = (value, index) => {
// const validate = emptyValidate('output', value)['output'];
// return {
// type: types.TEST_CASE_OUTPUT_CHANGE,
// payload: {
// output: validate,
// value,
// index
// }
// }
return (dispatch, getState) => {
// 非空校验
let validate = emptyValidate('output', value)['output'];
if (!validate.errMsg) {
// 唯一性校验
const {testCases} = getState().ojFormReducer;
let _errMsg = '输出值不能为空';
const bool = testCases.some((item, i) => {
if (i !== index) {
// if (item['output'] === value) {
// _errMsg=`与测试用例${index}的输入值重复了,请重新填写`;
// }
return item['output'] === value;
} else {
return false;
}
});
if (bool) {
validate = {
validateStatus: 'error',
errMsg: _errMsg
};
}
const validate = emptyValidate('output', value)['output'];
return {
type: types.TEST_CASE_OUTPUT_CHANGE,
payload: {
output: validate,
value,
index
}
dispatch({
type: types.TEST_CASE_OUTPUT_CHANGE,
payload: {
output: validate,
value,
index
}
});
}
// return (dispatch, getState) => {
// // 非空校验
// let validate = emptyValidate('output', value)['output'];
// if (!validate.errMsg) {
// // 唯一性校验
// const {testCases} = getState().ojFormReducer;
// let _errMsg = '';
// const bool = testCases.some((item, i) => {
// if (i !== index) {
// // if (item['output'] === value) {
// // _errMsg=`与测试用例${index}的输入值重复了,请重新填写`;
// // }
// return item['output'] === value;
// } else {
// return false;
// }
// });
// if (bool) {
// validate = {
// validateStatus: 'error',
// errMsg: _errMsg
// };
// }
// }
// dispatch({
// type: types.TEST_CASE_OUTPUT_CHANGE,
// payload: {
// output: validate,
// value,
// index
// }
// });
// }
}
// // 调试代码时,更改对应的状态值

Loading…
Cancel
Save