filtrate-group.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <view class="group-box">
  3. <view class="title" v-if="item.title">{{ item.title }}</view>
  4. <view class="options">
  5. <view class="option" :class="(option[item.selected] == item.value) ? 'active' : ''" v-for="option in item.rang"
  6. :key="option[item.selected]" hover-class="navigator-hover" @click="change(option)">
  7. {{ option[item.showKey || item.selected] }}
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. props: {
  15. item: {
  16. type: Object
  17. },
  18. rowIndex: {
  19. type: [String, Number]
  20. },
  21. onChange: {
  22. type: Function
  23. }
  24. },
  25. watch: {
  26. item(val) {
  27. console.log(val)
  28. }
  29. },
  30. data() {
  31. return {
  32. show: true
  33. }
  34. },
  35. methods: {
  36. change(option) {
  37. this.$emit("onChange", option, this.rowIndex)
  38. }
  39. },
  40. }
  41. </script>
  42. <style lang="scss">
  43. .group-box {
  44. padding: 10px;
  45. padding-left: 0px;
  46. box-sizing: border-box;
  47. .title {
  48. line-height: 22px;
  49. font-family: PingFang SC, PingFang SC;
  50. font-weight: bold;
  51. font-size: 16px;
  52. color: #333333;
  53. box-sizing: border-box;
  54. padding-left: 10px;
  55. }
  56. .options {
  57. display: flex;
  58. flex-wrap: wrap;
  59. box-sizing: border-box;
  60. padding-left: 5px;
  61. .option {
  62. min-width: 72px;
  63. padding: 6px;
  64. font-family: PingFang SC, PingFang SC;
  65. text-align: center;
  66. font-size: 14px;
  67. color: #333333;
  68. margin: 10px 0 0 5px;
  69. background: #F2F2F2;
  70. border-radius: 5px;
  71. }
  72. .active {
  73. color: #FFFFFF;
  74. background: #C30D23;
  75. }
  76. }
  77. }
  78. </style>