project.js 3.82 KB
/**
 * @fileOverview 反馈模块
 * @author:Hbomb(zhouqq@yoho.cn)
 * @date:2013-05-27
 */
define('project',function(require, exports)
{
    var box = require('box'); // 提示框
    var $ = require("jquery");
    require('lib/ui/jquery.gantt');
    var form_html = $("#form_pan").html()+'';
    var admin = $("#form_pan").attr("admin");
    $("#form_pan").remove();
    $("#btn-createproject").click(function()
    {
        box.confirm
        (
            form_html, submitProject,
            {
                title: '创建项目', 
                width: '750px', 
                autoClose: false
            }
        );
        $('#finish_time,#create_time').click(function()
        {
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});
        });
    });
    
    //查看
    $(".look").click(function()
    {
        box.confirm
        (
            form_html, submitProject,
            {
                title: '查看项目', 
                width: '750px', 
                autoClose: false
            }
        );
        
        var obj = $(this).parents("tr");
        var name = obj.find("td:eq(1)").text();
        var email_list = obj.find("td:eq(2)").text();
        var finish_time = obj.find("td:eq(4)").text();
        var create_time = obj.find("td:eq(3)").text();
        var id = obj.find("td:eq(0)").text();
        
        $("#id").val(id);
        $("#name").val(name);
        $("#email_list").val(email_list);
        $("#finish_time").val(finish_time);
        $("#create_time").val(create_time);
        $("#state").val($(".search_panel select").val());
        
        $('#finish_time,#create_time').click(function()
        {
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});
        });
    });
    
    
    function submitProject()
    {
        if(admin==0)
        {
            alert("无权进行此操作");
            return;
        }
        var name = $("#name").val();
        var state = $("#state").val();
        var finish_time =  $("#finish_time").val();
        var create_time =  $("#create_time").val();
        var email_list = $("#email_list").val();
        var id = $("#id").val();
        if(name==""||create_time==""||finish_time==""||email_list=="")
        {
            alert("所有字段不能为空!");
            return;
        }
        $.ajax
        ({
            type: "post",
            url: '/default/default/submitproject',
            data: "name=" + name+
            "&finish_time="+finish_time+
            "&create_time="+create_time+
            "&email_list="+email_list+
            "&state="+state+
            "&id="+id,
            success: function(data)
            {
                if (data.code == 200)
                {
                    window.location.reload();
                }
                else
                {
                    box.alert(data.message);
                }
            }
        });
    }
    
    $.ajax
    ({
        type: "get",
        url: '/default/default/getprojectlist',
        dataType:"json",
        success: function(data)
        {
            if (data)
            {
                $(".gantt").gantt(
                {
                    months:["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
                    dow:["日", "一", "二", "三", "四", "五", "六"],
                    source: data,
                    navigate: "scroll",
                    scale: "days",
                    maxScale: "months",
                    minScale: "days",
                    itemsPerPage: 10,
                    onItemClick: function(data) {
                    },
                    onAddClick: function(dt, rowId) {
                    },
                    onRender: function() {
                    }
                });
            }
        }
    });
    


    
});