wangxy 3 dienas atpakaļ
vecāks
revīzija
df952cb41d

+ 1 - 8
pages.json

@@ -324,17 +324,10 @@
 			}
 		},
 		{
-			"path" : "pages/admin/Hetong/components/search",
-			"style" : 
-			{
-				"navigationBarTitleText" : ""
-			}
-		},
-		{
 			"path" : "pages/admin/Hetong/addSanfangHetong",
 			"style" : 
 			{
-				"navigationBarTitleText" : ""
+					"navigationStyle": "custom"
 			}
 		}
 	],

+ 20 - 1
pages/admin/Hetong/addSanfangHetong.vue

@@ -1,7 +1,12 @@
 <template>
 	<view>
-		
+		<button @click="handleSelct('kh')">选择客户</button>
+		<button @click="handleSelct('jz')">选择家政</button>
 	</view>
+	<!-- 客户 -->
+	<selectKh ref="khRef"></selectKh>
+	<!-- 家政 -->
+	<selectJz ref="jzRef"></selectJz>
 </template>
 
 <script setup>
@@ -14,6 +19,20 @@
 		onLoad
 	} from "@dcloudio/uni-app";
 	import * as httpApi from "@/api/sanfang.js"
+	import selectKh from "./components/selectKh.vue"
+	import selectJz from "./components/selectJz.vue"
+	
+	const khRef = ref(null)
+	const jzRef = ref(null)
+	
+	function handleSelct(code) {
+		if (code == 'kh') {
+			khRef.value.handleShow();
+		} else {
+			jzRef.value.handleShow();
+		}
+	}
+	
 
 </script>
 

+ 114 - 79
pages/admin/Hetong/components/search.vue

@@ -1,99 +1,134 @@
 <template>
 	<uni-popup ref="searchPopup" type="top" :animation="false" :is-mask-click="true"
-	 mask-background-color="rgba(0, 0, 0, 0.4)">
-	   <view class="select-search-row">
-		   <view class="select-search-body">
-			  <view class="select-jt-box" @click="toggleMenu">
-				<view class="selected-item">{{ selectedOption.label }}</view>
-				<view class="arrow" :class="{ 'arrow-up': isMenuOpen, 'arrow-down': !isMenuOpen }"></view>
-			  </view>
-			  <view class="select-list-box" v-if="isMenuOpen">
-				<view
-				  v-for="(option, index) in options"
-				  :key="option.value"
-				  class="menu-item"
-				  @click="selectOption(option)"
-				>
-				  {{ option.label }}
+		mask-background-color="rgba(0, 0, 0, 0.4)">
+		<view class="select-search-row">
+			<view class="select-search-body">
+				<view class="select-jt-box" @click="toggleMenu">
+					<view class="selected-item">{{ selectedOption.label }}</view>
+					<view class="arrow" :class="{ 'arrow-up': isMenuOpen, 'arrow-down': !isMenuOpen }"></view>
+				</view>
+				<view class="select-list-box" v-if="isMenuOpen">
+					<view v-for="(option, index) in options" :key="option.value" class="menu-item"
+						@click="selectOption(option)">
+						{{ option.label }}
+					</view>
+				</view>
+				<input type="text" class="search-input" v-model="searchInput" :placeholder="searchPlaceholder" />
+				<view class="search-icon" @click="handleSearch">
+					<uni-icons type="search" size="24" color="#fff"></uni-icons>
 				</view>
-			  </view>
-			  <input type="text" class="search-input" v-model="searchInput" :placeholder="searchPlaceholder" />
-			  <view class="search-icon" @click="handleSearch">
-			  	<uni-icons type="search" size="24" color="#fff"></uni-icons>
-			  </view>	
 			</view>
 		</view>
 		<view class="search-clear-box" v-if="searchInput" @click="searchReset">
 			<icon></icon>
 			<text>清空搜索</text>
 		</view>
-  </uni-popup>
+	</uni-popup>
 </template>
 
 <script setup>
