SalaryCount.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <script setup lang="ts">
  2. import { ref, reactive } from 'vue'
  3. import type { TableColumnCtx } from 'element-plus'
  4. import { Salary_List, Salary_Send, Salary_Excel } from '@/api/salary/index'
  5. import { ElMessage } from 'element-plus'
  6. let date = new Date()
  7. const year = date.getFullYear()
  8. const month = date.getMonth()
  9. const salaryFromData = reactive({
  10. year: year + '',
  11. month: (month < 10 ? '0' : '') + month,
  12. T_uuid: ''
  13. })
  14. const tableTH = [
  15. { type: 'index', label: '序号', width: '60px' },
  16. { prop: 'T_user_name', label: '姓名' },
  17. { prop: 'T_user_dept', label: '部门' },
  18. { prop: 'T_user_post', label: '岗位' },
  19. { prop: 'T_base', label: '基本工资', sortable: true, width: '120px' },
  20. { prop: 'T_post', label: '岗位工资', sortable: true, width: '120px' },
  21. { prop: 'T_seniority', label: '工龄工资', sortable: true, width: '120px' },
  22. { prop: 'T_perf', label: '绩效金额', sortable: true, width: '120px' },
  23. { prop: 'T_perf_score', label: '绩效得分', sortable: true, width: '120px' },
  24. { prop: 'T_actual_Perf', label: '实发绩效', sortable: true, width: '120px' },
  25. { prop: 'T_back_payment', label: '其他补款', sortable: true, width: '120px' },
  26. { prop: 'T_attendance', label: '考勤扣款', sortable: true, width: '120px' },
  27. { prop: 'T_cut_payment', label: '其他扣款', sortable: true, width: '120px' },
  28. { prop: 'T_laballot', label: '应发合计', sortable: true, width: '120px' },
  29. { prop: 'T_pension_insurance', label: '养老保险', sortable: true, width: '120px' },
  30. { prop: 'T_unemployment_insurance', label: '失业保险', sortable: true, width: '120px' },
  31. { prop: 'T_medical_insurance', label: '基本医疗保险', sortable: true, width: '140px' },
  32. { prop: 'T_large_medical_insurance', label: '大额医疗保险', sortable: true, width: '140px' },
  33. { prop: 'T_housing_fund', label: '公积金', sortable: true, width: '100px' },
  34. { prop: 'T_tax', label: '个税扣款', sortable: true, width: '120px' },
  35. { prop: 'T_laborage', label: '扣款合计', sortable: true, width: '120px' },
  36. { prop: 'T_total', label: '实发合计', sortable: true, width: '120px' }
  37. ]
  38. interface User {
  39. Id: number
  40. T_user_name: string
  41. T_base: number
  42. T_post: number
  43. T_seniority: number
  44. T_Perf: number
  45. T_Perf_score: number
  46. T_back_payment: number
  47. T_tax: number
  48. T_attendance: number
  49. T_cut_payment: number
  50. T_pension_insurance: number
  51. T_unemployment_insurance: number
  52. T_medical_insurance: number
  53. T_Large_medical_insurance: number
  54. T_housing_fund: number
  55. }
  56. interface SpanMethodProps {
  57. row: User
  58. column: TableColumnCtx<User>
  59. rowIndex: number
  60. columnIndex: number
  61. }
  62. const arraySpanMethod = ({ rowIndex, columnIndex }: SpanMethodProps) => {
  63. if (rowIndex === tableData.value.length - 1) {
  64. if (columnIndex === 2) {
  65. return [1, 3]
  66. } else if (columnIndex === 3 || columnIndex === 4) {
  67. return [0, 0]
  68. }
  69. }
  70. }
  71. const initParam = {
  72. T_date: `${year}-${month < 10 ? '0' : ''}${month}`,
  73. page: 1,
  74. page_z: 10
  75. }
  76. const total = ref(0)
  77. const getSalary_List = async () => {
  78. const res: any = await Salary_List(initParam)
  79. tableData.value = res.Data.Data
  80. total.value = res.Data.Num
  81. }
  82. getSalary_List()
  83. const exportSalaryExcel = async () => {
  84. await Salary_Excel()
  85. }
  86. const publishSalary = async () => {
  87. // Salary_Send
  88. if (multipleSelection.value.length === 0 || multipleSelection.value[0]?.Id === 0) {
  89. ElMessage({
  90. message: '请选择用户!!!',
  91. type: 'warning'
  92. })
  93. return
  94. }
  95. multipleSelection.value.pop()
  96. for await (let item of multipleSelection.value) {
  97. Salary_Send({ T_id: item.Id })
  98. }
  99. }
  100. const multipleSelection = ref<User[]>([])
  101. const handleSelectionChange = (val: User[]) => {
  102. multipleSelection.value = val
  103. }
  104. const tableData = ref<User[]>([])
  105. </script>
  106. <template>
  107. <div class="SalaryCount">
  108. <el-card class="m-b-3">
  109. <el-row :gutter="24">
  110. <el-col :span="12" class="d-flex">
  111. <span class="demonstration">年:</span>
  112. <el-date-picker
  113. v-model="salaryFromData.year"
  114. style="width: 100px"
  115. value-format="YYYY"
  116. type="year"
  117. placeholder="请选择年"
  118. />
  119. <span class="demonstration">月:</span>
  120. <el-date-picker
  121. v-model="salaryFromData.month"
  122. style="width: 100px"
  123. value-format="MM"
  124. type="month"
  125. placeholder="请选择月"
  126. />
  127. </el-col>
  128. <el-col :span="12" class="d-flex">
  129. <el-button type="primary" @click="exportSalaryExcel">导出表格</el-button>
  130. <el-button type="success" @click="publishSalary">发布</el-button>
  131. </el-col>
  132. </el-row>
  133. </el-card>
  134. <el-card class="table-card">
  135. <el-table
  136. :data="tableData"
  137. @selection-change="handleSelectionChange"
  138. :span-method="arraySpanMethod"
  139. border
  140. style="width: 100%"
  141. >
  142. <el-table-column type="selection" width="55" />
  143. <template v-for="(item, index) in tableTH" :key="index">
  144. <el-table-column
  145. v-if="item.type === 'index'"
  146. :type="item.type"
  147. :width="item.width"
  148. align="center"
  149. :label="item.label"
  150. />
  151. <el-table-column
  152. v-else
  153. :prop="item.prop"
  154. :label="item.label"
  155. :width="item.width"
  156. align="center"
  157. label-class-name="label-table"
  158. :sortable="item.sortable"
  159. />
  160. </template>
  161. </el-table>
  162. <div class="pagination">
  163. <el-pagination background layout="total,prev, pager, next" :total="total" />
  164. </div>
  165. </el-card>
  166. </div>
  167. </template>
  168. <style scoped lang="scss">
  169. .SalaryCount {
  170. height: 100%;
  171. .table-card {
  172. height: calc(100% - 72px - 12px);
  173. :deep(.el-card__body) {
  174. height: 100%;
  175. display: flex;
  176. flex-direction: column;
  177. justify-content: space-between;
  178. }
  179. }
  180. }
  181. .label-table {
  182. white-space: nowrap;
  183. }
  184. .d-flex {
  185. display: flex;
  186. justify-content: center;
  187. align-items: center;
  188. flex-wrap: nowrap;
  189. }
  190. .pagination {
  191. display: flex;
  192. justify-content: end;
  193. margin-top: 2rem;
  194. }
  195. </style>