<!-- 企业需求弹框 -->
<template>
  <el-dialog title="基本信息" v-model="isShow">
    <el-form
      ref="formRef"
      :model="modelValue"
      :label-width="labelWidth + 'px'"
      disabled
    >
      <p><b>基本信息</b></p>
      <el-row>
        <el-col :span="24">
          <el-form-item label="成果需求名称:" prop="title">
            <el-input v-model="modelValue.title"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <!-- <el-checkbox label="0" @change="handleCheck">其他</el-checkbox> -->
          <el-form-item label="需求类别:">
            <el-checkbox-group v-model="modelValue.kinds">
              <el-checkbox
                v-for="item in checkList"
                :key="item.id"
                :label="item.name"
                >{{ item.name }}</el-checkbox
              >
            </el-checkbox-group>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="需求描述:" prop="introduce">
            <!-- <Editor v-model="modelValue.add" :minHeight="150" /> -->
            <WangEditor
              v-model="modelValue.introduce"
              width="100%"
              min-height="150px"
              readOnly
            ></WangEditor>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- <CityOptions
          v-model="form"
          :labelWidth="labelWidth"
          ref="cityForm"
        /> -->
      <FieldOptions
        v-model="modelValue"
        :labelWidth="labelWidth"
        disabled
        ref="fieldFormRef"
      />

      <el-row>
        <el-col :span="12">
          <el-form-item
            label="成果需求预算:"
            :prop="modelValue.budgetMode == 1 ? 'budget' : ''"
          >
            <el-input
              v-model="modelValue.budget"
              oninput="value=value.replace(/[^\d.]/g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').replace(/^\./g, '')"
              placeholder="请输入技术需求预算"
            >
              <template #append>万元</template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label-width="50px">
            <el-checkbox
              false-label="1"
              true-label="2"
              v-model="modelValue.budgetMode"
              >面议</el-checkbox
            >
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="截止时间:" prop="deadline">
            <el-date-picker
              style="width: 100%"
              v-model="modelValue.deadline"
              type="date"
              value-format="YYYY-MM-DD"
              placeholder="请选择截止时间"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="需求联系人:" prop="name">
            <el-input
              v-model="modelValue.name"
              placeholder="请输入需求联系人"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="联系人手机号:" prop="mobile">
            <el-input
              v-model="modelValue.mobile"
              placeholder="请输入联系人手机号"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- <el-row>
          <el-col :span="12">
            <el-form-item label="需求提交人:" prop="commitUserName">
              <el-input
                v-model="modelValue.commitUserName"
                placeholder="请输入需求提交人"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="需求提交人手机号:" prop="commitUserPhone">
              <el-input
                v-model="modelValue.commitUserPhone"
                placeholder="请输入需求提交人手机号"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row> -->

      <el-row>
        <el-col :span="24">
          <InputBoxAdd
            :labelWidth="labelWidth"
            v-model="modelValue"
            title="想合作的单位及模式"
            placeholder=""
            disabled
            fieldKey="wants"
            ref="directionsFormRef"
          />
        </el-col>
      </el-row>
    </el-form>
    <el-row type="flex" justify="end">
      <el-button type="primary" @click="approve('2')">驳回</el-button>
      <el-button type="primary" @click="approve('1')">通过需求</el-button>
    </el-row>
  </el-dialog>
</template>
<script setup>
import { updateTechnologyDemand } from "@/api/dataApproval/enterpriseTechnologyDemand";
import WangEditor from "@/components/WangEditor";
import FieldOptions from "@/views/components/FieldOptions";
import InputBoxAdd from "@/views/components/InputBoxAdd";
import { ElMessage } from "element-plus";
import { ref, toRefs } from "vue";
const emit = defineEmits(["update-list"]);
const props = defineProps({
  isShow: {
    type: Boolean,
    required: true,
  },
  modelValue: {
    type: Object,
    required: true,
  },
});
const { isShow, modelValue } = toRefs(props);
const labelWidth = 160;
const checkList = reactive([
  {
    id: 1,
    name: "成果推广",
  },
  {
    id: 2,
    name: "关键成果解决",
  },
  {
    id: 3,
    name: "对接专家院士",
  },
  {
    id: 4,
    name: "上市辅导",
  },
]);
const approve = async (status) => {
  let title = status == 1 ? "通过" : "驳回";
  await updateTechnologyDemand({ id: modelValue.value.id, status });
  ElMessage.success(`已${title}需求`);
  emit("update:is-show", false);
  emit("update-list");
};
</script>
<style></style>
