update two-step ui
This commit is contained in:
parent
484c7a0a64
commit
15d2f40e5d
|
@ -124,7 +124,7 @@ export function getApprovalStatusText(document) {
|
||||||
if (document.approved === false) {
|
if (document.approved === false) {
|
||||||
return 'رد شده';
|
return 'رد شده';
|
||||||
}
|
}
|
||||||
return 'نامشخص';
|
return 'تایید شده';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,5 +142,5 @@ export function getApprovalStatusColor(document) {
|
||||||
if (document.approved === false) {
|
if (document.approved === false) {
|
||||||
return 'error';
|
return 'error';
|
||||||
}
|
}
|
||||||
return 'grey';
|
return 'success';
|
||||||
}
|
}
|
||||||
|
|
|
@ -619,7 +619,7 @@ export default defineComponent({
|
||||||
|
|
||||||
if (item.isPreview) return 'در انتظار تایید';
|
if (item.isPreview) return 'در انتظار تایید';
|
||||||
if (item.isApproved) return 'تایید شده';
|
if (item.isApproved) return 'تایید شده';
|
||||||
return 'نامشخص';
|
return 'تایید شده';
|
||||||
},
|
},
|
||||||
// نمایش رنگ وضعیت تأیید
|
// نمایش رنگ وضعیت تأیید
|
||||||
getApprovalStatusColor(item) {
|
getApprovalStatusColor(item) {
|
||||||
|
@ -627,7 +627,7 @@ export default defineComponent({
|
||||||
|
|
||||||
if (item.isPreview) return 'warning';
|
if (item.isPreview) return 'warning';
|
||||||
if (item.isApproved) return 'success';
|
if (item.isApproved) return 'success';
|
||||||
return 'default';
|
return 'success';
|
||||||
},
|
},
|
||||||
// بررسی اینکه آیا دکمه تأیید باید نمایش داده شود
|
// بررسی اینکه آیا دکمه تأیید باید نمایش داده شود
|
||||||
canShowApprovalButton(item) {
|
canShowApprovalButton(item) {
|
||||||
|
|
|
@ -364,7 +364,6 @@ interface Header {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refs
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const inputItems = ref<Ticket[]>([]);
|
const inputItems = ref<Ticket[]>([]);
|
||||||
const outputItems = ref<Ticket[]>([]);
|
const outputItems = ref<Ticket[]>([]);
|
||||||
|
@ -386,7 +385,6 @@ const business = ref({
|
||||||
});
|
});
|
||||||
const currentUser = ref({ email: '', owner: false });
|
const currentUser = ref({ email: '', owner: false });
|
||||||
|
|
||||||
// دیالوگها
|
|
||||||
const deleteDialog = ref({
|
const deleteDialog = ref({
|
||||||
show: false,
|
show: false,
|
||||||
type: null as 'input' | 'output' | 'transfer' | 'waste' | null,
|
type: null as 'input' | 'output' | 'transfer' | 'waste' | null,
|
||||||
|
@ -399,7 +397,6 @@ const snackbar = ref({
|
||||||
color: 'primary'
|
color: 'primary'
|
||||||
});
|
});
|
||||||
|
|
||||||
// تعریف همه ستونها
|
|
||||||
const allHeaders = ref<Header[]>([
|
const allHeaders = ref<Header[]>([
|
||||||
{ title: "عملیات", key: "operation", align: 'center' as const, sortable: false, width: 100, visible: true },
|
{ title: "عملیات", key: "operation", align: 'center' as const, sortable: false, width: 100, visible: true },
|
||||||
{ title: "شماره", key: "code", align: 'center' as const, sortable: true, width: 100, visible: true },
|
{ title: "شماره", key: "code", align: 'center' as const, sortable: true, width: 100, visible: true },
|
||||||
|
@ -411,10 +408,8 @@ const allHeaders = ref<Header[]>([
|
||||||
{ title: "توضیحات", key: "des", align: 'center' as const, sortable: true, width: 200, visible: true },
|
{ title: "توضیحات", key: "des", align: 'center' as const, sortable: true, width: 200, visible: true },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// ستونهای قابل نمایش
|
|
||||||
const visibleHeaders = computed(() => {
|
const visibleHeaders = computed(() => {
|
||||||
return allHeaders.value.filter((header: Header) => {
|
return allHeaders.value.filter((header: Header) => {
|
||||||
// اگر ستونهای تأیید هستند، باید دو مرحلهای فعال باشد
|
|
||||||
if ((header.key === 'approvalStatus' || header.key === 'approvedBy') && !business.value.requireTwoStepApproval) {
|
if ((header.key === 'approvalStatus' || header.key === 'approvedBy') && !business.value.requireTwoStepApproval) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -422,12 +417,10 @@ const visibleHeaders = computed(() => {
|
||||||
}) as any;
|
}) as any;
|
||||||
});
|
});
|
||||||
|
|
||||||
// بررسی نمایش ستون
|
|
||||||
const isColumnVisible = (key: string) => {
|
const isColumnVisible = (key: string) => {
|
||||||
const header = allHeaders.value.find((header: Header) => header.key === key);
|
const header = allHeaders.value.find((header: Header) => header.key === key);
|
||||||
if (!header) return false;
|
if (!header) return false;
|
||||||
|
|
||||||
// اگر ستونهای تأیید هستند، باید دو مرحلهای فعال باشد
|
|
||||||
if ((key === 'approvalStatus' || key === 'approvedBy') && !business.value.requireTwoStepApproval) {
|
if ((key === 'approvalStatus' || key === 'approvedBy') && !business.value.requireTwoStepApproval) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -435,10 +428,8 @@ const isColumnVisible = (key: string) => {
|
||||||
return header.visible;
|
return header.visible;
|
||||||
};
|
};
|
||||||
|
|
||||||
// کلید ذخیرهسازی در localStorage
|
|
||||||
const LOCAL_STORAGE_KEY = 'hesabix_storeroom_tickets_table_columns';
|
const LOCAL_STORAGE_KEY = 'hesabix_storeroom_tickets_table_columns';
|
||||||
|
|
||||||
// لود تنظیمات ستونها
|
|
||||||
const loadColumnSettings = () => {
|
const loadColumnSettings = () => {
|
||||||
const savedSettings = localStorage.getItem(LOCAL_STORAGE_KEY);
|
const savedSettings = localStorage.getItem(LOCAL_STORAGE_KEY);
|
||||||
if (savedSettings) {
|
if (savedSettings) {
|
||||||
|
@ -449,7 +440,6 @@ const loadColumnSettings = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ذخیره تنظیمات ستونها
|
|
||||||
const updateColumnVisibility = () => {
|
const updateColumnVisibility = () => {
|
||||||
const visibleColumns = allHeaders.value
|
const visibleColumns = allHeaders.value
|
||||||
.filter(header => header.visible)
|
.filter(header => header.visible)
|
||||||
|
@ -457,13 +447,11 @@ const updateColumnVisibility = () => {
|
||||||
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(visibleColumns));
|
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(visibleColumns));
|
||||||
};
|
};
|
||||||
|
|
||||||
// تابع فرمتکننده اعداد
|
|
||||||
const formatNumber = (value: string | number) => {
|
const formatNumber = (value: string | number) => {
|
||||||
if (!value) return '0';
|
if (!value) return '0';
|
||||||
return Number(value).toLocaleString('fa-IR');
|
return Number(value).toLocaleString('fa-IR');
|
||||||
};
|
};
|
||||||
|
|
||||||
// فهرستهای نمایشی بر اساس ساب-تب و دو مرحلهای
|
|
||||||
const displayInputItems = computed(() => {
|
const displayInputItems = computed(() => {
|
||||||
if (!business.value.requireTwoStepApproval) return inputItems.value;
|
if (!business.value.requireTwoStepApproval) return inputItems.value;
|
||||||
return inputSubTab.value === 'pending'
|
return inputSubTab.value === 'pending'
|
||||||
|
@ -492,7 +480,6 @@ const displayWasteItems = computed(() => {
|
||||||
: wasteItems.value.filter(i => i.approved);
|
: wasteItems.value.filter(i => i.approved);
|
||||||
});
|
});
|
||||||
|
|
||||||
// بارگذاری اطلاعات بیزنس
|
|
||||||
const loadBusinessInfo = async () => {
|
const loadBusinessInfo = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('/api/business/get/info/' + localStorage.getItem('activeBid'));
|
const response = await axios.get('/api/business/get/info/' + localStorage.getItem('activeBid'));
|
||||||
|
@ -503,7 +490,6 @@ const loadBusinessInfo = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// بارگذاری اطلاعات کاربر فعلی
|
|
||||||
const loadCurrentUser = async () => {
|
const loadCurrentUser = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('/api/business/get/user/permissions');
|
const response = await axios.post('/api/business/get/user/permissions');
|
||||||
|
@ -514,7 +500,6 @@ const loadCurrentUser = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// بارگذاری دادهها
|
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
|
@ -540,25 +525,19 @@ const loadData = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// بررسی اینکه آیا دکمه تأیید باید نمایش داده شود
|
|
||||||
const canShowApprovalButton = (item: Ticket) => {
|
const canShowApprovalButton = (item: Ticket) => {
|
||||||
if (!business.value.requireTwoStepApproval) return false;
|
if (!business.value.requireTwoStepApproval) return false;
|
||||||
|
|
||||||
// اگر سند قبلاً تأیید شده، دکمه تأیید نمایش داده نشود
|
|
||||||
if (item?.approved) return false;
|
if (item?.approved) return false;
|
||||||
|
|
||||||
// مدیر کسب و کار همیشه میتواند تأیید کند
|
|
||||||
// یا کاربر تأییدکننده انبار
|
|
||||||
return business.value.warehouseApprover === currentUser.value.email || currentUser.value.owner === true;
|
return business.value.warehouseApprover === currentUser.value.email || currentUser.value.owner === true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// تایید حواله
|
|
||||||
const approveTicket = async (code: string) => {
|
const approveTicket = async (code: string) => {
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
await axios.post(`/api/approval/approve/storeroom/${code}`);
|
await axios.post(`/api/approval/approve/storeroom/${code}`);
|
||||||
|
|
||||||
// بهروزرسانی دادهها
|
|
||||||
await loadData();
|
await loadData();
|
||||||
|
|
||||||
snackbar.value = { show: true, message: 'حواله تایید شد', color: 'success' };
|
snackbar.value = { show: true, message: 'حواله تایید شد', color: 'success' };
|
||||||
|
@ -569,25 +548,22 @@ const approveTicket = async (code: string) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// نمایش متن وضعیت تأیید
|
|
||||||
const getApprovalStatusText = (item: Ticket) => {
|
const getApprovalStatusText = (item: Ticket) => {
|
||||||
if (!business.value.requireTwoStepApproval) return 'تایید دو مرحلهای غیرفعال';
|
if (!business.value.requireTwoStepApproval) return 'تایید دو مرحلهای غیرفعال';
|
||||||
|
|
||||||
if (item?.preview) return 'در انتظار تایید';
|
if (item?.preview) return 'در انتظار تایید';
|
||||||
if (item?.approved) return 'تایید شده';
|
if (item?.approved) return 'تایید شده';
|
||||||
return 'نامشخص';
|
return 'تایید شده';
|
||||||
};
|
};
|
||||||
|
|
||||||
// نمایش رنگ وضعیت تأیید
|
|
||||||
const getApprovalStatusColor = (item: Ticket) => {
|
const getApprovalStatusColor = (item: Ticket) => {
|
||||||
if (!business.value.requireTwoStepApproval) return 'default';
|
if (!business.value.requireTwoStepApproval) return 'default';
|
||||||
|
|
||||||
if (item?.preview) return 'warning';
|
if (item?.preview) return 'warning';
|
||||||
if (item?.approved) return 'success';
|
if (item?.approved) return 'success';
|
||||||
return 'default';
|
return 'success';
|
||||||
};
|
};
|
||||||
|
|
||||||
// حذف حواله
|
|
||||||
const deleteTicket = (type: 'input' | 'output' | 'transfer' | 'waste', code: string) => {
|
const deleteTicket = (type: 'input' | 'output' | 'transfer' | 'waste', code: string) => {
|
||||||
deleteDialog.value = {
|
deleteDialog.value = {
|
||||||
show: true,
|
show: true,
|
||||||
|
@ -596,7 +572,6 @@ const deleteTicket = (type: 'input' | 'output' | 'transfer' | 'waste', code: str
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// تأیید حذف
|
|
||||||
const confirmDelete = async () => {
|
const confirmDelete = async () => {
|
||||||
if (!deleteDialog.value?.type || !deleteDialog.value?.code) return;
|
if (!deleteDialog.value?.type || !deleteDialog.value?.code) return;
|
||||||
|
|
||||||
|
@ -639,7 +614,6 @@ const confirmDelete = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// مانت کامپوننت
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadColumnSettings();
|
loadColumnSettings();
|
||||||
loadBusinessInfo();
|
loadBusinessInfo();
|
||||||
|
@ -655,7 +629,6 @@ onMounted(() => {
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* استایل برای وسطچین کردن همه سلولهای جدول */
|
|
||||||
:deep(.v-data-table-header th) {
|
:deep(.v-data-table-header th) {
|
||||||
text-align: center !important;
|
text-align: center !important;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue