
<template>
  <el-dialog
    :title="!dataForm.id ? '车队注册' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible" width="70%" :before-close="handleClose">
    <el-form :model="dataForm_s" :rules="dataRule" ref="dataForm_s" @keyup.enter.native="dataFormSubmit()" label-width="200px">
      <el-form-item label="公司名称" prop="companyName">
        <el-input v-model="dataForm_s.companyName" placeholder="公司名称"></el-input>
      </el-form-item>
      <el-form-item label="公司地址" prop="companyAddress">
        <el-input v-model="dataForm_s.companyAddress" placeholder="公司地址"></el-input>
      </el-form-item>
      <el-form-item label="公司开户行" prop="openingBank">
        <el-input v-model="dataForm_s.openingBank" placeholder="公司开户行"></el-input>
      </el-form-item>
      <el-form-item label="银行账号" prop="bankAccount">
        <el-input v-model="dataForm_s.bankAccount" placeholder="银行账号"></el-input>
      </el-form-item>
      <el-form-item label="登录账号" prop="loginAccount">
        <el-input v-model="dataForm_s.loginAccount" :disabled="dataForm.id ? edit:false" placeholder="登录账号"></el-input>
      </el-form-item>
      <el-form-item label="登录密码" prop="pwd" v-if="dataForm_s.id ? false:true">
        <el-input v-model="dataForm_s.pwd" placeholder="登录密码" type="password"></el-input>
      </el-form-item>

      <el-form-item label="信用等级" prop="creditLv">
        <el-input v-model="dataForm_s.creditLv" placeholder="信用等级"></el-input>
      </el-form-item>
      <el-form-item label="账期天数(最迟结款天数)" prop="paymentDays">
        <el-input v-model="dataForm_s.paymentDays" placeholder="账期天数(最迟结款天数)"></el-input>
      </el-form-item>
      <el-form-item label="联系人" prop="linkMan">
        <el-input v-model="dataForm_s.linkMan" placeholder="联系人"></el-input>
      </el-form-item>
      <el-form-item label="联系电话" prop="linkPhone">
        <el-input v-model="dataForm_s.linkPhone" placeholder="联系电话"></el-input>
      </el-form-item>
      <el-form-item label="传真" prop="fax">
        <el-input v-model="dataForm_s.fax" placeholder="传真"></el-input>
      </el-form-item>
      <el-form-item label="email" prop="email">
        <el-input v-model="dataForm_s.email" placeholder="email"></el-input>
      </el-form-item>
      <el-form-item label="总公司" prop="headOffice">
        <el-input v-model="dataForm_s.headOffice" placeholder="总公司"></el-input>
      </el-form-item>
      <el-form-item label="注册资本" prop="registerdCapital">
        <el-input v-model="dataForm_s.registerdCapital" placeholder="注册资本"></el-input>
      </el-form-item>
      <el-form-item label="法人" prop="legalPerson">
        <el-input v-model="dataForm_s.legalPerson" placeholder="法人"></el-input>
      </el-form-item>
      <el-form-item label="所属行业" prop="insdustry">
        <el-input v-model="dataForm_s.insdustry" placeholder="所属行业"></el-input>
      </el-form-item>
      <el-form-item label="社会统一信用代码" prop="creditNum">
        <el-input v-model="dataForm_s.creditNum" placeholder="社会统一信用代码"></el-input>
      </el-form-item>
      <el-form-item label="纳税人识别号" prop="taxpayerNum">
        <el-input v-model="dataForm_s.taxpayerNum" placeholder="纳税人识别号"></el-input>
      </el-form-item>
      <el-form-item label="工商注册号" prop="industryCommerceNum">
        <el-input v-model="dataForm_s.industryCommerceNum" placeholder="工商注册号"></el-input>
      </el-form-item>
      <el-form-item label="组织机构代码" prop="organizationNum">
        <el-input v-model="dataForm_s.organizationNum" placeholder="组织机构代码"></el-input>
      </el-form-item>
      <el-form-item label="登记机关" prop="registerOrganization">
        <el-input v-model="dataForm_s.registerOrganization" placeholder="登记机关"></el-input>
      </el-form-item>
      <el-form-item label="成立日期" prop="dateOfEstablishment">
        <!--            <el-input v-model="dataForm.dateOfEstablishment" placeholder="成立日期"></el-input>-->
        <el-date-picker
          style="width: 100%"
          value-format="yyyy-MM-dd HH:mm:ss"
          v-model="dataForm_s.dateOfEstablishment"
          type="date"
          placeholder="创建时间">
        </el-date-picker>

      </el-form-item>
      <el-form-item label="企业类型" prop="companyType">
        <el-input v-model="dataForm_s.companyType" placeholder="企业类型"></el-input>
      </el-form-item>
      <el-form-item label="营业期限" prop="businessDeadline">
        <el-input v-model="dataForm_s.businessDeadline" placeholder="营业期限"></el-input>
      </el-form-item>
      <el-form-item label="营业区域" prop="businessArea">
        <el-input v-model="dataForm_s.businessArea" placeholder="营业区域"></el-input>
      </el-form-item>
      <el-form-item label="审核年检日期" prop="annualDate">
        <!--            <el-input v-model="dataForm.annualDate" placeholder="审核年检日期"></el-input>-->
        <el-date-picker
          style="width: 100%"
          value-format="yyyy-MM-dd HH:mm:ss"
          v-model="dataForm_s.annualDate"
          type="date"
          placeholder="创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="注册地址" prop="registerdAddress">
        <el-input v-model="dataForm_s.registerdAddress" placeholder="注册地址"></el-input>
      </el-form-item>
      <el-form-item label="经营范围" prop="manageScope">
        <el-input v-model="dataForm_s.manageScope" placeholder="经营范围"></el-input>
      </el-form-item>

      <el-form-item label="登录密码确认" prop="pwd2" v-if="dataForm_s.id ? false:true">
        <el-input v-model="dataForm_s.pwd2" placeholder="登录密码确认" type="password"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="cancel">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import {preservation,lookOver} from "@/api/fleet/companyMsg"
