fs-action.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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)">
  5. {{ item.name }}
  6. </view>
  7. <view class="fs-action-extra"><slot></slot></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. get: () => props.modelValue,
  37. set: value => emits('update:modelValue', value)
  38. })
  39. const cancel = () => {
  40. emits('update:modelValue', false)
  41. }
  42. const handleAction = item => {
  43. emits('change', item)
  44. cancel()
  45. }
  46. </script>
  47. <style lang="scss" scoped>
  48. .fs-action {
  49. background-color: #f8f8f8;
  50. &-item {
  51. padding: 20rpx;
  52. text-align: center;
  53. background-color: #fff;
  54. & + & {
  55. border-top: 1px solid var(--border-color);
  56. }
  57. }
  58. &-cancel {
  59. padding: 20rpx;
  60. text-align: center;
  61. background-color: #fff;
  62. margin-top: 10rpx;
  63. }
  64. }
  65. </style>