<template>
|
<div class="app-container">
|
<!--工具栏-->
|
<div class="head-container">
|
<div v-if="crud.props.searchToggle">
|
<!-- 搜索 -->
|
<label class="el-form-item-label">员工</label>
|
<el-select v-model="query.userId" filterable clearable placeholder="请选择员工" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
|
<el-option
|
v-for="item in users"
|
:key="item.id"
|
:label="item.nickName"
|
:value="item.id"
|
/>
|
</el-select>
|
<label class="el-form-item-label">年月</label>
|
<el-date-picker v-model="query.yearMonth" clearable type="month" format="yyyy 年 MM 月" placeholder="请选择年月" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
<rrOperation :crud="crud" />
|
</div>
|
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
<crudOperation :permission="permission">
|
<el-button
|
slot="right"
|
v-permission="permission.generate"
|
class="filter-item"
|
size="mini"
|
type="primary"
|
icon="el-icon-plus"
|
style="margin-right: 6px;"
|
@click="openGenerate"
|
>生成</el-button>
|
</crudOperation>
|
<!--表单组件-->
|
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
|
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
|
<el-form-item label="员工" prop="userId">
|
<el-select v-model="form.userId" filterable clearable placeholder="请选择员工" style="width: 340px;" @change="changeUser">
|
<el-option
|
v-for="item in users"
|
:key="item.id"
|
:label="item.nickName"
|
:value="item.id"
|
>
|
<span style="float: left">{{ item.nickName }}</span>
|
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.company.label }}</span>
|
</el-option>
|
</el-select>
|
<el-button icon="el-icon-refresh" plain circle @click="loadCmnInsurance" />
|
</el-form-item>
|
<el-form-item label="年月" prop="yearMonth">
|
<el-date-picker v-model="form.yearMonth" value-format="yyyy-MM" format="yyyy 年 MM 月" clearable type="month" placeholder="请选择年月" style="width: 370px;" />
|
</el-form-item>
|
<el-form-item label="公积金基数" prop="accumulationFund">
|
<el-input v-model="form.accumulationFund" style="width: 370px;" />
|
</el-form-item>
|
<el-form-item label="公积金个人比例" prop="accumulationFundPersonal">
|
<el-input v-model="form.accumulationFundPersonal" style="width: 370px;">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="公积金公司比例" prop="accumulationFundCompany">
|
<el-input v-model="form.accumulationFundCompany" style="width: 370px;">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="养老险基数" prop="retirementInsurance">
|
<el-input v-model="form.retirementInsurance" style="width: 370px;" />
|
</el-form-item>
|
<el-form-item label="公积金个人比例" prop="retirementInsurancePersonal">
|
<el-input v-model="form.retirementInsurancePersonal" style="width: 370px;">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="公积金公司比例" prop="retirementInsuranceCompany">
|
<el-input v-model="form.retirementInsuranceCompany" style="width: 370px;">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="医疗险基数" prop="medicalInsurance">
|
<el-input v-model="form.medicalInsurance" style="width: 370px;" />
|
</el-form-item>
|
<el-form-item label="医疗险个人比例" prop="medicalInsurancePersonal">
|
<el-input v-model="form.medicalInsurancePersonal" style="width: 370px;">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="医疗险公司比例" prop="medicalInsuranceCompany">
|
<el-input v-model="form.medicalInsuranceCompany" style="width: 370px;">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="失业险基数" prop="unemploymentInsurance">
|
<el-input v-model="form.unemploymentInsurance" style="width: 370px;" />
|
</el-form-item>
|
<el-form-item label="失业险个人比例" prop="unemploymentInsurancePersonal">
|
<el-input v-model="form.unemploymentInsurancePersonal" style="width: 370px;">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="失业险公司比例" prop="unemploymentInsuranceCompany">
|
<el-input v-model="form.unemploymentInsuranceCompany" style="width: 370px;">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="生育险基数" prop="birthInsurance">
|
<el-input v-model="form.birthInsurance" style="width: 370px;" />
|
</el-form-item>
|
<el-form-item label="生育险个人比例" prop="birthInsurancePersonal">
|
<el-input v-model="form.birthInsurancePersonal" style="width: 370px;">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="生育险公司比例" prop="birthInsuranceCompany">
|
<el-input v-model="form.birthInsuranceCompany" style="width: 370px;">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="工伤险基数" prop="employmentInsurance">
|
<el-input v-model="form.employmentInsurance" style="width: 370px;" />
|
</el-form-item>
|
<el-form-item label="工伤险个人比例" prop="employmentInsurancePersonal">
|
<el-input v-model="form.employmentInsurancePersonal" style="width: 370px;">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="工伤险公司比例" prop="employmentInsuranceCompany">
|
<el-input v-model="form.employmentInsuranceCompany" style="width: 370px;">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
<el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
</div>
|
</el-dialog>
|
<!--表格渲染-->
|
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
<el-table-column type="selection" width="55" />
|
<el-table-column prop="nickName" label="员工" />
|
<el-table-column prop="yearMonth" label="年月" />
|
<el-table-column prop="accumulationFund" label="公积金基数" />
|
<el-table-column prop="accumulationFundPersonal" label="公积金个人比例">
|
<template slot-scope="scope">
|
{{ scope.row.accumulationFundPersonal }}%
|
</template>
|
</el-table-column>
|
<el-table-column prop="accumulationFundCompany" label="公积金公司比例">
|
<template slot-scope="scope">
|
{{ scope.row.accumulationFundCompany }}%
|
</template>
|
</el-table-column>
|
<el-table-column prop="retirementInsurance" label="养老险基数" />
|
<el-table-column prop="retirementInsurancePersonal" label="公积金个人比例">
|
<template slot-scope="scope">
|
{{ scope.row.retirementInsurancePersonal }}%
|
</template>
|
</el-table-column>
|
<el-table-column prop="retirementInsuranceCompany" label="公积金公司比例">
|
<template slot-scope="scope">
|
{{ scope.row.retirementInsuranceCompany }}%
|
</template>
|
</el-table-column>
|
<el-table-column prop="medicalInsurance" label="医疗险基数" />
|
<el-table-column prop="medicalInsurancePersonal" label="医疗险个人比例">
|
<template slot-scope="scope">
|
{{ scope.row.medicalInsurancePersonal }}%
|
</template>
|
</el-table-column>
|
<el-table-column prop="medicalInsuranceCompany" label="医疗险公司比例">
|
<template slot-scope="scope">
|
{{ scope.row.medicalInsuranceCompany }}%
|
</template>
|
</el-table-column>
|
<el-table-column prop="unemploymentInsurance" label="失业险基数" />
|
<el-table-column prop="unemploymentInsurancePersonal" label="失业险个人比例">
|
<template slot-scope="scope">
|
{{ scope.row.unemploymentInsurancePersonal }}%
|
</template>
|
</el-table-column>
|
<el-table-column prop="unemploymentInsuranceCompany" label="失业险公司比例">
|
<template slot-scope="scope">
|
{{ scope.row.unemploymentInsuranceCompany }}%
|
</template>
|
</el-table-column>
|
<el-table-column prop="birthInsurance" label="生育险基数" />
|
<el-table-column prop="birthInsurancePersonal" label="生育险个人比例">
|
<template slot-scope="scope">
|
{{ scope.row.birthInsurancePersonal }}%
|
</template>
|
</el-table-column>
|
<el-table-column prop="birthInsuranceCompany" label="生育险公司比例">
|
<template slot-scope="scope">
|
{{ scope.row.birthInsuranceCompany }}%
|
</template>
|
</el-table-column>
|
<el-table-column prop="employmentInsurance" label="工伤险基数" />
|
<el-table-column prop="employmentInsurancePersonal" label="工伤险个人比例">
|
<template slot-scope="scope">
|
{{ scope.row.employmentInsurancePersonal }}%
|
</template>
|
</el-table-column>
|
<el-table-column prop="employmentInsuranceCompany" label="工伤险公司比例">
|
<template slot-scope="scope">
|
{{ scope.row.employmentInsuranceCompany }}%
|
</template>
|
</el-table-column>
|
<el-table-column v-if="checkPer(['admin','userInsurance:edit','userInsurance:del','userInsurance:generate'])" label="操作" width="150px" align="center">
|
<template slot-scope="scope">
|
<udOperation
|
:data="scope.row"
|
:permission="permission"
|
/>
|
</template>
|
</el-table-column>
|
</el-table>
|
<!--分页组件-->
|
<pagination />
|
<!--表单组件-->
|
<el-dialog :close-on-click-modal="false" :before-close="closeGenerate" :visible.sync="generateStatus" title="生成五险一金" width="500px">
|
<el-form ref="generateForm" :model="generateForm" :rules="generateRules" size="small" label-width="80px">
|
<el-form-item label="工资年月" prop="targetYearMonth">
|
<el-date-picker
|
v-model="generateForm.targetYearMonth"
|
value-format="yyyy-MM"
|
format="yyyy 年 MM 月"
|
type="month"
|
style="width: 370px;"
|
placeholder="工资年月"
|
/>
|
</el-form-item>
|
<el-form-item label="员工" prop="userId">
|
<el-tree
|
ref="tree"
|
:data="deptDatas"
|
:props="props"
|
:load="getDeptDatas"
|
lazy
|
:default-expanded-keys="[]"
|
show-checkbox
|
node-key="id"
|
@check="handleCheckChange"
|
/>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="text" @click="closeGenerate">取消</el-button>
|
<el-button :loading="generateLoading" type="primary" @click="submitGenerate">确认</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import crudUserInsurance from '@/api/treatment/userInsurance'
|
import crudCmnInsurance from '@/api/treatment/cmnInsurance'
|
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
import rrOperation from '@crud/RR.operation'
|
import crudOperation from '@crud/CRUD.operation'
|
import udOperation from '@crud/UD.operation'
|
import pagination from '@crud/Pagination'
|
import crudUser from '@/api/system/user'
|
import { getDepts } from '@/api/system/dept'
|
|
const defaultForm = { id: null, userId: null, yearMonth: null, accumulationFund: null, accumulationFundPersonal: null, accumulationFundCompany: null, retirementInsurance: null, retirementInsurancePersonal: null, retirementInsuranceCompany: null, medicalInsurance: null, medicalInsurancePersonal: null, medicalInsuranceCompany: null, unemploymentInsurance: null, unemploymentInsurancePersonal: null, unemploymentInsuranceCompany: null, birthInsurance: null, birthInsurancePersonal: null, birthInsuranceCompany: null, employmentInsurance: null, employmentInsurancePersonal: null, employmentInsuranceCompany: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
|
export default {
|
name: 'UserInsurance',
|
components: { pagination, crudOperation, rrOperation, udOperation },
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
cruds() {
|
return CRUD({ title: '员工五险一金', url: 'api/userInsurance', idField: 'id', sort: 'id,desc', crudMethod: { ...crudUserInsurance }})
|
},
|
data() {
|
return {
|
permission: {
|
add: ['admin'],
|
edit: ['admin', 'userInsurance:edit'],
|
del: ['admin', 'userInsurance:del'],
|
download: ['admin', 'userInsurance:list'],
|
generate: ['admin', 'userInsurance:generate']
|
},
|
rules: {
|
userId: [
|
{ required: true, message: '员工不能为空', trigger: 'blur' }
|
],
|
yearMonth: [
|
{ required: true, message: '年月不能为空', trigger: 'blur' }
|
],
|
accumulationFund: [
|
{ required: true, message: '公积金基数不能为空', trigger: 'blur' }
|
],
|
accumulationFundPersonal: [
|
{ required: true, message: '公积金个人缴纳比例不能为空', trigger: 'blur' }
|
],
|
accumulationFundCompany: [
|
{ required: true, message: '公积金公司缴纳比例不能为空', trigger: 'blur' }
|
],
|
retirementInsurance: [
|
{ required: true, message: '养老险基数不能为空', trigger: 'blur' }
|
],
|
retirementInsurancePersonal: [
|
{ required: true, message: '养老险个人缴纳比例不能为空', trigger: 'blur' }
|
],
|
retirementInsuranceCompany: [
|
{ required: true, message: '养老险公司缴纳比例不能为空', trigger: 'blur' }
|
],
|
medicalInsurance: [
|
{ required: true, message: '医疗险基数不能为空', trigger: 'blur' }
|
],
|
medicalInsurancePersonal: [
|
{ required: true, message: '医疗险个人缴纳比例不能为空', trigger: 'blur' }
|
],
|
medicalInsuranceCompany: [
|
{ required: true, message: '医疗险公司缴纳比例不能为空', trigger: 'blur' }
|
],
|
unemploymentInsurance: [
|
{ required: true, message: '失业险基数不能为空', trigger: 'blur' }
|
],
|
unemploymentInsurancePersonal: [
|
{ required: true, message: '失业险个人缴纳比例不能为空', trigger: 'blur' }
|
],
|
unemploymentInsuranceCompany: [
|
{ required: true, message: '失业险公司缴纳比例不能为空', trigger: 'blur' }
|
],
|
birthInsurance: [
|
{ required: true, message: '生育险基数不能为空', trigger: 'blur' }
|
],
|
birthInsurancePersonal: [
|
{ required: true, message: '生育险个人缴纳比例不能为空', trigger: 'blur' }
|
],
|
birthInsuranceCompany: [
|
{ required: true, message: '生育险公司缴纳比例不能为空', trigger: 'blur' }
|
],
|
employmentInsurance: [
|
{ required: true, message: '工伤险基数不能为空', trigger: 'blur' }
|
],
|
employmentInsurancePersonal: [
|
{ required: true, message: '工伤险个人缴纳比例不能为空', trigger: 'blur' }
|
],
|
employmentInsuranceCompany: [
|
{ required: true, message: '工伤险公司缴纳比例不能为空', trigger: 'blur' }
|
]
|
},
|
queryTypeOptions: [
|
{ key: 'userId', display_name: '员工' },
|
{ key: 'yearMonth', display_name: '年月' }
|
],
|
// 员工
|
users: [],
|
// 生成表单状态
|
generateStatus: false,
|
// 生成表单加载
|
generateLoading: false,
|
// 生成表单数据
|
generateForm: { targetYearMonth: null, nodes: [] },
|
// 生成表单验证
|
generateRules: {
|
targetYearMonth: [
|
{ required: true, message: '工资年月不能为空', trigger: 'blur' }
|
]
|
},
|
props: {
|
children: 'children', label: 'label', isLeaf: 'leaf'
|
},
|
deptDatas: []
|
}
|
},
|
mounted() {
|
this.getAllUser()
|
},
|
methods: {
|
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
[CRUD.HOOK.beforeRefresh]() {
|
return true
|
},
|
// 获取全部员工
|
getAllUser() {
|
// 用户
|
crudUser.getAll({ enabled: true }).then(res => {
|
this.users = res
|
})
|
},
|
// 变更员工
|
changeUser(userId) {
|
this.form.company = null
|
this.users.forEach(user => {
|
if (user.id === userId) {
|
this.form.company = user.company
|
}
|
})
|
},
|
// 生成表单打开
|
openGenerate() {
|
// 生成表单数据
|
this.generateForm = { targetYearMonth: null, nodes: [] }
|
// 生成表单状态
|
this.generateStatus = true
|
},
|
// 生成表单关闭
|
closeGenerate() {
|
// 生成表单状态
|
this.generateStatus = false
|
this.getDeptDatas({ level: 0 })
|
// 清空表单
|
this.$refs['generateForm'].clearValidate()
|
},
|
// 生成表单提交
|
submitGenerate() {
|
// 生成表单加载
|
this.generateLoading = true
|
// 表单验证
|
this.$refs['generateForm'].validate((valid) => {
|
if (valid) {
|
// 生成工资
|
crudUserInsurance.generate(this.generateForm).then(res => {
|
// 生成表单加载
|
this.generateLoading = false
|
// 生成表单关闭
|
this.closeGenerate()
|
// 搜索:刷新表格
|
this.crud.toQuery()
|
// 消息提示
|
this.crud.notify('生成成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
}).catch(() => {
|
// 生成表单加载
|
this.generateLoading = false
|
})
|
} else {
|
// 生成表单加载
|
this.generateLoading = false
|
}
|
})
|
},
|
// 加载企业五险一金
|
loadCmnInsurance() {
|
if (this.form.company === undefined || this.form.company === null) {
|
return false
|
}
|
crudCmnInsurance.getAll({ companyId: this.form.company.id }).then(res => {
|
// 公积金基数
|
if (this.form.accumulationFund === null || this.form.accumulationFund < res[0].accumulationFund) {
|
this.form.accumulationFund = res[0].accumulationFund
|
}
|
// 公积金个人比例
|
if (this.form.accumulationFundPersonal === null || this.form.accumulationFundPersonal < res[0].accumulationFundPersonal) {
|
this.form.accumulationFundPersonal = res[0].accumulationFundPersonal
|
}
|
// 公积金公司比例
|
if (this.form.accumulationFundCompany === null || this.form.accumulationFundCompany < res[0].accumulationFundCompany) {
|
this.form.accumulationFundCompany = res[0].accumulationFundCompany
|
}
|
// 养老保险基数
|
if (this.form.retirementInsurance === null || this.form.retirementInsurance < res[0].retirementInsurance) {
|
this.form.retirementInsurance = res[0].retirementInsurance
|
}
|
// 养老保险个人比例
|
if (this.form.retirementInsurancePersonal === null || this.form.retirementInsurancePersonal < res[0].retirementInsurancePersonal) {
|
this.form.retirementInsurancePersonal = res[0].retirementInsurancePersonal
|
}
|
// 养老保险公司比例
|
if (this.form.retirementInsuranceCompany === null || this.form.retirementInsuranceCompany < res[0].retirementInsuranceCompany) {
|
this.form.retirementInsuranceCompany = res[0].retirementInsuranceCompany
|
}
|
// 医疗保险基数
|
if (this.form.medicalInsurance === null || this.form.medicalInsurance < res[0].medicalInsurance) {
|
this.form.medicalInsurance = res[0].medicalInsurance
|
}
|
// 医疗保险个人比例
|
if (this.form.medicalInsurancePersonal === null || this.form.medicalInsurancePersonal < res[0].medicalInsurancePersonal) {
|
this.form.medicalInsurancePersonal = res[0].medicalInsurancePersonal
|
}
|
// 医疗保险公司比例
|
if (this.form.medicalInsuranceCompany === null || this.form.medicalInsuranceCompany < res[0].medicalInsuranceCompany) {
|
this.form.medicalInsuranceCompany = res[0].medicalInsuranceCompany
|
}
|
// 失业保险基数
|
if (this.form.unemploymentInsurance === null || this.form.unemploymentInsurance < res[0].unemploymentInsurance) {
|
this.form.unemploymentInsurance = res[0].unemploymentInsurance
|
}
|
// 失业保险个人比例
|
if (this.form.unemploymentInsurancePersonal === null || this.form.unemploymentInsurancePersonal < res[0].unemploymentInsurancePersonal) {
|
this.form.unemploymentInsurancePersonal = res[0].unemploymentInsurancePersonal
|
}
|
// 失业保险公司比例
|
if (this.form.unemploymentInsuranceCompany === null || this.form.unemploymentInsuranceCompany < res[0].unemploymentInsuranceCompany) {
|
this.form.unemploymentInsuranceCompany = res[0].unemploymentInsuranceCompany
|
}
|
// 生育保险基数
|
if (this.form.birthInsurance === null || this.form.birthInsurance < res[0].birthInsurance) {
|
this.form.birthInsurance = res[0].birthInsurance
|
}
|
// 生育保险个人比例
|
if (this.form.birthInsurancePersonal === null || this.form.birthInsurancePersonal < res[0].birthInsurancePersonal) {
|
this.form.birthInsurancePersonal = res[0].birthInsurancePersonal
|
}
|
// 生育保险公司比例
|
if (this.form.birthInsuranceCompany === null || this.form.birthInsuranceCompany < res[0].birthInsuranceCompany) {
|
this.form.birthInsuranceCompany = res[0].birthInsuranceCompany
|
}
|
// 工伤保险基数
|
if (this.form.employmentInsurance === null || this.form.employmentInsurance < res[0].employmentInsurance) {
|
this.form.employmentInsurance = res[0].employmentInsurance
|
}
|
// 工伤保险个人比例
|
if (this.form.employmentInsurancePersonal === null || this.form.employmentInsurancePersonal < res[0].employmentInsurancePersonal) {
|
this.form.employmentInsurancePersonal = res[0].employmentInsurancePersonal
|
}
|
// 工伤保险公司比例
|
if (this.form.employmentInsuranceCompany === null || this.form.employmentInsuranceCompany < res[0].employmentInsuranceCompany) {
|
this.form.employmentInsuranceCompany = res[0].employmentInsuranceCompany
|
}
|
})
|
},
|
// 获取部门数据
|
getDeptDatas(node, resolve) {
|
const sort = 'id,desc'
|
const params = { sort: sort }
|
if (node.level !== 0) {
|
crudUser.getByDept(node.level !== 0 ? node.data.id : null).then(res => {
|
if (resolve) {
|
resolve(res)
|
} else {
|
this.deptDatas = res.content
|
}
|
})
|
} else {
|
getDepts(params).then(res => {
|
if (resolve) {
|
resolve(res.content)
|
} else {
|
this.deptDatas = res.content
|
}
|
})
|
}
|
},
|
handleCheckChange(data, status) {
|
this.generateForm.nodes = status.checkedNodes
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|