yangg 3 viikkoa sitten
vanhempi
sitoutus
ee3df51074

+ 2 - 2
.env.production

@@ -2,8 +2,8 @@
 ENV = 'production'
 
 # 线上环境接口地址
-VITE_API_URL = 'http://10.68.32.3:8086' # docker-compose部署不需要修改,nginx容器自动代理了这个地址1.94.168.85:8086
-
+#VITE_API_URL = 'http://10.68.32.3:8086' # docker-compose部署不需要修改,nginx容器自动代理了这个地址1.94.168.85:8086
+VITE_API_URL = 'http://1.94.168.85:8086'
 # 微信API地址
 VITE_API_WX_URL='https://api.weixin.qq.com/'
 

+ 52 - 3
src/views/system/Inventorycount/InventoryDialog/index.vue

@@ -1,8 +1,8 @@
 <template>
-    <el-dialog v-model="visible" title="开始盘点" width="800px" @open="onOpen" @close="onClose">
+    <el-dialog v-model="visible" title="开始盘点" width="800px" @open="onOpen" @opened="onOpened" @close="onClose">
       <div>
         <div class="form-row">
-          <el-input v-model="device_code" placeholder="设备编号" @keyup.enter="handleAdd" :disabled="loading" />
+          <el-input ref="deviceCodeInputRef" v-model="device_code" placeholder="设备编号" @keyup.enter="handleAdd" :disabled="loading" />
           <el-input v-model="check_no" placeholder="盘点编号" @keyup.enter="handleAdd" :disabled="true" />
           <el-button type="primary" @click="handleAdd" :loading="loading">添加</el-button>
         </div>
@@ -28,7 +28,7 @@
   </template>
   
   <script setup lang="ts" >
-  import { ref } from 'vue';
+  import { ref, nextTick } from 'vue';
   import * as api from '../api';
   import { ElMessage } from 'element-plus';
   const emit = defineEmits(['completed']);
@@ -39,18 +39,65 @@
   const deviceList = ref<any[]>([]);
   const currentRecordId = ref<number | null>(null);
   const loading = ref(false);
+  const deviceCodeInputRef = ref<any>(null);
 //   const btflag=ref(true);
   
   const setCheckNo = (val: string) => {
     console.log("val::::::",val)
     check_no.value = val;
 };
+  
+  // 聚焦设备编号输入框
+  const focusDeviceCodeInput = async () => {
+    // 等待 DOM 更新和对话框动画完成
+    await nextTick();
+    // 使用 setTimeout 确保对话框完全打开
+    setTimeout(() => {
+      if (!deviceCodeInputRef.value || loading.value) return;
+      
+      // 尝试多种方式获取 input 元素
+      let inputEl: HTMLInputElement | null = null;
+      
+      // 方式1: Element Plus 组件可能直接有 focus 方法
+      if (typeof deviceCodeInputRef.value.focus === 'function') {
+        deviceCodeInputRef.value.focus();
+        return;
+      }
+      
+      // 方式2: 通过 input 属性获取
+      if (deviceCodeInputRef.value.input) {
+        inputEl = deviceCodeInputRef.value.input;
+      }
+      // 方式3: 通过 $el 查询
+      else if (deviceCodeInputRef.value.$el) {
+        inputEl = deviceCodeInputRef.value.$el.querySelector('input');
+      }
+      // 方式4: 直接通过 ref 的 DOM 元素查询
+      else if (deviceCodeInputRef.value instanceof HTMLElement) {
+        inputEl = deviceCodeInputRef.value.querySelector('input');
+      }
+      
+      if (inputEl) {
+        inputEl.focus();
+        // 延迟选中文本,确保焦点已设置
+        setTimeout(() => {
+          inputEl?.select();
+        }, 10);
+      }
+    }, 100);
+  };
+
   const onOpen = () => {
     device_code.value = '';
     // check_no.value = '';
     deviceList.value = [];
     currentRecordId.value = null;
   };
+
+  // 对话框完全打开后聚焦输入框
+  const onOpened = () => {
+    focusDeviceCodeInput();
+  };
   
   const findCheckRecord = (checkNo: string, list: any[]) => {
         console.log("lists::::",list)
@@ -89,6 +136,8 @@
       }
     } finally {
       loading.value = false;
+      // 在 loading 状态更新后聚焦
+      await focusDeviceCodeInput();
     }
   };
 

+ 55 - 5
src/views/system/borrow/component/CollectEquipment/index.vue

@@ -215,7 +215,7 @@
                 <el-row :gutter="16">
                     <el-col :span="24">
                         <div style="margin: 8px 0">
-                            <el-input v-model="searchText" placeholder="请扫描设备条码添加" style="width: 300px" @keyup.enter="handleScanSearch" />
+                            <el-input ref="searchInputRef" v-model="searchText" placeholder="请扫描设备条码添加" style="width: 300px" @keyup.enter.prevent="handleScanSearch" />
                             <el-button type="primary" style="margin-left: 16px" @click="handleAdd">手动借用</el-button>
                         </div>
                         <el-table :data="deviceList" border style="width: 100%">
@@ -284,7 +284,7 @@
                 <el-row :gutter="16">
                     <el-col :span="24">
                         <div style="margin: 8px 0" v-if="!isView" >
