老k游戏大厅官 当前位置:首页>老k游戏大厅官>正文

老k游戏大厅官

发布时间:2019-01-21

原标题:MUI开发记录——我的考勤

MUI开发记录——我的考勤


已经好久没有更新技术博客了,因为最近一直在做跨平台web app应用的开发,由于是刚做这个,也没太多经验同大家分享,可我是一个闲不住的人,我还是决定于百忙之中抽空整理一篇,记录下开发历程......——前言

需求描述

可以选择日期,按月份分别查看应出勤数、已出勤数、迟到数、早退数,用特殊标记标出某天是迟到还是早退等等,选中某天,直接加载该天的所有考勤记录,看上去挺简单的功能,要我写js估计可以写到吐血,还好懂得拿来主义,网上找个开源的日历组件,然后进行改造。日历组件源码地址Calendar.js由于公司没有平面和美工,也没有前端,所以这些活我就兼做了,所以大家不要对界面吐槽,我已经尽力了,555~,下面的界面截图我都是用的谷歌浏览器,模拟iphone6的效果,同真机上比自然会有一定的出入,通常来说真机上面要比模拟器上面更漂亮和清晰,界面效果如下:

注:橙色表示当前日期,浅蓝色表示选中日期,默认情况下显示当前日期,并加载当天的考勤记录。

功能实现

之前本来打算使用区域滚动的,后面看见原型界面是整个页面滚动,所以我就暂时注释了这块。

日历支持左右滑动进行翻页(按月进行翻),顶部按钮也支持翻页。

技术选型:mui、h5、h5+、vue.js

html代码如下:

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>我的考勤</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../../css/mui.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="../../css/base.css" />
    <link rel="stylesheet" href="../../css/app/home/timeline.css" />
    <link rel="stylesheet" href="../../css/app/my/punch-card.css" />
    <link rel="stylesheet" href="../../css/calendar.css" />
