pms-front/src/views/project/list.vue

353 lines
9.0 KiB
Vue
Raw Normal View History

<template>
<div class="project-list">
<div class="search-bar">
<el-form
:inline="true"
:model="searchForm"
class="demo-form-inline"
size="small"
>
<el-form-item label="项目名称" class="form-item">
<el-input v-model="searchForm.projectName" placeholder="项目名称" />
</el-form-item>
<el-form-item label="负责人" class="form-item">
<el-input
v-model="searchForm.projectLeaderName"
placeholder="负责人"
readonly
@click.native="openUserSelectDialog"
2024-11-07 08:53:35 +00:00
><el-button slot="append" icon="el-icon-s-custom"></el-button
2024-10-22 01:46:54 +00:00
></el-input>
</el-form-item>
<el-form-item label="项目状态" class="form-item">
<el-select v-model="searchForm.projectState" placeholder="项目状态" clearable>
2024-10-22 01:46:54 +00:00
<el-option
v-for="item in statusList"
:key="item.dictValue"
:label="item.dictLabel"
:value="item.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item class="search-buttons">
<el-button type="primary" @click="onSearch"></el-button>
<el-button @click="onReset"></el-button>
</el-form-item>
</el-form>
</div>
<div class="table-actions mb10">
<el-button
type="primary"
size="mini"
@click="addProject"
v-hasPermi="['project:list:add']"
>+ 新建项目</el-button
>
</div>
2024-10-16 09:32:16 +00:00
<div class="f1 df">
<CustomTable
:columns="columns"
:tableData="tableData"
:total="total"
:show-selection="false"
:show-index="true"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
2024-10-22 01:46:54 +00:00
tableHeight="495px"
2024-10-16 09:32:16 +00:00
>
<template slot="operation" slot-scope="{ row }">
<div class="operation-buttons">
<el-button
@click="handleEdit(row)"
type="text"
size="mini"
icon="el-icon-edit"
v-hasPermi="['project:list:eidt']"
>编辑</el-button
>
<el-button
type="text"
size="mini"
icon="el-icon-delete"
@click="handleDelete(row)"
v-hasPermi="['project:list:delete']"
>删除</el-button
>
</div>
</template>
</CustomTable>
</div>
<SelectUser
:dialogVisible="userSelectDialogVisible"
:multiSelect="false"
:currentSelectedUser="currentSelectedUser"
@confirm="handleUserConfirm"
@close="handleUserClose"
/>
</div>
</template>
<script>
import CustomTable from "@/components/CustomTable.vue";
import SelectUser from "@/components/SelectUser.vue";
2024-10-22 01:46:54 +00:00
import { projectApi, systemApi } from "@/utils/api";
export default {
components: {
CustomTable,
SelectUser,
},
data() {
return {
searchForm: {
projectName: "",
projectLeaderName: "",
projectLeader: "",
projectState: "",
},
columns: [
2024-10-22 01:46:54 +00:00
{ prop: "projectName", label: "项目名称", width: 300 },
{ prop: "projectCode", label: "项目编号", width: 200 },
{ prop: "projectLeaderName", label: "负责人" },
{ prop: "budgetDate", label: "预计工时(天)" },
{
prop: "startDate",
label: "开始时间",
type: "status",
2024-10-22 01:46:54 +00:00
callback: (data) => data?.split(" ")[0],
},
{
prop: "endDate",
label: "结束时间",
type: "status",
2024-10-22 01:46:54 +00:00
callback: (data) => data?.split(" ")[0],
},
{
prop: "projectState",
label: "项目状态",
type: "status",
callback: (value) => {
2024-10-22 01:46:54 +00:00
let status = this.statusList.find(
(ele) => ele.dictValue == value
)?.dictLabel;
let color = "#333";
// switch (status) {
// case "待启动":
// color = "#fa721d"; // 橙色
// break;
// case "已提需求-待开发":
// color = "#dd242a"; // 红色
// break;
// case "已提需求-开发中":
// color = "#1686d8"; // 绿色
// break;
// case "已提需求-已完成":
// color = "#5cb85c"; // 红色
// break;
// case "开发完成-待验收":
// color = "#f7c731"; // 黄色
// break;
// case "开发完成-已验收":
// color = "#8C33FF"; // 蓝色
// break;
// case "开发完成-已计收":
// color = "#08fb9e"; // 绿色
// break;
// default:
// color = "#000"; // 默认白色
// break;
// }
return `<span style="color: ${color}">${status}</span>`;
},
},
2024-10-22 01:46:54 +00:00
{ prop: "teamNum", label: "参与项目人数",width:100 },
{ prop: "createByName", label: "项目创建人" },
{
prop: "operation",
label: "操作",
width: "150",
fixed: "right",
className: "operation-column",
},
],
tableData: [],
total: 0,
userSelectDialogVisible: false,
currentSelectedUser: [],
pageNum: 1, // 当前页码
pageSize: 10, // 每页条数
2024-10-22 01:46:54 +00:00
statusList: [],
};
},
methods: {
onSearch() {
this.fetchProjectList();
},
onReset() {
Object.keys(this.searchForm).forEach((key) => {
this.searchForm[key] = "";
});
this.fetchProjectList();
},
addProject() {
this.$router.push({
path: "/project/detail",
});
},
handleEdit(row) {
this.$router.push({
path: "/project/detail",
query: { id: row.projectId },
});
},
handleDelete(row) {
this.currentDeleteItem = row;
2024-10-16 09:32:16 +00:00
this.$modal.confirm(`是否确认删项目"${row.projectName}"`).then(() => {
return this.confirmDelete(row.menuId);
});
},
async confirmDelete() {
await projectApi.deleteProject(this.currentDeleteItem.projectId);
this.deleteDialogVisible = false;
this.currentDeleteItem = null;
this.$message.success("删除成功");
this.fetchProjectList();
},
fetchProjectList() {
projectApi
.listProject({
...this.searchForm,
pageNum: this.pageNum,
pageSize: this.pageSize,
})
.then((res) => {
this.tableData = res.rows;
this.total = res.total;
});
},
handleSizeChange(size) {
this.pageSize = size;
this.pageNum = 1; // 重置为第一页
this.fetchProjectList();
},
handleCurrentChange(page) {
this.pageNum = page;
this.fetchProjectList();
},
openUserSelectDialog() {
this.userSelectDialogVisible = true;
},
handleUserConfirm(data) {
this.searchForm.projectLeaderName = data[0].nickName;
this.searchForm.projectLeader = data[0].userId;
},
handleUserClose() {
this.userSelectDialogVisible = false;
},
2024-10-22 01:46:54 +00:00
async getDictData() {
const res = await systemApi.getDictData("business_projectstate");
this.statusList = res.data;
},
},
mounted() {
2024-10-22 01:46:54 +00:00
this.getDictData();
this.fetchProjectList();
},
};
</script>
<style lang="scss" scoped>
.project-list {
padding: 20px;
background-color: white;
height: 88vh;
box-sizing: border-box;
overflow: hidden;
2024-10-16 09:32:16 +00:00
display: flex;
flex-direction: column;
}
.search-bar {
margin-bottom: 20px;
}
.demo-form-inline {
// display: flex;
// flex-wrap: nowrap;
// align-items: flex-start;
}
.demo-form-inline .el-form-item {
// margin-right: 50px; /* 将间距设置为 30px */
margin-bottom: 0;
}
.demo-form-inline .el-form-item:last-child {
margin-right: 0; /* 移除最后一个元素的右边距 */
}
.form-item {
flex: 1;
}
.form-item ::v-deep .el-form-item__content {
// width: 100%;
}
.form-item ::v-deep .el-input,
.form-item ::v-deep .el-select {
// width: 100%;
}
.search-buttons {
white-space: nowrap;
}
::v-deep .operation-buttons .el-button {
padding: 4px 8px;
margin: 0 2px;
}
::v-deep .operation-column {
2024-10-22 01:46:54 +00:00
background-color: #ffffff;
box-shadow: -2px 0 5px rgba(241, 112, 6, 0.1);
}
.el-button.is-text {
min-width: 32px !important;
}
.dialog-footer {
display: flex;
justify-content: center;
align-items: center;
}
.dialog-footer .el-button {
margin: 0 10px;
}
.delete-content {
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}
.warning-icon {
font-size: 24px;
color: #e6a23c;
margin-right: 10px;
}
/* 添加以下样式来使对话框垂直居中 */
::v-deep .delete-dialog.el-dialog {
margin-top: 0 !important;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>