首页 > 其他分享 >021.开发请假申请View层(1)

021.开发请假申请View层(1)

时间:2022-12-18 22:56:34浏览次数:52  
标签:请假 oa 021 department import com public imooc View

1.leave_form.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>请假申请单</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" type="text/css" href="/assets/element-plus/index.css">
    <!-- 引入组件库 -->
    <script src="/assets/vue/vue.global.js"></script>
    <script src="/assets/element-plus/index.full.js"></script>
    <script src="/assets/element-plus/locale/zh-cn.js"></script>
    <script src="/assets/axios/axios.js"></script>

    <style>
        .el-form {
            border: 1px solid #DCDFE6;
            width: 600px;
            margin: 180px auto;
            padding: 35px 35px 15px 35px;
            border-radius: 5px;
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px;
            box-shadow: 0 0 25px #909399;
        }
    </style>

</head>
<body>
<div id="app">
    <el-form ref="leaveForm" :model="form" :rules="rules" label-width="80px">
        <el-descriptions title="请假申请单" :column="1" border>
            <el-descriptions-item label="部门">{{department.departmentName}}</el-descriptions-item>
            <el-descriptions-item label="申请人">{{employee.name}}[{{employee.title}}]
            </el-descriptions-item>
            <el-descriptions-item label="请假类型">

                <el-select v-model="form.formType" style="width: 100%">
                    <el-option label="事假" value="1"></el-option>
                    <el-option label="病假" value="2"></el-option>
                    <el-option label="工伤假" value="3"></el-option>
                    <el-option label="婚嫁" value="4"></el-option>
                    <el-option label="产假" value="5"></el-option>
                    <el-option label="丧假" value="6"></el-option>
                </el-select>

            </el-descriptions-item>
            <el-descriptions-item label="请假时间">
                <el-form-item prop="timeRange" label-width="0px">
                    <div class="block">
                        <el-date-picker
                                v-model="form.timeRange"
                                type="datetimerange"
                                range-separator="至"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期">
                        </el-date-picker>
                    </div>
                </el-form-item>
            </el-descriptions-item>
            <el-descriptions-item label="请假原因">
                <el-form-item prop="reason" label-width="0px">
                    <el-input type="text" placeholder="请输入请假原因" v-model="form.reason"/>
                </el-form-item>
            </el-descriptions-item>

        </el-descriptions>
        <div style="text-align: center;padding-top: 30px">
            <el-button type="primary" >立即申请</el-button>
        </div>
    </el-form>

</div>

<script>

    var Main = {
        data() {
            return {
                employee:{},
                department:{},
                form: {
                    formType: "1",
                    timeRange: "",
                    startTime: "",
                    endTime: "",
                    reason: "",
                    eid: "",
                },
                // 表单验证,需要在 el-form-item 元素中增加 prop 属性
                rules: {
                    timeRange: [
                        {required: true, message: '请选择请假时间', trigger: 'blur'}
                    ],
                    reason: [
                        {required: true, message: '请填写请假原因', trigger: 'blur'}
                    ]
                }
            }
        }
        ,mounted(){
            const objApp = this;
            axios.get("/api/user_info?uid=" + sessionStorage.uid + "&eid=" + sessionStorage.eid)
            .then(function(response){
                console.info(response);
                objApp.employee = response.data.data.employee;
                objApp.department = response.data.data.department;
            })
        }
    };
    ElementPlus.locale(ElementPlus.lang.zhCn);
    const app = Vue.createApp(Main);
    app.use(ElementPlus, ElementPlus.lang.zhCn);
    app.mount("#app");
</script>
</body>
</html>

2.部门表

2.1 实体类com.imooc.oa.entity

package com.imooc.oa.entity;

public class Department {
    private Long departmentId;
    private String departmentName;

    public Long getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(Long departmentId) {
        this.departmentId = departmentId;
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }
}

2.2 开发mapper(com.imooc.oa.mapper.DepartmentMapper)

package com.imooc.oa.mapper;

import com.imooc.oa.entity.Department;

public interface DepartmentMapper {
    public Department selectById(Long departmentId);
}

2.3  mappers/department.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">
<!--namespace与包名类名一致-->
<mapper namespace="com.imooc.oa.mapper.DepartmentMapper">
    <select id="selectById" parameterType="Long" resultType="com.imooc.oa.entity.Department">
        select * from adm_department where department_id = #{value}
    </select>
</mapper>

2.4 在mybatis-config.xml中注册

  <mapper resource="mappers/department.xml"/>

2.5 com.imooc.oa.service.DepartmentService

package com.imooc.oa.service;

import com.imooc.oa.entity.Department;
import com.imooc.oa.mapper.DepartmentMapper;
import com.imooc.oa.utils.MybatisUtils;

