createTask.js 7.1 KB

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