完善入库跳转以及出库创建页面

This commit is contained in:
zx
2026-04-07 10:55:39 +08:00
parent ce6d5e5d6e
commit b16dd22d70
16 changed files with 514 additions and 166 deletions

View File

@@ -3,73 +3,117 @@
<view class="nav-placeholder" :style="{ height: navHeight + 'px' }"></view>
<view class="navbar" :style="{ paddingTop: statusBarHeight + 'px' }">
<view class="left" @click="goBack">
<uni-icons type="left" size="18" />
</view>
<!-- 中间标题 -->
<!-- 标题 -->
<view class="title">{{ title }}</view>
<!-- 右侧父组件传入插槽 -->
<!-- 右侧插槽 -->
<view class="right">
<slot name="right"></slot>
</view>
</view>
<view class="content">
</view>
<view class="content"></view>
</template>
<script setup>
import { ref, onMounted, toRefs } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app';
import { onLoad } from '@dcloudio/uni-app'
import { getTabBarList } from '../until'
import { find, findIndex } from 'lodash'
const props = defineProps({
title: { type: String, default: '' },
backUrl: { type: String, default: '' },
title: {
type: String,
default: ''
},
backUrl: {
type: String,
default: ''
},
showBack: {
type: Boolean,
default: true
}
})
const { backUrl, title, showBack } = toRefs(props)
// 状态栏 + 导航栏高度
const statusBarHeight = ref(0)
const navHeight = ref(0)
const back = ref('')
const { backUrl, title } = toRefs(props)
onMounted(() => {
const res = uni.getSystemInfoSync()
statusBarHeight.value = res.statusBarHeight
navHeight.value = res.statusBarHeight + 44
})
// 接收id 且修改标题
onLoad(() => {
const pages = getCurrentPages()
if (pages.length >= 2) {
const prevPage = pages?.[pages.length - 2]
back.value = backUrl.value ? backUrl.value : prevPage.route
console.log(back.value, prevPage, pages, ' back.value');
// 返回目标路由
const backTarget = ref('')
const isTabBar = ref('')
// 获取系统信息
onMounted(() => {
try {
const res = uni.getSystemInfoSync()
statusBarHeight.value = res.statusBarHeight || 0
// 标准导航栏高度 44px + 状态栏 = 总高度
navHeight.value = statusBarHeight.value + 44
} catch (e) {
console.warn('获取系统信息失败', e)
}
})
//页面加载时获取上一页路由
onLoad(() => {
const tabList = getTabBarList()
const isTabBarNav = findIndex(tabList, (i) => i.pagePath == backUrl.value) != -1
isTabBar.value = isTabBarNav
if (backUrl.value) {
backTarget.value = backUrl.value
return
}
try {
const pages = getCurrentPages()
if (pages && pages.length >= 2) {
const prevPage = pages[pages.length - 2]
backTarget.value = prevPage.route || ''
}
} catch (e) {
console.warn('获取页面栈失败', e)
}
})
// 返回
const goBack = () => {
console.log(back.value, back.value);
if (back.value) {
uni.navigateTo({
url: `/${back.value}`,
});
// 返回逻辑
const goBack = () => {
if (!showBack.value) return;
if (backTarget.value) {
const url = backTarget.value.startsWith('/') ? backTarget.value : `/${backTarget.value}`;
if (isTabBar.value) uni.switchTab({ url: url })
else uni.navigateTo({ url: url })
} else {
// 无目标路由 正常返回
uni.navigateBack()
}
}
</script>
<style scoped lang="scss">
/* 导航栏占位:撑开页面内容,不被遮挡 */
.nav-placeholder {
width: 100%;
}
/* 导航栏主体fixed 固定在顶部 */
.navbar {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 70px;
// 高度由 状态栏 + 44px 决定,不要写死 70px
height: 44px;
background: #fff;
display: flex;
align-items: center;
@@ -77,21 +121,24 @@ const goBack = () => {
padding: 0 20rpx;
box-sizing: border-box;
z-index: 999;
// margin-bottom: 8px;
}
.left {
display: flex;
align-items: center;
}
.back-txt {
margin-left: 6rpx;
justify-content: center;
width: 40rpx;
height: 100%;
}
.title {
font-size: 14px;
font-size: 16rpx;
font-weight: bold;
color: #333;
max-width: 400rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.right {
@@ -101,7 +148,8 @@ const goBack = () => {
justify-content: flex-end;
}
.nav-placeholder {
.content {
width: 100%;
box-sizing: border-box;
}
</style>