month-salary-list.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <basic-container>
  3. <avue-crud
  4. ref="crud"
  5. v-bind="bindVal"
  6. v-on="onEvent"
  7. v-model="form"
  8. :page.sync="page"
  9. :before-open="handleBeforeOpen"
  10. :permission="permissionList"
  11. >
  12. <template slot="menuLeft">
  13. <el-button
  14. type="danger"
  15. size="small"
  16. icon="el-icon-delete"
  17. plain
  18. @click="handleDelete"
  19. >
  20. 删除
  21. </el-button>
  22. <el-button
  23. type="success"
  24. size="small"
  25. plain
  26. icon="el-icon-upload2"
  27. @click="handleImport"
  28. >
  29. 导入
  30. </el-button>
  31. <el-button
  32. type="warning"
  33. size="small"
  34. plain
  35. icon="el-icon-download"
  36. @click="handleExport"
  37. >
  38. 导出
  39. </el-button>
  40. <el-button
  41. type="primary"
  42. size="small"
  43. plain
  44. >
  45. 引用当月研发人员名单
  46. </el-button>
  47. <print-table-btn @click="printTable" />
  48. <div>
  49. <year-month-select v-model="params.yearAndMonth"></year-month-select>
  50. </div>
  51. </template>
  52. <!-- <div v-for="key of watchUpdateKey" :slot="key" slot-scope="scope" :key="key">
  53. <updated-text v-if="scope.row[key+'Edit'] === 1" :text="scope.row[key]"></updated-text>
  54. <span v-else>{{ scope.row[key] }}</span>
  55. </div> -->
  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. </basic-container>
  67. </template>
  68. <script>
  69. import { getLastMonthData } from "@/api/basicResource/technicianMonthAvgSales";
  70. import {exportBloByPost} from "@/api/common";
  71. import YearMonthSelect from "@/components/year-month-select";
  72. import UpdatedText from "@/components/updated-text";
  73. import UploadExcelDialog from "@/components/upload-excel-dialog";
  74. import moment from "moment";
  75. import {getToken} from "@/util/auth";
  76. import {downloadXls} from "@/util/util";
  77. import Decimal from "decimal.js";
  78. import PrintTableBtn from "@/components/print-table-btn";
  79. import WideTablePrinter from '@/components/print-wide-table'
  80. export default window.$crudCommon({
  81. components: {
  82. YearMonthSelect,
  83. UpdatedText,
  84. UploadExcelDialog,
  85. WideTablePrinter,
  86. PrintTableBtn
  87. },
  88. data() {
  89. return {
  90. params: {
  91. yearAndMonth: moment(new Date()).format('yyyyMM'),
  92. },
  93. operateType: '',
  94. watchUpdateKey: ["averageMonthlySalary", "pensionInsurance", "medicalInsurance", "unemploymentInsurance", "injuryInsurance", "maternityInsurance", "providentFund"],
  95. beforeUpdatedData: {},
  96. updatedFormData: {},
  97. wideTableColumns: [],
  98. printTitle: "",
  99. };
  100. },
  101. watch: {
  102. 'params.yearAndMonth'(newVal) {
  103. this.page.currentPage = 1;
  104. this.getList(this.page);
  105. }
  106. },
  107. created() {
  108. let newOption = { ...this.option };
  109. // 姓名下拉框,设置监听事件
  110. newOption.column.forEach(item => {
  111. if (item.prop == "name") {
  112. item.change = ({ item }) => {
  113. if (!!item) {
  114. this.form = {
  115. ...this.form,
  116. name: item.name,
  117. number: item.number,
  118. identityCard: item.identityCard,
  119. department: item.department,
  120. personnelType: item.personnelType,
  121. };
  122. }
  123. }
  124. }
  125. });
  126. this.option = { ...newOption };
  127. },
  128. methods: {
  129. handleBeforeOpen(done, type) {
  130. this.operateType = type;
  131. this.beforeUpdatedData = { ...this.form };
  132. this.option.column.forEach(item => {
  133. if (item.prop == "name") {
  134. item.dicUrl = '/api/kd-scientific/technician/page';
  135. item.dicQuery.yearAndMonth = this.params.yearAndMonth;
  136. }
  137. });
  138. done();
  139. },
  140. getFormData() {
  141. if (this.operateType === 'edit') {
  142. return this.updatedFormData
  143. }
  144. return this.form;
  145. },
  146. updateBefore(loading, callback) {
  147. let updatedData = {};
  148. this.watchUpdateKey.forEach(key => {
  149. if (Number(this.form[key]) != Number(this.beforeUpdatedData[key])) {
  150. updatedData[key] = this.form[key];
  151. }
  152. });
  153. this.updatedFormData = {
  154. technicianId: this.form.technicianId,
  155. yearAndMonth: this.params.yearAndMonth,
  156. ...updatedData
  157. };
  158. callback && callback();
  159. },
  160. getDelParams(row) {
  161. return [{ yearAndMonth: this.params.yearAndMonth, technicianId: row.technicianId }]
  162. },
  163. getBatchDelParams() {
  164. let delArr = [];
  165. this.data.forEach(item => {
  166. if (this.ids.indexOf(item.id) > -1) {
  167. delArr.push({ yearAndMonth: this.params.yearAndMonth, technicianId: item.technicianId });
  168. }
  169. });
  170. return delArr;
  171. },
  172. handleImport() {
  173. let excelParams = { yearAndMonth: this.params.yearAndMonth };
  174. this.$refs.uploadExcelDialog.open('/api/kd-scientific/salary/import', excelParams);
  175. },
  176. uploadAfter() {
  177. this.page.currentPage = 1;
  178. this.getList(this.page);
  179. },
  180. handleExport() {
  181. exportBloByPost(`/api/kd-scientific/salary/export-salary?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
  182. downloadXls(res.data, `技术人员${this.params.yearAndMonth}年度平均工资.xlsx`);
  183. });
  184. },
  185. handleReadyLastMonData() {
  186. this.$confirm("确认读取上年度工资明细吗?", "提示", {
  187. confirmButtonText: "确定",
  188. cancelButtonText: "取消",
  189. type: "warning"
  190. }).then(() => {
  191. getLastMonthData({ yearAndMonth: this.params.yearAndMonth}).then(res => {
  192. let data = res.data;
  193. if (data.success) {
  194. this.$message.success('读取成功!');
  195. this.page.currentPage = 1;
  196. this.getList(this.page);
  197. }
  198. });
  199. });
  200. },
  201. printTable(isLandscape) {
  202. this.wideTableColumns = this.$refs.crud.columnOption;
  203. this.printTitle = `技术人员${this.params.yearAndMonth}年度平均工资`;
  204. this.$nextTick(() => {
  205. this.$refs.printWideTable.printTable(isLandscape);
  206. });
  207. },
  208. },
  209. }, {
  210. // 模块路径
  211. name: 'yfCostManage/basicDataSetting/monthSalaryList',
  212. res: ({ data }) => {
  213. data.records = data.records.map(item => {
  214. // 处理id为空的时候,批量清除数据无法获取数据的问题
  215. item.id = !item.id ? (item.number || item.identityCard) : item.id;
  216. item.averageMonthlySalary = Number(item.averageMonthlySalary || 0).toFixed(2);
  217. item.pensionInsurance = Number(item.pensionInsurance || 0).toFixed(2);
  218. item.medicalInsurance = Number(item.medicalInsurance || 0).toFixed(2);
  219. item.unemploymentInsurance = Number(item.unemploymentInsurance || 0).toFixed(2);
  220. item.injuryInsurance = Number(item.injuryInsurance || 0).toFixed(2);
  221. item.maternityInsurance = Number(item.maternityInsurance || 0).toFixed(2);
  222. item.providentFund = Number(item.providentFund || 0).toFixed(2);
  223. let pensionInsurance = new Decimal(item.pensionInsurance);
  224. let medicalInsurance = new Decimal(item.medicalInsurance);
  225. let unemploymentInsurance = new Decimal(item.unemploymentInsurance);
  226. let injuryInsurance = new Decimal(item.injuryInsurance);
  227. let maternityInsurance = new Decimal(item.maternityInsurance);
  228. let providentFund = new Decimal(item.providentFund);
  229. // 社保合计
  230. let socialInsurance = pensionInsurance.add(medicalInsurance).add(unemploymentInsurance).add(injuryInsurance).add(maternityInsurance);
  231. // 总计
  232. let total = socialInsurance.add(providentFund);
  233. item.socialInsurance = socialInsurance.toFixed(2);
  234. item.total = total.toFixed(2);
  235. return item;
  236. });
  237. return data;
  238. },
  239. });
  240. </script>