refactor: 适配后端删除接口重构,由 URL 传参重构为请求体传参

This commit is contained in:
2025-04-13 18:02:12 +08:00
parent 987dddf55a
commit 62a4f5faf4
14 changed files with 34 additions and 29 deletions

View File

@@ -27,7 +27,7 @@ export function updateApp(data: any, id: string) {
/** @desc 删除应用 */ /** @desc 删除应用 */
export function deleteApp(id: string) { export function deleteApp(id: string) {
return http.del(`${BASE_URL}/${id}`) return http.del(`${BASE_URL}`, { ids: [id] })
} }
/** @desc 导出应用 */ /** @desc 导出应用 */

View File

@@ -26,6 +26,6 @@ export function updateClient(data: any, id: string) {
} }
/** @desc 删除终端 */ /** @desc 删除终端 */
export function deleteClient(ids: string | Array<string>) { export function deleteClient(id: string) {
return http.del(`${BASE_URL}/${ids}`) return http.del(`${BASE_URL}`, { ids: [id] })
} }

View File

@@ -27,7 +27,7 @@ export function updateDept(data: any, id: string) {
/** @desc 删除部门 */ /** @desc 删除部门 */
export function deleteDept(id: string) { export function deleteDept(id: string) {
return http.del(`${BASE_URL}/${id}`) return http.del(`${BASE_URL}`, { ids: [id] })
} }
/** @desc 导出部门 */ /** @desc 导出部门 */

View File

@@ -27,7 +27,7 @@ export function updateDict(data: any, id: string) {
/** @desc 删除字典 */ /** @desc 删除字典 */
export function deleteDict(id: string) { export function deleteDict(id: string) {
return http.del(`${BASE_URL}/${id}`) return http.del(`${BASE_URL}`, { ids: [id] })
} }
/** @desc 清除字典缓存 */ /** @desc 清除字典缓存 */
@@ -57,5 +57,5 @@ export function updateDictItem(data: any, id: string) {
/** @desc 删除字典项 */ /** @desc 删除字典项 */
export function deleteDictItem(id: string) { export function deleteDictItem(id: string) {
return http.del(`${BASE_URL}/item/${id}`) return http.del(`${BASE_URL}/item`, { ids: [id] })
} }

View File

@@ -16,8 +16,8 @@ export function updateFile(data: any, id: string) {
} }
/** @desc 删除文件 */ /** @desc 删除文件 */
export function deleteFile(ids: string | Array<string>) { export function deleteFile(id: string) {
return http.del(`${BASE_URL}/${ids}`) return http.del(`${BASE_URL}`, { ids: [id] })
} }
/** @desc 查询文件资源统计统计 */ /** @desc 查询文件资源统计统计 */

View File

@@ -27,7 +27,7 @@ export function updateMenu(data: any, id: string) {
/** @desc 删除菜单 */ /** @desc 删除菜单 */
export function deleteMenu(id: string) { export function deleteMenu(id: string) {
return http.del(`${BASE_URL}/${id}`) return http.del(`${BASE_URL}`, { ids: [id] })
} }
/** @desc 清除菜单缓存 */ /** @desc 清除菜单缓存 */

View File

@@ -11,13 +11,18 @@ export function listMessage(query: T.MessagePageQuery) {
} }
/** @desc 删除消息 */ /** @desc 删除消息 */
export function deleteMessage(ids: string | Array<string>) { export function deleteMessage(ids: Array<string>) {
return http.del(`${BASE_URL}/${ids}`) return http.del(`${BASE_URL}`, { ids })
} }
/** @desc 标记已读 */ /** @desc 标记已读 */
export function readMessage(ids?: string | Array<string>) { export function readMessage(ids?: Array<string>) {
return http.patch(`${BASE_URL}/read`, ids) return http.patch(`${BASE_URL}/read`, { ids })
}
/** @desc 全部已读 */
export function readAllMessage() {
return http.patch(`${BASE_URL}/readAll`)
} }
/** @desc 查询未读消息数量 */ /** @desc 查询未读消息数量 */

View File

@@ -26,6 +26,6 @@ export function updateNotice(data: any, id: string) {
} }
/** @desc 删除公告 */ /** @desc 删除公告 */
export function deleteNotice(ids: string | Array<number>) { export function deleteNotice(id: string) {
return http.del(`${BASE_URL}/${ids}`) return http.del(`${BASE_URL}`, { ids: [id] })
} }

View File

@@ -26,8 +26,8 @@ export function updateRole(data: any, id: string) {
} }
/** @desc 删除角色 */ /** @desc 删除角色 */
export function deleteRole(ids: string | Array<string>) { export function deleteRole(id: string) {
return http.del(`${BASE_URL}/${ids}`) return http.del(`${BASE_URL}`, { ids: [id] })
} }
/** @desc 修改角色权限 */ /** @desc 修改角色权限 */

View File

