瀏覽代碼

跳转处理

wuhb 3 月之前
父節點
當前提交
a85031ca80
共有 2 個文件被更改,包括 26 次插入6 次删除
  1. 25 5
      pages/apply/applyNew.uvue
  2. 1 1
      pages/apply/index.uvue

+ 25 - 5
pages/apply/applyNew.uvue

@@ -329,10 +329,6 @@
 	    return selectedItems.value.find((s: SelectedItem) => s.itemId === mdItem.itemId) != null
 	}
 
-	onMounted(() => {
-		loadCategories()
-	})
-	
 	const handleSearch = (): void => {
 	    page.value = 1
 	    loadItems()
@@ -380,6 +376,8 @@
 		result['wmPurchaseApplyLineList'] = applyLines
 		return result
 	}
+	// 来源页面
+	const fromIndexPage = ref<boolean>(false)
 
 	// 保存申请
 	const saveApplication = (): void => {
@@ -394,7 +392,13 @@
 		    // 清空已选列表
 		    selectedItems.value = []
 		    loadItems()
-		}).catch((e) => {  // 添加箭头 =>
+		    // 如果从index.uvue跳转过来,返回index.uvue
+		    if (fromIndexPage.value) {
+			    setTimeout(() => {
+				    uni.navigateBack()
+			    }, 1000)
+		    }
+		}).catch((e) => {
 		    console.log(e)
 			const error = e as UTSError
 			const errMsg = error?.message
@@ -423,12 +427,28 @@
 			// 清空已选列表
 			selectedItems.value = []
 			loadItems()
+			// 如果从index.uvue跳转过来,返回index.uvue
+			if (fromIndexPage.value) {
+				setTimeout(() => {
+					uni.navigateBack()
+				}, 1000)
+			}
 		}).catch((e) => {
 			const error = e as UTSError
 			const errMsg = error?.message
 			uni.showToast({ title: errMsg.toString(), icon: 'none' })
 		})
 	}
+	onMounted(() => {
+		loadCategories()
+	// 获取页面参数,判断是否从index.uvue跳转过来
+		const pages = getCurrentPages()
+		const currentPage = pages[pages.length - 1]
+		const options = currentPage.options
+		if (options != null && options.from == 'index') {
+			fromIndexPage.value = true
+		}
+	})
 </script>
 
 <style lang="scss">

+ 1 - 1
pages/apply/index.uvue

@@ -255,7 +255,7 @@
 
 	const handleRight = ():void=>{
 		uni.navigateTo({
-		    url: `/pages/apply/applyNew`
+		    url: `/pages/apply/applyNew?from=index`
 		})
 	}