-                            <el-input :disabled="isView" v-model="returnSearchText" placeholder="请扫描设备条码添加" style="width: 300px" @keyup.enter="handleReturnScanSearch" />
+                            <el-input ref="returnSearchInputRef" :disabled="isView" v-model="returnSearchText" placeholder="请扫描设备条码添加" style="width: 300px" @keyup.enter.prevent="handleReturnScanSearch" />
                             <el-button type="primary" style="margin-left: 16px" @click="handleAdd" :disabled="isView">手动归还</el-button>
                         </div>
                         <el-table :data="returnDeviceList" border style="width: 100%" >
@@ -670,6 +670,10 @@ const timeline = ref({
 const activeName = ref('first');
 const returnStatus = ref('未归还'); // 添加独立的状态变量
 
+// 输入框引用
+const searchInputRef = ref<any>(null);
+const returnSearchInputRef = ref<any>(null);
+
 // 借用列表相关数据
 const searchText = ref('');
 const deviceList = ref<DeviceListItem[]>([]);
@@ -907,7 +911,12 @@ const handleViewAbnormal = (index: number) => {
 };
 
 // 处理扫码搜索
-const handleScanSearch = async () => {
+const handleScanSearch = async (event?: Event) => {
+    // 阻止默认行为,防止表单提交导致页面刷新
+    if (event) {
+        event.preventDefault();
+        event.stopPropagation();
+    }
     if (!searchText.value.trim()) return;
     
     try {
@@ -922,6 +931,10 @@ const handleScanSearch = async () => {
             const device = res.data[0];
             if (device.available_quantity <= 0) {
                 ElMessage.warning('该设备当前无可用数量');
+                // 重新聚焦输入框
+                nextTick(() => {
+                    searchInputRef.value?.focus?.();
+                });
                 return;
             }
             
@@ -953,6 +966,10 @@ const handleScanSearch = async () => {
         ElMessage.error('搜索设备失败');
     } finally {
         searchText.value = ''; // 清空搜索框
+        // 重新聚焦输入框,保持选中状态
+        nextTick(() => {
+            searchInputRef.value?.focus?.();
+        });
     }
 };
 
@@ -970,7 +987,12 @@ const normalizeReturnStatus = (status?: { value?: number | string; label?: strin
 };
 
 // 处理归还扫码搜索
-const handleReturnScanSearch = async () => {
+const handleReturnScanSearch = async (event?: Event) => {
+    // 阻止默认行为,防止表单提交导致页面刷新
+    if (event) {
+        event.preventDefault();
+        event.stopPropagation();
+    }
     if (!returnSearchText.value.trim()) return;
     
     try {
@@ -1018,6 +1040,10 @@ const handleReturnScanSearch = async () => {
         ElMessage.error('搜索设备失败');
     } finally {
         returnSearchText.value = ''; // 清空搜索框
+        // 重新聚焦输入框,保持选中状态
+        nextTick(() => {
+            returnSearchInputRef.value?.focus?.();
+        });
     }
 };
 
@@ -1205,6 +1231,17 @@ function onDeviceSelected(devices: Device[]) {
 
 function handleClick(tab: TabsPaneContext) {
   console.log('Tab clicked:', tab.props.name);
+  // 当切换到设备清单标签页时,自动聚焦输入框
+  if (tab.props.name === 'second') {
+    nextTick(() => {
+      searchInputRef.value?.focus?.();
+    });
+  } else if (tab.props.name === 'third') {
+    // 当切换到归还设备清单标签页时,自动聚焦输入框
+    nextTick(() => {
+      returnSearchInputRef.value?.focus?.();
+    });
+  }
 }
 
 function handleUploadSuccess(response: any, file: any, fileList: any) {
@@ -1310,7 +1347,20 @@ onMounted(() => {
 
 watch(
 	() => props.visible,
-	(v) => (visible.value = v)
+	(v) => {
+		visible.value = v;
+		// 当对话框打开且当前标签页是设备清单时,自动聚焦输入框
+		if (v && activeName.value === 'second' && isCollect.value) {
+			nextTick(() => {
+				searchInputRef.value?.focus?.();
+			});
+		} else if (v && activeName.value === 'third' && !isView.value) {
+			// 当对话框打开且当前标签页是归还设备清单时,自动聚焦输入框
+			nextTick(() => {
+				returnSearchInputRef.value?.focus?.();
+			});
+		}
+	}
 );
 
 watch(() => props.modelValue, async (val) => {

+ 9 - 5
src/views/system/borrow/index.vue

@@ -165,11 +165,15 @@ async function handleSettlement(e: CustomEvent) {
 }
 
 async function handleRenewDevice(e: CustomEvent) {
-	const row = e.detail;
-	showSettlementDialog.value = true;
-	nextTick(() => {
-		borrowForm.value = { ...row, mode: 'renew' };
-	});
+	const res: any = await api.GetApplicationDetail(e.detail.id);
+		if(res.code==2000){
+			showSettlementDialog.value = true;
+			nextTick(() => {
+				borrowForm.value = { ...res.data, mode: 'renew' };
+			});
+		}else{
+			ElMessage.error('获取续借详情失败');
+		}
 }