在若依框架中,以下是这些代码的作用及它们在程序运行中的关联方式:
1. `domain.java`:通常用于定义实体类,它描述了与数据库表对应的对象结构,包含属性和对应的访问方法。作用是封装数据,为数据的操作提供基础。
2. `mapper.java`:定义了与数据库操作相关的接口方法,如查询、插入、更新、删除等。是数据访问层的接口定义。
3. `service.java`:定义业务逻辑的接口,规定了系统提供的服务方法,描述了系统应具备的业务功能。
4. `serviceImpl.java`:实现了 `service.java` 中定义的接口方法,处理具体的业务逻辑,是服务层的具体实现。
5. `controller.java`:接收前端的请求,调用 `service` 层的方法进行处理,并将结果返回给前端。它是前后端交互的桥梁。
6. `mapper.xml`:编写具体的 SQL 语句,实现 `mapper.java` 中定义的方法,用于数据库的实际操作。
7. `api.js`:如果是前端的 API 请求文件,用于向前端发送请求和处理响应,实现与后端的数据交互。
8. `index.vue`:前端页面的 Vue 组件,负责页面的展示和与后端的交互,是用户直接操作和查看的界面。
在程序运行过程中的关联方式如下:
当用户在 `index.vue` 页面进行操作,触发相关事件时,通过 `api.js` 向后端发送请求。请求到达后端的 `controller.java` ,`controller` 接收到请求后,调用 `service.java` 中定义的业务方法,而具体的业务逻辑实现则在 `serviceImpl.java` 中。`serviceImpl` 可能会调用 `mapper.java` 中的方法,通过 `mapper.xml` 中编写的 SQL 语句对数据库进行操作,获取或更新数据。最后,`controller` 将处理结果返回给前端,前端的 `index.vue` 根据返回的数据进行页面的更新和展示。
例如,用户在 `index.vue` 页面点击查询按钮,通过 `api.js` 发送查询请求到 `controller.java` ,`controller` 调用 `service` 的查询方法,`serviceImpl` 执行具体逻辑并通过 `mapper` 从数据库获取数据,`controller` 将数据返回给前端,`index.vue` 展示查询结果。
domain.java
package com.ruoyi.hrm.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 面试情况对象 hrm_interview
*
* @author wxq
* @date 2024-07-03
*/
public class HrmInterview extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 应聘人 */
@Excel(name = "应聘人")
private String name;
/** 性别 */
@Excel(name = "性别")
private Long gender;
/** 最高学历 */
@Excel(name = "最高学历")
private String highestEdu;
/** 毕业院校 */
@Excel(name = "毕业院校")
private String college;
/** 面试分值 */
@Excel(name = "面试分值")
private String score;
/** 面试情况 */
@Excel(name = "面试情况")
private String condition;
/** 面试是否通过 */
@Excel(name = "面试是否通过")
private Long pass;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setGender(Long gender)
{
this.gender = gender;
}
public Long getGender()
{
return gender;
}
public void setHighestEdu(String highestEdu)
{
this.highestEdu = highestEdu;
}
public String getHighestEdu()
{
return highestEdu;
}
public void setCollege(String college)
{
this.college = college;
}
public String getCollege()
{
return college;
}
public void setScore(String score)
{
this.score = score;
}
public String getScore()
{
return score;
}
public void setCondition(String condition)
{
this.condition = condition;
}
public String getCondition()
{
return condition;
}
public void setPass(Long pass)
{
this.pass = pass;
}
public Long getPass()
{
return pass;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("gender", getGender())
.append("highestEdu", getHighestEdu())
.append("college", getCollege())
.append("score", getScore())
.append("condition", getCondition())
.append("pass", getPass())
.append("remark", getRemark())
.toString();
}
}
mapper.java
package com.ruoyi.hrm.mapper;
import java.util.List;
import com.ruoyi.hrm.domain.HrmInterview;
/**
* 面试情况Mapper接口
*
* @author wxq
* @date 2024-07-03
*/
public interface HrmInterviewMapper
{
/**
* 查询面试情况
*
* @param id 面试情况主键
* @return 面试情况
*/
public HrmInterview selectHrmInterviewById(Long id);
/**
* 查询面试情况列表
*
* @param hrmInterview 面试情况
* @return 面试情况集合
*/
public List<HrmInterview> selectHrmInterviewList(HrmInterview hrmInterview);
/**
* 新增面试情况
*
* @param hrmInterview 面试情况
* @return 结果
*/
public int insertHrmInterview(HrmInterview hrmInterview);
/**
* 修改面试情况
*
* @param hrmInterview 面试情况
* @return 结果
*/
public int updateHrmInterview(HrmInterview hrmInterview);
/**
* 删除面试情况
*
* @param id 面试情况主键
* @return 结果
*/
public int deleteHrmInterviewById(Long id);
/**
* 批量删除面试情况
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteHrmInterviewByIds(Long[] ids);
}
service.java
package com.ruoyi.hrm.service;
import java.util.List;
import com.ruoyi.hrm.domain.HrmInterview;
/**
* 面试情况Service接口
*
* @author wxq
* @date 2024-07-03
*/
public interface IHrmInterviewService
{
/**
* 查询面试情况
*
* @param id 面试情况主键
* @return 面试情况
*/
public HrmInterview selectHrmInterviewById(Long id);
/**
* 查询面试情况列表
*
* @param hrmInterview 面试情况
* @return 面试情况集合
*/
public List<HrmInterview> selectHrmInterviewList(HrmInterview hrmInterview);
/**
* 新增面试情况
*
* @param hrmInterview 面试情况
* @return 结果
*/
public int insertHrmInterview(HrmInterview hrmInterview);
/**
* 修改面试情况
*
* @param hrmInterview 面试情况
* @return 结果
*/
public int updateHrmInterview(HrmInterview hrmInterview);
/**
* 批量删除面试情况
*
* @param ids 需要删除的面试情况主键集合
* @return 结果
*/
public int deleteHrmInterviewByIds(Long[] ids);
/**
* 删除面试情况信息
*
* @param id 面试情况主键
* @return 结果
*/
public int deleteHrmInterviewById(Long id);
}
serviceImpl.java
package com.ruoyi.hrm.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.hrm.mapper.HrmInterviewMapper;
import com.ruoyi.hrm.domain.HrmInterview;
import com.ruoyi.hrm.service.IHrmInterviewService;
/**
* 面试情况Service业务层处理
*
* @author wxq
* @date 2024-07-03
*/
@Service
public class HrmInterviewServiceImpl implements IHrmInterviewService
{
@Autowired
private HrmInterviewMapper hrmInterviewMapper;
/**
* 查询面试情况
*
* @param id 面试情况主键
* @return 面试情况
*/
@Override
public HrmInterview selectHrmInterviewById(Long id)
{
return hrmInterviewMapper.selectHrmInterviewById(id);
}
/**
* 查询面试情况列表
*
* @param hrmInterview 面试情况
* @return 面试情况
*/
@Override
public List<HrmInterview> selectHrmInterviewList(HrmInterview hrmInterview)
{
return hrmInterviewMapper.selectHrmInterviewList(hrmInterview);
}
/**
* 新增面试情况
*
* @param hrmInterview 面试情况
* @return 结果
*/
@Override
public int insertHrmInterview(HrmInterview hrmInterview)
{
return hrmInterviewMapper.insertHrmInterview(hrmInterview);
}
/**
* 修改面试情况
*
* @param hrmInterview 面试情况
* @return 结果
*/
@Override
public int updateHrmInterview(HrmInterview hrmInterview)
{
return hrmInterviewMapper.updateHrmInterview(hrmInterview);
}
/**
* 批量删除面试情况
*
* @param ids 需要删除的面试情况主键
* @return 结果
*/
@Override
public int deleteHrmInterviewByIds(Long[] ids)
{
return hrmInterviewMapper.deleteHrmInterviewByIds(ids);
}
/**
* 删除面试情况信息
*
* @param id 面试情况主键
* @return 结果
*/
@Override
public int deleteHrmInterviewById(Long id)
{
return hrmInterviewMapper.deleteHrmInterviewById(id);
}
}
controller.java
package com.ruoyi.hrm.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hrm.domain.HrmInterview;
import com.ruoyi.hrm.service.IHrmInterviewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 面试情况Controller
*
* @author wxq
* @date 2024-07-03
*/
@RestController
@RequestMapping("/hrm/interview")
public class HrmInterviewController extends BaseController
{
@Autowired
private IHrmInterviewService hrmInterviewService;
/**
* 查询面试情况列表
*/
@PreAuthorize("@ss.hasPermi('hrm:interview:list')")
@GetMapping("/list")
public TableDataInfo list(HrmInterview hrmInterview)
{
startPage();
List<HrmInterview> list = hrmInterviewService.selectHrmInterviewList(hrmInterview);
return getDataTable(list);
}
/**
* 导出面试情况列表
*/
@PreAuthorize("@ss.hasPermi('hrm:interview:export')")
@Log(title = "面试情况", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, HrmInterview hrmInterview)
{
List<HrmInterview> list = hrmInterviewService.selectHrmInterviewList(hrmInterview);
ExcelUtil<HrmInterview> util = new ExcelUtil<HrmInterview>(HrmInterview.class);
util.exportExcel(response, list, "面试情况数据");
}
/**
* 获取面试情况详细信息
*/
@PreAuthorize("@ss.hasPermi('hrm:interview:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(hrmInterviewService.selectHrmInterviewById(id));
}
/**
* 新增面试情况
*/
@PreAuthorize("@ss.hasPermi('hrm:interview:add')")
@Log(title = "面试情况", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody HrmInterview hrmInterview)
{
return toAjax(hrmInterviewService.insertHrmInterview(hrmInterview));
}
/**
* 修改面试情况
*/
@PreAuthorize("@ss.hasPermi('hrm:interview:edit')")
@Log(title = "面试情况", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody HrmInterview hrmInterview)
{
return toAjax(hrmInterviewService.updateHrmInterview(hrmInterview));
}
/**
* 删除面试情况
*/
@PreAuthorize("@ss.hasPermi('hrm:interview:remove')")
@Log(title = "面试情况", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(hrmInterviewService.deleteHrmInterviewByIds(ids));
}
}
-
@RestController
:这是一个组合注解,表明这个类是一个处理 RESTful 请求的控制器,并且返回的数据会直接以 JSON 或其他适合的格式响应给客户端,而不是跳转页面。 -
@RequestMapping("/hrm/interview")
:用于定义控制器类的基本请求路径,即所有该控制器处理的请求 URL 都以/hrm/interview
开头。 -
@PreAuthorize("@ss.hasPermi('hrm:interview:list')")
:这是一个基于 Spring Security 的权限控制注解。表示在执行被注解的方法(如list
方法)之前,会检查当前用户是否具有'hrm:interview:list'
权限,如果没有则拒绝访问。 -
@PathVariable
:用于获取请求路径中的参数值。例如在getInfo
方法中,通过@PathVariable("id") Long id
获取路径中{id}
的值,并绑定到id
参数上。
mapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.hrm.mapper.HrmInterviewMapper">
<resultMap type="HrmInterview" id="HrmInterviewResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="gender" column="gender" />
<result property="highestEdu" column="highestEdu" />
<result property="college" column="college" />
<result property="score" column="score" />
<result property="condition" column="condition" />
<result property="pass" column="pass" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectHrmInterviewVo">
select id, name, gender, highestEdu, college, score, condition, pass, remark from hrm_interview
</sql>
<select id="selectHrmInterviewList" parameterType="HrmInterview" resultMap="HrmInterviewResult">
<include refid="selectHrmInterviewVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="gender != null "> and gender = #{gender}</if>
<if test="highestEdu != null and highestEdu != ''"> and highestEdu = #{highestEdu}</if>
<if test="college != null and college != ''"> and college like concat('%', #{college}, '%')</if>
<if test="score != null and score != ''"> and score = #{score}</if>
<if test="condition != null and condition != ''"> and condition = #{condition}</if>
<if test="pass != null "> and pass = #{pass}</if>
</where>
</select>
<select id="selectHrmInterviewById" parameterType="Long" resultMap="HrmInterviewResult">
<include refid="selectHrmInterviewVo"/>
where id = #{id}
</select>
<insert id="insertHrmInterview" parameterType="HrmInterview" useGeneratedKeys="true" keyProperty="id">
insert into hrm_interview
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="gender != null">gender,</if>
<if test="highestEdu != null">highestEdu,</if>
<if test="college != null">college,</if>
<if test="score != null">score,</if>
<if test="condition != null">condition,</if>
<if test="pass != null">pass,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="gender != null">#{gender},</if>
<if test="highestEdu != null">#{highestEdu},</if>
<if test="college != null">#{college},</if>
<if test="score != null">#{score},</if>
<if test="condition != null">#{condition},</if>
<if test="pass != null">#{pass},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateHrmInterview" parameterType="HrmInterview">
update hrm_interview
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="gender != null">gender = #{gender},</if>
<if test="highestEdu != null">highestEdu = #{highestEdu},</if>
<if test="college != null">college = #{college},</if>
<if test="score != null">score = #{score},</if>
<if test="condition != null">condition = #{condition},</if>
<if test="pass != null">pass = #{pass},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteHrmInterviewById" parameterType="Long">
delete from hrm_interview where id = #{id}
</delete>
<delete id="deleteHrmInterviewByIds" parameterType="String">
delete from hrm_interview where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
sql
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('面试情况', '2055', '1', 'interview', 'hrm/interview/index', 1, 0, 'C', '0', '0', 'hrm:interview:list', '#', 'admin', sysdate(), '', null, '面试情况菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('面试情况查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', 'hrm:interview:query', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('面试情况新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', 'hrm:interview:add', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('面试情况修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', 'hrm:interview:edit', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('面试情况删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', 'hrm:interview:remove', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('面试情况导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', 'hrm:interview:export', '#', 'admin', sysdate(), '', null, '');
api.js
import request from '@/utils/request'
// 查询面试情况列表
export function listInterview(query) {
return request({
url: '/hrm/interview/list',
method: 'get',
params: query
})
}
// 查询面试情况详细
export function getInterview(id) {
return request({
url: '/hrm/interview/' + id,
method: 'get'
})
}
// 新增面试情况
export function addInterview(data) {
return request({
url: '/hrm/interview',
method: 'post',
data: data
})
}
// 修改面试情况
export function updateInterview(data) {
return request({
url: '/hrm/interview',
method: 'put',
data: data
})
}
// 删除面试情况
export function delInterview(id) {
return request({
url: '/hrm/interview/' + id,
method: 'delete'
})
}
index.vue
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="应聘人" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入应聘人"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="性别" prop="gender">
<el-select v-model="queryParams.gender" placeholder="请选择性别" clearable>
<el-option
v-for="dict in dict.type.sys_user_sex"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="最高学历" prop="highestEdu">
<el-select v-model="queryParams.highestEdu" placeholder="请选择最高学历" clearable>
<el-option
v-for="dict in dict.type.tiptop_degree"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="毕业院校" prop="college">
<el-input
v-model="queryParams.college"
placeholder="请输入毕业院校"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="面试分值" prop="score">
<el-input
v-model="queryParams.score"
placeholder="请输入面试分值"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="面试情况" prop="condition">
<el-input
v-model="queryParams.condition"
placeholder="请输入面试情况"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="面试是否通过" prop="pass">
<el-select v-model="queryParams.pass" placeholder="请选择面试是否通过" clearable>
<el-option
v-for="dict in dict.type.interview_state"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</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="['hrm:interview: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="['hrm:interview: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="['hrm:interview: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="['hrm:interview:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="interviewList" @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="应聘人" align="center" prop="name" />
<el-table-column label="性别" align="center" prop="gender">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_user_sex" :value="scope.row.gender"/>
</template>
</el-table-column>
<el-table-column label="最高学历" align="center" prop="highestEdu">
<template slot-scope="scope">
<dict-tag :options="dict.type.tiptop_degree" :value="scope.row.highestEdu"/>
</template>
</el-table-column>
<el-table-column label="毕业院校" align="center" prop="college" />
<el-table-column label="面试分值" align="center" prop="score" />
<el-table-column label="面试情况" align="center" prop="condition" />
<el-table-column label="面试是否通过" align="center" prop="pass">
<template slot-scope="scope">
<dict-tag :options="dict.type.interview_state" :value="scope.row.pass"/>
</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="['hrm:interview:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['hrm:interview: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="应聘人" prop="name">
<el-input v-model="form.name" placeholder="请输入应聘人" />
</el-form-item>
<el-form-item label="性别" prop="gender">
<el-select v-model="form.gender" placeholder="请选择性别">
<el-option
v-for="dict in dict.type.sys_user_sex"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="最高学历" prop="highestEdu">
<el-select v-model="form.highestEdu" placeholder="请选择最高学历">
<el-option
v-for="dict in dict.type.tiptop_degree"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="毕业院校" prop="college">
<el-input v-model="form.college" placeholder="请输入毕业院校" />
</el-form-item>
<el-form-item label="面试分值" prop="score">
<el-input v-model="form.score" placeholder="请输入面试分值" />
</el-form-item>
<el-form-item label="面试情况" prop="condition">
<el-input v-model="form.condition" placeholder="请输入面试情况" />
</el-form-item>
<el-form-item label="面试是否通过" prop="pass">
<el-select v-model="form.pass" placeholder="请选择面试是否通过">
<el-option
v-for="dict in dict.type.interview_state"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</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 { listInterview, getInterview, delInterview, addInterview, updateInterview } from "@/api/hrm/interview";
export default {
name: "Interview",
dicts: ['interview_state', 'tiptop_degree', 'sys_user_sex'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 面试情况表格数据
interviewList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
gender: null,
highestEdu: null,
college: null,
score: null,
condition: null,
pass: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询面试情况列表 */
getList() {
this.loading = true;
listInterview(this.queryParams).then(response => {
this.interviewList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
name: null,
gender: null,
highestEdu: null,
college: null,
score: null,
condition: null,
pass: 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
getInterview(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) {
updateInterview(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addInterview(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除面试情况编号为"' + ids + '"的数据项?').then(function() {
return delInterview(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('hrm/interview/export', {
...this.queryParams
}, `interview_${new Date().getTime()}.xlsx`)
}
}
};
</script>
<!-- el-form-item 组件,用于展示需求部门的输入框和标签 -->
<el-form-item label="需求部门" prop="dept">
<!-- el-select 组件,用于选择部门,v-model 绑定了 form 对象中的 dept 属性 -->
<el-select v-model="form.dept" placeholder="请选择部门">
<!-- 使用 v-for 指令遍历 options 数组来生成选项 -->
<el-option
v-for="item in options"
:key="item.value" <!-- 为每个选项提供唯一的 key 值,这里使用 item.value -->
:label="item.label" <!-- 选项显示的文本内容,来自 item.label -->
:value="item.value"> <!-- 选项的值,来自 item.value -->
</el-option>
</el-select>
</el-form-item>