<template>
  <div class="app-container" v-loading="loading">
    <el-button type="success" @click="openPrint = true">打印</el-button>
    <h3 class="text-center"><b>{{ '招聘申请表' }}</b></h3>
    <el-form ref="recruitForm" :model="form" :rules="rules" label-width="125px" disabled>
        <el-row>
            <el-col :span="6" :xs="24">
                <el-form-item label="申请人" prop="applier" >
                    {{ getUserName(form.applier) }}
                </el-form-item>
            </el-col>
            <el-col :span="6" :xs="24">
        <el-form-item label="申请部门" prop="applyDept" >
            {{ getDeptName(form.applyDept) }}
        </el-form-item>
            </el-col>
        </el-row>
        <el-row v-show="isProject">
            <el-col :span="6" :xs="24">
            <el-form-item label="项目编号：" prop="projectNumber">
                {{ form.project ? form.project.projectNumber : ""}}
            </el-form-item>
            </el-col>
            <el-col :span="6" :xs="24">
            <el-form-item label="项目名称：" prop="projectName">
                {{ form.project ? form.project.projectName : ""}}
            </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="6" :xs="24">
            <el-form-item label="岗位名称：" prop="postName">
                {{ form.postName }}
            </el-form-item>
            </el-col>
            <el-col :span="6" :xs="24">
            <el-form-item label="招聘人数：" prop="postNumber">
                {{ form.postNumber }}
            </el-form-item>
            </el-col>
        </el-row>
        <el-form-item label="岗位职责：" prop="duty">
            <el-input v-model="form.duty" placeholder="请输入分管审批意见" type="textarea"
            :autosize="{ minRows: 4 }" />
        </el-form-item>
        <el-form-item label="任职资格：" prop="qualification">
            <el-input v-model="form.qualification" placeholder="请输入分管审批意见" type="textarea"
            :autosize="{ minRows: 4 }" />
        </el-form-item>
        <el-form-item label="薪资待遇：" prop="wage">
            <el-input v-model="form.wage" placeholder="请输入分管审批意见" type="textarea"
            :autosize="{ minRows: 4 }" />
        </el-form-item>
        <el-form-item label="部门意见：" prop="deptComment">
            <el-input v-model="form.deptComment" placeholder="请输入部门意见" type="textarea"
            :autosize="{ minRows: 4 }" />
        </el-form-item>
        <el-row>
            <el-col :span="6" :xs="24" :offset="12">
            <el-form-item label="签名" prop="deptUserId">
                <span class="auditor"> {{ form.deptUserId ? form.deptUser.nickName : '' }}
                </span>
            </el-form-item>
            </el-col>
            <el-col :span="6">
            <el-form-item label="日期：" label-width="120px">
                <span> {{ parseTime(form.deptTime, '{y}-{m}-{d}') }} </span>
            </el-form-item>
            </el-col>
        </el-row>
         <el-form-item label="分管审批意见：" prop="managerComment">
            <el-input v-model="form.managerComment" placeholder="请输入分管审批意见" type="textarea"
            :autosize="{ minRows: 4 }" />
        </el-form-item>
        <el-row>
            <el-col :span="6" :xs="24" :offset="12">
            <el-form-item label="签名" prop="deptUserId">
                <span class="auditor"> {{ form.managerUserId ? form.managerUser.nickName : '' }}
                </span>
            </el-form-item>
            </el-col>
            <el-col :span="6">
            <el-form-item label="日期：" label-width="120px">
                <span> {{ parseTime(form.managerTime, '{y}-{m}-{d}') }} </span>
            </el-form-item>
            </el-col>
        </el-row>
        <el-form-item label="总经理审批意见：" prop="zjlComment">
            <el-input v-model="form.zjlComment" placeholder="请输入总经理审批意见" type="textarea" 
            :autosize="{ minRows: 4 }" />
        </el-form-item>
        <el-row>
            <el-col :span="6" :xs="24" :offset="12">
            <el-form-item label="签名" prop="deptUserId">
                <span class="auditor"> {{ form.zjlUserId ? form.zjlUser.nickName : '' }}
                </span>
            </el-form-item>
            </el-col>
            <el-col :span="6">
            <el-form-item label="日期：" label-width="120px">
                <span> {{ parseTime(form.zjlTime, '{y}-{m}-{d}') }} </span>
            </el-form-item>
            </el-col>
        </el-row>
    </el-form>
    <el-dialog title="招聘申请表格预览" :visible.sync="openPrint" width="65%" append-to-body>
      <recruit-print :form="form" @cancel="openPrint = false"></recruit-print>
    </el-dialog>
  </div>
</template>

<script>
import { listRecruit, getRecruit, delRecruit, addRecruit, updateRecruit } from "@/api/oa/recruit/recruit";
import { listUser } from '@/api/system/user';
import { getProject } from "@/api/oa/project/project";
import RecruitPrint from '../../flowable/form/components/print/recruitPrint.vue';
export default {
  components: { RecruitPrint },
  props: {
    taskForm: {
      type: Object,
      required: true
    }
  },
  computed: {
    projectNumber() {
      return this.$store.state.projectProcess.projectNumber;
    },
    projectName() {
      return this.$store.state.projectProcess.projectName;
    },
  },
  watch: {
    projectNumber(newval) {
      this.$set(this.form, "projectNumber", newval);
    },
    projectName(newval) {
      this.$set(this.form, "projectName", newval);
    },
    'taskForm.formId'() {
      this.loading = true;
      this.initForm();
    }

  },
  data() {
    return {
      isEmpty: true,
      form: {},
      rules: {},
      userList: [],
      loading: false,
      isProject: false,
      openPrint: false,
    }
  },
  mounted() {
    this.initForm();
  },
  methods: {
    /** 查询cmc招聘列表 */
    initForm() {
      getRecruit(this.taskForm.formId).then((res) => {
        if (res.data) {
            this.isEmpty = false;
            this.form = res.data;
            if (res.data) {
              if(res.data.projectId!=''){
                  this.isProject = true;
              }else{
                this.isProject = false;
              }
              this.loading = false
            }
        }})
      },
    }
  }
</script>

<style lang="scss" scoped>
::v-deep .el-input.is-disabled .el-input__inner {
  color: #686a6e;
}

::v-deep .el-textarea.is-disabled .el-textarea__inner,
.el-radio__input.is-disabled+span.el-radio__label {
  color: #686a6e;
}

::v-deep .el-radio__input.is-disabled+span.el-radio__label {
  color: #686a6e;
}
</style>