123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <template>
- <fs-popup direction="bottom" height="auto" v-model="visible" :showMask="showMask" :maskClickable="maskClickable">
- <view class="fs-action">
- <view class="fs-action-item" v-for="(item, index) in list" :key="index" @click="handleAction(item)">
- {{ item.name }}
- </view>
- <view class="fs-action-extra"><slot></slot></view>
- <view class="fs-action-cancel" v-if="showCancel" @click="cancel">{{ cancelText }}</view>
- </view>
- </fs-popup>
- </template>
- <script>
- /**
- * 动作组件
- * @description 动作组件
- * @property {Array} list action列表
- * @property {Boolean} showMask 是否展示遮罩
- * @property {Boolean} maskClickable 遮罩是否可点击
- * @property {Boolean} showCancel 是否展示取消action
- * @property {String} cancelText “取消”文字
- * @event {Function} change change事件
- * @example <fs-action :list="list" v-model="show" @change="change"></fs-action>
- */
- export default {
- name: 'fs-action'
- }
- </script>
- <script setup>
- import { computed } from 'vue'
- const props = defineProps({
- list: Array,
- modelValue: Boolean,
- showMask: {
- type: Boolean,
- default: true
- },
- maskClickable: {
- type: Boolean,
- default: true
- },
- cancelText: {
- type: String,
- default: '取消'
- },
- showCancel: {
- type: Boolean,
- default: true
- }
- })
- const emits = defineEmits(['update:modelValue', 'change'])
- const visible = computed({
- get: () => props.modelValue,
- set: value => emits('update:modelValue', value)
- })
- const cancel = () => {
- emits('update:modelValue', false)
- }
- const handleAction = item => {
- emits('change', item)
- cancel()
- }
- </script>
- <style lang="scss" scoped>
- .fs-action {
- background-color: #f8f8f8;
- &-item {
- padding: 20rpx;
- text-align: center;
- background-color: #fff;
- & + & {
- border-top: 1px solid var(--border-color);
- }
- }
- &-cancel {
- padding: 20rpx;
- text-align: center;
- background-color: #fff;
- margin-top: 10rpx;
- }
- }
- </style>
|