addclock.html 12.5 KB
<include file="public@header"/>
</head>
<body>

<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('index')}">打卡列表</a></li>
        <li class="active">
            <a href="{:url('add')}">打卡添加</a>
        </li>
    </ul>
    <form action="{:url('addPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
        <div class="row">
            <div class="col-md-9">
                <table class="table table-bordered">
                    <tr>
                        <th width="100">名称(限20字)<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control" type="text" name="activity_name" required
                                   id="title" value="{$data.activity_name}" placeholder="请输入活动名称"/>
                            <input type="hidden" name="activity_id" value="{$data.activity_id}">
                            <input type="hidden" name="user_id" value="{$data.user_id}">
                            <input type="hidden" name="activity_name" value="{$data.activity_name}">
                        </td>
                    </tr>
                    <tr>
                        <th width="100">名称(限20字)<span class="form-required">*</span></th>
                        <td>
                            <input required class="form-control" type="text" name="activity_name"
                                   id="title" value="{$data.activity_name}" placeholder="请输入活动名称"/>
                        </td>
                    </tr>
                    <tr>
                        <th width="100">活动日期<span class="form-required">*</span></th>
                        <td>
                            <input required class="form-control js-date" type="text" name="date"
                                   type="time"  id="title" value="{:date('Y-m-d',$data.start_time)}" placeholder="请输入"/>
                        </td>
                    </tr>
                    <tr>
                        <th width="100">地址名称<span class="form-required">*</span></th>
                        <td>
                            <input required class="form-control" type="text" name="address"
                                   type="time"  id="address_name" value="" placeholder="请输入"/>
                        </td>
                    </tr>
                    <tr>
                        <th width="100">经度<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control" type="text" name="long"
                                   type="text"  id="lng" value="{$data.long|default=''}" placeholder="请输入"/>
                            <text id="selectBtn">点击地图选择坐标</text>
                        </td>
                    </tr>
                    <tr>
                        <th width="100">纬度<span class="form-required">*</span></th>
                        <td>
                            <input required class="form-control" type="text" name="lat"
                                   type="text"  id="lat" value="{$data.lat|default=''}" placeholder="请输入"/>
                        </td>
                    </tr>
                    <tr>
                        <th width="100">开始打卡时间<span class="form-required">*</span></th>
                        <td>
                            <input  class="form-control" type="time" name="start_clock_time"
                                   type="time"  id="title" value="" placeholder="请输入"/>
                        </td>
                    </tr>

                    <tr>
                        <th width="100">结束打卡时间<span class="form-required">*</span></th>
                        <td>
                            <input  class="form-control date-time" type="time" name="end_clock_time"
                                   type="time"  value="" placeholder="请输入"/>
                        </td>
                    </tr>

                    <tr>
                        <th width="100">工作时长<span class="form-required">*</span></th>
                        <td>
                            <input required class="form-control date-time" type="number" name="work_time"
                                   type="time"  value="" placeholder="请输入"/>
                        </td>
                    </tr>

                </table>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
                        <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;



    var SelectLocation = {

        init:function(config){
            var eleId = config.id;
            var mapUrl = config.url;
            var winHeight = config.height || 800;
            var winWidth = config.width || 1024;
            var winTop = config.top || 50;
            var winLeft = config.left || 100;
            this.callbackFun = config.callback;

            if(!eleId){
                alert('元素id不能为空');
                return;
            }

            if(!mapUrl){
                alert('地图url不能为空');
                return;
            }

            var ele = document.getElementById(eleId);
            ele.addEventListener('click',function(){
                window.open(mapUrl,'selectLocation','fullscreen=0,directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,' +
                    'height='+winHeight+',width='+winWidth+',top='+winTop+',left='+winLeft+'');
            });
        },

        callbackFun:null,

        selectCallback:function(selectedLocation){
            console.log('12121212');
            if(this.callbackFun){
                this.callbackFun(selectedLocation);
            }
        }
    }
</script>
<script src="__TMPL__/public/assets/js/selectLocation.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(function () {
        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

        $('.btn-cancel-thumbnail1').click(function () {
            $('#thumbnail-preview1').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail1').val('');
        });

    });
</script>


