下载bug
This commit is contained in:
parent
4bf261df57
commit
b449ebeb8d
@ -361,20 +361,36 @@ const handleBind = (record) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleDown = async (record) => {
|
const handleDown = async (record) => {
|
||||||
await nextTick();
|
const{base64QrCode,batteryCode}=record;
|
||||||
const rowElement = document.querySelector(`[data-row-key="${record.batteryCode}"]`);
|
console.log(record)
|
||||||
var canvas = rowElement.querySelector('Canvas')
|
const link = document.createElement('a')
|
||||||
if (canvas) {
|
link.href = base64QrCode
|
||||||
const url = canvas.toDataURL();
|
link.download = batteryCode
|
||||||
const a = document.createElement('a');
|
|
||||||
a.download = `${record.batteryCode}.png`;
|
// 兼容旧版浏览器
|
||||||
a.href = url;
|
if (document.createEvent) {
|
||||||
document.body.appendChild(a);
|
const event = new MouseEvent('click')
|
||||||
a.click();
|
link.dispatchEvent(event)
|
||||||
document.body.removeChild(a);
|
} else {
|
||||||
} else {
|
link.click()
|
||||||
console.error('Row element not found');
|
}
|
||||||
}
|
|
||||||
|
// 清理临时元素
|
||||||
|
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) => {
|
const handleSelect = (record) => {
|
||||||
|
|||||||
@ -365,20 +365,36 @@ const handleBind = (record) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleDown = async (record) => {
|
const handleDown = async (record) => {
|
||||||
await nextTick();
|
const{base64QrCode,bikeCode}=record;
|
||||||
const rowElement = document.querySelector(`[data-row-key="${record.bikeCode}"]`);
|
const link = document.createElement('a')
|
||||||
var canvas = rowElement.querySelector('Canvas')
|
link.href = base64QrCode
|
||||||
if (canvas) {
|
link.download = bikeCode
|
||||||
const url = canvas.toDataURL();
|
|
||||||
const a = document.createElement('a');
|
// 兼容旧版浏览器
|
||||||
a.download = `${record.bikeCode}.png`;
|
if (document.createEvent) {
|
||||||
a.href = url;
|
const event = new MouseEvent('click')
|
||||||
document.body.appendChild(a);
|
link.dispatchEvent(event)
|
||||||
a.click();
|
} else {
|
||||||
document.body.removeChild(a);
|
link.click()
|
||||||
} else {
|
}
|
||||||
console.error('Row element not found');
|
|
||||||
}
|
// 清理临时元素
|
||||||
|
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) => {
|
const handleSelect = (record) => {
|
||||||
|
|||||||
@ -361,20 +361,36 @@ const handleBind = (record) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleDown = async (record) => {
|
const handleDown = async (record) => {
|
||||||
await nextTick();
|
const{base64QrCode,helmetCode}=record;
|
||||||
const rowElement = document.querySelector(`[data-row-key="${record.helmetCode}"]`);
|
console.log(record)
|
||||||
var canvas = rowElement.querySelector('Canvas')
|
const link = document.createElement('a')
|
||||||
if (canvas) {
|
link.href = base64QrCode
|
||||||
const url = canvas.toDataURL();
|
link.download = helmetCode
|
||||||
const a = document.createElement('a');
|
|
||||||
a.download = `${record.helmetCode}.png`;
|
// 兼容旧版浏览器
|
||||||
a.href = url;
|
if (document.createEvent) {
|
||||||
document.body.appendChild(a);
|
const event = new MouseEvent('click')
|
||||||
a.click();
|
link.dispatchEvent(event)
|
||||||
document.body.removeChild(a);
|
} else {
|
||||||
} else {
|
link.click()
|
||||||
console.error('Row element not found');
|
}
|
||||||
}
|
|
||||||
|
// 清理临时元素
|
||||||
|
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) => {
|
const handleSelect = (record) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user