<template>
<!-- 这是组建1 -->
<div>
<div class="box">
<el-button class="department-button" style="border: none;" @click="showModal" @mouseenter="handleMouseEnter"
@mouseleave="handleMouseLeave">
{{ selectedDepartment || '请选择部门> ' }}
<span title="selectedDepartment" v-show="showFullDepartment">{{ selectedDepartment }} </span>
</el-button>
<el-dialog :visible.sync="dialogVisible" width="100%">
<el-tree :data="treeData[0].children" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
</el-dialog>
</div>
<div class="box1" style="text-align: center;" v-show="!selectedDepartment">
请先选择部门,
<a @click="showModal">
去选择
</a>
</div>
</div>
</template>
<script>
import { zqueryDepartTreeList, enableTimeRange, queryMySubordinate } from '@/api/api'
export default {
data() {
return {
date: {},
dialogVisible: false,
treeData: [],
selectedDepartment: '',
showFullDepartment: false,
selectedDepartm: false,
defaultProps: {
label: 'title'
},
// 组件2参数
// param: { minDate: '', maxDate: '' }
param: ''
};
},
created() {
this.loadDepart();
this.loadDepart1()
},
methods: {
handleMouseEnter() {
this.showFullDepartment = true;
},
handleMouseLeave() {
this.showFullDepartment = false;
},
showModal() {
this.dialogVisible = true;
},
loadDepart() {
zqueryDepartTreeList().then(res => {
this.treeData = res.result;
this.initCheckedStatus(this.treeData[0].children); // 初始化选中状态
});
},
loadDepart1() {
enableTimeRange().then(res => {
});
},
handleNodeClick(node) {
if (node.children && node.children.length > 0) {
return;
}
const departId = node.id;
this.selectedDepartment = node.title;
this.dialogVisible = false;
console.log("店铺id", departId);
this.$emit('isUpdate', 'time_picker', { state: "data", val: departId })
// "endDate": this.formatDate(this.param.maxDate), "startDate": this.formatDate(this.param.minDate),
if (this.param != '') {
let data = this.param.split(' - ')
let startDay = data[0]
let endDay = data[1]
this.$emit('isUpdate', 'employee_schedule', { state: "load", val: true })
queryMySubordinate({ departId, startDay, endDay },).then(response => {
this.$emit('isUpdate', 'employee_schedule', { state: "load", val: false })
this.$emit('isUpdate', 'employee_schedule', { state: "data", val: response })
});
// this.handleItemClick(node);
}
},
// handleItemClick(clickedNode) {
// // 清空其他选择项的选中状态
// this.treeData[0].children.forEach(parentItem => {
// parentItem.children.forEach(childItem => {
// if (childItem !== clickedNode) {
// this.$set(childItem, 'checked', false);
// }
// });
// });
// if (!clickedNode.checked) {
// this.$set(clickedNode, 'checked', true);
// } else {
// this.$set(clickedNode, 'checked', false);
// }
// this.$forceUpdate(); // 强制更新组件
// },
// initCheckedStatus(nodes) {
// nodes.forEach(node => {
// node.children.forEach(child => {
// this.$set(child, 'checked', false); // 添加选中状态属性
// });
// });
// },
},
};
</script>
<style scoped>
/* 样式可以根据自己的需求进行调整 */
.box {
height: 100%;
overflow-y: hidden;
position: relative;
}
::v-deep .el-dialog__body {
padding: 0px;
}
.department-button {
max-width: 200px;
/* 设置按钮的最大宽度 */
overflow: hidden;
/* 隐藏溢出部分 */
text-overflow: ellipsis;
/* 使用省略号表示溢出的部分 */
white-space: nowrap;
/* 不换行 */
}
.department-button {
position: relative;
}
.department-button span {
display: none;
position: absolute;
top: 100%;
left: 0;
background-color: #fff;
padding: 5px;
border: 1px solid #ddd;
}
.department-button:hover span {
display: block;
}
.department-button {
position: relative;
}
.department-button span {
display: none;
position: absolute;
top: 100%;
left: 0;
background-color: #fff;
padding: 5px;
border: 1px solid #ddd;
}
.department-button:hover span {
display: block;
}
.el-button {
font-size: 3.3333vw;
}
.box1 {
position: absolute;
top: 69%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
</style>
选择部门>
今昔在2023-12-29 17:43
相关推荐
小阮的学习笔记3 分钟前
Vue3中使用LogicFlow实现简单流程图YBN娜3 分钟前
Vue实现登录功能阳光开朗大男孩 = ̄ω ̄=4 分钟前
CSS——选择器、PxCook软件、盒子模型杨荧6 分钟前
【JAVA毕业设计】基于Vue和SpringBoot的服装商城系统学科竞赛管理系统minDuck8 分钟前
ruoyi-vue集成tianai-captcha验证码小政爱学习!29 分钟前
封装axios、环境变量、api解耦、解决跨域、全局组件注入魏大帅。34 分钟前
Axios 的 responseType 属性详解及 Blob 与 ArrayBuffer 解析花花鱼40 分钟前
vue3 基于element-plus进行的一个可拖动改变导航与内容区域大小的简单方法k093344 分钟前
sourceTree回滚版本到某次提交EricWang13581 小时前
[OS] 项目三-2-proc.c: exit(int status)