发票申请
This commit is contained in:
1 parent
1dc2859a85
commit
3a9bf58f62
1 file changed
+32
-29
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="预览" width="800px" :close-on-click-modal="false" draggable destroy-on-close>
|
||||
<div id="receiptRef" ref="receiptRef" class="w-[17.5cm] h-[9.5cm] border border-gray-400 p-6 bg-[#EBE1C622]">
|
||||
<div v-loading="loading" id="receiptRef" ref="receiptRef" class="w-[17.5cm] h-[9.5cm] border border-gray-400 p-6 bg-[#EBE1C622]">
|
||||
<div class="text-center mx-auto w-[10cm] text-3xl font-bold">浦江县行政事业单位食堂统一收款收据</div>
|
||||
|
||||
<div class="flex justify-between items-end mb-1">
|
||||
@@ -61,7 +61,7 @@
|
||||
<td class="border border-gray-600 px-2 w-1/6 h-[0.75cm]">收款单位<br />(盖章)</td>
|
||||
<td class="border border-gray-600 px-2 text-left w-1/6 h-[0.75cm] text-sm text-blue-800">
|
||||
<!-- <input type="text" v-model="receiptData.payeeDept" class="w-full h-full bg-transparent" /> -->
|
||||
<img
|
||||
<!-- <img
|
||||
v-if="receiptData.picUrl || isStamping"
|
||||
class="w-[2.5cm] h-[2.5cm] absolute -top-2 left-[140px]"
|
||||
:class="{ stamping: isStamping }"
|
||||
@@ -69,7 +69,7 @@
|
||||
style="-webkit-user-drag: none; user-select: none; pointer-events: none"
|
||||
oncontextmenu="return false"
|
||||
src="/@/assets/receiptStamp.png"
|
||||
/>
|
||||
/> -->
|
||||
</td>
|
||||
<td class="border border-gray-600 px-2 w-1/6 h-[0.75cm]">开票人<br />(签名)</td>
|
||||
<td class="border border-gray-600 px-2 text-left w-1/6 h-[0.75cm] text-sm text-blue-800">
|
||||
@@ -95,18 +95,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-6">
|
||||
<el-progress
|
||||
:percentage="progressPercent"
|
||||
v-if="progressPercent > 30"
|
||||
:stroke-width="6"
|
||||
status="success"
|
||||
striped
|
||||
striped-flow
|
||||
:duration="20"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="handleClose" :disabled="loading">关闭</el-button>
|
||||
<el-button
|
||||
@@ -124,10 +112,11 @@
|
||||
type="primary"
|
||||
plain
|
||||
@click="backInvoice"
|
||||
:disabled="loadingBack"
|
||||
:disabled="loading"
|
||||
>
|
||||
作废
|
||||
</el-button>
|
||||
<el-button type="primary" :disabled="loading" @click="applyStamp">申请审批</el-button>
|
||||
<el-button v-auth="'wallet_walletRechargeApply_receiptSave'" type="primary" @click="saveReceipt" :disabled="loading">保存</el-button>
|
||||
<el-button v-if="receiptData.picUrl" type="primary" @click="handlePrint" :disabled="loading">打印</el-button>
|
||||
</template>
|
||||
@@ -142,7 +131,7 @@ import request from "/@/utils/request"
|
||||
import { formatDate } from "/@/utils/formatTime"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
import printJS from "print-js"
|
||||
import { bindInvoice, invoiceBack, getObj } from "/@/api/wallet/wallet-recharge-invoice"
|
||||
import { bindInvoice, invoiceBack, getObj, apply } from "/@/api/wallet/wallet-recharge-invoice"
|
||||
|
||||
const emit = defineEmits(["refresh"])
|
||||
|
||||
@@ -158,11 +147,11 @@ interface ReceiptData {
|
||||
remark: string
|
||||
totalPriceCnStr: string
|
||||
picUrl: string
|
||||
processStatus: string | null
|
||||
}
|
||||
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const loadingBack = ref(false)
|
||||
const receiptRef = ref<HTMLElement | null>(null)
|
||||
const deptOrUserInput = ref<HTMLInputElement | null>(null)
|
||||
let timer
|
||||
@@ -179,9 +168,9 @@ const receiptData = ref<ReceiptData>({
|
||||
payeeUser: "", // 开票人
|
||||
remark: "", // 备注
|
||||
picUrl: "", // 发票图片地址
|
||||
processStatus: "",
|
||||
})
|
||||
const applyId = ref<string>()
|
||||
const progressPercent = ref(30)
|
||||
const receiptDataItems = computed(() => {
|
||||
try {
|
||||
const itemJson = JSON.parse(receiptData.value.itemJson)
|
||||
@@ -216,7 +205,7 @@ const backInvoice = async () => {
|
||||
useMessage().error("请先盖章")
|
||||
return
|
||||
}
|
||||
loadingBack.value = true
|
||||
loading.value = true
|
||||
try {
|
||||
await invoiceBack({ id: receiptData.value.id })
|
||||
const res = await getObj(receiptData.value.id)
|
||||
@@ -227,7 +216,7 @@ const backInvoice = async () => {
|
||||
console.error(error)
|
||||
useMessage().error(error.msg)
|
||||
} finally {
|
||||
loadingBack.value = false
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +241,6 @@ const genImage = async (): Promise<Blob | void | null> => {
|
||||
// 图片上传
|
||||
const uploadImage = async (blob: Blob): Promise<string | void> => {
|
||||
try {
|
||||
loading.value = true
|
||||
const formData = new FormData()
|
||||
formData.append("file", blob, "receipt.png")
|
||||
const { code, data } = await request({
|
||||
@@ -262,19 +250,12 @@ const uploadImage = async (blob: Blob): Promise<string | void> => {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
data: formData,
|
||||
onUploadProgress: (progressEvent: any) => {
|
||||
if (progressEvent.lengthComputable) {
|
||||
progressPercent.value = Math.round((progressEvent.loaded * 100) / progressEvent.total)
|
||||
}
|
||||
},
|
||||
})
|
||||
if (code == 0) return data.url
|
||||
useMessage().error(data.msg || "上传失败")
|
||||
} catch (error) {
|
||||
useMessage().error(error as string)
|
||||
} finally {
|
||||
loading.value = false
|
||||
progressPercent.value = 30
|
||||
isStamping.value = false
|
||||
}
|
||||
}
|
||||
@@ -318,6 +299,28 @@ const saveReceipt = async (): Promise<void> => {
|
||||
}
|
||||
}
|
||||
|
||||
// 申请盖章审批
|
||||
const applyStamp = async () => {
|
||||
await useMessage().delConfirm("是否提交审批")
|
||||
if (receiptData.value.processStatus == "1") return useMessage().warning("你已提交申请,请勿重复提交")
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const blob = await genImage()
|
||||
if (!blob) return useMessage().success("图片生成失败")
|
||||
const picUrl = await uploadImage(blob)
|
||||
if (!picUrl) return useMessage().success("图片上传失败")
|
||||
|
||||
const { code } = await apply({ id: receiptData.value.id, picUrl })
|
||||
if (code == 0) return useMessage().success("申请成功")
|
||||
useMessage().error("申请失败")
|
||||
} catch (error) {
|
||||
useMessage().error(error as string)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 打印
|
||||
const handlePrint = async () => {
|
||||
if (receiptRef.value) {
|
||||
|
||||
Reference in new issue
Block a user