|
@@ -13,6 +13,7 @@ import { RevisionTaskListComponent } from '../../../components/revision-task-lis
|
|
|
import { RevisionTaskService } from '../../../../../app/pages/services/revision-task.service';
|
|
import { RevisionTaskService } from '../../../../../app/pages/services/revision-task.service';
|
|
|
import { DeliveryMessageService, MESSAGE_TEMPLATES } from '../../../../../app/pages/services/delivery-message.service';
|
|
import { DeliveryMessageService, MESSAGE_TEMPLATES } from '../../../../../app/pages/services/delivery-message.service';
|
|
|
import { WxworkSDKService } from '../../../services/wxwork-sdk.service';
|
|
import { WxworkSDKService } from '../../../services/wxwork-sdk.service';
|
|
|
|
|
+import { DeliveryMessageModalComponent, MessageModalConfig } from './components/delivery-message-modal/delivery-message-modal.component';
|
|
|
import { ImageAnalysisService } from '../../../services/image-analysis.service';
|
|
import { ImageAnalysisService } from '../../../services/image-analysis.service';
|
|
|
import { PhaseDeadlines, PhaseName } from '../../../../../app/models/project-phase.model';
|
|
import { PhaseDeadlines, PhaseName } from '../../../../../app/models/project-phase.model';
|
|
|
import { ensurePhaseDeadlines, mapDeliveryTypeToPhase, markPhaseStatus, updatePhaseOnSubmission } from '../../../../../app/utils/phase-deadline.utils';
|
|
import { ensurePhaseDeadlines, mapDeliveryTypeToPhase, markPhaseStatus, updatePhaseOnSubmission } from '../../../../../app/utils/phase-deadline.utils';
|
|
@@ -82,7 +83,7 @@ interface DeliveryFile {
|
|
|
@Component({
|
|
@Component({
|
|
|
selector: 'app-stage-delivery',
|
|
selector: 'app-stage-delivery',
|
|
|
standalone: true,
|
|
standalone: true,
|
|
|
- imports: [CommonModule, FormsModule, DragUploadModalComponent, RevisionTaskModalComponent, RevisionTaskListComponent],
|
|
|
|
|
|
|
+ imports: [CommonModule, FormsModule, DragUploadModalComponent, RevisionTaskModalComponent, RevisionTaskListComponent, DeliveryMessageModalComponent],
|
|
|
templateUrl: './stage-delivery-new.component.html',
|
|
templateUrl: './stage-delivery-new.component.html',
|
|
|
styleUrls: ['./stage-delivery-new.component.scss'],
|
|
styleUrls: ['./stage-delivery-new.component.scss'],
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
@@ -128,17 +129,8 @@ export class StageDeliveryComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
// 消息发送相关
|
|
// 消息发送相关
|
|
|
showMessageModal: boolean = false;
|
|
showMessageModal: boolean = false;
|
|
|
- messageModalConfig: {
|
|
|
|
|
- spaceId: string;
|
|
|
|
|
- spaceName: string;
|
|
|
|
|
- stage: string;
|
|
|
|
|
- stageName: string;
|
|
|
|
|
- imageUrls: string[];
|
|
|
|
|
- } | null = null;
|
|
|
|
|
- selectedTemplate: string = '';
|
|
|
|
|
- customMessage: string = '';
|
|
|
|
|
|
|
+ messageModalConfig: MessageModalConfig | null = null;
|
|
|
sendingMessage: boolean = false;
|
|
sendingMessage: boolean = false;
|
|
|
- sendImageOnly: boolean = false; // 只发图片,不发文字
|
|
|
|
|
messageTemplates = MESSAGE_TEMPLATES;
|
|
messageTemplates = MESSAGE_TEMPLATES;
|
|
|
|
|
|
|
|
// 交付类型定义
|
|
// 交付类型定义
|
|
@@ -3260,20 +3252,16 @@ export class StageDeliveryComponent implements OnInit, OnDestroy {
|
|
|
const space = this.projectProducts.find(p => p.id === spaceId);
|
|
const space = this.projectProducts.find(p => p.id === spaceId);
|
|
|
const stageInfo = this.deliveryTypes.find(t => t.id === stage);
|
|
const stageInfo = this.deliveryTypes.find(t => t.id === stage);
|
|
|
|
|
|
|
|
- if (!space || !stageInfo) return;
|
|
|
|
|
|
|
+ if (!space || !stageInfo || !this.projectId) return;
|
|
|
|
|
|
|
|
this.messageModalConfig = {
|
|
this.messageModalConfig = {
|
|
|
- spaceId,
|
|
|
|
|
|
|
+ projectId: this.projectId,
|
|
|
spaceName: this.getSpaceDisplayName(space),
|
|
spaceName: this.getSpaceDisplayName(space),
|
|
|
- stage,
|
|
|
|
|
stageName: stageInfo.name,
|
|
stageName: stageInfo.name,
|
|
|
|
|
+ stage,
|
|
|
imageUrls
|
|
imageUrls
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- // 默认选择第一个模板
|
|
|
|
|
- const templates = this.deliveryMessageService.getStageTemplates(stage);
|
|
|
|
|
- this.selectedTemplate = templates[0] || '';
|
|
|
|
|
- this.customMessage = '';
|
|
|
|
|
this.showMessageModal = true;
|
|
this.showMessageModal = true;
|
|
|
this.cdr.markForCheck();
|
|
this.cdr.markForCheck();
|
|
|
}
|
|
}
|
|
@@ -3300,78 +3288,41 @@ export class StageDeliveryComponent implements OnInit, OnDestroy {
|
|
|
closeMessageModal(): void {
|
|
closeMessageModal(): void {
|
|
|
this.showMessageModal = false;
|
|
this.showMessageModal = false;
|
|
|
this.messageModalConfig = null;
|
|
this.messageModalConfig = null;
|
|
|
- this.selectedTemplate = '';
|
|
|
|
|
- this.customMessage = '';
|
|
|
|
|
- this.sendImageOnly = false;
|
|
|
|
|
this.cdr.markForCheck();
|
|
this.cdr.markForCheck();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 选择话术模板
|
|
|
|
|
|
|
+ * 发送消息(从子组件接收消息数据)
|
|
|
*/
|
|
*/
|
|
|
- selectTemplate(template: string): void {
|
|
|
|
|
- this.selectedTemplate = template;
|
|
|
|
|
- this.cdr.markForCheck();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 只发图片选项变化处理
|
|
|
|
|
- */
|
|
|
|
|
- onSendImageOnlyChange(): void {
|
|
|
|
|
- if (this.sendImageOnly) {
|
|
|
|
|
- // 勾选"只发图片"时,清空话术和自定义消息
|
|
|
|
|
- this.selectedTemplate = '';
|
|
|
|
|
- this.customMessage = '';
|
|
|
|
|
- }
|
|
|
|
|
- this.cdr.markForCheck();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 发送消息
|
|
|
|
|
- */
|
|
|
|
|
- async sendMessage(): Promise<void> {
|
|
|
|
|
|
|
+ async onSendMessage(messageData: { text: string; imageUrls: string[] }): Promise<void> {
|
|
|
if (!this.project || !this.currentUser || !this.messageModalConfig) return;
|
|
if (!this.project || !this.currentUser || !this.messageModalConfig) return;
|
|
|
|
|
|
|
|
- // 🔥 如果勾选了"只发图片",则强制content为空字符串
|
|
|
|
|
- const content = this.sendImageOnly ? '' : (this.customMessage.trim() || this.selectedTemplate);
|
|
|
|
|
-
|
|
|
|
|
- // 🔥 验证:必须有图片或文字内容(不能两者都没有)
|
|
|
|
|
- if (!content && !this.messageModalConfig.imageUrls.length) {
|
|
|
|
|
- window?.fmode?.alert?.('请输入消息内容或选择图片');
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 🔥 验证:如果没有勾选"只发图片",且没有图片时,必须有文字内容
|
|
|
|
|
- if (!this.sendImageOnly && !content && this.messageModalConfig.imageUrls.length === 0) {
|
|
|
|
|
- window?.fmode?.alert?.('请输入消息内容或选择预设话术');
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const { text, imageUrls } = messageData;
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
console.log('📤 [发送消息] 开始发送...');
|
|
console.log('📤 [发送消息] 开始发送...');
|
|
|
- console.log('🔘 [发送消息] 只发图片模式:', this.sendImageOnly);
|
|
|
|
|
this.sendingMessage = true;
|
|
this.sendingMessage = true;
|
|
|
this.cdr.markForCheck();
|
|
this.cdr.markForCheck();
|
|
|
|
|
|
|
|
- console.log('📝 [发送消息] 内容:', content || '(无文字)');
|
|
|
|
|
- console.log('📸 [发送消息] 图片数量:', this.messageModalConfig.imageUrls.length);
|
|
|
|
|
|
|
+ console.log('📝 [发送消息] 内容:', text || '(无文字)');
|
|
|
|
|
+ console.log('📸 [发送消息] 图片数量:', imageUrls.length);
|
|
|
console.log('🏷️ [发送消息] 阶段:', this.messageModalConfig.stage);
|
|
console.log('🏷️ [发送消息] 阶段:', this.messageModalConfig.stage);
|
|
|
|
|
|
|
|
- if (this.messageModalConfig.imageUrls.length > 0) {
|
|
|
|
|
- // 发送图文消息(如果content为空,则只发图片)
|
|
|
|
|
|
|
+ if (imageUrls.length > 0) {
|
|
|
|
|
+ // 发送图文消息(如果text为空,则只发图片)
|
|
|
await this.deliveryMessageService.createImageMessage(
|
|
await this.deliveryMessageService.createImageMessage(
|
|
|
this.project.id!,
|
|
this.project.id!,
|
|
|
this.messageModalConfig.stage,
|
|
this.messageModalConfig.stage,
|
|
|
- this.messageModalConfig.imageUrls,
|
|
|
|
|
- content,
|
|
|
|
|
|
|
+ imageUrls,
|
|
|
|
|
+ text,
|
|
|
this.currentUser
|
|
this.currentUser
|
|
|
);
|
|
);
|
|
|
- } else {
|
|
|
|
|
|
|
+ } else if (text) {
|
|
|
// 发送纯文本消息
|
|
// 发送纯文本消息
|
|
|
await this.deliveryMessageService.createTextMessage(
|
|
await this.deliveryMessageService.createTextMessage(
|
|
|
this.project.id!,
|
|
this.project.id!,
|
|
|
this.messageModalConfig.stage,
|
|
this.messageModalConfig.stage,
|
|
|
- content,
|
|
|
|
|
|
|
+ text,
|
|
|
this.currentUser
|
|
this.currentUser
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
@@ -3500,17 +3451,13 @@ export class StageDeliveryComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
// 打开消息弹窗
|
|
// 打开消息弹窗
|
|
|
this.messageModalConfig = {
|
|
this.messageModalConfig = {
|
|
|
- spaceId,
|
|
|
|
|
|
|
+ projectId: this.projectId,
|
|
|
spaceName: this.getSpaceDisplayName(space) + ` (${stageNames.join('、')})`,
|
|
spaceName: this.getSpaceDisplayName(space) + ` (${stageNames.join('、')})`,
|
|
|
stage: firstStageWithImages.id,
|
|
stage: firstStageWithImages.id,
|
|
|
stageName: `全部阶段`,
|
|
stageName: `全部阶段`,
|
|
|
imageUrls: allImageUrls
|
|
imageUrls: allImageUrls
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- // 默认选择第一个模板
|
|
|
|
|
- const templates = this.deliveryMessageService.getStageTemplates(firstStageWithImages.id);
|
|
|
|
|
- this.selectedTemplate = templates[0] || '';
|
|
|
|
|
- this.customMessage = '';
|
|
|
|
|
this.showMessageModal = true;
|
|
this.showMessageModal = true;
|
|
|
this.cdr.markForCheck();
|
|
this.cdr.markForCheck();
|
|
|
}
|
|
}
|