+
+
+
浦江县行政事业单位食堂统一收款收据
@@ -24,6 +26,7 @@
v-model="receiptData.deptOrUser"
class="caret-red-600 w-full h-full bg-transparent text-center"
ref="deptOrUserInput"
+ maxlength="30"
/>
@@ -61,15 +64,14 @@
收款单位 (盖章) |
-
+ /> -->
|
开票人 (签名) |
@@ -81,7 +83,8 @@
备注:
|
@@ -95,21 +98,9 @@
-
-
-
-
关闭
-
盖章
-
+ -->
作废
+ 申请审批
保存
- 打印
+ 打印
@@ -142,9 +134,8 @@ 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"
-
-const emit = defineEmits(["refresh"])
+import { bindInvoice, invoiceBack, getObj, apply } from "/@/api/wallet/wallet-recharge-invoice"
+import { useDict } from "/@/hooks/dict"
interface ReceiptData {
id: string
@@ -158,14 +149,18 @@ interface ReceiptData {
remark: string
totalPriceCnStr: string
picUrl: string
+ stampPicUrl: string
+ processStatus: string | null
}
+const emit = defineEmits(["refresh"])
+
+const { check_status } = useDict("check_status")
+let timer
const visible = ref(false)
const loading = ref(false)
-const loadingBack = ref(false)
const receiptRef = ref
(null)
const deptOrUserInput = ref(null)
-let timer
const isStamping = ref(false) // 盖章动画开关
const receiptData = ref({
id: "",
@@ -179,9 +174,9 @@ const receiptData = ref({
payeeUser: "", // 开票人
remark: "", // 备注
picUrl: "", // 发票图片地址
+ stampPicUrl: "", // 盖过章的发票图片地址
+ processStatus: "", // 审批状态
})
-const applyId = ref()
-const progressPercent = ref(30)
const receiptDataItems = computed(() => {
try {
const itemJson = JSON.parse(receiptData.value.itemJson)
@@ -198,7 +193,7 @@ const totalPrice = computed(() => displayPrice(receiptData.value.totalPrice))
const openDialog = (data: ReceiptData, id: string) => {
visible.value = true
receiptData.value = data
- applyId.value = id
+ receiptData.value.id = id
isStamping.value = false
timer = setTimeout(() => {
deptOrUserInput.value?.focus()
@@ -212,11 +207,7 @@ const handleClose = () => {
// 发票作废
const backInvoice = async () => {
- if (!receiptData.value.picUrl) {
- 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 +218,7 @@ const backInvoice = async () => {
console.error(error)
useMessage().error(error.msg)
} finally {
- loadingBack.value = false
+ loading.value = false
}
}
@@ -251,50 +242,36 @@ const genImage = async (): Promise => {
// 图片上传
const uploadImage = async (blob: Blob): Promise => {
- try {
- loading.value = true
- const formData = new FormData()
- formData.append("file", blob, "receipt.png")
- const { code, data } = await request({
- url: "/admin/sys-file/upload",
- method: "post",
- headers: {
- "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
- }
+ const formData = new FormData()
+ formData.append("file", blob, "receipt.png")
+ const { code, data } = await request({
+ url: "/admin/sys-file/upload",
+ method: "post",
+ headers: {
+ "Content-Type": "multipart/form-data",
+ },
+ data: formData,
+ })
+ if (code == 0) return data.url
+ useMessage().error(data.msg || "上传失败")
}
// 盖章并上传发票图片并保存
-const stampReceipt = () => {
- loading.value = true
- isStamping.value = true
+// const stampReceipt = () => {
+// loading.value = true
+// isStamping.value = true
- timer = setTimeout(async () => {
- const blob = await genImage()
- if (blob) {
- const url = await uploadImage(blob)
- if (url) {
- receiptData.value.picUrl = url
- await saveReceipt()
- }
- }
- }, 1030)
-}
+// timer = setTimeout(async () => {
+// const blob = await genImage()
+// if (blob) {
+// const url = await uploadImage(blob)
+// if (url) {
+// receiptData.value.picUrl = url
+// await saveReceipt()
+// }
+// }
+// }, 1030)
+// }
// 保存发票
const saveReceipt = async (): Promise => {
@@ -303,7 +280,7 @@ const saveReceipt = async (): Promise => {
const { code, data } = await bindInvoice({
...receiptData.value,
deptOrUser: receiptData.value.deptOrUser,
- applyId: applyId.value,
+ applyId: receiptData.value.id,
})
if (code == 0) {
emit("refresh")
@@ -318,6 +295,33 @@ const saveReceipt = async (): Promise => {
}
}
+// 申请盖章审批
+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, msg } = await apply({ id: receiptData.value.id, picUrl })
+ if (code == 0) {
+ useMessage().success("申请成功")
+ emit("refresh")
+ visible.value = false
+ return
+ }
+ useMessage().error(msg || "申请失败")
+ } catch (error) {
+ useMessage().error(error as string)
+ } finally {
+ loading.value = false
+ }
+}
+
// 打印
const handlePrint = async () => {
if (receiptRef.value) {