index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view class="jnpf-tree-select">
  3. <u-input input-align='right' type="select" :select-open="selectShow" v-model="innerValue"
  4. :placeholder="placeholder" @click="openSelect" />
  5. <Select v-model="selectShow" :selectedId="selectedId" ref="userTree" @close="handleClose()"
  6. @confirm="handleConfirm" />
  7. </view>
  8. </template>
  9. <script>
  10. import Select from './Select.vue';
  11. import {
  12. getMsgTemplate
  13. } from '@/api/portal/portal.js'
  14. import {
  15. login
  16. } from '@/api/common';
  17. export default {
  18. components: {
  19. Select
  20. },
  21. props: {
  22. modelValue: {
  23. default: ''
  24. },
  25. send: {
  26. type: String,
  27. default: ''
  28. },
  29. placeholder: {
  30. type: String,
  31. default: '请选择'
  32. },
  33. disabled: {
  34. type: Boolean,
  35. default: false
  36. },
  37. sendName: {
  38. type: String,
  39. default: '请选择'
  40. },
  41. },
  42. data() {
  43. return {
  44. selectShow: false,
  45. innerValue: '',
  46. selectedId: '',
  47. }
  48. },
  49. watch: {
  50. send: {
  51. handler(val) {
  52. if (!val) return this.innerValue = ''
  53. this.setDefault(val)
  54. },
  55. immediate: true
  56. }
  57. },
  58. methods: {
  59. setDefault(id) {
  60. this.innerValue = this.modelValue
  61. this.selectedId = id
  62. },
  63. openSelect() {
  64. if (this.disabled) return
  65. this.selectShow = true
  66. this.$refs.userTree.resetData()
  67. },
  68. handleConfirm(e) {
  69. this.selectedId = e.id;
  70. this.defaultValue = e.id
  71. this.innerValue = e.fullName
  72. this.$emit('update:modelValue', e.id)
  73. this.$emit('change', e.id, e.fullName)
  74. },
  75. handleClose() {
  76. this.selectShow = false
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .jnpf-tree-select {
  83. width: 100%;
  84. }
  85. </style>