yangg 1 тиждень тому
батько
коміт
8243542a5b

+ 25 - 2
src/layout/navBars/breadcrumb/user.vue

@@ -236,8 +236,15 @@ const onLanguageChange = (lang: string) => {
 	initI18nOrSize('globalI18n', 'disabledI18n');
 };
 // 初始化组件大小/i18n
-const initI18nOrSize = (value: string, attr: string) => {
-	state[attr] = Local.get('themeConfig')[value];
+type ThemeConfigKey = 'globalComponentSize' | 'globalI18n';
+type StateKey = 'disabledSize' | 'disabledI18n';
+const initI18nOrSize = (value: ThemeConfigKey, attr: StateKey) => {
+    const theme = Local.get('themeConfig') as any;
+    if (attr === 'disabledSize') {
+        state.disabledSize = theme[value];
+    } else {
+        state.disabledI18n = theme[value];
+    }
 };
 // 页面加载时
 onMounted(() => {
@@ -272,6 +279,8 @@ const getLastMsg= ()=>{
 
 <style scoped lang="scss">
 .layout-navbars-breadcrumb-user {
+	// 可配置的导航图标尺寸(默认与现状一致),可在外部覆盖以放大图标
+	--nav-icon-size: 18px;
 	display: flex;
 	align-items: center;
 	justify-content: flex-end;
@@ -311,6 +320,20 @@ const getLastMsg= ()=>{
 		display: flex;
 		align-items: center;
 	}
+	// 统一控制 Element Plus 图标与 svg 尺寸
+	:deep(.el-icon) {
+		font-size: var(--nav-icon-size);
+		// 处理 el-icon 内部 svg 尺寸
+		svg {
+			width: var(--nav-icon-size);
+			height: var(--nav-icon-size);
+		}
+	}
+	// 统一控制 iconfont 图标尺寸
+	:deep(i.iconfont) {
+		font-size: var(--nav-icon-size);
+		line-height: 1;
+	}
 	:deep(.el-badge__content.is-fixed) {
 		top: 12px;
 	}

+ 59 - 0
src/views/system/borrow/component/ClassroomBorrow/index.vue

@@ -764,4 +764,63 @@ function onSave() {
 	});
 }
 
+// —— 按学号/工号回显借用人信息(防抖,不影响现有交互) ——
+let userCodeDebounceTimer: any = null;
+async function queryUserByCode(userCode: string) {
+  try {
+    // 先在已加载的全量列表中查找,避免重复请求
+    if (allUserList.value && allUserList.value.length > 0) {
+      const local = allUserList.value.find((u: any) => String(u.user_code || '').trim() === String(userCode).trim());
+      if (local) {
+        form.value.app_user_borrower = Number(local.id);
+        form.value.user_code = local.user_code || '';
+        form.value.mobile = local.mobile || '';
+        return;
+      }
+    }
+
+    // 远端查询:尽量使用通用查询参数,兼容不同实现
+    const tryParamsList = [
+      { user_code: userCode, page: 1, limit: 20 },
+      { search: userCode, page: 1, limit: 20 },
+      { code: userCode, page: 1, limit: 20 },
+    ];
+
+    let found: any = null;
+    for (const params of tryParamsList) {
+      const res: any = await api.GetAllUser(params);
+      if (res && (res.code === 2000 || res.status === 200) && Array.isArray(res.data) && res.data.length > 0) {
+        found = res.data.find((u: any) => String(u.user_code || '').trim() === String(userCode).trim()) || res.data[0];
+        break;
+      }
+    }
+
+    if (found) {
+      form.value.app_user_borrower = Number(found.id);
+      form.value.user_code = found.user_code || '';
+      form.value.mobile = found.mobile || '';
+      // 部门信息将由现有的 app_user_borrower 监听逻辑自动回填
+    } else {
+      // 未找到时不覆盖已有填写,给出轻提示
+      ElMessage.warning('未找到匹配的借用人');
+    }
+  } catch (e) {
+    /* empty */
+  }
+}
+
+function scheduleQueryUserByCode(userCode: string) {
+  if (userCodeDebounceTimer) clearTimeout(userCodeDebounceTimer);
+  userCodeDebounceTimer = setTimeout(() => {
+    if (!userCode || String(userCode).trim().length < 2) return;
+    if (form.value.borrower_type === 2) return; // 外部用户不查
+    if (isView.value) return; // 查看态不查
+    queryUserByCode(String(userCode).trim());
+  }, 300);
+}
+
+watch(() => form.value.user_code, (nv) => {
+  scheduleQueryUserByCode(nv as any);
+});
+
 </script>

+ 59 - 0
src/views/system/borrow/component/SpecialBorrow/index.vue

@@ -586,6 +586,65 @@ onMounted(() => {
 	}
 });
 
+// —— 按学号/工号回显借用人信息(防抖,不影响现有交互) ——
+let userCodeDebounceTimer: any = null;
+async function queryUserByCode(userCode: string) {
+  try {
+    // 先在已加载的全量列表中查找,避免重复请求
+    if (allUserList.value && allUserList.value.length > 0) {
+      const local = allUserList.value.find((u: any) => String(u.user_code || '').trim() === String(userCode).trim());
+      if (local) {
+        form.value.app_user_borrower = Number(local.id);
+        form.value.user_code = local.user_code || '';
+        form.value.mobile = local.mobile || '';
+        return;
+      }
+    }
+
+    // 远端查询:尽量使用通用查询参数,兼容不同实现
+    const tryParamsList = [
+      { user_code: userCode, page: 1, limit: 20 },
+      { search: userCode, page: 1, limit: 20 },
+      { code: userCode, page: 1, limit: 20 },
+    ];
+
+    let found: any = null;
+    for (const params of tryParamsList) {
+      const res: any = await api.GetAllUser(params);
+      if (res && (res.code === 2000 || res.status === 200) && Array.isArray(res.data) && res.data.length > 0) {
+        found = res.data.find((u: any) => String(u.user_code || '').trim() === String(userCode).trim()) || res.data[0];
+        break;
+      }
+    }
+
+    if (found) {
+      form.value.app_user_borrower = Number(found.id);
+      form.value.user_code = found.user_code || '';
+      form.value.mobile = found.mobile || '';
+      // 部门信息将由现有的 app_user_borrower 监听逻辑自动回填
+    } else {
+      // 未找到时不覆盖已有填写,给出轻提示
+      ElMessage.warning('未找到匹配的借用人');
+    }
+  } catch (e) {
+    /* empty */
+  }
+}
+
+function scheduleQueryUserByCode(userCode: string) {
+  if (userCodeDebounceTimer) clearTimeout(userCodeDebounceTimer);
+  userCodeDebounceTimer = setTimeout(() => {
+    if (!userCode || String(userCode).trim().length < 2) return;
+    if (form.value.borrower_type === 2) return; // 外部用户不查
+    if (isView.value) return; // 查看态不查
+    queryUserByCode(String(userCode).trim());
+  }, 300);
+}
+
+watch(() => form.value.user_code, (nv) => {
+  scheduleQueryUserByCode(nv as any);
+});
+
 watch(
 	() => props.visible,
 	(v) => (visible.value = v)