Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

86 righe
1.8 KiB

  1. <template>
  2. <!-- #ifndef MP-DINGTALK -->
  3. <l-label @click="click" :arrow="!readonly" :required="required" :title="title">
  4. {{ value || displayPlaceholder }}
  5. </l-label>
  6. <!-- #endif -->
  7. <!-- #ifdef MP-DINGTALK -->
  8. <l-label :arrow="!readonly" :required="required" :title="title">
  9. <text @click="click">{{ value || displayPlaceholder }}</text>
  10. </l-label>
  11. <!-- #endif -->
  12. </template>
  13. <script>
  14. /**
  15. * 弹层选择器
  16. *
  17. * 接受两个参数:
  18. * source: 弹层选单源数据
  19. * layerData: 弹层绑定定义
  20. *
  21. * 举例:
  22. * // 数据源,这里以数据字典里的公司类别来举例
  23. * source: this.GET_GLOBAL('dataDictionary').CompanyType
  24. *
  25. * // 需要展示在弹层页面中的字段
  26. * layerData: [
  27. * {
  28. * name: 'text', // 对应数据源中的字段
  29. * label: '公司类别', // 标题文本
  30. * value: 'F_CompanyName' // 对应要绑定到的字段
  31. * }, {
  32. * name: 'value',
  33. * label: '对应值',
  34. * value: 'F_CompanyId'
  35. * }
  36. * ]
  37. */
  38. export default {
  39. name: 'l-layer-picker',
  40. props: {
  41. value: { default: null },
  42. title: {},
  43. required: {},
  44. placeholder: {},
  45. readonly: {},
  46. source: { default: () => [] },
  47. layerData: { default: () => [] }
  48. },
  49. methods: {
  50. click() {
  51. if (this.readonly) {
  52. return
  53. }
  54. const { source, layerData } = this
  55. this.ONCE(`select-layer`, data => {
  56. this.$emit('input', data)
  57. this.$emit('change', data)
  58. })
  59. this.SET_PARAM({ source, layerData })
  60. this.NAV_TO('/pages/common/select-layer')
  61. }
  62. },
  63. computed: {
  64. displayPlaceholder() {
  65. if (this.readonly) {
  66. return ''
  67. }
  68. if (this.placeholder) {
  69. return this.placeholder
  70. }
  71. return this.title ? `请选择${this.title}` : '请选择…'
  72. }
  73. }
  74. }
  75. </script>