-import { ref } from 'vue';
-const $emit = defineEmits(['search-btn','reset-search'])
-const searchPopup = ref(null); // 索引
+	import {
+		ref,
+		computed
+	} from 'vue';
+	const $emit = defineEmits(['search-btn', 'reset-search'])
+	const searchPopup = ref(null); // 索引
+
+	const props = defineProps({
+		shenfen: {
+			type: String,
+		}
+	})
+
+	let arr = computed(() => {
+		if (props.shenfen == 'kh') {
+			return [{
+				label: '客户名',
+				value: 2
+			}, ]
+		} else if (props.shenfen == 'jz') {
+			return [{
+				label: '阿姨名',
+				value: 3
+			}]
+		} else {
+			return [{
+					label: '客户名',
+					value: 2
+				},
+				{
+					label: '阿姨名',
+					value: 3
+				}
+			]
+		}
+	})
+
+	let txt = computed(() => {
+		if (props.shenfen == 'kh') {
+			return '请输入客户名'
+		} else if (props.shenfen == 'jz') {
+			return '请输入家政阿姨名'
+		} else {
+			return '请输入客户名'
+		}
+	})
+
+
+	const options = ref(arr);
+	const searchPlaceholder = ref(txt);
+	const searchInput = ref('');
+	// 存储当前选中的选项对象
+	const selectedOption = ref(options.value[0]);
 
+	// 存储菜单是否打开的状态
+	const isMenuOpen = ref(false);
 
-const options = ref([
-	  { label: '客户名', value: 2 },
-	  { label: '阿姨名', value: 3 }
-	]);
-const searchPlaceholder= ref('请输入客户名');
-const searchInput= ref('');
-// 存储当前选中的选项对象
-const selectedOption = ref(options.value[0]);
- 
-// 存储菜单是否打开的状态
-const isMenuOpen = ref(false);
- 
-// 切换菜单打开/关闭状态的函数
-const toggleMenu = () => {
-  isMenuOpen.value = !isMenuOpen.value;
+	// 切换菜单打开/关闭状态的函数
+	const toggleMenu = () => {
+		isMenuOpen.value = !isMenuOpen.value;
 
-};
- 
-// 选择选项的函数
-const selectOption = (option) => {
-  selectedOption.value = option;
-  searchInput.value = '';
-  isMenuOpen.value = false; // 选择后关闭菜单
-  if ( option.value == 2) {
-	  searchPlaceholder.value = '请输入客户名'
-  } else {
-	  searchPlaceholder.value = '请输入家政阿姨名'
-  }
-};
+	};
 
-// 打开弹窗
-function handleShow() {
-	searchPopup.value.open();
-}
-// 取消
-function handleClose() {
-	searchInput.value = '';
-	searchPopup.value.close();
-}
-// 确认
-function handleSearch(){
-	let searchKey = '';
-	searchKey = selectedOption.value.value;
-	// 搜索 key和 data
-	$emit('search-btn',searchKey,searchInput);
-	searchPopup.value.close();
-}
+	// 选择选项的函数
+	const selectOption = (option) => {
+		selectedOption.value = option;
+		searchInput.value = '';
+		isMenuOpen.value = false; // 选择后关闭菜单
+		if (option.value == 2) {
+			searchPlaceholder.value = '请输入客户名'
+		} else {
+			searchPlaceholder.value = '请输入家政阿姨名'
+		}
+	};
 
-// 清空搜索
-function searchReset(){
-	searchInput.value = '';
-	$emit('reset-search');
-}
+	// 打开弹窗
+	function handleShow() {
+		searchPopup.value.open();
+	}
+	// 取消
+	function handleClose() {
+		searchInput.value = '';
+		searchPopup.value.close();
+	}
+	// 确认
+	function handleSearch() {
+		let searchKey = '';
+		searchKey = selectedOption.value.value;
+		// 搜索 key和 data
+		$emit('search-btn', searchKey, searchInput);
+		searchPopup.value.close();
+	}
 
+	// 清空搜索
+	function searchReset() {
+		searchInput.value = '';
+		$emit('reset-search');
+	}
 