public class DepartmentService {
    public Department selectById(Long departmentId){
        return (Department)MybatisUtils.executeQuery(sqlSession -> sqlSession.getMapper(DepartmentMapper.class).selectById(departmentId));
    }
}

2.6 修改com.imooc.oa.controller.UserInfoServlet

package com.imooc.oa.controller;

import com.imooc.oa.entity.Department;
import com.imooc.oa.entity.Employee;
import com.imooc.oa.entity.Node;
import com.imooc.oa.service.DepartmentService;
import com.imooc.oa.service.EmployeeService;
import com.imooc.oa.service.RbacService;
import com.imooc.oa.utils.ResponseUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@WebServlet("/api/user_info")
public class UserInfoServlet extends HttpServlet {
    private RbacService rbacService = new RbacService();
    private EmployeeService employeeService = new EmployeeService();
    private DepartmentService departmentService = new DepartmentService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String uid = request.getParameter("uid");
        String eid = request.getParameter("eid");
        List<Node> nodes = rbacService.selectNodeByUserId(Long.parseLong(uid));
        List<Map> treeList = new ArrayList<>();
        Map module = null;
        for(Node node : nodes){
            if(node.getNodeType() == 1){
                module = new LinkedHashMap();
                module.put("node", node);
                module.put("children", new ArrayList());
                treeList.add(module);
            }else if(node.getNodeType() == 2){
                List children = (List)module.get("children");
                children.add(node);
            }
        }
        Employee employee = employeeService.selectById(Long.parseLong(eid));
        Department department = departmentService.selectById(employee.getDepartmentId());
        String json = new ResponseUtils()
                .put("nodeList", treeList).put("employee",employee).put("department",department).toJsonString();
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().println(json);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}

 

标签:请假,oa,021,department,import,com,public,imooc,View
From: https://www.cnblogs.com/LLL0617/p/16991132.html

相关文章

  • Modern C++ Overview (综览)
    PartI:Language(第一篇:语言)大局观——简直像个新语言给出一个完整实例,展示(几乎)所有新特性的样貌,让学员从真实代码中一次性窥得(几乎)全豹,得知即将面对的新知和挑战......
  • 100 Interview Questions for Software Developers-软件开发者面试百问
    ​​http://www.noop.nl/2009/01/100-interview-questions-for-software-developers.html​​​​​​Hiringsmartsoftwaredevelopersisnoteasy.Ifyou'renotcar......
  • 020.开发请假Controller层
    1.LeaveFormServlet.java(src\main\java\com\imooc\oa\controller)packagecom.imooc.oa.controller;importcom.imooc.oa.entity.LeaveForm;importcom.imooc.oa.servi......
  • 45册 + 325集 + 31套,Python学习资源【2021精华版本】
    给大家准备了如下资料黄同学经过千挑万选,为大家准备好的资源。45本Python电子书325集Python全栈视频【最新版】Python项目开发实战Python数据分析与机器学习实战【最新视频......
  • GuiLite 学习笔记(一) Mainloop与ViewTree
    以GuiLiteSamples中的HelloSlide为例,剖析一下GuiLite的设计思路和刷新机制;首先是main.cpp;可以分成3部分:1、根据fbmode拿到对应的phy_fb,后续的绘制都在这个fb上执行......
  • 上市公司数字化转型数据(1990-2021)
    上市公司数字化转型数据(1990-2021)上市公司数字化转型数据(1990-2021)上市公司数字化转型数据(1990-2021) 最新版数据已整理为Excel格式,数据的时间区间为1990-2021年,内含“......
  • 【报告分享】2020-2021视频号发展现状与趋势.pdf(附下载链接)
    本报告共53页,包含如下五大部分:1、2020年视频号发展总结;2、2020年视频号核心数据;3、视频号与抖音快手市场竞争格局;4、视频号商业化生态分析;5、2021年视频号发展趋势预测。本......
  • SAP ABAP CDS view Association 引入的缘由
    ABAPCDSview支持三种join方式:InnerJoinLeftOuterjoinRightouterjoin我们使用ABAPDevelopmentTool的CDSview向导创建一个CDSview:向导里包含的$......
  • 2021年蓝桥杯A组省赛-回路计数 【状压dp】
    题面分析单源最短Hamilton路径的状压dp模板题。\(dp[i][j]\)表示终点为\(j\),经过的点集状态为\(i\)的方案数。假设状态由\(k\)转移到\(j\)。当前计算\(dp[i][j]\),那么i......
  • wpf GridView去除右侧空白列
    页面<ListViewSizeChanged="ListView_SizeChanged"Loaded="ListView_Loaded"><ListView.View><GridView><GridViewColumnHeader="col1"Width=......