hookehuyr

fix(打卡): 修复计数打卡目标选择和样式问题

修复在确认任务时person_type赋值顺序问题,避免重复调用fetchTargetList
优化目标列表组件样式,防止文本选择和右键菜单
<!--
* @Date: 2025-12-16 11:44:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-12-16 13:53:45
* @LastEditTime: 2025-12-16 14:17:38
* @FilePath: /mlaj/src/components/count/CheckinTargetList.vue
* @Description: 打卡动态对象列表组件
-->
......@@ -20,7 +20,8 @@
<template v-if="targetList.length > 0">
<div v-for="(item, index) in targetList" :key="index"
class="px-4 py-1.5 rounded-full text-sm transition-colors duration-200 border cursor-pointer select-none relative"
:style="selectedTargets.some(t => t.id === item.id) ? {
:style="[
selectedTargets.some(t => t.id === item.id) ? {
backgroundColor: '#4caf50',
color: '#ffffff',
borderColor: '#4caf50'
......@@ -28,7 +29,14 @@
backgroundColor: '#ffffff',
color: '#4b5563',
borderColor: '#e5e7eb'
}"
},
{
'-webkit-touch-callout': 'none',
'-webkit-user-select': 'none',
'user-select': 'none'
}
]"
@contextmenu.prevent
@click="onClick(item)"
@touchstart="onTouchStart(item)"
@touchend="onTouchEnd"
......
......@@ -256,6 +256,7 @@ const onConfirmTask = ({ selectedOptions }) => {
selectedTaskValue.value = [option.value]
isMakeup.value = !!option.is_makeup
showTaskPicker.value = false
personType.value = option.person_type
// 动态表单字段映射
if (option.field_list && Array.isArray(option.field_list)) {
......@@ -276,7 +277,7 @@ const onConfirmTask = ({ selectedOptions }) => {
unitField.type = 'textarea'
}
} else {
// 如果没有配置字段,使用默认字段 (兼容旧数据或Mock)
// 如果没有配置字段,使用默认字段
dynamicFormFields.value = [
{ id: 'name', label: '姓名', type: 'text', required: true },
{ id: 'city', label: '城市', type: 'textarea', required: true },
......@@ -293,8 +294,7 @@ const onConfirmTask = ({ selectedOptions }) => {
// 如果是计数打卡,根据选中的作业ID查询计数对象
if (taskType.value === 'count') {
fetchTargetList(option.person_type)
personType.value = option.person_type
fetchTargetList(personType.value)
}
}
......@@ -902,12 +902,12 @@ onMounted(async () => {
if (option) {
selectedTaskText.value = option.text
isMakeup.value = !!option.is_makeup
personType.value = option.person_type
}
// 如果是计数打卡,根据选中的作业ID查询计数对象
if (taskType.value === 'count') {
fetchTargetList(option.person_type)
personType.value = option.person_type
fetchTargetList(personType.value)
}
}
......