wangxy 1 miesiąc temu
rodzic
commit
57d07aadb8

+ 91 - 0
components/dialog/contentDialog.vue

@@ -0,0 +1,91 @@
+<template>
+	<uni-popup ref="commonPopup" :animation="false" :is-mask-click="false" mask-background-color="rgba(0, 0, 0, 0.4)">
+		<view class="phone-common-dialog">
+			<view class="common-body-box">
+				<view class="common-title">{{title}}</view>
+				<view class="common-content" :class="dialogContentClass">
+					<slot></slot>
+				</view>
+				<view class="common-btn-box" v-if="showBtn">
+					<view class="not-confirm-btn" @click="handleClose">{{notBtn}}</view>
+					<view class="confirm-btn" @click="confirmBtn">{{okBtn}}</view>
+				</view>
+			</view>
+		</view>
+	<!-- 	<view class="popup-content" :class="{ 'popup-height': type='bottom' }">
+			<slot></slot>
+		</view> -->
+	</uni-popup>
+
+</template>
+
+<script setup>
+	import {
+		reactive,
+		ref
+	} from 'vue';
+	import {
+		getJiazhengZhiye
+	} from "@/api/jiazheng.js"
+
+
+	const props = defineProps({
+		type: {
+			type: String,
+			default: 'bottom'
+		},
+		title: {
+			type: String,
+			default: ''
+		},
+		content: {
+			type: String,
+			require: true,
+			default: ''
+		},
+		dialogContentClass: {
+			type: String,
+			require: true,
+			default: 'content-center-class'
+		},
+		notBtn: {
+			type: String,
+			require: true,
+			default: '取消'
+		},
+		okBtn: {
+			type: String,
+			require: true,
+			default: '确认'
+		},
+		showBtn: {
+			type: Boolean,
+			default: true
+		}
+	});
+	const commonPopup = ref(null); // 索引
+	const $emit = defineEmits(['confirm-btn'])
+
+
+	// 打开弹窗
+	function handleShow() {
+		commonPopup.value.open();
+	}
+	// 取消
+	function handleClose() {
+		commonPopup.value.close();
+	}
+	// 确认
+	function confirmBtn() {
+		$emit('confirm-btn');
+		commonPopup.value.close();
+	}
+
+	defineExpose({
+		handleShow,
+		handleClose
+	})
+</script>
+
+<style>
+</style>

+ 156 - 0
components/selectZyLevel/index.vue

