| | |
| | | <script setup> |
| | | import { ref, getCurrentInstance } from 'vue' |
| | | import filePreview from '@/components/filePreview/index.vue' |
| | | import { ElMessageBox } from 'element-plus' |
| | | import { |
| | | delLedgerFile |
| | | } from "@/api/salesManagement/salesLedger.js"; |
| | | |
| | | const emit = defineEmits(['refresh']) |
| | | const dialogVisible = ref(false) |
| | | const tableData = ref([]) |
| | | const currentRowId = ref(null) |
| | | const { proxy } = getCurrentInstance(); |
| | | const filePreviewRef = ref() |
| | | const handleClose = () => { |
| | | dialogVisible.value = false |
| | | } |
| | | const open = (list) => { |
| | | const open = (list, rowId = null) => { |
| | | dialogVisible.value = true |
| | | tableData.value = list |
| | | currentRowId.value = rowId |
| | | } |
| | | const downLoadFile = (row) => { |
| | | proxy.$download.name(row.url); |
| | |
| | | filePreviewRef.value.open(row.url) |
| | | } |
| | | const delFile = (row) => { |
| | | let ids = []; |
| | | ids.push(row.id); |
| | | delLedgerFile(ids).then((res) => { |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | ElMessageBox.confirm('确定要删除该附件吗?', '删除确认', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }).then(() => { |
| | | let ids = []; |
| | | ids.push(row.id); |
| | | delLedgerFile(ids).then((res) => { |
| | | if (res.code === 200) { |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | // 通知父组件刷新数据 |
| | | emit('refresh', currentRowId.value); |
| | | } else { |
| | | proxy.$modal.msgError(res.msg || "删除失败"); |
| | | } |
| | | }).catch((error) => { |
| | | console.error("删除附件失败:", error); |
| | | proxy.$modal.msgError("删除失败,请稍后重试"); |
| | | }); |
| | | }).catch(() => { |
| | | // 用户取消删除 |
| | | }); |
| | | } |
| | | defineExpose({ |