update test case tip

chromesetting
tangjiang 5 years ago
parent f96f984386
commit ec4eba76ce

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