<template>
  <div class="enterprise-list">
    <tables
      :data-api="getCompanyList"
      :delete-api="deleteCompany"
      :columns="columns"
      @toCheck="check"
      deleteIdKey="agency_user_id"
      placeholder="输入公司名称"
      ref="table"
    />
  </div>
</template>

<script>
import tables from 'components/tables'
import { getCompanyList, updateCompany } from '@/api/company'
export default {
  data () {
    return {
      getCompanyList,
      columns: [
        {
          type: 'index',
          title: '序号',
          align: 'center',
          width: 80
        },
        {
          title: '公司名称',
          key: 'companyName',
          align: 'center'
        },
        {
          title: '所属行业',
          key: 'companyType',
          align: 'center'
        },
        {
          title: '公司地址',
          key: 'companyAddress',
          align: 'center'
        },
        {
          title: '成立时间',
          key: 'registerDate',
          align: 'center'
        },
        {
          title: '讲解人员',
          key: 'name',
          align: 'center'
        },
        {
          title: '手机号码',
          key: 'name',
          align: 'center'
        },
        {
          title: '操作',
          slot: 'action',
          tools: ['check', 'del' ],
          align: 'center'
        }
      ],
    }
  },
  components: {
    tables
  },
  methods: {
    check (item) {
      this.$router.push({
        path: '/enterprise',
        query: {
          companyId: item.companyId
        }
      })
    },
    async deleteCompany(row) {
      row[0].enable = 0
      await updateCompany(row[0])
      this.$Message.success({
        content: '删除成功'
      })
    }
  }
}
</script>

<style lang="less" scoped>
.enterprise-list {
  padding: 30px;
}
</style>