addTask.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. 'use strict';
  2. $(function(){
  3. //读取链接参数
  4. function getUrlParam(name, link){
  5. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  6. var search;
  7. if (link) {search = link.substr(link.indexOf("?"),link.length);}
  8. else { search = window.location.search;}
  9. var r = search.substr(1).match(reg);
  10. if (r != null)
  11. return decodeURI(r[2]);
  12. return null;
  13. }
  14. //给任务名和任务处理人默认值
  15. if ($('input[name="name"]').val() == "") {
  16. $('input[name="name"]').val(getUrlParam('name'));
  17. }
  18. if(getUrlParam('resourcename')) {
  19. showDefault(getUrlParam('resourcename'));
  20. }
  21. // 默认需要回复
  22. $('input[name="type"]').trigger('click');
  23. // 输入框右侧图标点击使输入框获得焦点
  24. $('.weui_cell_input .weui_cell_ft').on('click', function(){
  25. $('input', $(this).parent()).trigger('focus');
  26. });
  27. // 已选择指定人的容器
  28. var checkedUsers = [];
  29. // Loading框,封装了show 和 hide 方法
  30. var Loading = function(){
  31. var loading = $('#loadingToast');
  32. return {
  33. show: function(){loading.css('display', 'block')},
  34. hide: function(){loading.css('display', 'none')}
  35. };
  36. }();
  37. //系统默认时间
  38. Date.prototype.Format = function (fmt) { //author: meizz
  39. var o = {
  40. "M+": this.getMonth() + 1, //月份
  41. "d+": this.getDate(), //日
  42. "h+": this.getHours(), //小时
  43. "m+": this.getMinutes(), //分
  44. "s+": this.getSeconds(), //秒
  45. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  46. "S": this.getMilliseconds() //毫秒
  47. };
  48. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  49. for (var k in o)
  50. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  51. return fmt;
  52. }
  53. // dialog对话框
  54. var dialog = function(title, content, footer, fn){
  55. $('#dialog .weui_dialog .weui_dialog_title').text(title);
  56. $('#dialog .weui_dialog .weui_dialog_bd').text(content);
  57. if(footer) {// 如果传了按钮字符,设置按钮字符
  58. $('#dialog .weui_dialog .primary').text(footer);
  59. }
  60. $('#dialog .weui_dialog .weui_dialog_ft').on('click', function() {
  61. $('#dialog').css('display', 'none');
  62. if(fn) {// 如果传了回调函数,调用回调函数
  63. fn.call(null);
  64. }
  65. });
  66. $('#dialog').css('display', 'block');
  67. };
  68. // 检验用户是否已经被选中,未被选中返回-1,选中返回index
  69. function checked(em) {
  70. var r = -1;
  71. $.each(checkedUsers, function(k, v) {
  72. if(v.em_code == em.em_code) {
  73. r = k;
  74. return r;
  75. }
  76. });
  77. return r;
  78. };
  79. // 打开指定人的页面
  80. function openUserTab(){
  81. $('#userTab').addClass('open');
  82. //初始化数据
  83. var rootData = [];
  84. //节点层级数 最多10层
  85. var leafNumber = ['containerFirst','containerTwo','containerThree','containerFour','containerFive','containerSix','containerSeven','containerEight','containerNine','containerTen']
  86. var parentEle = 'containerFirst';
  87. function spanNumConvert(num) {
  88. var str = num.slice(0,num.indexOf('span'));
  89. var lenfNum = 'container' + str.replace(/(^|\s+)\w/g,function(s){return s.toUpperCase();});
  90. return lenfNum;
  91. }
  92. function StrConvert(str){
  93. switch(str)
  94. {
  95. case 'First':
  96. return 'twospan';
  97. break;
  98. case 'Two':
  99. return 'threespan';
  100. break;
  101. case 'Three':
  102. return 'fourspan';
  103. break;
  104. case 'Four':
  105. return 'fivespan';
  106. break;
  107. case 'Five':
  108. return 'sixspan';
  109. break;
  110. case 'Six':
  111. return 'sevenspan';
  112. break;
  113. case 'Seven':
  114. return 'eightspan';
  115. break;
  116. case 'Eight':
  117. return 'ninespan';
  118. break;
  119. case 'Nine':
  120. return 'tenspan';
  121. break;
  122. default:
  123. return str;
  124. break;
  125. }
  126. }
  127. function NumConvert(str) {
  128. switch(str)
  129. {
  130. case 'containerFirst':
  131. return 1;
  132. break;
  133. case 'containerTwo':
  134. return 2;
  135. break;
  136. case 'containerThree':
  137. return 3;
  138. break;
  139. case 'containerFour':
  140. return 4;
  141. break;
  142. case 'containerFive':
  143. return 5;
  144. break;
  145. case 'containerSix':
  146. return 6;
  147. break;
  148. case 'containerSeven':
  149. return 7;
  150. break;
  151. case 'containerEight':
  152. return 8;
  153. break;
  154. case 'containerNine':
  155. return 9;
  156. break;
  157. default:
  158. return str;
  159. break;
  160. }
  161. }
  162. var leafInfo = {
  163. or_id: null,
  164. page: 1,
  165. pageSize: 100
  166. };
  167. //查看根节点
  168. function getRoot(str) {
  169. $('#userTab .firstdepto .'+ str +' .uas-seft').on('click', function(e) {
  170. parentEle = $(this).parent('div').attr('class');
  171. $('.'+ parentEle).css('display', 'none');
  172. $('#userTab .uas span').removeClass('active');
  173. var v_id = $(this).attr('id');
  174. var hrorg = {};
  175. //第几层数据
  176. var num = NumConvert(str);
  177. if(rootData[num-1].hasOwnProperty('hrorgs')) {
  178. $.each(rootData[num-1].hrorgs, function(k, v){
  179. if(v.or_code == v_id) {
  180. hrorg = v;
  181. }
  182. });
  183. }
  184. // 获取对应层级
  185. var spanNumber = StrConvert(parentEle.substr(9));
  186. var parentNumber = parentEle.substr(9).toLowerCase() + "span"
  187. var html = '<span id="' + spanNumber + '" class="active">'+ hrorg.or_name +'<i class="fa fa-caret-right"></i></span>';
  188. $('#userTab .uas #' + parentNumber).next('span').remove();
  189. $(html).insertAfter('#userTab .uas #' + parentNumber);
  190. leafInfo.or_id = hrorg.or_id;
  191. getLeaf(parentEle);
  192. $('#userTab .uas #' + spanNumber).on('click', function(event) {
  193. $('#' + spanNumber).addClass('active');
  194. $('.'+ spanNumConvert(spanNumber)).css('display', 'block');
  195. if($(this).next('span').length >= 1) {
  196. rootData.splice(NumConvert(spanNumConvert(spanNumber)),rootData.length);
  197. }
  198. while($('.' + spanNumConvert(spanNumber)).next('div') && $('.' + spanNumConvert(spanNumber)).next('div').length != 0) {
  199. $('.' + spanNumConvert(spanNumber)).next('div').remove();
  200. }
  201. while($(this).next('span') && $(this).next('span').length != 0) {
  202. $(this).next('span').remove();
  203. }
  204. event.stopPropagation(); // 阻止事件冒泡
  205. });
  206. });
  207. }
  208. //查询叶子节点目录
  209. function getLeaf(str) {
  210. function getNextContainer(str) {
  211. for (var i=0;i<=leafNumber.length;i++) {
  212. if(leafNumber[i] == str){
  213. return leafNumber[i+1];
  214. }
  215. }
  216. }
  217. Loading.show();
  218. $.ajax({
  219. url: 'mobile/getLeafHrorg.action',
  220. type: 'GET',
  221. data: leafInfo,
  222. success: function(data) {
  223. if(data.hrorgs.length == 0 && data.employees.length == 0) {
  224. dialog('提示', '未查询到数据,请返回上一层');
  225. }
  226. if(rootData.length == NumConvert(str)) {
  227. rootData.push(data);
  228. }
  229. var nextContainer = getNextContainer(str);
  230. var htmlTwo = '<div class="' + nextContainer + '"></div>';
  231. $('#userTab .firstdepto').append(htmlTwo);
  232. $.each(data.hrorgs,function(k,v) {
  233. if(data.hrorgs.length == k+1) {
  234. var html3 = '<a id="' + v.or_code + '" class="weui_cell uas-seft" href="javascript:;" style="margin-bottom: -10px;">' +
  235. '<div class="weui_cell_hd">' +
  236. '<img src="jsps/mobile/img/iconfont_bumen.png" alt="icon"style="width: 20px; margin-right: 5px; display: block">' +
  237. '</div>' +
  238. '<div class="weui_cell_bd weui_cell_primary">' +
  239. '<p>' + v.or_name + '</p></div><div class="weui_cell_ft">'+ v.or_name +
  240. '</div>' +
  241. '</a>';
  242. }else {
  243. var html3 = '<a id="' + v.or_code + '" class="weui_cell uas-seft" href="javascript:;">' +
  244. '<div class="weui_cell_hd">' +
  245. '<img src="jsps/mobile/img/iconfont_bumen.png" alt="icon"style="width: 20px; margin-right: 5px; display: block">' +
  246. '</div>' +
  247. '<div class="weui_cell_bd weui_cell_primary">' +
  248. '<p>' + v.or_name + '</p></div><div class="weui_cell_ft">'+ v.or_name +
  249. '</div>' +
  250. ' </a>';
  251. }
  252. $('#userTab .firstdepto .' + nextContainer).append(html3);
  253. })
  254. if(data.hasOwnProperty('employees')) {
  255. $('#userTab .firstdepto .' + nextContainer).append('<div class="weui_cells weui_cells_checkbox" style="margin-left: 2px;"></div>')
  256. var html = '';
  257. $.each(data.employees, function(k, v){
  258. html += userLabel(v);// 增加一个指定人选中项
  259. });
  260. $('#userTab .firstdepto .' + nextContainer +' .weui_cells_checkbox').append(html);
  261. // 绑定点击列表添加到指定人的事件
  262. $('#userTab .firstdepto .' + nextContainer +' .userLabel input').on('change', function(e){
  263. var em_name = $('.em_name', $(this).parent().parent()).text();// 用户编号
  264. var em_code = $(this).attr('name');// 用户名
  265. checkUserName({em_code: em_code, em_name: em_name});// 改变已选择的人
  266. });
  267. }
  268. Loading.hide();
  269. getRoot(nextContainer);
  270. },
  271. error: function(data){
  272. Loading.hide();// 关闭加载框
  273. dialog('系统错误', '任务添加失败,请联系系统管理员');
  274. }
  275. })
  276. }
  277. //查询顶级目录
  278. Loading.show();
  279. $.ajax({
  280. url: 'mobile/getRootHrorg.action',
  281. type: 'POST',
  282. data: {master: 'UAS'},
  283. success: function(data){
  284. if (!$('#userTab .firstdepto div').hasClass('containerFirst')) {
  285. var htmlFirst = '<div class="containerFirst"></div>';
  286. $('#userTab .firstdepto').append(htmlFirst);
  287. $.each(data.hrorgs, function(k, v){
  288. if(data.hrorgs.length == k+1) {
  289. var html2 = '<a id="' + v.or_code + '" class="weui_cell uas-seft" href="javascript:;" style="margin-bottom: -10px;">' +
  290. '<div class="weui_cell_hd">' +
  291. '<img src="jsps/mobile/img/iconfont_bumen.png" alt="icon"style="width: 20px; margin-right: 5px; display: block">' +
  292. '</div>' +
  293. '<div class="weui_cell_bd weui_cell_primary">' +
  294. '<p>' + v.or_name + '</p></div><div class="weui_cell_ft">'+ v.or_name +
  295. '</div>' +
  296. '</a>';
  297. } else {
  298. var html2 = '<a id="' + v.or_code + '" class="weui_cell uas-seft" href="javascript:;">' +
  299. '<div class="weui_cell_hd">' +
  300. '<img src="jsps/mobile/img/iconfont_bumen.png" alt="icon"style="width: 20px; margin-right: 5px; display: block">' +
  301. '</div>' +
  302. '<div class="weui_cell_bd weui_cell_primary">' +
  303. '<p>' + v.or_name + '</p></div><div class="weui_cell_ft">'+ v.or_name +
  304. '</div>' +
  305. '</a>';
  306. }
  307. $('#userTab .firstdepto .containerFirst').append(html2);
  308. });
  309. if(data.hasOwnProperty('employees')) {
  310. $('#userTab .firstdepto .containerFirst').append('<div class="weui_cells weui_cells_checkbox" style="margin-top: -5px;"></div>')
  311. var html = '';
  312. $.each(data.employees, function(k, v){
  313. html += userLabel(v);// 增加一个指定人选中项
  314. });
  315. $('#userTab .firstdepto .containerFirst .weui_cells_checkbox').append(html);
  316. // 绑定点击列表添加到指定人的事件
  317. $('#userTab .firstdepto .containerFirst .userLabel input').on('change', function(e){
  318. var em_name = $('.em_name', $(this).parent().parent()).text();// 用户编号
  319. var em_code = $(this).attr('name');// 用户名
  320. checkUserName({em_code: em_code, em_name: em_name});// 改变已选择的人
  321. });
  322. }
  323. if(rootData.length == 0) {
  324. rootData.push(data);
  325. }
  326. getRoot('containerFirst');
  327. $('#userTab .uas #firstspan').on('click', function(event) {
  328. if(rootData.length > 0) {
  329. rootData.splice(1,rootData.length);
  330. }
  331. $('#firstspan').addClass('active');
  332. $('.containerFirst').css('display', 'block');
  333. $('.containerFirst').siblings('div').remove();
  334. while($(this).next('span') && $(this).next('span').length != 0){
  335. $(this).next('span').remove();
  336. }
  337. event.stopPropagation(); // 阻止事件冒泡
  338. });
  339. Loading.hide();// 关闭加载框
  340. }else {
  341. Loading.hide();// 关闭加载框
  342. }
  343. },
  344. error: function(data){
  345. Loading.hide();// 关闭加载框
  346. dialog('系统错误', '任务添加失败,请联系系统管理员');
  347. }
  348. })
  349. };
  350. // 关闭指定人的页面
  351. function closeUserTab() {
  352. $('#userTab').removeClass('open');
  353. };
  354. $('.openUserTab').on('click', openUserTab);
  355. $('.closeUserTab').on('click', closeUserTab);
  356. // 将用户转化为指定人选中Lebel
  357. function userLabel(em) {
  358. var em_position = em.em_position ? '[' + em.em_position + ']': '';
  359. var em_name = em.em_name;
  360. var em_code = em.em_code;
  361. var em_checked = checked(em);// 是否已经选择了
  362. var html = '<label class="weui_cell weui_check_label userLabel" for="' + em_code + '">' +
  363. '<div class="weui_cell_bd weui_cell_primary">' +
  364. '<p>' +
  365. '<i class="fa fa-user"></i> <span class="em_name">' + em_name + '</span> ' + em_position +
  366. '</p>' +
  367. '</div>' +
  368. '<div class="weui_cell_ft">' +
  369. '<input type="checkbox" class="weui_check" name="' + em_code + '" id="' + em_code + '" ' + (em_checked != -1 ? 'checked="checked"': '') +'>' +
  370. '<i class="weui_icon_checked"></i>' +
  371. '</div>' +
  372. '</label>';
  373. return html;
  374. };
  375. // 将已选择的人转化为展示的按钮
  376. function addUserButtonName(em) {
  377. var html = '<button class="weui_btn weui_btn_mini weui_btn_warn" title="' + em.em_code + '">' + em.em_name + ' <i class="fa fa-close"></i></button> ';
  378. $('.checkedUsers .weui_cell_bd').append(html);
  379. // 绑定点击按钮删除的事件
  380. $('button[title="' + em.em_code + '"]').on('click', function(){
  381. var inputs = $('.firstdepto input[name="' + $(this).attr('title') + '"]');
  382. if(inputs.length > 0) {
  383. inputs.trigger('click');
  384. } else {
  385. checkUserName({em_code: em.em_code, em_name: em.em_name});// 改变已选择的人
  386. }
  387. });
  388. };
  389. // 点击一个用户选择,添加或删除指定人
  390. function checkUserName(em){
  391. var i = checked(em);
  392. if(i != -1) {// 已选择的,去掉
  393. checkedUsers.splice(i, 1);
  394. $('.checkedUsers .weui_cell_bd button[title="' + em.em_code + '"]').remove()
  395. } else {// 未选择的,添加
  396. checkedUsers.push(em);
  397. addUserButtonName(em);
  398. }
  399. $('.checkedSize').text(checkedUsers.length);
  400. };
  401. // 将已选择的人转化为展示的按钮
  402. function addUserButton(em) {
  403. var html = '<button class="weui_btn weui_btn_mini weui_btn_warn" title="' + em.em_code + '">' + em.em_name + ' <i class="fa fa-close"></i></button> ';
  404. $('.checkedUsers .weui_cell_bd').append(html);
  405. // 绑定点击按钮删除的事件
  406. $('button[title="' + em.em_code + '"]').on('click', function(){
  407. $('#searchResult input[name="' + $(this).attr('title') + '"]').trigger('click');
  408. });
  409. };
  410. // 点击一个用户选择,添加或删除指定人
  411. function checkUser(em){
  412. var i = checked(em);
  413. if(i != -1) {// 已选择的,去掉
  414. checkedUsers.splice(i, 1);
  415. $('.checkedUsers .weui_cell_bd button[title="' + em.em_code + '"]').remove()
  416. } else {// 未选择的,添加
  417. checkedUsers.push(em);
  418. addUserButton(em);
  419. }
  420. $('.checkedSize').text(checkedUsers.length);
  421. };
  422. // 根据关键词查询用户结果
  423. function showDefault(resourcename) {
  424. var keyword = resourcename;
  425. try {
  426. $.ajax({
  427. url: 'hr/employee/getEmployees.action',
  428. type: 'POST',
  429. data: {condition: "em_name like '%" + keyword + "%' and nvl(em_class,' ')<>'离职'"},
  430. success: function(data, status) {
  431. if(data.success) {
  432. var html = '';
  433. $.each(data.employees, function(k, v){
  434. html += userLabel(v);// 增加一个指定人选中项
  435. });
  436. $('#searchResult .weui_cells_checkbox').html(html);
  437. $('#searchResult .weui_cells_title').text('共找到' + data.employees.length + '个可选的指定人');
  438. checkUser({em_code: data.employees[0].em_code, em_name: data.employees[0].em_name});
  439. $('.userLabel input').attr('checked', 'checked');
  440. // 绑定点击列表添加到指定人的事件
  441. $('.userLabel input').on('change', function(e){
  442. var em_name = $('.em_name', $(this).parent().parent()).text();// 用户编号
  443. var em_code = $(this).attr('name');// 用户名
  444. checkUser({em_code: em_code, em_name: em_name});// 改变已选择的人
  445. });
  446. }
  447. Loading.hide();
  448. },
  449. error: function(xhr) {
  450. Loading.hide();
  451. if(xhr.response) {
  452. var response = $.parseJSON(xhr.response);
  453. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  454. dialog('提示', '您还未登录,请先登录');
  455. } else {
  456. dialog('错误', response.exceptionInfo);
  457. }
  458. }
  459. }
  460. });
  461. } catch(error) {
  462. Loading.hide();
  463. document.write(error.name + ' | ' + error.message);
  464. }
  465. };
  466. // 根据关键词查询用户结果
  467. function search() {
  468. var keyword = $('#search_input').val();
  469. if(!keyword) {// 没有输入关键词
  470. dialog('提示', '未指定关键词,点击确定重新加载界面');
  471. $('#searchResult .weui_cells_checkbox>label').remove();
  472. return;
  473. }
  474. Loading.show();
  475. try {
  476. $.ajax({
  477. url: 'hr/employee/getEmployees.action',
  478. type: 'POST',
  479. data: {condition: "em_name like '%" + keyword + "%' and nvl(em_class,' ')<>'离职'"},
  480. success: function(data, status) {
  481. if(data.success) {
  482. var html = '';
  483. $.each(data.employees, function(k, v){
  484. html += userLabel(v);// 增加一个指定人选中项
  485. });
  486. $('#searchResult .weui_cells_checkbox').html(html);
  487. $('#searchResult .weui_cells_title').text('共找到' + data.employees.length + '个可选的指定人');
  488. // 绑定点击列表添加到指定人的事件
  489. $('.userLabel input').on('change', function(e){
  490. var em_name = $('.em_name', $(this).parent().parent()).text();// 用户编号
  491. var em_code = $(this).attr('name');// 用户名
  492. checkUser({em_code: em_code, em_name: em_name});// 改变已选择的人
  493. });
  494. }
  495. Loading.hide();
  496. },
  497. error: function(xhr) {
  498. Loading.hide();
  499. if(xhr.response) {
  500. var response = $.parseJSON(xhr.response);
  501. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  502. dialog('提示', '您还未登录,请先登录');
  503. } else {
  504. dialog('错误', response.exceptionInfo);
  505. }
  506. }
  507. }
  508. });
  509. } catch(error) {
  510. Loading.hide();
  511. document.write(error.name + ' | ' + error.message);
  512. }
  513. };
  514. // 成功提示
  515. function showSuccess(form) {
  516. $('#successPage .msg_title').text(form.name);
  517. $('#successPage .msg_startdate').text(form.startdate);
  518. $('#successPage .msg_continuetime').text(form.duration);
  519. $('#successPage .msg_resourcename').text(form.resourcename);
  520. if(form.type) {
  521. $('#successPage .msg_type').text('需要');
  522. } else {
  523. $('#successPage .msg_type').text('不需要');
  524. }
  525. $('#successPage').css('display', 'block');
  526. }
  527. // 搜索框图标点击事件
  528. $('#search_icon').on('click' , search);
  529. //给开始时间默认值
  530. if($('input[name="startdate"]').val() == "") {
  531. $('input[name="startdate"]').val(new Date().Format("yyyy-MM-ddThh:mm"));
  532. }
  533. // 确定按钮事件
  534. $('#commit').on('click', function(){
  535. var form = {
  536. name: $('input[name="name"]').val(),
  537. duration: $('input[name="continuetime"]').val(),
  538. startdate: $('input[name="startdate"]').val().replace('T', ' ').substring(0, 16) + ':00',
  539. description: $('textarea[name="description"]').val()
  540. };
  541. // 是否需要回复
  542. if($('input[name="type"]').attr('checked')) {
  543. form.type = 1;
  544. } else {
  545. form.type = 0;
  546. }
  547. // 处理人
  548. form.resourcename = '';
  549. $.each(checkedUsers, function(k, v){
  550. if(form.resourcename) form.resourcename += ',';
  551. form.resourcename += v.em_name;
  552. });
  553. if(!form.name) {
  554. dialog('提示', '任务名称未输入');
  555. return;
  556. }
  557. if(form.startdate.length != 19) {
  558. dialog('提示', '开始日期未输入');
  559. return;
  560. }
  561. if(!form.resourcename) {
  562. dialog('提示', '您还未指定任务处理人');
  563. return;
  564. }
  565. if(!form.description) {
  566. dialog('提示', '任务描述未输入');
  567. return;
  568. }
  569. Loading.show();// 显示加载框
  570. // 提交请求
  571. $.ajax({
  572. url: 'plm/task/addbilltask.action',
  573. type: 'POST',
  574. data: {formStore: JSON.stringify(form)},
  575. success: function(data){
  576. Loading.hide();// 关闭加载框
  577. showSuccess(form);
  578. },
  579. error: function(data){
  580. Loading.hide();// 关闭加载框
  581. dialog('系统错误', '任务添加失败,请联系系统管理员');
  582. }
  583. });
  584. });
  585. });