This commit is contained in:
weiwei committed 2025-07-04 15:09:59 +08:00
1 parent a1a2e90251
commit 1f35a78c17
1 file changed
+34 -41
@@ -99,7 +99,7 @@
<template #footer>
<el-button @click="handleClose" :disabled="loading">关闭</el-button>
<el-button
<!-- <el-button
v-if="!receiptData.picUrl"
v-auth="'wallet_walletRechargeApply_receiptStamp'"
type="primary"
@@ -107,7 +107,7 @@
:disabled="loading"
>
盖章
</el-button>
</el-button> -->
<el-button
v-if="receiptData.picUrl"
v-auth="'wallet_walletRechargeApply_back'"
@@ -160,9 +160,9 @@ interface ReceiptData {
const emit = defineEmits(["refresh"])
const { check_status } = useDict("check_status")
let timer
const visible = ref(false)
const loading = ref(false)
let timer
const receiptRef = ref<HTMLElement | null>(null)
const processDrawerRef = ref()
const deptOrUserInput = ref<HTMLInputElement | null>(null)
@@ -182,7 +182,6 @@ const receiptData = ref<ReceiptData>({
processStatus: "", // 审批状态
processId: "", // 流程实例id
})
const applyId = ref<string>()
const receiptDataItems = computed(() => {
try {
const itemJson = JSON.parse(receiptData.value.itemJson)
@@ -199,7 +198,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()
@@ -252,42 +251,36 @@ const genImage = async (): Promise<Blob | void | null> => {
// 图片上传
const uploadImage = async (blob: Blob): Promise<string | void> => {
try {
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 || "上传失败")
} catch (error) {
useMessage().error(error as string)
} finally {
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<void> => {
@@ -296,7 +289,7 @@ const saveReceipt = async (): Promise<void> => {
const { code, data } = await bindInvoice({
...receiptData.value,
deptOrUser: receiptData.value.deptOrUser,
applyId: applyId.value,
applyId: receiptData.value.id,
})
if (code == 0) {
emit("refresh")
@@ -314,7 +307,7 @@ const saveReceipt = async (): Promise<void> => {
// 申请盖章审批
const applyStamp = async () => {
await useMessage().delConfirm("是否提交审批")
if (receiptData.value.processStatus == "1") return useMessage().warning("你已提交申请,请勿重复提交")
if (receiptData.value.processStatus == "1") return useMessage().warning("你已提交过申请,请勿重复提交")
loading.value = true
try {
@@ -333,10 +326,10 @@ const applyStamp = async () => {
}
}
// 盖章执行审批
// 执行审批
const stampApproval = () => {
if (!receiptData.value.processId) return useMessage().info("流程id不存在")
processDrawerRef.value.openProcessDrawer(receiptData.value.processId)
processDrawerRef.value.openProcessDrawer(receiptData.value)
}
// 审批提交