index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div :class="ui" class="hc-report-tasks-user-box">
  3. <div class="tag-user-list" @click="userShowModal">
  4. <template v-for="(item, index) in userData" :key="index">
  5. <el-tag>{{ item.userName }}</el-tag>
  6. <hc-icon v-if="(userData.length - 1) > index" name="arrow-right" ui="arrow-icon-tag" />
  7. </template>
  8. <div v-if="userData.length <= 0" class="tasks-placeholder">点击这里选择任务人</div>
  9. </div>
  10. <!-- 选择任务人 -->
  11. <HcUserModal v-model="isUserModalShow" :data="userData" :datas="dataInfo" @finish="fixedUserFinish" />
  12. </div>
  13. </template>
  14. <script setup>
  15. import { ref, watch } from 'vue'
  16. import { arrToKey, deepClone, getObjValue } from 'js-fast-way'
  17. import HcUserModal from './user-modal.vue'
  18. //参数
  19. const props = defineProps({
  20. ui: {
  21. type: String,
  22. default: '',
  23. },
  24. data: {
  25. type: Object,
  26. default: () => ({}),
  27. },
  28. })
  29. //事件
  30. const emit = defineEmits(['change'])
  31. //监听基础数据
  32. const dataInfo = ref(props.data)
  33. watch(() => props.data, (data) => {
  34. dataInfo.value = getObjValue(data)
  35. }, { deep: true, immediate: true })
  36. //展开弹窗
  37. const isUserModalShow = ref(false)
  38. const userShowModal = () => {
  39. isUserModalShow.value = true
  40. }
  41. //选择完成
  42. const userData = ref([])
  43. const fixedUserFinish = (data) => {
  44. const res = deepClone(data)
  45. userData.value = res
  46. const userIds = arrToKey(res, 'userId', ',')
  47. emit('change', userIds)
  48. }
  49. </script>
  50. <style lang="scss">
  51. @import './index.scss';
  52. </style>