<script type="text/javascript">

    $('.btn-cancel-thumbnail').click(function () {
        $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
        $('#thumbnail').val('');
    });
    $('.btn-cancel-thumbnail2').click(function () {
        $('#thumbnail2-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
        $('#thumbnail2').val('');
    });
    $('.btn-cancel-thumbnail3').click(function () {
        $('#thumbnail3-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
        $('#thumbnail3').val('');
    });

    // 百度地图API功能
    var center = new BMap.Point({$data.long|default='116.404'}, {$data.lat|default='39.915'});

    var map = new BMap.Map("allmap");
    map.centerAndZoom(new BMap.Point(116.404, 39.915), 8);
    map.enableScrollWheelZoom();    //启用滚轮放大缩小,默认禁用
    map.enableContinuousZoom();

    var map_ac = new BMap.Autocomplete(    //建立一个自动完成的对象
        {
            "input": "aaa",
            "location": map
        });

    var marker = new BMap.Marker(center);  // 创建标注
    map.addOverlay(marker);              // 将标注添加到地图中
    marker.enableDragging();    //可拖拽
    //marker.setAnimation(BMAP_ANIMATION_BOUNCE);

    map_ac.addEventListener("onconfirm", function (e) {    //鼠标点击下拉列表后的事件
        var _value = e.item.value;

        function myFun() {
            var pp = local.getResults().getPoi(0).point;    //获取第一个智能搜索的结果
            map.centerAndZoom(pp, 8);
            marker.setPosition(pp);
            mgetLocation(pp);
        }

        myValue   = _value.province + _value.city + _value.district + _value.street + _value.business;
        var local = new BMap.LocalSearch(map, { //智能搜索
            onSearchComplete: myFun
        });
        local.search(myValue);
    });


    var opts       = {
        width: 200,     // 信息窗口宽度
        height: 30,     // 信息窗口高度
        title: "", // 信息窗口标题
        enableMessage: false,//设置允许信息窗发送短息

    }
    var infoWindow = new BMap.InfoWindow("拖动我设置你的位置", opts);  // 创建信息窗口对象
    marker.openInfoWindow(infoWindow);

    var gc = new BMap.Geocoder();

    function msetpoint(e) {
        document.getElementById("lng_input").value = e.point.lng;
        document.getElementById("lat_input").value = e.point.lat;
        marker.setPosition(new BMap.Point(e.point.lng, e.point.lat));
        mgetLocation(e.point);
    }

    function mgetLocation(point) {
        gc.getLocation(point, function (rs) {
            console.log(rs);
            var addComp = rs.addressComponents;
            marker.openInfoWindow(new BMap.InfoWindow(rs.address, opts));
            document.getElementById("address_input").value  = rs.address;
            document.getElementById("city_input").value     = addComp.city;
            document.getElementById("province_input").value = addComp.province;
            document.getElementById("district_input").value = addComp.district;
            document.getElementById("lng_input").value = rs.point.lng;
            document.getElementById("lat_input").value = rs.point.lat;
            //alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
        });
    }
    marker.addEventListener("dragend", msetpoint)

    map.addEventListener("click", msetpoint);


    function tilesloaded() {
        map.setCenter(center);   //设置地图中心点。center除了可以为坐标点以外,还支持城市名
        mgetLocation(center);
        // map.setZoom(8);  //将视图切换到指定的缩放等级,中心点坐标不变
        map.removeEventListener("tilesloaded", tilesloaded);
    }
    map.addEventListener("tilesloaded", tilesloaded);


    function confirm() {
        var data      = {};
        data.lng      = document.getElementById("lng_input").value;
        data.lat      = document.getElementById("lat_input").value;
        data.address  = document.getElementById("address_input").value;
        data.city     = document.getElementById("city_input").value;
        data.province = document.getElementById("province_input").value;
        data.district = document.getElementById("district_input").value;
        return data;
    }

</script>

<script type="text/javascript">
    SelectLocation.init({
        id:'selectBtn',     //打开地图窗口按钮的ID
        url:'/txmap.html',   //地图页面的地址
//        width:'1024',        //打开地图窗口的宽度,可不传
//        height:'800',        //打开地图窗口的高度,可不传
//        top:'50',            //打开地图窗口距显示器顶部的距离,可不传
//        left:'100',          //打开地图窗口显示器左边的距离,可不传
        callback:function(selectedLocation){
            var lat = document.getElementById('lat');
            var lng = document.getElementById('lng');
            var address_name = document.getElementById('address_name');
            console.log(selectedLocation);
            var gps=selectedLocation.latlng;
            if (gps==''){
                return false;
            }
            console.log(gps)
            lat.value =gps.lat;
            lng.value =gps.lng;
            address_name.value=selectedLocation.poiaddress+selectedLocation.poiname
        }
    });
</script>
</body>
</html>