jiapu 2 месяцев назад
Родитель
Сommit
477cb93386

+ 6 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/DanAssessmentController.java

@@ -167,6 +167,7 @@ public class DanAssessmentController {
     @PostMapping("/appointment/create")
     public Result<AssessmentAppointment> createAppointment(@RequestBody Map<String, Object> body) {
         Long userId = body.get("userId") != null ? Long.valueOf(body.get("userId").toString()) : null;
+        Long familyId = body.get("familyId") != null ? Long.valueOf(body.get("familyId").toString()) : null;
         Long childId = Long.valueOf(body.get("childId").toString());
         // 兼容前端 teacherId / guideId 字段,允许为 null(系统安排)
         Long guideId = null;
@@ -178,9 +179,13 @@ public class DanAssessmentController {
         Long packageId = body.get("packageId") != null ? Long.valueOf(body.get("packageId").toString()) : null;
         String appointmentDate = (String) body.get("appointmentDate");
         String appointmentTime = (String) body.get("appointmentTime");
+        String appointmentType = body.get("appointmentType") != null ? body.get("appointmentType").toString() : null;
+        Integer durationMinutes = body.get("durationMinutes") != null
+                ? Integer.valueOf(body.get("durationMinutes").toString()) : null;
         String notes = (String) body.get("notes");
         AssessmentAppointment appointment = appointmentService.createAppointment(
-                userId, childId, guideId, packageId, appointmentDate, appointmentTime, notes);
+                userId, familyId, childId, guideId, packageId,
+                appointmentDate, appointmentTime, appointmentType, durationMinutes, notes);
         return Result.success(appointment);
     }
 

+ 2 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/assessment/AssessmentAppointmentController.java

@@ -63,7 +63,8 @@ public class AssessmentAppointmentController {
         }
 
         AssessmentAppointment appointment = appointmentService.createAppointment(
-                userId, childId, guideId, null, appointmentDate, appointmentTime, notes);
+                userId, user.getFamilyId(), childId, guideId, null,
+                appointmentDate, appointmentTime, null, null, notes);
 
         // 创建执行记录
         AssessmentExecution exec = executionService.create(quotaId, childId, appointment.getId());

+ 4 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/AssessmentAppointment.java

