src/views/basicInformation/index.vue
@@ -58,7 +58,6 @@
          @selection-change="handleSelectionChange"
          :operations="['edit', 'viewRow']"
          :operationsWidth="200"
          :show-overflow-tooltip="false"
        >
          <!-- 字段名称列的自定义插槽 - 显示为标签 -->
          <template
@@ -168,7 +167,6 @@
import Coal from "./mould/coal.vue";
import coalQualityMaintenance from "./mould/coalQualityMaintenance.vue";
import coalMeiZhiZiDuanWeiHu from "./mould/coalMeiZhiZiDuanWeiHu.vue";
import Descriptions from "@/components/dialog/Descriptions.vue";
// ===== API 服务导入 =====
import { delSupply, getSupply } from "@/api/basicInformation/supplier.js";
@@ -186,16 +184,12 @@
import {
  getCoalFieldList,
  getCoalPlanList,
  delCoalPlan,
} from "@/api/basicInformation/coalQualityMaintenance";
import { useDelete } from "@/hooks/useDelete.js";
const { proxy } = getCurrentInstance();
// ===== 响应式状态管理 =====
// 弹窗控制状态
const showDialog = ref(false);
const currentViewData = ref({}); // 当前查看的数据
const dialogFormVisible = ref(false);
const form = ref({});
const title = ref("");
@@ -316,10 +310,12 @@
const getUserList = async () => {
  try {
    const res = await testUserList();
    console.log("获取用户列表数据:", res);
    console.log("userMap:", userMap.value);
    if (res && res.data) {
      userList.value = res.data;
      userList.value.forEach((user) => {
        userMap.value[user.userId] = user.username;
        userMap.value[user.userId] = user.nickName;
      });
    }
  } catch (error) {
@@ -721,57 +717,22 @@
 * 批量删除处理
 * @description 批量删除选中的记录
 */
const handleDelete = async () => {
  if (selectedRows.value.length === 0) {
    ElMessage.warning("请选择要删除的数据");
    return;
  }
  const deleteIds = selectedRows.value.map((item) => item.id);
  try {
    await ElMessageBox.confirm("确定删除选中的数据吗?", "提示", {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning",
    });
    const deleteApiMap = {
  const deleteApiMap = {
      supplier: delSupply,
      coal: delCoalInfo,
      coalQualityMaintenance: () => {
        throw new Error("delCoalQuality API not imported");
      },
      coalQualityMaintenance: delCoalPlan,
      customer: delCustomer,
      coalMeiZhiZiDuanWeiHu: deleteCoalField,
    };
    const deleteApi = deleteApiMap[tabName.value];
    if (!deleteApi) {
      ElMessage.error("删除接口未配置");
      return;
    }
    console.log(deleteIds);
    const res = await deleteApi(deleteIds);
    if (res.code !== 200 && res.msg !== "操作成功") {
      ElMessage.error("删除失败:" + res.msg);
      return;
    }
    ElMessage.success("删除成功");
    await getList();
  } catch (error) {
    if (error.message !== "cancel") {
      console.error("删除操作失败:", error);
      ElMessage.error("删除失败,请稍后再试");
    } else {
      ElMessage.info("已取消删除操作");
    }
  } finally {
    selectedRows.value = [];
  }
};
const {handleDeleteBatch :handleDelete} = useDelete({
  deleteApi: () => deleteApiMap[tabName.value],
  selectedRows: selectedRows,
  getList: () => getList,
  tableData: tableData,
  total: total,
  confirmText: "确认删除选中的数据吗?",
  successText: "删除成功",
})
/**
 * 关闭弹窗处理