zhang_12370
6 天以前 c6d13e58d85fbaaceb49d4c24401b50143050173
src/views/procureMent/index.vue
@@ -35,7 +35,11 @@
        @delete="handleDeleteSuccess"
        :show-selection="true"
        :border="true"
        :maxHeight="440"
        style="width: 100%; height: calc(100vh - 26em)"
        @viewRow="handleView"
        :operations="['edit', 'viewRow']"
        :operationsWidth="200"
        :show-overflow-tooltip="false"
      />
      <pagination
        v-if="total > 0"
@@ -69,7 +73,9 @@
  purchaseRegistration,
  getSupplyList,
  getCoalInfoList,
  delPR
} from "@/api/procureMent";
import { useDelete } from "@/hooks/useDelete";
import useUserStore from "@/store/modules/user";
// 引入字典数据
@@ -150,7 +156,7 @@
const MatchQuery = (data, name) => {
  const list = name === "supplyRes" ? supplyRes.value.data : coalRes.value.data;
  const item = list.find((items) => items.id == data);
  return item ? item.coal || item.supplierName  : "";
  return item ? item.coal || item.supplierName : "";
};
// 获取供应商列表
const supplyRes = ref([]);
@@ -177,19 +183,20 @@
const productionDialogs = ref(null); // 添加ref声明
const handleAddEdit = () => {
  addOrEdit.value == "add" ? (title.value = "新增") : (title.value = "编辑");
  addOrEdit.value == "add" ? (title.value = "新增") : addOrEdit.value == "viewRow" ? (title.value = "查看") : (title.value = "编辑");
  title.value = title.value + "采购信息";
  openDialog();
};
// 打开弹窗
const openDialog = () => {
  if (addOrEdit.value === "edit") {
  if (addOrEdit.value === "edit" || addOrEdit.value === "viewRow") {
    // 确保复制一份数据,避免直接引用
    copyForm.value = JSON.parse(JSON.stringify(form.value));
    dialogFormVisible.value = true;
    // 触发ref里面的方法
    return;
  }
  console.log(userInfo.value)
  // 新建时初始化表单
  form.value = {
    supplierName: "",
@@ -201,7 +208,7 @@
    priceIncludingTax: "",
    totalPriceIncludingTax: "",
    taxRate: "",
    registrantId: userInfo.value.userName,
    registrantId: userInfo.value.userId,
    registrationDate: new Date().toISOString().split("T")[0],
  };
  // 新建时也需要设置 copyForm 用于重置功能
@@ -229,28 +236,20 @@
  addOrEdit.value = "edit";
  handleAddEdit();
};
const handleDelete = () => {
  if (selectedRows.value.length === 0) {
    ElMessage.warning("请选择要删除的数据");
    return;
  }
  ElMessageBox.confirm(`确定删除选中的数据吗?`, "提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      // 模拟删除操作
      tableData.value = tableData.value.filter(
        (item) => !selectedRows.value.includes(item)
      );
      total.value = tableData.value.length;
      ElMessage.success("删除成功");
    })
    .catch(() => {
      ElMessage.info("已取消删除");
    });
const handleView = (row) => {
  form.value = JSON.parse(JSON.stringify(row));
  addOrEdit.value = "viewRow";
  handleAddEdit();
};
// 使用删除组合式函数 - 简化版本
const { handleDeleteBatch: handleDelete } = useDelete({
  deleteApi: delPR,
  selectedRows,
  tableData,
  total,
  confirmText: "确定删除选中的采购记录吗?",
  useLocalUpdate: true
});
const handleDeleteSuccess = (row) => {
  ElMessage.success("删除成功:" + row.supplierName);
};