src/views/salesManagement/opportunityManagement/fileList.vue
@@ -2,10 +2,11 @@
  <el-dialog v-model="dialogVisible" title="附件" width="40%" :before-close="handleClose">
    <el-table :data="tableData" border height="40vh" stripe>
      <el-table-column label="附件名称" prop="name" min-width="400" show-overflow-tooltip />
      <el-table-column fixed="right" label="操作" width="100" align="center">
      <el-table-column fixed="right" label="操作" width="150" align="center">
        <template #default="scope">
          <el-button link type="primary" size="small" @click="downLoadFile(scope.row)">下载</el-button>
          <el-button link type="primary" size="small" @click="lookFile(scope.row)">预览</el-button>
          <el-button link type="primary" size="small" @click="delFile(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
@@ -16,17 +17,24 @@
<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);
@@ -35,6 +43,30 @@
const lookFile = (row) => {
  filePreviewRef.value.open(row.url)
}
const delFile = (row) => {
  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({
  open
})