@@ -1,6 +1,8 @@
 package com.etotem.cfc.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -18,7 +20,9 @@ public class AssessmentAppointment implements Serializable {
     private Long userId;
     private Long familyId;
     private Long childId;
+    @TableField(insertStrategy = FieldStrategy.IGNORED)
     private Long teacherId;
+    @TableField(insertStrategy = FieldStrategy.IGNORED)
     private Long guideId;
     private Long packageId;
     private String appointmentDate;

+ 6 - 2
cfc-backend/src/main/java/com/etotem/cfc/service/AssessmentAppointmentService.java

@@ -23,16 +23,20 @@ public class AssessmentAppointmentService extends ServiceImpl<AssessmentAppointm
     @Resource
     private EnergyService energyService;
 
-    public AssessmentAppointment createAppointment(Long userId, Long childId, Long guideId,
-                                                    Long packageId, String appointmentDate, String appointmentTime, String notes) {
+    public AssessmentAppointment createAppointment(Long userId, Long familyId, Long childId, Long guideId,
+                                                    Long packageId, String appointmentDate, String appointmentTime,
+                                                    String appointmentType, Integer durationMinutes, String notes) {
         AssessmentAppointment appointment = new AssessmentAppointment();
         appointment.setUserId(userId);
+        appointment.setFamilyId(familyId);
         appointment.setChildId(childId);
         appointment.setGuideId(guideId);
         appointment.setPackageId(packageId);
         appointment.setAppointmentDate(appointmentDate);
         appointment.setAppointmentTime(appointmentTime);
         appointment.setTeacherId(guideId);
+        appointment.setAppointmentType(appointmentType);
+        appointment.setDurationMinutes(durationMinutes);
         appointment.setStatus(0); // pending
         appointment.setNotes(notes);
         appointment.setCreatedAt(new Date());

+ 2 - 2
cfc-backend/src/main/resources/schema.sql

@@ -325,8 +325,8 @@ CREATE TABLE IF NOT EXISTS assessment_appointments (
     user_id BIGINT COMMENT '用户ID',
     family_id BIGINT NOT NULL,
     child_id BIGINT COMMENT '孩子ID',
-    teacher_id BIGINT COMMENT '教师ID',
-    guide_id BIGINT COMMENT '规划师ID',
+    teacher_id BIGINT NULL COMMENT '教师ID(可为空,系统安排时由客服后续分配)',
+    guide_id BIGINT NULL COMMENT '规划师ID(可为空,系统安排时由客服后续分配)',
     package_id BIGINT COMMENT '任务模板ID',
     appointment_date VARCHAR(20) COMMENT '预约日期 yyyy-MM-dd',
     appointment_time VARCHAR(20) COMMENT '预约时间 HH:mm',

+ 51 - 20
cfc-frontend/pages/profile/edit-child.vue

@@ -47,22 +47,22 @@
         <input class="input" v-model="form.idCard" placeholder="请输入身份证号" maxlength="18" />
       </view>
 
-      <!-- 扣分开关 -->
-      <view class="form-item">
+      <!-- 扣分开关(仅 children 系统支持) -->
+      <view class="form-item" v-if="!isFamilyMember">
         <text class="label">扣分开关</text>
         <switch :checked="form.penaltyEnabled === 1" @change="onPenaltyChange" color="#F97316" />
         <text class="hint">开启后,超时未完成任务将扣减积分</text>
       </view>
 
-      <!-- 对家庭成员可见 -->
-      <view class="form-item">
+      <!-- 对家庭成员可见(仅 children 系统支持) -->
+      <view class="form-item" v-if="!isFamilyMember">
         <text class="label">对家庭成员可见</text>
         <switch :checked="form.showToFamily !== 0" @change="onShowToFamilyChange" color="#5B9BD5" />
         <text class="hint">关闭后,其他家庭成员将看不到此孩子</text>
       </view>
 
-      <!-- 主题风格 -->
-      <view class="form-item">
+      <!-- 主题风格(仅 children 系统支持) -->
+      <view class="form-item" v-if="!isFamilyMember">
         <text class="label">主题风格</text>
         <picker :range="themes" range-key="label" @change="onThemeChange">
           <view class="picker">
@@ -77,12 +77,14 @@
 </template>
 
 <script>
-import { getChildren, updateChild } from '../../utils/api.js'
+import { getChildren, updateChild, updateFamilyMember } from '../../utils/api.js'
 
 export default {
   data() {
     return {
       childId: '',
+      memberId: '',
+      isFamilyMember: false,
       submitting: false,
       form: {
         nickname: '',
@@ -133,12 +135,19 @@ export default {
   },
   onLoad(options) {
     this.childId = options.childId || ''
-    if (!this.childId) {
+    this.memberId = options.memberId || ''
+    if (!this.childId && !this.memberId) {
       uni.showToast({ title: '参数错误', icon: 'none' })
       setTimeout(() => uni.navigateBack(), 1500)
       return
     }
-    this.loadChildData()
+    // 优先按 childId 从 children 系统加载,找不到则按 memberId 从 family-member 系统加载
+    if (this.childId) {
+      this.loadChildData()
+    } else {
+      this.isFamilyMember = true
+      this.loadFamilyMemberData(options)
+    }
   },
   methods: {
     async loadChildData() {
@@ -158,12 +167,24 @@ export default {
             showToFamily: child.showToFamily !== 0 ? 1 : 0,
             theme: child.theme || 'default'
           }
+        } else {
+          // children 系统找不到,尝试作为 family member 加载
+          this.isFamilyMember = true
+          this.memberId = this.childId
+          this.childId = ''
         }
       } catch (e) {
         console.error('加载孩子数据失败', e)
         uni.showToast({ title: '加载失败', icon: 'none' })
       }
     },
+    loadFamilyMemberData(options) {
+      // 从 URL 参数中填充基本信息(family member 系统字段有限)
+      this.form.nickname = options.nickname ? decodeURIComponent(options.nickname) : ''
+      this.form.gender = options.gender || ''
+      this.form.phone = options.phone || ''
+      this.form.birthday = options.birthday || ''
+    },
     onBirthdayChange(e) {
       this.form.birthday = e.detail.value
       // 根据出生日期自动计算年龄
@@ -204,17 +225,27 @@ export default {
 
       this.submitting = true
       try {
-        await updateChild(this.childId, {
-          nickname: this.form.nickname,
-          birthday: this.form.birthday,
-          gender: this.form.gender,
-          age: this.form.age,
-          phone: this.form.phone,
-          idCard: this.form.idCard,
-          penaltyEnabled: this.form.penaltyEnabled,
-          showToFamily: this.form.showToFamily,
-          theme: this.form.theme
-        })
+        if (this.isFamilyMember) {
+          await updateFamilyMember({
+            memberId: this.memberId,
+            nickname: this.form.nickname,
+            birthday: this.form.birthday,
+            gender: this.form.gender,
+            phone: this.form.phone
+          })
+        } else {
+          await updateChild(this.childId, {
+            nickname: this.form.nickname,
+            birthday: this.form.birthday,
+            gender: this.form.gender,
+            age: this.form.age,
+            phone: this.form.phone,
+            idCard: this.form.idCard,
+            penaltyEnabled: this.form.penaltyEnabled,
+            showToFamily: this.form.showToFamily,
+            theme: this.form.theme
+          })
+        }
         uni.showToast({ title: '保存成功', icon: 'success' })
         setTimeout(() => uni.navigateBack(), 1500)
       } catch (e) {

+ 5 - 1
cfc-frontend/pages/profile/family-members.vue

@@ -359,7 +359,11 @@ export default {
     },
     onEditRelation(member) {
       this.showMemberDetailModal = false
-      uni.navigateTo({ url: '/pages/profile/user-edit?memberId=' + member.id + '&nickname=' + encodeURIComponent(member.nickname || '') })
+      var params = 'memberId=' + member.id + '&nickname=' + encodeURIComponent(member.nickname || '')
+      if (member.gender) params += '&gender=' + member.gender
+      if (member.phone) params += '&phone=' + member.phone
+      if (member.birthday) params += '&birthday=' + member.birthday
+      uni.navigateTo({ url: '/pages/profile/edit-child?' + params })
     },
     doQuestionnaire(member) {
       this.showMemberDetailModal = false