import React, {useState} from 'react'; import { View, Text, StyleSheet, TextInput, TouchableOpacity, SafeAreaView, ActivityIndicator, } from 'react-native'; import {NativeStackNavigationProp} from '@react-navigation/native-stack'; import {useNavigation} from '@react-navigation/native'; import {RootStackParamList} from '../../navigation/types'; import {useTheme} from '../../contexts/ThemeContext'; import Icon from 'react-native-vector-icons/MaterialIcons'; import LinearGradient from 'react-native-linear-gradient'; import Svg, {Path} from 'react-native-svg'; import axios from 'axios'; import {DialogUtils} from '../../utils'; interface StockInEmptyResponse { code: number; message: string; data: { code: number; message: string; }; } type StockInEmptyScreenNavigationProp = NativeStackNavigationProp< RootStackParamList, 'StockInEmpty' >; export const StockInEmpty: React.FC = () => { const navigation = useNavigation(); const theme = useTheme(); const [vehicleNo, setVehicleNo] = useState(''); const [loading, setLoading] = useState(false); // 空托入库方法 const handleEmptyIn = async () => { if (!vehicleNo.trim()) { DialogUtils.showWarningMessage('警告', '请先填写载具号', '返回填写'); return; } try { setLoading(true); const response = await axios.post( '/api/vehicle/empty-in', {vehicleNo: vehicleNo.trim()}, ); if (response.status !== 200) { DialogUtils.showWarningMessage('警告', '服务器请求失败', '我知道了'); return; } const responseData = response.data; if (responseData.code === 200) { DialogUtils.showSuccessMessage('成功', '空载具入库成功', '我知道了'); setVehicleNo(''); } else { DialogUtils.showWarningMessage( '警告', `服务器返回失败:${responseData.message}`, '我知道了', ); } } catch (error) { DialogUtils.showErrorMessage( '请求发生错误', `请求服务器发生错误:${ error instanceof Error ? error.message : String(error) }`, '我知道了', ); } finally { setLoading(false); } }; return ( {/* 头部导航栏 */} navigation.goBack()} style={styles.backButton}> 空载具入库 {/* 波浪效果 */} {/* 主体内容 */} {/* 说明文字 */} 请扫描或输入载具号进行空载具入库操作 {/* 载具号输入框 */} 载具号 * {vehicleNo.length > 0 && ( setVehicleNo('')} style={styles.clearButton}> )} {/* 提交按钮 */} {loading ? ( ) : ( <> 确认入库 )} ); }; const styles = StyleSheet.create({ container: { flex: 1, }, header: { height: 56, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 16, elevation: 4, shadowColor: '#000', shadowOffset: {width: 0, height: 2}, shadowOpacity: 0.2, shadowRadius: 2, }, waveContainer: { height: 100, backgroundColor: 'transparent', position: 'absolute', top: 56, left: 0, right: 0, zIndex: -1, }, waveSvg: { position: 'absolute', top: 0, }, backButton: { padding: 8, }, headerTitle: { fontSize: 18, fontWeight: '600', }, headerRight: { width: 40, }, content: { flex: 1, padding: 20, }, infoSection: { flexDirection: 'row', alignItems: 'center', padding: 16, borderRadius: 8, marginBottom: 24, }, infoText: { marginLeft: 12, fontSize: 14, flex: 1, }, inputContainer: { marginBottom: 24, }, inputLabel: { fontSize: 16, marginBottom: 8, fontWeight: '500', }, required: { color: '#ff4d4f', }, inputWrapper: { flexDirection: 'row', alignItems: 'center', borderWidth: 1, borderRadius: 8, height: 48, paddingHorizontal: 12, }, inputIcon: { marginRight: 8, }, input: { flex: 1, fontSize: 16, padding: 0, height: '100%', }, clearButton: { padding: 4, }, submitButton: { height: 48, borderRadius: 24, marginTop: 32, elevation: 2, shadowColor: '#000', shadowOffset: {width: 0, height: 2}, shadowOpacity: 0.1, shadowRadius: 2, }, submitButtonContent: { flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', }, submitButtonDisabled: { opacity: 0.6, }, submitIcon: { marginRight: 8, }, submitButtonText: { fontSize: 16, fontWeight: '600', }, });