gaoluyang
2 天以前 9d496497c8f4b9fea9609efd20b96b44016c305d
src/views/fileManagement/borrow/index.vue
@@ -44,6 +44,9 @@
            <el-icon><Plus /></el-icon>
            新增借阅
          </el-button>
          <el-button @click="handleOut">
            导出
          </el-button>
          <el-button
            type="danger"
            @click="handleBatchDelete"
@@ -201,7 +204,7 @@
const borrowList = ref([]);
const selectedRows = ref([]);
const documentList = ref([]); // 文档列表,用于借阅书籍选择
const scanContent = ref('') // 扫码内容
const scanContent = ref() // 扫码内容
// 分页相关
const pagination = reactive({
  currentPage: 1,
@@ -234,7 +237,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 +311,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 +393,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 {
      // 未找到匹配的文档,提示用户
@@ -555,6 +560,21 @@
  });
};
// 导出
const handleOut = () => {
  ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      proxy.download("/documentationBorrowManagement/export", {}, "借阅登记.xlsx");
    })
    .catch(() => {
      ElMessage.info("已取消");
    });
};
// 选择变化事件
const handleSelectionChange = (selection) => {
  selectedRows.value = selection;