salary.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <HcCard>
  3. <template #header>
  4. <div class="w-36 ml-2">
  5. <el-select v-model="searchForm.userId" block clearable filterable placeholder="员工姓名" size="large">
  6. <el-option v-for="item in userList" :label="item.name" :value="item.id" />
  7. </el-select>
  8. </div>
  9. <div class="w-36 ml-2">
  10. <el-date-picker v-model="searchForm.month" class="block" size="large" type="month" format="YYYY-MM" value-format="YYYY-MM" />
  11. </div>
  12. <div class="ml-4">
  13. <el-button type="primary" size="large" @click="searchClick">
  14. <HcIcon name="search-2" />
  15. <span>搜索</span>
  16. </el-button>
  17. </div>
  18. <div class="ml-2">
  19. <el-button size="large" @click="resetClick">
  20. <HcIcon name="close-circle" />
  21. <span>重置</span>
  22. </el-button>
  23. </div>
  24. </template>
  25. <template #extra>
  26. <el-button v-auth-btn="['people-salary-load']" type="primary" size="large" @click="downloadXlsx">
  27. <HcIcon name="download-2" />
  28. <span>下载模板</span>
  29. </el-button>
  30. <el-button v-auth-btn="['people-salary-import']" type="primary" size="large" class="ml-2" @click="toImportTempClick">
  31. <HcIcon name="folder-upload" />
  32. <span>导入数据</span>
  33. </el-button>
  34. </template>
  35. <HcTable border :is-index="false" :loading="tableLoading" :column="tableColumn" :datas="tableData" />
  36. <template #action>
  37. <HcPages :pages="searchForm" @change="pageChange" />
  38. </template>
  39. <!-- 导入数据弹窗 -->
  40. <HcDialog
  41. bg-color="#ffffff" widths="26rem" is-to-body :show="importModal" title="导入数据"
  42. save-text="上传excel" @close="importModalClose" @save="importModalSave"
  43. >
  44. <div class="w-full">
  45. <el-date-picker v-model="uploadParams.dateInfo" class="block" type="month" size="large" format="YYYY-MM" value-format="YYYY-MM" />
  46. </div>
  47. </HcDialog>
  48. <!-- 上传控件 -->
  49. <HcUploadFile ref="uploadFileRef" :options="uploadOptions" :params="uploadParams" @success="uploadFileSuccess" />
  50. </HcCard>
  51. </template>
  52. <script setup>
  53. import { onActivated, ref } from 'vue'
  54. import { getuserList } from '~api/other'
  55. import mainApi from '~api/people/salary'
  56. import { getTokenHeader } from '~src/api/request/header'
  57. import { downloadBlob, getArrValue } from 'js-fast-way'
  58. onActivated(() => {
  59. getuserListApi()
  60. getTableData()
  61. })
  62. //获取用户下拉数据
  63. const userList = ref([])
  64. const getuserListApi = async () => {
  65. const { data } = await getuserList()
  66. userList.value = getArrValue(data)
  67. }
  68. const searchForm = ref({
  69. userId: null, month: null,
  70. current: 1, size: 20, total: 0,
  71. })
  72. //搜索
  73. const searchClick = () => {
  74. searchForm.value.current = 1
  75. getTableData()
  76. }
  77. //重置搜索表单
  78. const resetClick = () => {
  79. searchForm.value = { current: 1, size: 20, total: 0 }
  80. }
  81. //分页被点击
  82. const pageChange = ({ current, size }) => {
  83. searchForm.value.current = current
  84. searchForm.value.size = size
  85. getTableData()
  86. }
  87. //表格参数
  88. const tableLoading = ref(false)
  89. const tableColumn = [
  90. { key: 'name', name: '姓名', width: 100, align: 'center' },
  91. { key: 'yaAllDays', name: '应出勤天数', width: 100, align: 'center' },
  92. { key: 'saAllDays', name: '实际出勤天数', width: 110, align: 'center' },
  93. { key: 'yearDays', name: '年假', width: 80, align: 'center' },
  94. { key: 'caLeaveDays', name: '调休假', width: 80, align: 'center' },
  95. { key: 'sickLeaveDays', name: '病假', width: 80, align: 'center' },
  96. { key: 'absenceDays', name: '事假', width: 80, align: 'center' },
  97. { key: 'basicSalary', name: '基本工资', width: 100, align: 'center' },
  98. { key: 'postSalary', name: '岗位工资', width: 100, align: 'center' },
  99. { key: 'meritSalary', name: '绩效工资', width: 100, align: 'center' },
  100. { key: 'bonusSalary', name: '奖励', width: 100, align: 'center' },
  101. { key: 'mealWance', name: '伙食补贴', width: 100, align: 'center' },
  102. { key: 'otherWance', name: '其他补贴', width: 100, align: 'center' },
  103. { key: 'attendDuction', name: '考勤扣款', width: 100, align: 'center' },
  104. { key: 'absDuction', name: '事假扣款', width: 100, align: 'center' },
  105. { key: 'otherDuction', name: '其他扣款', width: 100, align: 'center' },
  106. { key: 'grossPay', name: '应发工资', width: 100, align: 'center' },
  107. { key: 'personalTax', name: '代扣个人应交社保', width: 140, align: 'center' },
  108. { key: 'socialSec', name: '代扣代缴个税', width: 120, align: 'center' },
  109. { key: 'netSalary', name: '实发工资', width: 100, align: 'center' },
  110. { key: 'desc', name: '备注', minWidth: 140, align: 'center' },
  111. ]
  112. //获取表格数据
  113. const tableData = ref([])
  114. const getTableData = async () => {
  115. tableLoading.value = true
  116. const { data } = await mainApi.page(searchForm.value)
  117. tableData.value = getArrValue(data['records'])
  118. searchForm.value.total = data['total'] || 0
  119. tableLoading.value = false
  120. }
  121. //下载模板
  122. const downloadXlsx = async () => {
  123. const { error, disposition, res } = await mainApi.exportTemplate()
  124. if (!error && disposition) {
  125. downloadBlob(res, disposition)
  126. } else {
  127. window.$message?.error('数据异常')
  128. }
  129. }
  130. //导入数据弹窗
  131. const importModal = ref(false)
  132. const uploadTime = ref(null)
  133. //上传配置
  134. const uploadFileRef = ref(null)
  135. const uploadParams = ref({
  136. dateInfo: null,
  137. })
  138. const uploadOptions = {
  139. url: '/api/blade-control/userpayinfo/import-userpay',
  140. headers: getTokenHeader(),
  141. multiple: false,
  142. size: 50,
  143. }
  144. //打开导入数据弹窗
  145. const toImportTempClick = () => {
  146. uploadTime.value = null
  147. importModal.value = true
  148. }
  149. //导入数据弹窗保存
  150. const importModalSave = () => {
  151. if (uploadParams.value.dateInfo) {
  152. uploadFileRef.value?.selectFile()
  153. } else {
  154. window.$message?.error('请先选择月份')
  155. }
  156. }
  157. // 文件上传成功的回调
  158. const uploadFileSuccess = () => {
  159. window.$message?.success('导入成功')
  160. uploadFileRef.value?.setModalShow(false)
  161. importModalClose()
  162. getTableData()
  163. }
  164. //导入数据弹窗关闭
  165. const importModalClose = () => {
  166. uploadTime.value = null
  167. importModal.value = false
  168. }
  169. </script>
  170. <style lang='scss' scoped>
  171. </style>