index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <view class="single-drop-list" @click="show = true">
  3. <u--input
  4. v-model="name"
  5. disabled
  6. disabledColor="#ffffff"
  7. :placeholder="placeholder"
  8. border="none"
  9. ></u--input>
  10. <u-icon
  11. slot="right"
  12. name="arrow-right"
  13. ></u-icon>
  14. <u-action-sheet
  15. :show="show"
  16. :actions="src"
  17. :title="placeholder"
  18. @close="show = false"
  19. @select="onSelect"
  20. >
  21. </u-action-sheet>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. name: 'single-drop-list',
  27. props: {
  28. src: {
  29. type: Array,
  30. default: () => [],
  31. },
  32. defaultValue: {
  33. type: String,
  34. default: () => {},
  35. },
  36. placeholder: {
  37. type: String,
  38. default: '选择参会企业',
  39. },
  40. onChange: {
  41. type: Function,
  42. default: () => {},
  43. },
  44. },
  45. data() {
  46. return {
  47. show: false,
  48. name: '',
  49. value: '',
  50. };
  51. },
  52. watch: {
  53. src: {
  54. handler(val) {
  55. if (val && val.length > 0 && this.defaultValue) {
  56. const defItem = val.find((item) => item.value === this.defaultValue);
  57. this.name = defItem.name;
  58. }
  59. },
  60. immediate: true,
  61. },
  62. },
  63. created() {
  64. },
  65. mounted() {
  66. },
  67. methods: {
  68. onSelect(item) {
  69. this.name = item.name;
  70. this.onChange(item);
  71. },
  72. },
  73. };
  74. </script>
  75. <style lang="scss" src="./index.scss" />