Advertisement
Guest User

Untitled

a guest
May 25th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.81 KB | None | 0 0
  1. $(function () {
  2. loadBillSubTable();
  3. var t1 = new table("quotaTable", "prId", "quotaTotal", "gszbzjiaddy", formatterMap);
  4. t1.initSetting();
  5. });
  6. var formatterMap = {
  7. prId: function (value, row, index) {
  8. return '<span>' + (index + 1) + '</span>';
  9. },
  10. printFlag: function (value, row, index) {
  11. if(value == '0')
  12. return '未打印';
  13. else if(value == '1')
  14. return '已打印';
  15. },
  16. printDate: function (value, row, index) {
  17. if (value != undefined && value != '') {
  18. return '<span>' + value.substring(0, 10) + '</span>';
  19. }
  20. }
  21. };
  22.  
  23. function loadBillSubTable() {
  24. $('#quotaTable')
  25. .bootstrapTable(
  26. {
  27. method: 'get',
  28. url: "/quota/budgetUnitBill/printlist",
  29. iconSize: 'outline',
  30. toolbar: '#exampleToolbar',
  31. striped: true,
  32. dataType: "json",
  33. pagination: true,
  34. singleSelect: false,
  35. pageSize: 10,
  36. pageNumber: 1,
  37. showColumns: false,
  38. undefinedText: "",
  39. sidePagination: "server",
  40. queryParams: function (params) {
  41. return {
  42. limit: params.limit,
  43. offset: params.offset,
  44. indicatorNumber: $("#indicatorNumber").val(),
  45. //budgetUnit: $("#budgetUnit").val(),
  46. quotaSource: $("#quotaSource").val(),
  47. capitalType: $("#capitalType").val(),
  48. functionType: $("#functionType").val(),
  49. businessUnit: $("#businessUnit").val(),
  50. billType: $("#billType").val(),
  51. budgetUnitStartDate: $("#budgetUnitStartDate").val(),
  52. budgetUnitEndDate: $("#budgetUnitEndDate").val(),
  53. printStatus:$("#printStatus").val()
  54. };
  55. },
  56. columns: [
  57. {
  58. checkbox: true
  59. },
  60. {
  61. field: 'prId',
  62. title: '编号',
  63. formatter: function (value, row, index) {
  64. return '<span>' + (index + 1) + '</span>';
  65. }
  66. },
  67. {
  68. field: 'billNumber',
  69. title: '单号'
  70. },
  71. {
  72. field: 'indicatorNumber',
  73. title: '指标文号'
  74. },
  75. {
  76. field: 'businessUnitName',
  77. title: '业务股室'
  78. },
  79. {
  80. field: 'capitalTypeName',
  81. title: '资金性质'
  82. },
  83. {
  84. field: 'functionTypeName',
  85. title: '功能分类'
  86. },
  87. {
  88. field: 'itemType',
  89. title: '项目分类'
  90. },
  91. {
  92. field: 'printFlag',
  93. title: '打印状态'
  94. },
  95. {
  96. field: 'quotaSumMoney',
  97. title: '金额'
  98. },
  99. {
  100. field: 'money',
  101. title: '录入金额'
  102. }],
  103. onPostBody: function () {
  104. addQuotaTableSubTotal();
  105. },
  106. onToggle: function (cardView) {
  107. addQuotaTableSubTotal();
  108. }
  109. });
  110. }
  111.  
  112. function addQuotaTableSubTotal() {
  113. var rows = $('#quotaTable').bootstrapTable('getData');
  114. if (rows.length > 0) {
  115. $("#quotaTotal").remove();
  116. var totalSumMoney = 0.00, entryTotalSumMoney = 0.00;
  117. for (var i = 0; i < rows.length; i++) {
  118. var money = parseFloat(rows[i].quotaSumMoney == "" || rows[i].quotaSumMoney == undefined ? "0.00" : rows[i].quotaSumMoney);
  119. var entrymoney = parseFloat(rows[i].money == "" || rows[i].money == undefined ? "0.00" : rows[i].money);
  120. totalSumMoney = totalSumMoney + money;
  121. entryTotalSumMoney = entryTotalSumMoney + entrymoney;
  122. }
  123. totalSumMoney = totalSumMoney.toFixed(2);
  124. entryTotalSumMoney = entryTotalSumMoney.toFixed(2);
  125. var row = "<tr id='quotaTotal'>" +
  126. "<th></th>" +
  127. "<th><div class='th-inner'>小计</div></th>" +
  128. "<th></th><th></th><th></th><th></th><th></th><th></th><th><div class='th-inner'>" + totalSumMoney + "</div></th>" +
  129. "<th><div class='th-inner'>" + entryTotalSumMoney + "</div></th>"
  130. "</tr>";
  131. $('#quotaTable thead').append(row);
  132. } else {
  133. $("#quotaTotal").remove();
  134. var row = "<tr id='quotaTotal'>" +
  135. "<th></th>" +
  136. "<th><div class='th-inner'>小计</div></th>" +
  137. "<th></th><th></th><th></th><th></th><th></th><th></th><th><div class='th-inner'>0.00</div></th><th><div class='th-inner'>0.00</div></th>"
  138. "</tr>";
  139. $('#quotaTable thead').append(row);
  140. }
  141. }
  142.  
  143. function query() {
  144. $('#quotaTable').bootstrapTable('refreshOptions', {pageNumber: 1});
  145. $('#quotaTable').bootstrapTable('refresh', {pageNumber: 1});
  146. }
  147.  
  148. //获取指标文号
  149. function openQuotaNumber() {
  150. layer.open({
  151. type: 2,
  152. title: "请选择指标文号",
  153. offset: 'rt',
  154. area: ['21%', '100%'],
  155. content: "/basis/indicatorNumber/treeView"
  156. });
  157. }
  158.  
  159. function inNumber(Id, Name) {
  160. $("#indicatorNumber").val(Name);
  161. }
  162.  
  163. //获取业务股室
  164. function openBusinessUnit() {
  165. layer.open({
  166. type: 2,
  167. title: "请选择业务股室",
  168. offset: 'rt',
  169. area: ['21%', '100%'],
  170. content: "/basis/basicBusinessOffice/treeViewWithCheckBox",
  171. id: "treeDiv",
  172. scrollbar: false,
  173. btn: ['确定', '关闭'],
  174. yes: function (index, layero) {
  175. var idArray = [], nameArray = [];
  176. var result = $("#treeDiv").find('iframe')[0].contentWindow.$('#deptTree').jstree(true).get_selected(true);
  177. if (result.length > 0) {
  178. $.each(result, function (i, data) {
  179. idArray.push(data.id);
  180. nameArray.push(data.text);
  181. });
  182. $('#businessUnit').val(idArray.join(","));
  183. $('#businessUnitName').val(nameArray.join(","));
  184. } else {
  185. $('#businessUnit').val("");
  186. $('#businessUnitName').val("");
  187. }
  188. layer.close(index);
  189. query();
  190. },
  191. btn2: function (index, layero) {
  192. layer.close(index);
  193. }
  194. });
  195. }
  196.  
  197. function loadBusiness(bId, bName) {
  198. $('#businessUnit').val(bId);
  199. $('#businessUnitName').val(bName);
  200. }
  201.  
  202. //获取预算单位
  203. function openBudgetUnit() {
  204. layer.open({
  205. type: 2,
  206. title: "请选择预算单位",
  207. offset: 'rt',
  208. area: ['21%', '100%'],
  209. content: "/basis/budgetUnit/treeView"
  210. });
  211. }
  212.  
  213. function loadBudgetUnit(unitId, unitName) {
  214. $('#budgetUnit').val(unitId);
  215. $('#budgetUnitName').val(unitName);
  216. }
  217.  
  218.  
  219. //获取功能分类
  220. function openFunctionType() {
  221. layer.open({
  222. type: 2,
  223. title: "请选择功能分类",
  224. offset: 'rt',
  225. area: ['21%', '100%'],
  226. content: "/basis/functionType/treeViewWithCheckBox",
  227. id: "treeDiv",
  228. scrollbar: false,
  229. btn: ['确定', '关闭'],
  230. yes: function (index, layero) {
  231. var idArray = [], nameArray = [];
  232. var result = $("#treeDiv").find('iframe')[0].contentWindow.$('#deptTree').jstree(true).get_selected(true);
  233. if (result.length > 0) {
  234. $.each(result, function (i, data) {
  235. idArray.push(data.id);
  236. nameArray.push(data.text);
  237. });
  238. $('#functionType').val(idArray.join(","));
  239. $('#functionTypeName').val(nameArray.join(","));
  240. } else {
  241. $('#functionType').val("");
  242. $('#functionTypeName').val("");
  243. }
  244. layer.close(index);
  245. query();
  246. },
  247. btn2: function (index, layero) {
  248. layer.close(index);
  249. }
  250. });
  251. }
  252.  
  253. function loadType(id, name) {
  254. $('#functionType').val(id);
  255. $('#functionTypeName').val(name);
  256. }
  257.  
  258.  
  259. //获取指标来源
  260. function openQuotaSource() {
  261. layer.open({
  262. type: 2,
  263. title: "请选择指标来源",
  264. offset: 'rt',
  265. area: ['21%', '100%'],
  266. content: "/basis/capitalSource/treeViewWithCheckBox",
  267. id: "treeDiv",
  268. scrollbar: false,
  269. btn: ['确定', '关闭'],
  270. yes: function (index, layero) {
  271. var idArray = [], nameArray = [];
  272. var result = $("#treeDiv").find('iframe')[0].contentWindow.$('#deptTree').jstree(true).get_selected(true);
  273. if (result.length > 0) {
  274. $.each(result, function (i, data) {
  275. idArray.push(data.id);
  276. nameArray.push(data.text);
  277. });
  278. $('#quotaSource').val(idArray.join(","));
  279. $('#quotaSourceName').val(nameArray.join(","));
  280. } else {
  281. $('#quotaSource').val("");
  282. $('#quotaSourceName').val("");
  283. }
  284. layer.close(index);
  285. query();
  286. },
  287. btn2: function (index, layero) {
  288. layer.close(index);
  289. }
  290. });
  291. }
  292.  
  293. function loadCapital(typeId, typeName) {
  294. $('#quotaSource').val(typeId);
  295. $('#quotaSourceName').val(typeName);
  296. }
  297.  
  298. //封装选中的行数据
  299. function selectValue() {
  300. var row = $('#quotaTable').bootstrapTable('getSelections');
  301. if (row.length == 0) {
  302. layer.msg("请选择一条数据");
  303. return;
  304. } else {
  305. if (row.length == 1) {
  306. return row;
  307. } else {
  308. layer.msg("只能选择一条数据");
  309. return;
  310. }
  311. }
  312. }
  313.  
  314.  
  315. //清空
  316. function clearVal() {
  317. $("#queryForm input").each(function (index) {
  318. $(this).val("");
  319. });
  320. query();
  321. }
  322.  
  323. //资金性质
  324. var openNOF = function () {
  325. layer.open({
  326. type: 2,
  327. title: "资金性质",
  328. offset: 'rt',
  329. area: ['21%', '100%'],
  330. content: "/basis/natureOfFunds/treeViewWithCheckBox",
  331. id: "treeDiv",
  332. scrollbar: false,
  333. btn: ['确定', '关闭'],
  334. yes: function (index, layero) {
  335. var idArray = [], nameArray = [];
  336. var result = $("#treeDiv").find('iframe')[0].contentWindow.$('#deptTree').jstree(true).get_selected(true);
  337. if (result.length > 0) {
  338. $.each(result, function (i, data) {
  339. idArray.push(data.id);
  340. nameArray.push(data.text);
  341. });
  342. $('#capitalType').val(idArray.join(","));
  343. $('#capitalTypeName').val(nameArray.join(","));
  344. } else {
  345. $('#capitalType').val("");
  346. $('#capitalTypeName').val("");
  347. }
  348. layer.close(index);
  349. query();
  350. },
  351. btn2: function (index, layero) {
  352. layer.close(index);
  353. }
  354.  
  355. });
  356. }
  357.  
  358. function loadNatureOfFunds(deptId, deptName) {
  359. $("#capitalType").val(deptId);
  360. $("#capitalTypeName").val(deptName);
  361. }
  362.  
  363.  
  364. //打印
  365. function print() {
  366. var rows = $('#quotaTable').bootstrapTable('getSelections');
  367. if (rows.length > 0) {
  368. var code = "";
  369. var billType = $("#billType").val();
  370. if (billType == "0") {
  371. code = "ystzs";
  372. } else if (billType == "1") {
  373. code = "yszjtzs";
  374. } else if (billType == "2") {
  375. code = "ystjtzs";
  376. }
  377. var ids = "";
  378. $.each(rows, function (i, row) {
  379. ids += "," + row['prId'];
  380. });
  381. if (ids != "") {
  382. ids = ids.substring(1);
  383. }
  384. layer.open({
  385. id: "printDiv",
  386. type: 2,
  387. title: "打印",
  388. area: ['100%', '100%'],
  389. content: "/basis/print/toPaper?code=" + code + "&ids=" + ids+"&doClose=doClose",
  390. btn: ['关闭','调整模板','打印','打印完成'],
  391. yes: function (index, layero) {
  392. layer.close(index);
  393. },
  394. btn2: function (index, layero) {
  395. $('#printDiv').find('iframe')[0].contentWindow.configPosition();
  396. return false;
  397. },
  398. btn3: function (index, layero) {
  399. $('#printDiv').find('iframe')[0].contentWindow.saveAndPrint();
  400. return false;
  401. },
  402. btn4: function (index, layero){
  403. // alert("打印完成!");
  404. var rows = $('#quotaTable').bootstrapTable('getSelections');
  405. var ids = "";
  406. $.each(rows, function (i, row) {
  407. ids += "," + row['prId'];
  408. });
  409. if (ids != "") {
  410. ids = ids.substring(1);
  411. }
  412. // alert(ids);
  413. $.ajax({
  414. cache : false,
  415. type : "POST",
  416. url :"/quota/budgetUnitBill/setPrintFlag",
  417. data:{
  418. ids:ids
  419. },
  420. async : false,
  421. success: function (data) {
  422. if (data.code == 0) {
  423. parent.layer.msg("打印成功");
  424. layer.close(index);
  425. query();
  426. } else {
  427. parent.layer.alert(data.msg)
  428. }
  429. }
  430. });
  431. }
  432. })
  433. //$("#printFrame").attr("src", "/basis/print/toPaper?code=" + code + "&ids=" + ids);
  434. } else {
  435. layer.msg("请至少选择一条数据");
  436. }
  437. }
  438.  
  439. $("#quotaTable").on("dbl-click-row.bs.table", function (row, $element, field) {
  440. var params = {};
  441. var masterKey = "prId";
  442. var rows = $('#quotaTable').bootstrapTable('getData');
  443. params["pageUrl"] = "quota/budgetUnitBill/budgetUnitBillPrintDetail";
  444. params["pageData"] = JSON.stringify($element);
  445. var url = "/common/detail/goPage?data=";
  446. var isFirst = false;
  447. var isLast = false;
  448. var currentIndex = 0;
  449. var currentMasterKey = $element[masterKey];
  450. var prids = new Array();
  451. $.each(rows, function (i, row) {
  452. prids[i] = row[masterKey];
  453. if (currentMasterKey == row[masterKey]) {
  454. currentIndex = i;
  455. }
  456. if (currentMasterKey == row[masterKey] && i == 0) {
  457. isFirst = true;
  458. isLast = false;
  459. } else if (currentMasterKey == row[masterKey] && i == (rows.length - 1)) {
  460. isFirst = false;
  461. isLast = true;
  462. }
  463. if (rows.length == 1) {
  464. isFirst = true;
  465. isLast = true;
  466. }
  467. });
  468. var cacheUrl="/common/detail/cacheData";
  469. $.ajax({
  470. cache : false,
  471. type : "POST",
  472. url :cacheUrl,data:{data:JSON.stringify(params)},
  473. async : false,
  474. success : function(data) {
  475. if(data.code==0){
  476. var uuid=data.uuid;
  477. layer.open({
  478. type: 2,
  479. id: "detailInfo",
  480. title: '列表详细信息',
  481. scrollbar: false,
  482. maxmin: false,
  483. shadeClose: false,
  484. area: ['50%', '85%'],
  485. content: url + uuid,
  486. btn: ['关闭', '上一个', '下一个'],
  487. yes: function (index, layero) {
  488. layer.close(index);
  489. },
  490. btn2: function (index, layero) {
  491. if (!isFirst) {
  492. isLast = false;
  493. var data = rows[currentIndex - 1];
  494. params["pageData"] = JSON.stringify(data);
  495. $.ajax({
  496. cache : false,
  497. type : "POST",
  498. url :cacheUrl,data:{data:JSON.stringify(params)},
  499. async : false,
  500. success : function(data) {
  501. if (data.code == 0) {
  502. var uuid=data.uuid;
  503. $("#detailInfo").find("iframe").eq(0).attr("src", url + uuid);
  504. }
  505. }
  506. });
  507. currentIndex--;
  508. if (currentIndex == 0) {
  509. isFirst = true;
  510. isLast = false;
  511. }
  512. }
  513. return false;
  514. },
  515. btn3: function (index, layero) {
  516. if (!isLast) {
  517. isFirst = false;
  518. var data = rows[currentIndex + 1];
  519. params["pageData"] = JSON.stringify(data);
  520. $.ajax({
  521. cache : false,
  522. type : "POST",
  523. url :cacheUrl,data:{data:JSON.stringify(params)},
  524. async : false,
  525. success : function(data) {
  526. if (data.code == 0) {
  527. var uuid=data.uuid;
  528. $("#detailInfo").find("iframe").eq(0).attr("src", url + uuid);
  529. }
  530. }
  531. });
  532. currentIndex++;
  533. if (currentIndex == (rows.length - 1)) {
  534. isFirst = false;
  535. isLast = true;
  536. }
  537. }
  538. return false;
  539. }
  540. });
  541. }
  542. }
  543. });
  544. /* layer.open({
  545. type: 2,
  546. id: "detailInfo",
  547. title: '列表详情信息',
  548. scrollbar: false,
  549. maxmin: false,
  550. shadeClose: false,
  551. area: ['70%', '80%'],
  552. content: url + encodeURIComponent(JSON.stringify(params)),
  553. btn: ['关闭', '上一个', '下一个'],
  554. yes: function (index, layero) {
  555. layer.close(index);
  556. },
  557. btn2: function (index, layero) {
  558. if (!isFirst) {
  559. var data = rows[currentIndex - 1];
  560. params["pageData"] = JSON.stringify(data);
  561. $("#detailInfo").find("iframe").eq(0).attr("src", url + encodeURIComponent(JSON.stringify(params)));
  562. currentIndex--;
  563. if (currentIndex == 0) {
  564. isFirst = true;
  565. isLast = false;
  566. }
  567. }
  568. if (isLast) {
  569. isLast = false;
  570. }
  571. return false;
  572. },
  573. btn3: function (index, layero) {
  574. if (!isLast) {
  575. var data = rows[currentIndex + 1];
  576. params["pageData"] = JSON.stringify(data);
  577. $("#detailInfo").find("iframe").eq(0).attr("src", url + encodeURIComponent(JSON.stringify(params)));
  578. currentIndex++;
  579. if (currentIndex == (rows.length - 1)) {
  580. isFirst = false;
  581. isLast = true;
  582. }
  583. }
  584. if (isFirst) {
  585. isFirst = false;
  586. }
  587. return false;
  588. }
  589. });*/
  590. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement