fs-action.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <fs-popup direction="bottom" height="auto" v-model="visible" :showMask="showMask" :maskClickable="maskClickable">
  3. <view class="fs-action">
  4. <view class="fs-action-item" v-for="(item, index) in list" :key="index" @click="handleAction(item)">{{item.name}}</view>
  5. <view class="fs-action-extra">
  6. <slot></slot>
  7. </view>
  8. <view class="fs-action-cancel" v-if="showCancel" @click="cancel">{{cancelText}}</view>
  9. </view>
  10. </fs-popup>
  11. </template>
  12. <script setup>
  13. import { computed } from 'vue'
  14. const props = defineProps({
  15. list: Array,
  16. modelValue: Boolean,
  17. showMask: {
  18. type: Boolean,
  19. default: true
  20. },
  21. maskClickable: {
  22. type: Boolean,
  23. default: true
  24. },
  25. cancelText: {
  26. type: String,
  27. default: '取消'
  28. },
  29. showCancel: {
  30. type: Boolean,
  31. default: true
  32. }
  33. })
  34. const emits = defineEmits(['update:modelValue', 'change'])
  35. const visible = computed(
  36. {
  37. get: () => props.modelValue,
  38. set: value => emits('update:modelValue', value)
  39. }
  40. )
  41. const cancel = () => {
  42. emits('update:modelValue', false)
  43. }
  44. const handleAction = item => {
  45. emits('change', item)
  46. cancel()
  47. }
  48. </script>
  49. <style lang="scss" scoped>
  50. .fs-action {
  51. background-color: #f8f8f8;
  52. &-item {
  53. padding: 20rpx;
  54. text-align: center;
  55. background-color: #fff;
  56. &+& {
  57. border-top: 1px solid var(--border-color);
  58. }
  59. }
  60. &-cancel {
  61. padding: 20rpx;
  62. text-align: center;
  63. background-color: #fff;
  64. margin-top: 10rpx;
  65. }
  66. }
  67. </style>