对接帮助文章管理接口
- 新增/编辑/详情/列表/删除接口及类型定义 - 操作列增加上架/下架,图标按钮改为文字按钮
This commit is contained in:
77
src/api/helpArticle/index.ts
Normal file
77
src/api/helpArticle/index.ts
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import type { HelpArticleForm, HelpArticleQuery, HelpArticleVO } from '@/api/helpArticle/types';
|
||||||
|
import type { PageResult } from '@/api/types';
|
||||||
|
import type { AxiosPromise } from '@/utils/api-types';
|
||||||
|
import request from '@/utils/request';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询帮助文章列表
|
||||||
|
* @param query
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
export const listHelpArticle = (query?: HelpArticleQuery): AxiosPromise<PageResult<HelpArticleVO>> => {
|
||||||
|
return request({
|
||||||
|
url: '/helpManage/helpArticle/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询帮助文章详细
|
||||||
|
* @param articleId
|
||||||
|
*/
|
||||||
|
export const getHelpArticle = (articleId: string | number): AxiosPromise<HelpArticleVO> => {
|
||||||
|
return request({
|
||||||
|
url: '/helpManage/helpArticle/' + articleId,
|
||||||
|
method: 'get'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增帮助文章
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
export const addHelpArticle = (data: HelpArticleForm) => {
|
||||||
|
return request({
|
||||||
|
url: '/helpManage/helpArticle',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改帮助文章
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
export const updateHelpArticle = (data: HelpArticleForm) => {
|
||||||
|
return request({
|
||||||
|
url: '/helpManage/helpArticle',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改帮助文章状态(上下架)
|
||||||
|
* @param articleId 帮助文章ID
|
||||||
|
* @param status 状态(0草稿 1已上架 2已下架)
|
||||||
|
*/
|
||||||
|
export const changeHelpArticleStatus = (articleId: string | number, status: string) => {
|
||||||
|
return request({
|
||||||
|
url: '/helpManage/helpArticle/status/' + articleId + '/' + status,
|
||||||
|
method: 'put'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除帮助文章
|
||||||
|
* @param articleId
|
||||||
|
*/
|
||||||
|
export const delHelpArticle = (articleId: string | number | Array<string | number>) => {
|
||||||
|
return request({
|
||||||
|
url: '/helpManage/helpArticle/' + articleId,
|
||||||
|
method: 'delete'
|
||||||
|
});
|
||||||
|
};
|
||||||
100
src/api/helpArticle/types.ts
Normal file
100
src/api/helpArticle/types.ts
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
export interface HelpArticleVO {
|
||||||
|
/**
|
||||||
|
* 帮助文章ID
|
||||||
|
*/
|
||||||
|
articleId: string | number;
|
||||||
|
/**
|
||||||
|
* 帮助分类ID
|
||||||
|
*/
|
||||||
|
categoryId: string | number;
|
||||||
|
/**
|
||||||
|
* 适用端(0租客 1房东)
|
||||||
|
*/
|
||||||
|
audience: string;
|
||||||
|
/**
|
||||||
|
* 文章标题
|
||||||
|
*/
|
||||||
|
title: string;
|
||||||
|
/**
|
||||||
|
* 文章内容
|
||||||
|
*/
|
||||||
|
content: string;
|
||||||
|
/**
|
||||||
|
* 状态(0草稿 1已上架 2已下架)
|
||||||
|
*/
|
||||||
|
status: string;
|
||||||
|
/**
|
||||||
|
* 上架时间
|
||||||
|
*/
|
||||||
|
publishedAt: string;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
updateTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HelpArticleForm extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 帮助文章ID
|
||||||
|
*/
|
||||||
|
articleId?: string | number;
|
||||||
|
/**
|
||||||
|
* 帮助分类ID
|
||||||
|
*/
|
||||||
|
categoryId?: number;
|
||||||
|
/**
|
||||||
|
* 适用端(0租客 1房东)
|
||||||
|
*/
|
||||||
|
audience?: string;
|
||||||
|
/**
|
||||||
|
* 文章标题
|
||||||
|
*/
|
||||||
|
title?: string;
|
||||||
|
/**
|
||||||
|
* 文章内容
|
||||||
|
*/
|
||||||
|
content?: string;
|
||||||
|
/**
|
||||||
|
* 状态(0草稿 1已上架 2已下架)
|
||||||
|
*/
|
||||||
|
status?: string;
|
||||||
|
/**
|
||||||
|
* 上架时间
|
||||||
|
*/
|
||||||
|
publishedAt?: string;
|
||||||
|
/**
|
||||||
|
* 创建部门
|
||||||
|
*/
|
||||||
|
createDept?: number;
|
||||||
|
/**
|
||||||
|
* 创建后台账号ID
|
||||||
|
*/
|
||||||
|
createBy?: number;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
createTime?: string;
|
||||||
|
/**
|
||||||
|
* 更新后台账号ID
|
||||||
|
*/
|
||||||
|
updateBy?: number;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
updateTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HelpArticleQuery extends PageQuery {
|
||||||
|
/**
|
||||||
|
* 适用端(0租客 1房东),必传
|
||||||
|
*/
|
||||||
|
audience: string;
|
||||||
|
/**
|
||||||
|
* 文章标题
|
||||||
|
*/
|
||||||
|
title?: string;
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
status?: string;
|
||||||
|
}
|
||||||
@@ -74,14 +74,20 @@
|
|||||||
<dict-tag :options="ur_help_article_status" :value="scope.row.status" />
|
<dict-tag :options="ur_help_article_status" :value="scope.row.status" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</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">
|
<template #default="scope">
|
||||||
<el-tooltip content="修改" placement="top">
|
<div class="table-actions">
|
||||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['helpManage:helpArticle:edit']"></el-button>
|
<el-button
|
||||||
</el-tooltip>
|
link
|
||||||
<el-tooltip content="删除" placement="top">
|
:type="isPublished(scope.row) ? 'warning' : 'success'"
|
||||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['helpManage:helpArticle:remove']"></el-button>
|
@click="handleToggleStatus(scope.row)"
|
||||||
</el-tooltip>
|
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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -114,6 +120,7 @@
|
|||||||
<script setup name="HelpArticle" lang="ts">
|
<script setup name="HelpArticle" lang="ts">
|
||||||
import {
|
import {
|
||||||
addHelpArticle,
|
addHelpArticle,
|
||||||
|
changeHelpArticleStatus,
|
||||||
delHelpArticle,
|
delHelpArticle,
|
||||||
getHelpArticle,
|
getHelpArticle,
|
||||||
listHelpArticle,
|
listHelpArticle,
|
||||||
@@ -141,6 +148,9 @@ const helpTabs = [
|
|||||||
{ label: '房东帮助', value: '1' }
|
{ label: '房东帮助', value: '1' }
|
||||||
];
|
];
|
||||||
const activeTab = ref('0');
|
const activeTab = ref('0');
|
||||||
|
|
||||||
|
/** 是否已上架(兼容后端返回字符串或数字) */
|
||||||
|
const isPublished = (row: Partial<HelpArticleVO>) => String(row.status ?? '') === '1';
|
||||||
const helpArticleList = ref<HelpArticleVO[]>([]);
|
const helpArticleList = ref<HelpArticleVO[]>([]);
|
||||||
const buttonLoading = ref(false);
|
const buttonLoading = ref(false);
|
||||||
const { loading, withLoading } = useLoading(true);
|
const { loading, withLoading } = useLoading(true);
|
||||||
@@ -257,8 +267,8 @@ const handleAdd = () => {
|
|||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
const handleUpdate = async (row?: Partial<HelpArticleVO>) => {
|
const handleUpdate = async (row?: Partial<HelpArticleVO>) => {
|
||||||
reset();
|
reset();
|
||||||
const _articleId = row?.articleId || ids.value[0];
|
const articleId = row?.articleId || ids.value[0];
|
||||||
const res = await getHelpArticle(_articleId);
|
const res = await getHelpArticle(articleId);
|
||||||
Object.assign(form.value, res.data);
|
Object.assign(form.value, res.data);
|
||||||
publishNow.value = form.value.status === '1';
|
publishNow.value = form.value.status === '1';
|
||||||
showDialog('修改帮助文章');
|
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 handleDelete = async (row?: Partial<HelpArticleVO>) => {
|
||||||
const _articleIds = row?.articleId || ids.value;
|
const articleIds = row?.articleId || ids.value;
|
||||||
await modal.confirm('是否确认删除帮助文章编号为"' + _articleIds + '"的数据项?');
|
await modal.confirm('是否确认删除帮助文章编号为"' + articleIds + '"的数据项?');
|
||||||
await delHelpArticle(_articleIds);
|
await delHelpArticle(articleIds);
|
||||||
modal.msgSuccess('删除成功');
|
modal.msgSuccess('删除成功');
|
||||||
await getList();
|
await getList();
|
||||||
};
|
};
|
||||||
@@ -310,6 +340,35 @@ onMounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<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 {
|
.tabs-panel {
|
||||||
:deep(.el-card__body) {
|
:deep(.el-card__body) {
|
||||||
padding: 10px 16px;
|
padding: 10px 16px;
|
||||||
|
|||||||
Reference in New Issue
Block a user