<template>
  <div  class="createPost-container">
    <el-form ref="postForm" class="form-container">
      <div class="createPost-main-container">
        <el-form-item style="margin-bottom: 20px;" label="用户UID：">
          <el-input v-model="postForm.uid" :rows="1" placeholder="" />
        </el-form-item>

        <el-form-item style="margin-bottom: 20px;" label="对接方向：">
          <occupation_direction v-model="postForm.occupation_direction"></occupation_direction>
        </el-form-item>

        <el-form-item style="margin-bottom: 20px;" label="需要技能：">
          <skill v-model="postForm.match_skills" />
        </el-form-item>

        <el-form-item style="margin-bottom: 20px;" label="全职开发：">
          <el-radio v-model="postForm.is_appoint_freelance" label="1">不需要</el-radio>
          <el-radio v-model="postForm.is_appoint_freelance" label="2">需要</el-radio>
        </el-form-item>

        <el-form-item style="margin-bottom: 20px;" label="驻场开发：">
          <el-radio v-model="postForm.publish_present_hire" label="0">不需要</el-radio>
          <el-radio v-model="postForm.publish_present_hire" label="1">需要</el-radio>
        </el-form-item>

        <el-form-item v-if="postForm.publish_present_hire=='1'" style="margin-bottom: 20px;" label="驻场地区：">
          <area_select v-model="postForm.area" />
        </el-form-item>

        <el-form-item style="margin-bottom: 20px;" label="项目经理：">
          <el-radio v-model="postForm.is_need_manager" label="1">不需要</el-radio>
          <el-radio v-model="postForm.is_need_manager" label="2">需要</el-radio>
        </el-form-item>

        <el-form-item style="margin-bottom: 20px;" label="项目预算：">
          <el-radio v-model="postForm.ys_money_type" label="1">6K以下</el-radio>
          <el-radio v-model="postForm.ys_money_type" label="2">6-12K</el-radio>
          <el-radio v-model="postForm.ys_money_type" label="3">12-18K</el-radio>
          <el-radio v-model="postForm.ys_money_type" label="4">18K+</el-radio>
        </el-form-item>

        <el-form-item style="margin-bottom: 20px;" label="需求描述：">
          <el-input v-model="postForm.description" :rows="10" type="textarea" placeholder="" />
        </el-form-item>

        <el-form-item style="margin-bottom: 30px;">
          <el-button v-loading="loading" style="margin-left: 10px;" type="success" @click="submitForm">
            确定发布
          </el-button>
        </el-form-item>
      </div>
    </el-form>
  </div>
</template>

<script>
  import occupation_direction from "/components/form/occupation_direction.vue";
  import skill from "/components/form/skill.vue";
  import area_select from "/components/form/area_select.vue";
  export default {
    components: {occupation_direction,skill,area_select},
    props: {
      getInfoParent: {
        type: Function,
        default: null
      }
    },
    data() {
      return {
        loading:false,
        postForm: {
          is_need_manager:"1",
          is_appoint_freelance:"1",
          ys_money_type:"1",
          occupation_direction:"",
          publish_present_hire:"0"
        },
      }
    },
    methods: {
      async submitForm() {
        if(this.loading)
        {
          return ;
        }
        this.loading=true;
        const res = await this.$post('/api/admin/job/publish3', this.postForm)
        if (res.status == 1) {
          this.$notify({
            title: '成功',
            message: '发布成功',
            type: 'success',
            duration: 2000
          })
          this.getInfoParent();
        }
        else
        {
          this.loading=false;
        }
      },
    }
  }
</script>

<style lang="scss" scoped>
  @import "~@/styles/mixin.scss";
  .createPost-container {
    position: relative;
    margin-top: 20px;

    .createPost-main-container {
      padding: 0px 45px 20px 50px;

      .postInfo-container {
        position: relative;
        @include clearfix;
        margin-bottom: 10px;

        .postInfo-container-item {
          float: left;
        }
      }
    }

    .word-counter {
      width: 40px;
      position: absolute;
      right: 10px;
      top: 0px;
    }
  }

  .article-textarea ::v-deep {
    textarea {
      padding-right: 40px;
      resize: none;
      border: none;
      border-radius: 0px;
      border-bottom: 1px solid #bfcbd9;
    }
  }
</style>
