<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="text-caption q-mb-lg q-px-md text-grey-6">招聘类型信息</div>
        <div class="row wrap">
          <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
  } 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: ''
        },
        optionTitle: "",
        saveLoading: false,
      }
    },
    mounted() {
      this.initObj()
    },
    methods: {
      //初始化表单
      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.ApplyStatus;
              this.objOption.ApplyContent = res.Data.ApplyContent;
              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>
