<template>
  <div class="app-container contentBox">
    <el-row>
      <el-col>
        <div class="grid-content bg-purple">
          <el-form
            ref="formInline"
            :model="formInline"
            :rules="rules"
            :inline="true"
            class="width-80"
            :disabled="$route.query.state == 'show'"
          >
            <el-row class="title-box clearable h3Parent width-c54">
              <el-col :span="24">
                <h3 class="titleUseStyle">企业信息</h3>
              </el-col>
            </el-row>
            <el-row :gutter="2">
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="企业名称">
                    <el-input v-model="formInline.qymc" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="统一社会信用代码" label-width="124px">
                    <el-input v-model="formInline.tyshxydm" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <el-row :gutter="2">
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="企业性质">
                    <el-input v-model="formInline.qyxz" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="所在区域（旗县）" label-width="124px">
                    <el-input v-model="formInline.qyszqy" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <div class="grid-content bg-purple">
                  <el-form-item label="地址">
                    <el-input v-model="formInline.qytxdz" type="textarea" :rows="1" resize="none"></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <el-row class="title-box clearable h3Parent width-c54">
              <el-col :span="24">
                <h3 class="titleUseStyle">应急级别</h3>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24" class="bannerCountyAdd-select">
                <el-col :span="6">
                  <el-form-item label="省级:">
                    <el-select
                      v-model="formInline.emergencyProvincialLevel"
                      clearable
                      placeholder="请选择"
                    >
                      <el-option
                        v-for="(item,index) in findingsAuditObj"
                        :key="index"
                        :label="item.value"
                        :value="item.code"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="市级:">
                    <el-select
                      v-model="formInline.emergencyMunicipalLevel"
                      clearable
                      placeholder="请选择"
                    >
                      <el-option
                        v-for="(item,index) in findingsAuditObj"
                        :key="index"
                        :label="item.value"
                        :value="item.code"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="县级:">
                    <el-select
                      v-model="formInline.emergencyCountyLevel"
                      clearable
                      placeholder="请选择"
                    >
                      <el-option
                        v-for="(item,index) in findingsAuditObj"
                        :key="index"
                        :label="item.value"
                        :value="item.code"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-col>
            </el-row>
            <el-row :gutter="2">
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="负责人">
                    <el-input v-model="formInline.fddbr" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="联系电话">
                    <el-input v-model="formInline.bgdh" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
            <el-row class="title-box clearable h3Parent width-c54">
              <el-col :span="24">
                <h3 class="titleUseStyle">日加工能力（吨）</h3>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24" class="bannerCountyAdd-select bannerCountyAdd-input">
                <el-col :span="6">
                  <div class="grid-content bg-purple">
                    <el-form-item label="面粉">
                      <el-input v-model="formInline.tzYjqyVO.rjgnlMf" autocomplete="off"></el-input>
                    </el-form-item>
                  </div>
                </el-col>
                <el-col :span="6">
                  <div class="grid-content bg-purple">
                    <el-form-item label="大米">
                      <el-input v-model="formInline.tzYjqyVO.rjgnlDm" autocomplete="off"></el-input>
                    </el-form-item>
                  </div>
                </el-col>
                <el-col :span="6">
                  <div class="grid-content bg-purple">
                    <el-form-item label="食用油">
                      <el-input v-model="formInline.tzYjqyVO.rjgnlSyy" autocomplete="off"></el-input>
                    </el-form-item>
                  </div>
                </el-col>
                <el-col :span="6">
                  <div class="grid-content bg-purple">
                    <el-form-item label="其他">
                      <el-input v-model="formInline.tzYjqyVO.rjgnlQt" autocomplete="off"></el-input>
                    </el-form-item>
                  </div>
                </el-col>
              </el-col>
            </el-row>
            <el-row :gutter="2">
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="经度">
                    <el-input v-model="formInline.qyjd" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="grid-content bg-purple">
                  <el-form-item label="纬度">
                    <el-input v-model="formInline.qywd" autocomplete="off"></el-input>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
          </el-form>
          <el-row class="saveCancel">
            <el-col :span="24">
              <div class="grid-content bg-purple">
                <el-button
                  type="primary"
                  class="outButton newReport"
                  v-show="!$route.query.state"
                  @click="saveNew"
                ><i class="iconfont">&#xe681;</i> 保存</el-button>
                <el-button
                  type="primary"
                  class="outButton newReport"
                  style="margin-left: 8px;"
                  v-show="$route.query.state !== 'show' && $route.query.state"
                  @click="submissionInfo('formInline')"
                ><i class="iconfont">&#xe681;</i> 确定</el-button>
                <el-button
                  type="primary"
                  class="outButton newReport"
                  style="margin-left: 8px;"
                  @click="cancel"
                ><i class="iconfont">&#xe688;</i> 取消</el-button>
              </div>
            </el-col>
          </el-row>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {
  budgetSubmissionSaveNew,
  budgetSubmissionModify,
  budgetSubmissionSubmission
} from "@/api/emergencyManagement/emergencyProcessingEnterprises/addIndex";

