<template>
  <div class="create-container">
    <div class="title h1">分析需求</div>
    <div class="create-body">
      <el-form
        :model="analyseDemand"
        :rules="rules"
        ref="analyseDemand"
        label-width="12%"
        class="demo-report"
      >
        <el-form-item label="可行性分析报告" prop="feasibilityReport">
          <el-upload
            class="upload-demo"
            drag
            action="https://jsonplaceholder.typicode.com/posts/"
            multiple
          >
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">
              将文件拖到此处，或
              <em>点击上传</em>
            </div>
            <div class="el-upload__tip" slot="tip">只能上传报告文档</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="价格审核报告" prop="priceAuditReport">
          <el-upload
            class="upload-demo"
            drag
            action="https://jsonplaceholder.typicode.com/posts/"
            multiple
          >
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">
              将文件拖到此处，或
              <em>点击上传</em>
            </div>
            <div class="el-upload__tip" slot="tip">只能上传报告文档</div>
          </el-upload>
        </el-form-item>
        <el-form-item>
          <div class="btn btn-medium btn-info" @click="submitForm('analyseDemand')">提交</div>
          <div class="btn btn-medium" @click="resetForm('analyseDemand')">重置</div>
          <div class="btn btn-medium" @click="back()">返回</div>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: "AnalyseDemand",
  data() {
    return {
      analyseDemand: {
        feasibilityReport: "",
        priceAuditReport: ""
      },
      rules: {
        feasibilityReport: [
          { required: true, message: "请上传可行性分析报告", trigger: "change" }
        ],
        priceAuditReport: [
          { required: true, message: "请上传价格审核报告", trigger: "change" }
        ]
      }
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          console.log(this.analyseDemand);
          //提交 project
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
      this.analyseDemand.feasibilityReport = "";
      this.analyseDemand.priceAuditReport = "";
    },
    back() {
      if (window.history.length <= 1) {
        this.$router.push({ path: "/" });
        return false;
      } else {
        this.$router.go(-1);
      }
    }
  }
};
</script>

<style lang="less" scoped>
</style>
