gx-auxiliary-sum-list.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <basic-container>
  3. <avue-crud
  4. v-bind="bindVal"
  5. v-on="onEvent"
  6. v-model="form"
  7. :page.sync="page"
  8. >
  9. <template slot="menuLeft">
  10. <el-button
  11. type="warning"
  12. size="small"
  13. plain
  14. icon="el-icon-download"
  15. @click="handleExport"
  16. >
  17. 导出
  18. </el-button>
  19. <print-table-btn @click="printTable" />
  20. <div style="display: flex; align-items: center;">
  21. <year-month-select v-model="params.yearAndMonth" :showAllYear="false"></year-month-select>
  22. </div>
  23. </template>
  24. </avue-crud>
  25. <WideTablePrinter
  26. ref="printWideTable"
  27. :columns="wideTableColumns"
  28. :data="data"
  29. :print-title="printTitle"
  30. :rows-per-page="30"
  31. :default-landscape="true"
  32. />
  33. </basic-container>
  34. </template>
  35. <script>
  36. import YearMonthSelect from "@/components/year-month-select";
  37. import {exportBlob} from "@/api/common";
  38. import {getToken} from "@/util/auth";
  39. import {downloadXls} from "@/util/util";
  40. import moment from "moment";
  41. import Decimal from "decimal.js";
  42. export default window.$crudCommon({
  43. components: {
  44. YearMonthSelect,
  45. },
  46. data() {
  47. return {
  48. params: {
  49. yearAndMonth: moment(new Date()).format('YYYYMM'),
  50. },
  51. wideTableColumns: [],
  52. printTitle: "",
  53. };
  54. },
  55. watch: {
  56. 'params.yearAndMonth'(newVal) {
  57. this.page.currentPage = 1;
  58. this.getList(this.page);
  59. }
  60. },
  61. methods: {
  62. handleExport() {
  63. exportBlob(`/api/kd-scientific/export?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
  64. downloadXls(res.data, `${this.params.yearAndMonth}高新研发费用辅助账汇总表.xlsx`);
  65. });
  66. },
  67. /**
  68. * 打印表格
  69. * @param isLandscape 是否横向打印
  70. */
  71. printTable(isLandscape) {
  72. this.wideTableColumns = this.$refs.crud.columnOption;
  73. this.printTitle = `${this.params.yearAndMonth}高新研发费用辅助账汇总表.xlsx`;
  74. this.$nextTick(() => {
  75. this.$refs.printWideTable.printTable(isLandscape);
  76. })
  77. },
  78. },
  79. }, {
  80. // 模块路径
  81. name: 'externalReports/gxAuxiliarySumList',
  82. res: ({ data }) => {
  83. data.records = data.records.map(item => {
  84. item.ryrgTotal = item.ryrgTotal.toFixed(2);
  85. item.zjtrTotal = item.zjtrTotal.toFixed(2);
  86. item.zjfyycqdtfyTotal = item.zjfyycqdtfyTotal.toFixed(2);
  87. item.sjfTotal = item.sjfTotal.toFixed(2);
  88. item.wxzctxTotal = item.wxzctxTotal.toFixed(2);
  89. item.zbtsfyysyfyTotal = item.zbtsfyysyfyTotal.toFixed(2);
  90. item.qtfyTotal = item.qtfyTotal.toFixed(2);
  91. item.qtfyLimit = item.qtfyLimit.toFixed(2);
  92. item.qtfyAdjust = item.qtfyAdjust.toFixed(2);
  93. item.wwyfTotal = item.wwyfTotal.toFixed(2);
  94. // 合计
  95. let amount = 0;
  96. amount = new Decimal(item.ryrgTotal)
  97. .add(new Decimal(item.zjtrTotal))
  98. .add(new Decimal(item.zjfyycqdtfyTotal))
  99. .add(new Decimal(item.sjfTotal))
  100. .add(new Decimal(item.wxzctxTotal))
  101. .add(new Decimal(item.zbtsfyysyfyTotal))
  102. .add(new Decimal(item.qtfyAdjust))
  103. .add(new Decimal(item.wwyfTotal));
  104. item.amount = amount;
  105. return item;
  106. });
  107. return data;
  108. },
  109. });
  110. </script>