|
|
@@ -148,8 +148,10 @@ export class StageDeliveryExecutionComponent implements OnChanges {
|
|
|
stageName: string;
|
|
|
imageUrls: string[];
|
|
|
} | null = null;
|
|
|
+ selectedTemplate: string = '';
|
|
|
customMessage: string = '';
|
|
|
sendingMessage: boolean = false;
|
|
|
+ sendImageOnly: boolean = false; // 只发图片,不发文字
|
|
|
messageTemplates = MESSAGE_TEMPLATES;
|
|
|
|
|
|
// 上传进度
|
|
|
@@ -777,23 +779,110 @@ export class StageDeliveryExecutionComponent implements OnChanges {
|
|
|
this.showMessageModal = false;
|
|
|
this.messageModalConfig = null;
|
|
|
this.customMessage = '';
|
|
|
+ this.selectedTemplate = '';
|
|
|
+ this.sendImageOnly = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ onSendImageOnlyChange() {
|
|
|
+ if (this.sendImageOnly) {
|
|
|
+ this.selectedTemplate = '';
|
|
|
+ this.customMessage = '';
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
async sendMessage() {
|
|
|
if (!this.messageModalConfig || !this.project) return;
|
|
|
|
|
|
+ // 🔥 如果勾选了"只发图片",则强制content为空字符串
|
|
|
+ const content = this.sendImageOnly ? '' : (this.customMessage.trim() || this.selectedTemplate);
|
|
|
+
|
|
|
+ // 🔥 验证:必须有图片或文字内容(不能两者都没有)
|
|
|
+ if (!content && !this.messageModalConfig.imageUrls.length) {
|
|
|
+ alert('请输入消息内容或选择图片');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 🔥 验证:如果没有勾选"只发图片",且没有图片时,必须有文字内容
|
|
|
+ if (!this.sendImageOnly && !content && this.messageModalConfig.imageUrls.length === 0) {
|
|
|
+ alert('请输入消息内容或选择预设话术');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
this.sendingMessage = true;
|
|
|
try {
|
|
|
- // Use deliveryMessageService to send message
|
|
|
- // Implementation depends on service details
|
|
|
- // ...
|
|
|
+ if (this.messageModalConfig.imageUrls.length > 0) {
|
|
|
+ await this.deliveryMessageService.createImageMessage(
|
|
|
+ this.project.id!,
|
|
|
+ this.messageModalConfig.stage,
|
|
|
+ this.messageModalConfig.imageUrls,
|
|
|
+ content,
|
|
|
+ this.currentUser
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ await this.deliveryMessageService.createTextMessage(
|
|
|
+ this.project.id!,
|
|
|
+ this.messageModalConfig.stage,
|
|
|
+ content,
|
|
|
+ this.currentUser
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
alert('消息已发送');
|
|
|
this.closeMessageModal();
|
|
|
} catch (e) {
|
|
|
+ console.error(e);
|
|
|
alert('发送失败');
|
|
|
} finally {
|
|
|
this.sendingMessage = false;
|
|
|
this.cdr.markForCheck();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ openMessageModalWithFiles(spaceId: string, stageId: string) {
|
|
|
+ const space = this.projectProducts.find(p => p.id === spaceId);
|
|
|
+ const stage = this.deliveryTypes.find(t => t.id === stageId);
|
|
|
+
|
|
|
+ if (!space || !stage) return;
|
|
|
+
|
|
|
+ const files = this.getProductDeliveryFiles(spaceId, stageId);
|
|
|
+ const imageUrls = files
|
|
|
+ .filter(f => this.isImageFile(f.name))
|
|
|
+ .map(f => f.url);
|
|
|
+
|
|
|
+ this.openMessageModal({
|
|
|
+ spaceId,
|
|
|
+ spaceName: this.getSpaceDisplayName(space),
|
|
|
+ stage: stageId,
|
|
|
+ stageName: stage.name,
|
|
|
+ imageUrls: imageUrls
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ sendSpaceAllImages(spaceId: string) {
|
|
|
+ const space = this.projectProducts.find(p => p.id === spaceId);
|
|
|
+ if (!space) return;
|
|
|
+
|
|
|
+ const allFiles: DeliveryFile[] = [];
|
|
|
+ this.deliveryTypes.forEach(type => {
|
|
|
+ const files = this.getProductDeliveryFiles(spaceId, type.id);
|
|
|
+ allFiles.push(...files);
|
|
|
+ });
|
|
|
+
|
|
|
+ const imageUrls = allFiles
|
|
|
+ .filter(f => this.isImageFile(f.name))
|
|
|
+ .map(f => f.url);
|
|
|
+
|
|
|
+ if (imageUrls.length === 0) {
|
|
|
+ alert('该空间暂无图片文件');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.openMessageModal({
|
|
|
+ spaceId,
|
|
|
+ spaceName: this.getSpaceDisplayName(space),
|
|
|
+ stage: 'delivery_list',
|
|
|
+ stageName: '交付清单',
|
|
|
+ imageUrls: imageUrls
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|