feat: refs #7828 useAcl & cherry pick mail data worker
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
adb9cac360
commit
44fd356d63
|
@ -12,7 +12,6 @@ import WorkerTimeControlCalendar from 'pages/Worker/Card/WorkerTimeControlCalend
|
||||||
|
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useRole } from 'src/composables/useRole';
|
|
||||||
import { useAcl } from 'src/composables/useAcl';
|
import { useAcl } from 'src/composables/useAcl';
|
||||||
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
|
@ -63,13 +62,16 @@ const selectedCalendarDates = ref([]);
|
||||||
const selectedDateFormatted = ref(toDateString(defaultDate.value));
|
const selectedDateFormatted = ref(toDateString(defaultDate.value));
|
||||||
|
|
||||||
const arrayData = useArrayData('workerData');
|
const arrayData = useArrayData('workerData');
|
||||||
|
const acl = useAcl();
|
||||||
const worker = computed(() => arrayData.store?.data);
|
const worker = computed(() => arrayData.store?.data);
|
||||||
|
const canSend = computed(() =>
|
||||||
const isHr = computed(() => useRole().hasAny(['hr']));
|
acl.hasAny([{ model: 'WorkerTimeControl', props: 'sendMail', accessType: 'WRITE' }])
|
||||||
|
);
|
||||||
const canSend = computed(() => useAcl().hasAny('WorkerTimeControl', 'sendMail', 'WRITE'));
|
const canUpdate = computed(() =>
|
||||||
|
acl.hasAny([
|
||||||
|
{ model: 'WorkerTimeControl', props: 'updateMailState', accessType: 'WRITE' },
|
||||||
|
])
|
||||||
|
);
|
||||||
const isHimself = computed(() => user.value.id === Number(route.params.id));
|
const isHimself = computed(() => user.value.id === Number(route.params.id));
|
||||||
|
|
||||||
const columns = computed(() => {
|
const columns = computed(() => {
|
||||||
|
@ -257,46 +259,25 @@ const fetchHours = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchWorkerTimeControlMails = async (filter) => {
|
|
||||||
try {
|
|
||||||
const { data } = await axios.get('WorkerTimeControlMails', {
|
|
||||||
params: { filter: JSON.stringify(filter) },
|
|
||||||
});
|
|
||||||
|
|
||||||
return data;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching worker time control mails');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchWeekData = async () => {
|
const fetchWeekData = async () => {
|
||||||
try {
|
const where = {
|
||||||
const data = (
|
|
||||||
await axios.get(`WorkerTimeControlMails/${route.params.id}/getWeeklyMail`, {
|
|
||||||
params: {
|
|
||||||
workerFk: route.params.id,
|
|
||||||
year: selectedDate.value.getFullYear(),
|
year: selectedDate.value.getFullYear(),
|
||||||
week: selectedWeekNumber.value,
|
week: selectedWeekNumber.value,
|
||||||
},
|
};
|
||||||
|
try {
|
||||||
|
const mail = (
|
||||||
|
await axios.get(`Workers/${route.params.id}/mail`, {
|
||||||
|
params: { filter: { where } },
|
||||||
})
|
})
|
||||||
).data;
|
).data[0];
|
||||||
if (!data.length) state.value = null;
|
if (!mail) state.value = null;
|
||||||
else {
|
else {
|
||||||
const [mail] = data;
|
|
||||||
state.value = mail.state;
|
state.value = mail.state;
|
||||||
reason.value = mail.reason;
|
reason.value = mail.reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
canResend.value = !!(
|
canResend.value = !!(
|
||||||
await axios.get('WorkerTimeControlMails/count', {
|
await axios.get('WorkerTimeControlMails/count', { params: { where } })
|
||||||
filter: {
|
|
||||||
where: {
|
|
||||||
year: selectedDate.value.getFullYear(),
|
|
||||||
week: selectedWeekNumber.value,
|
|
||||||
limit: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
).data.count;
|
).data.count;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error fetching week data');
|
console.error('Error fetching week data');
|
||||||
|
@ -443,7 +424,7 @@ onMounted(async () => {
|
||||||
<div>
|
<div>
|
||||||
<QBtnGroup push class="q-gutter-x-sm" flat>
|
<QBtnGroup push class="q-gutter-x-sm" flat>
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="isHimself && state"
|
v-if="canUpdate && state"
|
||||||
:label="t('Satisfied')"
|
:label="t('Satisfied')"
|
||||||
color="primary"
|
color="primary"
|
||||||
type="submit"
|
type="submit"
|
||||||
|
@ -451,7 +432,7 @@ onMounted(async () => {
|
||||||
@click="isSatisfied()"
|
@click="isSatisfied()"
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="isHimself && state"
|
v-if="canUpdate && state"
|
||||||
:label="t('Not satisfied')"
|
:label="t('Not satisfied')"
|
||||||
color="primary"
|
color="primary"
|
||||||
type="submit"
|
type="submit"
|
||||||
|
@ -462,7 +443,7 @@ onMounted(async () => {
|
||||||
</QBtnGroup>
|
</QBtnGroup>
|
||||||
<QBtnGroup push class="q-gutter-x-sm q-ml-none" flat>
|
<QBtnGroup push class="q-gutter-x-sm q-ml-none" flat>
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="reason && state && (isHimself || isHr)"
|
v-if="reason && state && canUpdate"
|
||||||
:label="t('Reason')"
|
:label="t('Reason')"
|
||||||
color="primary"
|
color="primary"
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|
Loading…
Reference in New Issue