salary.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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" @click="searchClick" size="large">
  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 type="primary" @click="downloadXlsx" size="large">
  27. <HcIcon name="download-2"/>
  28. <span>下载模板</span>
  29. </el-button>
  30. <el-button type="primary" @click="toImportTempClick" size="large" class="ml-2">
  31. <HcIcon name="folder-upload"/>
  32. <span>导入数据</span>
  33. </el-button>
  34. </template>
  35. <HcTable border :isIndex="false" :loading="tableLoading" :column="tableColumn" :datas="tableData"/>
  36. <template #action>
  37. <HcPages :pages="searchForm" @change="pageChange"/>
  38. </template>
  39. <!--导入数据弹窗-->
  40. <HcDialog bgColor="#ffffff" widths="34rem" isToBody :show="importModal" title="导入数据"
  41. @close="importModalClose" footer isRowFooter>
  42. <el-form label-position="top" label-width="auto" :model="formModel" size="large">
  43. <el-form-item label="请选择导入薪酬所时间属范围:">
  44. <el-date-picker v-model="formModel.time" type="daterange" start-placeholder="起始时间" end-placeholder="结束时间" :default-time="defaultTime"/>
  45. </el-form-item>
  46. </el-form>
  47. <template #rightRowFooter>
  48. <HcUploadFile ref="HcUploadFileRef" :options="UploadFileOptions" @progress="HcUploadFileProgress" @success="HcUploadFileSuccess" @change="HcUploadFileChange">
  49. <el-button type="primary" size="large" class="ml-2">
  50. <HcIcon name="folder-upload"/>
  51. <span>上传excel</span>
  52. </el-button>
  53. </HcUploadFile>
  54. <el-button type="primary" @click="importModalClose" size="large" class="ml-2">
  55. <HcIcon name="close-circle"/>
  56. <span>取消</span>
  57. </el-button>
  58. </template>
  59. </HcDialog>
  60. </HcCard>
  61. </template>
  62. <script setup>
  63. import {onActivated, ref} from 'vue'
  64. import {getuserList} from "~api/other";
  65. import mainApi from "~api/people/salary";
  66. import {getTokenHeader} from "~src/api/request/header";
  67. import {downloadBlob, getArrValue} from "js-fast-way";
  68. onActivated(() => {
  69. getuserListApi()
  70. getTableData()
  71. })
  72. //获取用户下拉数据
  73. const userList = ref([])
  74. const getuserListApi = async () => {
  75. const {data} = await getuserList()
  76. userList.value = getArrValue(data)
  77. }
  78. const searchForm = ref({
  79. userId: null, month: null,
  80. current: 1, size: 20, total: 0
  81. })
  82. //搜索
  83. const searchClick = () => {
  84. searchForm.value.current = 1;
  85. getTableData()
  86. }
  87. //重置搜索表单
  88. const resetClick = () => {
  89. searchForm.value = {current: 1, size: 20, total: 0}
  90. }
  91. //分页被点击
  92. const pageChange = ({current, size}) => {
  93. searchForm.value.current = current
  94. searchForm.value.size = size
  95. getTableData()
  96. }
  97. //表格参数
  98. const tableLoading = ref(false)
  99. const tableColumn = [
  100. {key: 'name', name: '姓名', width: 100, align: 'center'},
  101. {key: 'yaAllDays', name: '应出勤天数', width: 100, align: 'center'},
  102. {key: 'saAllDays', name: '实际出勤天数', width: 110, align: 'center'},
  103. {key: 'yearDays', name: '年假', width: 80, align: 'center'},
  104. {key: 'caLeaveDays', name: '调休假', width: 80, align: 'center'},
  105. {key: 'sickLeaveDays', name: '病假', width: 80, align: 'center'},
  106. {key: 'absenceDays', name: '事假', width: 80, align: 'center'},
  107. {key: 'basicSalary', name: '基本工资', width: 100, align: 'center'},
  108. {key: 'postSalary', name: '岗位工资', width: 100, align: 'center'},
  109. {key: 'meritSalary', name: '绩效工资', width: 100, align: 'center'},
  110. {key: 'bonusSalary', name: '奖励', width: 100, align: 'center'},
  111. {key: 'mealWance', name: '伙食补贴', width: 100, align: 'center'},
  112. {key: 'otherWance', name: '其他补贴', width: 100, align: 'center'},
  113. {key: 'attendDuction', name: '考勤扣款', width: 100, align: 'center'},
  114. {key: 'absDuction', name: '事假扣款', width: 100, align: 'center'},
  115. {key: 'otherDuction', name: '其他扣款', width: 100, align: 'center'},
  116. {key: 'grossPay', name: '应发工资', width: 100, align: 'center'},
  117. {key: 'personalTax', name: '代扣个人应交社保', width: 140, align: 'center'},
  118. {key: 'socialSec', name: '代扣代缴个税', width: 120, align: 'center'},
  119. {key: 'netSalary', name: '实发工资', width: 100, align: 'center'},
  120. {key: 'desc', name: '备注', minWidth: 140, align: 'center'},
  121. ]
  122. //获取表格数据
  123. const tableData = ref([])
  124. const getTableData = async () => {
  125. tableLoading.value = true
  126. const {data} = await mainApi.page(searchForm.value)
  127. tableData.value = getArrValue(data['records'])
  128. searchForm.value.total = data['total'] || 0
  129. tableLoading.value = false
  130. }
  131. //下载模板
  132. const downloadXlsx = async () => {
  133. const {error, disposition, res} = await mainApi.exportTemplate()
  134. if (!error && disposition) {
  135. downloadBlob(res, disposition)
  136. } else {
  137. window.$message?.error('数据异常')
  138. }
  139. }
  140. const defaultTime = ref([
  141. new Date(2000, 1, 1, 0, 0, 0),
  142. new Date(2000, 2, 1, 23, 59, 59),
  143. ])
  144. //导入数据弹窗
  145. const importModal = ref(false)
  146. const importModalClose = () => {
  147. importModal.value = false
  148. }
  149. const formModel = ref({})
  150. const toImportTempClick = () => {
  151. importModal.value = true
  152. }
  153. //上传配置
  154. const UploadFileOptions = {
  155. //此处设置header
  156. headers: getTokenHeader(),
  157. }
  158. // 文件上传进度
  159. const HcUploadFileProgress = (res) => {
  160. console.log('文件上传进度', res)
  161. }
  162. const HcUploadFileRef = ref(null)
  163. // 文件上传成功的回调
  164. const HcUploadFileSuccess = (res) => {
  165. HcUploadFileRef.value?.setModalShow(false);
  166. importModal.value = false
  167. getTableData()
  168. }
  169. // 文件全部上传成功
  170. const HcUploadFileChange = () => {
  171. console.log('文件全部上传成功')
  172. }
  173. </script>
  174. <style lang='scss' scoped>
  175. </style>