export default {
  props: {
    dataForm: {
      type: Object,
      require: false,
    }
  },
  data () {
    return {
      dataForm_s:{
        annualDate: '',
        bankAccount: '',
        billStatus: '',
        businessArea: '',
        businessDeadline: '',
        carNum: '',
        companyAddress:'',
        companyName: '',
        companyType: '',
        creatTime: '',
        createBy: '',
        createTime: '',
        creditLv: '',
        creditNum: '',
        dateOfEstablishment: '',
        delFlag: '',
        email: '',
        fax: '',
        headOffice: '',
        id: '',
        industryCommerceNum: '',
        insdustry: '',
        legalPerson: '',
        linkMan: '',
        linkPhone:'',
        loginAccount: '',
        manageScope: '',
        modificationTime: '',
        openingBank: '',
        organizationNum: '',
        params: '',
        paymentDays: '',
        registerOrganization: '',
        registerdAddress: '',
        registerdCapital: '',
        remark: '',
        searchValue: '',
        taxpayerNum: '',
        updateBy: '',
        updateTime: '',
      },
      visible: false,
      edit: true,
      login: this.dataForm.id,
      dataRule: {
        companyName: [
          {required: true, message: '请输入公司名称', trigger: 'blur'}
        ],
        companyAddress: [
          {required: true, message: '请输入公司地址', trigger: 'blur'}
        ],
        loginAccount: [
          {required: true, message: '请输入登录账号', trigger: 'blur'}
        ],
        pwd: [
          {required: true, message: '请输入登录密码', trigger: 'blur'}
        ],
        openingBank: [
          {required: true, message: '请输入开户行', trigger: 'blur'}
        ],
        bankAccount: [
          {required: true, message: '请输入银行账号', trigger: 'blur'}
        ],
        paymentDays: [
          {required: true, message: '请输入账期天数', trigger: 'blur'}
        ],
        pwd2: [
          {required: true, message: '请输入登录密码', trigger: 'blur'}
        ],
        linkPhone: [
          {required: true, message: '请输入联系人电话', trigger: 'blur'}
        ]
      }
    }
  },
  methods: {
    cancel(){
      this.$confirm('确认关闭？')
        .then(_ => {
          this.visible = false
          this.dataForm_s = {}
        })
        .catch(_ => {});
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
          this.visible = false
          this.dataForm_s = {}
        })
        .catch(_ => {});
    },
    init () {
      this.visible = true
        if (this.dataForm.id !== null){
          lookOver(this.dataForm.id).then(data=>{
            this.dataForm_s = data.data
          })
        }
    },
    // 表单提交
    dataFormSubmit () {
      if (this.dataForm_s.pwd != this.dataForm_s.pwd2) {
        this.$message.error('前后输入密码不一致!')
        return
      }
      this.$refs['dataForm_s'].validate((valid) => {
        if (valid) {
          console.log(valid)
          preservation(this.dataForm_s).then(data=>{
            this.$message.success('操作成功');
          })
        }
      })
    }
  },
  handlePreview (file) {
  },
  handleExceed (files, fileList) {
    this.$message.warning(
      `当前限制选择 3 个文件，本次选择了 ${
        files.length
      } 个文件，共选择了 ${files.length + fileList.length} 个文件`
    )
  },
  beforeRemove (file, fileList) {
    return this.$confirm(`确定移除 ${file.name}？`)
  }
}
</script>
<style scoped>

.el-form-item {
  width: 49%;
  margin-bottom: 20px;
  display: inline-block;
}
.el-select {
  display: block;
}
.upload-demo {
  margin-left: 50px;
}
</style>
