<template>
  <div
    class="ZTGlobal"
    style="width: 100%; padding: 1rem 1rem 0rem 1rem; color: white"
  >
    <el-row :gutter="10">
      <el-col :span="24">
        <el-form ref="ruleForm" :model="form" :rules="rules" label-width="90px">
          <el-form-item label="项目名称" size="mini" prop="projectname">
            <el-col :span="20">
              <el-input size="mini" v-model="form.projectname"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="申请单位" size="mini" prop="applicant">
            <el-col :span="20">
              <el-input size="mini" v-model="form.applicant"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="项目地址" size="mini" prop="projectaddress">
            <el-col :span="20">
              <el-input size="mini" v-model="form.projectaddress"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="地块编号" size="mini" prop="plotnumber">
            <el-col :span="20">
              <el-input size="mini" v-model="form.plotnumber"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="用地面积" size="mini" prop="landarea">
            <el-col :span="20">
              <el-input size="mini" v-model="form.landarea"></el-input>
            </el-col>
            <el-col :span="4">平方米</el-col>
          </el-form-item>
          <el-form-item label="用地性质" size="mini" prop="landusenature">
            <el-col :span="20">
              <el-select
                v-model="form.landusenature"
                placeholder="用地性质"
                clearable
              >
                <el-option
                  v-for="dict in zt_landusenature"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-col>
          </el-form-item>
          <el-form-item label="项目定位" size="mini" prop="projectpositioning">
            <el-col :span="20">
              <el-input
                size="mini"
                v-model="form.projectpositioning"
              ></el-input>
            </el-col>
          </el-form-item>
          <el-form-item
            label="项目总投资"
            size="mini"
            prop="totalprojectinvestment"
          >
            <el-col :span="20">
              <el-input
                size="mini"
                v-model="form.totalprojectinvestment"
              ></el-input>
            </el-col>
            <el-col :span="4">亿元</el-col>
          </el-form-item>
          <el-form-item label="资金来源" size="mini" prop="fundingsource">
            <el-col :span="20">
              <el-select
                v-model="form.fundingsource"
                placeholder="资金来源"
                clearable
              >
                <el-option
                  v-for="dict in zt_fundingsource"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
              <!-- <el-input size="mini" v-model="form.fundingsource"></el-input> -->
            </el-col>
          </el-form-item>

          <el-form-item label="土地情况" size="mini" prop="landsituation">
            <el-col :span="20">
              <el-input
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 4 }"
                size="mini"
                v-model="form.landsituation"
              ></el-input>
            </el-col>
          </el-form-item>
        </el-form>
        <div class="SaveCenter">
          <el-button type="primary" @click="submitForm('ruleForm')"
            >添加</el-button
          >
          <el-button @click="resetForm('ruleForm')">重置</el-button>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { v4 as uuidv4 } from "uuid";
import { addProjectinformation } from "@/api/zt/ztApi.js";
export default {
  data() {
    return {
      form: {
        id: "",
        meetingprogress: "0",
        applicant: "",
        projectname: "",
        projectaddress: "",
        plotnumber: "",
        landarea: "",
        landusenature: "",
        projectpositioning: "",
        landsituation: "",
        totalprojectinvestment: "",
        fundingsource: "",
      },
      zt_landusenature: window.dict.zt_landusenature,
      zt_fundingsource: window.dict.zt_fundingsource,
      rules: {
        projectname: [
          { required: true, message: "请输入项目名称", trigger: "blur" },
        ],
        plotnumber: [
          { required: true, message: "请输入地块编号", trigger: "blur" },
        ],
        landusenature: [
          { required: true, message: "用地性质", trigger: "blur" },
        ],
      },
    };
  },
  props: {
    info: {
      type: Object,
      default: () => {
        return {};
      },
    },
    layerid: {
      type: String,
      default: "",
    },
    lydata: {
      type: Object,
      default: () => {
        return {};
      },
    },
    lyoption: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  computed: {},
  mounted() {
    // this.init();
  },
  methods: {
    submitForm(formName) {
      let that = this;
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          that.form.id = uuidv4();
          that.form.meetingprogress = "0";
          // window.projectinformation.push(that.form);
          let result = await addProjectinformation(that.form);
          if (result.code) {
            that.$message({
              message: "添加成功",
              type: "success",
            });
            that.$layer.close(that.layerid);
          }
          debugger;
          // that.lyoption.cancel();
        } else {
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>
<style lang="scss">
@import "@/../../zt.scss";
</style>
<style lang="scss" scoped></style>
