| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- <template>
- <div>
- <el-dialog
- v-model="props.dialogVisible"
- :title="props.title"
- width="1000"
- append-to-body
- draggable
- >
- <el-select
- v-model="userId"
- filterable
- remote
- reserve-keyword
- placeholder="输入姓名,手机号,工号查找"
- :remote-method="remoteMethod"
- :loading="loading"
- style="width: 240px"
- clearable
- >
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="`${item.label}-${item.mobile}`"
- :value="item.value"
- >
- </el-option>
- </el-select>
- <div class="dialog-mian">
- <div v-show="userId == '' || userId == null">
- <el-tree
- ref="treeRef"
- style="max-width: 600px"
- class="filter-tree"
- :data="deptList"
- :props="defaultProps"
- :default-expand-all="true"
- :expand-on-click-node="false"
- @node-click="treeClick"
- >
- </el-tree>
- </div>
- <div>
- <el-radio-group v-model="userId" v-show="userId">
- <div style="display: flex; flex-direction: column">
- <el-radio
- v-for="item in options"
- :key="item.value"
- :value="item.value"
- style="margin-bottom: 15px"
- >
- <p style="margin: 0">{{ item.label }}</p>
- <p style="margin: 0">{{ item.value }}</p>
- </el-radio>
- </div>
- </el-radio-group>
- <el-radio-group v-model="treeReId" v-show="userList.length > 0 && !userId">
- <div style="display: flex; flex-direction: column">
- <el-radio
- v-for="item in userList"
- :key="item.id"
- :value="item.id"
- style="margin-bottom: 15px"
- >
- <p style="margin: 0">{{ item.name }}</p>
- <p style="margin: 0">{{ item.id }}</p>
- </el-radio>
- </div>
- </el-radio-group>
- </div>
- </div>
- <template #footer>
- <div class="dialog-footer">
- <el-button @click="dialogVisible = false">取消</el-button>
- <el-button type="primary" @click="submit">
- 确认
- </el-button>
- </div>
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup lang="ts">
- import { defineProps, ref, onMounted, defineEmits } from "vue";
- import api from "@/api";
- type tableType = {
- id: string;
- name: string;
- };
- const defaultProps = {
- children: "children",
- label: "name",
- };
- const props = defineProps<{
- dialogVisible: boolean;
- deptIds: Array<[]>;
- deptList: Array<tableType>;
- title: string;
- }>();
- interface ListItem {
- value: string;
- label: string;
- }
- const list = ref<ListItem[]>([]);
- const options = ref<ListItem[]>([]);
- const userId = ref<string>("");
- const loading = ref(false);
- const treeReId=ref<string>("");
- const emits=defineEmits(["closeDialog"]);
- const userList = ref<any[]>([]);
- const remoteMethod = (query: string) => {
- if (query) {
- loading.value = true;
- api.userApi
- .AllMemberList({
- name: query,
- })
- .then((res: any) => {
-
- if (res.code === 200) {
- // userList.value = res.data;
- let arr: any = [];
- res.data.forEach((item) => {
- arr.push({
- label: item.name,
- value: item.id,
- mobile: item.mobile,
- });
- });
- loading.value = false;
- options.value = arr;
- }
- });
- // setTimeout(() => {
- // loading.value = false
- // options.value = list.value.filter((item) => {
- // return item.label.toLowerCase().includes(query.toLowerCase())
- // })
- // }, 200)
- } else {
- options.value = [];
- }
- };
- function treeClick(node: any) {
- api.userApi
- .AllMemberList({
- deptId: node.id,
- })
- .then((res: any) => {
- if (res.code === 200) {
- userList.value = res.data;
- // options.value=arr
- }
- });
- }
- function submit(){
-
- if(props.title=='设置负责人'){
- if(userId.value){
-
- const obj=options.value.map((item:any)=>{
- if(item.value==userId.value){
- return {
- name:item.label,
- id:item.value,
- mobile:item.mobile
- }
- }
- })
- api.institutionApi.setDeptLeader({
- deptId:props.deptIds,
- leaderId:obj[0].userId
- }).then(res=>{
-
- if(res.code==200){
- emits('closeDialog')
- }
- })
-
-
- }else{
- let flag={}
- userList.value.some((item:any)=>{
-
- if( item.id==treeReId.value){
- flag={...item}
- return true
- }
- return false
-
- })
-
- api.institutionApi.setDeptLeader({
- deptId:props.deptIds,
- leaderId:flag.userId
- }).then(res=>{
- if(res.code==200){
- emits('closeDialog')
- }
- })
- // emits('closeDialog',flag)
- }
- }else{
- if(userId.value){
- const obj=options.value.map((item:any)=>{
- if(item.value==userId.value){
- return {
- name:item.label,
- id:item.value,
- mobile:item.mobile
- }
- }
- })
-
- emits('closeDialog',obj[0])
- }else{
- let flag={}
- userList.value.some((item:any)=>{
-
- if( item.id==treeReId.value){
- flag={...item}
- return true
- }
- return false
-
- })
- emits('closeDialog',flag)
- }
- }
-
-
- }
- </script>
- <style lang="scss" scoped>
- .dialog-mian {
- display: flex;
- border: 1px solid #ccc;
- border-radius: 10px;
- min-height: 500px;
- margin-top: 20px;
- > div {
- flex: 1;
- padding: 15px;
- box-sizing: border-box;
- max-height: 500px;
- overflow-y: auto;
- }
- > div:last-child {
- border-left: 1px solid #ccc;
- }
- }
- </style>
|