zztl-cost.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <div>
  3. <div style="margin-top: 6px;">
  4. <el-form :inline="true">
  5. <el-form-item label="研发项目名称">
  6. <project-select v-model="params.xmId" @change="handleProjectChange"></project-select>
  7. </el-form-item>
  8. <el-form-item label="研发项目编号">
  9. {{ selProject.xmbh }}
  10. </el-form-item>
  11. </el-form>
  12. </div>
  13. <avue-crud
  14. v-bind="bindVal"
  15. v-on="onEvent"
  16. v-model="form"
  17. :page.sync="page"
  18. :before-open="handleBeforeOpen"
  19. >
  20. <template slot="menuLeft">
  21. <el-button
  22. v-if="!isSelAnnual"
  23. type="danger"
  24. size="small"
  25. icon="el-icon-delete"
  26. plain
  27. @click="handleDelete"
  28. >
  29. 删 除
  30. </el-button>
  31. <el-button
  32. v-if="!isSelAnnual"
  33. type="success"
  34. size="small"
  35. plain
  36. icon="el-icon-upload2"
  37. @click="handleImport"
  38. >
  39. 导入
  40. </el-button>
  41. <el-button
  42. type="warning"
  43. size="small"
  44. plain
  45. icon="el-icon-download"
  46. @click="handleExport"
  47. >
  48. 导出
  49. </el-button>
  50. <print-table-btn @click="printTable" />
  51. </template>
  52. </avue-crud>
  53. <upload-excel-dialog ref="uploadExcelDialog" :uploadAfter="uploadAfter"/>
  54. <WideTablePrinter
  55. ref="printWideTable"
  56. :columns="wideTableColumns"
  57. :data="data"
  58. :print-title="printTitle"
  59. :rows-per-page="30"
  60. :default-landscape="true"
  61. />
  62. </div>
  63. </template>
  64. <script>
  65. import {exportBloByPost} from "@/api/common";
  66. import UploadExcelDialog from "@/components/upload-excel-dialog";
  67. import projectSelect from "@/components/project-select";
  68. import {getToken} from "@/util/auth";
  69. import {downloadXls} from "@/util/util";
  70. import Decimal from "decimal.js";
  71. export default window.$crudCommon({
  72. props: {
  73. projectId: [String, Number]
  74. },
  75. components: {
  76. UploadExcelDialog,
  77. projectSelect,
  78. },
  79. data() {
  80. return {
  81. params: {
  82. xmId: ''
  83. },
  84. selProject: {},
  85. wideTableColumns: [],
  86. printTitle: "",
  87. };
  88. },
  89. watch: {
  90. "params.xmId"() {
  91. this.page.currentPage = 1;
  92. this.getList(this.page);
  93. },
  94. },
  95. created() {
  96. this.params.xmId = this.projectId;
  97. this.option.height = window.innerHeight - 340;
  98. },
  99. methods: {
  100. handleBeforeOpen(done, type) {
  101. if (!this.params.xmId) {
  102. this.$message.warning("请选择项目!");
  103. return;
  104. }
  105. done();
  106. },
  107. getList() {
  108. if (!this.params.xmId) {
  109. return;
  110. }
  111. this.loadData();
  112. },
  113. getFormData() {
  114. return { ...this.form, xmId: this.params.xmId }
  115. },
  116. handleProjectChange(data) {
  117. this.selProject = data;
  118. },
  119. handleImport() {
  120. if (!this.params.xmId) {
  121. this.$message.warning("请选择项目!");
  122. return;
  123. }
  124. let excelParams = { xmId: this.params.xmId };
  125. this.$refs.uploadExcelDialog.open('/api/kd-scientific/ys-zjtrfy/import', excelParams);
  126. },
  127. uploadAfter() {
  128. this.page.currentPage = 1;
  129. this.getList(this.page);
  130. },
  131. handleExport() {
  132. exportBloByPost(`/api/kd-scientific/ys-zjtrfy/export?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
  133. downloadXls(res.data, `${this.selProject.xmmc}直接投入费用.xlsx`);
  134. });
  135. },
  136. /**
  137. * 打印表格
  138. * @param isLandscape 是否横向打印
  139. */
  140. printTable(isLandscape) {
  141. this.wideTableColumns = this.$refs.crud.columnOption;
  142. this.printTitle = `${this.selProject.xmmc}直接投入费用`;
  143. this.$nextTick(() => {
  144. this.$refs.printWideTable.printTable(isLandscape);
  145. })
  146. },
  147. },
  148. }, {
  149. // 模块路径
  150. name: 'projectManage/zztlCost',
  151. res: ({ data }) => {
  152. data.records = data.records.map(item => {
  153. item.yongLiang = item.yongLiang === -1 ? '' : (item.yongLiang).toFixed(2);
  154. item.danJia = item.danJia === -1 ? '' : (item.danJia).toFixed(2);
  155. item.ysje = item.ysje === -1 ? '' : (item.ysje).toFixed(2);
  156. item.zlfyys = item.zlfyys === -1 ? '' : (item.zlfyys).toFixed(2);
  157. if (item.yongLiang && item.danJia) {
  158. item.wzysje = new Decimal(item.yongLiang).mul(item.danJia);
  159. }
  160. return item;
  161. });
  162. return data;
  163. },
  164. });
  165. </script>