watch(
() => route.query.title,
(newQuery, oldQuery) => {
title.value = route.query.title ? route.query.title : "发布成果";
const actions = {
发布成果: GetdraftAchieve,
发布需求: GetdraftDemand,
发布专利: GetdraftPatent,
};
actions[title.value].call();
},
{ immediate: true }
);
function RequestHanle(fnc) {
//注释:check_state 0 未审核 1审核通过 2草稿箱
return fnc({ check_state: 2 }).then((res) => {
if (res.success) {
draftList.value = res.data.currentPageDatas;
}
});
}
function GetdraftAchieve() {
toPath.value = "/results/put?title=发布成果";
editPath.value = "/results/put?title=编辑草稿";
RequestHanle(draftAchieve);
}
function GetdraftDemand() {
toPath.value = "/demands/put?title=发布需求";
editPath.value = "/demands/put?title=编辑草稿";
RequestHanle(draftDemand);
}
function GetdraftPatent() {
toPath.value = "/patent/put?title=发布专利";
editPath.value = "/patent/put?title=编辑草稿";
RequestHanle(draftPatent);
}
简化前:
// watch(() => route.query.title,(newQuery, oldQuery) => {
// title.value=route.query.title
// if(title.value=="发布成果"){
// toPath.value="/results/put?title=发布成果"
// editPath.value="/results/put?title=编辑草稿"
// draftAchieve({
// check_state:2
// }).then((res)=>{
// if(res.success){
// draftList.value=res.data.currentPageDatas
// console.log('draftList',draftList.value)
// }
// })
// }
// else if(title.value=="发布需求"){
// toPath.value="/demands/put?title=发布需求"
// editPath.value="/demands/put?title=编辑草稿"
// draftDemand({
// check_state:2
// }).then((res)=>{
// if(res.success){
// draftList.value=res.data.currentPageDatas
// }
// })
// }
// else if(title.value=="发布专利"){
// toPath.value="/patent/put?title=发布专利"
// editPath.value="/patent/put?title=编辑草稿"
// draftPatent({
// check_state:2
// }).then((res)=>{
// if(res.success){
// draftList.value=res.data.currentPageDatas
// console.log('draftList',draftList.value)
// }
// })
// }
// },{ immediate: true });