picker-mixin-internal.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import pickerMixin from './picker-mixin'
  2. const pickerMixinInternal = {
  3. // 把内部picker暴露给外层组件
  4. inject: {
  5. RegisterPicker: { default: undefined },
  6. },
  7. created() {
  8. this.RegisterPicker?.(this)
  9. },
  10. mixins: [pickerMixin],
  11. props: {
  12. /**
  13. * 对话框的标题
  14. */
  15. title: {
  16. type: String,
  17. default: '请选择',
  18. },
  19. /**
  20. * 备选项label字段名
  21. */
  22. optionLabel: {
  23. type: String,
  24. default: 'name',
  25. },
  26. /**
  27. * 备选项value字段名
  28. */
  29. optionValue: {
  30. type: String,
  31. default: 'id',
  32. },
  33. /**
  34. * <p>备选项每行的渲染函数</p>
  35. * <pre>(item, direction) => vNode|string</pre>
  36. */
  37. render: {
  38. type: Function,
  39. default: function(item) {
  40. return item[this.optionLabel]
  41. },
  42. },
  43. /**
  44. * 设置对话框的props
  45. */
  46. modalProps: {
  47. type: Object,
  48. default: () => ({}),
  49. },
  50. },
  51. methods: {
  52. openPicker() {
  53. // tree-picker,通过this.$refs.picker获取
  54. // value-picker,通过this获取
  55. const picker = this.$refs.picker || this
  56. picker.inputClick()
  57. },
  58. },
  59. }
  60. export default pickerMixinInternal