Merge branch 'samandar' into 'dev'
exel See merge request azizziy/cpost!13
This commit is contained in:
@@ -210,5 +210,6 @@
|
||||
"update_packet": "編輯套件",
|
||||
"party_weight": "大量重量",
|
||||
"qr_code": "二维码",
|
||||
"created_at": "添加日期"
|
||||
"created_at": "添加日期",
|
||||
"download_all_items_exel": "将所有产品上传至Excel"
|
||||
}
|
||||
@@ -209,7 +209,7 @@
|
||||
"weight_of_items": "Products weight",
|
||||
"update_packet": "Edit Paket",
|
||||
"party_weight": "Batch weight",
|
||||
|
||||
"download_all_items_exel": "Upload all products in Excel",
|
||||
"qr_code": "QR Code",
|
||||
"created_at": "Date of joining"
|
||||
}
|
||||
@@ -222,6 +222,7 @@
|
||||
"weight_of_items": "Вес продукта",
|
||||
"update_packet": "Редактировать пакет",
|
||||
"party_weight": "Вес партии",
|
||||
"download_all_items_exel": "Загрузить все товары в Excel",
|
||||
|
||||
"qr_code": "QR код",
|
||||
"created_at": "Дата добавления"
|
||||
|
||||
@@ -216,6 +216,7 @@
|
||||
"date_of_birth": "Tug'ilgan kuni",
|
||||
"are_you_sure_delete_client_id": "Rostdan ham {id} id lik klientni o'chirmoqchimisiz?",
|
||||
"download_all_items": "Barcha mahsulotlarni yuklab olish",
|
||||
"download_all_items_exel": "Barcha mahsulotlarni exelda yuklash",
|
||||
"download_all_clients": "Barcha mijozlarni yuklab olish",
|
||||
"are_you_sure_delete_party": "{name} yuk partiyasini o'chirishga ishonchingiz komilmi?",
|
||||
"passport": "Pasport",
|
||||
|
||||
@@ -35,4 +35,7 @@ export const party_requests = {
|
||||
async downloadPartyItemsExcel(params: { partyId: number | string }) {
|
||||
return request.get<Blob>('/parties/items/download', { params, responseType: 'blob' });
|
||||
},
|
||||
async downloadPartyItemsAllExcel(params: { partyId: number | string }) {
|
||||
return request.get<Blob>('/parties/download/box-order', { params, responseType: 'blob' });
|
||||
},
|
||||
};
|
||||
|
||||
@@ -40,6 +40,7 @@ const DashboardPartiesPage = (props: Props) => {
|
||||
const [deleteIds, setDeleteIds] = useState<number[]>([]);
|
||||
const [downloadIds, setDownloadIds] = useState<number[]>([]);
|
||||
const [downloadItemIds, setDownloadItemIds] = useState<number[]>([]);
|
||||
const [downloadItemIdsExel, setDownloadItemIdsExel] = useState<number[]>([]);
|
||||
const [changeStatusIds, setChangeStatusIds] = useState<number[]>([]);
|
||||
|
||||
const partyStatusOptions = useMemo(() => {
|
||||
@@ -145,6 +146,21 @@ const DashboardPartiesPage = (props: Props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const onDownloadPartyItemsExel = async (id: number, name: string) => {
|
||||
if (downloadItemIds.includes(id)) return;
|
||||
|
||||
try {
|
||||
setDownloadItemIdsExel(p => [...p, id]);
|
||||
const response = await party_requests.downloadPartyItemsAllExcel({ partyId: id });
|
||||
const file = new File([response.data], `${name}.xlsx`, { type: response.data.type });
|
||||
file_service.download(file);
|
||||
} catch (error) {
|
||||
notifyUnknownError(error);
|
||||
} finally {
|
||||
setDownloadItemIdsExel(prev => prev.filter(i => i !== id));
|
||||
}
|
||||
};
|
||||
|
||||
const onChangeStatus = async (id: number, newStatus: PartyStatus) => {
|
||||
if (changeStatusIds.includes(id)) return;
|
||||
|
||||
@@ -290,29 +306,38 @@ const DashboardPartiesPage = (props: Props) => {
|
||||
},
|
||||
...(isAdmin
|
||||
? [
|
||||
{
|
||||
icon: <Download sx={{ path: { color: '#3489E4' } }} />,
|
||||
label: t('download_all_items'),
|
||||
onClick: () => {
|
||||
onDownloadPartyItems(data.id);
|
||||
},
|
||||
dontCloseOnClick: true,
|
||||
loading: downloadItemIds.includes(data.id),
|
||||
},
|
||||
]
|
||||
{
|
||||
icon: <Download sx={{ path: { color: '#3489E4' } }} />,
|
||||
label: t('download_all_items'),
|
||||
onClick: () => {
|
||||
onDownloadPartyItems(data.id);
|
||||
},
|
||||
dontCloseOnClick: true,
|
||||
loading: downloadItemIds.includes(data.id),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
icon: <Download sx={{ path: { color: '#3489E4' } }} />,
|
||||
label: t('download_all_items_exel'),
|
||||
onClick: () => {
|
||||
onDownloadPartyItemsExel(data.id, data.name);
|
||||
},
|
||||
dontCloseOnClick: true,
|
||||
loading: downloadItemIdsExel.includes(data.id),
|
||||
},
|
||||
...(Boolean(data.partyStatus === 'ON_THE_WAY' || data.partyStatus === 'ARRIVED')
|
||||
? [
|
||||
{
|
||||
icon: <Download sx={{ path: { color: '#3489E4' } }} />,
|
||||
label: t('download_excel'),
|
||||
onClick: () => {
|
||||
onDownloadExcel(data.id);
|
||||
},
|
||||
loading: downloadIds.includes(data.id),
|
||||
dontCloseOnClick: true,
|
||||
},
|
||||
]
|
||||
{
|
||||
icon: <Download sx={{ path: { color: '#3489E4' } }} />,
|
||||
label: t('download_excel'),
|
||||
onClick: () => {
|
||||
onDownloadExcel(data.id);
|
||||
},
|
||||
loading: downloadIds.includes(data.id),
|
||||
dontCloseOnClick: true,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
]}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user