billsLibAjax.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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. }
  115. var billsAjax = {
  116. getStdBillsLibName: function(billsLibId) {
  117. $.ajax({
  118. type: "post",
  119. url: "/stdBillsEditor/getStdBillsLibName",
  120. data: {data: JSON.stringify({billsLibId: billsLibId})},
  121. success: function(result){
  122. if(!result.error){
  123. $(".navbar-text").append(
  124. "<a href='stdBillsmain'>清单规则</a><i class='fa fa-angle-right fa-fw'></i>"+result.data[0].billsLibName
  125. );
  126. }
  127. }
  128. });
  129. },
  130. getBills: function(billsLibId, callback){
  131. $.ajax({
  132. type: "post",
  133. url: "/stdBillsEditor/getBills",
  134. data: {data: JSON.stringify({billsLibId: billsLibId})},
  135. dataType: "json",
  136. success: function(result){
  137. if(!result.error){
  138. if(callback) {
  139. callback(result.data);
  140. }
  141. }
  142. }
  143. });
  144. },
  145. createBills: function(billsLibId, newId, pid, nid, callback){
  146. $.ajax({
  147. type: 'post',
  148. url: 'stdBillsEditor/createBills',
  149. data: {data: JSON.stringify({billsLibId: billsLibId, newId: newId, ParentID: pid, NextSiblingID: nid})},
  150. dataType: 'json',
  151. success: function(result){
  152. if(!result.error){
  153. if(callback){
  154. callback();
  155. }
  156. }
  157. }
  158. });
  159. },
  160. /* updatePNId: function(billsLibId, updateId, pid, nid, callback){
  161. $.ajax({
  162. type: 'post',
  163. url: 'stdBillsEditor/updatePNId',
  164. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: updateId, ParentID: pid, NextSiblingID: nid})},
  165. dataType: 'json',
  166. success: function(result){
  167. if(!result.error){
  168. if(callback){
  169. callback();
  170. }
  171. }
  172. }
  173. });
  174. },*/
  175. updatePNId: function(billsLibId, updateData, callback){
  176. $.ajax({
  177. type: 'post',
  178. url: 'stdBillsEditor/updatePNId',
  179. data: {data: JSON.stringify({billsLibId: billsLibId, updateData: updateData})},
  180. dataType: 'json',
  181. success: function(result){
  182. if(!result.error){
  183. if(callback){
  184. callback();
  185. }
  186. }
  187. }
  188. });
  189. },
  190. deleteBills: function(billsLibId, deleteIds, callback){
  191. $.ajax({
  192. type: 'post',
  193. url: 'stdBillsEditor/deleteBills',
  194. data: {data: JSON.stringify({billsLibId: billsLibId, deleteIds: deleteIds})},
  195. dataType: 'json',
  196. success: function(result){
  197. if(!result.error){
  198. if(callback){
  199. callback();
  200. }
  201. }
  202. }
  203. });
  204. },
  205. updateBills: function(billsLibId, updateId, field, data){
  206. $.ajax({
  207. type: 'post',
  208. url: 'stdBillsEditor/updateBills',
  209. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: updateId, field: field, data: data})},
  210. dataType: 'json',
  211. success: function(result){
  212. }
  213. });
  214. },
  215. updateBillsArr: function(billsLibId, updateId, orgId, newId, type, classify){
  216. $.ajax({
  217. type: 'post',
  218. url: 'stdBillsEditor/updateBillsArr',
  219. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: updateId, orgId: orgId, newId: newId, type: type, classify: classify})},
  220. dataType: 'json',
  221. success: function(result){
  222. }
  223. });
  224. },
  225. updateRecharge: function(billsLibId, updateIds, data){
  226. $.ajax({
  227. type: 'post',
  228. url: 'stdBillsEditor/updateRecharge',
  229. data: {data: JSON.stringify({billsLibId: billsLibId, updateIds: updateIds, data: data})},
  230. dataType: 'json',
  231. success: function(result){
  232. }
  233. });
  234. }
  235. }
  236. var jobsAjax = {
  237. getJobContent: function(billsLidId, callback){
  238. $.ajax({
  239. type: 'post',
  240. url: 'stdBillsEditor/getJobContent',
  241. data: {data: JSON.stringify({billsLibId: billsLidId})},
  242. dataType: 'json',
  243. success: function(result){
  244. if(!result.error && callback){
  245. callback(result.data);
  246. }
  247. }
  248. });
  249. },
  250. getSomeJobs: function(billsLibId, ids, callback){
  251. $.ajax({
  252. type: 'post',
  253. url: 'stdBillsEditor/getSomeJobs',
  254. data: {data: JSON.stringify({billsLibId: billsLibId, ids: ids})},
  255. dataType: 'json',
  256. success: function(result){
  257. if(!result.error && callback){
  258. callback(result.data);
  259. }
  260. }
  261. });
  262. },
  263. createJobContent: function(billsLibId, field, data, serialNo, callback){
  264. $.ajax({
  265. type: 'post',
  266. url: 'stdBillsEditor/createJobContent',
  267. data: {data: JSON.stringify({billsLibId: billsLibId, field: field, data: data, serialNo: serialNo })},
  268. dataType: 'json',
  269. success: function(result){
  270. if(!result.error){
  271. if(callback){
  272. callback(result.data);
  273. }
  274. }
  275. }
  276. });
  277. },
  278. updateJobContent: function(id, field, data){
  279. $.ajax({
  280. type: 'post',
  281. url: 'stdBillsEditor/updateJobContent',
  282. data: {data: JSON.stringify({updateId: id, field: field, data: data })},
  283. dataType: 'json',
  284. success: function(result){
  285. }
  286. });
  287. },
  288. deleteJobContent: function(ids){
  289. $.ajax({
  290. type: 'post',
  291. url: 'stdBillsEditor/deleteJobContent',
  292. data: {data: JSON.stringify({ids: ids})},
  293. dataType: 'json',
  294. success: function(result){
  295. }
  296. });
  297. }
  298. }
  299. var itemsAjax = {
  300. getItemCharacter: function(billsLibId, callback){
  301. $.ajax({
  302. type: 'post',
  303. url: 'stdBillsEditor/getItemCharacter',
  304. data: {data: JSON.stringify({billsLibId: billsLibId})},
  305. dataType: 'json',
  306. success: function(result){
  307. if(!result.error){
  308. if(callback){
  309. callback(result.data);
  310. }
  311. }
  312. }
  313. });
  314. },
  315. createItemCharacter: function(billsLibId, field, data, serialNo, callback){
  316. $.ajax({
  317. type: 'post',
  318. url: 'stdBillsEditor/createItemCharacter',
  319. data: {data: JSON.stringify({billsLibId: billsLibId, field: field, data: data, serialNo: serialNo})},
  320. dataType: 'json',
  321. success: function(result){
  322. if(!result.error){
  323. if(callback){
  324. callback(result.data);
  325. }
  326. }
  327. }
  328. });
  329. },
  330. updateItemCharacter: function(id, field, data){
  331. $.ajax({
  332. type: 'post',
  333. url: 'stdBillsEditor/updateItemCharacter',
  334. data: {data: JSON.stringify({updateId: id, field: field, data: data })},
  335. dataType: 'json',
  336. success: function(result){
  337. }
  338. });
  339. },
  340. updateValue: function(id, data, deleteCodes, type){
  341. $.ajax({
  342. type: 'post',
  343. url: 'stdBillsEditor/updateValue',
  344. data: {data: JSON.stringify({updateId: id, data: data, type: type, deleteCodes: deleteCodes})},
  345. dataType: 'json',
  346. success: function(reslut){
  347. }
  348. });
  349. },
  350. deleteItemCharacter: function(ids){
  351. $.ajax({
  352. type: 'post',
  353. url: 'stdBillsEditor/deleteItemCharacter',
  354. data: {data: JSON.stringify({ids: ids})},
  355. dataType: 'json',
  356. success: function(result){
  357. }
  358. });
  359. }
  360. }