367 lines
8.2 KiB
Vue
367 lines
8.2 KiB
Vue
<template>
|
|
<view class="page">
|
|
<scroll-view class="body" scroll-y :show-scrollbar="false">
|
|
<view class="body-inner">
|
|
<view v-if="loading" class="state-box">
|
|
<text class="state-text">加载中...</text>
|
|
</view>
|
|
<u-empty
|
|
v-else-if="!payroll"
|
|
mode="list"
|
|
:icon-size="80"
|
|
text="工资单不存在或无权查看"
|
|
/>
|
|
<block v-else>
|
|
<view class="hero-card">
|
|
<view class="hero-head">
|
|
<text class="hero-month">{{ payroll.payroll_month }} 工资单</text>
|
|
<u-tag
|
|
:text="getPayrollStatusLabel(payroll.status)"
|
|
size="mini"
|
|
bg-color="rgba(255,255,255,0.22)"
|
|
color="#ffffff"
|
|
border-color="rgba(255,255,255,0.22)"
|
|
/>
|
|
</view>
|
|
<view class="hero-amount">
|
|
<text class="amount-label">实发合计</text>
|
|
<text class="amount-value">¥{{ money(payroll.net_salary) }}</text>
|
|
</view>
|
|
<view class="hero-meta">
|
|
<text>{{ payroll.employee_name || '本人' }}</text>
|
|
<text v-if="payroll.department">· {{ payroll.department }}</text>
|
|
<text v-if="payroll.position">· {{ payroll.position }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="sum-card">
|
|
<view class="sum-item">
|
|
<text class="sum-value income">¥{{ money(payroll.gross_salary) }}</text>
|
|
<text class="sum-label">应发合计</text>
|
|
</view>
|
|
<view class="sum-line" />
|
|
<view class="sum-item">
|
|
<text class="sum-value deduct">¥{{ money(payroll.total_deduction) }}</text>
|
|
<text class="sum-label">扣款合计</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view v-if="incomeItems.length" class="group-card">
|
|
<view class="group-head">
|
|
<view class="group-bar" />
|
|
<text class="group-title">应发项目</text>
|
|
</view>
|
|
<view v-for="item in incomeItems" :key="item.key" class="row">
|
|
<text class="row-label">{{ item.label }}</text>
|
|
<text class="row-value income">+{{ money(item.amount) }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view v-if="deductItems.length" class="group-card">
|
|
<view class="group-head">
|
|
<view class="group-bar danger" />
|
|
<text class="group-title">扣款项目</text>
|
|
</view>
|
|
<view v-for="item in deductItems" :key="item.key" class="row">
|
|
<text class="row-label">{{ item.label }}</text>
|
|
<text class="row-value deduct">-{{ money(item.amount) }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="group-card">
|
|
<view class="group-head">
|
|
<view class="group-bar" />
|
|
<text class="group-title">其他信息</text>
|
|
</view>
|
|
<view class="row">
|
|
<text class="row-label">薪资月份</text>
|
|
<text class="row-text">{{ payroll.payroll_month || '-' }}</text>
|
|
</view>
|
|
<view class="row">
|
|
<text class="row-label">状态</text>
|
|
<text class="row-text">{{ getPayrollStatusLabel(payroll.status) }}</text>
|
|
</view>
|
|
<view v-if="payroll.confirmed_at" class="row">
|
|
<text class="row-label">确认时间</text>
|
|
<text class="row-text">{{ payroll.confirmed_at }}</text>
|
|
</view>
|
|
<view v-if="payroll.paid_at" class="row">
|
|
<text class="row-label">发放时间</text>
|
|
<text class="row-text">{{ payroll.paid_at }}</text>
|
|
</view>
|
|
<view v-if="payroll.remark" class="row">
|
|
<text class="row-label">备注</text>
|
|
<text class="row-text">{{ payroll.remark }}</text>
|
|
</view>
|
|
</view>
|
|
</block>
|
|
<view class="bottom-space" />
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, computed, onMounted } from 'vue'
|
|
import { getPayroll, getPayrollStatusLabel } from '@/api/oa.js'
|
|
import { isLoggedIn } from '@/utils/auth.js'
|
|
|
|
const id = ref(0)
|
|
const payroll = ref(null)
|
|
const loading = ref(true)
|
|
|
|
const INCOME_FIELDS = [
|
|
{ key: 'base_salary', label: '基本工资' },
|
|
{ key: 'post_allowance', label: '岗位津贴' },
|
|
{ key: 'performance_salary', label: '绩效工资' },
|
|
{ key: 'transport_allowance', label: '交通补贴' },
|
|
{ key: 'meal_allowance', label: '餐补' },
|
|
{ key: 'communication_allowance', label: '通讯补贴' },
|
|
{ key: 'overtime_pay', label: '加班费' },
|
|
{ key: 'bonus', label: '奖金' },
|
|
{ key: 'other_addition', label: '其他增加' }
|
|
]
|
|
|
|
const DEDUCT_FIELDS = [
|
|
{ key: 'leave_deduction', label: '请假扣款' },
|
|
{ key: 'late_deduction', label: '迟到扣款' },
|
|
{ key: 'other_deduction', label: '其他扣款' },
|
|
{ key: 'social_insurance', label: '社保' },
|
|
{ key: 'housing_fund', label: '公积金' },
|
|
{ key: 'personal_income_tax', label: '个人所得税' }
|
|
]
|
|
|
|
const incomeItems = computed(() => {
|
|
if (!payroll.value) return []
|
|
const base = INCOME_FIELDS
|
|
.filter(f => Number(payroll.value[f.key]) > 0)
|
|
.map(f => ({ key: f.key, label: f.label, amount: Number(payroll.value[f.key]) }))
|
|
const custom = (payroll.value.items || [])
|
|
.filter(it => it.item_type === 1)
|
|
.map(it => ({ key: 'c' + it.id, label: it.item_name, amount: Number(it.amount) }))
|
|
return base.concat(custom)
|
|
})
|
|
|
|
const deductItems = computed(() => {
|
|
if (!payroll.value) return []
|
|
const base = DEDUCT_FIELDS
|
|
.filter(f => Number(payroll.value[f.key]) > 0)
|
|
.map(f => ({ key: f.key, label: f.label, amount: Number(payroll.value[f.key]) }))
|
|
const custom = (payroll.value.items || [])
|
|
.filter(it => it.item_type === 2)
|
|
.map(it => ({ key: 'c' + it.id, label: it.item_name, amount: Number(it.amount) }))
|
|
return base.concat(custom)
|
|
})
|
|
|
|
onMounted(() => {
|
|
if (!isLoggedIn()) {
|
|
uni.reLaunch({ url: '/pages/login/login' })
|
|
return
|
|
}
|
|
const pages = getCurrentPages()
|
|
const current = pages[pages.length - 1]
|
|
id.value = Number((current && current.options && current.options.id) || 0)
|
|
loadDetail()
|
|
})
|
|
|
|
async function loadDetail() {
|
|
if (!id.value) {
|
|
loading.value = false
|
|
return
|
|
}
|
|
loading.value = true
|
|
try {
|
|
payroll.value = await getPayroll(id.value)
|
|
} catch (e) {
|
|
payroll.value = null
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
function money(value) {
|
|
return (Number(value) || 0).toFixed(2)
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import '@/src/styles/page-common.scss';
|
|
|
|
.page {
|
|
min-height: 100vh;
|
|
background: $color-bg-page;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.body {
|
|
flex: 1;
|
|
height: 0;
|
|
}
|
|
|
|
.body-inner {
|
|
padding: 24rpx $page-padding-x 0;
|
|
}
|
|
|
|
.hero-card {
|
|
@include card;
|
|
padding: 32rpx 28rpx;
|
|
background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
|
|
box-shadow: $shadow-float;
|
|
}
|
|
|
|
.hero-head {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.hero-month {
|
|
font-size: 28rpx;
|
|
color: rgba(255, 255, 255, 0.9);
|
|
}
|
|
|
|
.hero-amount {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8rpx;
|
|
margin-top: 26rpx;
|
|
}
|
|
|
|
.amount-label {
|
|
font-size: 24rpx;
|
|
color: rgba(255, 255, 255, 0.82);
|
|
}
|
|
|
|
.amount-value {
|
|
font-size: 60rpx;
|
|
font-weight: 700;
|
|
color: #ffffff;
|
|
line-height: 1.1;
|
|
}
|
|
|
|
.hero-meta {
|
|
margin-top: 16rpx;
|
|
font-size: 23rpx;
|
|
color: rgba(255, 255, 255, 0.82);
|
|
}
|
|
|
|
.sum-card {
|
|
@include card;
|
|
margin-top: 20rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 26rpx 0;
|
|
}
|
|
|
|
.sum-item {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 8rpx;
|
|
}
|
|
|
|
.sum-line {
|
|
width: 1rpx;
|
|
height: 56rpx;
|
|
background: $color-divider;
|
|
}
|
|
|
|
.sum-value {
|
|
font-size: 34rpx;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.sum-label {
|
|
font-size: 23rpx;
|
|
color: $color-text-muted;
|
|
}
|
|
|
|
.group-card {
|
|
@include card;
|
|
margin-top: 20rpx;
|
|
padding: 24rpx 28rpx;
|
|
}
|
|
|
|
.group-head {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12rpx;
|
|
margin-bottom: 8rpx;
|
|
}
|
|
|
|
.group-bar {
|
|
width: 6rpx;
|
|
height: 26rpx;
|
|
border-radius: 3rpx;
|
|
background: $color-primary;
|
|
|
|
&.danger {
|
|
background: $color-danger;
|
|
}
|
|
}
|
|
|
|
.group-title {
|
|
font-size: 29rpx;
|
|
font-weight: 600;
|
|
color: $color-text;
|
|
}
|
|
|
|
.row {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 20rpx;
|
|
padding: 22rpx 0;
|
|
border-bottom: 1rpx solid $color-divider;
|
|
|
|
&:last-child {
|
|
border-bottom: none;
|
|
}
|
|
}
|
|
|
|
.row-label {
|
|
font-size: 27rpx;
|
|
color: $color-text-secondary;
|
|
}
|
|
|
|
.row-value {
|
|
font-size: 29rpx;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.row-text {
|
|
font-size: 27rpx;
|
|
color: $color-text;
|
|
text-align: right;
|
|
flex: 1;
|
|
}
|
|
|
|
.income {
|
|
color: $color-success;
|
|
}
|
|
|
|
.deduct {
|
|
color: $color-danger;
|
|
}
|
|
|
|
.state-box {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 200rpx 48rpx;
|
|
gap: 20rpx;
|
|
}
|
|
|
|
.state-text {
|
|
font-size: 26rpx;
|
|
color: $color-text-muted;
|
|
text-align: center;
|
|
}
|
|
|
|
.bottom-space {
|
|
height: 48rpx;
|
|
}
|
|
</style> |