前端二维码逻辑

<script>
function oa_manage(){
	criterion_action = 'OaManage';
	$.ajax({url:'__APP__/OaManage/index',
	dataType:'json',
	success:function(data){
	CreatDialog(data.html,'oa_manage');
	}
	})
}
//添加员工信息
  function OaManage_data(staff_id, btn_id) {
    var name = $('#staff_name').val();
    var tel = $('#staff_tel').val();
    var id_number = $('#id_number').val();
    var operating_post = $('#operating_post').val();
    var gx_id = $('#staff_gx').val();
    var beizhu = $('#staff_beizhu').val();
    var gongren = $("#select_gr").val();
    var hasChk = $('#for_add_meterial').is(':checked');
    if (name.length == 0) {
      alert("请输入名称");
      return false;
    }
    if (tel.length == 0) {
      alert("请输入联系方式!");
      return false;
    }
    post_data = { zx_id: staff_id, name: name, tel: tel, beizhu: beizhu, gx_id: gx_id, id_number: id_number, operating_post: operating_post,module:gongren };
    exec_criterion_handle_submit1(post_data, 'Personnel_show_tr', btn_id, hasChk);
  }
  function exec_criterion_handle_submit1(submit_data, refurbish_id, btn_id, hasChk) {
    $.ajax({
      url: '__APP__/' + criterion_action + '/exec_criterion_handle_submit',
      dataType: 'json',
      type: 'POST',
      data: submit_data,
      success: function (data) {
        if (data.status == 0) {
          alert(data.info);
          return false;
        }
        var exs = $("#" + refurbish_id);
        var refurbish_obj = exs;
        alert(data.info);
        refurbish_obj.html(data.html);
        ex = exs.find("[gid=" + data.id + "]");
        ex.click();
        if (hasChk) {
          $('#staff_name').focus();
          $('#staff_name').attr('value', '');
          $('#staff_tel').attr('value', '');
          $('#staff_beizhu').attr('value', '');
          $('#id_number').attr('value', '');
          $('#operating_post').attr('value', '');
          $('#select_gr').attr('value', '工人');
        } else {
          close_xianshi_id(btn_id);
        }
      },
    })
  }
  var fflag=0
  var keep_time=0;
  //绑定工人
  function bound_workers(id){
    fflag=id;
    $.ajax({
        url: '__APP__/' + criterion_action + '/bound_workers',
        dataType: 'json',
        type: 'POST',
        data: {id:id},
        success: function (data) {
          if (data.status == 1) {
            CreatDialog(data.html,'bound_workers');
            Refresh_ewm(id);
          }
        }
      })
  }
  //解绑
  function unbind_worker(id){
    $.ajax({
        url: '__APP__/ProcessManage/unbind_worker',
        dataType: 'json',
        type: 'POST',
        data: {worker_id:id},
        success: function (data) {
          if (data.status == 1) {
            alert("解绑成功")
            oa_manage();
          }else{
            alert("解绑失败")
          }
        }
      })
  }
  //生成二维码
  function Refresh_ewm(id){
    $("#loading_img").show();
    $.ajax({
        url: '__APP__/ProcessManage/get_worker_bind_code_new',
        dataType: 'json',
        type: 'POST',
        data:{worker_id:id},
        success: function (data) {
          if (data.status == 1) {
           $("#loading_img").hide();
           $("#ewm_img").attr("src",data.data.url);
           $('#Refresh_ewm_a').hide();
            detection_ewm(id)
          }else{
            $("#Refresh_ewm_a").show();
            $("#Refresh_ewm_a").html("二维码生成失败,请点击刷新")
          }
        }
      })
  } 
  //结束循环
  function judge_isclose(){
     fflag=0;
    if(keep_time!=0){
            clearTimeout(keep_time);
            keep_time=0;
          }
  }

  //检测二维码
  function detection_ewm(gid){
    if(fflag==0){
          return false;
    }
	if(fflag!=gid){
		return false;
    }
    $.ajax({
        url: '__APP__/ProcessManage/chk_worker_bind_new',
        dataType: 'json',
        type: 'POST',
        data:{worker_id:gid},
        success: function (data) {
          //二维码扫码成功
          if (data.status == 1) {
            alert("绑定成功");
            //关闭页面
            close_xianshi($("#staff_close").get(0));
            //关闭定时器
            judge_isclose();
            //刷新页面
            oa_manage();
          }
          //二维码超时
          if(data.status == 2){
            $("#ewm_img").hide();
            $("#Refresh_ewm_a").show();
            $("#Refresh_ewm_a").html("二维码过期,请点击刷新")
          }
          if(data.status == 0){
            if(keep_time!=0){
              clearTimeout(keep_time);
              keep_time=0;
            }
            keep_time=setTimeout(function(){
                            detection_ewm(gid);
              }, 2000);
          }
        }
      })
  } 
  function edit_status(status,worker_id){
    $.ajax({
        url: '__APP__/' + criterion_action + '/edit_status',
        dataType: 'json',
        type: 'POST',
        data: {status:status,worker_id:worker_id},
        success: function (data) {
          if (data.status == 1) {
            alert(data.info);
            oa_manage()
          }
        }
      })
  }
</script>

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值