|
@@ -131,6 +131,7 @@ export class StageOrderComponent implements OnInit {
|
|
showAssignDialog: boolean = false;
|
|
showAssignDialog: boolean = false;
|
|
assigningDesigner: FmodeObject | null = null;
|
|
assigningDesigner: FmodeObject | null = null;
|
|
selectedSpaces: string[] = [];
|
|
selectedSpaces: string[] = [];
|
|
|
|
+ editingTeam: FmodeObject | null = null; // 当前正在编辑的团队对象
|
|
|
|
|
|
// 加载状态
|
|
// 加载状态
|
|
loading: boolean = true;
|
|
loading: boolean = true;
|
|
@@ -511,6 +512,26 @@ export class StageOrderComponent implements OnInit {
|
|
this.showAssignDialog = true;
|
|
this.showAssignDialog = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 编辑已分配的设计师 - 重用分配对话框
|
|
|
|
+ */
|
|
|
|
+ editAssignedDesigner(team: FmodeObject) {
|
|
|
|
+ if (!this.canEdit) return;
|
|
|
|
+
|
|
|
|
+ const designer = team.get('profile');
|
|
|
|
+ if (!designer) return;
|
|
|
|
+
|
|
|
|
+ // 设置当前编辑的设计师和团队对象
|
|
|
|
+ this.assigningDesigner = designer;
|
|
|
|
+ this.editingTeam = team;
|
|
|
|
+
|
|
|
|
+ // 预选当前已分配的空间
|
|
|
|
+ const currentSpaces = team.get('data')?.spaces || [];
|
|
|
|
+ this.selectedSpaces = [...currentSpaces];
|
|
|
|
+
|
|
|
|
+ this.showAssignDialog = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 切换空间选择
|
|
* 切换空间选择
|
|
*/
|
|
*/
|
|
@@ -524,7 +545,7 @@ export class StageOrderComponent implements OnInit {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 确认分配设计师
|
|
|
|
|
|
+ * 确认分配设计师(支持创建和更新)
|
|
*/
|
|
*/
|
|
async confirmAssignDesigner() {
|
|
async confirmAssignDesigner() {
|
|
if (!this.assigningDesigner || !this.project) return;
|
|
if (!this.assigningDesigner || !this.project) return;
|
|
@@ -537,22 +558,37 @@ export class StageOrderComponent implements OnInit {
|
|
try {
|
|
try {
|
|
this.saving = true;
|
|
this.saving = true;
|
|
|
|
|
|
- // 创建 ProjectTeam
|
|
|
|
- const ProjectTeam = Parse.Object.extend('ProjectTeam');
|
|
|
|
- const team = new ProjectTeam();
|
|
|
|
- team.set('project', this.project.toPointer());
|
|
|
|
- team.set('profile', this.assigningDesigner.toPointer());
|
|
|
|
- team.set('role', '组员');
|
|
|
|
- team.set('data', {
|
|
|
|
- spaces: this.selectedSpaces,
|
|
|
|
- assignedAt: new Date(),
|
|
|
|
- assignedBy: this.currentUser?.id
|
|
|
|
- });
|
|
|
|
|
|
+ if (this.editingTeam) {
|
|
|
|
+ // 更新现有团队成员的空间分配
|
|
|
|
+ const data = this.editingTeam.get('data') || {};
|
|
|
|
+ data.spaces = this.selectedSpaces;
|
|
|
|
+ data.updatedAt = new Date();
|
|
|
|
+ data.updatedBy = this.currentUser?.id;
|
|
|
|
+ this.editingTeam.set('data', data);
|
|
|
|
+
|
|
|
|
+ await this.editingTeam.save();
|
|
|
|
+
|
|
|
|
+ alert('更新成功');
|
|
|
|
+ } else {
|
|
|
|
+ // 创建新的 ProjectTeam
|
|
|
|
+ const ProjectTeam = Parse.Object.extend('ProjectTeam');
|
|
|
|
+ const team = new ProjectTeam();
|
|
|
|
+ team.set('project', this.project.toPointer());
|
|
|
|
+ team.set('profile', this.assigningDesigner.toPointer());
|
|
|
|
+ team.set('role', '组员');
|
|
|
|
+ team.set('data', {
|
|
|
|
+ spaces: this.selectedSpaces,
|
|
|
|
+ assignedAt: new Date(),
|
|
|
|
+ assignedBy: this.currentUser?.id
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ await team.save();
|
|
|
|
|
|
- await team.save();
|
|
|
|
|
|
+ // 加入群聊(静默执行)
|
|
|
|
+ await this.addMemberToGroupChat(this.assigningDesigner.get('userId'));
|
|
|
|
|
|
- // 加入群聊(静默执行)
|
|
|
|
- await this.addMemberToGroupChat(this.assigningDesigner.get('userId'));
|
|
|
|
|
|
+ alert('分配成功');
|
|
|
|
+ }
|
|
|
|
|
|
// 重新加载团队列表
|
|
// 重新加载团队列表
|
|
await this.loadProjectTeams();
|
|
await this.loadProjectTeams();
|
|
@@ -560,11 +596,11 @@ export class StageOrderComponent implements OnInit {
|
|
this.showAssignDialog = false;
|
|
this.showAssignDialog = false;
|
|
this.assigningDesigner = null;
|
|
this.assigningDesigner = null;
|
|
this.selectedSpaces = [];
|
|
this.selectedSpaces = [];
|
|
|
|
+ this.editingTeam = null;
|
|
|
|
|
|
- alert('分配成功');
|
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
- console.error('分配设计师失败:', err);
|
|
|
|
- alert('分配失败');
|
|
|
|
|
|
+ console.error(this.editingTeam ? '更新失败:' : '分配设计师失败:', err);
|
|
|
|
+ alert(this.editingTeam ? '更新失败' : '分配失败');
|
|
} finally {
|
|
} finally {
|
|
this.saving = false;
|
|
this.saving = false;
|
|
}
|
|
}
|
|
@@ -577,6 +613,7 @@ export class StageOrderComponent implements OnInit {
|
|
this.showAssignDialog = false;
|
|
this.showAssignDialog = false;
|
|
this.assigningDesigner = null;
|
|
this.assigningDesigner = null;
|
|
this.selectedSpaces = [];
|
|
this.selectedSpaces = [];
|
|
|
|
+ this.editingTeam = null;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|