This commit is contained in:
Double-_-Z 2024-11-12 17:35:06 +08:00
parent 64e8cdba0a
commit a1b4f465db
3 changed files with 59 additions and 6 deletions

View File

@ -90,6 +90,7 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const moduleName:any = route.query.moduleName; const moduleName:any = route.query.moduleName;
const labelName:any = route.query.labelName; const labelName:any = route.query.labelName;
const id:any = route.query.id;
const state = reactive({ const state = reactive({
data: { data: {
@ -118,7 +119,23 @@ const getArticleDetail = async() => {
}); });
if(res?.success) { if(res?.success) {
state.data = res.data.records[0]; state.data = res.data.records[0];
console.log(encodeURI(viteUrl+state.data.photo)) }
} catch (error) {
ElMessage.error('获取文章详情失败');
} finally {
state.loading = false;
}
}
// -id
const getArticleDetailById = async(id:number) => {
try {
state.loading = true;
let res = await artApi.getArticleDetail(id);
if(res?.success) {
state.data = res.data;
state.data.moduleName = moduleName;
state.data.labelName = labelName;
} }
} catch (error) { } catch (error) {
ElMessage.error('获取文章详情失败'); ElMessage.error('获取文章详情失败');
@ -156,7 +173,11 @@ function dateFormatter(){
} }
onMounted(() => { onMounted(() => {
getArticleDetail(); if(moduleName && moduleName !== '人才模块' && moduleName !== '简历模块'){
getArticleDetailById(id);
}else{
getArticleDetail();
}
getModuleList(); getModuleList();
}) })

View File

@ -125,7 +125,7 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const moduleName:any = route.query.moduleName; const moduleName:any = route.query.moduleName;
const labelName:any = route.query.labelName; const labelName:any = route.query.labelName;
const id:any = route.query.id;
const state = reactive({ const state = reactive({
data: { data: {
@ -199,6 +199,32 @@ const getArticleDetail = async() => {
} }
} }
// -id
const getArticleDetailById = async(id:number) => {
try {
state.loading = true;
let res = await artApi.getArticleDetail(id);
if(res?.success) {
state.data = res.data;
// 01truefalse
// ts
state.data.top = state.data.top === 1;
state.data.moduleName = moduleName;
state.data.labelName = labelName;
state.data.textid = state.data.id;
if(state.data.photo){
const never:any = [{name:state.data.title,url:viteUrl+state.data.photo}];
state.fileArray = never;
state.coverHide = true;
}
}
} catch (error) {
ElMessage.error('获取文章详情失败');
} finally {
state.loading = false;
}
}
// //
const getModuleList = async() => { const getModuleList = async() => {
try { try {
@ -317,7 +343,13 @@ const handleUploadChange = (uploadFile: UploadFile, uploadFiles: UploadFiles) =>
} }
onMounted(() => { onMounted(() => {
if(moduleName && labelName && route.path == '/article/edit') getArticleDetail(); if(moduleName && labelName && route.path == '/article/edit') {
if(moduleName && moduleName !== '人才模块' && moduleName !== '简历模块'){
getArticleDetailById(id);
}else{
getArticleDetail();
}
}
getModuleList(); getModuleList();
}) })

View File

@ -168,12 +168,12 @@ const toAddArticle = () => {
// //
const toEditArticle = (row: any) => { const toEditArticle = (row: any) => {
router.push({ path: '/article/edit', query: { moduleName: row.moduleName, labelName: row.labelName } }); router.push({ path: '/article/edit', query: { id:row.id, moduleName: row.moduleName, labelName: row.labelName } });
} }
// //
const toShowDetail = (row: any) => { const toShowDetail = (row: any) => {
router.push({ path: '/article/detail' , query: { moduleName: row.moduleName, labelName: row.labelName } }); router.push({ path: '/article/detail' , query: { id:row.id, moduleName: row.moduleName, labelName: row.labelName } });
} }
// //