task.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. task_parameter = {
  2. first : '(0)',
  3. last : '(0)',
  4. count : 20
  5. };
  6. function task_list_init() {
  7. var str = '<table border="1" width="100%">';
  8. str += '<thead><tr><td colspan="6"><a href="#" id="prev">prev</a>&nbsp;<a href="#" id="next">next</a>&nbsp;<span id="total">0</span></td></tr>';
  9. str += '<tr><th>rank</th><th>id</th><th>title</th><th>processName</th></tr></thead>';
  10. str += '<tbody id="grid"></tbody>'
  11. str += '</table>';
  12. $('#content').html(str);
  13. $('#next').click(function() {
  14. task_list_next();
  15. });
  16. $('#prev').click(function() {
  17. task_list_prev();
  18. });
  19. task_parameter.first = '(0)';
  20. task_parameter.last = '(0)';
  21. task_list_next();
  22. }
  23. function task_list_next(id) {
  24. var id = (id ? id : task_parameter.last);
  25. $.ajax({
  26. type : 'get',
  27. dataType : 'json',
  28. url : '../jaxrs/task/list/' + id + '/next/' + task_parameter.count,
  29. xhrFields : {
  30. 'withCredentials' : true
  31. },
  32. crossDomain : true
  33. }).done(function(json) {
  34. if (json.type == 'success') {
  35. if (json.data.length > 0) {
  36. task_parameter.first = json.data[0].id;
  37. task_parameter.last = json.data[json.data.length - 1].id;
  38. } else {
  39. task_parameter.first = '(0)';
  40. }
  41. task_list_grid(json);
  42. }
  43. }).always(function(json) {
  44. $('#result').html(JSON.stringify(json, null, 4));
  45. });
  46. }
  47. function task_list_prev(id) {
  48. var id = (id ? id : task_parameter.first);
  49. $.ajax({
  50. type : 'get',
  51. dataType : 'json',
  52. url : '../jaxrs/task/list/' + id + '/prev/' + task_parameter.count,
  53. xhrFields : {
  54. 'withCredentials' : true
  55. },
  56. crossDomain : true
  57. }).done(function(json) {
  58. if (json.type == 'success') {
  59. if (json.data.length > 0) {
  60. task_parameter.first = json.data[0].id;
  61. task_parameter.last = json.data[json.data.length - 1].id;
  62. } else {
  63. task_parameter.last = '(0)';
  64. }
  65. task_list_grid(json);
  66. }
  67. }).always(function(json) {
  68. $('#result').html(JSON.stringify(json, null, 4));
  69. });
  70. }
  71. function task_listWithApplication_init() {
  72. var str = '<table border="1" width="100%">';
  73. str += '<thead><tr><td colspan="4"><a href="#" id="prev">prev</a>&nbsp;<a href="#" id="next">next</a>&nbsp;<span id="total">0</span></td></tr>';
  74. str += '<tr><th>applicationFlag</th><th colspan="3"><input type="text" id="applicationFlag" style="width:95%"/></th></tr>';
  75. str += '<tr><th>rank</th><th>id</th><th>title</th><th>processName</th></tr></thead>';
  76. str += '<tbody id="grid"></tbody>'
  77. str += '</table>';
  78. $('#content').html(str);
  79. $('#next').click(function() {
  80. task_listWithApplication_next();
  81. });
  82. $('#prev').click(function() {
  83. task_listWithApplication_prev();
  84. });
  85. task_parameter.first = '(0)';
  86. task_parameter.last = '(0)';
  87. }
  88. function task_listWithApplication_next(id) {
  89. var id = (id ? id : task_parameter.last);
  90. $.ajax({
  91. type : 'get',
  92. dataType : 'json',
  93. url : '../jaxrs/task/list/' + task_parameter.last + '/next/' + task_parameter.count + '/application/' + $('#applicationFlag').val(),
  94. xhrFields : {
  95. 'withCredentials' : true
  96. },
  97. crossDomain : true
  98. }).done(function(json) {
  99. if (json.type == 'success') {
  100. if (json.data.length > 0) {
  101. task_parameter.first = json.data[0].id;
  102. task_parameter.last = json.data[json.data.length - 1].id;
  103. } else {
  104. task_parameter.first = '(0)';
  105. }
  106. task_list_grid(json);
  107. }
  108. }).always(function(json) {
  109. $('#result').html(JSON.stringify(json, null, 4));
  110. });
  111. }
  112. function task_listWithApplication_prev(id) {
  113. var id = (id ? id : task_parameter.first);
  114. $.ajax({
  115. type : 'get',
  116. dataType : 'json',
  117. url : '../jaxrs/task/list/' + id + '/prev/' + task_parameter.count + '/application/' + $('#applicationFlag').val(),
  118. xhrFields : {
  119. 'withCredentials' : true
  120. },
  121. crossDomain : true
  122. }).done(function(json) {
  123. if (json.type == 'success') {
  124. if (json.data.length > 0) {
  125. task_parameter.first = json.data[0].id;
  126. task_parameter.last = json.data[json.data.length - 1].id;
  127. } else {
  128. task_parameter.last = '(0)';
  129. }
  130. task_list_grid(json);
  131. }
  132. }).always(function(json) {
  133. $('#result').html(JSON.stringify(json, null, 4));
  134. });
  135. }
  136. function task_listWithProcess_init() {
  137. var str = '<table border="1" width="100%">';
  138. str += '<thead><tr><td colspan="4"><a href="#" id="prev">prev</a>&nbsp;<a href="#" id="next">next</a>&nbsp;<span id="total">0</span></td></tr>';
  139. str += '<tr><th>processFlag</th><th colspan="3"><input type="text" id="processFlag" style="width:95%"/></th></tr>';
  140. str += '<tr><th>rank</th><th>id</th><th>title</th><th>processName</th></tr></thead>';
  141. str += '<tbody id="grid"></tbody>'
  142. str += '</table>';
  143. $('#content').html(str);
  144. $('#next').click(function() {
  145. task_listWithProcess_next();
  146. });
  147. $('#prev').click(function() {
  148. task_listWithProcess_prev();
  149. });
  150. task_parameter.first = '(0)';
  151. task_parameter.last = '(0)';
  152. }
  153. function task_listWithProcess_next(id) {
  154. var id = (id ? id : task_parameter.last);
  155. $.ajax({
  156. type : 'get',
  157. dataType : 'json',
  158. url : '../jaxrs/task/list/' + id + '/next/' + task_parameter.count + '/process/' + $('#processFlag').val(),
  159. xhrFields : {
  160. 'withCredentials' : true
  161. },
  162. crossDomain : true
  163. }).done(function(json) {
  164. if (json.type == 'success') {
  165. if (json.data.length > 0) {
  166. task_parameter.first = json.data[0].id;
  167. task_parameter.last = json.data[json.data.length - 1].id;
  168. } else {
  169. task_parameter.first = '(0)';
  170. }
  171. task_list_grid(json);
  172. }
  173. }).always(function(json) {
  174. $('#result').html(JSON.stringify(json, null, 4));
  175. });
  176. }
  177. function task_listWithProcess_prev(id) {
  178. var id = (id ? id : task_parameter.first);
  179. $.ajax({
  180. type : 'get',
  181. dataType : 'json',
  182. url : '../jaxrs/task/list/' + id + '/prev/' + task_parameter.count + '/process/' + $('#processFlag').val(),
  183. xhrFields : {
  184. 'withCredentials' : true
  185. },
  186. crossDomain : true
  187. }).done(function(json) {
  188. if (json.type == 'success') {
  189. if (json.data.length > 0) {
  190. task_parameter.first = json.data[0].id;
  191. task_parameter.last = json.data[json.data.length - 1].id;
  192. } else {
  193. task_parameter.last = '(0)';
  194. }
  195. task_list_grid(json);
  196. }
  197. }).always(function(json) {
  198. $('#result').html(JSON.stringify(json, null, 4));
  199. });
  200. }
  201. function task_list_grid(json) {
  202. if (json.data && json.data.length > 0) {
  203. str = '';
  204. $.each(json.data, function(index, item) {
  205. str += '<tr>';
  206. str += '<td>' + item.rank + '</td>';
  207. str += '<td>' + item.id + '</td>';
  208. str += '<td>' + item.title + '</td>';
  209. str += '<td>' + item.processName + '</td>';
  210. str += '</tr>';
  211. });
  212. $('#total').html(json.count);
  213. $('#grid').html(str);
  214. } else {
  215. $('#total').html('0');
  216. $('#grid').html('');
  217. }
  218. }
  219. function task_listCountWithApplication() {
  220. $('#result').html('');
  221. $.ajax({
  222. type : 'get',
  223. dataType : 'json',
  224. url : '../jaxrs/task/list/count/application',
  225. xhrFields : {
  226. 'withCredentials' : true
  227. },
  228. crossDomain : true
  229. }).always(function(json) {
  230. $('#result').html(JSON.stringify(json, null, 4));
  231. });
  232. }
  233. function task_listCountWithProcess_init() {
  234. $('#result').html('');
  235. str = '<table border="1" width="100%">';
  236. str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
  237. str += '<tr><td>applicationFlag:</td><td><input type="text" id="applicationFlag" style="width:95%"/></td></tr>';
  238. str += '</table>';
  239. $('#content').html(str);
  240. $('#get').click(function() {
  241. task_listCountWithProcess($('#applicationFlag').val());
  242. });
  243. }
  244. function task_listCountWithProcess(applicationFlag) {
  245. $('#result').html('');
  246. $.ajax({
  247. type : 'get',
  248. dataType : 'json',
  249. url : '../jaxrs/task/list/count/application/' + applicationFlag + '/process',
  250. xhrFields : {
  251. 'withCredentials' : true
  252. },
  253. crossDomain : true
  254. }).always(function(json) {
  255. $('#result').html(JSON.stringify(json, null, 4));
  256. });
  257. }
  258. function task_countWithPerson_init() {
  259. $('#result').html('');
  260. str = '<table border="1" width="100%">';
  261. str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
  262. str += '<tr><td>person:</td><td><input type="text" id="person" style="width:95%"/></td></tr>';
  263. str += '</table>';
  264. $('#content').html(str);
  265. $('#get').click(function() {
  266. task_countWithPerson($('#person').val());
  267. });
  268. }
  269. function task_countWithPerson(person) {
  270. $('#result').html('');
  271. $.ajax({
  272. type : 'get',
  273. dataType : 'json',
  274. url : '../jaxrs/task/count/' + person,
  275. xhrFields : {
  276. 'withCredentials' : true
  277. },
  278. crossDomain : true
  279. }).always(function(json) {
  280. $('#result').html(JSON.stringify(json, null, 4));
  281. });
  282. }
  283. function task_get_init() {
  284. $('#result').html('');
  285. str = '<table border="1" width="100%">';
  286. str += '<tr><td colspan="2"><a href="#" id="get">get</a>&nbsp;<a href="#" id="reference">reference</a>&nbsp;<a href="#" id="process">process</a>&nbsp;<a href="#" id="update">update</a>&nbsp;<a href="#" id="reset">reset</a></td></tr>';
  287. str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
  288. str += '<tr><td>routeName:</td><td><input type="text" id="routeName" style="width:95%"/></td></tr>';
  289. str += '<tr><td>opinion:</td><td><input type="text" id="opinion" style="width:95%"/></td></tr>';
  290. str += '<tr><td>identityList:</td><td><textarea id="identityList" style="width:95%"/></td></tr>';
  291. str += '</table>';
  292. $('#content').html(str);
  293. $('#get').click(function() {
  294. task_get($('#id').val());
  295. });
  296. $('#reference').click(function() {
  297. task_reference($('#id').val());
  298. });
  299. $('#process').click(function() {
  300. task_process($('#id').val());
  301. });
  302. $('#update').click(function() {
  303. task_update($('#id').val());
  304. });
  305. $('#reset').click(function() {
  306. task_reset($('#id').val());
  307. });
  308. }
  309. function task_get(id) {
  310. $('#result').html('');
  311. $.ajax({
  312. type : 'get',
  313. dataType : 'json',
  314. url : '../jaxrs/task/' + id,
  315. xhrFields : {
  316. 'withCredentials' : true
  317. },
  318. crossDomain : true
  319. }).done(function(json) {
  320. if (json.type == 'success') {
  321. $('#routeName').val(json.data.routeName);
  322. $('#opinion').val(json.data.opinion);
  323. }
  324. }).always(function(json) {
  325. $('#result').html(JSON.stringify(json, null, 4));
  326. });
  327. }
  328. function task_update(id) {
  329. $.ajax({
  330. type : 'put',
  331. dataType : 'json',
  332. contentType : 'application/json; charset=utf-8',
  333. url : '../jaxrs/task/' + id,
  334. xhrFields : {
  335. 'withCredentials' : true
  336. },
  337. data : JSON.stringify({
  338. routeName : $('#routeName').val(),
  339. opinion : $('#opinion').val()
  340. }),
  341. crossDomain : true
  342. }).always(function(json) {
  343. $('#result').html(JSON.stringify(json, null, 4));
  344. });
  345. }
  346. function task_reference(id) {
  347. $('#result').html('');
  348. $.ajax({
  349. type : 'get',
  350. dataType : 'json',
  351. url : '../jaxrs/task/' + id + '/reference',
  352. xhrFields : {
  353. 'withCredentials' : true
  354. },
  355. crossDomain : true
  356. }).always(function(json) {
  357. $('#result').html(JSON.stringify(json, null, 4));
  358. });
  359. }
  360. function task_process(id) {
  361. $.ajax({
  362. type : 'post',
  363. dataType : 'json',
  364. contentType : 'application/json; charset=utf-8',
  365. url : '../jaxrs/task/' + id,
  366. xhrFields : {
  367. 'withCredentials' : true
  368. },
  369. data : JSON.stringify({
  370. routeName : $('#routeName').val(),
  371. opinion : $('#opinion').val()
  372. }),
  373. crossDomain : true
  374. }).always(function(json) {
  375. $('#result').html(JSON.stringify(json, null, 4));
  376. });
  377. }
  378. function task_reset(id) {
  379. $.ajax({
  380. type : 'put',
  381. dataType : 'json',
  382. contentType : 'application/json; charset=utf-8',
  383. url : '../jaxrs/task/' + id + '/reset',
  384. xhrFields : {
  385. 'withCredentials' : true
  386. },
  387. data : JSON.stringify({
  388. routeName : $('#routeName').val(),
  389. opinion : $('#opinion').val(),
  390. identityList : splitValue($('#identityList').val())
  391. }),
  392. crossDomain : true
  393. }).always(function(json) {
  394. $('#result').html(JSON.stringify(json, null, 4));
  395. });
  396. }
  397. function task_listFilter_init() {
  398. $('#result').html('');
  399. var str = '<table border="1" width="100%">';
  400. str += '<thead><tr><td colspan="4"><a href="#" id="prev">prev</a>&nbsp;<a href="#" id="next">next</a>&nbsp;<a href="#" id="clear">clear</a>&nbsp;<span id="total">0</span></td></tr>';
  401. str += '<tr><td>application</td><td colspan="3"><select id="applicationFilter"></select></td></tr>';
  402. str += '<tr><td>process</td><td colspan="3"><select id="processFilter"></select></td></tr>';
  403. str += '<tr><td>creatorCompany</td><td colspan="3"><select id="creatorCompanyFilter"></select></td></tr>';
  404. str += '<tr><td>creatorDepartment</td><td colspan="3"><select id="creatorDepartmentFilter"></select></td></tr>';
  405. str += '<tr><td>startTimeMonth</td><td colspan="3"><select id="startTimeMonthFilter"></select></td></tr>';
  406. str += '<tr><td>activityName</td><td colspan="3"><select id="activityNameFilter"></select></td></tr>';
  407. str += '<tr><td>key</td><td colspan="3"><input type="text" id="keyFilter" style="width:95%"/></td></tr>';
  408. str += '<tr><th>rank</th><th>id</th><th>title</th><th>processName</th></tr></thead>';
  409. str += '<tbody id="grid"></tbody>';
  410. str += '</table>';
  411. $('#content').html(str);
  412. $('#next').click(function() {
  413. task_listFilter_next();
  414. });
  415. $('#prev').click(function() {
  416. task_listFilter_prev();
  417. });
  418. $('#clear').click(function() {
  419. task_parameter.first = '(0)';
  420. task_parameter.last = '(0)';
  421. });
  422. task_parameter.first = '(0)';
  423. task_parameter.last = '(0)';
  424. $.ajax({
  425. type : 'get',
  426. dataType : 'json',
  427. contentType : 'application/json; charset=utf-8',
  428. url : '../jaxrs/task/filter/attribute',
  429. xhrFields : {
  430. 'withCredentials' : true
  431. },
  432. crossDomain : true
  433. }).done(function(json) {
  434. if (json.type == 'success') {
  435. txt = '<option value="">all</option>';
  436. if (json.data.applicationList) {
  437. $.each(json.data.applicationList, function(index, item) {
  438. txt += '<option value="' + item.value + '">' + item.name + '</option>';
  439. });
  440. }
  441. $('#applicationFilter').html(txt);
  442. txt = '<option value="">all</option>';
  443. if (json.data.processList) {
  444. $.each(json.data.processList, function(index, item) {
  445. txt += '<option value="' + item.value + '">' + item.name + '</option>';
  446. });
  447. }
  448. $('#processFilter').html(txt);
  449. txt = '<option value="">all</option>';
  450. if (json.data.creatorCompanyList) {
  451. $.each(json.data.creatorCompanyList, function(index, item) {
  452. txt += '<option value="' + item.value + '">' + item.name + '</option>';
  453. });
  454. }
  455. $('#creatorCompanyFilter').html(txt);
  456. txt = '<option value="">all</option>';
  457. if (json.data.creatorDepartmentList) {
  458. $.each(json.data.creatorDepartmentList, function(index, item) {
  459. txt += '<option value="' + item.value + '">' + item.name + '</option>';
  460. });
  461. }
  462. $('#creatorDepartmentFilter').html(txt);
  463. txt = '<option value="">all</option>';
  464. if (json.data.startTimeMonthList) {
  465. $.each(json.data.startTimeMonthList, function(index, item) {
  466. txt += '<option value="' + item.value + '">' + item.name + '</option>';
  467. });
  468. }
  469. $('#startTimeMonthFilter').html(txt);
  470. txt = '<option value="">all</option>';
  471. if (json.data.startTimeMonthList) {
  472. $.each(json.data.startTimeMonthList, function(index, item) {
  473. txt += '<option value="' + item.value + '">' + item.name + '</option>';
  474. });
  475. }
  476. $('#startTimeMonthFilter').html(txt);
  477. txt = '<option value="">all</option>';
  478. if (json.data.activityNameList) {
  479. $.each(json.data.activityNameList, function(index, item) {
  480. txt += '<option value="' + item.value + '">' + item.name + '</option>';
  481. });
  482. }
  483. $('#activityNameFilter').html(txt);
  484. }
  485. }).always(function(json) {
  486. $('#result').html(JSON.stringify(json, null, 4));
  487. });
  488. }
  489. function task_listFilter_next(id) {
  490. var id = (id ? id : task_parameter.last);
  491. $.ajax({
  492. type : 'post',
  493. dataType : 'json',
  494. contentType : 'application/json; charset=utf-8',
  495. url : '../jaxrs/task/list/' + id + '/next/' + task_parameter.count + '/filter',
  496. xhrFields : {
  497. 'withCredentials' : true
  498. },
  499. data : JSON.stringify({
  500. application : $('#applicationFilter').val(),
  501. process : $('#processFilter').val(),
  502. creatorCompany : $('#creatorCompanyFilter').val(),
  503. creatorDepartment : $('#creatorDepartmentFilter').val(),
  504. startTimeMonth : $('#startTimeMonthFilter').val(),
  505. activityName : $('#activityNameFilter').val(),
  506. key : $('#keyFilter').val()
  507. }),
  508. crossDomain : true
  509. }).done(function(json) {
  510. if (json.type == 'success') {
  511. if (json.data.length > 0) {
  512. task_parameter.first = json.data[0].id;
  513. task_parameter.last = json.data[json.data.length - 1].id;
  514. } else {
  515. task_parameter.first = '(0)';
  516. }
  517. task_list_grid(json);
  518. }
  519. }).always(function(json) {
  520. $('#result').html(JSON.stringify(json, null, 4));
  521. });
  522. }
  523. function task_listFilter_prev(id) {
  524. var id = (id ? id : task_parameter.first);
  525. $.ajax({
  526. type : 'post',
  527. dataType : 'json',
  528. contentType : 'application/json; charset=utf-8',
  529. url : '../jaxrs/task/list/' + id + '/prev/' + task_parameter.count + '/filter',
  530. xhrFields : {
  531. 'withCredentials' : true
  532. },
  533. data : JSON.stringify({
  534. application : $('#applicationFilter').val(),
  535. process : $('#processFilter').val(),
  536. creatorCompany : $('#creatorCompanyFilter').val(),
  537. creatorDepartment : $('#creatorDepartmentFilter').val(),
  538. startTimeMonth : $('#startTimeMonthFilter').val(),
  539. activityName : $('#activityNameFilter').val(),
  540. key : $('#keyFilter').val()
  541. }),
  542. crossDomain : true
  543. }).done(function(json) {
  544. if (json.type == 'success') {
  545. if (json.data.length > 0) {
  546. task_parameter.first = json.data[0].id;
  547. task_parameter.last = json.data[json.data.length - 1].id;
  548. } else {
  549. task_parameter.last = '(0)';
  550. }
  551. task_list_grid(json);
  552. }
  553. }).always(function(json) {
  554. $('#result').html(JSON.stringify(json, null, 4));
  555. });
  556. }