一单n制等功能,接入随手拍之前我先提交一版本
This commit is contained in:
@@ -472,9 +472,9 @@
|
||||
<view
|
||||
v-else
|
||||
class="executor-radio"
|
||||
:class="{ 'executor-radio-active': selectedExecutorId === item.userId }"
|
||||
:class="{ 'executor-radio-active': selectedExecutorIdentityId === item.identityId }"
|
||||
>
|
||||
<view v-if="selectedExecutorId === item.userId" class="executor-radio-dot"></view>
|
||||
<view v-if="selectedExecutorIdentityId === item.identityId" class="executor-radio-dot"></view>
|
||||
</view>
|
||||
<view class="executor-info">
|
||||
<text class="executor-name">{{ item.nickName }}</text>
|
||||
@@ -521,7 +521,7 @@ const formData = reactive({
|
||||
modeName: '',
|
||||
selectDeptId: '',
|
||||
selectDeptName: '',
|
||||
executorId: '',
|
||||
executorIdentityId: '',
|
||||
executorNames: '',
|
||||
rosterIdentityIds: [],
|
||||
cycleId: '',
|
||||
@@ -641,7 +641,7 @@ const todayMinDate = computed(() => getTodayTimestamp())
|
||||
const endDateMinDate = computed(() => {
|
||||
if (formData.startDate) {
|
||||
const [year, month, day] = formData.startDate.split('-').map(Number)
|
||||
return new Date(year, month - 1, day + 1).getTime()
|
||||
return new Date(year, month - 1, day).getTime()
|
||||
}
|
||||
return getTodayTimestamp()
|
||||
});
|
||||
@@ -665,7 +665,7 @@ const cycleColumns = ref([['每天一次', '每周一次', '每月一次', '每
|
||||
// 执行人员选择器
|
||||
const showExecutorPopup = ref(false);
|
||||
const executorList = ref([]);
|
||||
const selectedExecutorId = ref(null);
|
||||
const selectedExecutorIdentityId = ref(null);
|
||||
const selectedRosterIdentityIds = ref([]);
|
||||
|
||||
const pageScrollLockStyle = computed(() => {
|
||||
@@ -786,23 +786,55 @@ const onModeConfirm = (e) => {
|
||||
}
|
||||
|
||||
const clearExecutorSelection = () => {
|
||||
formData.executorId = ''
|
||||
formData.executorIdentityId = ''
|
||||
formData.executorNames = ''
|
||||
formData.rosterIdentityIds = []
|
||||
selectedExecutorId.value = null
|
||||
selectedExecutorIdentityId.value = null
|
||||
selectedRosterIdentityIds.value = []
|
||||
}
|
||||
|
||||
const getDeptUsersQueryParams = () => {
|
||||
if (formData.runMode === 4) {
|
||||
return { type: 4 }
|
||||
}
|
||||
if (formData.runMode === 1) {
|
||||
return { type: 5 }
|
||||
}
|
||||
return {}
|
||||
}
|
||||
|
||||
const syncSingleExecutorSelection = (rawValue) => {
|
||||
if (formData.runMode === 4 || rawValue === undefined || rawValue === null || rawValue === '') {
|
||||
return
|
||||
}
|
||||
const num = Number(rawValue)
|
||||
if (Number.isNaN(num)) return
|
||||
const byIdentity = executorList.value.find((user) => Number(user.identityId) === num)
|
||||
if (byIdentity) {
|
||||
selectedExecutorIdentityId.value = byIdentity.identityId
|
||||
formData.executorIdentityId = byIdentity.identityId
|
||||
return
|
||||
}
|
||||
const byUser = executorList.value.find((user) => Number(user.userId) === num)
|
||||
if (byUser) {
|
||||
selectedExecutorIdentityId.value = byUser.identityId
|
||||
formData.executorIdentityId = byUser.identityId
|
||||
}
|
||||
}
|
||||
|
||||
const fetchDeptUsers = async (deptId) => {
|
||||
if (!deptId) {
|
||||
executorList.value = []
|
||||
return
|
||||
}
|
||||
try {
|
||||
const params = formData.runMode === 4 ? { type: 4 } : {}
|
||||
const params = getDeptUsersQueryParams()
|
||||
const res = await getDeptUsers(deptId, params)
|
||||
if (res.code === 0 && res.data) {
|
||||
executorList.value = res.data || []
|
||||
if (formData.runMode === 1) {
|
||||
syncSingleExecutorSelection(formData.executorIdentityId)
|
||||
}
|
||||
} else {
|
||||
executorList.value = []
|
||||
}
|
||||
@@ -813,7 +845,7 @@ const fetchDeptUsers = async (deptId) => {
|
||||
}
|
||||
|
||||
const selectExecutor = (item) => {
|
||||
selectedExecutorId.value = item.userId
|
||||
selectedExecutorIdentityId.value = item.identityId
|
||||
}
|
||||
|
||||
const toggleRosterExecutor = (item) => {
|
||||
@@ -841,12 +873,12 @@ const confirmExecutorSelect = () => {
|
||||
showExecutorPopup.value = false
|
||||
return
|
||||
}
|
||||
if (!selectedExecutorId.value) {
|
||||
if (!selectedExecutorIdentityId.value) {
|
||||
uni.showToast({ title: '请选择执行人员', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const selectedUser = executorList.value.find(u => u.userId === selectedExecutorId.value)
|
||||
formData.executorId = selectedExecutorId.value
|
||||
const selectedUser = executorList.value.find((user) => user.identityId === selectedExecutorIdentityId.value)
|
||||
formData.executorIdentityId = selectedExecutorIdentityId.value
|
||||
formData.executorNames = selectedUser?.nickName || selectedUser?.nickname || ''
|
||||
showExecutorPopup.value = false
|
||||
}
|
||||
@@ -859,7 +891,7 @@ const openExecutorPopup = () => {
|
||||
if (formData.runMode === 4) {
|
||||
selectedRosterIdentityIds.value = [...(formData.rosterIdentityIds || [])]
|
||||
} else {
|
||||
selectedExecutorId.value = formData.executorId || null
|
||||
selectedExecutorIdentityId.value = formData.executorIdentityId || null
|
||||
}
|
||||
fetchDeptUsers(formData.deptId)
|
||||
showExecutorPopup.value = true
|
||||
@@ -933,7 +965,7 @@ const onStartDateConfirm = (e) => {
|
||||
})
|
||||
return
|
||||
}
|
||||
if (formData.endDate && parseDateValue(selectedDate) >= parseDateValue(formData.endDate)) {
|
||||
if (formData.endDate && parseDateValue(selectedDate) > parseDateValue(formData.endDate)) {
|
||||
formData.endDate = ''
|
||||
}
|
||||
formData.startDate = selectedDate
|
||||
@@ -949,8 +981,8 @@ const onEndDateConfirm = (e) => {
|
||||
})
|
||||
return
|
||||
}
|
||||
if (formData.startDate && parseDateValue(selectedDate) <= parseDateValue(formData.startDate)) {
|
||||
uni.showToast({ title: '计划结束日期必须晚于计划开始日期', icon: 'none' })
|
||||
if (formData.startDate && parseDateValue(selectedDate) < parseDateValue(formData.startDate)) {
|
||||
uni.showToast({ title: '计划结束日期不能早于计划开始日期', icon: 'none' })
|
||||
return
|
||||
}
|
||||
formData.endDate = selectedDate
|
||||
@@ -1466,7 +1498,7 @@ const handleSave = async () => {
|
||||
uni.showToast({ title: '请选择模式', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (formData.runMode === 1 && !formData.executorId) {
|
||||
if (formData.runMode === 1 && !formData.executorIdentityId) {
|
||||
uni.showToast({ title: '请选择执行人员', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
@@ -1482,8 +1514,8 @@ const handleSave = async () => {
|
||||
uni.showToast({ title: '请选择计划日期', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (parseDateValue(formData.endDate) <= parseDateValue(formData.startDate)) {
|
||||
uni.showToast({ title: '计划结束日期必须晚于计划开始日期', icon: 'none' });
|
||||
if (parseDateValue(formData.endDate) < parseDateValue(formData.startDate)) {
|
||||
uni.showToast({ title: '计划结束日期不能早于计划开始日期', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1536,8 +1568,8 @@ const handleSave = async () => {
|
||||
planEndTime: `${formData.endDate} 00:00:00`
|
||||
};
|
||||
|
||||
if (formData.runMode === 1 && formData.executorId) {
|
||||
params.executorId = formData.executorId;
|
||||
if (formData.runMode === 1 && formData.executorIdentityId) {
|
||||
params.executorIdentityId = formData.executorIdentityId;
|
||||
}
|
||||
|
||||
if (formData.runMode === 4 && formData.rosterIdentityIds?.length) {
|
||||
|
||||
Reference in New Issue
Block a user