修复任务的搜索中的项目阶段联动,清空项目报错问题
This commit is contained in:
@@ -90,7 +90,7 @@ const props = defineProps({
|
||||
|
||||
const { PROJECT_EXE_STATUS } = useDict('PROJECT_EXE_STATUS');
|
||||
|
||||
const emits = defineEmits(['update:projectInfo', 'loadComplete']);
|
||||
const emits = defineEmits(['update:projectInfo', 'loaded']);
|
||||
const nodeInfo = reactive<any>({
|
||||
nodeName: '',
|
||||
creator: '',
|
||||
@@ -152,7 +152,7 @@ watch(
|
||||
() => props.nodeId,
|
||||
async () => {
|
||||
await getNodeDetailFun();
|
||||
emits('loadComplete');
|
||||
emits('loaded');
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
<baseInfo
|
||||
ref="basePageRef"
|
||||
@update:projectInfo="updateProjectInfo"
|
||||
@loadComplete="projectInfoLoadCompleteFun"
|
||||
@loaded="projectInfoLoadCompleteFun"
|
||||
v-if="projectUuid"
|
||||
:nodeId="projectUuid"
|
||||
/>
|
||||
|
||||
@@ -150,6 +150,7 @@ const demandInfo = reactive({
|
||||
});
|
||||
|
||||
const changeFun = async (val: any, type: string) => {
|
||||
console.log('changeFun changeFun');
|
||||
let optionRef: any;
|
||||
if (type === 'search') {
|
||||
optionRef = tableRef.value;
|
||||
@@ -165,8 +166,16 @@ const changeFun = async (val: any, type: string) => {
|
||||
nextKey = 'phaseId';
|
||||
nodeId = val.data.projectId;
|
||||
}
|
||||
const optionList = await getPhaseList(nodeType, nodeId);
|
||||
optionRef.setOptionsFun(nextKey, optionList);
|
||||
if (nodeId) {
|
||||
const optionList = await getPhaseList(nodeType, nodeId);
|
||||
optionRef.setOptionsFun(nextKey, optionList);
|
||||
} else {
|
||||
optionRef.setOptionsFun(nextKey, []);
|
||||
optionRef?.setSearchParamsFun({
|
||||
...optionRef?.getSearchParamsFun(),
|
||||
phaseId: '',
|
||||
});
|
||||
}
|
||||
}
|
||||
if (val.key === 'demandType') {
|
||||
const simTypeList: any = commonStore.getDictData(val.data.demandType);
|
||||
|
||||
@@ -334,6 +334,11 @@ const changeFun = async (val: any, type: string) => {
|
||||
optionRef.setOptionsFun(nextKey, optionList);
|
||||
} else {
|
||||
optionRef.setOptionsFun(nextKey, []);
|
||||
optionRef?.setSearchParamsFun({
|
||||
...optionRef?.getSearchParamsFun(),
|
||||
[nextKey]: '',
|
||||
});
|
||||
phaseUuid.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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