删除项目
This commit is contained in:
parent
9797ca3068
commit
4bf4371fcb
|
|
@ -127,3 +127,18 @@ export const updateProject = (data) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除项目
|
||||||
|
* @param {string|string[]} ids 项目ID或ID数组
|
||||||
|
* @returns {Promise} 删除结果
|
||||||
|
*/
|
||||||
|
export const deleteProject = (ids) => {
|
||||||
|
const idsParam = Array.isArray(ids) ? ids.join(',') : ids;
|
||||||
|
|
||||||
|
return uni.$uv.http.delete(`bst/project/${idsParam}`, {}, {
|
||||||
|
custom: {
|
||||||
|
auth: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, watch, onMounted, nextTick, onUnmounted } from 'vue';
|
import { ref, computed, watch, onMounted, nextTick, onUnmounted } from 'vue';
|
||||||
import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
|
import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
|
||||||
import { getProjectList, getUserList } from '@/api';
|
import { getProjectList, getUserList, deleteProject } from '@/api';
|
||||||
import { usePagination } from '@/composables';
|
import { usePagination } from '@/composables';
|
||||||
import { useDictStore } from '@/store/dict';
|
import { useDictStore } from '@/store/dict';
|
||||||
import { useUserStore } from '@/store/user';
|
import { useUserStore } from '@/store/user';
|
||||||
|
|
@ -517,6 +517,8 @@ const getAvatarText = (member) => {
|
||||||
return name.charAt(0);
|
return name.charAt(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const deletingProjectId = ref('');
|
||||||
|
|
||||||
// 处理卡片菜单
|
// 处理卡片菜单
|
||||||
const handleCardMenu = (project) => {
|
const handleCardMenu = (project) => {
|
||||||
uni.showActionSheet({
|
uni.showActionSheet({
|
||||||
|
|
@ -525,8 +527,7 @@ const handleCardMenu = (project) => {
|
||||||
if (res.tapIndex === 0) {
|
if (res.tapIndex === 0) {
|
||||||
goToEditProject(project);
|
goToEditProject(project);
|
||||||
} else if (res.tapIndex === 1) {
|
} else if (res.tapIndex === 1) {
|
||||||
// 删除
|
handleDeleteProject(project);
|
||||||
uni.showToast({ title: '删除功能开发中', icon: 'none' });
|
|
||||||
} else if (res.tapIndex === 2) {
|
} else if (res.tapIndex === 2) {
|
||||||
// 新增任务
|
// 新增任务
|
||||||
uni.showToast({ title: '新增任务功能开发中', icon: 'none' });
|
uni.showToast({ title: '新增任务功能开发中', icon: 'none' });
|
||||||
|
|
@ -538,6 +539,50 @@ const handleCardMenu = (project) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDeleteProject = (project) => {
|
||||||
|
if (!project?.id) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '缺少项目ID',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deletingProjectId.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const projectName = project.name || project.projectName || '';
|
||||||
|
|
||||||
|
uni.showModal({
|
||||||
|
title: '删除项目',
|
||||||
|
content: projectName ? `确认删除项目「${projectName}」?` : '确认删除该项目?',
|
||||||
|
confirmColor: '#f56c6c',
|
||||||
|
success: async ({ confirm }) => {
|
||||||
|
if (!confirm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
deletingProjectId.value = project.id;
|
||||||
|
uni.showLoading({ title: '删除中...', mask: true });
|
||||||
|
await deleteProject(project.id);
|
||||||
|
uni.showToast({ title: '删除成功', icon: 'success' });
|
||||||
|
await refresh();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('删除项目失败:', err);
|
||||||
|
uni.showToast({
|
||||||
|
title: err?.message || '删除失败,请稍后重试',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
deletingProjectId.value = '';
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const goToCreateProject = () => {
|
const goToCreateProject = () => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/project/form/index?mode=add'
|
url: '/pages/project/form/index?mode=add'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user