Эх сурвалжийг харах

feat: project survey with contact surveylog

Future 1 өдөр өмнө
parent
commit
f084d98338

+ 1 - 1
src/modules/project/components/contact-selector/contact-selector.component.scss

@@ -26,5 +26,5 @@
 .sub { font-size:12px; color:#777; }
 .ops { display:flex; align-items:center; }
 .overlay { position:fixed; inset:0; background:rgba(0,0,0,0.2); }
-.customer-panel { position:fixed; right:20px; top:60px; width:480px; height:80vh; background:#fff; border:1px solid #ddd; border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,0.1); overflow:auto; padding:8px; }
+.customer-panel { z-index:100;position:fixed; right:20px; top:60px; width:480px; height:80vh; background:#fff; border:1px solid #ddd; border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,0.1); overflow:auto; padding:8px; }
 .customer-panel .close { position:absolute; right:12px; top:10px; padding:6px 10px; }

+ 3 - 2
src/modules/project/components/project-bottom-card/project-bottom-card.component.scss

@@ -210,8 +210,8 @@
     padding: 10px 12px;
 
     .card-content {
-      flex-direction: column;
-      gap: 12px;
+      flex-direction: row;
+      gap: 0px;
       align-items: stretch;
     }
 
@@ -220,6 +220,7 @@
 
       .project-title {
         font-size: 16px;
+        display: none;
       }
 
       .project-meta {

+ 0 - 1
src/modules/project/pages/contact/contact.component.html

@@ -193,7 +193,6 @@
                         }
                       </div>
                     </div>
-                    <svg class="icon arrow" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M184 112l144 144-144 144"/></svg>
                   </div>
                 }
               </div>

+ 4 - 2
src/modules/project/pages/project-detail/project-detail.component.html

@@ -60,7 +60,7 @@
     </app-contact-selector>
 
     <!-- 项目问卷卡片 -->
-    @if (contact) {
+    @if (contact && (currentStage=='order' || currentStage=='requirements')) {
       <div class="survey-card">
         <div class="survey-header">
           <div class="survey-title">
@@ -85,7 +85,7 @@
               </svg>
               <div class="survey-text">
                 <p class="survey-desc">
-                  {{ contact.get('realname') || contact.get('name') }} 已完成需求调查
+                  {{ surveyStatus.contact.get('realname') || surveyStatus.contact.get('name') }} 已完成需求调查
                 </p>
                 <p class="survey-meta">
                   完成时间: {{ surveyStatus.surveyLog?.get('completedAt') | date:'yyyy-MM-dd HH:mm' }}
@@ -135,6 +135,7 @@
         </div>
 
         <!-- 问卷说明 -->
+        @if (!surveyStatus.filled) {
         <div class="survey-footer">
           <div class="survey-highlights">
             <div class="highlight-item">
@@ -159,6 +160,7 @@
             </div>
           </div>
         </div>
+        }
       </div>
     }
 

+ 5 - 3
src/modules/project/pages/project-detail/project-detail.component.ts

@@ -100,6 +100,7 @@ export class ProjectDetailComponent implements OnInit {
     text: string;
     icon: string;
     surveyLog?: FmodeObject;
+    contact?: FmodeObject;
   } = {
     filled: false,
     text: '发送问卷',
@@ -522,14 +523,14 @@ export class ProjectDetailComponent implements OnInit {
    * 加载问卷状态
    */
   async loadSurveyStatus() {
-    if (!this.project?.id || !this.contact?.id) return;
+    if (!this.project?.id) return;
 
     try {
       const query = new Parse.Query('SurveyLog');
       query.equalTo('project', this.project.toPointer());
-      query.equalTo('contact', this.contact.toPointer());
       query.equalTo('type', 'survey-project');
       query.equalTo('isCompleted', true);
+      query.include("contact")
       const surveyLog = await query.first();
 
       if (surveyLog) {
@@ -537,7 +538,8 @@ export class ProjectDetailComponent implements OnInit {
           filled: true,
           text: '查看问卷',
           icon: 'checkmark-circle',
-          surveyLog
+          surveyLog,
+          contact:surveyLog?.get("contact")
         };
         console.log('✅ 问卷已填写');
       } else {

+ 11 - 8
src/modules/project/pages/project-survey/project-survey.component.html

@@ -1,11 +1,13 @@
 <!-- 顶部导航栏 -->
 <div class="survey-header">
   <div class="header-content">
+    @if(!currentContact?.id){
     <button class="back-button" (click)="goBack()">
       <svg class="icon" viewBox="0 0 512 512">
         <path fill="currentColor" d="M244 400L100 256l144-144M120 256h292"/>
       </svg>
     </button>
+    }
     <h1 class="header-title">项目需求调查</h1>
     <div class="header-spacer"></div>
   </div>
@@ -24,7 +26,7 @@
   }
 
   <!-- 错误状态 -->
-  @if (error && !loading) {
+  @if (error && !loading && !surveyLog?.get('isCompleted')) {
     <div class="status-view error-view">
       <div class="error-icon-wrapper">
         <svg class="icon error-icon" viewBox="0 0 512 512">
@@ -293,7 +295,7 @@
   }
 
   <!-- 结果页 -->
-  @if (currentState === 'result' && !loading && !error) {
+  @if (currentState === 'result' && !loading && (!error || surveyLog?.get('isCompleted'))) {
     <div class="result-view">
       <!-- 成功图标 -->
       <div class="success-icon-wrapper">
@@ -301,14 +303,15 @@
           <path fill="currentColor" d="M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm108.25 138.29l-134.4 160a16 16 0 01-12 5.71h-.27a16 16 0 01-11.89-5.3l-57.6-64a16 16 0 1123.78-21.4l45.29 50.32 122.59-145.91a16 16 0 0124.5 20.58z"/>
         </svg>
       </div>
-
-      <h2 class="result-title">问卷提交成功</h2>
-      <p class="result-subtitle">感谢您的反馈!</p>
-      <p class="result-desc">我们将根据您的选择制定服务方案</p>
-
+      @if(currentContact?.id){
+        <h2 class="result-title">问卷提交成功</h2>
+        <p class="result-subtitle">感谢您的反馈!</p>
+        <p class="result-desc">我们将根据您的选择制定服务方案</p>
+      }
+        
       <!-- 答卷内容 -->
       <div class="result-card">
-        <h3 class="result-card-title">您的答卷</h3>
+        <h3 class="result-card-title">问卷信息</h3>
 
         <div class="result-list">
           <div class="result-item">

+ 5 - 6
src/modules/project/pages/project-survey/project-survey.component.ts

@@ -214,7 +214,7 @@ export class ProjectSurveyComponent implements OnInit {
       if (!this.wxAuth) {
         this.isCustomerOnly = true;
         this.error = '该问卷仅供客户填写,请通过企微群聊进入';
-        return;
+        // return;
       }
 
       try {
@@ -226,13 +226,13 @@ export class ProjectSurveyComponent implements OnInit {
           console.warn('⚠️ 未找到外部联系人信息');
           this.isCustomerOnly = true;
           this.error = '该问卷仅供客户填写';
-          return;
+          // return;
         }
       } catch (error) {
         console.error('❌ 获取联系人失败:', error);
         this.isCustomerOnly = true;
         this.error = '该问卷仅供客户填写,请通过企微群聊进入';
-        return;
+        // return;
       }
 
       // 2. 加载项目
@@ -266,12 +266,11 @@ export class ProjectSurveyComponent implements OnInit {
    * 检查现有问卷
    */
   async checkExistingSurvey() {
-    if (!this.project || !this.currentContact) return;
+    if (!this.project) return;
 
     try {
       const query = new Parse.Query('SurveyLog');
       query.equalTo('project', this.project.toPointer());
-      query.equalTo('contact', this.currentContact.toPointer());
       query.equalTo('type', 'survey-project');
 
       this.surveyLog = await query.first();
@@ -540,6 +539,6 @@ export class ProjectSurveyComponent implements OnInit {
    * 返回项目详情
    */
   goBack() {
-    this.router.navigate(['/wxwork', this.cid, 'project', this.projectId]);
+      this.router.navigate(['/wxwork', this.cid, 'project', this.projectId]);
   }
 }