<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入手机号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证号" prop="idcardNo">
        <el-input
          v-model="queryParams.idcardNo"
          placeholder="请输入身份证号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="员工类型" prop="employeType">
        <el-select v-model="queryParams.employeType" placeholder="请选择员工类型" clearable size="small">
          <el-option
            v-for="dict in employeTypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
          <el-option
            v-for="dict in statusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['bizapprove:employee:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['bizapprove:employee:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['bizapprove:employee:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['bizapprove:employee:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="employeeList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="id" />
<!--      <el-table-column label="申请人ID" align="center" prop="applyUserId" />-->
<!--      <el-table-column label="申请人code" align="center" prop="applyUserName" />-->
<!--      <el-table-column label="申请人昵称" align="center" prop="applyUserNickName" />-->
<!--      <el-table-column label="申请人部门ID" align="center" prop="applyDeptId" />-->
<!--      <el-table-column label="申请人部门名称" align="center" prop="applyDeptName" />-->
<!--      <el-table-column label="申请时间" align="center" prop="applyTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.applyTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="结束时间" align="center" prop="finishTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.finishTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="流程实例ID" align="center" prop="instanceId" />-->
<!--      <el-table-column label="流程定义key" align="center" prop="processKey" />-->
<!--      <el-table-column label="员工ID" align="center" prop="employeId" />-->
      <el-table-column label="唯一码" align="center" prop="uniqueCode" />
