调整
This commit is contained in:
parent
64e8cdba0a
commit
a1b4f465db
@ -90,6 +90,7 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const moduleName:any = route.query.moduleName;
|
||||
const labelName:any = route.query.labelName;
|
||||
const id:any = route.query.id;
|
||||
|
||||
const state = reactive({
|
||||
data: {
|
||||
@ -118,7 +119,23 @@ const getArticleDetail = async() => {
|
||||
});
|
||||
if(res?.success) {
|
||||
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) {
|
||||
ElMessage.error('获取文章详情失败');
|
||||
@ -156,7 +173,11 @@ function dateFormatter(){
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getArticleDetail();
|
||||
if(moduleName && moduleName !== '人才模块' && moduleName !== '简历模块'){
|
||||
getArticleDetailById(id);
|
||||
}else{
|
||||
getArticleDetail();
|
||||
}
|
||||
getModuleList();
|
||||
})
|
||||
|
||||
|
@ -125,7 +125,7 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const moduleName:any = route.query.moduleName;
|
||||
const labelName:any = route.query.labelName;
|
||||
|
||||
const id:any = route.query.id;
|
||||
|
||||
const state = reactive({
|
||||
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;
|
||||
// 下面这里处理一下,因为后端返回的是0和1,而前端需要的是true和false,到时候提交的时候再转换回来
|
||||
// 这个报错没关系的,只是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() => {
|
||||
try {
|
||||
@ -317,7 +343,13 @@ const handleUploadChange = (uploadFile: UploadFile, uploadFiles: UploadFiles) =>
|
||||
}
|
||||
|
||||
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();
|
||||
})
|
||||
|
||||
|
@ -168,12 +168,12 @@ const toAddArticle = () => {
|
||||
|
||||
// 添加文章
|
||||
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) => {
|
||||
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 } });
|
||||
}
|
||||
|
||||
// 文章删除
|
||||
|
Loading…
Reference in New Issue
Block a user