feat:盖章修改
This commit is contained in:
1 parent
8a528cb85c
commit
9b106590a0
2 files changed
+61
-39
No files matched your search
@@ -2,26 +2,14 @@
|
|||||||
<div class="layout-padding">
|
<div class="layout-padding">
|
||||||
<div class="layout-padding-auto layout-padding-view">
|
<div class="layout-padding-auto layout-padding-view">
|
||||||
<div
|
<div
|
||||||
class="p-4 min-w-[375px] md:min-w-[700px] xl:min-w-[800px] mt-3 grid grid-cols-1 gap-5 md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-3 3xl:grid-cols-6"
|
class="p-4 min-w-[375px] md:min-w-[700px] xl:min-w-[800px] mt-3 grid grid-cols-1 gap-5 md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-3 3xl:grid-cols-6">
|
||||||
>
|
<div v-for="(item, index) in 6" :key="index"
|
||||||
<div
|
class="relative flex flex-grow !flex-row flex-col items-center rounded-[10px] border-[1px] border-gray-200 bg-white hover:scale-105 hover:shadow-lg bg-clip-border shadow-md shadow-[#F3F3F3] dark:border-[#ffffff33] dark:!bg-[#1d1d1d] dark:text-white dark:shadow-none">
|
||||||
v-for="(item, index) in 6"
|
|
||||||
:key="index"
|
|
||||||
class="relative flex flex-grow !flex-row flex-col items-center rounded-[10px] border-[1px] border-gray-200 bg-white hover:scale-105 hover:shadow-lg bg-clip-border shadow-md shadow-[#F3F3F3] dark:border-[#ffffff33] dark:!bg-[#1d1d1d] dark:text-white dark:shadow-none"
|
|
||||||
>
|
|
||||||
<div class="ml-[18px] flex h-[90px] w-auto flex-row items-center">
|
<div class="ml-[18px] flex h-[90px] w-auto flex-row items-center">
|
||||||
<div class="p-3 rounded-full bg-lightPrimary dark:bg-navy-700">
|
<div class="p-3 rounded-full bg-lightPrimary dark:bg-navy-700">
|
||||||
<span class="flex items-center text-brand-500 dark:text-white">
|
<span class="flex items-center text-brand-500 dark:text-white">
|
||||||
<svg
|
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24"
|
||||||
stroke="currentColor"
|
class="h-7 w-7" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">
|
||||||
fill="currentColor"
|
|
||||||
stroke-width="0"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
class="h-7 w-7"
|
|
||||||
height="1em"
|
|
||||||
width="1em"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<path fill="none" d="M0 0h24v24H0z"></path>
|
<path fill="none" d="M0 0h24v24H0z"></path>
|
||||||
<path d="M4 9h4v11H4zM16 13h4v7h-4zM10 4h4v16h-4z"></path>
|
<path d="M4 9h4v11H4zM16 13h4v7h-4zM10 4h4v16h-4z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ import { formatDate } from "/@/utils/formatTime"
|
|||||||
import { displayPrice } from "/@/utils/formatMoney"
|
import { displayPrice } from "/@/utils/formatMoney"
|
||||||
import printJS from "print-js"
|
import printJS from "print-js"
|
||||||
import * as WalletRechargeInvoiceApi from "/@/api/wallet/wallet-recharge-invoice"
|
import * as WalletRechargeInvoiceApi from "/@/api/wallet/wallet-recharge-invoice"
|
||||||
import { useDict } from "/@/hooks/dict"
|
|
||||||
|
|
||||||
interface ReceiptData {
|
interface ReceiptData {
|
||||||
id: string
|
id: string
|
||||||
@@ -138,8 +137,7 @@ interface ReceiptData {
|
|||||||
|
|
||||||
const emit = defineEmits(["refresh"])
|
const emit = defineEmits(["refresh"])
|
||||||
|
|
||||||
const { check_status } = useDict("check_status")
|
let timer: ReturnType<typeof setTimeout> | null = null
|
||||||
let timer
|
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const refreshLoading = ref(false)
|
const refreshLoading = ref(false)
|
||||||
@@ -178,6 +176,7 @@ const openDialog = (data: ReceiptData, id: string) => {
|
|||||||
visible.value = true
|
visible.value = true
|
||||||
receiptData.value = data
|
receiptData.value = data
|
||||||
receiptData.value.id = id
|
receiptData.value.id = id
|
||||||
|
if (timer) clearTimeout(timer)
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
deptOrUserInput.value?.focus()
|
deptOrUserInput.value?.focus()
|
||||||
}, 50)
|
}, 50)
|
||||||
@@ -185,6 +184,7 @@ const openDialog = (data: ReceiptData, id: string) => {
|
|||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
visible.value = false
|
visible.value = false
|
||||||
|
if (timer) clearTimeout(timer)
|
||||||
timer = null
|
timer = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,23 +241,54 @@ const backInvoice = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 生成图片
|
// 生成图片
|
||||||
const genImage = async (): Promise<Blob | void | null> => {
|
const waitForFrames = async (count: number) => {
|
||||||
if (receiptRef.value) {
|
for (let i = 0; i < count; i += 1) {
|
||||||
const blob = await htmlToImage
|
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))
|
||||||
.toBlob(receiptRef.value, {
|
|
||||||
canvasWidth: 661.5,
|
|
||||||
canvasHeight: 359.1,
|
|
||||||
backgroundColor: "#ffffff",
|
|
||||||
pixelRatio: 6,
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error(error)
|
|
||||||
return useMessage().error("图片生成错误")
|
|
||||||
})
|
|
||||||
return blob
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const withReceiptCaptureStyle = async <T,>(fn: () => Promise<T>) => {
|
||||||
|
const el = receiptRef.value
|
||||||
|
if (!el) return fn()
|
||||||
|
|
||||||
|
const prevBackgroundColor = el.style.backgroundColor
|
||||||
|
const prevTransition = el.style.transition
|
||||||
|
const prevOpacity = el.style.opacity
|
||||||
|
|
||||||
|
el.style.backgroundColor = "#ffffff"
|
||||||
|
el.style.transition = "none"
|
||||||
|
el.style.opacity = "1"
|
||||||
|
|
||||||
|
await waitForFrames(2)
|
||||||
|
|
||||||
|
try {
|
||||||
|
return await fn()
|
||||||
|
} finally {
|
||||||
|
el.style.backgroundColor = prevBackgroundColor
|
||||||
|
el.style.transition = prevTransition
|
||||||
|
el.style.opacity = prevOpacity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const genImage = async (): Promise<Blob | void | null> => {
|
||||||
|
if (!receiptRef.value) return
|
||||||
|
|
||||||
|
const blob = await withReceiptCaptureStyle(async () => {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 120))
|
||||||
|
return await htmlToImage.toBlob(receiptRef.value!, {
|
||||||
|
canvasWidth: 661.5,
|
||||||
|
canvasHeight: 359.1,
|
||||||
|
backgroundColor: "transparent",
|
||||||
|
pixelRatio: 3,
|
||||||
|
})
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error)
|
||||||
|
return useMessage().error("图片生成错误")
|
||||||
|
})
|
||||||
|
|
||||||
|
return blob
|
||||||
|
}
|
||||||
|
|
||||||
// 图片上传
|
// 图片上传
|
||||||
const uploadImage = async (blob: Blob): Promise<string | void> => {
|
const uploadImage = async (blob: Blob): Promise<string | void> => {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
@@ -337,11 +368,14 @@ const applyStamp = async () => {
|
|||||||
// 打印
|
// 打印
|
||||||
const handlePrint = async () => {
|
const handlePrint = async () => {
|
||||||
if (receiptRef.value) {
|
if (receiptRef.value) {
|
||||||
const pngBase64 = await htmlToImage.toPng(receiptRef.value, {
|
const pngBase64 = await withReceiptCaptureStyle(async () => {
|
||||||
canvasWidth: 661.5,
|
await new Promise((resolve) => setTimeout(resolve, 120))
|
||||||
canvasHeight: 359.1,
|
return await htmlToImage.toPng(receiptRef.value!, {
|
||||||
pixelRatio: 10,
|
canvasWidth: 661.5,
|
||||||
backgroundColor: "#ffffff",
|
canvasHeight: 359.1,
|
||||||
|
pixelRatio: 4,
|
||||||
|
backgroundColor: "transparent",
|
||||||
|
})
|
||||||
})
|
})
|
||||||
printJS({ printable: pngBase64, type: "image", targetStyles: ["*"], maxWidth: 661.5 })
|
printJS({ printable: pngBase64, type: "image", targetStyles: ["*"], maxWidth: 661.5 })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user