bills_lib_ajax.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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, updateId, data){
  234. $.ajax({
  235. type: 'post',
  236. url: 'stdBillsEditor/updateRecharge',
  237. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: updateId, 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, callback){
  285. $.ajax({
  286. type: 'post',
  287. url: 'stdBillsEditor/createJobContent',
  288. data: {data: JSON.stringify({billsLibId: billsLibId, data: data, serialNo: serialNo})},
  289. dataType: 'json',
  290. success: function(result){
  291. if(!result.error && callback){
  292. callback(result.data);
  293. }
  294. }
  295. });
  296. },
  297. updateJobContent: function(billsLibId, id, field, data){
  298. $.ajax({
  299. type: 'post',
  300. url: 'stdBillsEditor/updateJobContent',
  301. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: id, field: field, data: data })},
  302. dataType: 'json',
  303. success: function(result){
  304. }
  305. });
  306. },
  307. deleteJobContent: function(billsLibId, ids){
  308. $.ajax({
  309. type: 'post',
  310. url: 'stdBillsEditor/deleteJobContent',
  311. data: {data: JSON.stringify({billsLibId: billsLibId, ids: ids})},
  312. dataType: 'json',
  313. success: function(result){
  314. }
  315. });
  316. },
  317. pasteJobs: function(pasteDatas, callback){
  318. $.ajax({
  319. type: 'post',
  320. url: 'stdBillsEditor/pasteJobs',
  321. data: {data: JSON.stringify({pasteDatas: pasteDatas})},
  322. dataType: 'json',
  323. success: function(result){
  324. if(!result.error && callback){
  325. callback(result.data);
  326. }
  327. }
  328. });
  329. },
  330. edCreateJob: function(billsLibId, billsId, data, code, serialNo, callback){
  331. $.ajax({
  332. type: 'post',
  333. url: 'stdBillsEditor/edCreateJob',
  334. data: {data: JSON.stringify({billsLibId: billsLibId, billsId:billsId, data: data, code: code, serialNo: serialNo})},
  335. dataType: 'json',
  336. success: function(result){
  337. if(!result.error && callback){
  338. callback(result.data);
  339. }
  340. }
  341. });
  342. },
  343. edUpdateJob: function(billsLibId, billsId, content, code, orgJobId, callback){
  344. $.ajax({
  345. type: 'post',
  346. url: 'stdBillsEditor/edUpdateJob',
  347. data: {data: JSON.stringify({billsLibId: billsLibId, billsId:billsId, content: content, code: code, orgJobId: orgJobId})},
  348. dataType: 'json',
  349. success: function(result){
  350. if(!result.error && callback){
  351. callback(result.data);
  352. }
  353. }
  354. });
  355. }
  356. };
  357. var itemsAjax = {
  358. getItemCharacter: function(billsLibId, callback){
  359. $.ajax({
  360. type: 'post',
  361. url: 'stdBillsEditor/getItemCharacter',
  362. data: {data: JSON.stringify({billsLibId: billsLibId})},
  363. dataType: 'json',
  364. success: function(result){
  365. if(!result.error){
  366. if(callback){
  367. callback(result.data);
  368. }
  369. }
  370. }
  371. });
  372. },
  373. createItemCharacter: function(billsLibId, data, serialNo, id){
  374. $.ajax({
  375. type: 'post',
  376. url: 'stdBillsEditor/createItemCharacter',
  377. data: {data: JSON.stringify({billsLibId: billsLibId, data: data, serialNo: serialNo, id: id})},
  378. dataType: 'json',
  379. success: function(result){
  380. }
  381. });
  382. },
  383. updateItemCharacter: function(billsLibId, id, field, data){
  384. $.ajax({
  385. type: 'post',
  386. url: 'stdBillsEditor/updateItemCharacter',
  387. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: id, field: field, data: data })},
  388. dataType: 'json',
  389. success: function(result){
  390. }
  391. });
  392. },
  393. updateValue: function(billsLibId, id, data, deleteCodes, type){
  394. $.ajax({
  395. type: 'post',
  396. url: 'stdBillsEditor/updateValue',
  397. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: id, data: data, type: type, deleteCodes: deleteCodes})},
  398. dataType: 'json',
  399. success: function(reslut){
  400. }
  401. });
  402. },
  403. deleteItemCharacter: function(billsLibId, ids){
  404. $.ajax({
  405. type: 'post',
  406. url: 'stdBillsEditor/deleteItemCharacter',
  407. data: {data: JSON.stringify({billsLibId: billsLibId, ids: ids})},
  408. dataType: 'json',
  409. success: function(result){
  410. }
  411. });
  412. },
  413. pasteItems: function(pasteDatas){
  414. $.ajax({
  415. type: 'post',
  416. url: 'stdBillsEditor/pasteItems',
  417. data: {data: JSON.stringify({pasteDatas: pasteDatas})},
  418. dataType: 'json',
  419. success: function(result){
  420. }
  421. });
  422. },
  423. pasteValues: function(pasteDatas, callback){
  424. $.ajax({
  425. type: 'post',
  426. url: 'stdBillsEditor/pasteValues',
  427. data: {data: JSON.stringify({pasteDatas: pasteDatas})},
  428. dataType: 'json',
  429. success: function(result){
  430. if(!result.error && callback){
  431. callback(result.data);
  432. }
  433. }
  434. });
  435. },
  436. edCreateItem: function(billsLibId, billsId, data, code, serialNo, callback){
  437. $.ajax({
  438. type: 'post',
  439. url: 'stdBillsEditor/edCreateItem',
  440. data: {data: JSON.stringify({billsLibId: billsLibId, billsId:billsId, data: data, code: code, serialNo: serialNo})},
  441. dataType: 'json',
  442. success: function(result){
  443. if(!result.error && callback){
  444. callback(result.data);
  445. }
  446. }
  447. });
  448. },
  449. edUpdateItem: function(billsLibId, billsId, content, code, orgItemId, callback){
  450. $.ajax({
  451. type: 'post',
  452. url: 'stdBillsEditor/edUpdateItem',
  453. data: {data: JSON.stringify({billsLibId: billsLibId, billsId:billsId, content: content, code: code, orgItemId: orgItemId})},
  454. dataType: 'json',
  455. success: function(result){
  456. if(!result.error && callback){
  457. callback(result.data);
  458. }
  459. }
  460. });
  461. }
  462. }