filtrate-group.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. box-sizing: border-box;
  46. .title {
  47. line-height: 22px;
  48. font-family: PingFang SC, PingFang SC;
  49. font-weight: bold;
  50. font-size: 16px;
  51. color: #333333;
  52. }
  53. .options {
  54. display: flex;
  55. flex-wrap: wrap;
  56. .option {
  57. min-width: 80px;
  58. padding: 6px;
  59. font-family: PingFang SC, PingFang SC;
  60. text-align: center;
  61. font-size: 14px;
  62. color: #333333;
  63. margin: 10px 5px 0 0;
  64. background: #F2F2F2;
  65. border-radius: 5px;
  66. }
  67. .active {
  68. color: #FFFFFF;
  69. background: #C30D23;
  70. }
  71. }
  72. }
  73. </style>