@@ -27,5 +27,5 @@ export function updateSmsConfig(data: any, id: string) {
/** @desc 删除短信配置 */ /** @desc 删除短信配置 */
export function deleteSmsConfig(id: string) { export function deleteSmsConfig(id: string) {
return http.del(`${BASE_URL}/${id}`) return http.del(`${BASE_URL}`, { ids: [id] })
} }

View File

@@ -17,7 +17,7 @@ export function getSmsLog(id: string) {
/** @desc 删除短信日志 */ /** @desc 删除短信日志 */
export function deleteSmsLog(id: string) { export function deleteSmsLog(id: string) {
return http.del(`${BASE_URL}/${id}`) return http.del(`${BASE_URL}`, { ids: [id] })
} }
/** @desc 导出短信日志 */ /** @desc 导出短信日志 */

View File

@@ -27,7 +27,7 @@ export function updateStorage(data: any, id: string) {
/** @desc 删除存储 */ /** @desc 删除存储 */
export function deleteStorage(id: string) { export function deleteStorage(id: string) {
return http.del(`${BASE_URL}/${id}`) return http.del(`${BASE_URL}`, { ids: [id] })
} }
/** @desc 修改存储状态 */ /** @desc 修改存储状态 */

View File

@@ -29,8 +29,8 @@ export function updateUser(data: any, id: string) {
} }
/** @desc 删除用户 */ /** @desc 删除用户 */
export function deleteUser(ids: string | Array<string>) { export function deleteUser(id: string) {
return http.del(`${BASE_URL}/${ids}`) return http.del(`${BASE_URL}`, { ids: [id] })
} }
/** @desc 导出用户 */ /** @desc 导出用户 */

View File

@@ -1,16 +1,16 @@
<template> <template>
<GiTable <GiTable
v-model:selectedKeys="selectedKeys"
row-key="id" row-key="id"
:data="dataList" :data="dataList"
:columns="columns" :columns="columns"
:loading="loading" :loading="loading"
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }" :scroll="{ x: '100%', y: '100%', minWidth: 800 }"
:pagination="pagination" :pagination="pagination"
:disabled-tools="['size', 'setting']" :disabled-tools="['size', 'setting']"
:row-selection="{ type: 'checkbox', showCheckedAll: true }" :row-selection="{ type: 'checkbox', showCheckedAll: true }"
:selected-keys="selectedKeys"
@select-all="selectAll"
@select="select" @select="select"
@select-all="selectAll"
@refresh="search" @refresh="search"
> >
<template #toolbar-left> <template #toolbar-left>
@@ -59,7 +59,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { TableInstance } from '@arco-design/web-vue' import type { TableInstance } from '@arco-design/web-vue'
import { Message, Modal } from '@arco-design/web-vue' import { Message, Modal } from '@arco-design/web-vue'
import { type MessageQuery, deleteMessage, listMessage, readMessage } from '@/apis' import { type MessageQuery, deleteMessage, listMessage, readAllMessage, readMessage } from '@/apis'
import { useTable } from '@/hooks' import { useTable } from '@/hooks'
import { useDict } from '@/hooks/app' import { useDict } from '@/hooks/app'
@@ -90,7 +90,7 @@ const columns: TableInstance['columns'] = [
render: ({ rowIndex }) => h('span', {}, rowIndex + 1 + (pagination.current - 1) * pagination.pageSize), render: ({ rowIndex }) => h('span', {}, rowIndex + 1 + (pagination.current - 1) * pagination.pageSize),
}, },
{ title: '标题', dataIndex: 'title', slotName: 'title', minWidth: 100, ellipsis: true, tooltip: true }, { title: '标题', dataIndex: 'title', slotName: 'title', minWidth: 100, ellipsis: true, tooltip: true },
{ title: '状态', dataIndex: 'isRead', slotName: 'isRead', align: 'center' }, { title: '状态', dataIndex: 'isRead', slotName: 'isRead', minWidth: 100, align: 'center' },
{ title: '时间', dataIndex: 'createTime', width: 180 }, { title: '时间', dataIndex: 'createTime', width: 180 },
{ title: '类型', dataIndex: 'type', slotName: 'type', width: 180, ellipsis: true, tooltip: true }, { title: '类型', dataIndex: 'type', slotName: 'type', width: 180, ellipsis: true, tooltip: true },
] ]
@@ -108,7 +108,7 @@ const onDelete = () => {
if (!selectedKeys.value.length) { if (!selectedKeys.value.length) {
return Message.warning('请选择数据') return Message.warning('请选择数据')
} }
return handleDelete(() => deleteMessage(selectedKeys.value), { showModal: false, multiple: true }) return handleDelete(() => deleteMessage(selectedKeys.value), { showModal: true, content: `是否确定删除所选的${selectedKeys.value.length}条消息?`, multiple: true })
} }
// 标记为已读 // 标记为已读
@@ -129,7 +129,7 @@ const onReadAll = async () => {
hideCancel: false, hideCancel: false,
maskClosable: false, maskClosable: false,
onOk: async () => { onOk: async () => {
await readMessage([]) await readAllMessage()
Message.success('操作成功') Message.success('操作成功')
search() search()
}, },