bills_lib_ajax.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. /**
  2. * Created by vian on 2017/3/27.
  3. */
  4. var mainAjax = {
  5. getMaxNumber: function(billsLibId, field, callback){
  6. $.ajax({
  7. type: 'post',
  8. url: 'stdBillsEditor/getMaxNumber',
  9. data: {data: JSON.stringify({billsLibId: billsLibId, field: field})},
  10. dataType: 'json',
  11. success: function(result){
  12. if(!result.error){
  13. if(callback){
  14. callback(result.data);
  15. }
  16. }
  17. }
  18. });
  19. },
  20. getABillsLib: function(billsLibId, callback){
  21. $.ajax({
  22. type: 'post',
  23. url: '/stdBillsEditor/getABillsLib',
  24. data: {data: JSON.stringify({billsLibId: billsLibId})},
  25. dataType: 'json',
  26. success: function(result){
  27. if(!result.error){
  28. if(callback){
  29. callback(result.data);
  30. }
  31. }
  32. }
  33. });
  34. },
  35. getStdBillsLib: function(userId){
  36. $.ajax({
  37. type: "post",
  38. url: "/stdBillsEditor/getStdBillsLib",
  39. data: {data: JSON.stringify({userId: userId})},
  40. dataType: "json",
  41. success: function(result){
  42. if(result.data){
  43. for(var i=0; i<result.data.length; i++){
  44. var id = result.data[i].billsLibId;
  45. var billsLibName = result.data[i].billsLibName;
  46. var createDate = result.data[i].createDate;
  47. var createDateFmt = new Date(createDate).format("yyyy-MM-dd");
  48. $("#showArea").append(
  49. "<tr id='tempId'>" +
  50. "<td><a href='stdBills'>"+billsLibName+"</a></td>" +
  51. "<td>"+createDateFmt+" </td>" +
  52. "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
  53. "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
  54. "<i class='fa fa-remove'></i></a></td></tr>");
  55. var newHref = "stdBills?billsLibId="+id;
  56. $("#tempId td:first a").attr("href", newHref);
  57. $("#tempId").attr("id", id);
  58. }
  59. }
  60. }
  61. });
  62. },
  63. createStdBillsLib: function(userId, billsLibName){
  64. $.ajax({
  65. type: "POST",
  66. url: "/stdBillsEditor/createStdBillsLib",
  67. data: {data: JSON.stringify({userId: userId, name: billsLibName}) },
  68. dataType: "json",
  69. success: function(result){
  70. if(!result.error){
  71. var id = result.data[0].billsLibId;
  72. var createDate = result.data[0].createDate;
  73. var createDateFmt = new Date(createDate).format("yyyy-MM-dd");
  74. $("#showArea").append(
  75. "<tr id='tempId'><td><a href='stdBills'>"+billsLibName+"</a></td><td>"+createDateFmt+" </td><td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
  76. "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
  77. "<i class='fa fa-remove'></i></a></td></tr>"
  78. );
  79. var newHref = "stdBills?billsLibId="+id;
  80. $("#tempId td:first a").attr("href", newHref);
  81. $("#tempId").attr("id", id);
  82. }
  83. }
  84. });
  85. },
  86. deleteStdBillsLib: function(billsLibId){
  87. $.ajax({
  88. type: "POST",
  89. url: "/stdBillsEditor/deleteStdBillsLib",
  90. data: {data: JSON.stringify({billsLibId: billsLibId})},
  91. dataType: "json",
  92. success: function(result){
  93. if(!result.error){
  94. var jqSel = "#"+billsLibId;
  95. $(jqSel).remove();
  96. }
  97. }
  98. });
  99. },
  100. renameStdBillsLib: function(billsLibId, newName){
  101. $.ajax({
  102. type: "post",
  103. url: "/stdBillsEditor/renameStdbillsLib",
  104. data: {data: JSON.stringify({id: billsLibId, value: newName})},
  105. dataType: "json",
  106. success: function(result){
  107. if(!result.error){
  108. var jqSel = "#" + billsLibId + " td:first" + " a";
  109. $(jqSel).text(newName);
  110. }
  111. }
  112. });
  113. },
  114. getCurrentUniqId: function (callback) {
  115. $.ajax({
  116. type: 'post',
  117. url: 'stdBillsEditor/getCurrentUniqId',
  118. dataType: 'json',
  119. success: function(result){
  120. if(!result.error && callback){
  121. callback(result.data);
  122. }
  123. }
  124. });
  125. }
  126. }
  127. var billsAjax = {
  128. getStdBillsLibName: function(billsLibId) {
  129. $.ajax({
  130. type: "post",
  131. url: "/stdBillsEditor/getStdBillsLibName",
  132. data: {data: JSON.stringify({billsLibId: billsLibId})},
  133. success: function(result){
  134. if(!result.error){
  135. $(".navbar-text").append(
  136. "<a href='stdBillsmain'>清单规则</a><i class='fa fa-angle-right fa-fw'></i>"+result.data[0].billsLibName
  137. );
  138. }
  139. }
  140. });
  141. },
  142. getBills: function(billsLibId, callback){
  143. $.ajax({
  144. type: "post",
  145. url: "/stdBillsEditor/getBills",
  146. data: {data: JSON.stringify({billsLibId: billsLibId})},
  147. dataType: "json",
  148. success: function(result){
  149. if(!result.error){
  150. if(callback) {
  151. callback(result.data);
  152. }
  153. }
  154. }
  155. });
  156. },
  157. createBills: function(billsLibId, newId, pid, nid, updatePreData, callback){
  158. $.ajax({
  159. type: 'post',
  160. url: 'stdBillsEditor/createBills',
  161. data: {data: JSON.stringify({billsLibId: billsLibId, newId: newId, ParentID: pid, NextSiblingID: nid, updatePreData: updatePreData})},
  162. dataType: 'json',
  163. success: function(result){
  164. if(!result.error){
  165. if(callback){
  166. callback();
  167. }
  168. }
  169. }
  170. });
  171. },
  172. upMove: function(billsLibId, updateDatas, callback){
  173. $.ajax({
  174. type: 'post',
  175. url: 'stdBillsEditor/upMove',
  176. data: {data: JSON.stringify({billsLibId: billsLibId, updateDatas: updateDatas})},
  177. dataType: 'json',
  178. success: function(result){
  179. if(!result.error && callback){
  180. callback();
  181. }
  182. }
  183. });
  184. },
  185. updatePNId: function(billsLibId, updateData, callback){
  186. $.ajax({
  187. type: 'post',
  188. url: 'stdBillsEditor/updatePNId',
  189. data: {data: JSON.stringify({billsLibId: billsLibId, updateData: updateData})},
  190. dataType: 'json',
  191. success: function(result){
  192. if(!result.error && callback){
  193. callback();
  194. }
  195. else {
  196. //提示窗口:更新失败
  197. }
  198. }
  199. });
  200. },
  201. deleteBills: function(billsLibId, deleteIds, updateNode, callback){
  202. $.ajax({
  203. type: 'post',
  204. url: 'stdBillsEditor/deleteBills',
  205. data: {data: JSON.stringify({billsLibId: billsLibId, deleteIds: deleteIds, updateNode: updateNode})},
  206. dataType: 'json',
  207. success: function(result){
  208. if(!result.error){
  209. console.log(result.message);
  210. if(callback){
  211. callback();
  212. }
  213. }
  214. }
  215. });
  216. },
  217. updateBills: function(billsLibId, updateId, field, data){
  218. $.ajax({
  219. type: 'post',
  220. url: 'stdBillsEditor/updateBills',
  221. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: updateId, field: field, data: data})},
  222. dataType: 'json',
  223. success: function(result){
  224. }
  225. });
  226. },
  227. updateBillsArr: function(billsLibId, updateId, orgId, newId, type, classify){
  228. $.ajax({
  229. type: 'post',
  230. url: 'stdBillsEditor/updateBillsArr',
  231. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: updateId, orgId: orgId, newId: newId, type: type, classify: classify})},
  232. dataType: 'json',
  233. success: function(result){
  234. }
  235. });
  236. },
  237. pasteBills: function(datas){
  238. $.ajax({
  239. type: 'post',
  240. url: 'stdBillsEditor/pasteBills',
  241. data: {data: JSON.stringify({datas: datas})},
  242. dataType: 'json',
  243. success: function(result){
  244. }
  245. });
  246. },
  247. updateRecharge: function(billsLibId, updateId, data){
  248. $.ajax({
  249. type: 'post',
  250. url: 'stdBillsEditor/updateRecharge',
  251. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: updateId, data: data})},
  252. dataType: 'json',
  253. success: function(result){
  254. }
  255. });
  256. },
  257. pasteRel: function (updateDatas, createDatas, field, callback) {
  258. $.ajax({
  259. type: 'post',
  260. url: 'stdBillsEditor/pasteRel',
  261. data: {data:JSON.stringify({updateDatas: updateDatas, createDatas: createDatas, field: field})},
  262. dataType: 'json',
  263. success: function(result){
  264. if(!result.error && callback){
  265. callback(result.data);
  266. }
  267. }
  268. });
  269. }
  270. };
  271. var jobsAjax = {
  272. getJobContent: function(billsLidId, callback){
  273. $.ajax({
  274. type: 'post',
  275. url: 'stdBillsEditor/getJobContent',
  276. data: {data: JSON.stringify({billsLibId: billsLidId})},
  277. dataType: 'json',
  278. success: function(result){
  279. if(!result.error && callback){
  280. callback(result.data);
  281. }
  282. }
  283. });
  284. },
  285. getSomeJobs: function(billsLibId, ids, callback){
  286. $.ajax({
  287. type: 'post',
  288. url: 'stdBillsEditor/getSomeJobs',
  289. data: {data: JSON.stringify({billsLibId: billsLibId, ids: ids})},
  290. dataType: 'json',
  291. success: function(result){
  292. if(!result.error && callback){
  293. callback(result.data);
  294. }
  295. }
  296. });
  297. },
  298. createJobContent: function(billsLibId, data, serialNo, callback){
  299. $.ajax({
  300. type: 'post',
  301. url: 'stdBillsEditor/createJobContent',
  302. data: {data: JSON.stringify({billsLibId: billsLibId, data: data, serialNo: serialNo})},
  303. dataType: 'json',
  304. success: function(result){
  305. if(!result.error && callback){
  306. callback(result.data);
  307. }
  308. }
  309. });
  310. },
  311. updateJobContent: function(billsLibId, id, field, data){
  312. $.ajax({
  313. type: 'post',
  314. url: 'stdBillsEditor/updateJobContent',
  315. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: id, field: field, data: data })},
  316. dataType: 'json',
  317. success: function(result){
  318. }
  319. });
  320. },
  321. deleteJobContent: function(billsLibId, ids){
  322. $.ajax({
  323. type: 'post',
  324. url: 'stdBillsEditor/deleteJobContent',
  325. data: {data: JSON.stringify({billsLibId: billsLibId, ids: ids})},
  326. dataType: 'json',
  327. success: function(result){
  328. }
  329. });
  330. },
  331. pasteJobs: function(pasteDatas, callback){
  332. $.ajax({
  333. type: 'post',
  334. url: 'stdBillsEditor/pasteJobs',
  335. data: {data: JSON.stringify({pasteDatas: pasteDatas})},
  336. dataType: 'json',
  337. success: function(result){
  338. if(!result.error && callback){
  339. callback(result.data);
  340. }
  341. }
  342. });
  343. },
  344. edCreateJob: function(billsLibId, billsId, data, code, serialNo, callback){
  345. $.ajax({
  346. type: 'post',
  347. url: 'stdBillsEditor/edCreateJob',
  348. data: {data: JSON.stringify({billsLibId: billsLibId, billsId:billsId, data: data, code: code, serialNo: serialNo})},
  349. dataType: 'json',
  350. success: function(result){
  351. if(!result.error && callback){
  352. callback(result.data);
  353. }
  354. }
  355. });
  356. },
  357. edUpdateJob: function(billsLibId, billsId, content, code, orgJobId, callback){
  358. $.ajax({
  359. type: 'post',
  360. url: 'stdBillsEditor/edUpdateJob',
  361. data: {data: JSON.stringify({billsLibId: billsLibId, billsId:billsId, content: content, code: code, orgJobId: orgJobId})},
  362. dataType: 'json',
  363. success: function(result){
  364. if(!result.error && callback){
  365. callback(result.data);
  366. }
  367. }
  368. });
  369. }
  370. };
  371. var itemsAjax = {
  372. getItemCharacter: function(billsLibId, callback){
  373. $.ajax({
  374. type: 'post',
  375. url: 'stdBillsEditor/getItemCharacter',
  376. data: {data: JSON.stringify({billsLibId: billsLibId})},
  377. dataType: 'json',
  378. success: function(result){
  379. if(!result.error){
  380. if(callback){
  381. callback(result.data);
  382. }
  383. }
  384. }
  385. });
  386. },
  387. createItemCharacter: function(billsLibId, data, serialNo, id){
  388. $.ajax({
  389. type: 'post',
  390. url: 'stdBillsEditor/createItemCharacter',
  391. data: {data: JSON.stringify({billsLibId: billsLibId, data: data, serialNo: serialNo, id: id})},
  392. dataType: 'json',
  393. success: function(result){
  394. }
  395. });
  396. },
  397. updateItemCharacter: function(billsLibId, id, field, data){
  398. $.ajax({
  399. type: 'post',
  400. url: 'stdBillsEditor/updateItemCharacter',
  401. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: id, field: field, data: data })},
  402. dataType: 'json',
  403. success: function(result){
  404. }
  405. });
  406. },
  407. updateValue: function(billsLibId, id, data, deleteCodes, type){
  408. $.ajax({
  409. type: 'post',
  410. url: 'stdBillsEditor/updateValue',
  411. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: id, data: data, type: type, deleteCodes: deleteCodes})},
  412. dataType: 'json',
  413. success: function(reslut){
  414. }
  415. });
  416. },
  417. deleteItemCharacter: function(billsLibId, ids){
  418. $.ajax({
  419. type: 'post',
  420. url: 'stdBillsEditor/deleteItemCharacter',
  421. data: {data: JSON.stringify({billsLibId: billsLibId, ids: ids})},
  422. dataType: 'json',
  423. success: function(result){
  424. }
  425. });
  426. },
  427. pasteItems: function(pasteDatas, callback){
  428. $.ajax({
  429. type: 'post',
  430. url: 'stdBillsEditor/pasteItems',
  431. data: {data: JSON.stringify({pasteDatas: pasteDatas})},
  432. dataType: 'json',
  433. success: function(result){
  434. if(!result.error && callback){
  435. callback(result.data);
  436. }
  437. }
  438. });
  439. },
  440. pasteValues: function(pasteDatas, callback){
  441. $.ajax({
  442. type: 'post',
  443. url: 'stdBillsEditor/pasteValues',
  444. data: {data: JSON.stringify({pasteDatas: pasteDatas})},
  445. dataType: 'json',
  446. success: function(result){
  447. if(!result.error && callback){
  448. callback(result.data);
  449. }
  450. }
  451. });
  452. },
  453. edCreateItem: function(billsLibId, billsId, data, code, serialNo, callback){
  454. $.ajax({
  455. type: 'post',
  456. url: 'stdBillsEditor/edCreateItem',
  457. data: {data: JSON.stringify({billsLibId: billsLibId, billsId:billsId, data: data, code: code, serialNo: serialNo})},
  458. dataType: 'json',
  459. success: function(result){
  460. if(!result.error && callback){
  461. callback(result.data);
  462. }
  463. }
  464. });
  465. },
  466. edUpdateItem: function(billsLibId, billsId, content, code, orgItemId, callback){
  467. $.ajax({
  468. type: 'post',
  469. url: 'stdBillsEditor/edUpdateItem',
  470. data: {data: JSON.stringify({billsLibId: billsLibId, billsId:billsId, content: content, code: code, orgItemId: orgItemId})},
  471. dataType: 'json',
  472. success: function(result){
  473. if(!result.error && callback){
  474. callback(result.data);
  475. }
  476. }
  477. });
  478. }
  479. }