payment_compare.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. $(document).ready(function() {
  2. autoFlashHeight();
  3. class BillsObj {
  4. constructor() {
  5. this.spread = SpreadJsObj.createNewSpread($('#bills-spread')[0]);
  6. this.sheet = this.spread.getActiveSheet();
  7. this.treeSetting = {
  8. id: 'tree_id',
  9. pid: 'tree_pid',
  10. order: 'tree_order',
  11. level: 'tree_level',
  12. rootId: -1,
  13. autoExpand: 3,
  14. markExpandKey: 'bills-expand',
  15. markExpandSubKey: window.location.pathname.split('/')[2],
  16. calcFields: ['cur_tp', 'pre_tp', 'end_tp'],
  17. };
  18. this.spreadSetting = {
  19. baseCols: [
  20. {title: '编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 70, formatter: '@'},
  21. {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 185, formatter: '@'},
  22. {title: '规格', colSpan: '1', rowSpan: '2', field: 'spec', hAlign: 0, width: 150, formatter: '@'},
  23. {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@', cellType: 'unit'},
  24. {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number'},
  25. ],
  26. extraCols: [
  27. {title: '%s|数量', colSpan: '2|1', rowSpan: '1|1', field: '{%s}_qty{%d}', hAlign: 2, width: 60, type: 'Number', },
  28. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: '{%s}_tp{%d}', hAlign: 2, width: 60, type: 'Number', },
  29. ],
  30. emptyRows: 3,
  31. headRows: 2,
  32. headRowHeight: [25, 25],
  33. defaultRowHeight: 21,
  34. headerFont: '12px 微软雅黑',
  35. font: '12px 微软雅黑',
  36. };
  37. this.tree = createNewPathTree('ledger', this.treeSetting);
  38. this.ckBillsSpread = window.location.pathname + '-billsSelect';
  39. this.initSpread();
  40. }
  41. refreshSpreadSetting(roles) {
  42. this.spreadSetting.cols = [];
  43. for (const col of this.spreadSetting.baseCols) {
  44. this.spreadSetting.cols.push(col);
  45. }
  46. // todo 根据参与审批的人加载数据
  47. }
  48. initSpread(roles = []) {
  49. this.refreshSpreadSetting(roles);
  50. SpreadJsObj.initSheet(this.sheet, this.spreadSetting);
  51. }
  52. loadData(datas, roles, history) {
  53. // todo 整理数据
  54. this.initSpread(roles);
  55. this.tree.loadDatas(datas);
  56. treeCalc.calculateAll(this.tree);
  57. SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Tree, this.tree);
  58. SpreadJsObj.loadTopAndSelect(this.sheet, this.ckBillsSpread);
  59. }
  60. }
  61. const billsObj = new BillsObj();
  62. // 加载安全生产费数据
  63. postData('load', { filter: 'bills;audit;history' }, function(result) {
  64. billsObj.loadData(result.bills);
  65. });
  66. // 导航Menu
  67. $.subMenu({
  68. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  69. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  70. key: 'menu.1.0.0',
  71. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  72. callback: function (info) {
  73. if (info.mini) {
  74. $('.panel-title').addClass('fluid');
  75. $('#sub-menu').removeClass('panel-sidebar');
  76. } else {
  77. $('.panel-title').removeClass('fluid');
  78. $('#sub-menu').addClass('panel-sidebar');
  79. }
  80. autoFlashHeight();
  81. billsObj.spread.refresh();
  82. }
  83. });
  84. // 显示层次
  85. (function (select, sheet) {
  86. $(select).click(function () {
  87. if (!sheet.zh_tree) return;
  88. const tag = $(this).attr('tag');
  89. const tree = sheet.zh_tree;
  90. setTimeout(() => {
  91. showWaitingView();
  92. switch (tag) {
  93. case "1":
  94. case "2":
  95. case "3":
  96. case "4":
  97. tree.expandByLevel(parseInt(tag));
  98. SpreadJsObj.refreshTreeRowVisible(sheet);
  99. break;
  100. case "last":
  101. tree.expandByCustom(() => { return true; });
  102. SpreadJsObj.refreshTreeRowVisible(sheet);
  103. break;
  104. }
  105. closeWaitingView();
  106. }, 100);
  107. });
  108. })('a[name=showLevel]', billsObj.sheet);
  109. });