mirror of
https://gitee.com/dromara/go-view.git
synced 2026-05-12 00:00:01 +08:00
feat: 新增删除接口
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { ref, reactive } from 'vue';
|
||||
import { goDialog } from '@/utils'
|
||||
import { goDialog, httpErrorHandle } from '@/utils'
|
||||
import { DialogEnum } from '@/enums/pluginEnum'
|
||||
import { projectListApi } from '@/api/path/project'
|
||||
import { ChartList } from '../../../index.d'
|
||||
import { projectListApi, deleteProjectApi } from '@/api/path/project'
|
||||
import { Chartype, ChartList } from '../../../index.d'
|
||||
import { ResultEnum } from '@/enums/httpEnum'
|
||||
|
||||
// 数据初始化
|
||||
export const useDataListInit = () => {
|
||||
@@ -20,28 +21,25 @@ export const useDataListInit = () => {
|
||||
|
||||
// 数据请求
|
||||
const fetchList = async () => {
|
||||
try {
|
||||
const res: any = await projectListApi({
|
||||
page: paginat.page,
|
||||
limit: paginat.limit
|
||||
const res: any = await projectListApi({
|
||||
page: paginat.page,
|
||||
limit: paginat.limit
|
||||
})
|
||||
if (res.data) {
|
||||
const { count } = res
|
||||
paginat.count = count
|
||||
list.value = res.data.map((e: any) => {
|
||||
const { id, projectName, state, createTime, createUserId } = e
|
||||
return {
|
||||
id: id,
|
||||
title: projectName,
|
||||
createId: createUserId,
|
||||
time: createTime,
|
||||
release: state !== -1
|
||||
}
|
||||
})
|
||||
if (res.data) {
|
||||
const { count } = res
|
||||
paginat.count = count
|
||||
list.value = res.data.map((e:any) => {
|
||||
const {id, projectName, state, createTime, createUserId} = e
|
||||
return {
|
||||
id: id,
|
||||
title: projectName,
|
||||
createId: createUserId,
|
||||
time: createTime,
|
||||
release: state !== -1
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
window['$message'].error(window['$t']('http.error_message'))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 修改页数
|
||||
@@ -57,15 +55,22 @@ export const useDataListInit = () => {
|
||||
}
|
||||
|
||||
// 删除
|
||||
const deleteHandle = (cardData: object, index: number) => {
|
||||
const deleteHandle = (cardData: Chartype, index: number) => {
|
||||
goDialog({
|
||||
type: DialogEnum.DELETE,
|
||||
promise: true,
|
||||
onPositiveCallback: () =>
|
||||
new Promise(res => setTimeout(() => res(1), 1000)),
|
||||
promiseResCallback: (e: any) => {
|
||||
window['$message'].success('删除成功')
|
||||
list.value.splice(index, 1)
|
||||
onPositiveCallback: () => new Promise(res => {
|
||||
res(deleteProjectApi({
|
||||
ids: cardData.id
|
||||
}))
|
||||
}),
|
||||
promiseResCallback: (res: any) => {
|
||||
if (res.code === ResultEnum.SUCCESS) {
|
||||
window['$message'].success('删除成功')
|
||||
fetchList()
|
||||
return
|
||||
}
|
||||
httpErrorHandle()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<project-items-card
|
||||
:cardData="item"
|
||||
@resize="resizeHandle"
|
||||
@delete="deleteHandle($event, index)"
|
||||
@delete="deleteHandle(item, index)"
|
||||
@edit="editHandle"
|
||||
></project-items-card>
|
||||
</n-grid-item>
|
||||
|
||||
Reference in New Issue
Block a user