cmvr-wms/mobile-app/src/screens/Workspace.tsx
lixiaolong 6ae0682546 feat(workspace): 优化工作空间页面布局并改进到货管理功能
- 新增 ArrivalListTools 和 ArrivalCard 组件用于到货列表管理
- 集成 arrivalListQuery 查询逻辑优化数据加载
- 调整页面标题文字样式增加最小宽度和行高
- 更新底部标签栏字体大小和行高设置
- 重构到货操作界面添加键盘避让视图支持
- 优化到货操作按钮状态管理增加次要按钮样式
- 实现助手组件分页功能支持动态页面大小
- 扩展文件存储区域配置支持项目工作空间
- 增加文件流式上传下载方法支持大文件处理
- 优化采购表格单元格键盘输入体验
- 修复移动端到货操作界面键盘遮挡问题
- 调整测试用例数据量验证分页功能正确性
2026-10-21 15:13:39 +08:00

49 lines
10 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React,{useContext} from 'react';
import {Image,Pressable,ScrollView,Text,View,useWindowDimensions} from 'react-native';
import Constants from 'expo-constants';
import * as Updates from 'expo-updates';
import {AppearanceContext,Avatar,Button,Card,Heading,Icon,MenuItem,Note,s,useTheme,type IconName} from '../ui';
import {imagePath} from '../core/account';
import {usePrivateImage} from '../files';
import {ApiClient} from '../core/network';
import type {Module,Row} from '../core/modules';
import {workspaceColumns} from '../core/workspace-layout';
const icons:Record<string,IconName>={arrival:'checkmark-circle-outline',use:'file-tray-outline',move:'swap-horizontal-outline',count:'clipboard-outline',stock:'cube-outline',purchase:'cart-outline',pending:'download-outline',in:'file-tray-full-outline',loans:'swap-horizontal-outline',check:'clipboard-outline',out:'file-tray-outline',production:'construct-outline'};
const hints:Record<string,string>={arrival:'登记到货、逐次验收合格数量',use:'选择库存,核对后领用出库',move:'同项目库存更换实际存放库区',count:'现场清点,登记实际数量',stock:'查询物品、数量和所在库区',purchase:'采购明细与报价进展',pending:'核对物品,现场办理入库',in:'追溯每一次入库',loans:'查询项目间借还进度',check:'查看盘点记录、确认盘点',out:'查看领用与退回记录',production:'查询任务、产量与执行状态'};
type Props={api:ApiClient;user:Row;modules:Module[];open:(name:string)=>void;go:(tab:string)=>void;ai:boolean};
export function Workspace({api,user,modules,open,go,ai}:Props){
const t=useTheme(),uri=usePrivateImage(api,imagePath(user.avatar));const hour=new Date().getHours(),greeting=hour<11?'早上好':hour<14?'中午好':hour<18?'下午好':'晚上好';
const {width,fontScale}=useWindowDimensions(),columns=workspaceColumns(width,fontScale);
const quick=['arrival','pending','use','move','count'].map(k=>modules.find(m=>m.key===k)).filter((m):m is Module=>!!m);
return <ScrollView contentContainerStyle={[s.page,{paddingTop:8,paddingBottom:20,gap:12}]}>
<View style={{flexDirection:'row',alignItems:'center',padding:16,gap:12,borderRadius:16,backgroundColor:t.hero}}><View style={{gap:4,flex:1,minWidth:0}}><Text style={{color:'#dfeaff',fontSize:13,lineHeight:19}}>{new Date().toLocaleDateString('zh-CN',{month:'long',day:'numeric',weekday:'long'})}</Text><Text style={{color:'#fff',fontSize:20,lineHeight:28,fontWeight:'700'}}>{greeting},{user.nickName||user.userName}</Text></View><Pressable accessibilityRole="button" accessibilityLabel="打开我的" onPress={()=>go('me')} style={{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'}}><Avatar name={user.nickName||user.userName} uri={uri} size={44}/></Pressable></View>
<View style={[s.row,{justifyContent:'space-between'}]}><Text style={{color:t.text,fontSize:17,lineHeight:24,fontWeight:'700'}}>常用操作</Text><Pressable accessibilityRole="button" accessibilityLabel="查看全部业务" onPress={()=>go('business')} style={{paddingHorizontal:4,minHeight:44,justifyContent:'center'}}><Text style={{color:t.accent,fontSize:14,lineHeight:21}}>全部业务 →</Text></Pressable></View>
<View style={{flexDirection:'row',flexWrap:'wrap',gap:12}}>{quick.map(m=><Pressable accessibilityRole="button" accessibilityLabel={m.title} key={m.key} onPress={()=>open(m.key)} style={({pressed})=>({flexBasis:columns===1?'100%':'47%',flexGrow:1,flexShrink:1,minWidth:0,padding:14,gap:8,borderRadius:14,backgroundColor:t.card,borderWidth:1,borderColor:t.line,opacity:pressed ? .7 : 1})}><View style={{flexDirection:'row',alignItems:'center',gap:8}}><View style={{padding:6,backgroundColor:t.soft,borderRadius:9,flexShrink:0}}><Icon name={icons[m.key]} size={22}/></View><Text style={{color:t.text,fontSize:16,fontWeight:'600',lineHeight:23,flex:1,minWidth:0}}>{m.title}</Text></View><Text style={{color:t.muted,fontSize:13,lineHeight:19}}>{hints[m.key]}</Text></Pressable>)}</View>
{!quick.length&&<Note>你的移动业务入口尚未配置,可请管理员协助确认工作范围。</Note>}
{ai&&<Pressable accessibilityRole="button" accessibilityLabel="与 AI 对话" onPress={()=>go('assistant')}><Card><View style={{flexDirection:'row',alignItems:'center',gap:12}}><Image source={require('../../assets/assistant.png')} style={{width:40,height:40,borderRadius:20}}/><View style={{flex:1,minWidth:0,gap:4}}><Text style={{color:t.text,fontSize:16,fontWeight:'700',lineHeight:23}}>不确定怎么操作?问我就好</Text><Text style={{color:t.muted,fontSize:13,lineHeight:19}}>说需求、传图片,也可以继续补充</Text></View><Icon name="arrow-forward" size={18}/></View></Card></Pressable>}
<Pressable accessibilityRole="button" accessibilityLabel="问题与建议" onPress={()=>open('feedback')} style={[s.row,{padding:10,justifyContent:'center',minHeight:44}]}><Icon name="chatbubble-ellipses-outline" size={17} color={t.muted}/><Text style={{color:t.muted,fontSize:13,lineHeight:20}}>遇到问题?告诉我们,让工作更顺畅</Text></Pressable>
</ScrollView>;
}
export function BusinessHub({modules,open}:{modules:Module[];open:(name:string)=>void}){
const t=useTheme();return <ScrollView contentContainerStyle={s.page}><Heading>在现场,也能从容处理</Heading><Note>常用现场操作优先,其他业务随时查询;提交前均先核对。</Note>{[['现场办理',['arrival','pending','use','move','count']],['查询与记录',['stock','purchase','production','in','out','loans','check']]].map(([label,keys])=>{const entries=(keys as string[]).map(key=>modules.find(m=>m.key===key)).filter((m):m is Module=>!!m);return entries.length?<View key={label as string} style={{gap:10,marginTop:6}}><Text style={{color:t.muted,fontSize:13,fontWeight:'600',paddingLeft:4}}>{label as string}</Text><Card>{entries.map((m,i)=><MenuItem key={m.key} title={m.title} detail={hints[m.key]} icon={icons[m.key]} onPress={()=>open(m.key)} last={i===entries.length-1}/>)}</Card></View>:null;})}{!modules.length&&<Note>暂未分配移动业务,可请管理员协助确认。</Note>}</ScrollView>;
}
export function Me({api,user,open}:{api:ApiClient;user:Row;open:(name:string)=>void}){
const t=useTheme(),uri=usePrivateImage(api,imagePath(user.avatar));return <ScrollView contentContainerStyle={s.page}><Pressable accessibilityRole="button" accessibilityLabel="个人资料" onPress={()=>open('profile')}><View style={[s.row,{paddingVertical:12,gap:16}]}><Avatar name={user.nickName||user.userName} uri={uri} size={70}/><View style={{flex:1,gap:7}}><Text style={{color:t.text,fontSize:24,fontWeight:'700'}}>{user.nickName||user.userName}</Text><Text style={{color:t.muted,fontSize:13}}>账号 {user.userName}</Text><Text style={{color:t.muted,fontSize:12}}>{user.dept?.deptName||'个人工作空间'}</Text></View><Icon name="chevron-forward" color={t.muted}/></View></Pressable>
<Card><MenuItem title="个人资料" detail="昵称、手机号码和邮箱" icon="person-outline" onPress={()=>open('profile')}/><MenuItem title="账号与密码" detail="管理当前账号的登录密码" icon="lock-closed-outline" onPress={()=>open('password')} last/></Card>
<Card><MenuItem title="消息中心" detail="查看站内消息、通知公告和未读提醒" icon="notifications-outline" onPress={()=>open('messages')} last/></Card>
<Card><MenuItem title="问题与建议" detail="发现问题、提出需求,支持添加图片" icon="chatbubble-ellipses-outline" onPress={()=>open('feedback')}/><MenuItem title="我的反馈" detail="查看处理进展与负责人回复" icon="receipt-outline" onPress={()=>open('feedback-list')} last/></Card>
<Card><MenuItem title="设置" detail="外观、内网连接及应用更新" icon="settings-outline" onPress={()=>open('settings')}/><MenuItem title="关于应用" icon="information-circle-outline" onPress={()=>open('about')} last/></Card>
<Text style={{color:t.muted,fontSize:11,textAlign:'center',letterSpacing:2,marginTop:8}}>CMVR · 让工作更简单</Text>
</ScrollView>;
}
export function Settings({updateText,environment,baseUrl,connection,logout,about=false}:{updateText:string;environment:string;baseUrl:string;connection?:React.ReactNode;logout:()=>void;about?:boolean}){
const t=useTheme(),{mode,setMode}=useContext(AppearanceContext);
return <ScrollView contentContainerStyle={s.page}>{about?<><View style={{alignItems:'center',paddingVertical:24,gap:12}}><View style={{backgroundColor:t.accent,padding:20,borderRadius:25}}><Icon name="layers-outline" color="#fff" size={43}/></View><Heading>CMVR 移动工作空间</Heading><Note>把业务带到现场,让协作更轻松。</Note></View><Card><Note>应用版本 {Constants.expoConfig?.version}</Note><Note>当前环境 {environment==='prod'?'正式环境':'开发环境'}</Note><Note>更新标识 {Updates.updateId?.slice(0,8)||'内置版本'}</Note></Card><Card><Heading>数据与安全</Heading><Note>业务数据来自公司内网服务。可见数据和可用操作由后台权限决定;AI 操作须经人工确认,查询直接返回。</Note><Note>请仅在可信的公司网络使用。不要在反馈或 AI 对话中填写密码和授权码。</Note></Card></>:<>
<Card><Heading>外观</Heading><Note>选择适合你的阅读方式。</Note><View style={s.row}>{([['system','跟随系统'],['light','浅色'],['dark','深色']] as const).map(([value,label])=><Button key={value} title={`${mode===value?'✓ ':''}${label}`} secondary={mode!==value} onPress={()=>setMode(value)}/>)}</View></Card>
{connection||<Card><Heading>内网连接</Heading><Note>当前:{environment==='prod'?'正式环境':'开发环境'}</Note><Text selectable style={{color:t.text,lineHeight:22}}>{baseUrl}</Text><Note>正式服务由安装包固定,避免误切环境。</Note></Card>}
<Card><Heading>应用更新</Heading><Note>{updateText}</Note><Note>启动时自动检查内网更新。下载完成后下次启动生效,不会中断当前表单。原生能力变更仍需安装新版。</Note><Note>版本 {Constants.expoConfig?.version} · {Updates.updateId?.slice(0,8)||'内置版本'}</Note></Card>
<Button title="退出登录" secondary onPress={logout}/>
</>}</ScrollView>;
}