bills_lib_ajax.js 14 KB

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