feat(1.3.0-beta1): 优化参数传递

This commit is contained in:
opensnail 2024-12-28 20:37:26 +08:00
parent 40568d5c98
commit 84802a02ce

View File

@ -109,40 +109,52 @@ function createDefaultScriptParams() {
}
function handleUpdateModelWhenEdit() {
if (props.rowData) {
Object.assign(model, props.rowData);
// 1: 2:广 3: 4:Map 5:MapReduce
if (props.rowData.taskType === 3 && props.rowData.argsStr) {
Object.assign(dynamicForm, {
args: JSON.parse(props.rowData.argsStr).map((item: string) => {
return { arg: item };
})
});
}
if (props.rowData.taskType === 5 && props.rowData.argsStr) {
const argsJson = JSON.parse(props.rowData.argsStr);
shardNum.value = argsJson.shardNum;
model.tmpArgsStr = argsJson.argsStr;
}
if (executorCustomOptions.map(item => item.value).includes(props.rowData.executorInfo)) {
if (props.rowData.executorInfo === 'snailJobHttpExecutor') {
Object.assign(httpParams, JSON.parse(props.rowData.argsStr));
if (httpParams.headers) {
httpHeaders.value = Object.keys(httpParams.headers).map((item: string) => {
return { key: item, value: httpParams.headers![item] };
});
}
} else {
Object.assign(scriptParams, JSON.parse(props.rowData.argsStr));
}
}
} else {
if (!props.rowData) {
Object.assign(model, createDefaultModel());
httpHeaders.value = [];
Object.assign(httpParams, createDefaultHttpParams());
Object.assign(scriptParams, createDefaultScriptParams());
return;
}
Object.assign(model, props.rowData);
const taskType = props.rowData.taskType;
const argsStr = props.rowData.argsStr;
if (!argsStr) {
return;
}
// 1: 2:广 4:Map
model.tmpArgsStr = argsStr;
// 3:
if (taskType === 3) {
Object.assign(dynamicForm, {
args: JSON.parse(argsStr).map((item: string) => {
return { arg: item };
})
});
}
// 5:MapReduce
if (taskType === 5) {
const argsJson = JSON.parse(argsStr);
shardNum.value = argsJson.shardNum;
model.tmpArgsStr = argsJson.argsStr;
}
if (executorCustomOptions.map(item => item.value).includes(props.rowData.executorInfo)) {
if (props.rowData.executorInfo === 'snailJobHttpExecutor') {
Object.assign(httpParams, JSON.parse(argsStr));
if (httpParams.headers) {
httpHeaders.value = Object.keys(httpParams.headers).map((item: string) => {
return { key: item, value: httpParams.headers![item] };
});
}
} else {
Object.assign(scriptParams, JSON.parse(argsStr));
}
}
}