Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 添加项目成员前端修改 #246

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,16 @@ const flush = () => {
dialogVisible.value = false;
getProjectList();
};

// const getProjectList = () => {
// axios.get('/controller/projects/list').then((resp) => {
// projectData.value = resp.data;
// store.commit('saveProjectList', projectData.value);
// });
// };
// 修改为:按用户查找所有项目
const getProjectList = () => {
axios.get('/controller/projects/list').then((resp) => {
axios.get('/controller/users/listProjects').then((resp) => {
projectData.value = resp.data;
store.commit('saveProjectList', projectData.value);
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectUpdate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ onMounted(() => {
>{{ $t('form.save') }}
</el-button>
<el-button
v-if="isUpdate"
v-if="isUpdate && project.createBy===store.state.userInfo.id"
type="danger"
size="medium"
icon="el-icon-delete"
Expand Down
20 changes: 20 additions & 0 deletions src/locales/lang/en_US.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,27 @@ const homeTS = {
setting: 'Project Related Settings',
mange: 'Module Manage',
update: 'Version Manage',
member: 'Project Member',
},
};

// 项目成员
const proMemberTS = {
dialogVisible: {
addMember: 'Add Member',
inputParam: 'Input User Name',
},
pageData: {
memberId: 'Member ID',
memberName: 'Member Name',
memberRole: 'Member Role',
memberNoNull: 'User cannot be empty',
delMessage: 'Are you sure to delete the project member?',
createBy: 'Created By',
members: 'Member',
},
};

const jobsTS = {
dialogVisible: {
message: 'Timed job message',
Expand Down Expand Up @@ -1036,6 +1055,7 @@ export default {
elements,
globalParamsTs,
homeTS,
proMemberTS,
jobsTS,
loginTS,
modulesTS,
Expand Down
22 changes: 22 additions & 0 deletions src/locales/lang/zh_CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ const routes = {
globalParameter: '全局参数',
moduleManage: '模块管理',
versionIteration: '版本迭代',
membersProject: '项目成员',
timedTask: '定时任务',
projectSetting: '项目设置',
projectPage: '项目首页',
Expand Down Expand Up @@ -429,8 +430,28 @@ const homeTS = {
setting: '项目相关设置',
mange: '模块管理',
update: '版本迭代',
member: '项目成员',
},
};

// 项目成员
const proMemberTS = {
dialogVisible: {
addMember: '添加成员',
inputParam: '输入用户名',
},
pageData: {
memberId: '成员ID',
memberName: '用户名',
memberRole: '成员角色',
memberNoNull: '用户不能为空',
delMessage: '确认删除项目成员吗?',
createBy: '创建人',
members: '普通成员',
},
};


const jobsTS = {
dialogVisible: {
message: '定时任务信息',
Expand Down Expand Up @@ -1011,6 +1032,7 @@ export default {
elements,
globalParamsTs,
homeTS,
proMemberTS,
jobsTS,
loginTS,
modulesTS,
Expand Down
7 changes: 7 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ const getRoutes = () => [
component: () => import('../views/Jobs.vue'),
meta: { title: $tc('routes.timedTask') },
},
//llj:项目成员功能
{
path: 'Members',
name: 'Members',
component: () => import('../views/Members.vue'),
meta: { title: $tc('routes.membersProject') },
},
{
path: 'ProjectOption',
name: 'ProjectOption',
Expand Down
5 changes: 5 additions & 0 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ onMounted(() => {
>
<i class="el-icon-coin"></i>{{ $t('homeTS.projectSetting.update') }}
</el-menu-item>

<el-menu-item :index="'/Home/'+ route.params.projectId + '/Members'">
<i class="el-icon-user"></i>{{ $t('homeTS.projectSetting.member') }}
</el-menu-item>

<el-menu-item
:index="'/Home/' + route.params.projectId + '/ProjectOption'"
>
Expand Down
188 changes: 188 additions & 0 deletions src/views/Members.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<script setup>
import { onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';
import axios from '@/http/axios';
import { ElMessage } from 'element-plus';
import Pageable from '@/components/Pageable.vue';
import { useI18n } from 'vue-i18n';

const { t: $t } = useI18n();

const route = useRoute();
const pageData = ref({});
const pageSize = ref(10);
const pageCurrNum = ref(1);
const dialogVisible = ref(false);
const memberDialogVisible = ref(false);

const memberParams = ref({
userName: '',
});


// 添加成员
const openAddMember = (row) => {
memberParams.value = {
projectId: parseInt(route.params.projectId),
userName: row.userName,
memberRole: 0,
};
memberDialogVisible.value = true;
};

const addMemberForm = ref(null);
const addMemberFunction = () => {
addMemberForm.value.validate(async (valid) => {
if (valid) {
await axios
.post('/controller/projects/addMember', memberParams.value)
.then((resp) => {
if (resp.code === 2000) {
memberDialogVisible.value = false;
ElMessage.success({
message: resp.message,
});
getMemberList(1);
}
});
}
});
};


// 查询项目成员
const getMemberList = (pageNum, pSize) => {
pageSize.value = pSize || pageSize.value;
pageCurrNum.value = pageNum || pageCurrNum.value;
axios
.get('/controller/projects/listMembers', {
params: {
projectId: route.params.projectId,
page: pageCurrNum.value,
pageSize: pageSize.value,
},
})
.then((resp) => {
pageData.value = resp.data;
});
};

// 删除项目成员
const deleteProjectUsers = (id) => {
axios
.delete('/controller/projects/deleteMember', {
params: {
id: id,
},
})
.then((resp) => {
if (resp.code === 2000) {
ElMessage.success({
message: resp.message,
});
dialogVisible.value = false;
getMemberList();
}
});
};

onMounted(() => {
getMemberList();
});
</script>

<template>
<el-dialog
v-model="memberDialogVisible"
:title="$t('proMemberTS.dialogVisible.addMember')"
width="600px"
>
<el-form
ref="addMemberForm"
:model="memberParams"
size="small"
class="demo-table-expand"

label-position="left"
>
<el-form-item
prop="userName"
:label="$t('proMemberTS.pageData.memberName')"
:rules="{
required: true,
message: $t('proMemberTS.pageData.memberNoNull'),
trigger: 'blur',
}"
>
<el-input
v-model="memberParams.userName"
:placeholder="$t('proMemberTS.dialogVisible.inputParam')"
></el-input>
</el-form-item>
</el-form>

<div style="text-align: center">
<el-button size="small" type="primary" @click="addMemberFunction">{{
$t('modulesTS.sure')
}}</el-button>
</div>
</el-dialog>

<el-button size="mini" round type="primary" @click="openAddMember">{{
$t('proMemberTS.dialogVisible.addMember')
}}
</el-button>

<el-table :data="pageData['content']" style="width: 100%; margin-top: 20px" border >
<el-table-column
:label="$t('proMemberTS.pageData.memberId')"
width="90"
align="center"
prop="id"
>
</el-table-column>
<el-table-column
:label="$t('proMemberTS.pageData.memberName')"
align="center"
prop="userName"
></el-table-column>

<el-table-column
:label="$t('proMemberTS.pageData.memberRole')"
align="center"
prop="memberRole"
>
<template #default="scope">
<span v-if = "scope.row.memberRole == 1" >{{$t('proMemberTS.pageData.createBy')}}</span>
<span v-if = "scope.row.memberRole == 0" >{{$t('proMemberTS.pageData.members')}}</span>
</template>
</el-table-column>

<el-table-column fixed="right" :label="$t('common.operate')" align="center">
<template #default="scope">
<el-popconfirm v-if = "scope.row.memberRole == 0"
style="margin-left: 10px"
:confirm-button-text="$t('form.confirm')"
:cancel-button-text="$t('form.cancel')"
icon="el-icon-warning"
icon-color="red"
:title="$t('proMemberTS.pageData.delMessage')"
@confirm="deleteProjectUsers(scope.row.id)"
>
<template #reference>
<el-button type="danger" size="mini">
{{ $t('common.delete') }}
</el-button>
</template>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<pageable
:is-page-set="true"
:total="pageData['totalElements']"
:current-page="pageData['number'] + 1"
:page-size="pageData['size']"
@change="getMemberList"
></pageable>
</template>