This commit is contained in:
@@ -85,6 +85,7 @@
|
||||
<n-button v-perms="['/admin/qrcode/edit']" mr-10 type="warning" @click="openModal(2)">
|
||||
修改二维码
|
||||
</n-button>
|
||||
<n-button mr-10 type="info" @click="saveCode">下载二维码</n-button>
|
||||
<!-- <n-button mr-10 type="primary" @click="openModal(1)">新增二维码</n-button> -->
|
||||
<!-- <n-button mr-10 type="warning" @click="openModal(3)">修改二维码</n-button> -->
|
||||
<n-button type="primary" @click="getList">搜索</n-button>
|
||||
@@ -147,6 +148,8 @@
|
||||
|
||||
<script setup>
|
||||
import { NButton } from 'naive-ui'
|
||||
import JSZip from 'jszip'
|
||||
import { saveAs } from 'file-saver'
|
||||
import api from '../api'
|
||||
import { ref, resolveDirective, withDirectives } from 'vue'
|
||||
|
||||
@@ -464,6 +467,27 @@ const handleValidateClick = (e) => {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 下载二维码
|
||||
const saveCode = async () => {
|
||||
if (checkedRowKeysRef.value.length === 0) return $message.error('请选择二维码')
|
||||
|
||||
const zip = new JSZip()
|
||||
|
||||
data.value.forEach((item) => {
|
||||
checkedRowKeysRef.value.forEach((id) => {
|
||||
if (item.qid === id) {
|
||||
const imageData = item.url.split(',')[1]
|
||||
zip.file(`${item.qid}.png`, imageData, {
|
||||
base64: true,
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const content = await zip.generateAsync({ type: 'blob' })
|
||||
saveAs(content, '二维码.zip')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
||||
Reference in New Issue
Block a user