Răsfoiți Sursa

修改页面navbar

huangxw 1 săptămână în urmă
părinte
comite
212c340573

+ 23 - 7
src/components/ut-navbar/ut-navbar.vue

@@ -20,13 +20,15 @@
         </up-navbar>
         <view v-if="breadcrumb" class="bg-#EBF6EE pd2-10-24 f-s-24 c-#3FAD5B">
             <slot name="breadcrumb">
-                {{ breadcrumb }}
+                <template v-for="(item, index) in breads" :key="index">{{ index ? ' > ' : '' }}{{ item.title }}</template>
             </slot>
         </view>
     </view>
 </template>
 <script lang="ts" setup>
+import { usePagesStore } from '@/store/modules/pages';
 import { ref, onMounted } from 'vue';
+const pagesStore = usePagesStore();
 const props = withDefaults(
     defineProps<{
         title?: string;
@@ -35,7 +37,7 @@ const props = withDefaults(
         homeUrl?: string;
         leftText?: string;
         // 是否有面包屑
-        breadcrumb?: string;
+        breadcrumb?: boolean;
     }>(),
     {
         title: '',
@@ -43,7 +45,7 @@ const props = withDefaults(
         fixed: true,
         homeUrl: '/pages/index/index',
         leftText: '',
-        breadcrumb: '',
+        breadcrumb: true,
     }
 );
 
@@ -67,13 +69,27 @@ function handleBackClick() {
         uni.switchTab({ url: props.homeUrl });
     }
 }
-
 function handleHomeClick() {
     emit('home');
     uni.switchTab({ url: props.homeUrl });
 }
-onLoad(() => {
-    const currentPage = getCurrentPages().pop();
-    console.log(currentPage, 'currentPage');
+const breads = ref<any[]>([])
+const initPages = () => {
+    const pages = getCurrentPages()
+    // 获取当前页面
+    const currentPage: any = pages[pages.length - 1]
+    if (props.title || props.leftText) {
+        pagesStore.setPageTitle(currentPage.route, props.title || props.leftText);
+    }
+    breads.value = pages.map((item: any) => {
+        const route = item.route;        
+        return {
+            title: pagesStore.mapPages.get(route)?.title || '未命名页面',
+            route,
+        }
+    })
+};
+onMounted(() => {
+  initPages();
 });
 </script>

+ 1 - 1
src/pages.json

@@ -244,7 +244,7 @@
     "globalStyle": {
         "navigationStyle": "custom",
         "navigationBarTextStyle": "black",
-        "navigationBarTitleText": "uni-app",
+        "navigationBarTitleText": "中药材种植全链条追溯系统",
         "navigationBarBackgroundColor": "#F8F8F8",
         "backgroundColor": "#F8F8F8",
         "rpxCalcMaxDeviceWidth": 1920,

+ 1 - 1
src/plant/storage/storage-room/edit/index.vue

@@ -1,7 +1,7 @@
 <template>
     <z-paging ref="paging" bgColor="#F7F7F7" safe-area-inset-bottom paging-class="paging-btm-shadow" scroll-with-animation>
         <template #top>
-            <ut-navbar :title="did ? '编辑库房' : '新增库房'" :fixed="false" border :breadcrumb="`库房管理 > ${did ? '编辑库房' : '新增库房'}`"></ut-navbar>
+            <ut-navbar :title="did ? '编辑库房' : '新增库房'" :fixed="false" border ></ut-navbar>
         </template>
         <up-form class="p-rtv" labelPosition="top" :model="form" :rules="rules" labelWidth="auto" ref="upFormRef">
             <view class="pd-24">

+ 2 - 0
src/plant/storage/storage-room/list/index.vue

@@ -63,6 +63,7 @@
 <script setup lang="ts">
 import { useClientRequest } from '@/utils/request';
 import FormShelve from '../edit/models/form-shelve.vue';
+const title =  ref('库房管理');
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 const { pt_warehouse_type } = toRefs<any>(proxy?.useDict('pt_warehouse_type'));
 const paging = ref();
@@ -157,6 +158,7 @@ const submitFormShelveAdd = async (data: any) => {
     }
 };
 onMounted(() => {
+
     uni.$on('refreshStorageRoomList', () => {
         onRefresh();
     });

+ 48 - 0
src/store/modules/pages.ts

@@ -0,0 +1,48 @@
+import { defineStore } from 'pinia';
+import { ref } from 'vue';
+
+export const usePagesStore = defineStore(
+    'pagesStore',
+    () => {
+        const mapPages = ref<Map<string, any>>(new Map([
+            // 主包 pages
+            ['pages/index/index', { title: '首页' }],
+            ['pages/login/login', { title: '用户登录' }],
+            ['pages/plant/base/index', { title: '基地' }],
+            ['pages/plant/port/index', { title: '种养殖' }],
+            ['pages/production/index', { title: '生产端' }],
+            // 基地分包 plant/base
+            ['plant/base/base-list/index', { title: '基地列表' }],
+            ['plant/base/base-detail/index', { title: '基地详情' }],
+            ['plant/base/base-edit/index', { title: '添加基地' }],
+            ['plant/base/base-map/index', { title: '基地地图' }],
+            ['plant/base/gap-base-info/index', { title: 'GAP基地信息' }],
+            ['plant/base/gap-base-info-edit/index', { title: '添加GAP基地信息' }],
+            ['plant/base/gap-base-info-detail/index', { title: 'GAP基地详情' }],
+            ['plant/base/mark-swyq-base/index', { title: '标记三无一全基地' }],
+            ['plant/base/mark-swyq-base-detail/index', { title: '三无一全基地详情' }],
+            // 主营物种 plant/species
+            ['plant/species/config/index', { title: '配置主营物种' }],
+            // 种养殖 plant/port
+            ['plant/port/port-create/index', { title: '创建种养殖任务' }],
+            // 库存 plant/storage
+            ['plant/storage/storage-room/list/index', { title: '库房管理' }],
+            ['plant/storage/storage-room/edit/index', { title: '新增库房' }],
+            ['plant/storage/storage-room/detail/index', { title: '库房详情' }],
+            // 通用工具 tools
+            ['tools/map-draw-area/index', { title: '地图绘制面积图' }],
+            ['tools/map-gd/index', { title: '地图绘制面积图' }],
+            ['tools/select-cpy-member/index', { title: '选择企业成员' }],
+            ['tools/select-medicine/index', { title: '选择获评品种' }],
+            ['tools/select-gap-info/index', { title: '选择GAP获评信息' }],
+            ['tools/por-torganism/index', { title: '选择动植物类型' }],
+            // 审核端 audit/plant
+            ['audit/plant/base/audit-list/index', { title: '基地审核列表' }],
+            ['audit/plant/base/audit-detail/index', { title: '基地审核详情' }],
+        ]));
+        // 设置页面标题
+        function setPageTitle(route: string, title: string) {
+            mapPages.value.set(route, { title });
+        }
+        return { mapPages, setPageTitle };
+    });