|
@@ -3,7 +3,6 @@ import { CommonModule } from '@angular/common';
|
|
|
import { FormsModule } from '@angular/forms';
|
|
|
import { ActivatedRoute } from '@angular/router';
|
|
|
import { FmodeObject, FmodeParse } from 'fmode-ng/parse';
|
|
|
-import { NovaUploadService } from 'fmode-ng/storage';
|
|
|
import { ProjectFileService } from '../../../services/project-file.service';
|
|
|
import { ProductSpaceService, Project } from '../../../services/product-space.service';
|
|
|
|
|
@@ -166,9 +165,6 @@ export class StageDeliveryComponent implements OnInit {
|
|
|
uploading: boolean = false;
|
|
|
saving: boolean = false;
|
|
|
|
|
|
- // 注入上传服务
|
|
|
- private uploadService: NovaUploadService = inject(NovaUploadService);
|
|
|
-
|
|
|
constructor(
|
|
|
private route: ActivatedRoute,
|
|
|
private projectFileService: ProjectFileService,
|
|
@@ -286,13 +282,13 @@ export class StageDeliveryComponent implements OnInit {
|
|
|
url: file.get('fileUrl'),
|
|
|
name: file.get('fileName'),
|
|
|
type: this.getFileType(file.get('fileName')),
|
|
|
- uploadTime: file.createdAt,
|
|
|
+ uploadTime: file.get('uploadedAt') || file.get('data')?.uploadedAt || file.createdAt,
|
|
|
uploadBy: {
|
|
|
id: file.get('uploadedBy')?.id,
|
|
|
name: file.get('uploadedBy')?.get('name')
|
|
|
},
|
|
|
size: file.get('fileSize'),
|
|
|
- metadata: file.get('metadata')
|
|
|
+ metadata: file.get('data')?.metadata
|
|
|
}));
|
|
|
}
|
|
|
|
|
@@ -505,7 +501,7 @@ export class StageDeliveryComponent implements OnInit {
|
|
|
if (!files || files.length === 0) return;
|
|
|
|
|
|
const deliverable = this.getDeliverable(spaceId, processType);
|
|
|
- if (!deliverable) return;
|
|
|
+ if (!deliverable || !this.project || !this.currentUser) return;
|
|
|
|
|
|
try {
|
|
|
this.uploading = true;
|
|
@@ -519,8 +515,8 @@ export class StageDeliveryComponent implements OnInit {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- // 使用ProjectFileService上传文件
|
|
|
- const uploadedFile = await this.projectFileService.uploadProjectFile(
|
|
|
+ // 统一使用服务方法:上传并创建记录,返回 ProjectFile
|
|
|
+ const savedProjectFile = await this.projectFileService.uploadProjectFileWithRecord(
|
|
|
file,
|
|
|
this.projectId,
|
|
|
'deliverable',
|
|
@@ -533,29 +529,26 @@ export class StageDeliveryComponent implements OnInit {
|
|
|
}
|
|
|
);
|
|
|
|
|
|
- // 添加到交付物文件列表
|
|
|
+ // 添加到交付物文件列表,使用 ProjectFile 的真实ID以支持删除
|
|
|
deliverable.files.push({
|
|
|
- id: uploadedFile.md5,
|
|
|
- url: uploadedFile.url,
|
|
|
- name: uploadedFile.name,
|
|
|
- type: this.getFileType(uploadedFile.name),
|
|
|
- uploadTime: new Date(),
|
|
|
+ id: savedProjectFile.id,
|
|
|
+ url: savedProjectFile.get('fileUrl'),
|
|
|
+ name: savedProjectFile.get('fileName'),
|
|
|
+ type: this.getFileType(savedProjectFile.get('fileName') || ''),
|
|
|
+ uploadTime: savedProjectFile.get('uploadedAt') || new Date(),
|
|
|
uploadBy: {
|
|
|
- id: this.currentUser?.id,
|
|
|
- name: this.currentUser?.get('name')
|
|
|
+ id: savedProjectFile.get('uploadedBy')?.id,
|
|
|
+ name: savedProjectFile.get('uploadedBy')?.get('name')
|
|
|
},
|
|
|
- size: uploadedFile.size,
|
|
|
- metadata: uploadedFile.metadata
|
|
|
+ size: savedProjectFile.get('fileSize'),
|
|
|
+ metadata: savedProjectFile.get('data')?.metadata
|
|
|
});
|
|
|
}
|
|
|
|
|
|
this.cdr.markForCheck();
|
|
|
- // await this.saveDraft();
|
|
|
- // alert('上传成功');
|
|
|
|
|
|
} catch (err) {
|
|
|
console.error('上传失败:', err);
|
|
|
- // alert('上传失败');
|
|
|
} finally {
|
|
|
this.uploading = false;
|
|
|
}
|
|
@@ -566,7 +559,7 @@ export class StageDeliveryComponent implements OnInit {
|
|
|
*/
|
|
|
async deleteFile(spaceId: string, processType: string, fileId: string) {
|
|
|
try {
|
|
|
- // 从数据库删除
|
|
|
+ // 从数据库删除(参数为 ProjectFile 记录ID)
|
|
|
await this.projectFileService.deleteProjectFile(fileId);
|
|
|
|
|
|
const deliverable = this.getDeliverable(spaceId, processType);
|
|
@@ -574,8 +567,6 @@ export class StageDeliveryComponent implements OnInit {
|
|
|
deliverable.files = deliverable.files.filter((file: any) => file.id !== fileId);
|
|
|
this.cdr.markForCheck();
|
|
|
}
|
|
|
-
|
|
|
- // await this.saveDraft();
|
|
|
} catch (error) {
|
|
|
console.error('删除文件失败:', error);
|
|
|
}
|
|
@@ -584,11 +575,10 @@ export class StageDeliveryComponent implements OnInit {
|
|
|
/**
|
|
|
* 进行质量自查
|
|
|
*/
|
|
|
- performQualityCheck(spaceName: string, processType: string) {
|
|
|
- const deliverable = this.getDeliverable(spaceName, processType);
|
|
|
+ performQualityCheck(spaceId: string, processType: string) {
|
|
|
+ const deliverable = this.getDeliverable(spaceId, processType);
|
|
|
if (!deliverable) return;
|
|
|
|
|
|
- // 初始化质量检查清单
|
|
|
const template = this.qualityCheckTemplates[processType as keyof typeof this.qualityCheckTemplates];
|
|
|
if (!deliverable.qualityCheck) {
|
|
|
deliverable.qualityCheck = {
|
|
@@ -601,11 +591,10 @@ export class StageDeliveryComponent implements OnInit {
|
|
|
/**
|
|
|
* 提交交付物给组长审核
|
|
|
*/
|
|
|
- async submitForReview(spaceName: string, processType: string) {
|
|
|
- const deliverable = this.getDeliverable(spaceName, processType);
|
|
|
+ async submitForReview(spaceId: string, processType: string) {
|
|
|
+ const deliverable = this.getDeliverable(spaceId, processType);
|
|
|
if (!deliverable) return;
|
|
|
|
|
|
- // 验证
|
|
|
if (deliverable.files.length === 0) {
|
|
|
alert('请先上传交付物文件');
|
|
|
return;
|
|
@@ -622,7 +611,6 @@ export class StageDeliveryComponent implements OnInit {
|
|
|
deliverable.status = 'submitted';
|
|
|
await this.saveDraft();
|
|
|
|
|
|
- // TODO: 发送企微通知给组长
|
|
|
alert('已提交审核');
|
|
|
|
|
|
} catch (err) {
|
|
@@ -636,13 +624,13 @@ export class StageDeliveryComponent implements OnInit {
|
|
|
/**
|
|
|
* 组长审核(通过/驳回)
|
|
|
*/
|
|
|
- async reviewDeliverable(spaceName: string, processType: string, result: 'approved' | 'rejected', comments: string) {
|
|
|
+ async reviewDeliverable(spaceId: string, processType: string, result: 'approved' | 'rejected', comments: string) {
|
|
|
if (!this.isTeamLeader && !this.canEdit) {
|
|
|
alert('您没有审核权限');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const deliverable = this.getDeliverable(spaceName, processType);
|
|
|
+ const deliverable = this.getDeliverable(spaceId, processType);
|
|
|
if (!deliverable) return;
|
|
|
|
|
|
try {
|
|
@@ -675,8 +663,8 @@ export class StageDeliveryComponent implements OnInit {
|
|
|
/**
|
|
|
* 创建问题反馈
|
|
|
*/
|
|
|
- async createIssue(spaceName: string, processType: string, issue: any) {
|
|
|
- const deliverable = this.getDeliverable(spaceName, processType);
|
|
|
+ async createIssue(spaceId: string, processType: string, issue: any) {
|
|
|
+ const deliverable = this.getDeliverable(spaceId, processType);
|
|
|
if (!deliverable || !deliverable.review) return;
|
|
|
|
|
|
deliverable.review.issues.push(issue);
|