<template>
    <vm-image-list :data="dataImageList" title="演员列表" @delete-ok="deletefn" class="vm-margin"
                   @getList="getActorList"
                   @updateList="getActorList(1, '')" :total="total"></vm-image-list>
</template>

<script>
import VmImageList from '@/components/ctop/vm-image-list'
import {
    actorList,
    actorListDelete
} from '@/api/actor'

export default {
    name: 'ImageList',
    components: {
        VmImageList
    },
    // inject:[page],
    mounted() {
        this.$nextTick(() => {
            this.getActorList(1)

        })
    },
    methods: {
        deletefn: function (data) {
            console.log('最外层deleteFn执行', data)
            actorListDelete({
                id: data.id
            }).then(res => {
                if (res.success) {
                    this.$message.success('删除成功')
                    this.getActorList(data.page)
                } else {
                    this.$message.error('删除失败，稍后再试')
                }
            })

        },
        getActorList(page, name) {
            this.listLoading = true
            this.dataImageList = []
            actorList({
                pageNo: page,
                pageSize: 8,
                name: name
            }).then(res => {
                if (res.code == 0) {
                    this.dataImageList = res.result.records
                    this.total = res.result.total
                    this.listLoading = false
                }
            })
            this.listLoading = false
        }
    },
    data: function () {
        return {
            dataImageList: [],
            total: null
        }
    }
}
</script>