en-select.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="select sys-background-fff page-env-20">
  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" :class="item.id === current?'':'active'"
  14. v-for="(item,index) in localData" @click="onSelect(index)">
  15. <text class="size-28">{{item[itemText]}}</text>
  16. </view>
  17. </scroll-view>
  18. </view>
  19. <EnButton :is_fixed="true" text="确认" @onSubmit="setAffirm(true)"></EnButton>
  20. </view>
  21. </template>
  22. <script>
  23. import EnButton from "@/components/en-utils/en-button/en-button.vue";
  24. export default {
  25. name: 'peak_chart',
  26. props: {
  27. title: {
  28. type: String,
  29. default: '选择'
  30. },
  31. localData: {
  32. default: []
  33. },
  34. itemKey: {
  35. type: String,
  36. default: 'id'
  37. },
  38. itemText: {
  39. type: String,
  40. default: 'name'
  41. },
  42. value: {
  43. default: ''
  44. }
  45. },
  46. components: {
  47. EnButton
  48. },
  49. data() {
  50. return {
  51. current: -1,
  52. newValue: 0
  53. };
  54. },
  55. watch: {
  56. 'value': function() {
  57. if (this.current !== this.value) {
  58. this.current = this.value
  59. }
  60. }
  61. },
  62. methods: {
  63. setAffirm(type) {
  64. this.$emit('input', this.newValue)
  65. this.$emit('setAffirm', type)
  66. },
  67. onSelect(index) {
  68. this.current = index
  69. this.newValue = this.localData[index][this.itemKey]
  70. this.$emit('input', this.newValue)
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss">
  76. .select {
  77. height: 800rpx;
  78. border-radius: 20rpx 20rpx 0 0;
  79. }
  80. .icon {
  81. width: 40rpx;
  82. text-align: right;
  83. }
  84. .scroll-view-item {
  85. height: 90rpx;
  86. line-height: 90rpx;
  87. text-align: center;
  88. background: rgba(15, 177, 96, 0.1);
  89. border-radius: 10rpx;
  90. color: #0FB160;
  91. border: 1rpx solid #0FB160;
  92. margin: 16rpx 30rpx;
  93. }
  94. .active {
  95. border: none;
  96. color: #333333;
  97. background: #F7F9FE;
  98. }
  99. </style>