teacher-student-selector.blade.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <div class="space-y-4">
  2. {{-- 选择老师(如果是老师登录,自动选中并隐藏) --}}
  3. @if(!$this->shouldHideTeacherDropdown())
  4. <div class="form-control w-full">
  5. <label class="label">
  6. <span class="label-text font-medium">
  7. {{ $teacherLabel }}
  8. @if($required)
  9. <span class="text-error">*</span>
  10. @endif
  11. </span>
  12. </label>
  13. <select
  14. wire:model.live="teacherId"
  15. class="select select-bordered w-full"
  16. @if($required) required @endif
  17. >
  18. <option value="">{{ $teacherPlaceholder }}</option>
  19. @foreach($teacherOptions as $teacherId => $teacherName)
  20. <option value="{{ $teacherId }}">{{ $teacherName }}</option>
  21. @endforeach
  22. </select>
  23. @if($teacherHelperText)
  24. <label class="label">
  25. <span class="label-text-alt text-info">{{ $teacherHelperText }}</span>
  26. </label>
  27. @endif
  28. @if($teacherId)
  29. <label class="label">
  30. <span class="label-text-alt text-success">
  31. <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  32. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
  33. </svg>
  34. 已选择:{{ $teacherId ? $teacherOptions[$teacherId] ?? '未选择' : '未选择' }}
  35. </span>
  36. </label>
  37. @endif
  38. </div>
  39. @else
  40. {{-- 显示当前选中的老师信息(不可编辑) --}}
  41. <div class="form-control w-full">
  42. <label class="label">
  43. <span class="label-text font-medium">
  44. {{ $teacherLabel }}
  45. @if($required)
  46. <span class="text-error">*</span>
  47. @endif
  48. </span>
  49. <span class="label-text-alt text-info">
  50. <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  51. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
  52. </svg>
  53. 已自动选择
  54. </span>
  55. </label>
  56. <div class="p-3 bg-base-200 rounded-lg">
  57. <div class="font-medium">
  58. {{ $teacherId ? $teacherOptions[$teacherId] ?? '未选择' : '未选择' }}
  59. </div>
  60. @if($teacherHelperText)
  61. <div class="text-xs text-gray-500 mt-1">{{ $teacherHelperText }}</div>
  62. @endif
  63. </div>
  64. <input type="hidden" wire:model.live="teacherId">
  65. </div>
  66. @endif
  67. {{-- 选择学生 --}}
  68. <div class="form-control w-full">
  69. <label class="label">
  70. <span class="label-text font-medium">
  71. {{ $studentLabel }}
  72. @if($required)
  73. <span class="text-error">*</span>
  74. @endif
  75. </span>
  76. </label>
  77. <select
  78. wire:model.live="studentId"
  79. wire:change="$refresh"
  80. class="select select-bordered w-full"
  81. @if(empty($teacherId)) disabled @endif
  82. @if($required) required @endif
  83. >
  84. <option value="">
  85. @if(empty($teacherId))
  86. 请先选择老师
  87. @else
  88. {{ $studentPlaceholder }}
  89. @endif
  90. </option>
  91. @foreach($studentOptions as $studentId => $studentName)
  92. <option value="{{ $studentId }}">{{ $studentName }}</option>
  93. @endforeach
  94. </select>
  95. @if($studentHelperText)
  96. <label class="label">
  97. <span class="label-text-alt text-info">{{ $studentHelperText }}</span>
  98. </label>
  99. @endif
  100. @if($studentId)
  101. <label class="label">
  102. <span class="label-text-alt text-success">
  103. <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  104. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
  105. </svg>
  106. 已选择:{{ $studentId ? $studentOptions[$studentId] ?? '未选择' : '未选择' }}
  107. </span>
  108. </label>
  109. @elseif($teacherId && empty($studentOptions))
  110. <label class="label">
  111. <span class="label-text-alt text-warning">
  112. <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  113. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 15.5c-.77.833.192 2.5 1.732 2.5z"></path>
  114. </svg>
  115. 该老师暂无学生
  116. </span>
  117. </label>
  118. @endif
  119. </div>
  120. </div>