<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="kaohedo.aspx.cs" Inherits="xxjxkhbase.app.kaohedo" %>

<html>
<head>
    <meta charset="utf-8">
    <title>考核评分——<%=xxsoft_check.check.getseting("systitle") %></title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="../weui/css/weui.css"/>
    <link rel="stylesheet" href="../weui/css/weuix.css"/>

    <script src="../weui/js/zepto.min.js"></script>
    <script src="../weui/js/zepto.weui.js"></script>

    <script src="../weui/js/php.js"></script>

</head>

<body ontouchstart>
    <div class="weui-header bg-blue"> 
  <div class="weui-header-left"> <a class="icon icon-109 f-white" href="javascript:history.go(-1);">返回</a>  </div>
   <h1 class="weui-header-title">考核评分</h1>
    <div class="weui-header-right"><a class="icon icon-112 f-white" href="exit.aspx"></a></div> 
    </div>
        <%
            string fanganid = Request.QueryString["fanganid"] != null ? Request.QueryString["fanganid"].ToString() : "0";
            string fangan = "";
            string fangshiid = Request.QueryString["fangshiid"] != null ? Request.QueryString["fangshiid"].ToString() : "0";
            string fangshi ="";
            string userid = Request.QueryString["userid"] != null ? Request.QueryString["userid"].ToString() : "0";
            string huizong=Request.QueryString["huizong"] != null ? Request.QueryString["huizong"].ToString() : "0";
            string kaoheren = xxsoft_user.userclass.getuserid();
            string pingfen ="2";
            int pinlu =2;
            int jichufen =0;
            int shunyan =0;
            string shijian = DateTime.Now.ToString("yyyy-MM-dd");
            string zongfen = jichufen.ToString();
            System.Data.DataTable tbf = SqlHelper.dataTable("select * from vkaoheshezhi where fanganid=" + fanganid + " and fangshiid="+fangshiid+"");
        if (tbf.Rows.Count > 0)
        {
            fangan = tbf.Rows[0]["title"].ToString();
            fangshi = tbf.Rows[0]["fangshi"].ToString();
            huizong = tbf.Rows[0]["huizong"].ToString();
            pingfen=tbf.Rows[0]["pingfen"].ToString();
            pinlu=Convert.ToInt32(tbf.Rows[0]["pinlu"]);
            jichufen=Convert.ToInt32(tbf.Rows[0]["jichufen"]);
            shunyan=Convert.ToInt32(tbf.Rows[0]["shunyan"]);
        }
            System.Data.DataTable tbz = SqlHelper.dataTable("select * from vchengji where userid="+userid+" and fanganid="+fanganid+" and fangshiid="+fanganid+" "+xxsoft_user.userclass.chksql(shijian,pinlu)+"");
            if (tbz.Rows.Count > 0)
            {
                zongfen = tbz.Rows[0]["chengji"].ToString();
            }
            string userxm = "";
            string bumen = "";
            string zhiwu = "";
            string ruzhidate = "";
            string sqlstr = "select * from vuserinfo where id=" + userid + "";
            System.Data.DataTable tbu = SqlHelper.dataTable(sqlstr);
            if (tbu.Rows.Count > 0)
            {
                userxm = tbu.Rows[0]["userxm"].ToString();
                bumen = tbu.Rows[0]["bumen"].ToString();
                zhiwu = tbu.Rows[0]["zhiwu"].ToString();
                ruzhidate = tbu.Rows[0]["ruzhidate"].ToString();
            }
        %>