<!--      <el-table-column label="单位ID" align="center" prop="deptId" />-->
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="手机号" align="center" prop="phone" />
      <el-table-column label="身份证号" align="center" prop="idcardNo" />
      <el-table-column label="性别" align="center" prop="sex" :formatter="sexFormat" />
      <el-table-column label="出生日期" align="center" prop="birthDay" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.birthDay, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否独生子女" align="center" prop="onlyChild" :formatter="onlyChildFormat" />
      <el-table-column label="民族" align="center" prop="folk" :formatter="folkFormat" />
      <el-table-column label="政治面貌" align="center" prop="politicalStatus" :formatter="politicalStatusFormat" />
      <el-table-column label="籍贯" align="center" prop="nativePlace" />
      <el-table-column label="第一学历" align="center" prop="firstEducation" :formatter="firstEducationFormat" />
      <el-table-column label="第一学校" align="center" prop="firstEducationSchool" />
      <el-table-column label="第一专业" align="center" prop="firstEducationProfession" />
      <el-table-column label="最高学历学位" align="center" prop="topEducation" :formatter="topEducationFormat" />
      <el-table-column label="最高毕业学校" align="center" prop="topEducationSchool" />
      <el-table-column label="最高专业" align="center" prop="topEducationProfession" />
      <el-table-column label="技术职称" align="center" prop="professionalTitle" :formatter="professionalTitleFormat" />
      <el-table-column label="职务" align="center" prop="postJob" :formatter="postJobFormat" />
      <el-table-column label="岗位代码" align="center" prop="postCode" :formatter="postCodeFormat" />
      <el-table-column label="职务" align="center" prop="postTitle" :formatter="postTitleFormat" />
      <el-table-column label="职级" align="center" prop="postLevel" :formatter="postLevelFormat" />
      <el-table-column label="任同等职务时间" align="center" prop="postTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.postTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="参加工作时间" align="center" prop="workDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.workDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="入职时间" align="center" prop="hiredate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.hiredate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="解雇日期" align="center" prop="firedate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.firedate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="员工类型" align="center" prop="employeType" :formatter="employeTypeFormat" />
      <el-table-column label="人事档案是否在集团" align="center" prop="personnelDossier" :formatter="personnelDossierFormat" />
      <el-table-column label="人事档案存放地" align="center" prop="personnelDossierLocation" />
      <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" />
      <el-table-column label="审批状态" align="center" prop="approveStatus" :formatter="approveStatusFormat" />
      <el-table-column label="审批类型" align="center" prop="approveType" :formatter="approveTypeFormat" />
      <el-table-column label="审批意见" align="center" prop="approveContent" />
      <el-table-column label="审批人" align="center" prop="approveBy" />
      <el-table-column label="审批时间" align="center" prop="approveTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.approveTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="0:正常，1:已删除" align="center" prop="deleteStatus" />
      <el-table-column label="删除时间" align="center" prop="deleteTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.deleteTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="删除人" align="center" prop="deleteBy" />
      <el-table-column label="创建日期" align="center" prop="createDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新日期" align="center" prop="updateDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['bizapprove:employee:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['bizapprove:employee:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改员工花名册审批业务对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="申请人ID" prop="applyUserId">
          <el-input v-model="form.applyUserId" placeholder="请输入申请人ID" />
        </el-form-item>
        <el-form-item label="申请人code" prop="applyUserName">
          <el-input v-model="form.applyUserName" placeholder="请输入申请人code" />
        </el-form-item>
        <el-form-item label="申请人昵称" prop="applyUserNickName">
          <el-input v-model="form.applyUserNickName" placeholder="请输入申请人昵称" />
        </el-form-item>
        <el-form-item label="申请人部门ID" prop="applyDeptId">
          <el-input v-model="form.applyDeptId" placeholder="请输入申请人部门ID" />
        </el-form-item>
        <el-form-item label="申请人部门名称" prop="applyDeptName">
          <el-input v-model="form.applyDeptName" placeholder="请输入申请人部门名称" />
        </el-form-item>
        <el-form-item label="申请时间" prop="applyTime">
          <el-date-picker clearable size="small"
            v-model="form.applyTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择申请时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束时间" prop="finishTime">
          <el-date-picker clearable size="small"
            v-model="form.finishTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择结束时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="流程实例ID" prop="instanceId">
          <el-input v-model="form.instanceId" placeholder="请输入流程实例ID" />
        </el-form-item>
        <el-form-item label="流程定义key" prop="processKey">
          <el-input v-model="form.processKey" placeholder="请输入流程定义key" />
        </el-form-item>
        <el-form-item label="员工ID" prop="employeId">
          <el-input v-model="form.employeId" placeholder="请输入员工ID" />
        </el-form-item>
        <el-form-item label="唯一码" prop="uniqueCode">
          <el-input v-model="form.uniqueCode" placeholder="请输入唯一码" />
        </el-form-item>
        <el-form-item label="单位ID" prop="deptId">
          <el-input v-model="form.deptId" placeholder="请输入单位ID" />
        </el-form-item>
        <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="手机号" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入手机号" />
        </el-form-item>
        <el-form-item label="身份证号" prop="idcardNo">
          <el-input v-model="form.idcardNo" placeholder="请输入身份证号" />
        </el-form-item>
        <el-form-item label="性别" prop="sex">
          <el-select v-model="form.sex" placeholder="请选择性别">
            <el-option
              v-for="dict in sexOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="出生日期" prop="birthDay">
          <el-date-picker clearable size="small"
            v-model="form.birthDay"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择出生日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="是否独生子女" prop="onlyChild">
          <el-input v-model="form.onlyChild" placeholder="请输入是否独生子女" />
        </el-form-item>
        <el-form-item label="民族" prop="folk">
          <el-input v-model="form.folk" placeholder="请输入民族" />
        </el-form-item>
        <el-form-item label="政治面貌">
          <el-radio-group v-model="form.politicalStatus">
            <el-radio
              v-for="dict in politicalStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictValue"
            >{{dict.dictLabel}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="籍贯" prop="nativePlace">
          <el-input v-model="form.nativePlace" placeholder="请输入籍贯" />
        </el-form-item>
        <el-form-item label="第一学历" prop="firstEducation">
          <el-input v-model="form.firstEducation" placeholder="请输入第一学历" />
        </el-form-item>
        <el-form-item label="第一学校" prop="firstEducationSchool">
          <el-input v-model="form.firstEducationSchool" placeholder="请输入第一学校" />
        </el-form-item>
        <el-form-item label="第一专业" prop="firstEducationProfession">
          <el-input v-model="form.firstEducationProfession" placeholder="请输入第一专业" />
        </el-form-item>
        <el-form-item label="最高学历学位" prop="topEducation">
          <el-input v-model="form.topEducation" placeholder="请输入最高学历学位" />
        </el-form-item>
        <el-form-item label="最高毕业学校" prop="topEducationSchool">
          <el-input v-model="form.topEducationSchool" placeholder="请输入最高毕业学校" />
        </el-form-item>
        <el-form-item label="最高专业" prop="topEducationProfession">
          <el-input v-model="form.topEducationProfession" placeholder="请输入最高专业" />
        </el-form-item>
        <el-form-item label="技术职称" prop="professionalTitle">
          <el-input v-model="form.professionalTitle" placeholder="请输入技术职称" />
        </el-form-item>
        <el-form-item label="职务" prop="postJob">
          <el-input v-model="form.postJob" placeholder="请输入职务" />
        </el-form-item>
        <el-form-item label="岗位代码" prop="postCode">
          <el-input v-model="form.postCode" placeholder="请输入岗位代码" />
        </el-form-item>
        <el-form-item label="职务" prop="postTitle">
          <el-input v-model="form.postTitle" placeholder="请输入职务" />
        </el-form-item>
        <el-form-item label="职级" prop="postLevel">
          <el-input v-model="form.postLevel" placeholder="请输入职级" />
        </el-form-item>
        <el-form-item label="任同等职务时间" prop="postTime">
          <el-date-picker clearable size="small"
            v-model="form.postTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择任同等职务时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="参加工作时间" prop="workDate">
          <el-date-picker clearable size="small"
            v-model="form.workDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择参加工作时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="入职时间" prop="hiredate">
          <el-date-picker clearable size="small"
            v-model="form.hiredate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择入职时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="解雇日期" prop="firedate">
          <el-date-picker clearable size="small"
            v-model="form.firedate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择解雇日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="员工类型" prop="employeType">
          <el-select v-model="form.employeType" placeholder="请选择员工类型">
            <el-option
              v-for="dict in employeTypeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="人事档案是否在集团" prop="personnelDossier">
          <el-input v-model="form.personnelDossier" placeholder="请输入人事档案是否在集团" />
        </el-form-item>
        <el-form-item label="人事档案存放地" prop="personnelDossierLocation">
          <el-input v-model="form.personnelDossierLocation" placeholder="请输入人事档案存放地" />
        </el-form-item>
        <el-form-item label="状态">
          <el-radio-group v-model="form.status">
            <el-radio
              v-for="dict in statusOptions"
              :key="dict.dictValue"
              :label="dict.dictValue"
            >{{dict.dictLabel}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审批状态">
          <el-radio-group v-model="form.approveStatus">
            <el-radio
              v-for="dict in approveStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictValue"
            >{{dict.dictLabel}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审批类型" prop="approveType">
          <el-select v-model="form.approveType" placeholder="请选择审批类型">
            <el-option
              v-for="dict in approveTypeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="审批意见">
          <editor v-model="form.approveContent" :min-height="192"/>
        </el-form-item>
        <el-form-item label="审批人" prop="approveBy">
          <el-input v-model="form.approveBy" placeholder="请输入审批人" />
        </el-form-item>
        <el-form-item label="审批时间" prop="approveTime">
          <el-date-picker clearable size="small"
            v-model="form.approveTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择审批时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="0:正常，1:已删除">
          <el-radio-group v-model="form.deleteStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="删除时间" prop="deleteTime">
          <el-date-picker clearable size="small"
            v-model="form.deleteTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择删除时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="删除人" prop="deleteBy">
          <el-input v-model="form.deleteBy" placeholder="请输入删除人" />
        </el-form-item>
        <el-form-item label="创建日期" prop="createDate">
          <el-date-picker clearable size="small"
            v-model="form.createDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择创建日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="更新日期" prop="updateDate">
          <el-date-picker clearable size="small"
            v-model="form.updateDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择更新日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="删除标志" prop="delFlag">
          <el-input v-model="form.delFlag" placeholder="请输入删除标志" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listEmployee, getEmployee, delEmployee, addEmployee, updateEmployee, exportEmployee } from "@/api/bizapprove/employee";
import Editor from '@/components/Editor';

export default {
  name: "Employee",
  components: {
    Editor,
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 员工花名册审批业务表格数据
      employeeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 性别字典
      sexOptions: [],
      // 是否独生子女字典
      onlyChildOptions: [],
      // 民族字典
      folkOptions: [],
      // 政治面貌字典
      politicalStatusOptions: [],
      // 第一学历字典
      firstEducationOptions: [],
      // 最高学历学位字典
      topEducationOptions: [],
      // 技术职称字典
      professionalTitleOptions: [],
      // 职务字典
      postJobOptions: [],
      // 岗位代码字典
      postCodeOptions: [],
      // 职务字典
      postTitleOptions: [],
      // 职级字典
      postLevelOptions: [],
      // 员工类型字典
      employeTypeOptions: [],
      // 人事档案是否在集团字典
      personnelDossierOptions: [],
      // 状态字典
      statusOptions: [],
      // 审批状态字典
      approveStatusOptions: [],
      // 审批类型字典
      approveTypeOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        applyUserId: null,
        applyUserName: null,
        applyUserNickName: null,
        applyDeptId: null,
        applyDeptName: null,
        applyTime: null,
        finishTime: null,
        instanceId: null,
        processKey: null,
        employeId: null,
        uniqueCode: null,
        deptId: null,
        name: null,
        phone: null,
        idcardNo: null,
        sex: null,
        birthDay: null,
        onlyChild: null,
        folk: null,
        politicalStatus: null,
        nativePlace: null,
        firstEducation: null,
        firstEducationSchool: null,
        firstEducationProfession: null,
        topEducation: null,
        topEducationSchool: null,
        topEducationProfession: null,
        professionalTitle: null,
        postJob: null,
        postCode: null,
        postTitle: null,
        postLevel: null,
        postTime: null,
        workDate: null,
        hiredate: null,
        firedate: null,
        employeType: null,
        personnelDossier: null,
        personnelDossierLocation: null,
        status: null,
        approveStatus: null,
        approveType: null,
        approveContent: null,
        approveBy: null,
        approveTime: null,
        deleteStatus: null,
        deleteTime: null,
        deleteBy: null,
        createDate: null,
        updateDate: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
    this.getDicts("sys_user_sex").then(response => {
      this.sexOptions = response.data;
    });
    this.getDicts("sys_yes_no").then(response => {
      this.onlyChildOptions = response.data;
    });
    this.getDicts("sys_folk").then(response => {
      this.folkOptions = response.data;
    });
    this.getDicts("sys_political_status").then(response => {
      this.politicalStatusOptions = response.data;
    });
    this.getDicts("sys_education").then(response => {
      this.firstEducationOptions = response.data;
    });
    this.getDicts("sys_education").then(response => {
      this.topEducationOptions = response.data;
    });
    this.getDicts("sys_professional_title").then(response => {
      this.professionalTitleOptions = response.data;
    });
    this.getDicts("sys_post").then(response => {
      this.postJobOptions = response.data;
    });
    this.getDicts("sys_employe_post").then(response => {
      this.postCodeOptions = response.data;
    });
    this.getDicts("sys_post").then(response => {
      this.postTitleOptions = response.data;
    });
    this.getDicts("sys_post_level").then(response => {
      this.postLevelOptions = response.data;
    });
    this.getDicts("sys_employe_type").then(response => {
      this.employeTypeOptions = response.data;
    });
    this.getDicts("sys_employe_dossier").then(response => {
      this.personnelDossierOptions = response.data;
    });
    this.getDicts("sys_employe_status").then(response => {
      this.statusOptions = response.data;
    });
    this.getDicts("employe_approve_status").then(response => {
      this.approveStatusOptions = response.data;
    });
    this.getDicts("employe_approve_type").then(response => {
      this.approveTypeOptions = response.data;
    });
  },
  methods: {
    /** 查询员工花名册审批业务列表 */
    getList() {
      this.loading = true;
      listEmployee(this.queryParams).then(response => {
        this.employeeList = response.rows;

        this.total = response.total;
        this.loading = false;
      });
    },
    // 性别字典翻译
    sexFormat(row, column) {
      return this.selectDictLabel(this.sexOptions, row.sex);
    },
    // 是否独生子女字典翻译
    onlyChildFormat(row, column) {
      return this.selectDictLabel(this.onlyChildOptions, row.onlyChild);
    },
    // 民族字典翻译
    folkFormat(row, column) {
      return this.selectDictLabel(this.folkOptions, row.folk);
    },
    // 政治面貌字典翻译
    politicalStatusFormat(row, column) {
      return this.selectDictLabel(this.politicalStatusOptions, row.politicalStatus);
    },
    // 第一学历字典翻译
    firstEducationFormat(row, column) {
      return this.selectDictLabel(this.firstEducationOptions, row.firstEducation);
    },
    // 最高学历学位字典翻译
    topEducationFormat(row, column) {
      return this.selectDictLabel(this.topEducationOptions, row.topEducation);
    },
    // 技术职称字典翻译
    professionalTitleFormat(row, column) {
      return this.selectDictLabel(this.professionalTitleOptions, row.professionalTitle);
    },
    // 职务字典翻译
    postJobFormat(row, column) {
      return this.selectDictLabel(this.postJobOptions, row.postJob);
    },
    // 岗位代码字典翻译
    postCodeFormat(row, column) {
      return this.selectDictLabel(this.postCodeOptions, row.postCode);
    },
    // 职务字典翻译
    postTitleFormat(row, column) {
      return this.selectDictLabel(this.postTitleOptions, row.postTitle);
    },
    // 职级字典翻译
    postLevelFormat(row, column) {
      return this.selectDictLabel(this.postLevelOptions, row.postLevel);
    },
    // 员工类型字典翻译
    employeTypeFormat(row, column) {
      return this.selectDictLabel(this.employeTypeOptions, row.employeType);
    },
    // 人事档案是否在集团字典翻译
    personnelDossierFormat(row, column) {
      return this.selectDictLabel(this.personnelDossierOptions, row.personnelDossier);
    },
    // 状态字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.status);
    },
    // 审批状态字典翻译
    approveStatusFormat(row, column) {
      return this.selectDictLabel(this.approveStatusOptions, row.approveStatus);
    },
    // 审批类型字典翻译
    approveTypeFormat(row, column) {
      return this.selectDictLabel(this.approveTypeOptions, row.approveType);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        applyUserId: null,
        applyUserName: null,
        applyUserNickName: null,
        applyDeptId: null,
        applyDeptName: null,
        applyTime: null,
        finishTime: null,
        instanceId: null,
        processKey: null,
        employeId: null,
        uniqueCode: null,
        deptId: null,
        name: null,
        phone: null,
        idcardNo: null,
        sex: null,
        birthDay: null,
        onlyChild: null,
        folk: null,
        politicalStatus: "0",
        nativePlace: null,
        firstEducation: null,
        firstEducationSchool: null,
        firstEducationProfession: null,
        topEducation: null,
        topEducationSchool: null,
        topEducationProfession: null,
        professionalTitle: null,
        postJob: null,
        postCode: null,
        postTitle: null,
        postLevel: null,
        postTime: null,
        workDate: null,
        hiredate: null,
        firedate: null,
        employeType: null,
        personnelDossier: null,
        personnelDossierLocation: null,
        status: "0",
        approveStatus: "0",
        approveType: null,
        approveContent: null,
        approveBy: null,
        approveTime: null,
        deleteStatus: "0",
        deleteTime: null,
        deleteBy: null,
        createBy: null,
        createDate: null,
        createTime: null,
        updateBy: null,
        updateDate: null,
        updateTime: null,
        delFlag: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加员工花名册审批业务";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getEmployee(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改员工花名册审批业务";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateEmployee(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addEmployee(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除员工花名册审批业务编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delEmployee(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有员工花名册审批业务数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportEmployee(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
    }
  }
};
</script>
