|
|
|
@ -170,7 +170,7 @@ |
|
|
|
<!-- 时段选择 --> |
|
|
|
<van-popup v-model:show="showTimePicker" position="bottom" round> |
|
|
|
<van-picker |
|
|
|
:columns="timeColumns" |
|
|
|
:columns="availableTimeColumns" |
|
|
|
@confirm="onTimeConfirm" |
|
|
|
@cancel="showTimePicker = false" |
|
|
|
/> |
|
|
|
@ -217,17 +217,16 @@ |
|
|
|
<span class="person-picker-title">选择执法人员</span> |
|
|
|
<van-icon name="cross" @click="showPersonPicker = false" /> |
|
|
|
</div> |
|
|
|
<van-search |
|
|
|
v-model="personSearchKeyword" |
|
|
|
placeholder="输入姓名/账号检索单位人员" |
|
|
|
shape="round" |
|
|
|
@update:model-value="onPersonSearchInput" |
|
|
|
/> |
|
|
|
<div class="search-bar"> |
|
|
|
<van-search v-model="personSearchKeyword" placeholder="请输入至少1个字搜索" |
|
|
|
@search="handlePersonSearch" @clear="clearPersonSearch" /> |
|
|
|
<van-button class="search-btn" type="primary" @click="handlePersonSearch">搜索</van-button> |
|
|
|
</div> |
|
|
|
<div class="person-picker-body"> |
|
|
|
<van-list |
|
|
|
v-model:loading="personLoading" |
|
|
|
:finished="personFinished" |
|
|
|
finished-text="" |
|
|
|
:finished-text="personFinishedText" |
|
|
|
:offset="50" |
|
|
|
@load="onPersonLoad" |
|
|
|
> |
|
|
|
@ -243,7 +242,7 @@ |
|
|
|
<!-- <span v-if="user.loginName" class="person-item-login">@{{ user.loginName }}</span> --> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<van-empty v-if="!personLoading && !personSearchResult.length" description="未检索到人员" image-size="80" /> |
|
|
|
<van-empty v-if="!personLoading && !personSearchResult.length" :description="personEmptyText" image-size="80" /> |
|
|
|
</van-list> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
@ -357,6 +356,38 @@ const timeColumns = [ |
|
|
|
{ text: '其他(18:00-21:00)', value: 3 }, |
|
|
|
]; |
|
|
|
|
|
|
|
// 可选时段:执法日期为今天时过滤已过去的时段 |
|
|
|
const availableTimeColumns = computed(() => { |
|
|
|
// 依赖弹窗显隐,打开时重新计算获取最新时间 |
|
|
|
void showTimePicker.value; |
|
|
|
const dateStr = form.value.enforceDate; |
|
|
|
if (!dateStr) return timeColumns; |
|
|
|
const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`; |
|
|
|
if (dateStr !== todayStr) return timeColumns; |
|
|
|
const now = new Date(); |
|
|
|
const nowMinutes = now.getHours() * 60 + now.getMinutes(); |
|
|
|
const periodEnds = { 1: 12 * 60, 2: 18 * 60, 3: 21 * 60 }; |
|
|
|
return timeColumns.filter(item => nowMinutes < periodEnds[item.value]); |
|
|
|
}); |
|
|
|
|
|
|
|
// 默认时段设为当前可选的第一个 |
|
|
|
const syncDefaultEnforceTime = () => { |
|
|
|
const available = availableTimeColumns.value; |
|
|
|
if (available.length === 0) return; |
|
|
|
const dateStr = form.value.enforceDate; |
|
|
|
const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`; |
|
|
|
// 非今天(未来日期)默认取第一个(上午) |
|
|
|
if (dateStr !== todayStr) { |
|
|
|
form.value.enforceTime = available[0].value; |
|
|
|
return; |
|
|
|
} |
|
|
|
// 今天:当前值不可用时取第一个 |
|
|
|
const currentValid = available.some(item => item.value === form.value.enforceTime); |
|
|
|
if (!currentValid) { |
|
|
|
form.value.enforceTime = available[0].value; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 日期+时段展示 |
|
|
|
const enforceTimeDisplay = computed(() => { |
|
|
|
const timeText = { 1: '上午(9:00-12:00)', 2: '下午(14:00-18:00)', 3: '其他(18:00-21:00)' }; |
|
|
|
@ -385,9 +416,12 @@ const personLoading = ref(false); |
|
|
|
const personFinished = ref(false); |
|
|
|
const personPageNum = ref(1); |
|
|
|
const personPageSize = 10; |
|
|
|
let personSearchTimer = null; |
|
|
|
const personSearched = ref(false); |
|
|
|
let personSearchSeq = 0; |
|
|
|
|
|
|
|
const personEmptyText = computed(() => personSearched.value ? '未检索到人员' : '请输入至少1个字搜索'); |
|
|
|
const personFinishedText = computed(() => personSearchResult.value.length > 0 ? '没有更多了' : ''); |
|
|
|
|
|
|
|
// 计划列表 |
|
|
|
const planOptions = ref([]); |
|
|
|
const planLoading = ref(false); |
|
|
|
@ -402,6 +436,8 @@ onMounted(() => { |
|
|
|
form.value.deptName = useCommon.deptName || ''; |
|
|
|
// 默认绑定当前用户为首位执法人员 |
|
|
|
bindCurrentUserAsDefaultPerson(); |
|
|
|
// 默认时段设为当前可选的第一个 |
|
|
|
syncDefaultEnforceTime(); |
|
|
|
|
|
|
|
if (isEdit.value) { |
|
|
|
loadDetail(route.query.id); |
|
|
|
@ -454,6 +490,7 @@ const loadDetail = (id, isReinitiateMode = false) => { |
|
|
|
const onDateConfirm = ({ selectedValues }) => { |
|
|
|
form.value.enforceDate = selectedValues.join('-'); |
|
|
|
showDatePicker.value = false; |
|
|
|
syncDefaultEnforceTime(); |
|
|
|
}; |
|
|
|
|
|
|
|
// 时段确认 |
|
|
|
@ -526,22 +563,33 @@ const onAddPerson = () => { |
|
|
|
personSearchKeyword.value = ''; |
|
|
|
personSearchResult.value = []; |
|
|
|
personPageNum.value = 1; |
|
|
|
personFinished.value = false; |
|
|
|
personFinished.value = true; |
|
|
|
personLoading.value = false; |
|
|
|
personSearched.value = false; |
|
|
|
showPersonPicker.value = true; |
|
|
|
// van-list 挂载后自动触发 @load 加载第一页 |
|
|
|
}; |
|
|
|
|
|
|
|
const onPersonSearchInput = (val) => { |
|
|
|
if (personSearchTimer) clearTimeout(personSearchTimer); |
|
|
|
const keyword = (val || '').trim(); |
|
|
|
personSearchTimer = setTimeout(() => { |
|
|
|
personPageNum.value = 1; |
|
|
|
personFinished.value = false; |
|
|
|
personSearchResult.value = []; |
|
|
|
personLoading.value = true; |
|
|
|
fetchPersonList(keyword); |
|
|
|
}, 300); |
|
|
|
const handlePersonSearch = () => { |
|
|
|
const keyword = (personSearchKeyword.value || '').trim(); |
|
|
|
if (keyword.length < 1) { |
|
|
|
showToast('请输入至少1个字搜索'); |
|
|
|
return; |
|
|
|
} |
|
|
|
personPageNum.value = 1; |
|
|
|
personFinished.value = false; |
|
|
|
personSearchResult.value = []; |
|
|
|
personLoading.value = true; |
|
|
|
personSearched.value = true; |
|
|
|
fetchPersonList(keyword); |
|
|
|
}; |
|
|
|
|
|
|
|
const clearPersonSearch = () => { |
|
|
|
personSearchKeyword.value = ''; |
|
|
|
personPageNum.value = 1; |
|
|
|
personFinished.value = true; |
|
|
|
personSearchResult.value = []; |
|
|
|
personLoading.value = false; |
|
|
|
personSearched.value = false; |
|
|
|
}; |
|
|
|
|
|
|
|
// van-list 触底加载 |
|
|
|
@ -551,6 +599,11 @@ const onPersonLoad = () => { |
|
|
|
|
|
|
|
// 实际发起人员检索(分页追加) |
|
|
|
const fetchPersonList = (keyword) => { |
|
|
|
if ((keyword || '').trim().length < 1) { |
|
|
|
personFinished.value = true; |
|
|
|
personLoading.value = false; |
|
|
|
return; |
|
|
|
} |
|
|
|
const seq = ++personSearchSeq; |
|
|
|
personLoading.value = true; |
|
|
|
searchBureauUnitUsers( |
|
|
|
@ -610,7 +663,6 @@ const removePerson = (index) => { |
|
|
|
}; |
|
|
|
|
|
|
|
const syncPersonData = () => { |
|
|
|
console.log(personList.value); |
|
|
|
form.value.enforceUserNames = personList.value.map(p => p.name).join(','); |
|
|
|
form.value.enforceUserIds = personList.value.map(p => p.id || '').join(','); |
|
|
|
form.value.enforceUserTels = personList.value.map(p => p.phone || '').join(','); |
|
|
|
@ -902,6 +954,20 @@ const doSubmit = (isDraft) => { |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
height: 100%; |
|
|
|
.search-bar { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
margin: 0.3rem; |
|
|
|
:deep(.van-search) { |
|
|
|
padding-right: 0px; |
|
|
|
flex: 1; |
|
|
|
height: 34px; |
|
|
|
} |
|
|
|
.search-btn { |
|
|
|
flex: none; |
|
|
|
height: 34px; |
|
|
|
} |
|
|
|
} |
|
|
|
.person-picker-header { |
|
|
|
display: flex; |
|
|
|
justify-content: space-between; |
|
|
|
|