zztl-cost.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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" templateKey="研发项目管理-预算编制-直接投入费用" :uploadAfter="uploadAfter"/>
  54. </div>
  55. </template>
  56. <script>
  57. import {exportBloByPost} from "@/api/common";
  58. import UploadExcelDialog from "@/components/upload-excel-dialog";
  59. import projectSelect from "@/components/project-select";
  60. import {getToken} from "@/util/auth";
  61. import {downloadXls} from "@/util/util";
  62. import Decimal from "decimal.js";
  63. export default window.$crudCommon({
  64. props: {
  65. projectId: [String, Number],
  66. projectData: Object,
  67. },
  68. components: {
  69. UploadExcelDialog,
  70. projectSelect,
  71. },
  72. data() {
  73. return {
  74. params: {
  75. xmId: ''
  76. },
  77. selProject: {},
  78. };
  79. },
  80. watch: {
  81. projectId(newVal, oldVal) {
  82. this.params.xmId = newVal;
  83. if (oldVal) {
  84. this.selProject = this.projectData;
  85. }
  86. },
  87. "params.xmId"() {
  88. this.page.currentPage = 1;
  89. this.getList(this.page);
  90. },
  91. },
  92. computed: {
  93. pageTitle() {
  94. return `${this.selProject.xmmc}直接投入费用`;
  95. }
  96. },
  97. created() {
  98. this.params.xmId = this.projectId;
  99. this.option.height = window.innerHeight - 340;
  100. },
  101. methods: {
  102. handleBeforeOpen(done, type) {
  103. if (!this.params.xmId) {
  104. this.$message.warning("请选择项目!");
  105. return;
  106. }
  107. done();
  108. },
  109. getList() {
  110. if (!this.params.xmId) {
  111. return;
  112. }
  113. this.loadData();
  114. },
  115. getFormData() {
  116. return { ...this.form, xmId: this.params.xmId }
  117. },
  118. handleProjectChange(data) {
  119. this.selProject = data;
  120. this.$emit("change", data);
  121. },
  122. handleImport() {
  123. if (!this.params.xmId) {
  124. this.$message.warning("请选择项目!");
  125. return;
  126. }
  127. let excelParams = { xmId: this.params.xmId };
  128. this.$refs.uploadExcelDialog.open('/api/kd-scientific/ys-zjtrfy/import', excelParams);
  129. },
  130. uploadAfter() {
  131. this.page.currentPage = 1;
  132. this.getList(this.page);
  133. },
  134. handleExport() {
  135. exportBloByPost(`/api/kd-scientific/ys-zjtrfy/export?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
  136. downloadXls(res.data, `${this.pageTitle}.xlsx`);
  137. });
  138. },
  139. /**
  140. * 打印表格
  141. * @param isLandscape 是否横向打印
  142. */
  143. printTable(isLandscape) {
  144. this.$emit("printClick", {
  145. column: this.printOption.column,
  146. data: this.data,
  147. pageTitle: this.pageTitle,
  148. zoom: 90
  149. });
  150. },
  151. },
  152. }, {
  153. // 模块路径
  154. name: 'projectManage/zztlCost',
  155. res: ({ data }) => {
  156. data.records = data.records.map(item => {
  157. item.yongLiang = item.yongLiang === -1 ? '' : (item.yongLiang).toFixed(2);
  158. item.danJia = item.danJia === -1 ? '' : (new Decimal(item.danJia).div(new Decimal(10000))).toFixed(4);
  159. item.ysje = item.ysje === -1 ? '' : (new Decimal(item.ysje).div(new Decimal(10000))).toFixed(4);
  160. item.zlfyys = item.zlfyys === -1 ? '' : (new Decimal(item.zlfyys).div(new Decimal(10000))).toFixed(4);
  161. if (item.yongLiang && item.danJia) {
  162. item.wzysje = new Decimal(item.yongLiang).mul(item.danJia).toFixed(4);
  163. }
  164. return item;
  165. });
  166. return data;
  167. },
  168. });
  169. </script>