managerModal.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <!-- 模板区域 -->
  2. <template>
  3. <div>
  4. <el-dialog :close-on-click-modal="false" v-model="props.managerModal" title="选择管理人" width="40%" @close="cancel">
  5. <div class="flex a-c">
  6. <el-input v-model="searchValue" style="width: 240px;margin-right: 10px;" clearable placeholder="输入姓名,手机号,工号查找" />
  7. <el-button type="primary" @click='searchValueclick'>查询</el-button>
  8. </div>
  9. <div class="deptlist flex ">
  10. <div class="area" style="border-right: 1px solid #dcdfe6;" v-show="!searchValueShow">
  11. <el-tree style="max-width: 600px;" :data="props.deptOptions" :props="parentIdprops" :highlight-current="true"
  12. @node-click="handleNodeClick" />
  13. </div>
  14. <div class="area">
  15. <el-radio-group v-model="userId">
  16. <div class="flex f-c">
  17. <el-radio :value="item.userId" v-for="(item,index) in managerlist" @change="radioChange" :key="index" class="m-btn-20">
  18. <div>{{ item.name }}</div>
  19. <div>{{ item.userId }}</div>
  20. </el-radio>
  21. </div>
  22. </el-radio-group>
  23. </div>
  24. </div>
  25. <template #footer>
  26. <div class="dialog-footer">
  27. <el-button class="border-[#0083FF] color-[#0083FF]" plain @click="cancel">取消</el-button>
  28. <el-button type="primary" @click="save">
  29. 确定
  30. </el-button>
  31. </div>
  32. </template>
  33. </el-dialog>
  34. </div>
  35. </template>
  36. <!-- 行为区域 -->
  37. <script lang='ts' setup>
  38. import api from '@/api';
  39. import { ref, reactive } from 'vue'
  40. import { defineProps, defineEmits } from "vue";
  41. interface Tree {
  42. id: string
  43. children?: Tree[]
  44. }
  45. interface managerlist{
  46. id:string,
  47. userId:string,
  48. name:string,
  49. deptName:string,
  50. }
  51. const props = defineProps<{
  52. managerModal: boolean,
  53. deptOptions: string[]
  54. managerlist: managerlist[],
  55. }>();
  56. const parentIdprops = {
  57. expandTrigger: 'hover' as const,
  58. value: 'id',
  59. label: 'name',
  60. checkStrictly: true,
  61. }
  62. const emits = defineEmits(["cancel", 'save', 'DrawerOpen', 'query', 'NodeClick','radioChange']);
  63. const userId = ref()
  64. const username = ref()
  65. const deptName=ref();
  66. const searchValue=ref();
  67. const searchValueShow=ref(false);
  68. watch(searchValue,()=>{
  69. if(!searchValue.value){
  70. searchValueShow.value=false;
  71. }
  72. })
  73. const handleNodeClick = (data: Tree) => {
  74. emits('NodeClick', data.id)
  75. }
  76. const cancel = () => {
  77. emits('cancel')
  78. }
  79. const save = () => {
  80. emits('save',userId.value,username.value,deptName.value)
  81. }
  82. const searchValueclick=()=>{
  83. searchValueShow.value=true;
  84. emits('query',searchValue.value)
  85. }
  86. const radioChange=(value:any)=>{
  87. let name=props.managerlist.find(val=>val.userId==value)?.name;
  88. let deptname=props.managerlist.find(val=>val.userId==value)?.deptName;
  89. username.value=name;
  90. deptName.value=deptname;
  91. }
  92. </script>
  93. <!-- 样式区域 -->
  94. <style lang='scss' scoped>
  95. .deptlist {
  96. height: 400px;
  97. margin-top: 20px;
  98. border: 1px solid #dcdfe6;
  99. border-radius: 5px;
  100. .area {
  101. flex: 1;
  102. height: 100%;
  103. padding: 10px;
  104. overflow: auto;
  105. }
  106. }
  107. </style>