<style>
  .jobInfo_item {
    margin-bottom: 20px;
  }

  .job_Line {
    width: 3px;
    height: 11px;
    margin-right: 10px;
    background-color: #3FC4FF;
    display: inline-block;
  }

  .visiHidden {
    visibility: hidden;
  }
  .PositionDesc{
    height:150px;
    overflow-y:auto;
  }
</style>
<template>
  <q-dialog v-model="persistent" content-class="bg-grey-1" persistent transition-show="scale" transition-hide="scale">
    <q-card style="width: 800px;max-width:900px;">
      <q-card-section>
        <div class="text-h6">{{optionTitle}}</div>
      </q-card-section>
      <q-card-section class="q-pt-none scroll" style="max-height: 70vh">
        <div class="jobInfo_item">
          <span class="job_Line"></span>招聘信息
        </div>
        <div class="row wrap">
          <q-select filled stack-label option-value="Id" option-label="TypeName" disable
            v-model="RecruitmentInfo.TypeId" :options="typeList" label="招聘类型" :dense="false"
            class="col-6 q-pr-lg q-pb-lg" emit-value map-options />
          <q-input filled stack-label :dense="false" disable v-model="RecruitmentInfo.PositionName"
            class="col-6 q-pb-lg" label="岗位名称" />
          <q-input filled stack-label disable :dense="false" v-model="RecruitmentInfo.SalaryStr"
            class="col-6 q-pr-lg q-pb-lg" label="薪资" />
          <q-input filled stack-label disable :dense="false" v-model="RecruitmentInfo.Experience"
            class="col-6 q-pb-lg" label="工作经验" />
          <q-input filled stack-label disable :dense="false" v-model="RecruitmentInfo.Education"
            class="col-6 q-pr-lg q-pb-lg" label="学历" />
          <q-input filled stack-label disable :dense="false" v-model="RecruitmentInfo.WorkPlace"
            class="col-6 q-pb-lg" label="工作地点" />
          <q-input filled stack-label disable :dense="false" v-model="RecruitmentInfo.PublishTimeStr" disable
            class="col-6 q-pr-lg q-pb-lg" label="更新时间" />
          <div class="PositionDesc">
              {{RecruitmentInfo.PositionDesc}}
          </div>
        </div>
        <div class="jobInfo_item" style="margin-top:20px;">
          <span class="job_Line"></span>申请信息
        </div>
        <div class="row wrap">
          <q-input filled stack-label maxlength="50" :dense="false" disable v-model="JobInfo.LinkMan"
            class="col-6 q-pr-lg q-pb-lg" label="申请人" />
          <q-input filled stack-label maxlength="50" :dense="false" disable v-model="JobInfo.LinkTel"
            class="col-6 q-pb-lg" label="电话" />
          <q-input filled stack-label :dense="false" disable v-model="JobInfo.Remark" style="margin-top: 20px"
            type="textarea" class="col-12" label="申请备注" />
        </div>
        <div class="row wrap" style="margin-top:20px;">
          <q-radio v-model="objOption.ApplyStatus" :val="1" label="已联系" />
          <q-radio v-model="objOption.ApplyStatus" :val="2" label="不合适" />
        </div>
        <div class="row wrap">
          <q-input filled stack-label :dense="false" v-model="objOption.ApplyContent" style="margin-top: 20px"
            type="textarea" class="col-12" label="内容" maxlength="200" />
        </div>

      </q-card-section>
      <q-separator />
      <q-card-actions align="right" class="bg-white">
        <q-btn label="取消" flat color="grey-10" style="font-weight:400 !important" @click="closeSaveForm" />
        <q-btn label="立即提交" color="accent q-px-md" style="font-weight:400 !important" :loading="saveLoading"
          @click="saveJob" />
      </q-card-actions>
    </q-card>
  </q-dialog>
</template>

<script>
  import {
    GetWebJobApply,
    UpdateWebJobApply,
    GetWebRecruitmentTypeList
  } from '../../api/system/webkit'
  export default {
    props: {
      saveObj: {
        type: Object,
        default: null
      }
    },
    data() {
      return {
        persistent: true,
        objOption: {
          Id: 0,
          ApplyStatus: 0, //处理状态(0-待处理，1-已联系，2-不合适）
          ApplyContent: ''
        },
        RecruitmentInfo: {}, //招聘信息
        JobInfo: {}, // 职务信息
        optionTitle: "",
        saveLoading: false,
        typeList: [],
        SalaryTypeList: [{
          Id: 1,
          Name: '固定薪资'
        }, {
          Id: 2,
          Name: '面议'
        }],

      }
    },
    mounted() {
      this.getTypeList();
      this.initObj()
    },
    methods: {
      //获取招聘类型下拉数据
      getTypeList() {
        let msg = {
          TypeName: ''
        }
        GetWebRecruitmentTypeList(msg).then(res => {
          if (res.Code == 1) {
            this.typeList = res.Data;
            let obj = {
              Id: 0,
              TypeName: '不限'
            }
            this.typeList.unshift(obj);
          }
        }).catch(() => {})
      },
      //初始化表单
      initObj() {
        if (this.saveObj && this.saveObj.Id > 0) {
          GetWebJobApply({
            Id: this.saveObj.Id
          }).then(res => {
            if (res.Code == 1) {
              this.objOption.Id = res.Data.Id;
              this.objOption.ApplyStatus = res.Data.JobInfo.ApplyStatus;
              this.objOption.ApplyContent = res.Data.JobInfo.ApplyContent;

              this.RecruitmentInfo = res.Data.RecruitmentInfo;
              this.JobInfo = res.Data.JobInfo;
              this.optionTitle = '修改招聘信息';
            }
          })
        }
      },
      //关闭弹窗
      closeSaveForm() {
        this.$emit('close')
        this.persistent = false
      },
      //保存菜单
      saveJob() {
        this.saveLoading = true
        UpdateWebJobApply(this.objOption).then(res => {
          this.saveLoading = false
          this.$q.notify({
            icon: 'iconfont icon-chenggong',
            color: 'accent',
            timeout: 2000,
            message: '数据保存成功！',
            position: 'top'
          })
          this.$emit("success")
          this.closeSaveForm()
        }).catch(() => {
          this.saveLoading = false
        })
      }
    },
  }

</script>
