<template>
    <div class="nus_operateoptions"
        v-if="list && list.length > 0">
        <template v-for="(item, index) in list">
            <operate-item
                :itemData="filterItem(item)"
                :key="index"
                @click="_onClickItem($event, item)"
                @tap="_onTapItem($event, item)">
            </operate-item>
        </template>
    </div>
</template>

<script>
import { callFn } from 'nimble-lib';
import OperateTmp from '../_comm/OperateTmp';
import OperateItem from '../operateItem/OperateItem';

export default {
    extends: OperateTmp,
    props: {
        /**
         * 数据项
         */
        list: {
            type: Array
        }
    },
    components: {
        OperateItem
    },
    methods: {
        /**
         * 过滤数据项
         * @param {String|Object} item 数据项
         * @returns {Object}
         */
        filterItem(item) {
            item = callFn(this.filterItemData || item, item);
            if (item && !(item instanceof Object)) {
                item = {
                    text: item
                };
            }
            return item;
        },
        /**
         * 点击按钮的回调
         * @param {Event} evt 事件对象
         * @param {Object} item 当前按钮的对象信息
         * @private
         */
        _onClickItem (evt, item) {
            const _that = this;
            _that._onClick(evt);
            _that._confirm(item);
        },
        /**
         * 点击按钮的回调
         * @param {Event} evt 事件对象
         * @param {Object} item 当前按钮的对象信息
         * @private
         */
        _onTapItem (evt, item) {
            const _that = this;
            _that._onTap(evt);
            _that._confirm(item);
        }
    }
};
</script>

<style lang="scss">
@import '../../../../_assets/style/_iconFont.scss';
@import '../../../../_assets/style/_var.scss';
@import '../../../../_assets/style/_mixin.scss';


</style>
