view.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <template>
  2. <el-dialog title="工资信息" v-model="visible" :width="width" append-to-body draggable @close="close"
  3. :close-on-click-modal="false">
  4. <div v-loading="loading">
  5. <!-- 功能按钮 -->
  6. <div style="padding: 8px 24px 16px 24px">
  7. <el-form size="small" label-width="100px" v-model="form">
  8. <el-row :gutter="30">
  9. <el-col :span="12">
  10. <el-form-item label="客户名称">
  11. <div>{{ form.companyName }}</div>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :span="12">
  15. <el-form-item label="所属月份">
  16. <div>{{ form.year }}-{{ form.month }}</div>
  17. </el-form-item>
  18. </el-col>
  19. <el-col :span="24" class="details-container">
  20. <div class="details-head">
  21. <div class="title">
  22. <i class="fa fa-th-list" aria-hidden="true" /> 人员信息
  23. <el-button class="button-class" size="small" @click="printSalary" icon="printer"
  24. type="primary">打印</el-button>
  25. <el-button class="button-class" size="small" @click="exportSalary" icon="download"
  26. type="info">导出</el-button>
  27. </div>
  28. <!-- <el-button size="small" @click="printSalary">打印</el-button>
  29. <el-button size="small" @click="exportSalary">导出</el-button> -->
  30. </div>
  31. <div class="details-body">
  32. <div>
  33. <el-table ref="sourceTable" :data="form.details" size="small" max-height="260px" border show-summary
  34. :summary-method="getSummaries" highlight-current-row header-row-class-name="list-header-row"
  35. row-class-name="list-row" @selection-change="handleCheckChange" @current-change="handleCurrentChange">
  36. <el-table-column type="index" label="序号" width="50" align="center" />
  37. <el-table-column label="员工姓名" width="80" align="center">
  38. <template #default="scope">
  39. <div>
  40. {{ scope.row.employeeName }}
  41. </div>
  42. <span style="
  43. color: red;
  44. position: absolute;
  45. z-index: 10;
  46. top: 4px;
  47. right: 6px;
  48. ">*</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="身份证号" width="150" align="center">
  52. <template #default="scope">
  53. <div>
  54. {{ scope.row.idCode }}
  55. </div>
  56. <span style="
  57. color: red;
  58. position: absolute;
  59. z-index: 10;
  60. top: 4px;
  61. right: 6px;
  62. ">*</span>
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="应发工资" width="70" header-align="center" align="right" prop="planSalary">
  66. <template #default="scope">
  67. <div>
  68. {{ rowNum(scope.row.planSalary) }}
  69. </div>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="实发工资" width="70" header-align="center" align="right" prop="actuallySalary">
  73. <template #default="scope">
  74. <div>
  75. {{ rowNum(scope.row.actuallySalary) }}
  76. </div>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="奖金及其他" width="95" header-align="center" align="right" prop="bonusAmount">
  80. <template #default="scope">
  81. <div>
  82. {{ rowNum(scope.row.bonusAmount) }}
  83. </div>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="社保申报" prop="socialSecurityStatus" align="center">
  87. <template #default="scope">
  88. {{ scope.row.socialSecurityStatus == 1 ? '已申报' : '未申报' }}
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="社保" align="center">
  92. <el-table-column label="养老保险" width="70" header-align="center" align="right"
  93. prop="endowmentInsurance">
  94. <template #default="scope">
  95. <div>
  96. {{ rowNum(scope.row.endowmentInsurance) }}
  97. </div>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="医疗保险" width="70" header-align="center" align="right"
  101. prop="medicalInsurance">
  102. <template #default="scope">
  103. <div>
  104. {{ rowNum(scope.row.medicalInsurance) }}
  105. </div>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="失业险" width="70" header-align="center" align="right"
  109. prop="unemploymentBenefit">
  110. <template #default="scope">
  111. <div>
  112. {{ rowNum(scope.row.unemploymentBenefit) }}
  113. </div>
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="大病险" width="70" header-align="center" align="right"
  117. prop="seriousIllnessInsurance">
  118. <template #default="scope">
  119. <div>
  120. {{ rowNum(scope.row.seriousIllnessInsurance) }}
  121. </div>
  122. </template>
  123. </el-table-column>
  124. </el-table-column>
  125. <el-table-column label="公积金申报" prop="housingFundStatus" align="center">
  126. <template #default="scope">
  127. {{ scope.row.housingFundStatus == 1 ? '已申报' : '未申报' }}
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="公积金" width="80" header-align="center" align="right" prop="housingFund">
  131. <template #default="scope">
  132. <div>
  133. {{ rowNum(scope.row.housingFund) }}
  134. </div>
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="个税" header-align="center" align="right" :prop="form.status === 3 && form.hasIndividualIncomeTax
  138. ? 'individualIncomeTaxConfirm'
  139. : 'currentIndividualIncomeTax'
  140. ">
  141. <template #default="scope">
  142. <div>
  143. {{
  144. rowNum(
  145. form.status === 3 && form.hasIndividualIncomeTax
  146. ? scope.row.individualIncomeTaxConfirm
  147. : scope.row.currentIndividualIncomeTax
  148. )
  149. }}
  150. </div>
  151. </template></el-table-column>
  152. <el-table-column label="其他扣款" width="70" header-align="center" align="right" prop="otherCut">
  153. <template #default="scope">
  154. <div>
  155. {{ rowNum(scope.row.otherCut) }}
  156. </div>
  157. </template>
  158. </el-table-column>
  159. <el-table-column label="备注" width="100" header-align="center">
  160. <template #default="scope">
  161. <div>
  162. {{ scope.row.remark }}
  163. </div>
  164. </template>
  165. </el-table-column>
  166. </el-table>
  167. </div>
  168. </div>
  169. </el-col>
  170. <el-col :span="24">
  171. <el-divider />
  172. </el-col>
  173. <el-col :span="24">
  174. <el-form-item label="备注">
  175. <span>
  176. {{ form.content }}
  177. </span>
  178. </el-form-item>
  179. </el-col>
  180. <el-col :span="24">
  181. <el-form-item label="合计工资">
  182. {{ rowNum(form.amount) }}
  183. </el-form-item>
  184. </el-col>
  185. <el-col v-if="showVerify()" :span="24">
  186. <el-divider />
  187. </el-col>
  188. <el-col v-if="showVerify()" :span="24">
  189. <el-form-item label="是否有个税">
  190. <el-select v-model.trim="form.hasIndividualIncomeTax" placeholder="请选择" size="small" style="width: 100%"
  191. @change="changeIndividual">
  192. <el-option v-for="item in confirmChoices" :key="item.value" :label="item.label" :value="item.value" />
  193. </el-select>
  194. </el-form-item>
  195. </el-col>
  196. <el-col v-if="showVerify() && form.hasIndividualIncomeTax === 1" :span="24" class="details-container">
  197. <div class="details-head">
  198. <div class="title">
  199. <i class="fa fa-th-list" aria-hidden="true" /> 人员信息
  200. </div>
  201. </div>
  202. <div class="details-body">
  203. <div>
  204. <el-table ref="sourceTable" :data="form.details" size="small" max-height="260px" border
  205. highlight-current-row header-row-class-name="list-header-row" row-class-name="list-row"
  206. @selection-change="handleCheckChange" @current-change="handleCurrentChange">
  207. <el-table-column type="index" label="序号" width="50" align="center" />
  208. <el-table-column label="员工姓名" width="120" align="center">
  209. <template #default="scope">
  210. <div>
  211. {{ scope.row.employeeName }}
  212. </div>
  213. <span style="
  214. color: red;
  215. position: absolute;
  216. z-index: 10;
  217. top: 4px;
  218. right: 6px;
  219. ">*</span>
  220. </template>
  221. </el-table-column>
  222. <el-table-column label="实际个税" align="center" width="120" prop="individualIncomeTaxConfirm">
  223. <template #default="scope">
  224. <div>
  225. <el-input-number v-model="scope.row.individualIncomeTaxConfirm" size="small" placeholder="个税"
  226. :precision="2" :controls="false" style="width: 100%" @change="rowChangeSum(scope.row)" />
  227. </div>
  228. </template>
  229. </el-table-column>
  230. </el-table>
  231. <br />
  232. </div>
  233. </div>
  234. </el-col>
  235. <el-col :span="24">
  236. <el-form-item label="审核备注">
  237. <el-input v-if="form.status === 2" v-model.trim="form.verifyContent" maxlength="200" show-word-limit
  238. type="textarea" rows="2" />
  239. <span v-else> {{ form.verifyContent }}</span>
  240. </el-form-item>
  241. </el-col>
  242. </el-row>
  243. </el-form>
  244. </div>
  245. <div class="form-btns-container" style="height: 40px">
  246. <el-button v-if="showVerify()" type="danger" size="small" icon="back" style="float: right; margin-left: 12px"
  247. @click="handleVerify(4)">
  248. 驳回</el-button>
  249. <el-button v-if="showVerify()" type="primary" icon="check" size="small" style="float: right; margin-left: 12px"
  250. @click="handleVerify(3)">
  251. 审核通过</el-button>
  252. <el-button v-if="blackButton() && form.status === 3" type="warning" size="small" icon="back"
  253. style="float: right; margin-left: 12px" @click="returnStatus()">退回</el-button>
  254. </div>
  255. <feedback-dialog ref="feedbackDialogView" :verify="verify" />
  256. </div>
  257. </el-dialog>
  258. </template>
  259. <script setup>
  260. import {
  261. getDetail,
  262. verifyDetail,
  263. turnBackDetail,
  264. exportSalaryEmployee,
  265. exportSalaryPdf,
  266. } from "@/api/business/production/salary";
  267. import feedbackDialog from "../feedbackDialog.vue";
  268. import { rowNum, numberToCurrencyNo } from "@/utils/index";
  269. import useUserStore from "@/store/modules/user";
  270. import { ref } from "vue";
  271. const { proxy } = getCurrentInstance();
  272. const visible = ref(false);
  273. const width = ref(1420);
  274. const selections = ref([]);
  275. const currentSource = ref(null);
  276. const loading = ref(false)
  277. const permissions = useUserStore().permissions;
  278. const all_permission = "*:*:*";
  279. const feedbackDialogView = ref(null);
  280. const confirmChoices = ref([
  281. {
  282. label: "是",
  283. value: 1,
  284. },
  285. {
  286. label: "否",
  287. value: 0,
  288. },
  289. ]);
  290. const props = defineProps({
  291. getList: {
  292. type: Function,
  293. default: () => { },
  294. },
  295. });
  296. const { getList } = toRefs(props);
  297. const total = ref(0);
  298. const employeeEmptyData = {
  299. id: null,
  300. title: "",
  301. remark: "",
  302. employeeName: "",
  303. departmentName: "",
  304. idCode: "",
  305. salaryAmount: "",
  306. bonusAmount: "",
  307. allowanceAmount: "",
  308. subsidyAmount: "",
  309. absenceCut: "",
  310. planSalary: 0,
  311. actuallySalary: 0,
  312. endowmentInsurance: 0,
  313. medicalInsurance: 0,
  314. unemploymentBenefit: 0,
  315. seriousIllnessInsurance: 0,
  316. housingFund: 0,
  317. otherCut: 0,
  318. cumulativeIncome: 0,
  319. cumulativeSpecialCut: 0,
  320. cumulativeChildEduCut: 0,
  321. cumulativeHouseLoanInterestCut: 0,
  322. cumulativeHouseRentCut: 0,
  323. cumulativeSupportElderCut: 0,
  324. cumulativeContinuingEduCut: 0,
  325. cumulativeBabyCareCut: 0,
  326. sumSpecialCumulativeCut: 0,
  327. cumulativeOtherCut: 0,
  328. cumulativeIndividualIncomeTax: 0,
  329. cumulativeHasPaidIit: 0,
  330. currentIndividualIncomeTax: 0,
  331. idiograph: "",
  332. details: [],
  333. editStatus: true,
  334. };
  335. const form = ref({
  336. amount: null,
  337. details: [],
  338. });
  339. const emptyForm = {
  340. details: [],
  341. };
  342. function open(detail) {
  343. console.log(detail);
  344. visible.value = true;
  345. form.value = detail;
  346. loadData();
  347. }
  348. function loadData() {
  349. loading.value = true
  350. getDetail(form.value).then((res) => {
  351. form.value = { ...proxy.deepClone(emptyForm), ...res.data };
  352. computeTotal();
  353. }).finally(() => {
  354. loading.value = false
  355. });
  356. }
  357. function close() {
  358. visible.value = false;
  359. reset();
  360. }
  361. function reset() {
  362. form.value = proxy.deepClone(emptyForm);
  363. total.value = 0;
  364. }
  365. //打印工资列表
  366. function printSalary() {
  367. exportSalaryPdf(form.value.id);
  368. }
  369. //导出工资列表
  370. function exportSalary() {
  371. exportSalaryEmployee(form.value.id);
  372. }
  373. function showVerify() {
  374. if (
  375. form.value.id == null ||
  376. form.value.status === 0 ||
  377. form.value.status === 3 ||
  378. form.value.status === 4
  379. ) {
  380. return false;
  381. } else if (verifiable()) {
  382. return true;
  383. }
  384. else {
  385. return false;
  386. }
  387. }
  388. function verifiable() {
  389. return (
  390. permissions.includes("business:salary:verify") || permissions.includes(all_permission));
  391. }
  392. function blackButton() {
  393. return (
  394. permissions.includes("business:salary:back") || permissions.includes(all_permission)
  395. );
  396. }
  397. function handleCurrentChange(row) {
  398. currentSource.value = row;
  399. }
  400. function handleCheckChange(selection) {
  401. selections.value = selection.map((item) => item);
  402. }
  403. function getSummaries(param) {
  404. const { columns, data } = param;
  405. const sums = [];
  406. columns.forEach((column, index) => {
  407. if (index === 0) {
  408. sums[index] = "合计";
  409. return;
  410. } else if (index === 1||index === 6) {
  411. sums[index] = "";
  412. return;
  413. }
  414. const values = data.map((item) => Number(item[column.property]));
  415. if (!values.every((value) => isNaN(value))) {
  416. sums[index] = values.reduce((prev, curr) => {
  417. const value = Number(curr);
  418. if (!isNaN(value)) {
  419. return (Number(prev) + Number(curr)).toFixed(2);
  420. } else {
  421. return Number(prev).toFixed(2);
  422. }
  423. }, 0);
  424. } else {
  425. sums[index] = "";
  426. }
  427. });
  428. return sums;
  429. }
  430. function handleVerify(status) {
  431. if (status === 4) {
  432. const saveValue = proxy.deepClone(form.value);
  433. saveValue.status = status;
  434. feedbackDialogView.value.open(saveValue);
  435. } else {
  436. proxy.$modal
  437. .confirm("确认审核么?")
  438. .then((_) => {
  439. const saveValue = proxy.deepClone(form.value);
  440. saveValue.status = status;
  441. verify(saveValue);
  442. })
  443. .catch((_) => {
  444. proxy.$modal.msg("已取消审核");
  445. });
  446. }
  447. }
  448. function verify(data) {
  449. loading.value = true
  450. verifyDetail(data).then((res) => {
  451. reset();
  452. getList.value();
  453. close();
  454. }).finally(() => {
  455. loading.value = false
  456. });
  457. }
  458. function rowChangeSum(row) {
  459. let actuallySalary = 0;
  460. actuallySalary += row.planSalary == null ? 0 : row.planSalary;
  461. actuallySalary += row.bonusAmount == null ? 0 : row.bonusAmount;
  462. actuallySalary -= row.endowmentInsurance == null ? 0 : row.endowmentInsurance;
  463. actuallySalary -= row.medicalInsurance == null ? 0 : row.medicalInsurance;
  464. actuallySalary -=
  465. row.unemploymentBenefit == null ? 0 : row.unemploymentBenefit;
  466. actuallySalary -=
  467. row.seriousIllnessInsurance == null ? 0 : row.seriousIllnessInsurance;
  468. actuallySalary -= row.housingFund == null ? 0 : row.housingFund;
  469. if (form.value.hasIndividualIncomeTax === 1) {
  470. actuallySalary -=
  471. row.individualIncomeTaxConfirm == null
  472. ? 0
  473. : row.individualIncomeTaxConfirm;
  474. } else {
  475. actuallySalary -=
  476. row.currentIndividualIncomeTax == null
  477. ? 0
  478. : row.currentIndividualIncomeTax;
  479. }
  480. actuallySalary -= row.otherCut == null ? 0 : row.otherCut;
  481. row.actuallySalary = actuallySalary;
  482. computeTotal();
  483. }
  484. function computeTotal() {
  485. let totalSalay = 0;
  486. form.value.details.forEach((l) => {
  487. totalSalay += l.actuallySalary == null ? 0 : l.actuallySalary;
  488. });
  489. form.value.amount = totalSalay;
  490. }
  491. function returnStatus(status) {
  492. proxy.$modal
  493. .confirm("确认退回么?")
  494. .then((_) => {
  495. loading.value = true
  496. turnBackDetail(form.value).then((res) => {
  497. // if (res.data.successStatus = true) {
  498. // reset()
  499. // getList.value()
  500. // close()
  501. // } else {
  502. // proxy.$modal.msg(res.data.message)
  503. // }
  504. reset();
  505. getList.value();
  506. close();
  507. }).finally(() => {
  508. loading.value = false
  509. });
  510. })
  511. .catch((_) => {
  512. proxy.$modal.msg("已取消退回");
  513. });
  514. }
  515. function changeIndividual(arg) {
  516. // if (arg === 1) {
  517. form.value.details.forEach((row) => {
  518. let actuallySalary = 0;
  519. actuallySalary += row.planSalary == null ? 0 : row.planSalary;
  520. actuallySalary += row.bonusAmount == null ? 0 : row.bonusAmount;
  521. actuallySalary -=
  522. row.endowmentInsurance == null ? 0 : row.endowmentInsurance;
  523. actuallySalary -= row.medicalInsurance == null ? 0 : row.medicalInsurance;
  524. actuallySalary -=
  525. row.unemploymentBenefit == null ? 0 : row.unemploymentBenefit;
  526. actuallySalary -=
  527. row.seriousIllnessInsurance == null ? 0 : row.seriousIllnessInsurance;
  528. actuallySalary -= row.housingFund == null ? 0 : row.housingFund;
  529. if (arg === 1) {
  530. actuallySalary -=
  531. row.individualIncomeTaxConfirm == null
  532. ? 0
  533. : row.individualIncomeTaxConfirm;
  534. } else {
  535. actuallySalary -=
  536. row.currentIndividualIncomeTax == null
  537. ? 0
  538. : row.currentIndividualIncomeTax;
  539. }
  540. actuallySalary -= row.otherCut == null ? 0 : row.otherCut;
  541. row.actuallySalary = actuallySalary;
  542. });
  543. computeTotal();
  544. }
  545. // 暴露给父组件的方法
  546. defineExpose({
  547. open,
  548. });
  549. </script>
  550. <style lang="scss" scoped>
  551. .button-class {
  552. margin-top: 10px;
  553. margin-bottom: 10px;
  554. }
  555. </style>