editTask.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. function getSelectData(initData){
  2. var projId = $("#projId").val();
  3. if(projId != ""){
  4. $.ajax({
  5. type:"post",
  6. url:"TaskDetailAction.do?task=getSelectData4Edit&time=" + new Date().getTime(),
  7. data:{"projId":projId},
  8. timeout:20000,
  9. cache:false,
  10. dataType:"json",
  11. beforeSend:function(){
  12. $("#projNodeIdLoading").show();
  13. $("#taskTypeLoading").show();
  14. },
  15. success:function(data){
  16. var projNodeList = data.projNodeList;
  17. var taskTypeList = data.taskTypeList;
  18. var projNode = document.getElementById("projNodeId");
  19. var taskType = document.getElementById("taskType");
  20. taskType.options.length = 0;
  21. projNode.options.length = 0;
  22. for(var i = 0; i < taskTypeList.length; i++){
  23. addSelectOption(taskType, taskTypeList[i].dname, taskTypeList[i].dvalue);
  24. }
  25. for(var i = 0; i < projNodeList.length; i++){
  26. if(projNodeList[i].projectid){
  27. projNodeList[i].node_name = projNodeList[i].node_name + "(当前阶段)";
  28. }
  29. addSelectOption(projNode, projNodeList[i].node_name, projNodeList[i].universalid);
  30. }
  31. if(projId < 1){
  32. addSelectOption(projNode, "无", "0");
  33. }
  34. // 加一个空的option
  35. addSelectOption(taskType, "", "");
  36. taskType.value = "";
  37. },
  38. error:function(err){
  39. showAjaxError(err);
  40. },
  41. complete:function(msg,err){
  42. $("#projNodeIdLoading").hide();
  43. $("#taskTypeLoading").hide();
  44. if(initData != undefined){
  45. $("#projNodeId").val(initData.projNodeId);
  46. $("#taskType").val(initData.taskType);
  47. }
  48. }
  49. });
  50. }
  51. }
  52. function checkForm() {
  53. var rs = $.validate({
  54. name : "projId",
  55. model : [ {
  56. type : "require",
  57. msg : "请选择项目名称!"
  58. }]
  59. });
  60. rs = $.validate({
  61. name : "projNodeId",
  62. model : [ {
  63. type : "require",
  64. msg : "请选择项目阶段!"
  65. }]
  66. }) && rs;
  67. rs = $.validate({
  68. name : "taskName",
  69. model : [ {
  70. type : "require",
  71. msg : "请填写任务名称!"
  72. } , {
  73. type : "len",
  74. min : 1,
  75. max : 40,
  76. msg : "任务名称须少于20个汉字!"
  77. }]
  78. }) && rs;
  79. rs = $.validate({
  80. name : "taskType",
  81. model : [ {
  82. type : "require",
  83. msg : "请选择任务类型!"
  84. }]
  85. }) && rs;
  86. rs = $.validate({
  87. name : "taskContent",
  88. model : [ {
  89. type : "require",
  90. msg : "请填写任务描述!",
  91. msgBox:"taskContentMsg"
  92. }, {
  93. type : "len",
  94. min : 1,
  95. max : 4000,
  96. msg : "任务描述内容太长,请减少到2000个汉字以内!",
  97. msgBox:"taskContentMsg"
  98. } ]
  99. }) && rs;
  100. rs = $.validate({
  101. name : "planStartDate",
  102. model : [ {
  103. type : "require",
  104. msg : "请填写计划开始时间!"
  105. }]
  106. }) && rs;
  107. rs = $.validate({
  108. name : "planFinDate",
  109. model : [ {
  110. type : "require",
  111. msg : "请填写计划结束始时间!"
  112. }]
  113. }) && rs;
  114. // rs = $.validate({
  115. // name : "provUserName",
  116. // model : [ {
  117. // type : "require",
  118. // msg : "请选择指派人!"
  119. // } ]
  120. // }) && rs;
  121. // rs = $.validate({
  122. // name : "developUserName",
  123. // model : [ {
  124. // type : "require",
  125. // msg : "请选择责任人!"
  126. // } ]
  127. // }) && rs;
  128. rs = $.validate({
  129. name : "planManHour",
  130. model : [ {
  131. type : "regex",
  132. regex: new RegExp("[1-9]\d{0,}"),
  133. msg : "工时必须是大于0的数字"
  134. } ]
  135. }) && rs;
  136. if (rs) {
  137. return true;
  138. }
  139. return false;
  140. }
  141. function commitTask(btnObj){
  142. var isPass = checkForm();
  143. if(isPass){
  144. btnObj.disabled = true;
  145. $.ligerDialog.waitting("正在提交,请稍后……");
  146. $("#taskForm").submit();
  147. }else{
  148. btnObj.disabled = false;
  149. }
  150. }
  151. function initPlanStartDate(initValue){
  152. var id = "planStartDate";
  153. if(initValue){
  154. document.getElementById(id).value = initValue;
  155. }else{
  156. document.getElementById(id).value = getDates(new Date());
  157. }
  158. $("#" + id).ligerDateEditor({ labelAlign: 'left', width:100});
  159. }
  160. function initPlanFinDate(initValue){
  161. var id = "planFinDate";
  162. if(initValue){
  163. document.getElementById(id).value = initValue;
  164. }else{
  165. document.getElementById(id).value = getDates(new Date());
  166. }
  167. $("#" + id).ligerDateEditor({ labelAlign: 'left', width:100});
  168. }
  169. function initPlanStartTime(initValue){
  170. var id = "planStartTime";
  171. createHourOption4Select(id);
  172. if(initValue){
  173. document.getElementById(id).value = initValue;
  174. }else{
  175. document.getElementById(id).value = defaultWorkStartTime;
  176. }
  177. $("#" + id).ligerComboBox({width:70,slide:false});
  178. }
  179. function initPlanFinTime(initValue){
  180. var id = "planFinTime";
  181. createHourOption4Select("planFinTime");
  182. if(initValue){
  183. document.getElementById(id).value = initValue;
  184. }else{
  185. document.getElementById(id).value = defaultWorkEndTime;
  186. }
  187. $("#" + id).ligerComboBox({width:70,slide:false});
  188. }
  189. function change4UserTree(){
  190. var projId = $("#projId").val();
  191. $("#provUserId").val(curProvUserId);
  192. $("#provUserName").val(curProvUserName);
  193. $("#developUserId").val("");
  194. $("#developUserName").val("");
  195. if(projId){
  196. $("#provUserBtn").unbind("click");
  197. $("#developUserBtn").unbind("click");
  198. if(projId > 0){
  199. loadTypeTree("provUserBtn",{type:"singleuser",backId:"provUserId",backName:"provUserName",tab: "7", tabParam:[{tab:"7",root:projId}]});
  200. loadTypeTree("developUserBtn",{type:"singleuser",backId:"developUserId",backName:"developUserName",tab: "7", tabParam:[{tab:"7",root:projId}]});
  201. }else{
  202. if(userScope == "dept"){
  203. loadTypeTree("provUserBtn",{type:"singleuser",backId:"provUserId",backName:"provUserName",tab: "2"});
  204. loadTypeTree("developUserBtn",{type:"singleuser",backId:"developUserId",backName:"developUserName",tab: "2"});
  205. }else if(userScope == "all"){
  206. loadTypeTree("provUserBtn",{type:"singleuser",backId:"provUserId",backName:"provUserName",tab: "1,2"});
  207. loadTypeTree("developUserBtn",{type:"singleuser",backId:"developUserId",backName:"developUserName",tab: "1,2"});
  208. }else{
  209. loadTypeTree("provUserBtn",{type:"singleuser",backId:"provUserId",backName:"provUserName",tab: "2"});
  210. loadTypeTree("developUserBtn",{type:"singleuser",backId:"developUserId",backName:"developUserName",tab: "2"});
  211. }
  212. }
  213. }else{
  214. $("#provUserBtn").bind("click", function(){alert("请先选择项目!");});
  215. $("#developUserBtn").bind("click", function(){alert("请先选择项目!");});
  216. }
  217. }