feat(custom): update
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-07-17 18:29:26 +08:00
parent c233ad8f5a
commit ca4ec000f6
5 changed files with 2253 additions and 1295 deletions

View File

@@ -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>