淘先锋技术网

首页 1 2 3 4 5 6 7
$grid->actions(function ($actions){
            $actions->disableDelete();
            $actions->disableEdit();
            $actions->disableView();
            $back_url = $_SERVER["QUERY_STRING"];
            if (\request('_scope_') == 'trashed') {
                $actions->append('<a class="btn btn-sm btn-default grid-row-restore" data-id="'.$actions->getKey().'">恢复</a>');
            }else{
                $actions->append('<a href="/admin/units/'.$actions->getKey().'/units_change?'.$back_url.'" class="btn btn-sm btn-default" >修改</a>');
                $actions->append('<a class="btn btn-sm btn-default grid-row-delete" data-id="'.$actions->getKey().'">删除</a>');
            }
        });
        Admin::script("$('.grid-row-delete').unbind('click').click(function() {
            var id = $(this).data('id');
            swal({
                title: \"确认删除?\",
    	      // text: "请扫描用户手机上的付款码",
    	      //  inputPlaceholder: "请填写付款码数字",
                type: \"warning\",
              // type: "input", 
                showCancelButton: true,
                confirmButtonColor: \"#DD6B55\",
                showLoaderOnConfirm: true,
                confirmButtonText: \"确认\",
                cancelButtonText: \"取消\",
             //  imageUrl: "/assets/images/icon/scancode.gif",
            //  closeOnConfirm: false,
			//  closeOnCancel: false
                preConfirm: function() {
                    return new Promise(function(resolve) {
                        $.ajax({
                            method: 'post',
                            url: '/admin/units/' + id,
                            data: {
                                _method:'delete',
                                _token:LA.token,
                            },
                            success: function (data) {
                                $.pjax.reload('#pjax-container');
                                resolve(data);
                            }
                        });
                    });
                }
            }).then(function(result) {
                var data = result.value;
                if (typeof data === 'object') {
                    if (data.status) {
                        swal(data.message, '', 'success');
                    } else {
                        swal(data.message, '', 'error');
                    }
                }
            });
        });");
        Admin::script("$('.grid-row-restore').unbind('click').click(function() {
            var id = $(this).data('id');
            swal({
                title: \"确认恢复?\",
                type: \"warning\",
                showCancelButton: true,
                confirmButtonColor: \"#DD6B55\",
                confirmButtonText: \"确认\",
                showLoaderOnConfirm: true,
                cancelButtonText: \"取消\",
                preConfirm: function() {
                    return new Promise(function(resolve) {
                        $.ajax({
                            method: 'post',
                            url: '/admin/units/restore',
                            data: {
                                _key:id,
                                _method:'post',
                                _token:LA.token,
                            },
                            success: function (data) {
                                $.pjax.reload('#pjax-container');
                                resolve(data);
                            }
                        });
                    });
                }
            }).then(function(result) {
                var data = result.value;
                if (typeof data === 'object') {
                    if (data.status) {
                        swal(data.message, '', 'success');
                    } else {
                        swal(data.message, '', 'error');
                    }
                }
            });
        });");
