<template>
  <div class="app-container">
    <span v-if="enterprise.enterpriseStatus==='N'">
      <el-table  :data="tableData"  >
      <el-table-column label="企业名称" align="center" prop="ebterpriseName" />
      <el-table-column label="法定代表人" align="center" prop="legalPerson" />
      <el-table-column label="企业成立时间" align="center" prop="estabinessDate" width="180"/>
      <el-table-column label="注册地址" align="center" prop="address" />
      <el-table-column label="企业联系方式" align="center" prop="contactPhone" />
      <el-table-column label="公司邮箱" align="center" prop="email" />
    </el-table>
    </span>
    <span  v-if="enterprise.enterpriseStatus!=='N'">
      <span>{{"企业信息未完善"}}</span>
      <span>
                   <el-button
                     size="mini"
                     type="primary"
                     @click="handleUpdate(open,enterprise)"
                   >完善信息</el-button>
      </span>
    </span>

    <!-- 添加或修改车辆运营平台对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="企业名称" prop="ebterpriseName">
          <el-input v-model="form.ebterpriseName" placeholder="请输入企业名称" />
        </el-form-item>
        <el-form-item label="法定代表人" prop="legalPerson">
          <el-input v-model="form.legalPerson" placeholder="请输入法定代表人" />
        </el-form-item>
        <el-form-item label="经营执照凭证号码" prop="businessLincenseNumber">
          <el-input v-model="form.businessLincenseNumber" placeholder="请输入经营执照凭证号码" />
        </el-form-item>
        <el-form-item label="企业成立时间" prop="estabinessDate">
          <el-date-picker clearable
                          v-model="form.estabinessDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择企业成立时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="经营范围" prop="businessScope">
          <el-input v-model="form.businessScope" placeholder="请输入经营范围" />
        </el-form-item>
        <el-form-item label="注册地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入注册地址" />
        </el-form-item>
        <el-form-item label="企业联系方式" prop="contactPhone">
          <el-input v-model="form.contactPhone" placeholder="请输入企业联系方式" />
        </el-form-item>
        <el-form-item label="公司邮箱" prop="email">
          <el-input v-model="form.email" placeholder="请输入公司邮箱" />
        </el-form-item>
        <el-form-item label="企业入驻平台时期" prop="registrationDate">
          <el-date-picker clearable
                          v-model="form.registrationDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择企业入驻平台时期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="企业认证id" prop="certificationId">
          <el-input v-model="form.certificationId" placeholder="请输入企业认证id" />
        </el-form-item>
        <el-form-item label="认证时间" prop="authenticationDate">
          <el-date-picker clearable
                          v-model="form.authenticationDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择认证时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="开通服务id" prop="openServerId">
          <el-input v-model="form.openServerId" placeholder="请输入开通服务id" />
        </el-form-item>
        <el-form-item label="增值服务id" prop="addServerId">
          <el-input v-model="form.addServerId" placeholder="请输入增值服务id" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import {selectByName} from "@/api/customerBusiness/fence";
import {parseTime} from "../../../utils/muyu";
import {getCar, updateCar, updateEnterprise} from "@/api/customerBusiness/vehicle";

export default {
  name: "Car",
  dicts: ['service_level', 'enterprise_status'],
  data() {
    return {
      // 遮罩层
      loading: true,
      enterprise:{},
      // 车辆运营平台表格数据
      tableData: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.selectByName();
  },
  methods: {
    parseTime,
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        ebterpriseName: null,
        legalPerson: null,
        businessLincenseNumber: null,
        estabinessDate: null,
        businessScope: null,
        address: null,
        contactPhone: null,
        email: null,
        enterpriseStatus: null,
        registrationDate: null,
        certificationId: null,
        authenticationDate: null,
        serviceLevel: null,
        openServerId: null,
        addServerId: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 修改按钮操作 */
    handleUpdate(open,row) {
      // this.reset();
        this.form = row;
        this.open = true;
        this.title = "修改车辆运营平台";
    },
    selectByName() {
      selectByName().then(response => {
        this.enterprise = response.data;
        this.tableData.push(this.enterprise)
      });
    },
      /** 提交按钮 */
      submitForm() {
        updateEnterprise(this.form).then(response =>{
          console.log(this.form)
            this.$modal.msgSuccess("修改成功");
            this.open = false;
            this.selectByName();
        })
      }
  }
};
</script>
