From 7ed2a032d0724e68aec8af940f2ce0023a9f0eb7 Mon Sep 17 00:00:00 2001
From: sen <sen@qq.com>
Date: 星期三, 15 四月 2026 09:27:51 +0800
Subject: [PATCH] 修改调度单年月日

---
 ui/car_wx_app/components/nav/index.vue |  151 +++++++++++++++++++++++++++++---------------------
 1 files changed, 87 insertions(+), 64 deletions(-)

diff --git a/ui/car_wx_app/components/nav/index.vue b/ui/car_wx_app/components/nav/index.vue
index e131452..871c23f 100644
--- a/ui/car_wx_app/components/nav/index.vue
+++ b/ui/car_wx_app/components/nav/index.vue
@@ -1,113 +1,136 @@
 <template>
-  <u-navbar :bgColor="bgColor" :left-icon="leftIcon"
-            :leftIconColor="leftIconColor"  :leftText="leftText"
-            :isShowLeft="isShowLeft" :placeholder="true"
-            :title="title" :titleStyle="titleStyle"
-            @leftClick="leftClick"
+  <u-navbar
+    :bgColor="bgColor"
+    :left-icon="leftIcon"
+    :leftIconColor="leftIconColor"
+    :leftText="leftText"
+    :isShowLeft="isShowLeft"
+    :placeholder="true"
+    :title="displayTitle"
+    :titleStyle="titleStyle"
+    @leftClick="leftClick"
   >
-    <view
-        class="u-nav-slot"
-        slot="right"
-    >
-      <u-icon :color="rightIconColor" @click="rightIconClick"
-          :name="rightIcon"
-          size="20"
-      ></u-icon>
+    <view v-if="rightIcon" class="u-nav-slot" slot="right">
+      <u-icon
+        :color="rightIconColor"
+        @click="rightIconClick"
+        :name="rightIcon"
+        size="20"
+      />
     </view>
   </u-navbar>
 </template>
 
 <script>
+import { navigateBack, navigateToBack, getPageParams } from '@/common/router'
+
 export default {
-  name: "index",
-  props:{
-    title:{
+  name: 'NavBar',
+  props: {
+    // 鏍囬 - 鍙互鐩存帴浼犲瓧绗︿覆锛屾垨浠庨〉闈㈠弬鏁颁腑璇诲彇
+    title: {
       type: String,
       default: ''
     },
-    leftText:{
+    // 鏍囬瀛楁鍚� - 濡傛灉浠庨〉闈㈠弬鏁颁腑璇诲彇锛屾寚瀹氬瓧娈靛悕
+    titleKey: {
+      type: String,
+      default: 'title'
+    },
+    leftText: {
       type: String,
       default: ''
     },
-    leftIconColor:{
+    leftIconColor: {
       type: String,
       default: '#fff'
     },
-    leftIcon:{
+    leftIcon: {
       type: String,
       default: 'arrow-left'
     },
-
-    bgColor:{
+    bgColor: {
       type: String,
-      default: '#409effc1'
+      default: '#409eff'
     },
-    isShowLeft:{
+    isShowLeft: {
       type: Boolean,
       default: true
     },
-    customBack:{
+    // 鑷畾涔夎繑鍥炶矾寰� - 鍙互鏄〉闈㈤敭鍚嶆垨璺緞
+    customBack: {
       type: String,
       default: ''
     },
-    customType:{
+    // 杩斿洖鏂瑰紡: navigateBack(榛樿杩斿洖涓婁竴椤�) | navigateTo(璺宠浆鍒版寚瀹氶〉)
+    backType: {
       type: String,
-      default: 'redirectTo'
+      default: 'navigateBack',
+      validator: (value) => ['navigateBack', 'navigateTo'].includes(value)
     },
-    rightIcon:{
+    rightIcon: {
       type: String,
       default: ''
     },
-    rightIconColor:{
+    rightIconColor: {
       type: String,
       default: '#fff'
-    },
-    rightClick:{
-      default:()=>{}
     }
   },
-  data(){
-    return{
-      titleStyle:{
-        color: "#fff"
+  data() {
+    return {
+      pageParams: {}
+    }
+  },
+  computed: {
+    // 鏈�缁堟樉绀虹殑鏍囬
+    displayTitle() {
+      // 浼樺厛浣跨敤 props 浼犲叆鐨� title
+      if (this.title) {
+        return this.title
+      }
+      // 鍏舵浠庨〉闈㈠弬鏁颁腑璇诲彇
+      if (this.pageParams[this.titleKey]) {
+        return this.pageParams[this.titleKey]
+      }
+      return ''
+    },
+    // 鏍囬鏍峰紡
+    titleStyle() {
+      return {
+        color: '#fff',
+        fontSize: '16px',
+        fontWeight: 500
       }
     }
   },
-  methods:{
-    leftClick(){
-      if (this.customBack){
-        if (this.customType == 'navigateBack'){
-          console.log('杩斿洖')
-          uni.navigateBack({
-            delta: 1,
-            success: function () {
-              console.log('杩斿洖鎴愬姛')
-            },
-            fail: function (e) {
-              console.log(e)
-            }
-          });
-        }else{
-          uni.$u.route({
-            url: this.customBack,
-            type: this.customType
-          }).catch(e=>{
-            console.log(e)
-          })
-        }
-      }else{
-        uni.redirectTo();
+  mounted() {
+    // 鑾峰彇椤甸潰鍙傛暟
+    this.pageParams = getPageParams()
+  },
+  methods: {
+    leftClick() {
+      // 濡傛灉鐖剁粍浠剁洃鍚簡 back 浜嬩欢锛岀敱鐖剁粍浠舵帴绠¤繑鍥為�昏緫
+      if (this.$listeners && this.$listeners.back) {
+        this.$emit('back')
+        return
+      }
+      if (this.customBack) {
+        navigateToBack(this.customBack)
+      } else {
+        navigateBack()
       }
     },
-	rightIconClick(){
-    console.log(1)
-		// this.rightClick();
-    this.$emit('rightClick')
+    rightIconClick() {
+      this.$emit('rightClick')
     }
   }
 }
 </script>
 
 <style scoped>
-
+.u-nav-slot {
+  display: flex;
+  align-items: center;
+}
 </style>

--
Gitblit v1.8.0