Files
ss-oa-manage-web/src/views/Home/Salary/index.vue

482 lines
14 KiB
Vue
Raw Normal View History

2024-07-15 18:21:49 +08:00
<template>
2024-07-16 16:49:01 +08:00
<div>
2024-07-22 16:04:19 +08:00
<el-form :model="searchForm" ref="searchFormRef" inline @submit.prevent>
2024-07-16 16:49:01 +08:00
<el-form-item>
2024-07-22 16:04:19 +08:00
<el-input
v-model="searchForm.name"
placeholder="员工姓名"
clearable
@keyup.enter="handleSearch"
/>
2024-07-16 16:49:01 +08:00
</el-form-item>
<el-form-item>
<el-date-picker
2024-07-22 20:07:53 +08:00
v-model="searchForm.period"
2024-07-16 16:49:01 +08:00
type="month"
2024-07-22 20:07:53 +08:00
format="YYYY-MM"
value-format="YYYY-MM"
2024-07-16 16:49:01 +08:00
placeholder="年月"
style="width: 100%"
2024-07-22 16:04:19 +08:00
@change="handleSearch"
2024-07-16 16:49:01 +08:00
/>
</el-form-item>
<el-form-item>
2024-07-18 15:11:37 +08:00
<el-button @click="handleSearch" v-hasPermi="['home:salary:search']">查询</el-button>
<el-button type="primary" plain @click="craeteSalary" v-hasPermi="['home:salary:create']"
>生成工资条</el-button
>
<el-button type="primary" @click="importHistorySalary" v-hasPermi="['home:salary:history']"
>导入历史工资条</el-button
>
2024-07-16 16:49:01 +08:00
</el-form-item>
</el-form>
<el-table
v-loading="loading"
:data="tableList"
border
stripe
:default-expand-all="false"
row-key="id"
2024-07-22 20:07:53 +08:00
:tree-props="{ children: 'userSalaryGrantRespVOList', hasChildren: 'hasChildren' }"
2024-07-16 16:49:01 +08:00
:span-method="spanMethod"
>
2025-02-17 14:12:34 +08:00
<el-table-column label="姓名" min-width="90px" fixed="left">
2024-07-16 16:49:01 +08:00
<template #default="{ row }">
2024-07-22 20:07:53 +08:00
<span v-if="row.userSalaryGrantRespVOList && row.userSalaryGrantRespVOList.length">
<span>{{ row.period }}</span>
<span class="ml-20px">应发工资人数{{ row.grantNum }}</span>
<span class="ml-20px">应发工资¥{{ row.allGrantSalaryTotal }}</span>
2024-07-16 16:49:01 +08:00
</span>
<span v-else>
{{ row.name }}
</span>
</template>
</el-table-column>
2024-07-22 20:07:53 +08:00
<el-table-column prop="period" label="年月" min-width="90px" />
2024-07-16 16:49:01 +08:00
<el-table-column prop="dept" label="部门" min-width="90px" />
2024-07-19 16:03:07 +08:00
<el-table-column prop="post" label="职位" min-width="90px" />
2024-07-16 16:49:01 +08:00
<el-table-column label="应发工资" align="center">
2024-12-10 17:17:14 +08:00
<el-table-column label="无责底薪" min-width="90px">
2024-07-16 16:49:01 +08:00
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-19 16:03:07 +08:00
v-model="row.baseSalary"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-19 16:03:07 +08:00
<span v-else> {{ row.baseSalary }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
2024-12-10 17:17:14 +08:00
<el-table-column label="标准绩效" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-12-24 17:28:34 +08:00
v-model="row.meritsSalary"
2024-12-10 17:17:14 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-12-24 17:28:34 +08:00
<span v-else> {{ row.meritsSalary }}</span>
2024-12-10 17:17:14 +08:00
</template>
</el-table-column>
<el-table-column label="绩效实发" min-width="90px">
2024-08-14 15:02:43 +08:00
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-12-24 17:28:34 +08:00
v-model="row.reallyMeritsSalary"
2024-08-14 15:02:43 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-12-24 17:28:34 +08:00
<span v-else> {{ row.reallyMeritsSalary }}</span>
2024-08-14 15:02:43 +08:00
</template>
</el-table-column>
2024-07-16 16:49:01 +08:00
<el-table-column label="补贴" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-22 16:04:19 +08:00
v-model="row.allowanceSalary"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-22 16:04:19 +08:00
<span v-else> {{ row.allowanceSalary }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
<el-table-column label="提成" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-22 16:04:19 +08:00
v-model="row.percentageSalary"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-22 16:04:19 +08:00
<span v-else> {{ row.percentageSalary }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
2024-07-18 12:34:01 +08:00
<el-table-column label="奖金" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-19 16:03:07 +08:00
v-model="row.rewardSalary"
2024-07-18 12:34:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-19 16:03:07 +08:00
<span v-else> {{ row.rewardSalary }}</span>
2024-07-18 12:34:01 +08:00
</template>
</el-table-column>
2024-07-16 16:49:01 +08:00
<el-table-column label="满勤" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-22 16:04:19 +08:00
v-model="row.fullWorkSalary"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-22 16:04:19 +08:00
<span v-else> {{ row.fullWorkSalary }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
<el-table-column label="其他" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-19 16:03:07 +08:00
v-model="row.extraSalary"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-19 16:03:07 +08:00
<span v-else> {{ row.extraSalary }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
2024-07-22 16:04:19 +08:00
<el-table-column label="小计" prop="salaryTotal" min-width="90px" />
2024-07-16 16:49:01 +08:00
</el-table-column>
2024-07-17 10:07:10 +08:00
<el-table-column label="应扣工资" align="center">
2024-07-16 16:49:01 +08:00
<el-table-column label="请假" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-22 16:04:19 +08:00
v-model="row.leaveDayDeduct"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-22 16:04:19 +08:00
<span v-else> {{ row.leaveDayDeduct }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
2024-07-17 10:10:57 +08:00
<el-table-column min-width="90px">
<template #header>
<Tooltip message="月中入职,入职前无需考勤天数" titel="缺勤" />
</template>
2024-07-16 16:49:01 +08:00
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-22 16:04:19 +08:00
v-model="row.absenceDeduct"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-22 16:04:19 +08:00
<span v-else> {{ row.absenceDeduct }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
<el-table-column label="旷工" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-22 16:04:19 +08:00
v-model="row.skipWorkDeduct"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-22 16:04:19 +08:00
<span v-else> {{ row.skipWorkDeduct }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
<el-table-column label="违纪" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-22 16:04:19 +08:00
v-model="row.breachDeduct"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-22 16:04:19 +08:00
<span v-else> {{ row.breachDeduct }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
<el-table-column label="公积金" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-19 16:03:07 +08:00
v-model="row.accumulationFundDeduct"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-19 16:03:07 +08:00
<span v-else> {{ row.accumulationFundDeduct }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
<el-table-column label="社保" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-19 16:03:07 +08:00
v-model="row.socialDeduct"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-19 16:03:07 +08:00
<span v-else> {{ row.socialDeduct }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
<el-table-column label="所得税" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-22 16:04:19 +08:00
v-model="row.taxDeduct"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-22 16:04:19 +08:00
<span v-else> {{ row.taxDeduct }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
<el-table-column label="其他" min-width="90px">
<template #default="{ row }">
<el-input-number
v-if="row.edit"
2024-07-22 16:04:19 +08:00
v-model="row.extraDeduct"
2024-07-16 16:49:01 +08:00
:min="0"
:controls="false"
size="small"
style="width: 65px"
/>
2024-07-22 16:04:19 +08:00
<span v-else> {{ row.extraDeduct }}</span>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
2024-07-22 16:04:19 +08:00
<el-table-column label="小计" prop="deductTotal" min-width="90px" />
2024-07-16 16:49:01 +08:00
</el-table-column>
2024-07-22 16:04:19 +08:00
<el-table-column label="实发工资" prop="gantSalary" fixed="right" width="90" />
2024-07-16 16:49:01 +08:00
<el-table-column label="操作" fixed="right" width="200">
<template #default="{ row }">
<el-button
type="primary"
style="padding: 0"
2024-07-22 20:07:53 +08:00
v-if="row.edit === '0'"
2024-07-16 16:49:01 +08:00
text
2024-07-18 15:11:37 +08:00
v-hasPermi="['home:salary:update']"
2024-07-16 16:49:01 +08:00
@click="handleEdit(row)"
>
修改
</el-button>
<el-button
type="primary"
2024-07-22 20:07:53 +08:00
v-else-if="row.edit === '1'"
2024-07-16 16:49:01 +08:00
text
style="padding: 0"
2024-07-18 15:11:37 +08:00
v-hasPermi="['home:salary:update']"
2024-07-16 16:49:01 +08:00
@click="handleSave(row)"
>
保存
</el-button>
<el-button
type="danger"
2024-07-25 14:45:44 +08:00
v-if="row.id"
:disabled="row.status == 1"
2024-07-16 16:49:01 +08:00
style="padding: 0"
text
2024-07-18 15:11:37 +08:00
v-hasPermi="['home:salary:sealup']"
2024-07-23 11:45:55 +08:00
@click="handleSealup(row)"
2024-07-16 16:49:01 +08:00
>
2024-07-25 14:45:44 +08:00
<span v-if="row.status == 0">封存</span>
<span v-else-if="row.status == 1">已封存</span>
2024-07-16 16:49:01 +08:00
</el-button>
2024-08-14 11:19:41 +08:00
<el-button type="primary" v-if="row.grantId" text @click="handleDetail(row)">
提成明细
</el-button>
2024-07-16 16:49:01 +08:00
</template>
</el-table-column>
</el-table>
2024-07-22 16:04:19 +08:00
<Pagination
:total="total"
v-model:page="searchForm.pageNo"
v-model:limit="searchForm.pageSize"
@pagination="getList"
/>
2024-07-16 16:49:01 +08:00
<DialogCreateSalary ref="createSalaryRef" @success="getList" />
2024-07-22 16:04:19 +08:00
<DialogSalaryImport ref="importSalaryRef" @success="getList" />
2024-07-16 16:49:01 +08:00
</div>
2024-07-15 18:21:49 +08:00
</template>
2024-07-16 16:49:01 +08:00
<script setup name="SalarySlip">
import DialogCreateSalary from './Comp/DialogCreateSalary.vue'
2024-07-22 16:04:19 +08:00
import DialogSalaryImport from './Comp/DialogSalaryImport.vue'
import { removeNullField } from '@/utils'
import * as SalaryApi from '@/api/home/salary.js'
2024-12-02 14:51:03 +08:00
import { ElLoading } from 'element-plus'
2024-07-22 16:04:19 +08:00
2024-07-23 11:45:55 +08:00
const message = useMessage() // 消息弹窗
2024-07-22 16:04:19 +08:00
const searchForm = ref({
name: undefined,
2024-07-22 20:07:53 +08:00
period: undefined,
2024-07-22 16:04:19 +08:00
pageNo: 1,
2024-07-22 20:07:53 +08:00
pageSize: 20
2024-07-22 16:04:19 +08:00
})
2024-07-16 16:49:01 +08:00
onMounted(() => {
handleSearch()
})
function handleSearch() {
2024-07-22 16:04:19 +08:00
searchForm.value.pageNo = 1
2024-07-16 16:49:01 +08:00
getList()
}
const loading = ref(false)
const tableList = ref([])
const total = ref(0)
2024-07-22 16:04:19 +08:00
async function getList() {
loading.value = true
try {
let params = {
...searchForm.value
}
2024-07-22 20:07:53 +08:00
if (params.period) {
2024-07-22 16:04:19 +08:00
params = {
...params,
2024-07-22 20:07:53 +08:00
year: new Date(params.period).getFullYear(),
month: new Date(params.period).getMonth() + 1
2024-07-22 16:04:19 +08:00
}
2024-07-16 16:49:01 +08:00
}
2024-07-22 16:04:19 +08:00
const data = await SalaryApi.getSalaryPage(removeNullField(params))
2024-07-22 20:07:53 +08:00
if (searchForm.value.name) {
tableList.value = data.list.reduce((pre, cur) => {
return pre.concat(cur.userSalaryGrantRespVOList)
}, [])
} else {
tableList.value = data.list.map((it, index) => ({
...it,
2024-12-10 17:17:14 +08:00
userSalaryGrantRespVOList: it.userSalaryGrantRespVOList.sort((pre, cur) =>
pre.name.localeCompare(cur.name)
),
2024-07-22 20:07:53 +08:00
id: index + 1,
2024-07-25 14:45:44 +08:00
edit: it.status == 1 ? '2' : '0'
2024-07-22 20:07:53 +08:00
}))
}
2024-07-22 16:04:19 +08:00
total.value = data.total
} catch (err) {
console.log(err)
} finally {
loading.value = false
}
2024-07-16 16:49:01 +08:00
}
const createSalaryRef = ref()
function craeteSalary() {
createSalaryRef.value.open()
}
2024-07-22 16:04:19 +08:00
const importSalaryRef = ref()
function importHistorySalary() {
importSalaryRef.value.open()
}
2024-07-16 16:49:01 +08:00
function spanMethod({ row, columnIndex }) {
2024-07-22 20:07:53 +08:00
if (row.userSalaryGrantRespVOList && row.userSalaryGrantRespVOList.length > 0) {
2024-07-16 16:49:01 +08:00
if (columnIndex === 0) {
2025-01-14 17:40:36 +08:00
return [1, 23]
} else if (columnIndex == 23 && row.id) {
2024-07-16 16:49:01 +08:00
return [1, 1]
} else {
return [0, 0]
}
}
}
function handleEdit(row) {
2024-07-22 20:07:53 +08:00
row.edit = '1'
row.userSalaryGrantRespVOList.forEach((it) => (it.edit = true))
2024-07-16 16:49:01 +08:00
}
2024-12-02 14:51:03 +08:00
const globalLoading = ref({})
2024-07-23 11:45:55 +08:00
async function handleSave(row) {
2024-12-02 14:51:03 +08:00
try {
row.edit = '0'
row.userSalaryGrantRespVOList.forEach((it) => (it.edit = false))
globalLoading.value = ElLoading.service({
lock: true,
text: `工资条数据保存中,请稍后...`,
background: 'rgba(0, 0, 0, 0.7)'
})
await SalaryApi.updateSalarySlip(row.userSalaryGrantRespVOList)
globalLoading.value.close()
message.success('保存成功!')
getList()
} catch {
globalLoading.value.close()
}
2024-07-23 11:45:55 +08:00
}
async function handleSealup(row) {
try {
// 二次确认
await message.confirm('确认要封存"' + row.period + '"工资条吗?')
// 发起修改状态
await SalaryApi.sealupSalarySlip({
grantIdList: row.userSalaryGrantRespVOList.map((it) => it.grantId),
period: row.period
})
2024-12-03 16:05:36 +08:00
message.success('封存成功!')
2024-07-23 11:45:55 +08:00
// 刷新列表
await getList()
} catch (err) {
console.log(err)
}
2024-07-16 16:49:01 +08:00
}
2024-08-14 11:19:41 +08:00
async function handleDetail(row) {
try {
const data = await SalaryApi.getCommissionDetail({ id: row.grantId })
2024-08-14 14:55:37 +08:00
if (data) {
message.alert(data)
} else {
message.info('该员工未配置提成方案!')
}
2024-08-14 11:19:41 +08:00
} catch (error) {
message.error(error)
console.log(error)
}
}
2024-07-16 16:49:01 +08:00
</script>
<style lang="scss" scoped>
:deep(.el-table__indent) {
display: none;
}
2024-07-15 18:21:49 +08:00
2024-07-16 16:49:01 +08:00
:deep(.el-table__placeholder) {
display: none;
}
</style>