You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

76 lines
1.6 KiB

  1. <template>
  2. <!-- #ifdef MP-DINGTALK -->
  3. <l-label :arrow="!readonly" :required="required" :title="title">
  4. <text @click="click">{{ display || displayPlaceholder }}</text>
  5. </l-label>
  6. <!-- #endif -->
  7. <!-- #ifndef MP-DINGTALK -->
  8. <l-label @click="click" :arrow="!readonly" :required="required" :title="title">
  9. {{ display || displayPlaceholder }}
  10. </l-label>
  11. <!-- #endif -->
  12. </template>
  13. <script>
  14. export default {
  15. name: 'l-organize-picker',
  16. props: {
  17. value: { default: '' },
  18. type: {},
  19. title: {},
  20. required: {},
  21. placeholder: {},
  22. readonly: {},
  23. rootId: {},
  24. rootType: {}
  25. },
  26. methods: {
  27. click() {
  28. if (this.readonly) {
  29. return
  30. }
  31. this.ONCE('select-organize', data => {
  32. this.$emit('input', data.id)
  33. this.$emit('change', data.id)
  34. })
  35. const rootType = this.rootType || { user: 'department', department: 'company', company: 'company' }[this.type]
  36. const rootId = this.rootId
  37. const url = rootId
  38. ? `/pages/common/select-organize?type=${this.type}&rootId=${rootId}&rootType=${rootType}`
  39. : `/pages/common/select-organize?type=${this.type}`
  40. this.NAV_TO(url)
  41. }
  42. },
  43. computed: {
  44. display() {
  45. if (!this.value) {
  46. return this.placeholder
  47. }
  48. const orgItem = this.GET_GLOBAL(this.type)[this.value]
  49. return orgItem ? orgItem.name : this.placeholder
  50. },
  51. displayPlaceholder() {
  52. if (this.readonly) {
  53. return ''
  54. }
  55. if (this.placeholder) {
  56. return this.placeholder
  57. }
  58. return this.title ? `请选择${this.title}` : '请选择…'
  59. }
  60. }
  61. }
  62. </script>