person-cost.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. ref="crud"
  15. v-bind="bindVal"
  16. v-on="onEvent"
  17. v-model="form"
  18. :page.sync="page"
  19. :before-open="handleBeforeOpen"
  20. >
  21. <template slot="menuLeft">
  22. <el-button
  23. v-if="!isSelAnnual"
  24. type="danger"
  25. size="small"
  26. icon="el-icon-delete"
  27. plain
  28. @click="handleDelete"
  29. >
  30. 删 除
  31. </el-button>
  32. <el-button
  33. v-if="!isSelAnnual"
  34. type="success"
  35. size="small"
  36. plain
  37. icon="el-icon-upload2"
  38. @click="handleImport"
  39. >
  40. 导入
  41. </el-button>
  42. <el-button
  43. type="warning"
  44. size="small"
  45. plain
  46. icon="el-icon-download"
  47. @click="handleExport"
  48. >
  49. 导出
  50. </el-button>
  51. <print-table-btn @click="printTable" />
  52. </template>
  53. <template slot="technicianIdForm">
  54. <project-person-select v-model="form.technicianId" valueKey="id" :startDate="projectStartMonth" />
  55. </template>
  56. </avue-crud>
  57. <upload-excel-dialog ref="uploadExcelDialog" templateKey="预算-人员人工费用" templateName="预算-人员人工费用-导入模板" :uploadAfter="uploadAfter"/>
  58. <WideTablePrinter
  59. ref="printWideTable"
  60. :columns="wideTableColumns"
  61. :data="data"
  62. :print-title="printTitle"
  63. :rows-per-page="30"
  64. :default-landscape="true"
  65. />
  66. </div>
  67. </template>
  68. <script>
  69. import {exportBloByPost} from "@/api/common";
  70. import UploadExcelDialog from "@/components/upload-excel-dialog";
  71. import projectSelect from "@/components/project-select";
  72. import projectPersonSelect from "@/components/project-person-select";
  73. import {getToken} from "@/util/auth";
  74. import {downloadXls} from "@/util/util";
  75. import Decimal from "decimal.js";
  76. import moment from "moment";
  77. export default window.$crudCommon({
  78. props: {
  79. projectId: [String, Number]
  80. },
  81. components: {
  82. projectSelect,
  83. projectPersonSelect,
  84. UploadExcelDialog,
  85. },
  86. data() {
  87. return {
  88. params: {
  89. xmId: ''
  90. },
  91. selProject: {},
  92. wideTableColumns: [],
  93. printTitle: "",
  94. projectStartMonth: ""
  95. };
  96. },
  97. created() {
  98. this.params.xmId = this.projectId;
  99. this.option.height = window.innerHeight - 340;
  100. },
  101. watch: {
  102. "params.xmId"() {
  103. this.page.currentPage = 1;
  104. this.getList(this.page);
  105. }
  106. },
  107. methods: {
  108. handleBeforeOpen(done, type) {
  109. if (!this.params.xmId) {
  110. this.$message.warning("请选择项目!");
  111. return;
  112. }
  113. done();
  114. },
  115. getList() {
  116. if (!this.params.xmId) {
  117. return;
  118. }
  119. this.loadData();
  120. },
  121. getFormData() {
  122. return { ...this.form, xmId: this.params.xmId }
  123. },
  124. handleProjectChange(data) {
  125. this.selProject = data;
  126. this.projectStartMonth = moment(data.xmkssj).format("yyyyMM");
  127. },
  128. handleImport() {
  129. if (!this.params.xmId) {
  130. this.$message.warning("请选择项目!");
  131. return;
  132. }
  133. let excelParams = {xmId: this.params.xmId };
  134. this.$refs.uploadExcelDialog.open('/api/kd-scientific/ys-ryrgfy/import', excelParams);
  135. },
  136. uploadAfter() {
  137. this.page.currentPage = 1;
  138. this.getList(this.page);
  139. },
  140. handleExport() {
  141. exportBloByPost(`/api/kd-scientific/ys-ryrgfy/export?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
  142. downloadXls(res.data, `${this.selProject.xmmc}人员人工费用.xlsx`);
  143. });
  144. },
  145. /**
  146. * 打印表格
  147. * @param isLandscape 是否横向打印
  148. */
  149. printTable(isLandscape) {
  150. this.wideTableColumns = this.$refs.crud.columnOption;
  151. this.printTitle = `${this.selProject.xmmc}人员人工费用`;
  152. this.$nextTick(() => {
  153. this.$refs.printWideTable.printTable(isLandscape);
  154. })
  155. },
  156. },
  157. }, {
  158. // 模块路径
  159. name: 'projectManage/personCost',
  160. res: ({ data }) => {
  161. data.records = data.records.map(item => {
  162. let zzsc = new Decimal(item.zzsc || 0);
  163. let pjrgfy = new Decimal(item.pjrgfy || 0);
  164. item.technicianId = item.technicianId.toString();
  165. item.name = item.technician.name;
  166. item.number = item.technician.number;
  167. item.idCard = item.technician.idCard;
  168. item.pjrgfy = (item.pjrgfy || 0).toFixed(2);
  169. item.total = zzsc.mul(pjrgfy).toFixed(2);
  170. item.isWp = item.nature === '在职' ? '是' : '否';
  171. return item;
  172. });
  173. return data;
  174. },
  175. });
  176. </script>