<form name="form1" id="form1" class="layui-form">
    <div class="weui-cells__title"><%=fangan %></div>
     <input id="fanganid" name="fanganid" type="hidden" value="<%=fanganid %>"/>
                    <input id="fangshiid" name="fangshiid" type="hidden" value="<%=fangshiid %>"/>
                    <input id="kaoheren" name="kaoheren" type="hidden" value="<%=kaoheren %>"/>
                    <input id="userid" name="userid" type="hidden" value="<%=userid %>"/>
                    <input id="huizong" name="huizong" type="hidden" value="<%=huizong %>"/>
                    <input id="pinlu" name="pinlu" type="hidden" value="<%=pinlu %>"/>
                    <input id="pingfen" name="pingfen" type="hidden" value="<%=pingfen %>"/>
    <input id="jichufen" name="jichufen" type="hidden" value="<%=jichufen %>"/>
                   <input id="shunyan" name="shunyan" type="hidden" value="<%=shunyan%>"/>
    <div class="weui-cells weui-cells_form">
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
        <div class="weui-cell__bd"><%=userxm %>
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd">
            <label class="weui-label">部门</label>
        </div>
        <div class="weui-cell__bd"><%=bumen %>
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd">
            <label class="weui-label">职务</label>
        </div>
        <div class="weui-cell__bd"><%=zhiwu %>
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd">
            <label class="weui-label">评分时间</label>
        </div>
        <div class="weui-cell__bd">
            <input type="text" id="shijian" name="shijian" autocomplete="off" class="weui-input" value="<%=shijian %>">
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd">
            <label class="weui-label">总分</label>
        </div>
        <div class="weui-cell__bd">
            <input type="text" id="zongfen" name="zongfen"  readonly="readonly" class="weui-input" autocomplete="off"  value="<%=zongfen %>">
        </div>
    </div>
  </div>
    <%

        System.Data.DataTable tbx = SqlHelper.dataTable("select * from vfanganxize where fanganid="+fanganid+"");
        for (int i = 0; i < tbx.Rows.Count; i++)
        {
            string timuid =tbx.Rows[i]["timuid"].ToString();
            string fenzhi =tbx.Rows[i]["fenzhi"].ToString();
            string minfen = tbx.Rows[i]["minfen"].ToString();
            string maxfen = tbx.Rows[i]["maxfen"].ToString();
            string bujinfen = tbx.Rows[i]["bujinfen"].ToString();
            string xuanxiang = tbx.Rows[i]["xuanxiang"].ToString();
            string defen = xxsoft_user.userclass.getpingfen(fanganid, userid,kaoheren,timuid, shijian,pinlu).ToString();
            %>
        <div class="weui-panel weui-panel_access">
        <div class="weui-panel__hd"> <input  name="timuid" type="hidden" value="<%=timuid %>"/>
                    <h4 class="weui-media-box__title"><%=tbx.Rows[i]["bianhao"] %>、<%=tbx.Rows[i]["title"] %>【<%=tbx.Rows[i]["fenzhi"] %>】</h4></div>
        <div class="weui-panel__bd">
            <div class="weui-media-box weui-media-box_text">
                <p class="weui-media-box__desc"><%=tbx.Rows[i]["biaozhun"] %></p>
            </div>
            <div class="weui-media-box weui-media-box_text">
                <p class="weui-media-box__desc"> <%switch (pingfen)
                        { %>
                    <%case "0": %>
                    <input id="xzfen<%=timuid %>" name="xzfen<%=timuid %>" type="radio" value="<%=fenzhi %>" onclick="showzhi(this)" <%if (defen == fenzhi){ %>checked <%} %>/>是
                    <input id="xzfen<%=timuid %>" name="xzfen<%=timuid %>" type="radio" value="0" onclick="showzhi(this)" <%if (defen == fenzhi){ %>checked <%} %>/>否
                    <%break;%>
                    <%case "1": %>
                    <select name="xzfen<%=timuid %>" id="xzfen<%=timuid %>"  onchange="showzhi(this)"  class="weui-select">>
    <%if (Convert.ToDouble(maxfen) > Convert.ToDouble(minfen) && Convert.ToDouble(bujinfen) > 0)
    {
        for (double e = Convert.ToDouble(minfen); e <= Convert.ToDouble(maxfen); e += Convert.ToDouble(bujinfen))
        { %>
                        <option value="<%=e %>" <%if (defen == e.ToString()){ %>selected<%} %>><%=e %></option>
                        <% }
    }
    else
    { %>
            <option><%=fenzhi%></option>
                        <%} %>
                    </select>
                    <%break;%>
                    <%case "2": %>
                    <div class="weui-count">
                    <a class="weui-count__btn weui-count__decrease"></a>
                    <input name="xzfen<%=timuid %>" id="xzfen<%=timuid %>" type="text" value="<%=defen %>"  min="<%=minfen %>" max="<%=maxfen %>" class="weui-form-input" style="width:180" onblur="showzhi(this)" />
                    <a class="weui-count__btn weui-count__increase"></a>
                     </div>
                    <%break;%>
                    <%case "3": %>
                    <select name="xzfen<%=timuid %>" id="xzfen<%=timuid %>"  onchange="showzhi(this)" class="weui-select">
                    <% if (xuanxiang != "" && xuanxiang.IndexOf("|") > 0 && xuanxiang.IndexOf("/") > 0)
    {
        string[] xx = xuanxiang.Split('|');
        for (int g = 0; g <= xx.Length - 1; g++)
        { 
             string[] tempxx = xx[g].Split('/');
              %>
                    <option value="<%=tempxx[0] %>" <%if (defen == tempxx[0]){ %>selected <%} %>><%=tempxx[1] %></option>
                        <%  }
    }
    else
    { %>
               <option value="0">设置有误</option>    
                    <%} %>
                    <%break;%>
                    <%} %></p>
            </div>
        </div>
        <div class="weui-media-box">
            <input id="beizhu<%=timuid %>"  name="beizhu<%=timuid %>" class="weui-form-input" placeholder="评分说明">
        </div>
    </div>
    <%} %>
            <% if (SqlHelper.chkExist("select id from kaohejilu where fanganid=" + fanganid + " and fangshiid=" + fangshiid + " and userid=" + userid + " and kaoheren=" + kaoheren + " and zhuangtai=1 " + xxsoft_user.userclass.chksql(shijian, pinlu) + ""))
                {%>
            <div class="weui-flex">
                <div class="weui-flex__item"><a href="javascript:;" class="weui-btn weui-btn_primary  weui-btn_disabled ">保存评分</a></div>
                <div class="weui-flex__item"><a href="javascript:;" class="weui-btn bg-blue  weui-btn_disabled ">提交评分</a></div>
            </div>
                   <% }
               else
                   { %>
            <div class="weui-flex">
                <div class="weui-flex__item"><a href="javascript:;" class="weui-btn weui-btn_primary" id="baocun">保存评分</a></div>
                <div class="weui-flex__item"><a href="javascript:;" class="weui-btn bg-blue" id="tijiao">提交评分</a></div>
           </div>
            <%} %>

