person-cost.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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="technicianId" slot-scope="scope">
  54. <span>{{ scope.row.name }}</span>
  55. </template>
  56. </avue-crud>
  57. <upload-excel-dialog ref="uploadExcelDialog" :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 {getToken} from "@/util/auth";
  73. import {downloadXls} from "@/util/util";
  74. import Decimal from "decimal.js";
  75. import moment from "moment";
  76. export default window.$crudCommon({
  77. props: {
  78. projectId: [String, Number]
  79. },
  80. components: {
  81. projectSelect,
  82. UploadExcelDialog,
  83. },
  84. data() {
  85. return {
  86. params: {
  87. xmId: ''
  88. },
  89. selProject: {},
  90. wideTableColumns: [],
  91. printTitle: "",
  92. };
  93. },
  94. created() {
  95. this.params.xmId = this.projectId;
  96. this.option.height = window.innerHeight - 340;
  97. },
  98. watch: {
  99. "params.xmId"() {
  100. this.page.currentPage = 1;
  101. this.getList(this.page);
  102. }
  103. },
  104. methods: {
  105. handleBeforeOpen(done, type) {
  106. if (!this.params.xmId) {
  107. this.$message.warning("请选择项目!");
  108. return;
  109. }
  110. this.option.column.forEach(item => {
  111. if (item.prop == "technicianId") {
  112. let startDate = this.selProject.xmkssj || new Date();
  113. let endDate = this.selProject.xmjssj || new Date();
  114. item.dicUrl = '/api/kd-scientific/technician/page/date-interval';
  115. item.dicQuery.startDate = moment(startDate).format("yyyyMM");
  116. item.dicQuery.endDate = moment(endDate).format("yyyyMM");
  117. }
  118. });
  119. done();
  120. },
  121. getList() {
  122. if (!this.params.xmId) {
  123. return;
  124. }
  125. this.loadData();
  126. },
  127. getFormData() {
  128. return { ...this.form, xmId: this.params.xmId }
  129. },
  130. handleProjectChange(data) {
  131. this.selProject = data;
  132. },
  133. handleImport() {
  134. let excelParams = {xmId: this.params.xmId };
  135. this.$refs.uploadExcelDialog.open('/api/kd-scientific/ys-ryrgfy/import', excelParams);
  136. },
  137. uploadAfter() {
  138. this.page.currentPage = 1;
  139. this.getList(this.page);
  140. },
  141. handleExport() {
  142. exportBloByPost(`/api/kd-scientific/ys-ryrgfy/export?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
  143. downloadXls(res.data, `${this.selProject.xmmc}人员人工费用.xlsx`);
  144. });
  145. },
  146. /**
  147. * 打印表格
  148. * @param isLandscape 是否横向打印
  149. */
  150. printTable(isLandscape) {
  151. this.wideTableColumns = this.$refs.crud.columnOption;
  152. this.printTitle = `${this.selProject.xmmc}人员人工费用`;
  153. this.$nextTick(() => {
  154. this.$refs.printWideTable.printTable(isLandscape);
  155. })
  156. },
  157. },
  158. }, {
  159. // 模块路径
  160. name: 'projectManage/personCost',
  161. res: ({ data }) => {
  162. data.records = data.records.map(item => {
  163. let zzsc = new Decimal(item.zzsc || 0);
  164. let pjrgfy = new Decimal(item.pjrgfy || 0);
  165. item.technicianId = item.technician.id;
  166. item.name = item.technician.name;
  167. item.number = item.technician.number;
  168. item.idCard = item.technician.idCard;
  169. item.pjrgfy = (item.pjrgfy || 0).toFixed(2);
  170. item.total = zzsc.mul(pjrgfy).toFixed(2);
  171. item.isWp = item.nature === '在职' ? '是' : '否';
  172. return item;
  173. });
  174. return data;
  175. },
  176. });
  177. </script>