$(function () {
    $(".table-hover").addClass('table-striped');

    var url_type = getQueryVariable('type');
    // 业务主管 和 供管部主管 审批
    $('.grid-row-check').unbind('click').click(function() {
        var id = $(this).data('id');
        var status = $(this).data('status');
        swal({
            title: "确认审批通过?",
            type: "success",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确认",
            showLoaderOnConfirm: true,
            cancelButtonText: "取消",
            preConfirm: function() {
                return new Promise(function(resolve) {
                    $.ajax({
                        method: 'post',
                        url: '/admin/tmpfeeds/check_store',
                        data: {
                            id:id,
                            status:status,
                            _token:LA.token,
                        },
                        success: function (data) {
                            $.pjax.reload('#pjax-container');
                            swal(data.message, '', 'success');
                            resolve(data);
                        }
                    });
                });
            }
        }).then(function(result) {
            var data = result.value;
            if (typeof data === 'object') {
                if (data.status) {
                    swal(data.message, '', 'success');
                } else {
                    swal(data.message, '', 'error');
                }
            }
        });
    });
    // 统一 审批驳回
    $('.grid-row-reject').unbind('click').click(function() {
        var id = $(this).data('id');
        var status = $(this).data('status');
        swal({
            title: "确认驳回?",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确认",
            showLoaderOnConfirm: true,
            cancelButtonText: "取消",
            preConfirm: function() {
                return new Promise(function(resolve) {
                    $.ajax({
                        method: 'post',
                        url: '/admin/tmpfeeds/check_store',
                        data: {
                            id:id,
                            status:status,
                            _token:LA.token,
                        },
                        success: function (data) {
                            $.pjax.reload('#pjax-container');
                            swal(data.message, '', 'success');
                            resolve(data);
                        }
                    });
                });
            }
        }).then(function(result) {
            var data = result.value;
            if (typeof data === 'object') {
                if (data.status) {
                    swal(data.message, '', 'success');
                } else {
                    swal(data.message, '', 'error');
                }
            }
        });
    });
    // 供管部经理点击审批
    $('.grid-row-lead-check').unbind('click').click(function() {
        $('body,html').animate({
                scrollTop: 0
            },
            500);
        var id = $(this).data('id');
        var status = $(this).data('status');
        $(".indate").datetimepicker({"format":"YYYY-MM-DD","locale":"zh-CN","allowInputToggle":true});
        $('.tmp_id').val(id)
        $('.tmp_status').val(status)
    });
    // TODO 供管部主管 审批模板
    var template = "" +
        " <div class=\"modal fade\" id=\"myModal\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\" aria-hidden=\"true\">\n" +
        "        <div class=\"modal-dialog modal-md\" id=\"modalDialog\" role=\"document\" style=\"width:600px\">\n" +
        "            <div class=\"modal-content\" >\n" +
        "                <div class=\"modal-header\">\n" +
        "                    <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\">&times;</span></button>\n" +
        "                    <h4 class=\"modal-title\">供管部经理审批</h4>\n" +
        "                </div>\n" +
        "                <form class=\"form-horizontal ajax_modify\" >\n" +
        "                    <div class=\"box-body\">\n" +
        "                        <div class=\"form-group\">\n" +
        "                            <div class=\"col-md-12\">\n" +
        "                                <label for=\"indate\" class=\"asterisk control-label col-md-3\" title=\"有效期\">有效期:</label>\n" +
        "                                <div class=\"col-md-7\">\n" +
        "                                    <input type=\"text\" id=\"indate\" class=\"form-control col-sm-12 indate\" name=\"indate\" placeholder=\"\" index=\"1\" required=\"1\">\n" +
        "                                </div>\n" +
        "                            </div>\n" +
        "                        </div>\n" +
        "                    </div>\n" +
        "                    <div class=\"modal-footer\">\n" +
        "                        <input type=\"hidden\" class=\"tmp_id\" name=\"id\">\n" +
        "                        <input type=\"hidden\" class=\"tmp_status\" name=\"status\">\n" +
        "                        <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">关闭</button>\n" +
        "                        <button type=\"button\" class=\"btn btn-primary\" οnclick=\"ajax_modify_submit()\">提交</button>\n" +
        "                    </div>\n" +
        "                </form>\n" +
        "            </div>\n" +
        "        </div>\n" +
        "    </div>" +
        "</div>" +
        "";

    if(url_type == 2){
        $('.table-responsive').append(template)
        $(".indate").datetimepicker({"format":"YYYY-MM-DD","locale":"zh-CN","allowInputToggle":true});
    }
    // 获取url
    function getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
        }
        return(false);
    }


});

function ajax_modify_submit(){
    var indate = $('.indate').val();
    var id = $('.tmp_id').val();
    var status = $('.tmp_status').val();
    if(!indate){
        swal('请选择有效期', '', 'error');
        return false;
    }
    swal({
        title: "确认审批通过?",
        type: "success",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确认",
        showLoaderOnConfirm: true,
        cancelButtonText: "取消",
        preConfirm: function() {
            return new Promise(function(resolve) {
                $.ajax({
                    method: 'post',
                    url: '/admin/tmpfeeds/check_store',
                    data: {
                        id:id,
                        status:status,
                        indate:indate,
                        _token:LA.token,
                    },
                    success: function (data) {
                        $.pjax.reload('#pjax-container');
                        swal(data.message, '', 'success');
                        resolve(data);
                    }
                });
            });
        }
    }).then(function(result) {
        var data = result.value;
        if (typeof data === 'object') {
            if (data.status) {
                swal(data.message, '', 'success');
            } else {
                swal(data.message, '', 'error');
            }
        }
    });
}
 //删除工单
function doDel(id){
	 swal({
		title: "确定要删除工单吗?",
		/* text: "删除之后无法恢复该数据!", */
		type: 'warning',
		showCancelButton: true,
		confirmButtonColor: "#DD6B55",
		confirmBu


ttonText: "确定",
		cancelButtonText: "取消",
		closeOnConfirm: false
		},
		function (isConfirm) {
			if(isConfirm){
				$.ajax({
					url:'<%=path%>/worktask/del',
					method:'post',
					data:{"ID":id},
					success:function(str){
						var data = eval("("+str+")");
						 if(data.success){
							 // 刷新数据
							 window.location.reload();
							 swal('提示','删除工单成功!');
						 }else{
							 swal('提示','删除工单失败!');
						 }
					 }
				 });
			}
		}); 
 }
//删除工单
	function doDel(id){
		 swal({
			title: "确定要删除该工单吗?",
			/* text: "删除之后无法恢复该数据!", */
			icon: 'warning',
			buttons: {
				  cancel: {
					    text: "取消",
					    value: "",
					    visible: true,
					    closeModal: true,
					  },
					  confirm: {
					    text: "确定",
					    value: true,
					    visible: true,
					    closeModal: true
					  }
					},
			confirmButtonColor: "#DD6B55",
			}).then(function(isConfirm){
				if(isConfirm){
					console.log("点击确定")
					 $.ajax({
						url:'<%=path%>/worktask/del',
						method:'post',
						data:{"ID":id},
						success:function(str){
							var data = eval("("+str+")");
							 if(data.success){
								 // 刷新数据
								 window.location.reload();
								 swal('提示','删除工单成功!');
							 }else{
								 swal('提示','删除工单失败!');
							 }
						 }
					 }); 
				}else{
					console.log("点击取消");
				}
			})
	 }