/**
* Экспортирует данные в файл
* @param int $id
* @param string $type
* @param null|array $params
* @return null|BFile
*/
public function exportAction(int $id, string $type, ?array $params = []): ?BFile
{
try {
$file = \Bitrix\Main\Engine\Response\BFile::createByFileId(985);
} catch (\Throwable $th) {
$this->addError(new Error($th->getMessage(), $th->getCode()));
}
return $file;
}
|
BX.ajax.runComponentAction('company:sale.basket.detail', 'export', {
mode: 'ajax',
data: {id, type},
method: 'POST',
})
?.then(response => {
if (response.status === 'success' && response.data?.url) {
window.location.href = response.data.url;
}
})
.catch(response => {...}) |