添加标签接口,优化笔记管理界面和逻辑

This commit is contained in:
钊钊 2024-12-20 15:51:37 +08:00
parent 8b7860e3ef
commit e639694427
5 changed files with 45 additions and 26 deletions

View File

@ -6,6 +6,8 @@ export interface ArticleVO {
*/
id: string | number;
tagId_copy: string[] | number[];
region?: string;
regionCode?: string;
/**
*
*/

View File

@ -15,6 +15,18 @@ export const listTag = (query?: TagQuery): AxiosPromise<TagVO[]> => {
params: query
});
};
/**
*
* @param query
* @returns
*/
export const tagAll = (query?: TagQuery): AxiosPromise<TagVO[]> => {
return request({
url: '/manage/tag/all',
method: 'get',
params: query
});
};
/**
*

View File

@ -14,7 +14,7 @@
<span>{{ formatTag(scope.row.tagId.toString()) }}</span>
</template>
</el-table-column>
<el-table-column label="笔记详情" align="center" prop="">
<el-table-column label="笔记详情" align="center" prop="" width="100">
<template #default="scope">
<el-button link type="primary" @click="handleDetail(scope.row)">查看详情</el-button>
</template>
@ -24,7 +24,11 @@
<el-button link type="primary" @click="handleComment(scope.row)">12</el-button>
</template>
</el-table-column>
<el-table-column label="点赞数" align="center" prop="agreeCount" width="80px" />
<el-table-column label="点赞数" align="center" prop="agreeCount" width="80px">
<template #default="scope">
<el-button link type="primary" @click="handleComment(scope.row)">12</el-button>
</template>
</el-table-column>
<el-table-column label="发布状态" align="center" prop="">
<template #default="scope">
<span>{{ scope.row.status == 0 ? '未发布' : scope.row.status == 1 ? '审核中' : scope.row.status == 2 ? '已发布' : '草稿' }}</span>
@ -183,7 +187,7 @@ const handleDelete = (row: any) => {
const formatTag = (tagId: string | null) => {
let tagString = '';
for (let i = 0; i < props.sys_user_tagOptions.length; i++) {
const element = props.sys_user_tagOptions[i];
const element:any = props.sys_user_tagOptions[i];
if (tagId?.includes(element.id)) {
tagString += ',' + element.title;
}

View File

@ -1,7 +1,8 @@
<!-- 笔记管理 -->
<template>
<div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter"
:leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
@ -19,7 +20,8 @@
</el-form-item>
<el-form-item label="发布状态" prop="tagId">
<!-- <el-input v-model="queryParams.tagId" placeholder="请输入标签" clearable @keyup.enter="handleQuery" /> -->
<el-select v-model="queryParams.tagId" placeholder="请选择发布状态" style="width: 240px" @keyup.enter="handleQuery">
<el-select v-model="queryParams.tagId" placeholder="请选择发布状态" style="width: 240px"
@keyup.enter="handleQuery">
<el-option v-for="item in statusoptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
@ -36,7 +38,8 @@
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button v-hasPermi="['manage:notebook:add']" type="primary" plain icon="Plus" @click="handleAdd">新增 </el-button>
<el-button v-hasPermi="['manage:notebook:add']" type="primary" plain icon="Plus" @click="handleAdd">新增
</el-button>
</el-col>
<!-- <el-col :span="1.5">-->
<!-- <el-button v-hasPermi="['manage:notebook:remove']" type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()"-->
@ -97,24 +100,23 @@
<el-table-column label="操作时间" align="center" prop="updateTime" width="200px" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button v-if="scope.row.status != 2" v-hasPermi="['manage:notebook:edit']" link type="primary" @click="handleUpdate(scope.row)"
>编辑</el-button
>
<el-button v-if="scope.row.status != 2" v-hasPermi="['manage:notebook:edit']" link type="primary" @click="fabudata(scope.row)"
>发布</el-button
>
<el-button v-if="scope.row.status == 2" v-hasPermi="['manage:notebook:edit']" link type="primary" @click="fabudata(scope.row)"
>撤销发布</el-button
>
<el-button v-if="scope.row.status != 2" v-hasPermi="['manage:notebook:edit']" link type="primary"
@click="handleUpdate(scope.row)">编辑</el-button>
<el-button v-if="scope.row.status != 2" v-hasPermi="['manage:notebook:edit']" link type="primary"
@click="fabudata(scope.row)">发布</el-button>
<el-button v-if="scope.row.status == 2" v-hasPermi="['manage:notebook:edit']" link type="primary"
@click="fabudata(scope.row)">撤销发布</el-button>
<!-- <el-tooltip content="发布" placement="top">-->
<!-- <el-button v-hasPermi="['manage:notebook:edit']" link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button>-->
<!-- </el-tooltip>-->
<el-button v-hasPermi="['manage:notebook:remove']" link type="primary" @click="handleDelete(scope.row)">删除</el-button>
<el-button v-hasPermi="['manage:notebook:remove']" link type="primary"
@click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
<pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
:total="total" @pagination="getList" />
</el-card>
<!-- 添加或修改笔记对话框 -->
<el-dialog v-model="dialog.visible" :title="dialog.title" width="60%" append-to-body>
@ -231,7 +233,7 @@ const data = reactive<PageData<NotebookForm, NotebookQuery>>({
rules: {
id: [{ required: true, message: '笔记ID不能为空', trigger: 'blur' }],
title: [{ required: true, message: '笔记标题不能为空', trigger: 'blur' }],
content: [{ required: true, message: '攻略内容不能为空', trigger: 'blur' }],
// content: [{ required: true, message: '', trigger: 'blur' }],
// cover: [{ required: true, message: '', trigger: 'blur' }],
status: [{ required: true, message: '帐号状态不能为空', trigger: 'change' }],
tagId: [{ required: true, message: '标签不能为空', trigger: 'blur' }],

View File

@ -399,7 +399,7 @@
</template>
<script setup name="Article" lang="ts">
import { listTag } from '@/api/manage/tag';
import { listTag,tagAll } from '@/api/manage/tag';
import { listArticle, getArticle, delArticle, addArticle, updateArticle, listByTagIdNotebook } from '@/api/manage/scenic';
import { ArticleVO, ArticleQuery, ArticleForm } from '@/api/manage/scenic/types';
import { useRouter } from 'vue-router';
@ -586,8 +586,8 @@ onMounted(() => {
};
});
const getTag = async () => {
const res = await listTag({ pageNum: 1, pageSize: 1000 });
sys_user_tagOptions.value = res.rows; //
const res = await tagAll();
sys_user_tagOptions.value = res; //
};
//
const performSearch = async (text) => {
@ -688,7 +688,7 @@ const cancel = (type: string) => {
}
dialog.visible = false;
noteBookVisible.value = false;
noteBookTagIds.value = null; //
noteBookTagIds.value = ''; //
};
/** 表单重置 */
@ -813,11 +813,10 @@ const handleDetail = async (row?: ArticleVO) => {
* @param row 相关笔记
*/
const noteBookVisible = ref(false);
const noteBookTagIds = ref(null); //id
const noteBookTagIds = ref(''); //id
const handleNote = async (row?: ArticleVO) => {
console.log(row);
noteBookTagIds.value = null;
noteBookTagIds.value = row?.tagId;
noteBookTagIds.value = '';
noteBookTagIds.value = row?.tagId as string;
noteBookVisible.value = true;
console.log(row.tagId);
};