| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- function getSelectData(initData){
- var projId = $("#projId").val();
- var projNodeIdObj = $("projNodeId");
- projNodeIdObj.val("");
- if(projId != ""){
- $.ajax({
- type:"post",
- url:"CreateTaskAction.do?task=getSelectData&time=" + new Date().getTime(),
- data:{"projId":projId} ,
- timeout:20000,
- cache:false,
- dataType:"json",
- beforeSend:function(){
- $("#projNodeIdLoading").show();
- $("#taskTypeLoading").show();
- },
- success:function(data){
- var projNodeList = data.projNodeList;
- var taskTypeList = data.taskTypeList;
- var projNode = document.getElementById("projNodeId");
- var taskType = document.getElementById("taskType");
- taskType.options.length = 0;
- projNode.options.length = 0;
- var selectedProjNodeId = 0;
- for(var i = 0; i < taskTypeList.length; i++){
- addSelectOption(taskType, taskTypeList[i].dname, taskTypeList[i].dvalue);
- }
- for(var i = 0; i < projNodeList.length; i++){
- if(projNodeList[i].projectid){
- selectedProjNodeId = projNodeList[i].universalid;
- projNodeList[i].node_name = projNodeList[i].node_name + "(当前阶段)";
- }
- addSelectOption(projNode, projNodeList[i].node_name, projNodeList[i].universalid);
- }
- if(projId < 1){
- addSelectOption(projNode, "无", "0");
- }
- projNode.value = selectedProjNodeId;
- // 加一个空的option
- addSelectOption(taskType, "", "");
- taskType.value = "";
- },
- error:function(err){
- showAjaxError(err);
- },
- complete:function(msg,err){
- $("#projNodeIdLoading").hide();
- $("#taskTypeLoading").hide();
- if(initData != undefined){
- projNode.value = initData.projNodeId;
- taskType.value = initData.taskType;
- }
- projNodeIdSelect.setSelect();
- taskTypeSelect.setSelect();
- }
- });
- }
- }
- function checkForm() {
- var rs = $.validate({
- name : "projId",
- model : [ {
- type : "require",
- msg : "请选择项目名称!",
- msgBox:"projIdMsg"
- }]
- });
- rs = $.validate({
- name : "projNodeId",
- model : [ {
- type : "require",
- msg : "请选择项目阶段!",
- msgBox : "projNodeIdMsg"
- }]
- }) && rs;
- rs = $.validate({
- name : "taskName",
- model : [ {
- type : "require",
- msg : "请填写任务名称!"
- } , {
- type : "len",
- min : 1,
- max : 40,
- msg : "任务名称须少于40个字!"
- }]
- }) && rs;
- rs = $.validate({
- name : "taskType",
- model : [ {
- type : "require",
- msg : "请选择任务类型!",
- msgBox: "taskTypeMsg"
- }]
- }) && rs;
- rs = $.validate({
- name : "taskContent",
- model : [ {
- type : "require",
- msg : "请填写任务描述!",
- msgBox:"taskContentMsg"
- }, {
- type : "len",
- min : 1,
- max : 4000,
- msg : "任务描述内容太长,请减少到2000个汉字以内!",
- msgBox:"taskContentMsg"
- } ]
- }) && rs;
- rs = $.validate({
- name : "planStartDate",
- model : [ {
- type : "require",
- msg : "请填写计划开始时间!"
- }]
- }) && rs;
- rs = $.validate({
- name : "planFinDate",
- model : [ {
- type : "require",
- msg : "请填写计划结束始时间!"
- }]
- }) && rs;
- rs = $.validate({
- name : "provUserName",
- model : [ {
- type : "require",
- msg : "请选择指派人!",
- msgBox:"provUserMsg"
- } ]
- }) && rs;
- rs = $.validate({
- name : "developUserName",
- model : [ {
- type : "require",
- msg : "请选择责任人!",
- msgBox:"developUserMsg"
- } ]
- }) && rs;
- rs = $.validate({
- name : "planManHour",
- model : [ {
- type : "regex",
- regex: new RegExp("[1-9]\d{0,}"),
- msg : "工时必须是大于0的数字"
- } ]
- }) && rs;
-
- // 负责人最多为20个
- var developUserId = $("#developUserId").val();
- if(developUserId.split(",").length > 21){
- $("#developUserWarn").show();
- rs = false;
- }else{
- $("#developUserWarn").hide();
- }
-
-
- if (rs) {
- return true;
- }
- return false;
- }
- function commitTask(btnObj){
- var isPass = checkForm();
- if(isPass){
- btnObj.disabled = true;
- $.ligerDialog.waitting("正在提交,请稍后……");
- $("#taskForm").submit();
- }else{
- btnObj.disabled = false;
- }
- }
- function cancelCreateTask(btnObj){
- window.close();
- }
- function initPlanStartDate(initValue){
- var id = "planStartDate";
- if(initValue){
- document.getElementById(id).value = initValue;
- }else{
- document.getElementById(id).value = getDates(new Date());
- }
- $("#" + id).ligerDateEditor({ labelAlign: 'left', width:100});
- }
- function initPlanFinDate(initValue){
- var id = "planFinDate";
- if(initValue){
- document.getElementById(id).value = initValue;
- }else{
- document.getElementById(id).value = getDates(new Date());
- }
- $("#" + id).ligerDateEditor({ labelAlign: 'left', width:100});
- }
- function initPlanStartTime(initValue){
- var id = "planStartTime";
- createHourOption4Select(id);
- if(initValue){
- document.getElementById(id).value = initValue;
- }else{
- document.getElementById(id).value = defaultWorkStartTime;
- }
- // $("#" + id).ligerComboBox({width:70,slide:false});
- }
- function initPlanFinTime(initValue){
- var id = "planFinTime";
- createHourOption4Select("planFinTime");
- if(initValue){
- document.getElementById(id).value = initValue;
- }else{
- document.getElementById(id).value = defaultWorkEndTime;
- }
- // $("#" + id).ligerComboBox({width:70,slide:false});
- }
- function change4UserTree(){
- var projId = $("#projId").val();
- $("#provUserId").val(curProvUserId);
- $("#provUserName").val(curProvUserName);
- $("#developUserId").val("");
- $("#developUserName").val("");
- if(projId){
- $("#provUserBtn").unbind("click");
- $("#developUserBtn").unbind("click");
- if(projId > 0){
- loadTypeTree("provUserBtn",{type:"singleuser",backId:"provUserId",backName:"provUserName",tab: "7", tabParam:[{tab:"7",root:projId}]});
- loadTypeTree("developUserBtn",{type:"user",backId:"developUserId",backName:"developUserName",tab: "7", tabParam:[{tab:"7",root:projId}]});
- }else{
- if(userScope == "dept"){
- loadTypeTree("provUserBtn",{type:"singleuser",backId:"provUserId",backName:"provUserName",tab: "2"});
- loadTypeTree("developUserBtn",{type:"user",backId:"developUserId",backName:"developUserName",tab: "2"});
- }else if(userScope == "all"){
- loadTypeTree("provUserBtn",{type:"singleuser",backId:"provUserId",backName:"provUserName",tab: "1,2"});
- loadTypeTree("developUserBtn",{type:"user",backId:"developUserId",backName:"developUserName",tab: "1,2"});
- }else{
- loadTypeTree("provUserBtn",{type:"singleuser",backId:"provUserId",backName:"provUserName",tab: "2"});
- loadTypeTree("developUserBtn",{type:"user",backId:"developUserId",backName:"developUserName",tab: "2"});
- }
- }
- }else{
- $("#provUserBtn").bind("click", function(){alert("请先选择项目!");});
- $("#developUserBtn").bind("click", function(){alert("请先选择项目!");});
- }
- }
- //修改者 yanwp 2013-4-12 新建临时任务分解
- function onchange4DevelopUser(){
- var developUserId = $("#developUserId").val();
- if(developUserId && developUserId.indexOf(",") != -1){
- if(developUserId.split(",").length > 21){ //任务分解 个人上限判断
- $("#developUserWarn").show();
- $("#developUserNotice").hide();
- }else{
- $("#developUserNotice").show();
- $("#developUserWarn").hide();
- }
- }else{
- $("#developUserWarn").hide();
- $("#developUserNotice").hide();
- }
- }
|