-defineExpose({
-	handleShow,
-	handleClose
-})
-</script>
 
+	defineExpose({
+		handleShow,
+		handleClose
+	})
+</script>

+ 10 - 3
pages/admin/Hetong/components/selectJz.vue

@@ -2,7 +2,7 @@
 	<uni-popup ref="popupRef" type="bottom" background-color="#fff" :is-mask-click="false" :mask-click="false">
 		<view class="ht-qm-popup">
 			<view class="phone-navBar-box">
-				<view @click="goUpPage" class="nav-bar-icon"></view>
+				<view @click="goback2" class="nav-bar-icon"></view>
 				<text class="nav-bar-title">选择家政阿姨</text>
 				<uni-icons class="nav-bar-right-icon bar-ml10" type="search" size="20"
 					@click="toggle('top')"></uni-icons>
@@ -56,12 +56,14 @@
 	import {
 		getJiazhengList
 	} from "@/api/jiazheng.js"
-	import searchDialog from "./components/search.vue";
+	import searchDialog from "./search.vue";
 
 
 	const emits = defineEmits(['select'])
 
-	function goback2() {}
+	function goback2() {
+		popupRef.value.close();
+	}
 
 	const searchDialogRef = ref(null);
 	const popupRef = ref(null)
@@ -166,9 +168,14 @@
 	}
 
 	function handleShow() {
+		data.realName = '';
 		popupRef.value.open();
 		onRefresh();
 	}
+	
+	defineExpose({
+		handleShow
+	})
 </script>
 
 <style>

+ 14 - 7
pages/admin/Hetong/components/selectKh.vue

@@ -1,14 +1,14 @@
 <template>
 	<uni-popup ref="popupRef" type="bottom" background-color="#fff" :is-mask-click="false" :mask-click="false">
 		<view class="ht-qm-popup">
-			<view class="phone-navBar-box">
-				<view @click="goUpPage" class="nav-bar-icon"></view>
-				<text class="nav-bar-title">选择客户</text>
+				<view class="phone-navBar-box">
+				<view @click="goback2" class="nav-bar-icon"></view>
+				<text>选择客户</text>
 				<uni-icons class="nav-bar-right-icon bar-ml10" type="search" size="20"
 					@click="toggle('top')"></uni-icons>
 			</view>
 			<view>
-				<search-dialog ref="searchDialogRef" shenfen="jz" @search-btn="dialogSearchBtn"
+				<search-dialog ref="searchDialogRef" shenfen="kh" @search-btn="dialogSearchBtn"
 					@reset-search="dialogSearchReset"></search-dialog>
 			</view>
 			
@@ -41,7 +41,7 @@
 				</scroll-view>
 			</view>
 			<view>
-				<button @click="handleSelect">选择此家政阿姨</button>
+				<button @click="handleSelect">选择此客户</button>
 			</view>
 		</view>
 	</uni-popup>
@@ -57,11 +57,13 @@
 		onLoad
 	} from "@dcloudio/uni-app";
 	import * as httpApi from "@/api/sanfang.js"
-	import searchDialog from "./components/search.vue";
+	import searchDialog from "./search.vue";
 
 	const emits = defineEmits(['select'])
 
-	function goback2() {}
+	function goback2() {
+		popupRef.value.close();
+	}
 
 	const searchDialogRef = ref(null);
 	const popupRef = ref(null)
@@ -169,9 +171,14 @@
 	}
 
 	function handleShow() {
+		data.realName = '';
 		popupRef.value.open();
 		onRefresh();
 	}
+	
+	defineExpose({
+		handleShow
+	})
 </script>
 
 <style>

+ 5 - 1
pages/admin/Hetong/sanfangHetong.vue

@@ -149,7 +149,11 @@
 		onRefresh();
 	}
 
-	function handleAdd() {}
+	function handleAdd() {
+		uni.navigateTo({
+			url: '/pages/admin/Hetong/addSanfangHetong'
+		})
+	}
 
 	function dialogSearchBtn(opt, searchInput) {
 		if (opt == 2) {