billsLibAjax.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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, updateData, callback){
  161. $.ajax({
  162. type: 'post',
  163. url: 'stdBillsEditor/updatePNId',
  164. data: {data: JSON.stringify({billsLibId: billsLibId, updateData: updateData})},
  165. dataType: 'json',
  166. success: function(result){
  167. if(!result.error){
  168. if(callback){
  169. callback();
  170. }
  171. }
  172. }
  173. });
  174. },
  175. deleteBills: function(billsLibId, deleteIds, callback){
  176. $.ajax({
  177. type: 'post',
  178. url: 'stdBillsEditor/deleteBills',
  179. data: {data: JSON.stringify({billsLibId: billsLibId, deleteIds: deleteIds})},
  180. dataType: 'json',
  181. success: function(result){
  182. if(!result.error){
  183. if(callback){
  184. callback();
  185. }
  186. }
  187. }
  188. });
  189. },
  190. updateBills: function(billsLibId, updateId, field, data){
  191. $.ajax({
  192. type: 'post',
  193. url: 'stdBillsEditor/updateBills',
  194. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: updateId, field: field, data: data})},
  195. dataType: 'json',
  196. success: function(result){
  197. }
  198. });
  199. },
  200. updateBillsArr: function(billsLibId, updateId, orgId, newId, type, classify){
  201. $.ajax({
  202. type: 'post',
  203. url: 'stdBillsEditor/updateBillsArr',
  204. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: updateId, orgId: orgId, newId: newId, type: type, classify: classify})},
  205. dataType: 'json',
  206. success: function(result){
  207. }
  208. });
  209. },
  210. pasteBills: function(datas){
  211. $.ajax({
  212. type: 'post',
  213. url: 'stdBillsEditor/pasteBills',
  214. data: {data: JSON.stringify({datas: datas})},
  215. dataType: 'json',
  216. success: function(result){
  217. }
  218. });
  219. },
  220. updateRecharge: function(billsLibId, updateIds, data){
  221. $.ajax({
  222. type: 'post',
  223. url: 'stdBillsEditor/updateRecharge',
  224. data: {data: JSON.stringify({billsLibId: billsLibId, updateIds: updateIds, data: data})},
  225. dataType: 'json',
  226. success: function(result){
  227. }
  228. });
  229. }
  230. }
  231. var jobsAjax = {
  232. getJobContent: function(billsLidId, callback){
  233. $.ajax({
  234. type: 'post',
  235. url: 'stdBillsEditor/getJobContent',
  236. data: {data: JSON.stringify({billsLibId: billsLidId})},
  237. dataType: 'json',
  238. success: function(result){
  239. if(!result.error && callback){
  240. callback(result.data);
  241. }
  242. }
  243. });
  244. },
  245. getSomeJobs: function(billsLibId, ids, callback){
  246. $.ajax({
  247. type: 'post',
  248. url: 'stdBillsEditor/getSomeJobs',
  249. data: {data: JSON.stringify({billsLibId: billsLibId, ids: ids})},
  250. dataType: 'json',
  251. success: function(result){
  252. if(!result.error && callback){
  253. callback(result.data);
  254. }
  255. }
  256. });
  257. },
  258. createJobContent: function(billsLibId, field, data, serialNo, callback){
  259. $.ajax({
  260. type: 'post',
  261. url: 'stdBillsEditor/createJobContent',
  262. data: {data: JSON.stringify({billsLibId: billsLibId, field: field, data: data, serialNo: serialNo })},
  263. dataType: 'json',
  264. success: function(result){
  265. if(!result.error){
  266. if(callback){
  267. callback(result.data);
  268. }
  269. }
  270. }
  271. });
  272. },
  273. updateJobContent: function(id, field, data){
  274. $.ajax({
  275. type: 'post',
  276. url: 'stdBillsEditor/updateJobContent',
  277. data: {data: JSON.stringify({updateId: id, field: field, data: data })},
  278. dataType: 'json',
  279. success: function(result){
  280. }
  281. });
  282. },
  283. deleteJobContent: function(ids){
  284. $.ajax({
  285. type: 'post',
  286. url: 'stdBillsEditor/deleteJobContent',
  287. data: {data: JSON.stringify({ids: ids})},
  288. dataType: 'json',
  289. success: function(result){
  290. }
  291. });
  292. }
  293. }
  294. var itemsAjax = {
  295. getItemCharacter: function(billsLibId, callback){
  296. $.ajax({
  297. type: 'post',
  298. url: 'stdBillsEditor/getItemCharacter',
  299. data: {data: JSON.stringify({billsLibId: billsLibId})},
  300. dataType: 'json',
  301. success: function(result){
  302. if(!result.error){
  303. if(callback){
  304. callback(result.data);
  305. }
  306. }
  307. }
  308. });
  309. },
  310. createItemCharacter: function(billsLibId, field, data, serialNo, callback){
  311. $.ajax({
  312. type: 'post',
  313. url: 'stdBillsEditor/createItemCharacter',
  314. data: {data: JSON.stringify({billsLibId: billsLibId, field: field, data: data, serialNo: serialNo})},
  315. dataType: 'json',
  316. success: function(result){
  317. if(!result.error){
  318. if(callback){
  319. callback(result.data);
  320. }
  321. }
  322. }
  323. });
  324. },
  325. updateItemCharacter: function(id, field, data){
  326. $.ajax({
  327. type: 'post',
  328. url: 'stdBillsEditor/updateItemCharacter',
  329. data: {data: JSON.stringify({updateId: id, field: field, data: data })},
  330. dataType: 'json',
  331. success: function(result){
  332. }
  333. });
  334. },
  335. updateValue: function(id, data, deleteCodes, type){
  336. $.ajax({
  337. type: 'post',
  338. url: 'stdBillsEditor/updateValue',
  339. data: {data: JSON.stringify({updateId: id, data: data, type: type, deleteCodes: deleteCodes})},
  340. dataType: 'json',
  341. success: function(reslut){
  342. }
  343. });
  344. },
  345. deleteItemCharacter: function(ids){
  346. $.ajax({
  347. type: 'post',
  348. url: 'stdBillsEditor/deleteItemCharacter',
  349. data: {data: JSON.stringify({ids: ids})},
  350. dataType: 'json',
  351. success: function(result){
  352. }
  353. });
  354. }
  355. }