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.
 
 
 
 
 
 

92 regels
2.2 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. <view style="white-space: normal;min-height: 54px;display: flex;align-items: center;justify-content: right;">
  11. <view style="line-height: 24px;">
  12. {{ display || displayPlaceholder }}
  13. </view>
  14. </view>
  15. </l-label>
  16. <!-- #endif -->
  17. </template>
  18. <script>
  19. export default {
  20. name: 'l-organize-picker',
  21. props: {
  22. value: { default: '' },
  23. type: {},
  24. title: {},
  25. required: {},
  26. placeholder: {},
  27. readonly: {},
  28. rootId: {},
  29. rootType: {},
  30. multiple: {}
  31. },
  32. methods: {
  33. click() {
  34. if (this.readonly) {
  35. return
  36. }
  37. this.ONCE('select-organize', data => {
  38. this.$emit('input', data.id||data.map(t=>t.id).toString())
  39. this.$emit('change', data.id||data.map(t=>t.id).toString())
  40. })
  41. const rootType = this.rootType || { user: 'department', department: 'company', company: 'company' }[this.type]
  42. const rootId = this.rootId
  43. let url_ = this.multiple?"select-organize-multiple":"select-organize"
  44. this.SET_PARAM(this.value)
  45. const url = rootId
  46. ? `/pages/common/${url_}?type=${this.type}&rootId=${rootId}&rootType=${rootType}`
  47. : `/pages/common/${url_}?type=${this.type}`
  48. this.NAV_TO(url)
  49. }
  50. },
  51. computed: {
  52. display() {
  53. if (!this.value) {
  54. return this.placeholder
  55. }
  56. const list = this.GET_GLOBAL(this.type)
  57. let values = this.value instanceof Array?this.value:this.value.split(",")
  58. if(values.length>1){
  59. const orgItems = values.map(t=>list[t]?list[t].name:'').toString()
  60. return orgItems
  61. }
  62. const orgItem = list[this.value]
  63. return orgItem ? orgItem.name : this.placeholder
  64. },
  65. displayPlaceholder() {
  66. if (this.readonly) {
  67. return ''
  68. }
  69. if (this.placeholder) {
  70. return this.placeholder
  71. }
  72. return this.title ? `请选择${this.title}` : '请选择…'
  73. }
  74. }
  75. }
  76. </script>