主要更新uniapp相关功能
This commit is contained in:
1 parent
aa92ca40a2
commit
5b4dbb2b46
65 files changed
+8532
-1921
No files matched your search
@@ -0,0 +1,367 @@
|
||||
<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>
|
||||
@@ -0,0 +1,230 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="toolbar">
|
||||
<picker mode="date" fields="month" :value="month || currentMonth" @change="onMonthChange">
|
||||
<view class="month-picker">
|
||||
<FaIcon name="calendar-days" color="#2563eb" :size="16" />
|
||||
<text class="month-text">{{ month || '全部月份' }}</text>
|
||||
<FaIcon name="chevron-right" color="#8a94ad" :size="12" />
|
||||
</view>
|
||||
</picker>
|
||||
<view v-if="month" class="clear-btn" @tap="clearMonth">查看全部</view>
|
||||
</view>
|
||||
|
||||
<scroll-view class="list-scroll" scroll-y :show-scrollbar="false">
|
||||
<view v-if="loading" class="state-box">
|
||||
<text class="state-text">加载中...</text>
|
||||
</view>
|
||||
<u-empty
|
||||
v-else-if="list.length === 0"
|
||||
mode="list"
|
||||
:icon-size="80"
|
||||
text="暂无工资单记录"
|
||||
/>
|
||||
<view v-else class="pay-list">
|
||||
<view v-for="item in list" :key="item.id" class="pay-card" @tap="openDetail(item.id)">
|
||||
<view class="pay-head">
|
||||
<text class="pay-month">{{ item.payroll_month }}</text>
|
||||
<text class="status-tag" :class="'st-' + item.status">{{ getPayrollStatusLabel(item.status) }}</text>
|
||||
</view>
|
||||
<view class="pay-amount">
|
||||
<text class="amount-label">实发</text>
|
||||
<text class="amount-value">¥{{ money(item.net_salary) }}</text>
|
||||
</view>
|
||||
<view class="pay-meta">
|
||||
<text>{{ item.employee_name || '本人' }}</text>
|
||||
<text v-if="item.department">· {{ item.department }}</text>
|
||||
<text v-if="item.position">· {{ item.position }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottom-space" />
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { fetchPayrolls, getPayrollStatusLabel } from '@/api/oa.js'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
import { pad } from '@/utils/date.js'
|
||||
|
||||
const month = ref('')
|
||||
const list = ref([])
|
||||
const loading = ref(false)
|
||||
|
||||
const now = new Date()
|
||||
const currentMonth = `${now.getFullYear()}-${pad(now.getMonth() + 1)}`
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
return
|
||||
}
|
||||
loadPayrolls()
|
||||
})
|
||||
|
||||
async function loadPayrolls() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchPayrolls({ payrollMonth: month.value, pageSize: 50 })
|
||||
list.value = res.list
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onMonthChange(e) {
|
||||
month.value = e.detail.value
|
||||
loadPayrolls()
|
||||
}
|
||||
|
||||
function clearMonth() {
|
||||
month.value = ''
|
||||
loadPayrolls()
|
||||
}
|
||||
|
||||
function money(value) {
|
||||
return (Number(value) || 0).toFixed(2)
|
||||
}
|
||||
|
||||
function openDetail(id) {
|
||||
uni.navigateTo({ url: `/pages/oa/compensation/detail?id=${id}` })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/page-common.scss';
|
||||
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
background: $color-bg-page;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
padding: 20rpx $page-padding-x;
|
||||
background: $color-card;
|
||||
box-shadow: $shadow-header;
|
||||
}
|
||||
|
||||
.month-picker {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
height: 72rpx;
|
||||
padding: 0 24rpx;
|
||||
background: $color-bg-page;
|
||||
border-radius: $radius-full;
|
||||
}
|
||||
|
||||
.month-text {
|
||||
font-size: 28rpx;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.clear-btn {
|
||||
font-size: 26rpx;
|
||||
color: $color-primary;
|
||||
}
|
||||
|
||||
.list-scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.pay-list {
|
||||
padding: 24rpx $page-padding-x 0;
|
||||
}
|
||||
|
||||
.pay-card {
|
||||
@include card;
|
||||
padding: 26rpx 24rpx;
|
||||
margin-bottom: 18rpx;
|
||||
|
||||
&:active {
|
||||
background: $color-bg-page;
|
||||
}
|
||||
}
|
||||
|
||||
.pay-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.pay-month {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.status-tag {
|
||||
padding: 2rpx 14rpx;
|
||||
font-size: 21rpx;
|
||||
border-radius: $radius-sm;
|
||||
color: $color-text-muted;
|
||||
background: $color-bg-page;
|
||||
|
||||
&.st-1 {
|
||||
color: $color-primary;
|
||||
background: $color-primary-bg;
|
||||
}
|
||||
|
||||
&.st-2 {
|
||||
color: $color-success;
|
||||
background: #eafaf1;
|
||||
}
|
||||
}
|
||||
|
||||
.pay-amount {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 12rpx;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.amount-label {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.amount-value {
|
||||
font-size: 44rpx;
|
||||
font-weight: 600;
|
||||
color: $color-primary;
|
||||
}
|
||||
|
||||
.pay-meta {
|
||||
margin-top: 12rpx;
|
||||
font-size: 23rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.state-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 160rpx 48rpx;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.state-text {
|
||||
font-size: 26rpx;
|
||||
color: $color-text-muted;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 40rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user