<!-- 企业需求弹框 -->
<template>
  <el-dialog title="基本信息" :model-value="isShow" @close="close">
    <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 v-if="false">
        <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>

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

<!--      <CityOptions-->
<!--          disabled-->
<!--          v-model="modelValue"-->
<!--          :labelWidth="labelWidth"-->
<!--          ref="cityFormRef"-->
<!--      />-->
      <el-form-item
          label="国家"
          prop="country"
      >
        <el-select
            v-model="modelValue.country"
            placeholder="请选择国家"
        >
          <el-option
              v-for="option in countryOptions"
              :label="option.value"
              :value="option.key"
          />
        </el-select>
      </el-form-item>

      <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 {countryOptions, demandCategoryList} from "@/utils/parameter";
import WangEditor from "@/components/WangEditor";
import CityOptions from "@/views/components/CityOptions";
import FieldOptions from "@/views/components/FieldOptions";
import InputBoxAdd from "@/views/components/InputBoxAdd";
import {ElMessage} from "element-plus";
import {toRefs} from "vue";
import useUserStore from "@/store/modules/user";
import {batchTechnologyDemand} from "@/api/dataApproval/enterpriseTechnologyDemand";

const userStore = useUserStore();
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(demandCategoryList);
const approve = async (status) => {
  let title = status == 1 ? "通过" : "驳回";
  // await updateTechnologyDemand({ id: modelValue.value.id, status });
  await batchTechnologyDemand(modelValue.value.id, status)
  userStore.getUnApprovedTechnology();
  ElMessage.success(`已${title}需求`);
  emit("update:isShow", false);
  emit("update-list");
};
const close = () => {
  emit("update:isShow", false);
};
</script>
<style></style>