@@ -0,0 +1,156 @@
+<template>
+	<contentDialogVue ref="commonPopup" @confirm-btn="confirmBtn" title="选择职业">
+		<!-- 技能块展示 -->
+		<view v-for="item in data.list" :key="item.id" class="phone-radio-item"
+			:class="{ radioActive: !!item.zyLevelName }" @click="toggleSelect(item)">
+			{{ item.name }}
+			<view class="radio-item-tag" v-if="!!item.zyLevelName">{{item.zyLevelName[0]}}</view>
+		</view>
+	</contentDialogVue>
+	<!-- 弹窗 -->
+	<contentDialogVue ref="commonPopup2" :showBtn="false" title="请选择职业等级">
+		<!-- 等级选择 -->
+		<view v-for="item in data.zyLevelList" :key="item.id" @click="handleSelectLevelId(item)">
+			{{item.name}}
+		</view>
+	</contentDialogVue>
+</template>
+
+<script setup>
+	import {
+		reactive,
+		ref
+	} from 'vue';
+	import {
+		getJiazhengZhiye,
+		getJiazhengLevel
+	} from "@/api/jiazheng.js"
+	import contentDialogVue from '@/components/dialog/contentDialog.vue';
+
+
+	const props = defineProps({
+		title: {
+			type: String,
+			default: ''
+		},
+		content: {
+			type: String,
+			require: true,
+			default: ''
+		},
+		dialogContentClass: {
+			type: String,
+			require: true,
+			default: 'content-center-class'
+		},
+		notBtn: {
+			type: String,
+			require: true,
+			default: '取消'
+		},
+		okBtn: {
+			type: String,
+			require: true,
+			default: '确认'
+		},
+		id: {
+			type: Number,
+		}
+	});
+
+	const commonPopup = ref(null);
+	const commonPopup2 = ref(null);
+	const $emit = defineEmits(['confirm-btn'])
+
+	const data = reactive({
+		list: [],
+		// item: {
+		// 	zyId: null,
+		// 	zyName: null,
+		// 	zyLevel: null,
+		// 	zyLevelName: null
+		// }
+		activeId: null, // 激活的zyId
+		zyLevelList: [],
+	})
+
+
+
+	// 打开弹窗
+	function handleShow(mdata) {
+		getZyList(mdata)
+
+	}
+	// 取消
+	function handleClose() {
+		commonPopup.value.handleClose();
+	}
+	// 确认
+	function confirmBtn() {
+		$emit('confirm-btn', data.list.filter(item => item.zyLevelName));
+	}
+
+	function getZyList(alreadySelect) {
+		getJiazhengZhiye({
+			id: props.id
+		}).then(res => {
+			data.list = res.data.map(item => {
+				if (alreadySelect) {
+					const da1 = alreadySelect.find(ite => ite.zyId == item.id);
+					if (da1) {
+						return {
+							id: item.id,
+							name: item.name,
+							zyLevel: da1.zyLevel,
+							zyLevelName: da1.zyLevelName
+						}
+					}
+				}
+				return {
+					id: item.id,
+					name: item.name,
+					zyLevel: null,
+					zyLevelName: null
+				}
+			})
+			commonPopup.value.handleShow();
+		})
+	}
+
+	function toggleSelect(item) {
+		if (item.zyLevelName) {
+			item.zyLevel = null;
+			item.zyLevelName = null
+		} else {
+			data.activeId = item.id;
+			getLevelList(item);
+		}
+	}
+
+	function getLevelList() {
+		getJiazhengLevel({jgId: props.id,zyId: data.activeId}).then(res => {
+			data.zyLevelList = res.data;
+			commonPopup2.value.handleShow();
+		})
+	}
+
+	function handleSelectLevelId(item) {
+		data.list.map(ite => {
+			if (ite.id === data.activeId) {
+				ite.zyLevel = item.id;
+				ite.zyLevelName = item.name
+			}
+			return ite;
+		})
+		commonPopup2.value.handleClose()
+	}
+
+	defineExpose({
+		handleShow,
+		handleClose
+	})
+</script>
+
+<style scoped>
+
+</style>

+ 7 - 0
pages.json

@@ -266,6 +266,13 @@
 			{
 				"navigationStyle": "custom"
 			}
+		},
+		{
+			"path" : "pages/demo/demo2",
+			"style" : 
+			{
+				"navigationBarTitleText" : ""
+			}
 		}
 	],
 	"tabBar": {

+ 8 - 0
pages/admin/ShouYe/shouye.vue

@@ -47,6 +47,10 @@
 		 	<icon class="index-icon zjz-icon"></icon>
 		 	<text>子家政公司</text>
 		 </view>
+<!--		 <view @click="goToPage('demo')" class="card-item-box" v-if="auth.type == 2">
+		 	<icon class="index-icon zjz-icon"></icon>
+		 	<text>demo</text>
+		 </view>-->
 	  </view>
 	  <view class="card-list-box">  
 		<view class="card-list-title">管理考证人员</view>
@@ -224,6 +228,10 @@ function tjBtnClick(data){
 				uni.redirectTo({
 					url:'/pages/admin/zijiazheng/index'
 				})
+			case 'demo':	
+				uni.redirectTo({
+					url:'/pages/demo/demo2'
+				})
 				break;
 		}
 	}

+ 21 - 0
pages/demo/demo2.vue

@@ -0,0 +1,21 @@
+<template>
+	<button @click="handleClis">激活</button>
+	<selectZyLevel ref="selectRef" @confirm-btn="onConfirm" :id="13"></selectZyLevel>
+</template>
+
+<script setup>
+import selectZyLevel from "@/components/selectZyLevel/index.vue"
+import {ref} from "vue"
+
+const selectRef = ref(null)
+function handleClis() {
+	selectRef.value.handleShow()
+}
+function onConfirm(list) {
+	console.log('list', list)
+}
+</script>
+
+<style>
+
+</style>