hookehuyr

refactor(CheckinDetailPage): 优化计数对象选择界面样式和交互逻辑

- 将复选框列表改为标签式选择,提升视觉体验
- 简化选择逻辑,移除不必要的复选框引用处理
- 将"学校"字段标签改为更通用的"单位"
...@@ -44,30 +44,31 @@ ...@@ -44,30 +44,31 @@
44 <van-button size="small" type="primary" plain icon="plus" @click="showAddTargetDialog = true" class="!h-7">添加</van-button> 44 <van-button size="small" type="primary" plain icon="plus" @click="showAddTargetDialog = true" class="!h-7">添加</van-button>
45 </div> 45 </div>
46 46
47 - <div class="bg-gray-50 rounded-lg p-2 max-h-48 overflow-y-auto"> 47 + <div class="bg-gray-50 rounded-lg p-2">
48 - <van-checkbox-group v-model="selectedTargets"> 48 + <div class="flex flex-wrap gap-2">
49 <template v-if="targetList.length > 0"> 49 <template v-if="targetList.length > 0">
50 <div 50 <div
51 v-for="(item, index) in targetList" 51 v-for="(item, index) in targetList"
52 :key="index" 52 :key="index"
53 - class="flex items-center justify-between p-3 mb-2 bg-white rounded border border-gray-100 last:mb-0" 53 + class="px-4 py-1.5 rounded-full text-sm transition-colors duration-200 border cursor-pointer select-none"
54 - @click="toggleTarget(index)" 54 + :style="selectedTargets.some(t => t.name === item.name) ? {
55 + backgroundColor: '#4caf50',
56 + color: '#ffffff',
57 + borderColor: '#4caf50'
58 + } : {
59 + backgroundColor: '#ffffff',
60 + color: '#4b5563',
61 + borderColor: '#e5e7eb'
62 + }"
63 + @click="toggleTarget(item)"
55 > 64 >
56 - <div class="flex-1"> 65 + {{ item.name }}
57 - <div class="font-medium text-gray-800">{{ item.name }}</div>
58 - <div class="text-xs text-gray-500 mt-0.5">{{ item.city }} | {{ item.school }}</div>
59 - </div>
60 - <van-checkbox
61 - :name="item"
62 - :ref="el => setCheckboxRef(el, index)"
63 - @click.stop
64 - />
65 </div> 66 </div>
66 </template> 67 </template>
67 - <div v-else class="text-center py-4 text-gray-400 text-sm"> 68 + <div v-else class="w-full text-center py-4 text-gray-400 text-sm">
68 暂无计数对象,请点击上方添加按钮 69 暂无计数对象,请点击上方添加按钮
69 </div> 70 </div>
70 - </van-checkbox-group> 71 + </div>
71 </div> 72 </div>
72 </div> 73 </div>
73 74
...@@ -94,12 +95,12 @@ ...@@ -94,12 +95,12 @@
94 /> 95 />
95 <van-field 96 <van-field
96 v-model="newTargetForm.school" 97 v-model="newTargetForm.school"
97 - label="学校" 98 + label="单位"
98 rows="2" 99 rows="2"
99 autosize 100 autosize
100 type="textarea" 101 type="textarea"
101 maxlength="50" 102 maxlength="50"
102 - placeholder="请输入所在学校" 103 + placeholder="请输入所在单位"
103 /> 104 />
104 </div> 105 </div>
105 </van-dialog> 106 </van-dialog>
...@@ -284,17 +285,12 @@ const newTargetForm = reactive({ ...@@ -284,17 +285,12 @@ const newTargetForm = reactive({
284 school: '' 285 school: ''
285 }) 286 })
286 287
287 -const checkboxRefs = ref([]) 288 +const toggleTarget = (item) => {
288 -const setCheckboxRef = (el, index) => { 289 + const index = selectedTargets.value.findIndex(t => t.name === item.name)
289 - if (el) { 290 + if (index > -1) {
290 - checkboxRefs.value[index] = el 291 + selectedTargets.value.splice(index, 1)
291 - } 292 + } else {
292 -} 293 + selectedTargets.value.push(item)
293 -
294 -const toggleTarget = (index) => {
295 - const checkbox = checkboxRefs.value[index]
296 - if (checkbox) {
297 - checkbox.toggle()
298 } 294 }
299 } 295 }
300 296
......