en-select.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="select">
  3. <view class="title p-30 row-justify-sb">
  4. <view class="icon"></view>
  5. <text class="size-30 sys-weight-600">{{title}}</text>
  6. <view class="icon">
  7. <uni-icons :animation="animationData" class="dropdown-icon" type="closeempty" size="16"
  8. color="#666"></uni-icons>
  9. </view>
  10. </view>
  11. <view class="select">
  12. <scroll-view scroll-y="true" class="scroll-Y select">
  13. <view id="demo1" class="scroll-view-item" v-for="(item,index) in localData" @click="onSelect(index)">
  14. <text class="size-28 color-0FB160">{{item[itemText]}}</text>
  15. </view>
  16. </scroll-view>
  17. </view>
  18. <EnButton :is_fixed="false"></EnButton>
  19. </view>
  20. </template>
  21. <script>
  22. import EnButton from "@/components/en-utils/en-button/en-button.vue";
  23. export default {
  24. name: 'peak_chart',
  25. props: {
  26. title: {
  27. type: String,
  28. default: '选择'
  29. },
  30. localData: {
  31. default: []
  32. },
  33. itemKey:{
  34. type:String,
  35. default:'id'
  36. },
  37. itemText:{
  38. type:String,
  39. default:'name'
  40. },
  41. value:{
  42. default:''
  43. }
  44. },
  45. components: {
  46. EnButton
  47. },
  48. data() {
  49. return {
  50. current: 0,
  51. };
  52. },
  53. watch:{
  54. 'value':function () {
  55. if(this.current!==this.value){
  56. this.current=this.value
  57. }
  58. }
  59. },
  60. methods: {
  61. onSelect(index) {
  62. this.$emit('onChange', index)
  63. this.$emit('input', this.localData[index][this.itemKey])
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss">
  69. .select {
  70. height: 800rpx;
  71. }
  72. .icon {
  73. width: 40rpx;
  74. text-align: right;
  75. }
  76. .scroll-view-item {
  77. height: 90rpx;
  78. line-height: 90rpx;
  79. text-align: center;
  80. background: rgba(15, 177, 96, 0.1);
  81. border-radius: 10rpx;
  82. border: 1rpx solid #0FB160;
  83. margin: 16rpx 30rpx;
  84. }
  85. </style>