huminmin
2 天以前 75d99a1160ca9bc5e13590b769b7b8f793b698ff
src/views/procureMent/index.vue
@@ -76,12 +76,19 @@
  delPR
} from "@/api/procureMent";
import { useDelete } from "@/hooks/useDelete";
const userStore = useUserStore();
import useUserStore from "@/store/modules/user";
let userList = ref([]);
userStore.getUserList().then((res) => {
  userList.value = res;
});
// 引入字典数据
const { proxy } = getCurrentInstance();
const dialogFormVisible = ref(false);
const form = ref({});
const form = ref({
  taxRate: 13,
  freight: 20,
});
const title = ref("");
// 状态变量
const loading = ref(false);
@@ -106,10 +113,12 @@
// 方法定义
const handleQuery = () => {
  loading.value = true;
   current.value = 1;
   pageSize.value = 10;
  // 这里添加实际的查询逻辑
  getList();
};
const userStore = useUserStore();
// 获取用户信息
const userInfo = ref({});
onMounted(async () => {
@@ -146,9 +155,16 @@
  { prop: "purchaseQuantity", label: "采购数量", minWidth: 100 },
  { prop: "priceIncludingTax", label: "单价(含税)", minWidth: 150 },
  { prop: "totalPriceIncludingTax", label: "总价(含税)", minWidth: 100 },
  { prop: "freight", label: "运费", minWidth: 100 },
  { prop: "taxRate", label: "税率", minWidth: 100 },
  { prop: "priceExcludingTax", label: "不含税单价", minWidth: 100 },
  { prop: "registrantId", label: "登记人", minWidth: 100 },
  { prop: "registrantId", label: "登记人", minWidth: 100,
    formatter: (row) => {
      // 匹配用户信息
      const user = userList.value.find((user) => user.userId === row.registrantId);
      return user ? user.nickName : "未知用户";
    },
  },
  { prop: "registrationDate", label: "登记日期", minWidth: 100 },
]);
@@ -207,7 +223,8 @@
    totalPriceExcludingTax: "",
    priceIncludingTax: "",
    totalPriceIncludingTax: "",
    taxRate: "",
    taxRate: 13,
    freight:20,
    registrantId: userInfo.value.userId,
    registrationDate: new Date().toISOString().split("T")[0],
  };
@@ -241,17 +258,33 @@
  addOrEdit.value = "viewRow";
  handleAddEdit();
};
// 使用删除组合式函数 - 简化版本
const { handleDeleteBatch: handleDelete } = useDelete({
  deleteApi: delPR,
  selectedRows,
  tableData,
  total,
  confirmText: "确定删除选中的采购记录吗?",
  useLocalUpdate: true
});
const handleDelete = () => {
  if (selectedRows.value.length === 0) {
    proxy.$modal.msgWarning("请选择要删除的数据");
    return;
  }
  proxy.$modal
      .confirm("是否要删除" +`选中的${selectedRows.value.length}条数据?`)
      .then((res) => {
        if (res) {
          delPR(selectedRows.value.map((row) => row.id)).then((res) => {
            if (res.result.code === 200) {
              proxy.$modal.msgSuccess("删除成功");
              getList();
            } else {
              proxy.$modal.msgError("删除失败:" + res.result.msg);
            }
          }).finally(() => {
            handleQuery()
          })
        }
      })
      .catch(() => {})
}
const handleDeleteSuccess = (row) => {
  ElMessage.success("删除成功:" + row.supplierName);
   handleQuery()
};
// 成功
const handleSuccess = (val) => {