<template>
  <el-form
    ref="formRef"
    :model="form"
    :rules="rules"
    :label-width="labelWidth + 'px'"
  >
    <div class="form_title">
      <p><b>基本信息</b></p>
    </div>

    <el-row>
      <el-col :span="24">
        <el-form-item label="产品名称:" prop="title">
          <el-input
            v-model="form.title"
            placeholder="请输入产品名称"
          ></el-input>
        </el-form-item>
      </el-col>
    </el-row>

    <FieldOptions v-model="form" :labelWidth="labelWidth" ref="fieldFormRef" />

    <InputBoxAdd
      :labelWidth="labelWidth"
      v-model="form"
      title="应用客户"
      placeholder="请输入应用客户"
      fieldKey="customers"
      ref="customerFormRef"
    />

    <el-row>
      <el-col :span="24">
        <el-form-item label="产品成熟度:" prop="maturity">
          <el-select v-model="form.maturity" clearable placeholder="请选择">
            <el-option
              v-for="item in maturityOptions"
              :key="item.key"
              :label="item.value"
              :value="item.key"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-form-item label="成果领先性:" prop="leadStandard">
          <el-select v-model="form.leadStandard" clearable placeholder="请选择">
            <el-option
              v-for="item in leadOptions"
              :key="item.key"
              :label="item.value"
              :value="item.key"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-form-item label="合作模式:">
          <el-select
            v-model="form.cooperationMode"
            clearable
            placeholder="请选择"
          >
            <el-option
              v-for="item in cooperationOptions"
              :key="item.key"
              :label="item.value"
              :value="item.key"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-col>
    </el-row>

    <InputBoxAdd
      :labelWidth="labelWidth"
      v-model="form"
      title="关键词"
      placeholder="请输入关键词"
      fieldKey="keywords"
      ref="keywordsForm"
    />

    <el-row>
      <el-col :span="24">
        <el-form-item label="产品简介:" prop="introduce">
          <wangEditor
            v-model="form.introduce"
            min-height="150px"
            width="100%"
            ref="introduceRef"
          />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="产品图片:" prop="image">
          <ImageUpload v-model="form.image" :limit="1" />
        </el-form-item>
      </el-col>
    </el-row>
    <p>
      <b>图片材料上传</b>
    </p>
    <el-row>
      <el-col :span="24">
        <el-form-item label="证明材料:" prop="material">
          <FileUpload
            v-model="form.material"
            :limit="1"
            :fileType="['doc', 'xls', 'pdf', 'jpg', 'png', 'zip']"
          />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script setup>
import CityOptions from "@/views/components/CityOptions";
import FieldOptions from "@/views/components/FieldOptions";
import InputBoxAdd from "@/views/components/InputBoxAdd";
import { reactive } from "vue";
import { useRoute } from "vue-router";

const route = useRoute();
const data = reactive({
  form: {},
});

const getAchievementInfo = async () => {
  
};
</script>

<!-- <script>
export default {
  components: {
    CityOptions,
    FieldOptions,
    InputBoxAdd,
  },
  props: {
    value: Object,
    isAdd: {
      type: Boolean,
      default: true,
    },
    showTitle: {
      type: Boolean,
      default: false,
    },
    labelWidth: {
      type: Number,
      default: 120,
    },
  },
  data() {
    return {
      rules: {
        title: [{ required: true, message: "请输入", trigger: "blur" }],
        maturity: [{ required: true, message: "请选择", trigger: "change" }],
        lead_standard: [
          { required: true, message: "请选择", trigger: "change" },
        ],
        description: [{ required: true, message: "请输入", trigger: "blur" }],
        image: [
          { required: true, message: "请上传", trigger: ["change", "blur"] },
        ],
      },
    };
  },
  methods: {
    submitForm() {
      let flag = false;
      this.$refs["formRef"].validate((valid) => {
        const fieldForm = this.$refs.fieldForm.submitForm();
        const customerForm = this.$refs.customerForm.submitForm();
        console.log();
        const directionsForm =
          this.value.mode == 2 ? this.$refs.directionsForm.submitForm() : true;
        const keywordsForm = this.$refs.keywordsForm.submitForm();
        if (
          valid &&
          fieldForm &&
          customerForm &&
          directionsForm &&
          keywordsForm
        ) {
          flag = !flag;
        }
      });
      return flag;
    },
  },
};
</script> -->
<style lang="scss" scoped>
.form_title {
  font-weight: 700;
  margin-bottom: 30px;
}
// 上传图片框限制
// ::v-deep .el-upload--picture-card {
//   width: 120px;
//   height: 120px;
//   line-height: 120px;
// }
.el-select,
.el-date-editor {
  display: block;
  width: 100%;
}
</style>
