| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <!-- 顶部搜索和操作栏 --> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" label-width="80px"> |
| | | <el-form-item label="项目名称" prop="projectName"> |
| | | <el-input |
| | | v-model="queryParams.projectName" |
| | | <el-form :model="queryParams" |
| | | ref="queryRef" |
| | | :inline="true" |
| | | label-width="80px"> |
| | | <el-form-item label="项目名称" |
| | | prop="projectName"> |
| | | <el-input v-model="queryParams.projectName" |
| | | placeholder="请输入项目名称" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | @keyup.enter="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="负责人" prop="managerName"> |
| | | <el-input |
| | | v-model="queryParams.managerName" |
| | | <el-form-item label="负责人" |
| | | prop="managerName"> |
| | | <el-input v-model="queryParams.managerName" |
| | | placeholder="请输入负责人姓名" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | @keyup.enter="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select |
| | | v-model="queryParams.status" |
| | | <el-form-item label="状态" |
| | | prop="status"> |
| | | <el-select v-model="queryParams.status" |
| | | placeholder="项目状态" |
| | | clearable |
| | | style="width: 150px" |
| | | > |
| | | <el-option label="规划中" value="planning" /> |
| | | <el-option label="进行中" value="inProgress" /> |
| | | <el-option label="已完成" value="completed" /> |
| | | <el-option label="已暂停" value="paused" /> |
| | | style="width: 150px"> |
| | | <el-option label="规划中" |
| | | value="planning" /> |
| | | <el-option label="进行中" |
| | | value="inProgress" /> |
| | | <el-option label="已完成" |
| | | value="completed" /> |
| | | <el-option label="已暂停" |
| | | value="paused" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | <el-button type="primary" |
| | | icon="Search" |
| | | @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" |
| | | @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | <!-- 工具栏 --> |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-row :gutter="10" |
| | | class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | <el-button type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="handleAdd" |
| | | v-hasPermi="['oaSystem:project:add']" |
| | | >新增项目</el-button> |
| | | v-hasPermi="['oaSystem:project:add']">新增项目</el-button> |
| | | </el-col> |
| | | <!-- <el-col :span="1.5"> |
| | | <el-button |
| | |
| | | >删除项目</el-button> |
| | | </el-col> --> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | <el-button type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['oaSystem:project:export']" |
| | | >导出项目</el-button> |
| | | v-hasPermi="['oaSystem:project:export']">导出项目</el-button> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <!-- 项目列表表格 --> |
| | | <el-table |
| | | v-loading="loading" |
| | | <el-table v-loading="loading" |
| | | :data="projectList" |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="50" align="center" /> |
| | | <el-table-column |
| | | label="项目编号" |
| | | @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" |
| | | width="50" |
| | | align="center" /> |
| | | <el-table-column label="项目编号" |
| | | align="center" |
| | | prop="projectId" |
| | | width="100" |
| | | /> |
| | | <el-table-column |
| | | label="项目名称" |
| | | width="100" /> |
| | | <el-table-column label="项目名称" |
| | | align="center" |
| | | prop="projectName" |
| | | :show-overflow-tooltip="true" |
| | | /> |
| | | <el-table-column |
| | | label="负责人" |
| | | :show-overflow-tooltip="true" /> |
| | | <el-table-column label="负责人" |
| | | align="center" |
| | | prop="managerName" |
| | | /> |
| | | <el-table-column |
| | | label="开始日期" |
| | | prop="managerName" /> |
| | | <el-table-column label="开始日期" |
| | | align="center" |
| | | prop="startDate" |
| | | width="120" |
| | | /> |
| | | <el-table-column |
| | | label="结束日期" |
| | | width="120" /> |
| | | <el-table-column label="结束日期" |
| | | align="center" |
| | | prop="endDate" |
| | | width="120" |
| | | /> |
| | | <el-table-column |
| | | label="状态" |
| | | width="120" /> |
| | | <el-table-column label="状态" |
| | | align="center" |
| | | prop="status" |
| | | width="90" |
| | | > |
| | | width="90"> |
| | | <template #default="scope"> |
| | | <el-tag :type="getStatusType(scope.row.status)">{{ getStatusText(scope.row.status) }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="完成度" |
| | | <el-table-column label="完成度" |
| | | align="center" |
| | | prop="completionRate" |
| | | width="100" |
| | | > |
| | | width="100"> |
| | | <template #default="scope"> |
| | | <el-progress :percentage="scope.row.completionRate" :stroke-width="6" /> |
| | | <el-progress :percentage="scope.row.completionRate" |
| | | :stroke-width="6" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="操作" |
| | | <el-table-column label="操作" |
| | | align="center" |
| | | width="180" |
| | | class-name="small-padding fixed-width" |
| | | > |
| | | class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | link |
| | | <el-button link |
| | | type="primary" |
| | | icon="Search" |
| | | @click="handleView(scope.row)" |
| | | v-hasPermi="['oaSystem:project:query']" |
| | | >详情</el-button> |
| | | <el-button |
| | | link |
| | | v-hasPermi="['oaSystem:project:query']">详情</el-button> |
| | | <el-button link |
| | | type="primary" |
| | | icon="Edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['oaSystem:project:edit']" |
| | | >编辑</el-button> |
| | | <el-button |
| | | link |
| | | v-hasPermi="['oaSystem:project:edit']">编辑</el-button> |
| | | <el-button link |
| | | type="danger" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['oaSystem:project:remove']" |
| | | >删除</el-button> |
| | | v-hasPermi="['oaSystem:project:remove']">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <!-- 分页组件 --> |
| | | <pagination |
| | | v-show="total > 0" |
| | | <pagination v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | |
| | | @pagination="getList" /> |
| | | <!-- 项目表单对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="600px" append-to-body> |
| | | <project-form |
| | | ref="projectFormRef" |
| | | <el-dialog :title="title" |
| | | v-model="open" |
| | | width="600px" |
| | | append-to-body> |
| | | <project-form ref="projectFormRef" |
| | | :form="form" |
| | | :rules="rules" |
| | | :visible="open" |
| | | /> |
| | | :visible="open" /> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" |
| | | @click="submitForm">确定</el-button> |
| | | <el-button @click="cancel">取消</el-button> |
| | | <el-button type="primary" @click="submitForm">确定</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, reactive, computed, onMounted } from 'vue'; |
| | | import { ElMessage, ElMessageBox } from 'element-plus'; |
| | | import Pagination from '@/components/Pagination'; |
| | | import ProjectForm from './components/projectForm.vue'; |
| | | import { useRouter } from 'vue-router'; |
| | | import { ref, reactive, computed, onMounted } from "vue"; |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | | import Pagination from "@/components/Pagination"; |
| | | import ProjectForm from "./components/projectForm.vue"; |
| | | import { useRouter } from "vue-router"; |
| | | const { proxy } = getCurrentInstance(); |
| | | // 导入项目管理API接口 |
| | | import { listProject, addProject, updateProject, delProject, exportProject } from '@/api/oaSystem/projectManagement'; |
| | | import { |
| | | listProject, |
| | | addProject, |
| | | updateProject, |
| | | delProject, |
| | | exportProject, |
| | | } from "@/api/oaSystem/projectManagement"; |
| | | // import { listUser } from '@/api/system/user'; // 导入用户列表API接口 |
| | | |
| | | // 创建router实例 |
| | |
| | | const queryParams = reactive({ |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | projectName: '', |
| | | managerName: '', |
| | | status: '' |
| | | projectName: "", |
| | | managerName: "", |
| | | status: "", |
| | | }); |
| | | |
| | | // 表单数据 |
| | | const form = reactive({ |
| | | projectId: undefined, |
| | | projectName: '', |
| | | description: '', |
| | | startDate: '', |
| | | endDate: '', |
| | | managerId: '', |
| | | managerName: '', |
| | | status: 'planning', |
| | | completionRate: 0 |
| | | projectName: "", |
| | | description: "", |
| | | startDate: "", |
| | | endDate: "", |
| | | managerId: "", |
| | | managerName: "", |
| | | status: "planning", |
| | | completionRate: 0, |
| | | }); |
| | | |
| | | // 表单校验规则 |
| | | const rules = { |
| | | projectName: [ |
| | | { required: true, message: '项目名称不能为空', trigger: 'blur' }, |
| | | { min: 2, max: 50, message: '项目名称长度在 2 到 50 个字符', trigger: 'blur' } |
| | | { required: true, message: "项目名称不能为空", trigger: "blur" }, |
| | | { |
| | | min: 2, |
| | | max: 50, |
| | | message: "项目名称长度在 2 到 50 个字符", |
| | | trigger: "blur", |
| | | }, |
| | | ], |
| | | startDate: [ |
| | | { required: true, message: '开始日期不能为空', trigger: 'change' } |
| | | { required: true, message: "开始日期不能为空", trigger: "change" }, |
| | | ], |
| | | endDate: [ |
| | | { required: true, message: '结束日期不能为空', trigger: 'change' } |
| | | ], |
| | | managerId: [ |
| | | { required: true, message: '负责人不能为空', trigger: 'blur' } |
| | | ] |
| | | endDate: [{ required: true, message: "结束日期不能为空", trigger: "change" }], |
| | | managerId: [{ required: true, message: "负责人不能为空", trigger: "blur" }], |
| | | }; |
| | | |
| | | // 对话框状态 |
| | | const open = ref(false); |
| | | const title = ref(''); |
| | | const title = ref(""); |
| | | const projectFormRef = ref(); |
| | | const queryRef = ref(); |
| | | |
| | |
| | | projectList.value = data.records; |
| | | total.value = data.total; |
| | | } catch (error) { |
| | | ElMessage.error('获取项目列表失败'); |
| | | console.error('获取项目列表失败:', error); |
| | | ElMessage.error("获取项目列表失败"); |
| | | console.error("获取项目列表失败:", error); |
| | | } finally { |
| | | loading.value = false; |
| | | } |
| | |
| | | }; |
| | | |
| | | // 选中行变化 |
| | | const handleSelectionChange = (selection) => { |
| | | const handleSelectionChange = selection => { |
| | | selectedRowKeys.value = selection.map(item => item.projectId); |
| | | }; |
| | | |
| | |
| | | const handleAdd = () => { |
| | | resetForm(); |
| | | open.value = true; |
| | | title.value = '新增项目'; |
| | | title.value = "新增项目"; |
| | | }; |
| | | |
| | | // 编辑项目 |
| | | const handleUpdate = async (row) => { |
| | | const handleUpdate = async row => { |
| | | resetForm(); |
| | | const projectId = row.projectId || selectedRowKeys.value[0]; |
| | | try { |
| | | // const { data } = await getProject(projectId); |
| | | Object.assign(form, row); |
| | | open.value = true; |
| | | title.value = '编辑项目'; |
| | | title.value = "编辑项目"; |
| | | } catch (error) { |
| | | ElMessage.error('获取项目详情失败'); |
| | | console.error('获取项目详情失败:', error); |
| | | ElMessage.error("获取项目详情失败"); |
| | | console.error("获取项目详情失败:", error); |
| | | } |
| | | }; |
| | | |
| | | // 删除项目 |
| | | const handleDelete = async (row) => { |
| | | const handleDelete = async row => { |
| | | // const projectIds = row.projectId ? [row.projectId] : selectedRowKeys.value; |
| | | const projectNames = row.projectName ? [row.projectName] : |
| | | projectList.value.filter(item => projectIds.includes(item.projectId)).map(item => item.projectName); |
| | | const projectNames = row.projectName |
| | | ? [row.projectName] |
| | | : projectList.value |
| | | .filter(item => projectIds.includes(item.projectId)) |
| | | .map(item => item.projectName); |
| | | |
| | | const confirmMessage = `确定要删除项目 "${projectNames.join('、')}" 吗?`; |
| | | await ElMessageBox.confirm(confirmMessage, '确认操作', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | const confirmMessage = `确定要删除项目 "${projectNames.join("、")}" 吗?`; |
| | | await ElMessageBox.confirm(confirmMessage, "确认操作", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }).catch(() => { |
| | | throw new Error('取消删除'); |
| | | throw new Error("取消删除"); |
| | | }); |
| | | |
| | | try { |
| | |
| | | // } else { |
| | | // await delProjectBatch(projectIds); |
| | | // } |
| | | ElMessage.success('删除成功'); |
| | | ElMessage.success("删除成功"); |
| | | getList(); |
| | | } catch (error) { |
| | | if (error.message !== '取消删除') { |
| | | ElMessage.error('删除失败'); |
| | | console.error('删除项目失败:', error); |
| | | if (error.message !== "取消删除") { |
| | | ElMessage.error("删除失败"); |
| | | console.error("删除项目失败:", error); |
| | | } |
| | | } |
| | | // try { |
| | |
| | | // // 模拟网络延迟 |
| | | // await new Promise(resolve => setTimeout(resolve, 300)); |
| | | |
| | | |
| | | // ElMessage.success('删除成功'); |
| | | // getList(); |
| | | // } catch (error) { |
| | |
| | | }; |
| | | |
| | | // 查看项目详情 |
| | | const handleView = (row) => { |
| | | const handleView = row => { |
| | | const projectId = row.projectId; |
| | | // 跳转到项目详情页面 |
| | | router.push({ |
| | | path: `/oaSystem/projectManagement/projectDetail/${projectId}`, |
| | | query: { projectName: row.projectName } |
| | | query: { projectName: row.projectName }, |
| | | }); |
| | | }; |
| | | |
| | |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | proxy.download(`/oA/project/export/${ids.join(',')}`, {}, "项目数据.xlsx"); |
| | | proxy.download( |
| | | `/oA/project/export/${ids.join(",")}`, |
| | | {}, |
| | | "项目数据.xlsx" |
| | | ); |
| | | ElMessage.success("导出成功"); |
| | | ids = []; |
| | | }) |
| | |
| | | |
| | | if (form.projectId) { |
| | | await updateProject(form); |
| | | ElMessage.success('修改项目成功'); |
| | | ElMessage.success("修改项目成功"); |
| | | } else { |
| | | console.log("form",form); |
| | | await addProject(form); |
| | | ElMessage.success('新增项目成功'); |
| | | ElMessage.success("新增项目成功"); |
| | | } |
| | | open.value = false; |
| | | getList(); |
| | | } catch (error) { |
| | | console.error('提交表单失败:', error); |
| | | console.error("提交表单失败:", error); |
| | | } |
| | | }; |
| | | |
| | |
| | | // 重置表单 |
| | | const resetForm = () => { |
| | | form.projectId = undefined; |
| | | form.projectName = ''; |
| | | form.description = ''; |
| | | form.startDate = ''; |
| | | form.endDate = ''; |
| | | form.managerId = ''; |
| | | form.managerName = ''; |
| | | form.status = 'planning'; |
| | | form.projectName = ""; |
| | | form.description = ""; |
| | | form.startDate = ""; |
| | | form.endDate = ""; |
| | | form.managerId = ""; |
| | | form.managerName = ""; |
| | | form.status = "planning"; |
| | | form.completionRate = 0; |
| | | if (projectFormRef.value) { |
| | | projectFormRef.value.resetFields(); |
| | |
| | | }; |
| | | |
| | | // 获取状态标签类型 |
| | | const getStatusType = (status) => { |
| | | const getStatusType = status => { |
| | | const statusTypeMap = { |
| | | planning: 'info', |
| | | inProgress: 'primary', |
| | | completed: 'success', |
| | | paused: 'warning' |
| | | planning: "info", |
| | | inProgress: "primary", |
| | | completed: "success", |
| | | paused: "warning", |
| | | }; |
| | | return statusTypeMap[status] || 'default'; |
| | | return statusTypeMap[status] || "default"; |
| | | }; |
| | | |
| | | // 获取状态文本 |
| | | const getStatusText = (status) => { |
| | | const getStatusText = status => { |
| | | const statusTextMap = { |
| | | planning: '规划中', |
| | | inProgress: '进行中', |
| | | completed: '已完成', |
| | | paused: '已暂停' |
| | | planning: "规划中", |
| | | inProgress: "进行中", |
| | | completed: "已完成", |
| | | paused: "已暂停", |
| | | }; |
| | | return statusTextMap[status] || status; |
| | | }; |