帐号治理-项目治理--初步优化
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import uuid
|
||||
from typing import Sequence
|
||||
|
||||
from sqlalchemy import select, update
|
||||
from sqlalchemy import select, update as sa_update
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.models.study import Study
|
||||
@@ -38,7 +38,7 @@ async def update(db: AsyncSession, study: Study, study_in: StudyUpdate) -> Study
|
||||
update_data = study_in.model_dump(exclude_unset=True)
|
||||
if update_data:
|
||||
await db.execute(
|
||||
update(Study)
|
||||
sa_update(Study)
|
||||
.where(Study.id == study.id)
|
||||
.values(**update_data)
|
||||
)
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
<el-card>
|
||||
<div class="header">
|
||||
<div>
|
||||
<h3>项目成员配置</h3>
|
||||
<h3>项目成员配置(角色仅在当前项目内生效)</h3>
|
||||
<div class="sub" v-if="project">项目:{{ project.code }} - {{ project.name }}</div>
|
||||
<div class="sub">同一账号在不同项目可拥有不同角色,角色授权仅在本页进行</div>
|
||||
</div>
|
||||
<el-button type="primary" @click="openAdd">新增成员</el-button>
|
||||
</div>
|
||||
<el-table :data="memberRows" v-loading="loading" stripe>
|
||||
<el-table-column prop="username" label="用户名" min-width="160" />
|
||||
<el-table-column prop="role_in_study" label="角色" width="120">
|
||||
<el-table-column prop="role_in_study" label="项目角色" width="140">
|
||||
<template #default="scope">
|
||||
<el-tag>{{ scope.row.role_in_study }}</el-tag>
|
||||
</template>
|
||||
@@ -33,6 +34,9 @@
|
||||
>
|
||||
<el-option label="PM" value="PM" />
|
||||
<el-option label="CRA" value="CRA" />
|
||||
<el-option label="PV" value="PV" />
|
||||
<el-option label="IMP" value="IMP" />
|
||||
<el-option label="ADMIN" value="ADMIN" />
|
||||
</el-select>
|
||||
<el-button
|
||||
link
|
||||
@@ -54,7 +58,7 @@
|
||||
<el-option
|
||||
v-for="user in availableUsers"
|
||||
:key="user.id"
|
||||
:label="`${user.username} (${user.role})`"
|
||||
:label="user.username"
|
||||
:value="user.id"
|
||||
:disabled="!user.is_active"
|
||||
/>
|
||||
@@ -64,6 +68,9 @@
|
||||
<el-select v-model="newMember.role_in_study" placeholder="请选择角色">
|
||||
<el-option label="PM" value="PM" />
|
||||
<el-option label="CRA" value="CRA" />
|
||||
<el-option label="PV" value="PV" />
|
||||
<el-option label="IMP" value="IMP" />
|
||||
<el-option label="ADMIN" value="ADMIN" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
<div class="page">
|
||||
<el-card>
|
||||
<div class="header">
|
||||
<h3>项目管理</h3>
|
||||
<div>
|
||||
<h3>项目治理</h3>
|
||||
<p class="sub">项目是独立业务实体,账号加入项目后才成为项目成员(角色在成员配置中设置)</p>
|
||||
</div>
|
||||
<el-button type="primary" @click="openCreate">新建项目</el-button>
|
||||
</div>
|
||||
<el-table :data="projects" v-loading="loading" stripe>
|
||||
@@ -18,7 +21,7 @@
|
||||
<el-table-column label="操作" width="320" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" size="small" @click="openEdit(scope.row)">编辑</el-button>
|
||||
<el-button link type="primary" size="small" @click="goMembers(scope.row)">成员配置</el-button>
|
||||
<el-button link type="primary" size="small" @click="goMembers(scope.row)">项目账号/成员配置</el-button>
|
||||
<el-button link type="primary" size="small" @click="goSites(scope.row)">中心管理</el-button>
|
||||
<el-button link type="success" size="small" @click="enterStudy(scope.row)">进入项目</el-button>
|
||||
</template>
|
||||
@@ -110,4 +113,8 @@ onMounted(() => {
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.sub {
|
||||
color: #666;
|
||||
margin-top: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -4,15 +4,6 @@
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="form.username" :disabled="!!user" placeholder="请输入用户名" />
|
||||
</el-form-item>
|
||||
<el-form-item label="角色" prop="role">
|
||||
<el-select v-model="form.role" placeholder="请选择角色">
|
||||
<el-option label="ADMIN" value="ADMIN" />
|
||||
<el-option label="PM" value="PM" />
|
||||
<el-option label="CRA" value="CRA" />
|
||||
<el-option label="PV" value="PV" />
|
||||
<el-option label="IMP" value="IMP" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="user ? '新密码(可选)' : '初始密码'" prop="password">
|
||||
<el-input v-model="form.password" type="password" show-password :placeholder="user ? '留空则不修改密码' : '请输入初始密码'" />
|
||||
</el-form-item>
|
||||
@@ -52,14 +43,12 @@ const formRef = ref<FormInstance>();
|
||||
const submitting = ref(false);
|
||||
const form = reactive({
|
||||
username: "",
|
||||
role: "PM",
|
||||
password: "",
|
||||
is_active: true,
|
||||
});
|
||||
|
||||
const rules = reactive<FormRules>({
|
||||
username: [{ required: true, message: "请输入用户名", trigger: "blur" }],
|
||||
role: [{ required: true, message: "请选择角色", trigger: "change" }],
|
||||
password: [
|
||||
{
|
||||
validator: (_rule, value, callback) => {
|
||||
@@ -76,7 +65,6 @@ const rules = reactive<FormRules>({
|
||||
|
||||
const resetForm = () => {
|
||||
form.username = "";
|
||||
form.role = "PM";
|
||||
form.password = "";
|
||||
form.is_active = true;
|
||||
};
|
||||
@@ -88,7 +76,6 @@ watch(
|
||||
resetForm();
|
||||
if (props.user) {
|
||||
form.username = props.user.username;
|
||||
form.role = props.user.role;
|
||||
form.is_active = props.user.is_active;
|
||||
}
|
||||
}
|
||||
@@ -102,7 +89,6 @@ const onSubmit = async () => {
|
||||
try {
|
||||
if (props.user) {
|
||||
await updateUser(props.user.id, {
|
||||
role: form.role,
|
||||
is_active: form.is_active,
|
||||
password: form.password || undefined,
|
||||
});
|
||||
@@ -110,7 +96,7 @@ const onSubmit = async () => {
|
||||
} else {
|
||||
await createUser({
|
||||
username: form.username,
|
||||
role: form.role,
|
||||
role: "PV",
|
||||
password: form.password,
|
||||
});
|
||||
ElMessage.success("用户已创建");
|
||||
|
||||
@@ -2,17 +2,14 @@
|
||||
<div class="page">
|
||||
<el-card>
|
||||
<div class="header">
|
||||
<h3>用户账号管理</h3>
|
||||
<div>
|
||||
<h3>账号治理(系统登录账号)</h3>
|
||||
<p class="sub">账号用于登录系统,本身不具备项目或角色权限</p>
|
||||
</div>
|
||||
<el-button type="primary" @click="openCreate">新建用户</el-button>
|
||||
</div>
|
||||
<el-table :data="users" stripe v-loading="loading" style="width: 100%">
|
||||
<el-table-column prop="username" label="用户名" min-width="140" />
|
||||
<el-table-column prop="role" label="角色" width="120">
|
||||
<template #default="scope">
|
||||
<el-tag type="success" v-if="scope.row.role === 'ADMIN'">ADMIN</el-tag>
|
||||
<el-tag v-else>{{ scope.row.role }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="120">
|
||||
<template #default="scope">
|
||||
<el-tag type="success" v-if="scope.row.is_active">启用</el-tag>
|
||||
@@ -134,6 +131,10 @@ onMounted(() => {
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.sub {
|
||||
color: #666;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.pagination {
|
||||
margin-top: 12px;
|
||||
text-align: right;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user