feat(业务): 我负责的页面完善1

This commit is contained in:
GUjiYN 2024-04-22 19:48:29 +08:00
parent ab4a3d85c0
commit 8af2d5501e
3 changed files with 271 additions and 309 deletions

View File

@ -49,7 +49,7 @@ export function DeleteProject(id, token) {
//编辑项目 //编辑项目
export function EditProject(id, data, token) { export function EditProject(id, data, token) {
return request({ return request({
url: '/project/edit/', url: '/project/edit',
method: 'put', method: 'put',
params:{ id }, params:{ id },
data, data,

View File

@ -1,5 +1,6 @@
<template> <template>
<div> <div>
<!--顶部卡片-->
<el-card style="max-width: 100vw;margin: 1.5vw;"> <el-card style="max-width: 100vw;margin: 1.5vw;">
<template #header> <template #header>
<div class="card-header"> <div class="card-header">
@ -35,6 +36,8 @@
</div> </div>
<template #footer>Footer content</template> <template #footer>Footer content</template>
</el-card> </el-card>
<!--表格卡片-->
<el-card style="max-width: 100vw;margin: 1.5vw;"> <el-card style="max-width: 100vw;margin: 1.5vw;">
<template #header> <template #header>
<div class="card-header" style="display: flex; justify-content: space-between; align-items: center;"> <div class="card-header" style="display: flex; justify-content: space-between; align-items: center;">
@ -118,9 +121,6 @@
<el-button link type="primary" size="small" @click="toggleEditDialog(row)">编辑</el-button> <el-button link type="primary" size="small" @click="toggleEditDialog(row)">编辑</el-button>
<el-button link type="primary" size="small" @click="toggleDeleteDialog(row)">删除</el-button> <el-button link type="primary" size="small" @click="toggleDeleteDialog(row)">删除</el-button>
</div> </div>
<div style="margin-bottom: 4px">
<el-button link type="primary" size="small" @click="toggleAppointDialog(row)">指定项目负责人</el-button>
</div>
<div style="margin-bottom: 4px"> <div style="margin-bottom: 4px">
<el-button link type="primary" size="small" @click="toChildSystem(row.id)">查看详情</el-button> <el-button link type="primary" size="small" @click="toChildSystem(row.id)">查看详情</el-button>
</div> </div>
@ -129,14 +129,18 @@
</el-table> </el-table>
<div style="display: flex; justify-content: center;margin-top: 2vh"> <div style="display: flex; justify-content: center;margin-top: 2vh">
<el-pagination <el-pagination
background @current-change="handleCurrentChange"
:current-page="currentPage"
:page-size="pageSize"
:total="total"
layout="prev, pager, next" layout="prev, pager, next"
:total="totalItems" background
/> style="display: flex; justify-content: center; margin-top: 20px;">
</el-pagination>
</div> </div>
</el-card> </el-card>
<!--新增项目对话框--> <!--新增项目对话框-->
<el-dialog v-model="AddDialogVisible" title="新增项目" width="500"> <el-dialog v-model="AddDialogVisible" title="新增项目" width="500">
<el-form label-width="auto" style="max-width: 600px"> <el-form label-width="auto" style="max-width: 600px">
@ -265,7 +269,6 @@
</template> </template>
</el-dialog> </el-dialog>
<!--删除多个项目对话框--> <!--删除多个项目对话框-->
<el-dialog <el-dialog
title="删除项目" title="删除项目"
@ -402,27 +405,6 @@
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
<!--指定项目负责人对话框-->
<el-dialog v-model="AppointDialogVisible" title="指定项目负责人">
<el-table :data="[currentRowData]" style="width: 100%">
<el-table-column prop="id" label="序号"></el-table-column>
<el-table-column prop="principalUser" label="项目负责人"></el-table-column>
<el-table-column label="选择新负责人">
<el-select v-model="selectedPrincipal" placeholder="请选择项目负责人">
<el-option v-for="option in appointOptions.option" :value="option.username">
{{option.username}}
</el-option>
</el-select>
</el-table-column>
</el-table>
<template #footer>
<div class="dialog-footer">
<el-button @click="CancelAppoint()">取消</el-button>
<el-button type="primary" @click="confirmAppointment()">确认</el-button>
</div>
</template>
</el-dialog>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -444,8 +426,9 @@ const tableData = ref([]);
const listLoading = ref(false); const listLoading = ref(false);
const token = getToken(); const token = getToken();
const page = ref(''); const page = ref('');
const pageSize = ref(''); const currentPage = ref(1);
const totalItems = ref(0); const pageSize = ref(10); //
const total = ref(0);
const editId = reactive({ id:'', }) const editId = reactive({ id:'', })
const searchData = reactive({ name:'', }); const searchData = reactive({ name:'', });
const deleteDatas = reactive({ ids: '' }); const deleteDatas = reactive({ ids: '' });
@ -512,38 +495,46 @@ async function getList() {
console.log("use token:", token); console.log("use token:", token);
listLoading.value = true; listLoading.value = true;
try { try {
// page pageSize
const response = await GetProject(page.value, pageSize.value, token); const response = await GetProject(page.value, pageSize.value, token);
console.log("完整响应内容:", response); if (response.data && response.data.list) {
if (response.data.list) { tableData.value = response.data.list.map(item => parseData(item));
const list = response.data.list; total.value = response.data.total; //
tableData.value = list.map(item => parseData(item));
totalItems.value = response.data.total;
} else { } else {
console.error("未获取到预期数据,响应内容:", response); console.error("未获取到预期数据,响应内容:", response);
tableData.value = [];
total.value = 0;
} }
} catch (error) { } catch (error) {
console.error('请求失败:', error); console.error('请求失败:', error);
tableData.value = [];
total.value = 0;
} finally { } finally {
listLoading.value = false; listLoading.value = false;
} }
} }
function handleCurrentChange(newPage) {
page.value = newPage;
getList(); //
}
// //
function toggleAddDialog() { function toggleAddDialog() {
AddDialogVisible.value = !AddDialogVisible.value; AddDialogVisible.value = !AddDialogVisible.value;
} }
async function addProject() { async function addProject() {
console.log("add token:", token);
try { try {
const res = await AddProject(AddFormData, token); const res = await AddProject(AddFormData, token);
if (res.data) { if (res.code===200) {
getList();
listLoading.value = true; listLoading.value = true;
ElMessage({ ElMessage({
message: '新增成功', message: '新增成功',
type: 'success', type: 'success',
}) })
getList();
} else { } else {
console.error("未获取到预期数据,响应内容:", res); console.error("未获取到预期数据,响应内容:", res);
} }
@ -688,45 +679,6 @@ function reset() {
getList(); getList();
} }
//
async function getAppointOptions() {
try {
const response = await GetAppointOptions(token);
if (response.code === 200) {
appointOptions.option = response.data;
} else {
console.error("无数据");
}
} catch (error) {
console.error('Error fetching status options:', error);
}
};
function toggleAppointDialog(row) {
currentRowData.value = row;
AppointDialogVisible.value = true;
}
function confirmAppointment() {
console.log("指定新负责人:", selectedPrincipal.value);
//
AppointDialogVisible.value = false;
ElMessage({
message: '项目负责人更新成功',
type: 'success',
duration: 3000
});
getList();
}
function CancelAppoint() {
AppointDialogVisible.value = false;
}
onMounted(async () => { onMounted(async () => {
await getList(); // await getList(); //
await getAppointOptions(); await getAppointOptions();

View File

@ -403,7 +403,7 @@ import {
AddChildSystem, AddChildSystem,
DeleteChildSystem, DeleteChildSystem,
DeleteProject, DeleteProject,
EditChildSystem, GetAppointOptions, EditChildSystem, EditProject, GetAppointOptions,
GetChildSysById, GetChildSysById,
GetProjectByName GetProjectByName
} from '@/api/project'; } from '@/api/project';
@ -496,7 +496,6 @@ function toggleAddDialog() {
} }
async function addChildSystem() { async function addChildSystem() {
console.log("add token:", token);
try { try {
const res = await AddChildSystem(AddFormData, token); const res = await AddChildSystem(AddFormData, token);
if (res.code===200) { if (res.code===200) {
@ -650,8 +649,11 @@ function toggleAppointDialog(row) {
} }
function confirmAppointment() { async function confirmAppointment() {
console.log("指定新负责人:", selectedPrincipal.value); console.log("指定新负责人:", selectedPrincipal.value);
const response = await EditChildSystem(editId, EditFormData, token);
if (response.code===200){
console.log("指定负责人Result:", response);
AppointDialogVisible.value = false; AppointDialogVisible.value = false;
ElMessage({ ElMessage({
message: '子系统负责人更新成功', message: '子系统负责人更新成功',
@ -659,7 +661,15 @@ function confirmAppointment() {
duration: 3000 duration: 3000
}); });
getChildSysById(); getChildSysById();
} else {
ElMessage({
message:'子系统负责人更新失败',
type: 'warning',
duration: 3000
})
} }
}
function CancelAppoint() { function CancelAppoint() {
AppointDialogVisible.value = false; AppointDialogVisible.value = false;