<template>
  <div>
    <el-row :gutter="10" class="mb8">
      <el-button
        type="primary"
        plain
        icon="el-icon-plus"
        size="mini"
        @click="dialogFormVisible=true"
      >新增企业
      </el-button>
    </el-row>

    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        label="id"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.id }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="企业名称"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.enterpriseName }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="法定代表人"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.legalPerson }}</span>
        </template>
      </el-table-column>


      <el-table-column
        label="企业成立日期"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.estabinessDate }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="地址"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.address }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="企业状态"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px" v-if="scope.row.status==1">正常</span>
          <span style="margin-left: 10px" v-if="scope.row.status==2">停用</span>
        </template>
      </el-table-column>

      <el-table-column
        label="企业入住平台日期"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.registrationDate }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="会员级别"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.member }}</span>
        </template>
      </el-table-column>

<!--      <el-table-column label="操作">-->
<!--        <template slot-scope="scope">-->
<!--          <el-button-->
<!--            size="mini"-->
<!--            @click="handleEdit(scope.$index, scope.row)">编辑</el-button>-->
<!--          <el-button-->
<!--            size="mini"-->
<!--            type="danger"-->
<!--            @click="handleDelete(scope.$index, scope.row)">删除</el-button>-->
<!--        </template>-->
<!--      </el-table-column>-->
    </el-table>

<!--    新增企业按钮-->
    <el-dialog title="新增企业" :visible.sync="dialogFormVisible" append-to-body width="600px">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="企业名称" prop="deptName">
              <el-input v-model="form.enterpriseName" placeholder="请输入企业名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="法定代表" prop="deptName">
              <el-input v-model="form.legalPerson" placeholder="请输入法定代表人"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="成立日期" prop="deptName">
              <el-input v-model="form.estabinessDate" placeholder="请输入企业成立日期"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="注册地址" prop="deptName">
              <el-input v-model="form.address" placeholder="请输入注册地址"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="deptName">
              <el-input v-model="form.contactPhone" placeholder="请输入联系电话"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="企业邮箱" prop="deptName">
              <el-input v-model="form.email" placeholder="请输入企业邮箱"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="数据库名" prop="deptName">
              <el-input v-model="form.databaseName" placeholder="请输入数据库名"/>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="enterpriseAdd()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）,
//例如：import 《组件名称》 from '《组件路径》,
import {findEnterpriseList} from "@/api/firm/enter";
import {enterpriseAdd} from "@/api/firm/enter";
export default {
  //import引入的组件需要注入到对象中才能使用"
  components: {},
  props: {},
  data() {
    //这里存放数据"

    return {
      //企业入驻列表
      tableData:[],
      enterpriseForm:{},
      //新增对话框
      dialogFormVisible:false,
      form:{},
    };
  },
  //计算属性 类似于data概念",
  computed: {},
  //监控data中的数据变化",
  watch: {},
  //方法集合",
  methods: {
    enterpriseAdd(){
      enterpriseAdd(this.form).then((res)=>{
        alert(res.msg);
        if (200==res.code){
          this.findEnterpriseList();
          this.dialogFormVisible=false;
        }
      })
    },
    //企业列表
    findEnterpriseList(){
      findEnterpriseList(this.enterpriseForm).then((res)=>{
        this.tableData=res.data;
      })
    }
  },
  //生命周期 - 创建完成（可以访问当前this实例）",
  created() {
    this.findEnterpriseList();
  },
  //生命周期 - 挂载完成（可以访问DOM元素）",
  mounted() {
  },
  beforeCreate() {
  }, //生命周期 - 创建之前",
  beforeMount() {
  }, //生命周期 - 挂载之前",
  beforeUpdate() {
  }, //生命周期 - 更新之前",
  updated() {
  }, //生命周期 - 更新之后",
  beforeDestroy() {
  }, //生命周期 - 销毁之前",
  destroyed() {
  }, //生命周期 - 销毁完成",
  activated() {
  } //如果页面有keep-alive缓存功能，这个函数会触发",
};
</script>
<style scoped>

</style>
