import { parseTime } from '@/utils' import { downloadRequest } from '@/utils/request' import { send, addTenant } from '@/api/base' function download ({ data, headers }, fileName) { const blob = new Blob([data], { type: headers['content-type'] }) const url = window.URL.createObjectURL(blob) const dom = document.createElement('a') dom.href = url dom.download = decodeURI(fileName) dom.style.display = 'none' document.body.appendChild(dom) dom.click() dom.parentNode.removeChild(dom) window.URL.revokeObjectURL(url) } export function getDeviceExcel () { return send({ url: '/device/tenant/export/excel', method: 'GET', params: addTenant() }, downloadRequest).then(response => { download(response, `设备报表${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}.xlsx`) }) } export function getMaterialExcel (params, fileName = '') { return send({ url: '/minio-data/export', method: 'GET', params: addTenant(params) }, downloadRequest).then(response => { download(response, `资源报表${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}_${fileName}.xlsx`) }) } export function getContentExcel (params, fileName = '') { return send({ url: '/minio-data/usage/degree/export', method: 'GET', params: addTenant(params) }, downloadRequest).then(response => { download(response, `内容播放${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}_${fileName}.xlsx`) }) } export function getAccountExcel (params, fileName = '') { return send({ url: '/admin/department/user/export', method: 'GET', params: addTenant(params) }, downloadRequest).then(response => { download(response, `账号报表${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}_${fileName}.xlsx`) }) } export function getAuditExcel (params, fileName = '') { return send({ url: '/orchestration/calendarReleaseHis/export', method: 'GET', params }, downloadRequest).then(response => { download(response, `三审报表${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}_${fileName}.xls`) }) } export function getProgramGuideExcel (params, fileName = '') { return send({ url: '/ad/tenant/scheduling/export', method: 'GET', params }, downloadRequest).then(response => { download(response, `节目单${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}_${fileName}.xlsx`) }) } export function getDeviceAdExcel ({ deviceId, date }, fileName = '') { return send({ url: `/minio-data/device/${deviceId}/usage/statistic/export`, method: 'GET', params: { date } }, downloadRequest).then(response => { download(response, `广告播放${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}_${fileName}.xlsx`) }) } export function getOnlineDurationExcel () { return send({ url: '/excel/export?type=DEVICE_ONLINE_TOTAL', method: 'POST', data: addTenant() }, downloadRequest).then(response => { download(response, `在线时长${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}.xlsx`) }) } export function getRangeOnlineDurationExcel (data, fileName = '') { return send({ url: '/excel/export?type=DEVICE_ONLINE_RANGEDAY', method: 'POST', data: addTenant(data) }, downloadRequest).then(response => { download(response, `在线时长${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}_${fileName}.xlsx`) }) } export function getDepartmentOnlineDurationExcel (department, fileName = '') { return send({ url: '/excel/export?type=DEVICE_ONLINE_TOTAL', method: 'POST', data: { department } }, downloadRequest).then(response => { download(response, `在线时长${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}_${fileName}.xlsx`) }) } export function getDepartmentRangeOnlineDurationExcel (data, fileName = '') { return send({ url: '/excel/export?type=DEVICE_ONLINE_RANGEDAY', method: 'POST', data }, downloadRequest).then(response => { download(response, `在线时长${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}_${fileName}.xlsx`) }) }