mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 04:29:21 +08:00
refactor: 运营团队成员改挂公司成员表以支持退出级联
This commit is contained in:
@@ -24,7 +24,7 @@ export namespace OpTeamDTO {
|
||||
|
||||
export interface AddMember {
|
||||
teamId: number;
|
||||
userId: number;
|
||||
companyMemberId: number;
|
||||
role?: number;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,6 @@ export namespace OpTeamDTO {
|
||||
|
||||
export interface RemoveMember {
|
||||
teamId: number;
|
||||
userId: number;
|
||||
companyMemberId: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ export namespace OpTeamVO {
|
||||
companyId: number;
|
||||
teamId: number;
|
||||
teamName?: string;
|
||||
userId: number;
|
||||
companyMemberId: number;
|
||||
userId?: number;
|
||||
role: number;
|
||||
roleName?: string;
|
||||
status: number;
|
||||
@@ -34,7 +35,8 @@ export namespace OpTeamVO {
|
||||
}
|
||||
|
||||
export interface Candidate {
|
||||
userId: number;
|
||||
companyMemberId: number;
|
||||
userId?: number;
|
||||
realName?: string;
|
||||
phone?: string;
|
||||
username?: string;
|
||||
|
||||
+37
-12
@@ -59,7 +59,7 @@ const [AddModal, addModalApi] = useVbenModal({
|
||||
const addFormRef = ref();
|
||||
const addSubmitting = ref(false);
|
||||
const addForm = ref({
|
||||
userId: undefined as number | undefined,
|
||||
companyMemberId: undefined as number | undefined,
|
||||
role: ROLE_MEMBER,
|
||||
});
|
||||
|
||||
@@ -67,17 +67,32 @@ const title = computed(() =>
|
||||
team.value ? `团队成员 · ${team.value.name}` : '团队成员',
|
||||
);
|
||||
|
||||
const memberUserIds = computed(() => new Set(members.value.map((m) => m.userId)));
|
||||
const memberCompanyMemberIds = computed(
|
||||
() => new Set(members.value.map((m) => m.companyMemberId)),
|
||||
);
|
||||
|
||||
const candidateOptions = computed(() =>
|
||||
candidates.value
|
||||
.filter((c) => !memberUserIds.value.has(c.userId))
|
||||
.filter(
|
||||
(c) =>
|
||||
c.companyMemberId != null &&
|
||||
!memberCompanyMemberIds.value.has(c.companyMemberId),
|
||||
)
|
||||
.map((c) => ({
|
||||
value: c.userId,
|
||||
label: [c.realName, c.phone].filter(Boolean).join(' · ') || `用户#${c.userId}`,
|
||||
value: c.companyMemberId,
|
||||
label:
|
||||
[c.realName, c.phone].filter(Boolean).join(' · ') ||
|
||||
`成员#${c.companyMemberId}`,
|
||||
})),
|
||||
);
|
||||
|
||||
/** 模态 zIndex=2100,下拉需挂到触发节点父级并抬高层级,否则点开看不见 */
|
||||
function selectPopupContainer(node: HTMLElement) {
|
||||
return (node.parentElement || document.body) as HTMLElement;
|
||||
}
|
||||
|
||||
const selectDropdownStyle = { zIndex: 2300 };
|
||||
|
||||
const columns = [
|
||||
{ title: '姓名', dataIndex: 'realName', key: 'realName' },
|
||||
{ title: '手机号', dataIndex: 'phone', key: 'phone', width: 140 },
|
||||
@@ -108,7 +123,7 @@ async function loadCandidates() {
|
||||
}
|
||||
|
||||
async function openAdd() {
|
||||
addForm.value = { userId: undefined, role: ROLE_MEMBER };
|
||||
addForm.value = { companyMemberId: undefined, role: ROLE_MEMBER };
|
||||
await loadCandidates();
|
||||
addModalApi.open();
|
||||
}
|
||||
@@ -116,11 +131,11 @@ async function openAdd() {
|
||||
async function submitAdd() {
|
||||
try {
|
||||
await addFormRef.value?.validate();
|
||||
if (!team.value || addForm.value.userId == null) return;
|
||||
if (!team.value || addForm.value.companyMemberId == null) return;
|
||||
addSubmitting.value = true;
|
||||
await addOpTeamMemberApi({
|
||||
teamId: team.value.id,
|
||||
userId: addForm.value.userId,
|
||||
companyMemberId: addForm.value.companyMemberId,
|
||||
role: addForm.value.role,
|
||||
});
|
||||
message.success('已加入团队');
|
||||
@@ -148,7 +163,10 @@ async function changeRole(row: OpTeamVO.Member, role: number) {
|
||||
async function removeMember(row: OpTeamVO.Member) {
|
||||
if (!team.value) return;
|
||||
try {
|
||||
await removeOpTeamMemberApi({ teamId: team.value.id, userId: row.userId });
|
||||
await removeOpTeamMemberApi({
|
||||
teamId: team.value.id,
|
||||
companyMemberId: row.companyMemberId,
|
||||
});
|
||||
message.success('已移除');
|
||||
await loadMembers();
|
||||
} catch (error) {
|
||||
@@ -238,22 +256,29 @@ defineExpose({ open, close });
|
||||
>
|
||||
<Form.Item
|
||||
label="成员"
|
||||
name="userId"
|
||||
name="companyMemberId"
|
||||
:rules="[{ required: true, message: '请选择成员' }]"
|
||||
>
|
||||
<Select
|
||||
v-model:value="addForm.userId"
|
||||
v-model:value="addForm.companyMemberId"
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
placeholder="请选择本公司成员"
|
||||
:options="candidateOptions"
|
||||
:get-popup-container="selectPopupContainer"
|
||||
:dropdown-style="selectDropdownStyle"
|
||||
:not-found-content="
|
||||
candidateOptions.length === 0 ? '没有可添加的成员' : undefined
|
||||
"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="角色" name="role">
|
||||
<Select v-model:value="addForm.role" :options="roleOptions" />
|
||||
<Select
|
||||
v-model:value="addForm.role"
|
||||
:options="roleOptions"
|
||||
:get-popup-container="selectPopupContainer"
|
||||
:dropdown-style="selectDropdownStyle"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</AddModal>
|
||||
|
||||
Reference in New Issue
Block a user