修复任务的搜索中的项目阶段联动,清空项目报错问题
This commit is contained in:
@@ -351,7 +351,6 @@ const oldAttachments = ref<any[]>([]);
|
||||
|
||||
const changeFun = async (val: any, type: string) => {
|
||||
const formData = tableFormRef.value.getFormDataFun();
|
||||
|
||||
editFormInfo.value = { ...formData };
|
||||
if (val.key === 'projectId') {
|
||||
let nodeType = '';
|
||||
@@ -362,13 +361,22 @@ const changeFun = async (val: any, type: string) => {
|
||||
nextKey = 'phaseId';
|
||||
nodeId = val.data.projectId;
|
||||
}
|
||||
const optionList = await getPhaseList(nodeType, nodeId);
|
||||
tableFormRef.value.setOptionsFun(nextKey, optionList);
|
||||
if (nextKey === 'phaseId' && optionList.length > 0) {
|
||||
formData.phaseId = optionList[0].value;
|
||||
}
|
||||
if (optionList.length === 0) {
|
||||
if (nodeId) {
|
||||
const optionList = await getPhaseList(nodeType, nodeId);
|
||||
tableFormRef.value.setOptionsFun(nextKey, optionList);
|
||||
if (nextKey === 'phaseId' && optionList.length > 0) {
|
||||
formData.phaseId = optionList[0].value;
|
||||
formData.workspace = await getWorkSpaceList(formData.phaseId);
|
||||
formData.extras = setWorkSpaceValue(formData.extras, formData.workspace);
|
||||
}
|
||||
if (optionList.length === 0) {
|
||||
formData.phaseId = '';
|
||||
}
|
||||
} else {
|
||||
tableFormRef.value.setOptionsFun(nextKey, []);
|
||||
formData.phaseId = '';
|
||||
formData.workspace = '';
|
||||
formData.extras = setWorkSpaceValue(formData.extras, formData.workspace);
|
||||
}
|
||||
// const formData = tableFormRef.value.getFormDataFun();
|
||||
// tableFormRef.value.setFormDataFun({ ...formData, phaseId: '' });
|
||||
@@ -376,29 +384,53 @@ const changeFun = async (val: any, type: string) => {
|
||||
}
|
||||
|
||||
if (val.key === 'phaseId') {
|
||||
const res: any = await getChildrenNodeListApi({
|
||||
current: 1,
|
||||
size: 999,
|
||||
nodeId: formData.phaseId,
|
||||
nodeType: NODE_TYPE.WORKSPACE,
|
||||
});
|
||||
if (res.code === 200) {
|
||||
if (res.data.length === 0) {
|
||||
ElMessage.warning('该阶段下没有工位,请先做仿真策划!');
|
||||
} else {
|
||||
tableFormRef.value.setOptionsFun(
|
||||
NODE_TYPE.WORKSPACE,
|
||||
res.data.map((item: { nodeName: string; uuid: string }) => {
|
||||
return {
|
||||
label: item.nodeName,
|
||||
value: item.uuid,
|
||||
};
|
||||
})
|
||||
);
|
||||
if (formData.phaseId) {
|
||||
formData.workspace = await getWorkSpaceList(formData.phaseId);
|
||||
formData.extras = setWorkSpaceValue(formData.extras, formData.workspace);
|
||||
} else {
|
||||
formData.workspace = '';
|
||||
formData.extras = setWorkSpaceValue(formData.extras, formData.workspace);
|
||||
}
|
||||
editFormInfo.value = { ...formData };
|
||||
}
|
||||
console.log('changeFun');
|
||||
emits('changeForm', { val, type });
|
||||
};
|
||||
|
||||
const setWorkSpaceValue = (extras: any, workspace: string) => {
|
||||
return extras.map((item: any) => {
|
||||
if (item.propertyName === NODE_TYPE.WORKSPACE) {
|
||||
item.propertyValue = workspace;
|
||||
}
|
||||
return {
|
||||
...item,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const getWorkSpaceList = async (phaseId: string) => {
|
||||
const res: any = await getChildrenNodeListApi({
|
||||
current: 1,
|
||||
size: 999,
|
||||
nodeId: phaseId,
|
||||
nodeType: NODE_TYPE.WORKSPACE,
|
||||
});
|
||||
if (res.code === 200) {
|
||||
if (res.data.length === 0) {
|
||||
ElMessage.warning('该阶段下没有工位,请先做仿真策划!');
|
||||
} else {
|
||||
const optionList = res.data.map((item: { nodeName: string; uuid: string }) => {
|
||||
return {
|
||||
label: item.nodeName,
|
||||
value: item.uuid,
|
||||
};
|
||||
});
|
||||
tableFormRef.value.setOptionsFun(NODE_TYPE.WORKSPACE, optionList);
|
||||
if (optionList.length > 0) {
|
||||
return optionList[0].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
emits('changeForm', { val, type });
|
||||
};
|
||||
|
||||
const getPhaseList = async (nodeType: string, projectUuid: string) => {
|
||||
|
||||
Reference in New Issue
Block a user