/**
 * 项目列表页
 * 
 * @link      http://www.u-bo.com
 * @copyright 南京友博网络科技有限公司 
 * @license   http://www.u-bo.com/license/ 
 * 
 * @author Strief http://blog.u-bo.com
 * @since 0.1
 */
jQuery(function($) {

	/**
	 * 列表页数据核对快捷操作
	 */
	$(document).on('click', '.set-check', function() {
		if (!confirm('确定更改数据核对状态？')) {
			return false;	
		}
		$.post($(this).data('setUrl'), {}, function(resp) {
			if (resp.status == 1) {
				art.dialog({
	                title: '成功提示',
	                time: 3,
	                icon: 'succeed',
	                content: resp.info,
	                close: function() {
	                    var opener = art.dialog.opener;
	                    var mainDialog = opener.art.dialog.list['main-dialog'];
	                    if (mainDialog != undefined) {
	                        mainDialog.close();
	                    }
	                    return true;
	                }
	            });
				setTimeout("window.location.href = index",1000);
			} else {
				art.dialog({
                    title: '失败提示',
                    time: 3,
                    icon: 'error',
                    content: resp.info
                });
			}
		});
	});

	//及时设置项目状态
    $(".project-status-select").on('change', function() {
        if (!confirm('确定要改变状态？')) {
            return false;
        }
        var statusId = $(this).find('option:selected').val();
        var url = $(this).data('setUrl');
        url += statusId;
        $.getJSON(url, function(json) {
            if (json.status == 1) {
                $(".project-status").html(json.status_name);
                art.dialog({
                    title: '成功提示',
                    time: 3,
                    icon: 'succeed',
                    content: json.info,
                    close: function() {
                        var opener = art.dialog.opener;
                        var mainDialog = opener.art.dialog.list['main-dialog'];
                        if (mainDialog != undefined) {
                            mainDialog.close();
                        }
                        return true;
                    }
                });
                //artDialog.tips('状态修改成功');
            }
            else {
                art.dialog({
                    title: '失败提示',
                    time: 3,
                    icon: 'error',
                    content: json.info
                });
            }

        });
    });
});