</head>
<body>
    <header class="mui-bar mui-bar-nav">
        <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
        <h1 class="mui-title">我的考勤</h1><span id="bigTime" class="bigTime" style="visibility:hidden;"></span>
    </header>
    <div id="app" class="mui-content">
        <div class="div-yearmonth">
            <i id="prePage" class="mui-icon iconfont icon-shangyiye"></i>
            <span class="spn-today"><i class="mui-icon iconfont icon-rili"></i><span id="timeNow"></span></span>
            <i id="nextPage" class="mui-icon iconfont icon-xiayiye"></i>
        </div>
        <div class="div-operate">
            <div class="mui-segmented-control ul-operate">
                <a class="mui-control-item mui-active" v-on:tap="getDataByType(1)">
                    <p><span v-text="obj.attendance"></span></p>
                    <p>应出勤</p>
                </a>
                <a class="mui-control-item" v-on:tap="getDataByType(2)">
                    <p><span v-text="obj.actualAttendance"></span></p>
                    <p>实际出勤</p>
                </a>
                <a class="mui-control-item" v-on:tap="getDataByType(3)">
                    <p><span v-text="obj.beLate"></span></p>
                    <p>迟到</p>
                </a>
                <a class="mui-control-item" v-on:tap="getDataByType(4)">
                    <p><span v-text="obj.leaveEarly"></span></p>
                    <p>早退</p>
                </a>
            </div>
        </div>
        <div id="container"></div>
        <div class="div-list">
            <div class="line"></div>
            <div class="date"><span class="spn-date"><i v-text="monthDay" class="monthDay"></i><i v-text="week">星期一</i></span></div>
            <!--<div id="mui-scroll-wrapper" class="mui-scroll-wrapper timeline">
                <div class="mui-scroll">-->
                    <!--这里放置真实显示的DOM内容-->
                    <section v-if="list.length>0" id="cd-timeline" class="cd-container">
                        <div v-for="(item,index) in list" class="cd-timeline-block">
                            <div class="cd-timeline-img cd-picture" v-bind:class="{first:!index}"><span class="worktag">早班上班</span></div>
                            <div class="cd-timeline-content">
                                <div class="timeline-head">
                                    <span class="fl" v-text="item.name"></span>
                                    <span class="fl">打卡时间</span><span class="fl" v-text="item.time"></span>
                                    <span v-if="item.errorType!=""" class="mui-badge fl" v-bind:class="g.getTimeCardTypeBcByVal(item.errorType)" v-text="g.getTimeCardTypeByVal(item.errorType)"></span>
                                </div>
                                <div class="div-address"><i class="mui-icon mui-icon-location"></i><span v-text="item.address"></span></div>
                            </div>
                        </div>
                    </section>
                    <div v-else>
                        <div class="emptyinfo">
                            <span class="mui-icon mui-icon-location"></span>
                            <p>您今天未打卡哦~</p>
                        </div>
                    </div>
                <!--</div>
            </div>-->
        </div>
    </div>
    <script src="../../js/mui.min.js"></script>
    <script type="text/javascript" src="../../js/libs/vue.min.js"></script>
    <script type="text/javascript" src="../../js/common/config.js"></script>
    <script type="text/javascript" src="../../js/common/global.js"></script>
    <script type="text/javascript" src="../../js/libs/calendar.js"></script>
    <script type="text/javascript">
        var canlendar = null;
        mui.init();
        mui.ready(function () {
            //g.initScroll({ h: "300px" });//区域滚动
        });
        var app = new Vue({
            el: "#app",
            data: {
                obj: {
                    attendance: "",
                    actualAttendance: "",
                    beLate: "",
                    leaveEarly: ""
                },
                appData: {
                    attendance: [],
                    actualAttendance: [],
                    beLate: [],
                    leaveEarly: []
                }, //不同考勤类型数据
                monthDay: g.getDatePart("month") + "/" + g.getDatePart("day"), //月/日
                week: g.getDatePart("week"), //星期几
                list: []
            },
            mounted: function () {
                var _self = this;
                eventListener();
                initHandleData(_self); //1
                canlendar = new Calendar({
                    parentNode: document.getElementById("container"),
                    appData: _self.appData,
                    sltDateFuc:_self.sltDateFuc
                }); //2注意顺序
                mui.plusReady(function () {
                    var wv = plus.webview.currentWebview();
                    _self.userName = wv.userName;
                    _self.roleName = wv.roleName;
                    _self.imgUrl = wv.imgUrl;
                })
            },
            methods: {
                //回调函数,根据日期获取考勤记录
                sltDateFuc: function (date) {
                    //test
                    console.log(date);
                    var sltDate = g.convertDateFromString(date);
                    this.monthDay = g.getDatePart("month", sltDate) + "/" + g.getDatePart("day", sltDate); //月/日
                    this.week = g.getDatePart("week", sltDate); //星期几
                    if (date == "2017-11-11") {
                        this.list = [{
                            name: "早班上班",
                            address: "广东省深圳市南山区学苑大道1001号南山智园C3栋5楼",
                            time: "08:20",
                            tag: 1,
                            errorType: "1"
                        },
                    {
                        name: "早班上班",
                        address: "广东省深圳市南山区学苑大道1001号南山智园C3栋5楼",
                        time: "09:20",
                        tag: 1,
                        errorType: "2"
                    },
                    {
                        name: "中班上班",
                        address: "广东省深圳市南山区学苑大道1001号南山智园C3栋5楼",
                        time: "12:20",
                        tag: 1,
                        errorType: ""
                    }
                        ];
                    } else if (date == "2017-11-10") {
                        this.list = [{
                            name: "晚班上班",
                            address: "广东省深圳市南山区学苑大道1001号南山智园C3栋5楼",
                            time: "21:20",
                            tag: 1,
                            errorType: "1"
                        },
                    {
                        name: "晚班上班",
                        address: "广东省深圳市南山区学苑大道1001号南山智园C3栋5楼",
                        time: "22:20",
                        tag: 1,
                        errorType: "2"
                    },
                    {
                        name: "晚班上班",
                        address: "广东省深圳市南山区学苑大道1001号南山智园C3栋5楼",
                        time: "23:20",
                        tag: 1,
                        errorType: ""
                    }
                        ];
                    } else {
                        this.list = [];
                    }
                },
                //切换考勤类型
                getDataByType: function (t) {
                    var result = [];
                    switch (t) {
                        case 1: //应出勤
                            app.appData.attendance = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27];
                            app.appData.beLate = [];
                            app.appData.leaveEarly = [];
                            app.appData.actualAttendance = [];
                            break;
                        case 2: //实际出勤
                            app.appData.actualAttendance = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27];
                            app.appData.attendance = [];
                            app.appData.leaveEarly = [];
                            app.appData.beLate = [];
                            break;
                        case 3: //迟到
                            app.appData.beLate = [3, 5];
                            app.appData.actualAttendance = [];
                            app.appData.attendance = [];
                            app.appData.leaveEarly = [];
                            break;
                        default: //早退
                            app.appData.leaveEarly = [11, 7, 21];
                            app.appData.attendance = [];
                            app.appData.actualAttendance = [];
                            app.appData.beLate = [];
                            break;
                    }
                    app.list = result;
                    canlendar = new Calendar({
                        parentNode: document.getElementById("container"),
                        appData: app.appData,
                        sltDateFuc: app.sltDateFuc
                    });
                }
            }
        });

        function eventListener() {
            //上月
            document.getElementById("prePage").addEventListener("tap", function () {
                console.log("prePage")
                canlendar.turnPre();
                var str = canlendar.getPreMonth(g.id("bigTime").innerHTML);
                updateMonth(str);
            })
            //下月
            document.getElementById("nextPage").addEventListener("tap明基投影仪售后电话 斗牛牛软件下载 上海大众官方网站 火拼双扣游戏下载 熊猫棋牌游戏下载 2019版本百赢棋牌2.6.3 qka棋牌比赛赢话费 俄罗斯方块下载经典版 单机棋牌手游排行榜 四平麻将梨树玩法

64096 40807 12072 98051 35596 2557965574 30029 15532

责任编辑:通帝成安