人事管理系统项目(三)

人事管理系统项目(三)

主页面点击添加员工、离职员工等按钮时也会弹出页面,下面来写这个页面样式:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="/font-awesome-4.7.0/css/font-awesome.css">

    <style>
        .empStatus {
            display: inline-block;
            width: 60px;
            height: 30px;
            border-radius: 2px;
            text-align: center;
            line-height: 30px;
            font-size: 14px;

        }
    </style>
</head>

<body>
    <div class="container-fluid">
        <div class="my-2">
            <button class="btn btn-primary" id="btnAddEmp">添加新员工</button>
            <button class="btn btn-danger" id="btnLeave">批量离职</button>
        </div>
        <div class="empInfo">
            <table id="empTable" class="text-center"></table>
        </div>


        <div id="win-add-emp" class="px-2 py-2" style="display: none">
            <form>
                <div class="form-group">
                    <label>员工姓名</label>
                    <input type="text" class="form-control" name="emp_name">
                </div>

                <div class="form-group">
                    <label>性别</label>
                    <div class="form-control border-0">
                        <div class="custom-control custom-radio custom-control-inline">
                            <input type="radio" id="male" name="emp_sex" class="custom-control-input" value="1">
                            <label class="custom-control-label" for="male"></label>
                        </div>
                        <div class="custom-control custom-radio custom-control-inline">
                            <input type="radio" name="emp_sex" id="female" class="custom-control-input" value="0">
                            <label class="custom-control-label" for="female"></label>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label>联系电话</label>
                    <input type="text" class="form-control" name="emp_phone">
                </div>

                <div class="form-group">
                    <label>出生日期</label>
                    <input type="date" class="form-control" name="emp_birthday">
                </div>

                <div class="form-group">
                    <label>入职时间</label>
                    <input type="date" class="form-control" name="emp_entry_date">
                </div>

                <div class="form-group custom-control-inline">
                    <div class="custom-control custom-control-inline">
                        <label style="width: 80px">部门</label>
                        <select class="custom-select mx-2" id="dept" name="dept">
                            <option value="">请选择部门</option>
                        </select>
                    </div>

                    <div class="custom-control custom-control-inline">
                        <label style="width: 80px">职位</label>
                        <select class="custom-select mx-2" id="post" name="post_id">
                            <option value="">请选择职位</option>
                        </select>
                    </div>
                </div>
                <div class="form-group text-center">
                    <button type="button" id="doAddEmp" class="btn btn-primary btn-lg btn-block">添加</button>
                </div>


            </form>
        </div>


        <!--添加离职员工开始-->
        <div id="win-add-leave" class="mx-3 mt-2" style="display: none">
            <h2 align="center">添加离职员工信息</h2>
            <form id="leaveForm">
                <div class="form-group">
                    <label>员工姓名:</label>
                    <span id="emp_name"></span>
                    <input type="hidden" name="emp_id" id="emp_id" />
                </div>
                <div class="form-group">
                    <label>离职原因</label>
                    <textarea class="form-control" name="leave_reasons" rows="3"></textarea>
                </div>

                <div class="form-group text-center">
                    <button type="button" id="doAddLeave" class="btn btn-primary btn-lg btn-block">提交</button>
                </div>
            </form>
        </div>


        <!--添加离职员工结束-->
        <input type="checkbox" disabled style="cursor: no-drop;" />

    </div>

    <script src="/js/jquery-3.4.1.min.js"></script>
    <script src="/js/popper.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/bootstrap-table.min.js"></script>
    <script src="/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="/layer-v3.1.1/layer/layer.js"></script>
    <script>
        let winLeaveIndex;//离职框
        $('#empTable').bootstrapTable({
            url: 'emp.do?operate=getEmpInfo',//返回JSON数组的服务器地址,JSON数组中的数据就是表格中显示的列数据
            theadClasses: 'thead-dark ',
            /**
             * columns中设置每列的数据
             *  列标题:title属性设置
             *  列数据绑定:field属性绑定列数据,field的值为json数组中对象的属性名
             */
            columns: [
                {
                    checkbox: true,
                },
                {
                    field: 'emp_id',
                    title: '编号'
                }, {
                    field: 'emp_name',
                    title: '姓名'
                }, {
                    field: 'emp_sex',
                    title: '性别',
                    //格式化列,参数为单元格的值
                    formatter: function (value) {
                        console.log(value);
                        return value == 0 ? "女" : "男";//return结果为界面显示的内容
                    }
                }, {
                    field: 'emp_phone',
                    title: '联系电话'
                }, {
                    field: 'emp_birthday',
                    title: '出生日期'
                }, {
                    field: 'emp_entry_time',
                    title: '入职时间'
                }, {
                    field: 'dept_name',
                    title: '部门'
                }, {
                    field: 'post_name',
                    title: '职位'
                }, {
                    field: 'emp_status',
                    title: '状态',
                    formatter: function (value) {
                        if (value == 0) {
                            return "<span class='btn-primary empStatus' >在职</span>"
                        } else {
                            return "<span class='btn-secondary empStatus'>离职</span>"
                        }
                    }
                }, {
                    title: '操作',
                    formatter: function (value, row, index, field) {
                        let link_status = "<a href='#' id='emp_status' class='btn btn-outline-danger'><i class='fa fa-times-circle'></i> 离职</a>";
                        if (row.emp_status == 1) {
                            link_status = "<a href='#' id='emp_status'   class='btn btn-outline-danger disabled' ><i class='fa fa-times-circle'></i> 离职</a>";
                        }
                        return [//设置界面实现的内容
                            "<a href='#' class='btn btn-outline-primary mx-2'><i class=\"fa fa-pencil\"></i> 编辑</a>",
                            link_status
                        ].join("")

                    }
                }],
            /******分页设置开始*********/
            //当开启分页后,bootstrap会自动向服务端传递分页参数
            pagination:true,//启用bootstraptable分页,设置为true在表格下方显示一个分页栏
            pageSize:5,//设置每页显示的记录数,默认值为10
            pageList:[5,8,10],//设置每页显示记录数的可选列表
            pageNumber:1,//设置初始化页码,默认值为1
            sidePagination:'server',//设置分页的方向(客户端分页,服务端分页),默认为客户端分页(client)
            //当值为limit时向服务端传递的分页参数的参数名为offset,limit这两个参数来表示要查询的页码和每页的记录数
            //但是我们更多的使用pageNumber和pageSize这两个参数名做为查询页码和查询记录数的名字,所以我们要把查询参数的类型
            //这是为不是limit的值(可以为任意值),只要不是limit那么参数名就为pageNumber和pageSize
            queryParamsType:'myParams',//查询参数类型的默认值为limit
            /******分页设置结束*********/
        });
    </script>
</body>

</html>

样式图片如下:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
到这里为止,前端页面就全部写完了,接下来就开始编写后端内容来把前端这些功能一一实现。

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值