Files
lingji-work-fe/src/utils/arcoD.tsx

69 lines
2.1 KiB
TypeScript
Raw Normal View History

2025-07-17 17:23:40 +08:00
import { Notification } from '@arco-design/web-vue';
import { downloadByUrl } from '@/utils/tools';
2025-07-17 17:23:40 +08:00
import { IconLoading } from '@arco-design/web-vue/es/icon';
2025-07-21 10:27:08 +08:00
import icon1 from '@/assets/img/media-account/icon-warn-1.png';
import icon2 from '@/assets/img/media-account/icon-success.png';
interface RenderNotificationData {
total_number: number;
success_number: number;
fail_number: number;
file?: string;
}
2025-07-21 15:10:26 +08:00
export function showExportNotification(label: string, { id = '', duration = 3000}) {
2025-07-17 17:23:40 +08:00
Notification.warning({
id,
2025-07-17 17:23:40 +08:00
showIcon: false,
closable: true,
content: () => (
<div class="flex items-center">
<IconLoading size={16} class="color-#6D4CFE mr-8px" />
<p class="text-14px lh-22px font-400 color-#211F24">{label}</p>
2025-07-17 17:23:40 +08:00
</div>
),
2025-07-21 15:10:26 +08:00
duration,
2025-07-17 17:23:40 +08:00
class: 'px-16px py-9px w-400px rounded-2px bg-#F0EDFF',
});
}
export const showImportResultNotification = (data: RenderNotificationData) => {
const { total_number, success_number, fail_number, file } = data;
const hasError = fail_number > 0;
const handleDownloadError = (file?: string) => {
file && downloadByUrl(file);
};
Notification.warning({
showIcon: false,
closable: true,
content: () => (
<div>
<div class="flex items-center mb-4px">
<img src={hasError ? icon1 : icon2} width="16" height="16" class="mr-8px" />
<span class="text-16px lh-24px font-400 color-#211F24"></span>
</div>
<p class="text-14px lh-22px font-400 color-#211F24">
{total_number} {success_number}
{hasError && (
<span>
<span class="color-#F64B31">{fail_number}</span>
</span>
)}
</p>
{hasError && (
<div
class="mt-8px text-14px lh-22px font-400 color-#6D4CFE cursor-pointer"
onClick={() => handleDownloadError(file)}
>
</div>
)}
</div>
),
duration: 3000,
class: `px-16px py-16px w-400px rounded-2px ${hasError ? 'bg-#FFF7E5' : 'bg-#EBF7F2'}`,
});
};