gaoluyang
2025-09-26 febbfe17f1ae201e62b9f23c7f29671251348e38
src/views/fileManagement/borrow/index.vue
@@ -201,7 +201,7 @@
const borrowList = ref([]);
const selectedRows = ref([]);
const documentList = ref([]); // 文档列表,用于借阅书籍选择
const scanContent = ref('') // 扫码内容
const scanContent = ref() // 扫码内容
// 分页相关
const pagination = reactive({
  currentPage: 1,
@@ -234,7 +234,7 @@
// 表单验证规则
const borrowRules = reactive({
  documentationId: [{ required: true, message: "请选择借阅书籍", trigger: "change" }],
  borrower: [{ required: true, message: "请输入借阅人", trigger: "blur" }],
  borrowPurpose: [{ required: true, message: "请输入借阅目的", trigger: "blur" }],
  borrowDate: [{ required: true, message: "请选择借阅日期", trigger: "change" }],
@@ -308,6 +308,7 @@
    const res = await getDocumentList();
    if (res.code === 200) {
      documentList.value = res.data || [];
      console.log("shuju",documentList.value)
    } else {
      ElMessage.error(res.msg || "获取文档列表失败");
      documentList.value = [];
@@ -389,18 +390,19 @@
// 处理扫码内容
const handleScanContent = async (value) => {
if (!value) return;
  if (!value) return;
  try {
    // 查找扫描内容对应的文档
    // 假设二维码包含的是文档ID或文档名称
    const matchedDoc = documentList.value.find(item => 
      item.documentationId === value
      item.id == value
    );
    console.log("matchedDoc", matchedDoc);
    
    if (matchedDoc) {
      // 找到匹配的文档,设置表单值
      borrowForm.documentationId = matchedDoc.documentationId;
      borrowForm.documentationId = matchedDoc.id;
      ElMessage.success(`已选择: ${matchedDoc.docName || matchedDoc.name}`);
    } else {
      // 未找到匹配的文档,提示用户