下载bug

This commit is contained in:
小小 2025-06-06 10:10:54 +08:00
parent 4bf261df57
commit b449ebeb8d
3 changed files with 90 additions and 42 deletions

View File

@ -361,20 +361,36 @@ const handleBind = (record) => {
}
const handleDown = async (record) => {
await nextTick();
const rowElement = document.querySelector(`[data-row-key="${record.batteryCode}"]`);
var canvas = rowElement.querySelector('Canvas')
if (canvas) {
const url = canvas.toDataURL();
const a = document.createElement('a');
a.download = `${record.batteryCode}.png`;
a.href = url;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
} else {
console.error('Row element not found');
}
const{base64QrCode,batteryCode}=record;
console.log(record)
const link = document.createElement('a')
link.href = base64QrCode
link.download = batteryCode
//
if (document.createEvent) {
const event = new MouseEvent('click')
link.dispatchEvent(event)
} else {
link.click()
}
//
document.body.removeChild(link)
// await nextTick();
// const rowElement = document.querySelector(`[data-row-key="${record.batteryCode}"]`);
// var canvas = rowElement.querySelector('Canvas')
// if (canvas) {
// const url = canvas.toDataURL();
// const a = document.createElement('a');
// a.download = `${record.batteryCode}.png`;
// a.href = url;
// document.body.appendChild(a);
// a.click();
// document.body.removeChild(a);
// } else {
// console.error('Row element not found');
// }
}
const handleSelect = (record) => {

View File

@ -365,20 +365,36 @@ const handleBind = (record) => {
}
const handleDown = async (record) => {
await nextTick();
const rowElement = document.querySelector(`[data-row-key="${record.bikeCode}"]`);
var canvas = rowElement.querySelector('Canvas')
if (canvas) {
const url = canvas.toDataURL();
const a = document.createElement('a');
a.download = `${record.bikeCode}.png`;
a.href = url;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
} else {
console.error('Row element not found');
}
const{base64QrCode,bikeCode}=record;
const link = document.createElement('a')
link.href = base64QrCode
link.download = bikeCode
//
if (document.createEvent) {
const event = new MouseEvent('click')
link.dispatchEvent(event)
} else {
link.click()
}
//
document.body.removeChild(link)
// await nextTick();
// console.log("66666666666666666666666",record)
// const rowElement = document.querySelector(`[data-row-key="${record.bikeCode}"]`);
// var canvas = rowElement.querySelector('Canvas')
// if (canvas) {
// const url = canvas.toDataURL();
// const a = document.createElement('a');
// a.download = `${record.bikeCode}.png`;
// a.href = url;
// document.body.appendChild(a);
// a.click();
// document.body.removeChild(a);
// } else {
// console.error('Row element not found');
// }
}
const handleSelect = (record) => {

View File

@ -361,20 +361,36 @@ const handleBind = (record) => {
}
const handleDown = async (record) => {
await nextTick();
const rowElement = document.querySelector(`[data-row-key="${record.helmetCode}"]`);
var canvas = rowElement.querySelector('Canvas')
if (canvas) {
const url = canvas.toDataURL();
const a = document.createElement('a');
a.download = `${record.helmetCode}.png`;
a.href = url;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
} else {
console.error('Row element not found');
}
const{base64QrCode,helmetCode}=record;
console.log(record)
const link = document.createElement('a')
link.href = base64QrCode
link.download = helmetCode
//
if (document.createEvent) {
const event = new MouseEvent('click')
link.dispatchEvent(event)
} else {
link.click()
}
//
document.body.removeChild(link)
// await nextTick();
// const rowElement = document.querySelector(`[data-row-key="${record.helmetCode}"]`);
// var canvas = rowElement.querySelector('Canvas')
// if (canvas) {
// const url = canvas.toDataURL();
// const a = document.createElement('a');
// a.download = `${record.helmetCode}.png`;
// a.href = url;
// document.body.appendChild(a);
// a.click();
// document.body.removeChild(a);
// } else {
// console.error('Row element not found');
// }
}
const handleSelect = (record) => {