export default {
  data() {
    return {
      rules: {
        projectName: [
          { required: true, message: "请填写项目名称", trigger: "blur" }
        ]
      },
      formInline: {
        tzYjqyVO: {}
      },
      //状态
      findingsAuditObj: [
        {
          value: "1",
          code: "1"
        }
      ]
    };
  },
  created() {
    if (this.$route.query.state) {
      this.info(this.$route.query.row.tyshxydm);
    } else {
    }
  },
  methods: {
    cancel() {
      this.$router.push({ path: "bannerCountySupply" });
    },
    saveNew() {
      budgetSubmissionSaveNew(this.formInline).then(response => {
        if (response.infoCode === 200) {
          this.$router.push({ path: "bannerCountySupply" });
          this.$notify({
            title: "成功",
            message: "新增成功",
            type: "success",
            duration: 2000
          });
        } else {
          this.$message({
            type: "error",
            message: response.msg
          });
        }
      });
    },
    info(id) {
      budgetSubmissionModify(id).then(response => {
        if (response.infoCode === 200) {
          this.formInline = response.data;
        } else {
          this.$message({
            type: "error",
            message: response.msg
          });
        }
      });
    },
    submissionInfo(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          budgetSubmissionSubmission(this.formInline).then(response => {
            if (response.infoCode == 200) {
              this.$notify({
                title: "成功",
                message: "修改成功",
                type: "success",
                duration: 2000
              });
              this.$router.push({ path: "bannerCountySupply" });
            } else {
              this.$message({
                type: "error",
                message: response.msg
              });
            }
          });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    }
  }
};
</script>
<style>
@import "common.css";
.el-message--error {
  display: none !important;
}
.font-color {
  height: 34px;
  font-size: 18px;
  font-weight: 600;
}
.width-c54 {
  width: calc(100% - 50px);
  margin-bottom: 20px;
}
.table-from table {
  width: calc(100% - 50px);
  border: 1px solid #dcdfe6;
  text-align: center;
  margin-bottom: 10px;
  margin-bottom: 20px;
}
.table-from table .el-textarea__inner {
  border: 0px solid #dcdfe6;
}
.budgetSubmission-upload .uploadBtn {
  margin-left: 20px;
  display: inline-block;
  line-height: normal;
  padding: 10px 10px;
  font-size: 14px;
  color: #ffffff;
  background: #145b9b;
  border-color: #145b9b;
  border-radius: 5px;
  cursor: pointer;
}

.budgetSubmission-upload .uploadBtn input[type="file"] {
  display: none;
}
.budgetSubmission-upload .fileBox {
  position: absolute;
  left: 72px;
  top: 0px;
  width: calc(100% - 50px);
  height: 133px;
  font-size: 16px;
  height: 38px;
  line-height: normal;
  background-color: #dcdfe6;
  color: #409eff;
  padding: 5px 10px;
  margin-top: 0px;
}

.budgetSubmission-upload .fileBox > i {
  float: right;
  font-size: 20px;
  margin: 0px 5px;
  color: #000000;
  cursor: pointer;
}

.budgetSubmission-upload .fileBox i:hover {
  color: #409eff;
}
.contentBox .bannerCountyAdd-select .el-form-item__content {
  display: inline-block;
  width: calc(100% - 125px);
}
.contentBox .bannerCountyAdd-select .el-form-item__label {
  width: 122px;
  /* width: 120px; */
  text-align: right;
}
.bannerCountyAdd-input .el-col-6 {
  width: 22%;
}
</style>
<style lang="scss">
.h3Parent {
  .el-col {
    position: relative;
  }
}
.title-box {
  //新增等标题外的el-row用样式（如调控管理>涉粮企业管理系统>企业基础信息管理>新增）
  .el-col {
    height: 38px;
  }
}
.titleUseStyle {
  position: absolute;
  top: 0px;
  font-size: 14px;
  width: 100%;
  height: 30px;
  line-height: 30px;
  color: #fff;
  font-weight: 400;
  background: #47a8b7;
  padding-left: 8px;
  &::before {
    position: relative;
    top: 2px;
    content: "";
    display: inline-block;
    margin-right: 10px;
    width: 2px;
    height: 14px;
    background-color: #fff;
  }
}
</style>


