DesignatedPersonSelection.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <div>
  3. <el-select v-model="prop.form.designatedUserList" value-key="id" multiple placeholder="请选择人员"
  4. @click="dialogVisible = !disableType.contentDisable" :disabled="disableType.contentDisable">
  5. <el-option v-for="user in selectedUser" :key="user.id" :label="user.staffNo + '-' + user.realname"
  6. :value="user" />
  7. </el-select>
  8. <el-dialog v-model="dialogVisible" title="添加人员" align-center :close-on-click-modal="false" style="height: 583px"
  9. :width="731" :destroy-on-close="true" :append-to-body="true" class="workShopDialog">
  10. <!-- <SelectTree @cancel="handleCancle" @submit="handleSubmit" :selectedUser="selectedUser" /> -->
  11. <PersonFilterSelection @cancel="handleCancle" @submit="handleSubmit" :init-selected="selectedUser" />
  12. </el-dialog>
  13. </div>
  14. </template>
  15. <script lang="ts" setup>
  16. import { ref, onBeforeUpdate, watch } from 'vue';
  17. import { SelectedFilterPersonInfo } from '@/api/message/person-group';
  18. // import SelectTree from '@/views/message/persongroup/components/SelectTree.vue';
  19. import PersonFilterSelection from '@/views/message/components/PersonFilterSelection.vue';
  20. // interface UserList {
  21. // id: string;
  22. // name: string;
  23. // userId: number;
  24. // }
  25. const dialogVisible = ref<boolean>(false);
  26. const selectedUser = ref<SelectedFilterPersonInfo[]>([]);
  27. const prop = defineProps(['form', 'disableType']);
  28. const handleCancle = () => {
  29. dialogVisible.value = false;
  30. };
  31. const handleSubmit = (selectedData: SelectedFilterPersonInfo[]) => {
  32. selectedUser.value = selectedData;
  33. prop.form.designatedUserList = selectedUser.value;
  34. dialogVisible.value = false;
  35. };
  36. watch(
  37. () => prop.form.designatedUserList,
  38. (newSelected) => {
  39. selectedUser.value = newSelected;
  40. },
  41. { deep: true, immediate: true },
  42. );
  43. onBeforeUpdate(() => {
  44. if (prop.form.designatedUserList?.value?.length > 0) {
  45. selectedUser.value = prop.form.designatedUserList.map((item) => {
  46. return {
  47. id: item.userId,
  48. realname: item.userNickname,
  49. staffNo: item.userLoginName,
  50. };
  51. });
  52. }
  53. });
  54. </script>
  55. <style lang="scss" scoped>
  56. ::v-deep .el-dialog__body {
  57. height: 527px;
  58. }
  59. ::v-deep .el-select__selection {
  60. min-height: 25px;
  61. max-height: 60px;
  62. overflow-y: auto;
  63. }
  64. </style>