bills_lib_ajax.js 14 KB

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