month-salary-list.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. @click="handleReadyLastMonData"
  45. >
  46. 引用当月研发人员名单
  47. </el-button>
  48. <print-table-btn @click="printTable" />
  49. <div>
  50. <year-month-select v-model="params.yearAndMonth" :showAllYear="false"></year-month-select>
  51. </div>
  52. </template>
  53. <!-- <div v-for="key of watchUpdateKey" :slot="key" slot-scope="scope" :key="key">
  54. <updated-text v-if="scope.row[key+'Edit'] === 1" :text="scope.row[key]"></updated-text>
  55. <span v-else>{{ scope.row[key] }}</span>
  56. </div> -->
  57. </avue-crud>
  58. <upload-excel-dialog ref="uploadExcelDialog" templateKey="每月工资信息" templateName="每月工资信息-导入模板" :uploadAfter="uploadAfter"/>
  59. <WideTablePrinter
  60. ref="printWideTable"
  61. :columns="wideTableColumns"
  62. :data="data"
  63. :print-title="printTitle"
  64. :rows-per-page="30"
  65. :default-landscape="true"
  66. />
  67. </basic-container>
  68. </template>
  69. <script>
  70. import { getLastMonthData } from "@/api/yfCostManage/basicDataSetting/monthSalaryList";
  71. import {exportBloByPost} from "@/api/common";
  72. import YearMonthSelect from "@/components/year-month-select";
  73. import UpdatedText from "@/components/updated-text";
  74. import UploadExcelDialog from "@/components/upload-excel-dialog";
  75. import moment from "moment";
  76. import {getToken} from "@/util/auth";
  77. import {downloadXls} from "@/util/util";
  78. import Decimal from "decimal.js";
  79. import PrintTableBtn from "@/components/print-table-btn";
  80. import WideTablePrinter from '@/components/print-wide-table'
  81. export default window.$crudCommon({
  82. components: {
  83. YearMonthSelect,
  84. UpdatedText,
  85. UploadExcelDialog,
  86. WideTablePrinter,
  87. PrintTableBtn
  88. },
  89. data() {
  90. return {
  91. params: {
  92. yearAndMonth: "",
  93. },
  94. operateType: '',
  95. watchUpdateKey: [
  96. "averageMonthlySalary",
  97. "pensionInsurance",
  98. "medicalInsurance",
  99. "unemploymentInsurance",
  100. "injuryInsurance",
  101. "maternityInsurance",
  102. "providentFund",
  103. "bonus",
  104. "benefit",
  105. "pensionInsuranceBc",
  106. "medicalInsuranceBc"
  107. ],
  108. beforeUpdatedData: {},
  109. updatedFormData: {},
  110. wideTableColumns: [],
  111. printTitle: "",
  112. };
  113. },
  114. watch: {
  115. 'params.yearAndMonth'(newVal) {
  116. this.page.currentPage = 1;
  117. this.getList(this.page);
  118. }
  119. },
  120. created() {
  121. let newOption = { ...this.option };
  122. // 姓名下拉框,设置监听事件
  123. newOption.column.forEach(item => {
  124. if (item.prop == "name") {
  125. item.change = ({ item }) => {
  126. if (!!item) {
  127. this.form = {
  128. ...this.form,
  129. name: item.name,
  130. number: item.number,
  131. idCard: item.idCard,
  132. department: item.department,
  133. personnelType: item.personnelType,
  134. };
  135. }
  136. }
  137. }
  138. });
  139. this.option = { ...newOption };
  140. },
  141. methods: {
  142. handleBeforeOpen(done, type) {
  143. this.operateType = type;
  144. this.beforeUpdatedData = { ...this.form };
  145. done();
  146. },
  147. getFormData() {
  148. if (this.operateType === 'edit') {
  149. return this.updatedFormData
  150. }
  151. return this.form;
  152. },
  153. updateBefore(loading, callback) {
  154. let updatedData = {};
  155. this.watchUpdateKey.forEach(key => {
  156. if (Number(this.form[key]) != Number(this.beforeUpdatedData[key])) {
  157. updatedData[key] = this.form[key];
  158. }
  159. });
  160. this.updatedFormData = {
  161. yearAndMonth: this.params.yearAndMonth,
  162. unicode: this.form.unicode,
  163. ...updatedData
  164. };
  165. callback && callback();
  166. },
  167. getDelParams(row) {
  168. return [{ yearAndMonth: this.params.yearAndMonth, unicode: row.unicode }]
  169. },
  170. getBatchDelParams() {
  171. let delArr = [];
  172. this.data.forEach(item => {
  173. if (this.ids.indexOf(item.id) > -1) {
  174. delArr.push({ yearAndMonth: this.params.yearAndMonth, unicode: item.unicode });
  175. }
  176. });
  177. return delArr;
  178. },
  179. handleImport() {
  180. let excelParams = { yearAndMonth: this.params.yearAndMonth };
  181. this.$refs.uploadExcelDialog.open('/api/kd-scientific/salary/import', excelParams);
  182. },
  183. uploadAfter() {
  184. this.page.currentPage = 1;
  185. this.getList(this.page);
  186. },
  187. handleExport() {
  188. exportBloByPost(`/api/kd-scientific/salary/export-salary?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
  189. downloadXls(res.data, `${this.params.yearAndMonth}工资明细.xlsx`);
  190. });
  191. },
  192. handleReadyLastMonData() {
  193. this.$confirm("确认引用单月研发人员名单吗?", "提示", {
  194. confirmButtonText: "确定",
  195. cancelButtonText: "取消",
  196. type: "warning"
  197. }).then(() => {
  198. getLastMonthData({ yearAndMonth: this.params.yearAndMonth}).then(res => {
  199. let data = res.data;
  200. if (data.success) {
  201. this.$message.success('读取成功!');
  202. this.page.currentPage = 1;
  203. this.getList(this.page);
  204. }
  205. });
  206. });
  207. },
  208. printTable(isLandscape) {
  209. this.wideTableColumns = this.$refs.crud.columnOption;
  210. this.printTitle = `${this.params.yearAndMonth}工资明细`;
  211. this.$nextTick(() => {
  212. this.$refs.printWideTable.printTable(isLandscape);
  213. });
  214. },
  215. },
  216. }, {
  217. // 模块路径
  218. name: 'yfCostManage/basicDataSetting/monthSalaryList',
  219. res: ({ data }, _this) => {
  220. console.log(_this)
  221. data.records = data.records.map(item => {
  222. // 处理id为空的时候,批量清除数据无法获取数据的问题
  223. item.id = !item.id ? (item.number || item.idCard) : item.id;
  224. item.yearAndMonth = _this.params.yearAndMonth;
  225. item.averageMonthlySalary = Number(item.averageMonthlySalary || 0).toFixed(2);
  226. item.pensionInsurance = Number(item.pensionInsurance || 0).toFixed(2);
  227. item.medicalInsurance = Number(item.medicalInsurance || 0).toFixed(2);
  228. item.unemploymentInsurance = Number(item.unemploymentInsurance || 0).toFixed(2);
  229. item.injuryInsurance = Number(item.injuryInsurance || 0).toFixed(2);
  230. item.maternityInsurance = Number(item.maternityInsurance || 0).toFixed(2);
  231. item.providentFund = Number(item.providentFund || 0).toFixed(2);
  232. item.bonus = Number(item.bonus || 0).toFixed(2);
  233. item.benefit = Number(item.benefit || 0).toFixed(2);
  234. item.pensionInsuranceBc = Number(item.pensionInsuranceBc || 0).toFixed(2);
  235. item.medicalInsuranceBc = Number(item.medicalInsuranceBc || 0).toFixed(2);
  236. let pensionInsurance = new Decimal(item.pensionInsurance);
  237. let medicalInsurance = new Decimal(item.medicalInsurance);
  238. let unemploymentInsurance = new Decimal(item.unemploymentInsurance);
  239. let injuryInsurance = new Decimal(item.injuryInsurance);
  240. let maternityInsurance = new Decimal(item.maternityInsurance);
  241. let providentFund = new Decimal(item.providentFund);
  242. // 社保合计
  243. let socialInsurance = pensionInsurance.add(medicalInsurance).add(unemploymentInsurance).add(injuryInsurance).add(maternityInsurance);
  244. item.socialInsurance = socialInsurance.toFixed(2);
  245. return item;
  246. });
  247. return data;
  248. },
  249. });
  250. </script>