</form>
    <script>
    var MAX = 99, MIN = 1;
    $('.weui-count__decrease').click(function (e) {
        var $input = $(e.currentTarget).parent().find('.weui-form-input');
        var number = parseInt($input.val() || "0") - 1
        if (number < MIN) number = MIN;
        $input.val(number)
        showzhi($input)
    })
    $('.weui-count__increase').click(function (e) {
        var $input = $(e.currentTarget).parent().find('.weui-form-input');
        var number = parseInt($input.val() || "0") + 1
        if (number > MAX) number = MAX;
        $input.val(number)
        showzhi($input)
    })
    function  showzhi(obj){
         var zf = $("#jichufen").val();
         $('input[name^="xzfen"]').each(function () {
             var min = parseFloat($(this).attr('min'));
            var max = parseFloat($(this).attr('max'));
             var fen = parseFloat($(this).val());
            if (fen > max || fen < min) {
                $(this).val(0)
            }
             if ($(this).val() != "" && $(this).val() != "NaN") {
                 zf += parseFloat($(this).val());
             }
         });
         $("#zongfen").val(zf);
        }
         $(function () {
             $(document).on("click", "#tijiao", function () {
                /* var result = [];
                 $("[name='timuid']:input").each(function () {
                     result.push($(this).val());
                 });
                 data.field.timuid = result.join(",");
                 alert(JSON.stringify(data.field))	*/
                 $.ajax({
                     // async:false,  //同步
                     url: 'kaohedo.aspx?action=save&zhuangtai=0',
                     type: "POST",
                     data: $("#form1").serialize(),
                     dataType: 'json',
                     beforeSend: function () { $.showLoading();},
                     success: function (res) {
                         $.alert(res.message, "操作提示", function () {
                             return window.location.href = 'kaoheuser.aspx?fanganid=' + $("#fanganid").val() + '&fangshiid='+$("#fanganid").val()+'&pingfen='+$("#pingfen").val()+'&huizong='+$("#huizong").val()+'&bumendy='+$("#bumendy").val()+'&pinlu='+$("#pinlu").val()+'';
                         });
                     }
                     , complete: function () { $.hideLoading();}
                 });
             });
              $(document).on("click", "#baocun", function () {
                /* var result = [];
                 $("[name='timuid']:input").each(function () {
                     result.push($(this).val());
                 });
                 data.field.timuid = result.join(",");
                 alert(JSON.stringify(data.field))	*/
                 $.ajax({
                     // async:false,  //同步
                     url: 'kaohedo.aspx?action=save&zhuangtai=0',
                     type: "POST",
                     data: $("#form1").serialize(),
                     dataType: 'json',
                     beforeSend: function () { $.showLoading();},
                     success: function (res) {
                         $.alert(res.message, "操作提示", function () {
                             return window.location.href = 'kaoheuser.aspx?fanganid=' + $("#fanganid").val() + '&fangshiid='+$("#fangshiid").val()+'&pingfen='+$("#pingfen").val()+'&huizong='+$("#huizong").val()+'&bumendy='+$("#bumendy").val()+'&pinlu='+$("#pinlu").val()+'';
                         });

                     }
                     , complete: function () { $.hideLoading();}
                 });
             });
        });
</script>
</body>
</html>