对接帮助文章管理接口

- 新增/编辑/详情/列表/删除接口及类型定义
- 操作列增加上架/下架,图标按钮改为文字按钮
This commit is contained in:
zhouyanli
2026-11-04 09:20:46 +08:00
parent 0bfbc2aaa9
commit 914153a07c
3 changed files with 248 additions and 12 deletions

View File

@@ -74,14 +74,20 @@
<dict-tag :options="ur_help_article_status" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="190">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['helpManage:helpArticle:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['helpManage:helpArticle:remove']"></el-button>
</el-tooltip>
<div class="table-actions">
<el-button
link
:type="isPublished(scope.row) ? 'warning' : 'success'"
@click="handleToggleStatus(scope.row)"
v-hasPermi="['helpManage:helpArticle:edit']"
>
{{ isPublished(scope.row) ? '下架' : '上架' }}
</el-button>
<el-button link type="primary" @click="handleUpdate(scope.row)" v-hasPermi="['helpManage:helpArticle:edit']">修改</el-button>
<el-button link type="danger" @click="handleDelete(scope.row)" v-hasPermi="['helpManage:helpArticle:remove']">删除</el-button>
</div>
</template>
</el-table-column>
</el-table>
@@ -114,6 +120,7 @@
<script setup name="HelpArticle" lang="ts">
import {
addHelpArticle,
changeHelpArticleStatus,
delHelpArticle,
getHelpArticle,
listHelpArticle,
@@ -141,6 +148,9 @@ const helpTabs = [
{ label: '房东帮助', value: '1' }
];
const activeTab = ref('0');
/** 是否已上架(兼容后端返回字符串或数字) */
const isPublished = (row: Partial<HelpArticleVO>) => String(row.status ?? '') === '1';
const helpArticleList = ref<HelpArticleVO[]>([]);
const buttonLoading = ref(false);
const { loading, withLoading } = useLoading(true);
@@ -257,8 +267,8 @@ const handleAdd = () => {
/** 修改按钮操作 */
const handleUpdate = async (row?: Partial<HelpArticleVO>) => {
reset();
const _articleId = row?.articleId || ids.value[0];
const res = await getHelpArticle(_articleId);
const articleId = row?.articleId || ids.value[0];
const res = await getHelpArticle(articleId);
Object.assign(form.value, res.data);
publishNow.value = form.value.status === '1';
showDialog('修改帮助文章');
@@ -282,11 +292,31 @@ const submitForm = () => {
});
};
/**
* 上架 / 下架:PUT /helpManage/helpArticle/status/{articleId}/{status}
* 已上架(1) → 下架(2);草稿(0) / 已下架(2) → 上架(1)
*/
const handleToggleStatus = async (row: Partial<HelpArticleVO>) => {
if (row.articleId == null) return;
const currentStatus = String(row.status ?? '');
const nextStatus = currentStatus === '1' ? '2' : '1';
const actionText = nextStatus === '1' ? '上架' : '下架';
try {
await modal.confirm(`是否确认${actionText}文章"${row.title || row.articleId}"?`);
} catch {
// 用户取消确认
return;
}
await changeHelpArticleStatus(row.articleId, nextStatus);
modal.msgSuccess(`${actionText}成功`);
await getList();
};
/** 删除按钮操作 */
const handleDelete = async (row?: Partial<HelpArticleVO>) => {
const _articleIds = row?.articleId || ids.value;
await modal.confirm('是否确认删除帮助文章编号为"' + _articleIds + '"的数据项?');
await delHelpArticle(_articleIds);
const articleIds = row?.articleId || ids.value;
await modal.confirm('是否确认删除帮助文章编号为"' + articleIds + '"的数据项?');
await delHelpArticle(articleIds);
modal.msgSuccess('删除成功');
await getList();
};
@@ -310,6 +340,35 @@ onMounted(() => {
</script>
<style scoped lang="scss">
/*
* 全局 _search-panel.scss 给 .data-table 里的 link 按钮加了 28x28 的圆角底色(带 !important),
* 操作列是纯文字按钮,这里用同等优先级覆盖掉底色与固定尺寸
*/
.data-table {
:deep(.table-actions) {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
gap: 4px 10px;
}
:deep(.table-actions .el-button.is-link) {
width: auto !important;
min-width: auto !important;
height: auto !important;
padding: 0 !important;
border-radius: 0 !important;
background: transparent !important;
font-size: 13px;
font-weight: 500;
}
:deep(.table-actions .el-button.is-link + .el-button.is-link) {
margin-left: 0 !important;
}
}
.tabs-panel {
:deep(.el-card__body) {
padding: 10px 16px;