<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
    <el-form-item label="合同id" prop="excelContractId">
      <el-input v-model="dataForm.excelContractId" placeholder="合同id"></el-input>
    </el-form-item>
    <el-form-item label="合同名称" prop="excelContract">
      <el-input v-model="dataForm.excelContract" placeholder="合同名称"></el-input>
    </el-form-item>
    <el-form-item label="建设单位" prop="excelJsdw">
      <el-input v-model="dataForm.excelJsdw" placeholder="建设单位"></el-input>
    </el-form-item>
    <el-form-item label="施工单位" prop="excelSgdw">
      <el-input v-model="dataForm.excelSgdw" placeholder="施工单位"></el-input>
    </el-form-item>
    <el-form-item label="监理单位" prop="excelJldw">
      <el-input v-model="dataForm.excelJldw" placeholder="监理单位"></el-input>
    </el-form-item>
    <el-form-item label="一审单位" prop="excelYsdw">
      <el-input v-model="dataForm.excelYsdw" placeholder="一审单位"></el-input>
    </el-form-item>
    <el-form-item label="二审单位" prop="excelEsdw">
      <el-input v-model="dataForm.excelEsdw" placeholder="二审单位"></el-input>
    </el-form-item>
    <el-form-item label="合同金额" prop="excelContractMoney">
      <el-input v-model="dataForm.excelContractMoney" placeholder="合同金额"></el-input>
    </el-form-item>
    <el-form-item label="合同签订时间" prop="excelContractQdtime">
      <el-input v-model="dataForm.excelContractQdtime" placeholder="合同签订时间"></el-input>
    </el-form-item>
    <el-form-item label="付款比例" prop="excelFkbl">
      <el-input v-model="dataForm.excelFkbl" placeholder="付款比例"></el-input>
    </el-form-item>
    <el-form-item label="验收时间" prop="excelYsbl">
      <el-input v-model="dataForm.excelYsbl" placeholder="验收时间"></el-input>
    </el-form-item>
    <el-form-item label="合同开工时间" prop="excelStartTime">
      <el-input v-model="dataForm.excelStartTime" placeholder="合同开工时间"></el-input>
    </el-form-item>
    <el-form-item label="合同竣工时间" prop="excelEndTime">
      <el-input v-model="dataForm.excelEndTime" placeholder="合同竣工时间"></el-input>
    </el-form-item>
    <el-form-item label="实际开工时间" prop="excelActualStart">
      <el-input v-model="dataForm.excelActualStart" placeholder="实际开工时间"></el-input>
    </el-form-item>
    <el-form-item label="实际竣工时间" prop="excelActualEnd">
      <el-input v-model="dataForm.excelActualEnd" placeholder="实际竣工时间"></el-input>
    </el-form-item>
    <el-form-item label="一审提报" prop="excelYstb">
      <el-input v-model="dataForm.excelYstb" placeholder="一审提报"></el-input>
    </el-form-item>
    <el-form-item label="一审减值" prop="excelYstz">
      <el-input v-model="dataForm.excelYstz" placeholder="一审减值"></el-input>
    </el-form-item>
    <el-form-item label="一审定值" prop="excelYsdz">
      <el-input v-model="dataForm.excelYsdz" placeholder="一审定值"></el-input>
    </el-form-item>
    <el-form-item label="一审定值确定时间" prop="excelYssureTime">
      <el-input v-model="dataForm.excelYssureTime" placeholder="一审定值确定时间"></el-input>
    </el-form-item>
    <el-form-item label="二审提报" prop="excelEstb">
      <el-input v-model="dataForm.excelEstb" placeholder="二审提报"></el-input>
    </el-form-item>
    <el-form-item label="二审减值" prop="excelEsjz">
      <el-input v-model="dataForm.excelEsjz" placeholder="二审减值"></el-input>
    </el-form-item>
    <el-form-item label="二审定值" prop="excelEsdz">
      <el-input v-model="dataForm.excelEsdz" placeholder="二审定值"></el-input>
    </el-form-item>
    <el-form-item label="二审定值确定时间" prop="excelEssureTime">
      <el-input v-model="dataForm.excelEssureTime" placeholder="二审定值确定时间"></el-input>
    </el-form-item>
    <el-form-item label="备注" prop="excelRemark">
      <el-input v-model="dataForm.excelRemark" placeholder="备注"></el-input>
    </el-form-item>
    <el-form-item label="提报与审计跟踪记录" prop="excelRecording">
      <el-input v-model="dataForm.excelRecording" placeholder="提报与审计跟踪记录"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          id: 0,
          excelContractId: '',
          excelContract: '',
          excelJsdw: '',
          excelSgdw: '',
          excelJldw: '',
          excelYsdw: '',
          excelEsdw: '',
          excelContractMoney: '',
          excelContractQdtime: '',
          excelFkbl: '',
          excelYsbl: '',
          excelStartTime: '',
          excelEndTime: '',
          excelActualStart: '',
          excelActualEnd: '',
          excelYstb: '',
          excelYstz: '',
          excelYsdz: '',
          excelYssureTime: '',
          excelEstb: '',
          excelEsjz: '',
          excelEsdz: '',
          excelEssureTime: '',
          excelRemark: '',
          excelRecording: ''
        },
        dataRule: {
          excelContractId: [
            { required: true, message: '合同id不能为空', trigger: 'blur' }
          ],
          excelContract: [
            { required: true, message: '合同名称不能为空', trigger: 'blur' }
          ],
          excelJsdw: [
            { required: true, message: '建设单位不能为空', trigger: 'blur' }
          ],
          excelSgdw: [
            { required: true, message: '施工单位不能为空', trigger: 'blur' }
          ],
          excelJldw: [
            { required: true, message: '监理单位不能为空', trigger: 'blur' }
          ],
          excelYsdw: [
            { required: true, message: '一审单位不能为空', trigger: 'blur' }
          ],
          excelEsdw: [
            { required: true, message: '二审单位不能为空', trigger: 'blur' }
          ],
          excelContractMoney: [
            { required: true, message: '合同金额不能为空', trigger: 'blur' }
          ],
          excelContractQdtime: [
            { required: true, message: '合同签订时间不能为空', trigger: 'blur' }
          ],
          excelFkbl: [
            { required: true, message: '付款比例不能为空', trigger: 'blur' }
          ],
          excelYsbl: [
            { required: true, message: '验收时间不能为空', trigger: 'blur' }
          ],
          excelStartTime: [
            { required: true, message: '合同开工时间不能为空', trigger: 'blur' }
          ],
          excelEndTime: [
            { required: true, message: '合同竣工时间不能为空', trigger: 'blur' }
          ],
          excelActualStart: [
            { required: true, message: '实际开工时间不能为空', trigger: 'blur' }
          ],
          excelActualEnd: [
            { required: true, message: '实际竣工时间不能为空', trigger: 'blur' }
          ],
          excelYstb: [
            { required: true, message: '一审提报不能为空', trigger: 'blur' }
          ],
          excelYstz: [
            { required: true, message: '一审减值不能为空', trigger: 'blur' }
          ],
          excelYsdz: [
            { required: true, message: '一审定值不能为空', trigger: 'blur' }
          ],
          excelYssureTime: [
            { required: true, message: '一审定值确定时间不能为空', trigger: 'blur' }
          ],
          excelEstb: [
            { required: true, message: '二审提报不能为空', trigger: 'blur' }
          ],
          excelEsjz: [
            { required: true, message: '二审减值不能为空', trigger: 'blur' }
          ],
          excelEsdz: [
            { required: true, message: '二审定值不能为空', trigger: 'blur' }
          ],
          excelEssureTime: [
            { required: true, message: '二审定值确定时间不能为空', trigger: 'blur' }
          ],
          excelRemark: [
            { required: true, message: '备注不能为空', trigger: 'blur' }
          ],
          excelRecording: [
            { required: true, message: '提报与审计跟踪记录不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`/business/businessssjdexcel/info/${this.dataForm.id}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.excelContractId = data.businessSsjdexcel.excelContractId
                this.dataForm.excelContract = data.businessSsjdexcel.excelContract
                this.dataForm.excelJsdw = data.businessSsjdexcel.excelJsdw
                this.dataForm.excelSgdw = data.businessSsjdexcel.excelSgdw
                this.dataForm.excelJldw = data.businessSsjdexcel.excelJldw
                this.dataForm.excelYsdw = data.businessSsjdexcel.excelYsdw
                this.dataForm.excelEsdw = data.businessSsjdexcel.excelEsdw
                this.dataForm.excelContractMoney = data.businessSsjdexcel.excelContractMoney
                this.dataForm.excelContractQdtime = data.businessSsjdexcel.excelContractQdtime
                this.dataForm.excelFkbl = data.businessSsjdexcel.excelFkbl
                this.dataForm.excelYsbl = data.businessSsjdexcel.excelYsbl
                this.dataForm.excelStartTime = data.businessSsjdexcel.excelStartTime
                this.dataForm.excelEndTime = data.businessSsjdexcel.excelEndTime
                this.dataForm.excelActualStart = data.businessSsjdexcel.excelActualStart
                this.dataForm.excelActualEnd = data.businessSsjdexcel.excelActualEnd
                this.dataForm.excelYstb = data.businessSsjdexcel.excelYstb
                this.dataForm.excelYstz = data.businessSsjdexcel.excelYstz
                this.dataForm.excelYsdz = data.businessSsjdexcel.excelYsdz
                this.dataForm.excelYssureTime = data.businessSsjdexcel.excelYssureTime
                this.dataForm.excelEstb = data.businessSsjdexcel.excelEstb
                this.dataForm.excelEsjz = data.businessSsjdexcel.excelEsjz
                this.dataForm.excelEsdz = data.businessSsjdexcel.excelEsdz
                this.dataForm.excelEssureTime = data.businessSsjdexcel.excelEssureTime
                this.dataForm.excelRemark = data.businessSsjdexcel.excelRemark
                this.dataForm.excelRecording = data.businessSsjdexcel.excelRecording
              }
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/business/businessssjdexcel/${!this.dataForm.id ? 'save' : 'update'}`),
              method: 'post',
              data: this.$http.adornData({
                'id': this.dataForm.id || undefined,
                'excelContractId': this.dataForm.excelContractId,
                'excelContract': this.dataForm.excelContract,
                'excelJsdw': this.dataForm.excelJsdw,
                'excelSgdw': this.dataForm.excelSgdw,
                'excelJldw': this.dataForm.excelJldw,
                'excelYsdw': this.dataForm.excelYsdw,
                'excelEsdw': this.dataForm.excelEsdw,
                'excelContractMoney': this.dataForm.excelContractMoney,
                'excelContractQdtime': this.dataForm.excelContractQdtime,
                'excelFkbl': this.dataForm.excelFkbl,
                'excelYsbl': this.dataForm.excelYsbl,
                'excelStartTime': this.dataForm.excelStartTime,
                'excelEndTime': this.dataForm.excelEndTime,
                'excelActualStart': this.dataForm.excelActualStart,
                'excelActualEnd': this.dataForm.excelActualEnd,
                'excelYstb': this.dataForm.excelYstb,
                'excelYstz': this.dataForm.excelYstz,
                'excelYsdz': this.dataForm.excelYsdz,
                'excelYssureTime': this.dataForm.excelYssureTime,
                'excelEstb': this.dataForm.excelEstb,
                'excelEsjz': this.dataForm.excelEsjz,
                'excelEsdz': this.dataForm.excelEsdz,
                'excelEssureTime': this.dataForm.excelEssureTime,
                'excelRemark': this.dataForm.excelRemark,
                'excelRecording': this.dataForm.excelRecording
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
