Добавил выбор ст. мед. сестер из отделений
This commit is contained in:
@@ -70,11 +70,12 @@ const openReport = (path) => {
|
||||
}
|
||||
|
||||
const openNurseReport = () => {
|
||||
if (authStore.isSeniorStaff) {
|
||||
showSelectNurseUserModal.value = true
|
||||
} else {
|
||||
router.visit('/nurse/report')
|
||||
}
|
||||
// if (authStore.isSeniorStaff) {
|
||||
// showSelectNurseUserModal.value = true
|
||||
// } else {
|
||||
// router.visit('/nurse/report')
|
||||
// }
|
||||
showSelectNurseUserModal.value = true
|
||||
}
|
||||
|
||||
const cardColor = computed(() => themeVars.value.cardColor)
|
||||
@@ -174,7 +175,7 @@ const dividerColor = computed(() => themeVars.value.dividerColor)
|
||||
</NFlex>
|
||||
</div>
|
||||
|
||||
<SelectUserModal v-model:show="showSelectUserModal" />
|
||||
<SelectUserModal v-model:show="showSelectUserModal" :only-user-department="false" />
|
||||
<SelectUserModal
|
||||
v-model:show="showSelectNurseUserModal"
|
||||
target-path="/nurse/report"
|
||||
|
||||
@@ -18,6 +18,10 @@ const props = defineProps({
|
||||
withExistsCheck: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
onlyUserDepartment: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
})
|
||||
|
||||
@@ -30,6 +34,8 @@ const usersLoaded = ref(false)
|
||||
const departmentsLoaded = ref(false)
|
||||
const reportExists = ref(false)
|
||||
const existingReportId = ref(null)
|
||||
const loadingDepartmentFetch = ref(false)
|
||||
const loadingUserFetch = ref(false)
|
||||
|
||||
const users = computed(() => rawUsers.value.map(itm => ({
|
||||
label: `${itm.FAM_V} ${itm.IM_V} ${itm.OT_V}`,
|
||||
@@ -41,22 +47,29 @@ const departments = computed(() => rawDepartments.value.map(itm => ({
|
||||
value: itm.department_id
|
||||
})))
|
||||
|
||||
const fetchUsers = () => {
|
||||
if (usersLoaded.value) return
|
||||
axios.get('/api/mis/department-users')
|
||||
const fetchUsers = (departmentId) => {
|
||||
usersLoaded.value = []
|
||||
loadingUserFetch.value = true
|
||||
const type = props.onlyUserDepartment ? 'nurse' : 'duty'
|
||||
axios.get(`/api/app/departments/${departmentId}/users?onlyUserDepartment=${props.onlyUserDepartment}&type=${type}`)
|
||||
.then((res) => {
|
||||
rawUsers.value = res.data
|
||||
usersLoaded.value = true
|
||||
})
|
||||
}).finally((e) => {
|
||||
loadingUserFetch.value = false
|
||||
})
|
||||
}
|
||||
|
||||
const fetchDepartments = () => {
|
||||
if (departmentsLoaded.value) return
|
||||
loadingDepartmentFetch.value = true
|
||||
axios.get('/api/app/departments')
|
||||
.then((res) => {
|
||||
rawDepartments.value = res.data
|
||||
departmentsLoaded.value = true
|
||||
})
|
||||
}).finally((e) => {
|
||||
loadingDepartmentFetch.value = false
|
||||
})
|
||||
}
|
||||
|
||||
const checkReportExists = async (userId, departmentId) => {
|
||||
@@ -130,7 +143,7 @@ watch(() => show.value, (opened) => {
|
||||
|
||||
reportStore.reportInfo.userId = null
|
||||
reportStore.reportInfo.departmentId = null
|
||||
fetchUsers()
|
||||
// fetchUsers()
|
||||
fetchDepartments()
|
||||
}, {immediate: false})
|
||||
|
||||
@@ -158,6 +171,11 @@ const onAfterLeave = () => {
|
||||
reportExists.value = false
|
||||
existingReportId.value = null
|
||||
}
|
||||
|
||||
const onChangeDepartment = (departmentId) => {
|
||||
usersLoaded.value = false
|
||||
fetchUsers(departmentId)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -168,15 +186,19 @@ const onAfterLeave = () => {
|
||||
@before-leave="onAfterLeave"
|
||||
>
|
||||
<NForm id="select-user-form" ref="formRef" :model="reportStore.reportInfo" :rules="rules">
|
||||
<NFormItem label="Выберите ответственного" path="userId">
|
||||
<NSelect :options="users"
|
||||
v-model:value="reportStore.reportInfo.userId"
|
||||
<NFormItem label="Выберите отделение" path="departmentId">
|
||||
<NSelect :options="departments"
|
||||
:loading="loadingDepartmentFetch"
|
||||
@change="onChangeDepartment"
|
||||
v-model:value="reportStore.reportInfo.departmentId"
|
||||
filterable
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="Выберите отделение" path="departmentId">
|
||||
<NSelect :options="departments"
|
||||
v-model:value="reportStore.reportInfo.departmentId"
|
||||
<NFormItem label="Выберите ответственного" path="userId">
|
||||
<NSelect :options="users"
|
||||
:loading="loadingUserFetch"
|
||||
:disabled="!usersLoaded"
|
||||
v-model:value="reportStore.reportInfo.userId"
|
||||
filterable
|
||||
/>
|
||||
</NFormItem>
|
||||
|
||||
Reference in New Issue
Block a user