SalaryCount.vue 6.9 KB

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