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

<script>
  import VmImageList from '@/components/ctop/vm-image-list'
  import {
    propList,
    propListDelete
  } from '@/api/actor'
  export default {
    name: 'ImageList',
    components: {
      VmImageList
    },
    mounted() {
      this.$nextTick(() => {
        this.getActorList(1)
      })
    },
    methods: {
      deletefn: function (data) {
        console.log('最外层deleteFn执行',data)
        propListDelete({
          id:data.id
        }).then(res=>{
          if(res.success){
            this.$message.success('删除成功')
            // for (let i = 0; i < this.dataImageList.length; i++) {
            //   if (this.dataImageList[i].id === data.id) {
            //     this.dataImageList.splice(i, 1)
            //   }
            // }
            this.getActorList(data.page)
          }else{
            this.$message.error('删除失败，稍后再试')
          }
          
        })
      },
      getActorList(page, name) {
        this.dataImageList = []
        propList({
          pageNo: page,
          pageSize: 8,
          name: name
        }).then(res => {
          if (res.code == 0) {
            this.dataImageList = res.result.records
            this.total = res.result.total
          }
        })
      }
    },
    data: function () {
      return {
        dataImageList: [

        ],
        total: null
      }
    }
  }
</script>