2026-10-06 19:54:38 +03:30
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { computed } from 'vue';
|
2026-10-18 19:39:59 +03:30
|
|
|
import {
|
|
|
|
|
Alert as AAlert,
|
|
|
|
|
Col as ACol,
|
|
|
|
|
FormItem as AFormItem,
|
|
|
|
|
Modal as AModal,
|
|
|
|
|
Row as ARow,
|
|
|
|
|
Textarea as ATextarea,
|
|
|
|
|
Typography,
|
|
|
|
|
} from 'ant-design-vue';
|
2026-10-06 19:54:38 +03:30
|
|
|
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
|
|
|
|
import type { RoutineTaskActions } from '@/lib/useRoutineTaskActions';
|
|
|
|
|
|
2026-10-18 19:39:59 +03:30
|
|
|
const { Text: ATypographyText } = Typography;
|
|
|
|
|
|
2026-10-06 19:54:38 +03:30
|
|
|
const props = defineProps<{ actions: RoutineTaskActions }>();
|
|
|
|
|
|
|
|
|
|
const modal = computed(() => props.actions.modal);
|
|
|
|
|
|
|
|
|
|
const title = computed(() => {
|
|
|
|
|
switch (modal.value.kind) {
|
|
|
|
|
case 'complete':
|
|
|
|
|
return modal.value.task?.status === 'completed' ? 'گزارش نتیجه' : 'ثبت انجام کار';
|
|
|
|
|
case 'skip':
|
|
|
|
|
return 'رد کردن کار';
|
|
|
|
|
case 'reschedule':
|
|
|
|
|
return 'تغییر زمان کار';
|
|
|
|
|
case 'cancel':
|
|
|
|
|
return 'لغو کار';
|
|
|
|
|
default:
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const noteRequired = computed(() => {
|
|
|
|
|
const t = modal.value.task;
|
|
|
|
|
if (!t) return false;
|
|
|
|
|
if (modal.value.kind === 'complete') return t.rules.reportRequired;
|
|
|
|
|
if (modal.value.kind === 'skip') return t.rules.skipReasonRequired;
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const noteLabel = computed(() => {
|
|
|
|
|
if (modal.value.kind === 'complete') return 'نتیجه / گزارش';
|
|
|
|
|
if (modal.value.kind === 'skip') return 'دلیل رد کردن';
|
|
|
|
|
return 'توضیح (اختیاری)';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const placeholder = computed(() => {
|
|
|
|
|
if (modal.value.kind === 'complete') return 'مثلاً: با مشتری تماس گرفته شد و قرار جلسه برای فردا تنظیم شد.';
|
|
|
|
|
if (modal.value.kind === 'skip') return 'چرا این کار امروز انجام نمیشود؟';
|
|
|
|
|
return '';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const submitLabel = computed(() => {
|
|
|
|
|
switch (modal.value.kind) {
|
|
|
|
|
case 'complete':
|
|
|
|
|
return modal.value.task?.status === 'completed' ? 'ذخیره گزارش' : 'انجام شد';
|
|
|
|
|
case 'skip':
|
|
|
|
|
return 'رد کردن';
|
|
|
|
|
case 'reschedule':
|
|
|
|
|
return 'ذخیره زمان جدید';
|
|
|
|
|
case 'cancel':
|
|
|
|
|
return 'لغو کار';
|
|
|
|
|
default:
|
|
|
|
|
return 'ذخیره';
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-10-18 19:39:59 +03:30
|
|
|
|
|
|
|
|
const okDanger = computed(() => modal.value.kind === 'cancel');
|
2026-10-06 19:54:38 +03:30
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-10-18 19:39:59 +03:30
|
|
|
<a-modal
|
|
|
|
|
:open="!!modal.kind"
|
|
|
|
|
:title="title"
|
|
|
|
|
:confirm-loading="modal.saving"
|
|
|
|
|
:ok-text="submitLabel"
|
|
|
|
|
:ok-button-props="{ danger: okDanger }"
|
|
|
|
|
cancel-text="انصراف"
|
|
|
|
|
destroy-on-close
|
|
|
|
|
@ok="actions.submit()"
|
|
|
|
|
@cancel="actions.close()"
|
|
|
|
|
>
|
|
|
|
|
<a-typography-text v-if="modal.task" strong>
|
|
|
|
|
{{ modal.task.title }}
|
|
|
|
|
</a-typography-text>
|
2026-10-06 19:54:38 +03:30
|
|
|
|
2026-10-18 19:39:59 +03:30
|
|
|
<a-row v-if="modal.kind === 'reschedule'" :gutter="[16, 0]" :style="{ marginTop: '12px' }">
|
|
|
|
|
<a-col :xs="24" :md="12">
|
|
|
|
|
<a-form-item label="تاریخ" required>
|
|
|
|
|
<JalaliDateInput v-model="modal.date" mode="date" required :clearable="false" />
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-col :xs="24" :md="12">
|
|
|
|
|
<a-form-item label="ساعت" extra="خالی = تا پایان روز">
|
|
|
|
|
<JalaliDateInput v-model="modal.time" mode="time" />
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
|
|
|
|
</a-row>
|
2026-10-06 19:54:38 +03:30
|
|
|
|
2026-10-18 19:39:59 +03:30
|
|
|
<a-form-item
|
|
|
|
|
v-else
|
|
|
|
|
:label="noteLabel"
|
|
|
|
|
:required="noteRequired"
|
|
|
|
|
:style="{ marginTop: '12px' }"
|
|
|
|
|
>
|
|
|
|
|
<a-textarea
|
|
|
|
|
v-model:value="modal.note"
|
|
|
|
|
:rows="4"
|
|
|
|
|
:placeholder="placeholder"
|
|
|
|
|
:maxlength="2000"
|
|
|
|
|
/>
|
|
|
|
|
</a-form-item>
|
2026-10-06 19:54:38 +03:30
|
|
|
|
2026-10-18 19:39:59 +03:30
|
|
|
<a-typography-text v-if="modal.kind === 'cancel'" type="secondary">
|
|
|
|
|
کار لغو شده در محاسبه درصد انجام حساب نمیشود.
|
|
|
|
|
</a-typography-text>
|
2026-10-06 19:54:38 +03:30
|
|
|
|
2026-10-18 19:39:59 +03:30
|
|
|
<a-alert
|
|
|
|
|
v-if="modal.error"
|
|
|
|
|
type="error"
|
|
|
|
|
show-icon
|
|
|
|
|
:message="modal.error"
|
|
|
|
|
:style="{ marginTop: '12px' }"
|
|
|
|
|
/>
|
|
|
|
|
</a-modal>
|
2026-10-06 19:54:38 +03:30
|
|
|
</template>
|