bills_lib_ajax.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  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, updatePreData, callback){
  158. $.ajax({
  159. type: 'post',
  160. url: 'stdBillsEditor/createBills',
  161. data: {data: JSON.stringify({billsLibId: billsLibId, newId: newId, ParentID: pid, NextSiblingID: nid, updatePreData: updatePreData})},
  162. dataType: 'json',
  163. success: function(result){
  164. if(!result.error){
  165. if(callback){
  166. callback();
  167. }
  168. }
  169. }
  170. });
  171. },
  172. upMove: function(billsLibId, updateDatas, callback){
  173. $.ajax({
  174. type: 'post',
  175. url: 'stdBillsEditor/upMove',
  176. data: {data: JSON.stringify({billsLibId: billsLibId, updateDatas: updateDatas})},
  177. dataType: 'json',
  178. success: function(result){
  179. if(!result.error && callback){
  180. callback();
  181. }
  182. }
  183. });
  184. },
  185. downMove: function (billsLibId, updateDatas, callback) {
  186. $.ajax({
  187. type: 'post',
  188. url: 'stdBillsEditor/downMove',
  189. data: {data: JSON.stringify({billsLibId: billsLibId, updateDatas: updateDatas})},
  190. dataType: 'json',
  191. success: function(result){
  192. if(!result.error && callback){
  193. callback();
  194. }
  195. }
  196. })
  197. },
  198. updatePNId: function(billsLibId, updateData, callback){
  199. $.ajax({
  200. type: 'post',
  201. url: 'stdBillsEditor/updatePNId',
  202. data: {data: JSON.stringify({billsLibId: billsLibId, updateData: updateData})},
  203. dataType: 'json',
  204. success: function(result){
  205. console.log(`entersFuc`);
  206. if(!result.error && callback){
  207. console.log(`enterSc`);
  208. callback();
  209. }
  210. else {
  211. //提示窗口:更新失败
  212. }
  213. },
  214. error: function(){
  215. console.log(`error`);
  216. }
  217. });
  218. },
  219. upLevel: function(billsLibId, updateDatas, callback){
  220. $.ajax({
  221. type: 'post',
  222. url: 'stdBillsEditor/upLevel',
  223. data: {data: JSON.stringify({billsLibId: billsLibId, updateDatas: updateDatas})},
  224. dataType: 'json',
  225. success: function (result) {
  226. console.log(`ssc`);
  227. if(!result.error && callback){
  228. callback();
  229. }
  230. }
  231. })
  232. },
  233. downLevel: function (billsLibId, updateDatas, callback) {
  234. $.ajax({
  235. type: 'post',
  236. url: 'stdBillsEditor/downLevel',
  237. data: {data: JSON.stringify({billsLibId: billsLibId, updateDatas: updateDatas})},
  238. dataType: 'json',
  239. success: function (result) {
  240. if(!result.error && callback){
  241. callback();
  242. }
  243. }
  244. })
  245. },
  246. deleteBills: function(billsLibId, deleteIds, updateNode, callback){
  247. $.ajax({
  248. type: 'post',
  249. url: 'stdBillsEditor/deleteBills',
  250. data: {data: JSON.stringify({billsLibId: billsLibId, deleteIds: deleteIds, updateNode: updateNode})},
  251. dataType: 'json',
  252. success: function(result){
  253. if(!result.error){
  254. console.log(result.message);
  255. if(callback){
  256. callback();
  257. }
  258. }
  259. }
  260. });
  261. },
  262. updateBills: function(billsLibId, updateId, field, data){
  263. $.ajax({
  264. type: 'post',
  265. url: 'stdBillsEditor/updateBills',
  266. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: updateId, field: field, data: data})},
  267. dataType: 'json',
  268. success: function(result){
  269. }
  270. });
  271. },
  272. updateBillsArr: function(billsLibId, updateId, orgId, newId, type, classify, callback){
  273. $.ajax({
  274. type: 'post',
  275. url: 'stdBillsEditor/updateBillsArr',
  276. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: updateId, orgId: orgId, newId: newId, type: type, classify: classify})},
  277. dataType: 'json',
  278. success: function(result){
  279. if(!result.error && callback){
  280. callback();
  281. }
  282. }
  283. });
  284. },
  285. pasteBills: function(datas){
  286. $.ajax({
  287. type: 'post',
  288. url: 'stdBillsEditor/pasteBills',
  289. data: {data: JSON.stringify({datas: datas})},
  290. dataType: 'json',
  291. success: function(result){
  292. }
  293. });
  294. },
  295. updateRecharge: function(billsLibId, updateId, data){
  296. $.ajax({
  297. type: 'post',
  298. url: 'stdBillsEditor/updateRecharge',
  299. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: updateId, data: data})},
  300. dataType: 'json',
  301. success: function(result){
  302. }
  303. });
  304. },
  305. pasteRel: function (updateDatas, createDatas, field, callback) {
  306. $.ajax({
  307. type: 'post',
  308. url: 'stdBillsEditor/pasteRel',
  309. data: {data:JSON.stringify({updateDatas: updateDatas, createDatas: createDatas, field: field})},
  310. dataType: 'json',
  311. success: function(result){
  312. if(!result.error && callback){
  313. callback(result.data);
  314. }
  315. }
  316. });
  317. }
  318. };
  319. var jobsAjax = {
  320. getJobContent: function(billsLidId, callback){
  321. $.ajax({
  322. type: 'post',
  323. url: 'stdBillsEditor/getJobContent',
  324. data: {data: JSON.stringify({billsLibId: billsLidId})},
  325. dataType: 'json',
  326. success: function(result){
  327. if(!result.error && callback){
  328. callback(result.data);
  329. }
  330. }
  331. });
  332. },
  333. getSomeJobs: function(billsLibId, ids, callback){
  334. $.ajax({
  335. type: 'post',
  336. url: 'stdBillsEditor/getSomeJobs',
  337. data: {data: JSON.stringify({billsLibId: billsLibId, ids: ids})},
  338. dataType: 'json',
  339. success: function(result){
  340. if(!result.error && callback){
  341. callback(result.data);
  342. }
  343. }
  344. });
  345. },
  346. createJobContent: function(billsLibId, data, serialNo, callback){
  347. $.ajax({
  348. type: 'post',
  349. url: 'stdBillsEditor/createJobContent',
  350. data: {data: JSON.stringify({billsLibId: billsLibId, data: data, serialNo: serialNo})},
  351. dataType: 'json',
  352. success: function(result){
  353. if(!result.error && callback){
  354. callback(result.data);
  355. }
  356. }
  357. });
  358. },
  359. updateJobContent: function(billsLibId, id, field, data){
  360. $.ajax({
  361. type: 'post',
  362. url: 'stdBillsEditor/updateJobContent',
  363. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: id, field: field, data: data })},
  364. dataType: 'json',
  365. success: function(result){
  366. }
  367. });
  368. },
  369. deleteJobContent: function(billsLibId, ids){
  370. $.ajax({
  371. type: 'post',
  372. url: 'stdBillsEditor/deleteJobContent',
  373. data: {data: JSON.stringify({billsLibId: billsLibId, ids: ids})},
  374. dataType: 'json',
  375. success: function(result){
  376. }
  377. });
  378. },
  379. pasteJobs: function(pasteDatas, callback){
  380. $.ajax({
  381. type: 'post',
  382. url: 'stdBillsEditor/pasteJobs',
  383. data: {data: JSON.stringify({pasteDatas: pasteDatas})},
  384. dataType: 'json',
  385. success: function(result){
  386. if(!result.error && callback){
  387. callback(result.data);
  388. }
  389. }
  390. });
  391. },
  392. edCreateJob: function(billsLibId, billsId, data, code, serialNo, callback){
  393. $.ajax({
  394. type: 'post',
  395. url: 'stdBillsEditor/edCreateJob',
  396. data: {data: JSON.stringify({billsLibId: billsLibId, billsId:billsId, data: data, code: code, serialNo: serialNo})},
  397. dataType: 'json',
  398. success: function(result){
  399. if(!result.error && callback){
  400. callback(result.data);
  401. }
  402. }
  403. });
  404. },
  405. edUpdateJob: function(billsLibId, billsId, content, code, orgJobId, callback){
  406. $.ajax({
  407. type: 'post',
  408. url: 'stdBillsEditor/edUpdateJob',
  409. data: {data: JSON.stringify({billsLibId: billsLibId, billsId:billsId, content: content, code: code, orgJobId: orgJobId})},
  410. dataType: 'json',
  411. success: function(result){
  412. if(!result.error && callback){
  413. callback(result.data);
  414. }
  415. }
  416. });
  417. }
  418. };
  419. var itemsAjax = {
  420. getItemCharacter: function(billsLibId, callback){
  421. $.ajax({
  422. type: 'post',
  423. url: 'stdBillsEditor/getItemCharacter',
  424. data: {data: JSON.stringify({billsLibId: billsLibId})},
  425. dataType: 'json',
  426. success: function(result){
  427. if(!result.error){
  428. if(callback){
  429. callback(result.data);
  430. }
  431. }
  432. }
  433. });
  434. },
  435. createItemCharacter: function(billsLibId, data, serialNo, id){
  436. $.ajax({
  437. type: 'post',
  438. url: 'stdBillsEditor/createItemCharacter',
  439. data: {data: JSON.stringify({billsLibId: billsLibId, data: data, serialNo: serialNo, id: id})},
  440. dataType: 'json',
  441. success: function(result){
  442. }
  443. });
  444. },
  445. updateItemCharacter: function(billsLibId, id, field, data){
  446. $.ajax({
  447. type: 'post',
  448. url: 'stdBillsEditor/updateItemCharacter',
  449. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: id, field: field, data: data })},
  450. dataType: 'json',
  451. success: function(result){
  452. }
  453. });
  454. },
  455. updateValue: function(billsLibId, id, data, deleteCodes, type){
  456. $.ajax({
  457. type: 'post',
  458. url: 'stdBillsEditor/updateValue',
  459. data: {data: JSON.stringify({billsLibId: billsLibId, updateId: id, data: data, type: type, deleteCodes: deleteCodes})},
  460. dataType: 'json',
  461. success: function(reslut){
  462. }
  463. });
  464. },
  465. deleteItemCharacter: function(billsLibId, ids){
  466. $.ajax({
  467. type: 'post',
  468. url: 'stdBillsEditor/deleteItemCharacter',
  469. data: {data: JSON.stringify({billsLibId: billsLibId, ids: ids})},
  470. dataType: 'json',
  471. success: function(result){
  472. }
  473. });
  474. },
  475. pasteItems: function(pasteDatas, callback){
  476. $.ajax({
  477. type: 'post',
  478. url: 'stdBillsEditor/pasteItems',
  479. data: {data: JSON.stringify({pasteDatas: pasteDatas})},
  480. dataType: 'json',
  481. success: function(result){
  482. if(!result.error && callback){
  483. callback(result.data);
  484. }
  485. }
  486. });
  487. },
  488. pasteValues: function(pasteDatas, callback){
  489. $.ajax({
  490. type: 'post',
  491. url: 'stdBillsEditor/pasteValues',
  492. data: {data: JSON.stringify({pasteDatas: pasteDatas})},
  493. dataType: 'json',
  494. success: function(result){
  495. if(!result.error && callback){
  496. callback(result.data);
  497. }
  498. }
  499. });
  500. },
  501. edCreateItem: function(billsLibId, billsId, data, code, serialNo, callback){
  502. $.ajax({
  503. type: 'post',
  504. url: 'stdBillsEditor/edCreateItem',
  505. data: {data: JSON.stringify({billsLibId: billsLibId, billsId:billsId, data: data, code: code, serialNo: serialNo})},
  506. dataType: 'json',
  507. success: function(result){
  508. if(!result.error && callback){
  509. callback(result.data);
  510. }
  511. }
  512. });
  513. },
  514. edUpdateItem: function(billsLibId, billsId, content, code, orgItemId, callback){
  515. $.ajax({
  516. type: 'post',
  517. url: 'stdBillsEditor/edUpdateItem',
  518. data: {data: JSON.stringify({billsLibId: billsLibId, billsId:billsId, content: content, code: code, orgItemId: orgItemId})},
  519. dataType: 'json',
  520. success: function(result){
  521. if(!result.error && callback){
  522. callback(result.data);
  523. }
  524. }
  525. });
  526. }
  527. }