主要更新uniapp相关功能

This commit is contained in:
hero920103 committed 2026-10-07 00:59:05 +08:00
1 parent aa92ca40a2
commit 5b4dbb2b46
65 files changed
+8532 -1921

No files matched your search

+367
View File
@@ -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>
+230
View File
@@ -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>
+408
View File
@@ -0,0 +1,408 @@
<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>
<view v-else-if="!contact" class="state-box">
<FaIcon name="circle-exclamation" color="#c0c4cc" :size="40" />
<text class="state-text">联系人不存在或无权查看</text>
</view>
<block v-else>
<view class="hero-card">
<view class="hero-avatar">
<image v-if="contact.avatar" class="hero-avatar-img" :src="contact.avatar" mode="aspectFill" />
<text v-else class="hero-avatar-text">{{ firstChar(contact.contact_name) }}</text>
</view>
<view class="hero-info">
<view class="hero-name-row">
<text class="hero-name">{{ contact.contact_name }}</text>
<text class="type-tag" :class="contact.contact_type === 1 ? 'inner' : 'outer'">
{{ getContactTypeLabel(contact.contact_type) }}
</text>
</view>
<text class="hero-sub">{{ heroSub }}</text>
</view>
</view>
<view v-if="mobilesText || contact.work_phone || contact.email" class="group-card">
<view class="group-head">
<view class="group-bar" />
<text class="group-title">联系方式</text>
</view>
<view v-if="mobilesText" class="row">
<text class="row-label">手机号</text>
<text class="row-text">{{ mobilesText }}</text>
<view class="copy-btn" @tap.stop="copy(mobilesText)">
<FaIcon name="copy" color="#2563eb" :size="13" />
</view>
</view>
<view v-if="contact.work_phone" class="row">
<text class="row-label">工作电话</text>
<text class="row-text">{{ contact.work_phone }}</text>
<view class="copy-btn" @tap.stop="copy(contact.work_phone)">
<FaIcon name="copy" color="#2563eb" :size="13" />
</view>
</view>
<view v-if="contact.email" class="row">
<text class="row-label">邮箱</text>
<text class="row-text">{{ contact.email }}</text>
<view class="copy-btn" @tap.stop="copy(contact.email)">
<FaIcon name="copy" color="#2563eb" :size="13" />
</view>
</view>
</view>
<view class="group-card">
<view class="group-head">
<view class="group-bar" />
<text class="group-title">更多信息</text>
</view>
<view v-if="contact.company_name" class="row">
<text class="row-label">公司</text>
<text class="row-text">{{ contact.company_name }}</text>
<view class="copy-btn" @tap.stop="copy(contact.company_name)">
<FaIcon name="copy" color="#2563eb" :size="13" />
</view>
</view>
<view v-if="deptText" class="row">
<text class="row-label">部门</text>
<text class="row-text">{{ deptText }}</text>
<view class="copy-btn" @tap.stop="copy(deptText)">
<FaIcon name="copy" color="#2563eb" :size="13" />
</view>
</view>
<view v-if="contact.position_title" class="row">
<text class="row-label">职位</text>
<text class="row-text">{{ contact.position_title }}</text>
<view class="copy-btn" @tap.stop="copy(contact.position_title)">
<FaIcon name="copy" color="#2563eb" :size="13" />
</view>
</view>
<view v-if="contact.wechat" class="row">
<text class="row-label">微信</text>
<text class="row-text">{{ contact.wechat }}</text>
<view class="copy-btn" @tap.stop="copy(contact.wechat)">
<FaIcon name="copy" color="#2563eb" :size="13" />
</view>
</view>
<view v-if="contact.qq" class="row">
<text class="row-label">QQ</text>
<text class="row-text">{{ contact.qq }}</text>
<view class="copy-btn" @tap.stop="copy(contact.qq)">
<FaIcon name="copy" color="#2563eb" :size="13" />
</view>
</view>
<view v-if="contact.address" class="row">
<text class="row-label">地址</text>
<text class="row-text">{{ contact.address }}</text>
<view class="copy-btn" @tap.stop="copy(contact.address)">
<FaIcon name="copy" color="#2563eb" :size="13" />
</view>
</view>
<view v-if="contact.remark" class="row">
<text class="row-label">备注</text>
<text class="row-text">{{ contact.remark }}</text>
<view class="copy-btn" @tap.stop="copy(contact.remark)">
<FaIcon name="copy" color="#2563eb" :size="13" />
</view>
</view>
</view>
</block>
<view class="bottom-space" />
</view>
</scroll-view>
<view v-if="contact && callPhone" class="action-bar">
<view class="call-action" @tap="call">
<FaIcon name="phone" color="#ffffff" :size="16" />
<text>拨打电话</text>
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getContact, getContactTypeLabel, formatMobiles, primaryPhone } from '@/api/contact.js'
import { isLoggedIn } from '@/utils/auth.js'
const id = ref(0)
const contact = ref(null)
const loading = ref(true)
const mobilesText = computed(() => {
if (!contact.value) return ''
const text = formatMobiles(contact.value.mobiles)
if (text) return text
return String(contact.value.phone || '').trim()
})
const deptText = computed(() => {
if (!contact.value) return ''
return contact.value.org_name || contact.value.dept_name || ''
})
const heroSub = computed(() => {
const parts = []
if (contact.value && contact.value.position_title) parts.push(contact.value.position_title)
if (deptText.value) parts.push(deptText.value)
return parts.length ? parts.join(' · ') : '公司内部通讯录'
})
const callPhone = computed(() => (contact.value ? primaryPhone(contact.value) : ''))
onLoad((options) => {
if (!isLoggedIn()) {
uni.reLaunch({ url: '/pages/login/login' })
return
}
id.value = Number((options && options.id) || 0)
loadDetail()
})
async function loadDetail() {
if (!id.value) {
loading.value = false
return
}
loading.value = true
try {
contact.value = await getContact(id.value)
} catch (e) {
contact.value = null
} finally {
loading.value = false
}
}
function firstChar(name) {
return String(name || '?').charAt(0)
}
function call() {
if (!callPhone.value) return
uni.makePhoneCall({ phoneNumber: callPhone.value })
}
function copy(text) {
const data = String(text || '').trim()
if (!data) return
uni.setClipboardData({
data,
success() {
uni.showToast({ title: '已复制', icon: 'none' })
}
})
}
</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;
display: flex;
align-items: center;
gap: 24rpx;
padding: 36rpx 30rpx;
background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
box-shadow: $shadow-float;
}
.hero-avatar {
width: 120rpx;
height: 120rpx;
border-radius: $radius-lg;
overflow: hidden;
flex-shrink: 0;
background: rgba(255, 255, 255, 0.22);
border: 1rpx solid rgba(255, 255, 255, 0.35);
display: flex;
align-items: center;
justify-content: center;
}
.hero-avatar-img {
width: 100%;
height: 100%;
}
.hero-avatar-text {
font-size: 48rpx;
font-weight: 600;
color: #ffffff;
}
.hero-info {
flex: 1;
min-width: 0;
}
.hero-name-row {
display: flex;
align-items: center;
gap: 12rpx;
min-width: 0;
}
.hero-name {
font-size: 40rpx;
font-weight: 600;
color: #ffffff;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.type-tag {
flex-shrink: 0;
padding: 2rpx 14rpx;
font-size: 21rpx;
border-radius: $radius-sm;
color: #ffffff;
background: rgba(255, 255, 255, 0.24);
}
.hero-sub {
display: block;
margin-top: 12rpx;
font-size: 25rpx;
color: rgba(255, 255, 255, 0.86);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.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;
}
.group-title {
font-size: 29rpx;
font-weight: 600;
color: $color-text;
}
.row {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 24rpx;
min-width: 0;
padding: 22rpx 0;
border-bottom: 1rpx solid $color-divider;
&:last-child {
border-bottom: none;
}
}
.row-label {
flex-shrink: 0;
font-size: 27rpx;
color: $color-text-secondary;
}
.row-text {
flex: 1;
min-width: 0;
font-size: 27rpx;
color: $color-text;
text-align: right;
word-break: break-all;
}
.copy-btn {
flex-shrink: 0;
width: 48rpx;
height: 48rpx;
border-radius: $radius-sm;
background: $color-primary-bg;
display: flex;
align-items: center;
justify-content: center;
&:active {
opacity: 0.7;
}
}
.action-bar {
flex-shrink: 0;
padding: 20rpx $page-padding-x calc(20rpx + env(safe-area-inset-bottom, 0px));
background: $color-card;
box-shadow: 0 -2rpx 12rpx rgba(15, 23, 42, 0.05);
}
.call-action {
display: flex;
align-items: center;
justify-content: center;
gap: 12rpx;
height: 88rpx;
border-radius: $radius-full;
background: $color-primary;
color: #ffffff;
font-size: 30rpx;
font-weight: 600;
&:active {
background: $color-primary-dark;
}
}
.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>
+364
View File
@@ -0,0 +1,364 @@
<template>
<view class="page">
<view class="toolbar">
<u-search
v-model="keyword"
placeholder="搜索姓名、手机号、邮箱"
:show-action="false"
shape="round"
bg-color="#f1f5f9"
color="#0f172a"
@search="onSearch"
@clear="clearSearch"
/>
<u-tabs
:list="TYPE_TABS"
:current="typeIndex"
:scrollable="false"
line-color="#2563eb"
:line-width="40"
:line-height="6"
:active-style="{ color: '#2563eb', fontWeight: '600' }"
:inactive-style="{ color: '#475569' }"
:item-style="{ height: '84rpx' }"
@change="onTabChange"
/>
<u-dropdown active-color="#2563eb" :height="84">
<u-dropdown-item
v-model="selectedOrgId"
title="部门"
:options="deptOptions"
height="520rpx"
@change="onDeptChange"
/>
</u-dropdown>
</view>
<scroll-view class="list-scroll" scroll-y :show-scrollbar="false" @scrolltolower="loadMore">
<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="keyword ? '未找到相关联系人' : '暂无联系人'"
/>
<block v-else>
<view class="contact-list">
<view v-for="item in list" :key="item.id" class="contact-card" @tap="openDetail(item.id)">
<u-avatar
:src="item.avatar"
:text="firstChar(item.contact_name)"
:size="48"
bg-color="#2563eb"
font-size="18"
/>
<view class="contact-body">
<view class="contact-head">
<text class="contact-name">{{ item.contact_name }}</text>
<text class="type-tag" :class="item.contact_type === 1 ? 'inner' : 'outer'">
{{ getContactTypeLabel(item.contact_type) }}
</text>
</view>
<text class="contact-sub">{{ subLine(item) }}</text>
<text v-if="primaryPhone(item)" class="contact-phone">{{ primaryPhone(item) }}</text>
</view>
<view v-if="primaryPhone(item)" class="call-btn" @tap.stop="call(item)">
<u-icon name="phone-fill" color="#ffffff" size="16" />
</view>
</view>
</view>
<view v-if="hasMore" class="more-tip" @tap="loadMore">
<text>{{ loadingMore ? '加载中...' : '加载更多' }}</text>
</view>
<view v-else class="more-tip end">
<text>已加载全部 {{ total }} 位联系人</text>
</view>
</block>
<view class="bottom-space" />
</scroll-view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import {
fetchContacts,
fetchContactOrgTree,
getContactTypeLabel,
primaryPhone
} from '@/api/contact.js'
import { isLoggedIn } from '@/utils/auth.js'
/** 顶部大类 tab:全部 / 内部 / 外部,索引与 contact_type 对应(0 表示不筛选) */
const TYPE_TABS = [{ name: '全部' }, { name: '内部' }, { name: '外部' }]
const TYPE_VALUES = [0, 1, 2]
const keyword = ref('')
const orgs = ref([])
const selectedOrgId = ref(0)
const typeIndex = ref(0)
const contactType = ref(0)
const list = ref([])
const total = ref(0)
const page = ref(1)
const pageSize = 20
const loading = ref(false)
const loadingMore = ref(false)
const hasMore = ref(false)
onMounted(() => {
if (!isLoggedIn()) {
uni.reLaunch({ url: '/pages/login/login' })
return
}
loadOrgTree()
loadContacts(true)
})
/** 部门下拉选项:全部 + 有内部联系人的部门(带人数) */
const deptOptions = computed(() => {
const options = [{ label: '全部部门', value: 0 }]
orgs.value.forEach((org) => {
const count = org.contact_count ? `(${org.contact_count})` : ''
options.push({ label: `${org.org_name}${count}`, value: org.id })
})
return options
})
/** 组织树拍平为部门列表,只保留有内部联系人的部门 */
function flattenOrgs(nodes, out) {
;(nodes || []).forEach((n) => {
if (Number(n.contact_count) > 0) {
out.push({ id: n.id, org_name: n.org_name, contact_count: n.contact_count })
}
if (n.children && n.children.length) {
flattenOrgs(n.children, out)
}
})
return out
}
async function loadOrgTree() {
try {
const tree = await fetchContactOrgTree()
orgs.value = flattenOrgs(Array.isArray(tree) ? tree : [], [])
} catch (e) {
orgs.value = []
}
}
async function loadContacts(reset) {
if (reset) {
page.value = 1
loading.value = true
} else {
loadingMore.value = true
}
try {
const res = await fetchContacts({
keyword: keyword.value,
orgId: selectedOrgId.value,
contactType: contactType.value,
page: page.value,
pageSize
})
list.value = reset ? res.list : list.value.concat(res.list)
total.value = res.total
hasMore.value = list.value.length < res.total
} catch (e) {
if (reset) list.value = []
} finally {
loading.value = false
loadingMore.value = false
}
}
function loadMore() {
if (!hasMore.value || loading.value || loadingMore.value) return
page.value += 1
loadContacts(false)
}
function onSearch() {
loadContacts(true)
}
function clearSearch() {
keyword.value = ''
loadContacts(true)
}
function onTabChange(item, index) {
typeIndex.value = index
contactType.value = TYPE_VALUES[index] || 0
loadContacts(true)
}
function onDeptChange() {
loadContacts(true)
}
function subLine(item) {
const parts = []
if (item.position_title) parts.push(item.position_title)
const dept = item.org_name || item.dept_name
if (dept) parts.push(dept)
return parts.length ? parts.join(' · ') : '暂无职位信息'
}
function firstChar(name) {
return String(name || '?').charAt(0)
}
function call(item) {
const phoneNumber = primaryPhone(item)
if (!phoneNumber) return
uni.makePhoneCall({ phoneNumber })
}
function openDetail(id) {
uni.navigateTo({ url: `/pages/oa/contact/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 {
position: relative;
z-index: 10;
flex-shrink: 0;
padding: 20rpx $page-padding-x 0;
background: $color-card;
box-shadow: $shadow-header;
}
.list-scroll {
flex: 1;
height: 0;
}
.contact-list {
padding: 24rpx $page-padding-x 0;
}
.contact-card {
@include card;
display: flex;
align-items: center;
gap: 22rpx;
padding: 24rpx;
margin-bottom: 18rpx;
&:active {
background: $color-bg-page;
}
}
.contact-body {
flex: 1;
min-width: 0;
}
.contact-head {
display: flex;
align-items: center;
gap: 12rpx;
}
.contact-name {
max-width: 60%;
font-size: 31rpx;
font-weight: 600;
color: $color-text;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.type-tag {
flex-shrink: 0;
padding: 2rpx 12rpx;
font-size: 20rpx;
border-radius: $radius-sm;
color: $color-text-muted;
background: $color-bg-page;
&.inner {
color: $color-primary;
background: $color-primary-bg;
}
}
.contact-sub {
display: block;
margin-top: 8rpx;
font-size: 25rpx;
color: $color-text-secondary;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.contact-phone {
display: block;
margin-top: 6rpx;
font-size: 24rpx;
color: $color-text-muted;
}
.call-btn {
flex-shrink: 0;
width: 72rpx;
height: 72rpx;
border-radius: 50%;
background: $color-primary;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 6rpx 16rpx rgba(37, 99, 235, 0.28);
&:active {
opacity: 0.85;
}
}
.more-tip {
padding: 12rpx 0 4rpx;
text-align: center;
font-size: 24rpx;
color: $color-primary;
&.end {
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>
+346
View File
@@ -0,0 +1,346 @@
<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="!doc"
mode="list"
:icon-size="80"
text="文档不存在或无访问权限"
/>
<block v-else>
<view class="head-card">
<view class="doc-icon">
<FaIcon :name="getDocTypeMeta(doc.doc_type).icon" color="#ffffff" :size="26" />
</view>
<view class="head-body">
<text class="title">{{ doc.title }}</text>
<view class="head-meta">
<text>{{ getDocTypeMeta(doc.doc_type).label }}</text>
<text v-if="doc.ext">· {{ doc.ext.toUpperCase() }}</text>
<text v-if="formatFileSize(doc.size)">· {{ formatFileSize(doc.size) }}</text>
<text v-if="doc.is_online">· 在线文档</text>
</view>
</view>
</view>
<view class="action-card">
<view class="action-btn-wrap">
<u-button
type="primary"
color="#2563eb"
icon="download"
text="下载"
:disabled="!doc.file_url"
@click="onDownload"
/>
</view>
<view class="action-btn-wrap">
<u-button
:type="doc.is_star === 1 ? 'warning' : 'info'"
:plain="doc.is_star !== 1"
:icon="doc.is_star === 1 ? 'star-fill' : 'star'"
:text="doc.is_star === 1 ? '已收藏' : '收藏'"
@click="onStar"
/>
</view>
</view>
<view class="info-card">
<view class="info-row">
<text class="info-label">所属分类</text>
<text class="info-value">{{ doc.visibility === 1 ? '私密文档' : '共享文档' }}</text>
</view>
<view class="info-row">
<text class="info-label">创建人</text>
<text class="info-value">{{ doc.creator_name || '-' }}</text>
</view>
<view class="info-row">
<text class="info-label">版本</text>
<text class="info-value">V{{ doc.version || 1 }}</text>
</view>
<view class="info-row">
<text class="info-label">创建时间</text>
<text class="info-value">{{ doc.create_time || '-' }}</text>
</view>
<view class="info-row">
<text class="info-label">更新时间</text>
<text class="info-value">{{ doc.update_time || '-' }}</text>
</view>
<view class="info-row">
<text class="info-label">浏览 / 下载</text>
<text class="info-value">{{ doc.view_count || 0 }} / {{ doc.download_count || 0 }}</text>
</view>
<view v-if="doc.tags" class="info-row">
<text class="info-label">标签</text>
<text class="info-value">{{ doc.tags }}</text>
</view>
</view>
<view v-if="doc.summary" class="summary-card">
<text class="section-title">文档摘要</text>
<text class="summary">{{ doc.summary }}</text>
</view>
</block>
<view class="bottom-space" />
</view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { getDoc, downloadDoc, toggleDocStar, getDocTypeMeta, formatFileSize } from '@/api/oa.js'
import { isLoggedIn } from '@/utils/auth.js'
import { getBaseURL } from '@/api/request.js'
const id = ref(0)
const doc = ref(null)
const loading = ref(true)
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 {
doc.value = await getDoc(id.value)
} catch (e) {
doc.value = null
} finally {
loading.value = false
}
}
/** 把可能的相对地址补全为绝对地址 */
function absoluteUrl(url) {
const value = String(url || '').trim()
if (!value) return ''
if (/^https?:/i.test(value)) return value
const base = String(getBaseURL() || '').replace(/\/$/, '')
if (value.startsWith('/')) return base + value
return base + '/' + value
}
async function onDownload() {
if (!doc.value) return
if (!doc.value.file_url) {
uni.showToast({ title: '该文档暂无可下载文件', icon: 'none' })
return
}
try {
const res = await downloadDoc(id.value)
if (doc.value) doc.value.download_count = (res && res.download_count) || doc.value.download_count
const url = absoluteUrl((res && res.file_url) || doc.value.file_url)
if (!url) {
uni.showToast({ title: '下载地址无效', icon: 'none' })
return
}
uni.showLoading({ title: '下载中...' })
uni.downloadFile({
url,
success(r) {
uni.hideLoading()
if (r.statusCode !== 200) {
copyLink(url)
return
}
uni.openDocument({
filePath: r.tempFilePath,
showMenu: true,
fail() {
copyLink(url)
}
})
},
fail() {
uni.hideLoading()
copyLink(url)
}
})
} catch (e) {
uni.showToast({ title: '下载失败', icon: 'none' })
}
}
function copyLink(url) {
uni.setClipboardData({
data: url,
success() {
uni.showToast({ title: '已复制下载链接,可在浏览器打开', icon: 'none' })
}
})
}
async function onStar() {
if (!doc.value) return
try {
const res = await toggleDocStar(id.value)
doc.value.is_star = res && res.is_star
uni.showToast({ title: doc.value.is_star === 1 ? '已收藏' : '已取消收藏', icon: 'none' })
} catch (e) {
uni.showToast({ title: '操作失败', icon: 'none' })
}
}
</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;
}
.head-card {
@include card;
display: flex;
align-items: center;
gap: 22rpx;
padding: 32rpx 28rpx;
}
.doc-icon {
width: 96rpx;
height: 96rpx;
border-radius: $radius-md;
background: $color-primary;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.head-body {
flex: 1;
min-width: 0;
}
.title {
display: block;
font-size: 32rpx;
font-weight: 600;
line-height: 1.45;
color: $color-text;
word-break: break-all;
}
.head-meta {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 6rpx;
margin-top: 12rpx;
font-size: 23rpx;
color: $color-text-muted;
}
.action-card {
display: flex;
gap: 20rpx;
margin-top: 20rpx;
}
.action-btn-wrap {
flex: 1;
}
.info-card {
@include card;
margin-top: 20rpx;
padding: 8rpx 28rpx;
}
.info-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 24rpx;
padding: 22rpx 0;
& + & {
border-top: 1rpx solid $color-divider;
}
}
.info-label {
flex-shrink: 0;
font-size: 26rpx;
color: $color-text-muted;
}
.info-value {
flex: 1;
text-align: right;
font-size: 26rpx;
color: $color-text;
word-break: break-all;
}
.summary-card {
@include card;
margin-top: 20rpx;
padding: 28rpx;
}
.section-title {
display: block;
font-size: 28rpx;
font-weight: 600;
color: $color-text;
margin-bottom: 14rpx;
}
.summary {
font-size: 27rpx;
line-height: 1.7;
color: $color-text-secondary;
white-space: pre-wrap;
word-break: break-all;
}
.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>
+304
View File
@@ -0,0 +1,304 @@
<template>
<view class="page">
<view class="toolbar">
<u-tabs
:list="spaceTabs"
:current="spaceIndex"
:scrollable="false"
line-color="#2563eb"
:line-width="40"
:active-style="{ color: '#2563eb', fontWeight: '600' }"
:inactive-style="{ color: '#475569' }"
:item-style="{ height: '84rpx' }"
@change="onSpaceTabChange"
/>
<u-search
v-model="keyword"
placeholder="搜索文档名称、标签"
:show-action="false"
shape="round"
bg-color="#f1f5f9"
color="#0f172a"
custom-style="margin-top:12rpx;"
@search="loadDocs"
@clear="clearSearch"
/>
<scroll-view class="cat-scroll" scroll-x :show-scrollbar="false">
<view class="cat-row">
<view class="cat-chip" :class="{ active: categoryId === 0 && !uncategorized }" @tap="selectCategory(0)">
全部
</view>
<view class="cat-chip" :class="{ active: uncategorized }" @tap="selectUncategorized">未分类</view>
<view
v-for="cat in categories"
:key="cat.id"
class="cat-chip"
:class="{ active: categoryId === cat.id }"
@tap="selectCategory(cat.id)"
>{{ cat.name }}</view>
</view>
</scroll-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="doc-list">
<view v-for="item in list" :key="item.id" class="doc-card" @tap="openDetail(item.id)">
<view class="doc-icon">
<FaIcon :name="getDocTypeMeta(item.doc_type).icon" color="#ffffff" :size="20" />
</view>
<view class="doc-body">
<view class="doc-head">
<text class="doc-title">{{ item.title }}</text>
<FaIcon v-if="item.is_star === 1" name="star" color="#f7ba2a" :size="14" />
</view>
<view class="doc-meta">
<text>{{ getDocTypeMeta(item.doc_type).label }}</text>
<text v-if="item.ext">· {{ item.ext.toUpperCase() }}</text>
<text v-if="formatFileSize(item.size)">· {{ formatFileSize(item.size) }}</text>
<text v-if="item.is_online">· 在线文档</text>
</view>
<view class="doc-meta">
<text>{{ item.creator_name || item.owner_name || '未知' }}</text>
<text>· {{ item.update_time || item.create_time }}</text>
</view>
</view>
</view>
</view>
<view class="bottom-space" />
</scroll-view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { fetchDocCategories, fetchDocs, getDocTypeMeta, formatFileSize } from '@/api/oa.js'
import { isLoggedIn } from '@/utils/auth.js'
const spaces = [
{ value: 'shared', label: '共享文档' },
{ value: 'personal', label: '私密文档' }
]
const spaceTabs = spaces.map((s) => ({ name: s.label }))
const scope = ref('shared')
const spaceIndex = computed(() => {
const i = spaces.findIndex((s) => s.value === scope.value)
return i < 0 ? 0 : i
})
const keyword = ref('')
const categoryId = ref(0)
const uncategorized = ref(false)
const categories = ref([])
const list = ref([])
const loading = ref(false)
onMounted(() => {
if (!isLoggedIn()) {
uni.reLaunch({ url: '/pages/login/login' })
return
}
loadCategories()
loadDocs()
})
async function loadCategories() {
try {
const tree = await fetchDocCategories(scope.value)
categories.value = Array.isArray(tree) ? tree : []
} catch (e) {
categories.value = []
}
}
async function loadDocs() {
loading.value = true
try {
const res = await fetchDocs({
scope: scope.value,
keyword: keyword.value,
categoryId: categoryId.value,
uncategorized: uncategorized.value,
pageSize: 50
})
list.value = res.list
} catch (e) {
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
function changeScope(value) {
if (scope.value === value) return
scope.value = value
categoryId.value = 0
uncategorized.value = false
loadCategories()
loadDocs()
}
function onSpaceTabChange(item, index) {
const tab = spaces[index]
if (tab) changeScope(tab.value)
}
function selectCategory(id) {
categoryId.value = id
uncategorized.value = false
loadDocs()
}
function selectUncategorized() {
categoryId.value = 0
uncategorized.value = true
loadDocs()
}
function clearSearch() {
keyword.value = ''
loadDocs()
}
function openDetail(id) {
uni.navigateTo({ url: `/pages/oa/document/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;
padding: 20rpx $page-padding-x 0;
background: $color-card;
box-shadow: $shadow-header;
}
.cat-scroll {
white-space: nowrap;
padding: 20rpx 0;
}
.cat-row {
display: inline-flex;
align-items: center;
gap: 14rpx;
}
.cat-chip {
flex-shrink: 0;
padding: 10rpx 26rpx;
font-size: 25rpx;
color: $color-text-secondary;
background: $color-bg-page;
border-radius: $radius-full;
&.active {
color: $color-primary;
background: $color-primary-bg;
font-weight: 500;
}
}
.list-scroll {
flex: 1;
height: 0;
}
.doc-list {
padding: 24rpx $page-padding-x 0;
}
.doc-card {
@include card;
display: flex;
align-items: center;
gap: 20rpx;
padding: 24rpx;
margin-bottom: 18rpx;
&:active {
background: $color-bg-page;
}
}
.doc-icon {
width: 80rpx;
height: 80rpx;
border-radius: $radius-md;
background: $color-primary;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.doc-body {
flex: 1;
min-width: 0;
}
.doc-head {
display: flex;
align-items: center;
gap: 10rpx;
}
.doc-title {
flex: 1;
min-width: 0;
font-size: 29rpx;
font-weight: 500;
color: $color-text;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.doc-meta {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 6rpx;
margin-top: 8rpx;
font-size: 22rpx;
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>
+481
View File
@@ -0,0 +1,481 @@
<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="!file"
mode="list"
:icon-size="80"
text="您暂无员工档案"
/>
<block v-else>
<view class="hero-card">
<view class="hero-avatar">
<text>{{ avatarText }}</text>
</view>
<view class="hero-info">
<view class="hero-name-row">
<text class="hero-name">{{ file.employee_name || '本人' }}</text>
<u-tag
:text="getEmploymentStatusLabel(file.employment_status)"
size="mini"
bg-color="rgba(255,255,255,0.22)"
color="#ffffff"
border-color="rgba(255,255,255,0.22)"
class="status-tag"
/>
</view>
<text class="hero-sub">{{ positionText }}</text>
</view>
</view>
<view class="group-card">
<view class="group-head">
<view class="group-bar" />
<text class="group-title">档案完整度</text>
<text class="group-extra">{{ file.completeness || 0 }}%</text>
</view>
<view class="progress-track">
<view class="progress-fill" :style="{ width: (file.completeness || 0) + '%' }" />
</view>
</view>
<view class="group-card">
<view class="group-head">
<view class="group-bar" />
<text class="group-title">基本信息</text>
</view>
<view v-for="row in baseInfo" :key="row.label" class="row">
<text class="row-label">{{ row.label }}</text>
<text class="row-text">{{ row.value || '-' }}</text>
</view>
</view>
<view class="group-card">
<view class="group-head">
<view class="group-bar" />
<text class="group-title">联系方式</text>
</view>
<view v-for="row in contactInfo" :key="row.label" class="row">
<text class="row-label">{{ row.label }}</text>
<text class="row-text">{{ row.value || '-' }}</text>
</view>
</view>
<view class="group-card">
<view class="group-head">
<view class="group-bar" />
<text class="group-title">紧急联系人</text>
</view>
<view v-for="row in emergencyInfo" :key="row.label" class="row">
<text class="row-label">{{ row.label }}</text>
<text class="row-text">{{ row.value || '-' }}</text>
</view>
</view>
<view v-for="group in recordGroups" :key="group.type" class="group-card">
<view class="group-head">
<view class="group-bar" />
<text class="group-title">{{ group.label }}</text>
<text class="group-extra">{{ group.list.length }}</text>
</view>
<view v-if="group.list.length === 0" class="record-empty">
<text class="record-empty-text">暂无记录</text>
</view>
<view v-else v-for="record in group.list" :key="record.id" class="record-item">
<view class="record-top">
<text class="record-title">{{ record.title || group.label }}</text>
<text v-if="record.sub_title" class="record-sub">{{ record.sub_title }}</text>
</view>
<view v-if="recordDate(record)" class="record-date">
<text>{{ recordDate(record) }}</text>
</view>
<text v-if="record.extra" class="record-extra">{{ record.extra }}</text>
<text v-if="record.description" class="record-desc">{{ record.description }}</text>
<view v-if="record.attachment_url" class="record-file" @tap="openAttachment(record.attachment_url)">
<FaIcon name="paperclip" color="#2563eb" :size="13" />
<text>查看附件</text>
</view>
</view>
</view>
</block>
<view class="bottom-space" />
</view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import {
getMyEmployeeFile,
getEmploymentStatusLabel,
getMaritalStatusLabel,
FILE_RECORD_TYPE_OPTIONS
} from '@/api/oa.js'
import { isLoggedIn } from '@/utils/auth.js'
import { getBaseURL } from '@/api/request.js'
const GENDER_TEXT = { 0: '未知', 1: '男', 2: '女' }
const file = ref(null)
const records = ref([])
const loading = ref(true)
const avatarText = computed(() => {
const name = (file.value && file.value.employee_name) || '我'
return name.slice(0, 1)
})
const positionText = computed(() => {
if (!file.value) return ''
const parts = [file.value.department_name || file.value.department, file.value.position].filter(Boolean)
return parts.join(' · ')
})
const baseInfo = computed(() => {
const f = file.value || {}
return [
{ label: '档案编号', value: f.file_no },
{ label: '员工账号', value: f.employee_account },
{ label: '性别', value: GENDER_TEXT[Number(f.gender)] || '未知' },
{ label: '生日', value: f.birthday },
{ label: '身份证号', value: f.id_card },
{ label: '学历', value: f.education },
{ label: '民族', value: f.nation },
{ label: '政治面貌', value: f.political_status },
{ label: '婚姻状况', value: getMaritalStatusLabel(f.marital_status) },
{ label: '籍贯', value: f.native_place },
{ label: '所属部门', value: f.department_name || f.department },
{ label: '职位', value: f.position },
{ label: '入职日期', value: f.hire_date },
{ label: '转正日期', value: f.regular_date },
{ label: '离职日期', value: f.leave_date },
{ label: '户籍地址', value: f.household_address },
{ label: '现居住地', value: f.current_address }
]
})
const contactInfo = computed(() => {
const f = file.value || {}
return [
{ label: '手机号码', value: f.phone },
{ label: '工作邮箱', value: f.work_email },
{ label: '个人邮箱', value: f.email },
{ label: '家庭住址', value: f.home_address }
]
})
const emergencyInfo = computed(() => {
const f = file.value || {}
return [
{ label: '联系人', value: f.emergency_contact },
{ label: '联系电话', value: f.emergency_phone },
{ label: '关系', value: f.emergency_relation }
]
})
const recordGroups = computed(() => {
return FILE_RECORD_TYPE_OPTIONS.map(option => ({
type: option.value,
label: option.label,
list: records.value.filter(r => Number(r.type) === option.value)
}))
})
onMounted(() => {
if (!isLoggedIn()) {
uni.reLaunch({ url: '/pages/login/login' })
return
}
loadFile()
})
async function loadFile() {
loading.value = true
try {
const data = await getMyEmployeeFile()
file.value = (data && data.file) || null
records.value = (data && data.records) || []
} catch (e) {
file.value = null
records.value = []
} finally {
loading.value = false
}
}
function fmtDate(value) {
if (!value) return ''
const text = String(value)
return text.length >= 10 ? text.slice(0, 10) : text
}
function recordDate(record) {
const start = fmtDate(record.start_date)
const end = fmtDate(record.end_date)
if (!start && !end) return ''
if (start && end) return `${start} ~ ${end}`
return start || end
}
function absoluteUrl(url) {
if (!url) return ''
if (/^https?:\/\//i.test(url)) return url
const base = (getBaseURL() || '').replace(/\/$/, '')
return base + (url.startsWith('/') ? url : '/' + url)
}
function openAttachment(url) {
const full = absoluteUrl(url)
if (!full) return
uni.setClipboardData({
data: full,
success: () => uni.showToast({ title: '链接已复制', icon: 'none' })
})
}
</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;
display: flex;
align-items: center;
gap: 24rpx;
padding: 32rpx 28rpx;
background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
box-shadow: $shadow-float;
}
.hero-avatar {
width: 104rpx;
height: 104rpx;
border-radius: $radius-full;
background: rgba(255, 255, 255, 0.22);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.hero-avatar text {
font-size: 44rpx;
font-weight: 600;
color: #ffffff;
}
.hero-info {
flex: 1;
min-width: 0;
}
.hero-name-row {
display: flex;
align-items: center;
gap: 14rpx;
}
.hero-name {
font-size: 36rpx;
font-weight: 600;
color: #ffffff;
min-width: 0;
word-break: break-all;
}
.status-tag {
flex-shrink: 0;
}
.hero-sub {
display: block;
margin-top: 12rpx;
font-size: 24rpx;
color: rgba(255, 255, 255, 0.82);
}
.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;
}
.group-title {
font-size: 29rpx;
font-weight: 600;
color: $color-text;
}
.group-extra {
margin-left: auto;
font-size: 24rpx;
color: $color-text-muted;
}
.progress-track {
height: 14rpx;
margin-top: 20rpx;
border-radius: $radius-full;
background: $color-bg-page;
overflow: hidden;
}
.progress-fill {
height: 100%;
border-radius: $radius-full;
background: linear-gradient(90deg, #60a5fa 0%, #2563eb 100%);
}
.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;
flex-shrink: 0;
}
.row-text {
font-size: 27rpx;
color: $color-text;
text-align: right;
flex: 1;
min-width: 0;
word-break: break-all;
}
.record-item {
padding: 22rpx 0;
border-bottom: 1rpx solid $color-divider;
&:last-child {
border-bottom: none;
}
}
.record-top {
display: flex;
align-items: center;
gap: 14rpx;
}
.record-title {
font-size: 28rpx;
font-weight: 600;
color: $color-text;
min-width: 0;
word-break: break-all;
}
.record-sub {
font-size: 24rpx;
color: $color-text-secondary;
min-width: 0;
word-break: break-all;
}
.record-date {
margin-top: 10rpx;
font-size: 23rpx;
color: $color-text-muted;
}
.record-extra {
display: block;
margin-top: 8rpx;
font-size: 24rpx;
color: $color-text-secondary;
word-break: break-all;
}
.record-desc {
display: block;
margin-top: 10rpx;
font-size: 24rpx;
line-height: 1.6;
color: $color-text-muted;
word-break: break-all;
}
.record-file {
display: inline-flex;
align-items: center;
gap: 8rpx;
margin-top: 14rpx;
font-size: 24rpx;
color: $color-primary;
}
.record-empty {
padding: 24rpx 0;
}
.record-empty-text {
font-size: 25rpx;
color: $color-text-muted;
}
.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>
+189
View File
@@ -0,0 +1,189 @@
<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="!notice"
mode="list"
:icon-size="80"
text="公告不存在或已被删除"
/>
<block v-else>
<view class="detail-card">
<view class="tag-row">
<u-tag v-if="notice.is_top" text="置顶" type="error" size="mini" />
<u-tag
:text="getNoticeLevelLabel(notice.level)"
:type="levelTagType(notice.level)"
size="mini"
plain
/>
<u-tag :text="getNoticeTypeLabel(notice.notice_type)" type="primary" size="mini" plain />
</view>
<text class="title">{{ notice.title }}</text>
<view class="meta">
<text>{{ notice.publisher_name || '系统' }}</text>
<text>·</text>
<text>{{ notice.publish_time || '-' }}</text>
</view>
<view class="stat-row">
<view class="stat-item">
<FaIcon name="eye" color="#8a94ad" :size="13" />
<text>{{ notice.read_count || 0 }} 次阅读</text>
</view>
</view>
</view>
<view class="content-card">
<text class="content">{{ notice.content || '(无正文)' }}</text>
</view>
</block>
<view class="bottom-space" />
</view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { getNotice, getNoticeTypeLabel, getNoticeLevelLabel } from '@/api/oa.js'
import { isLoggedIn } from '@/utils/auth.js'
const id = ref(0)
const notice = ref(null)
const loading = ref(true)
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()
})
/** 公告级别 → u-tag 类型:1 重要 / 2 紧急 / 其他 普通 */
function levelTagType(level) {
const n = Number(level)
if (n === 1) return 'warning'
if (n === 2) return 'error'
return 'info'
}
async function loadDetail() {
if (!id.value) {
loading.value = false
return
}
loading.value = true
try {
notice.value = await getNotice(id.value)
} catch (e) {
notice.value = null
} finally {
loading.value = false
}
}
</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;
}
.detail-card {
@include card;
padding: 32rpx 28rpx;
}
.tag-row {
display: flex;
align-items: center;
gap: 10rpx;
margin-bottom: 18rpx;
}
.title {
display: block;
font-size: 38rpx;
font-weight: 600;
line-height: 1.45;
color: $color-text;
}
.meta {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8rpx;
margin-top: 18rpx;
font-size: 24rpx;
color: $color-text-muted;
}
.stat-row {
margin-top: 18rpx;
padding-top: 18rpx;
border-top: 1rpx solid $color-divider;
}
.stat-item {
display: flex;
align-items: center;
gap: 8rpx;
font-size: 23rpx;
color: $color-text-muted;
}
.content-card {
@include card;
margin-top: 20rpx;
padding: 32rpx 28rpx;
}
.content {
font-size: 29rpx;
line-height: 1.75;
color: $color-text;
white-space: pre-wrap;
word-break: break-all;
}
.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>
+194
View File
@@ -0,0 +1,194 @@
<template>
<view class="page">
<view class="toolbar">
<u-search
v-model="keyword"
placeholder="搜索公告标题"
:show-action="false"
shape="round"
bg-color="#f1f5f9"
color="#0f172a"
@search="loadNotices"
@clear="clearSearch"
/>
</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="keyword ? '未找到相关公告' : '暂无公告'"
/>
<view v-else class="notice-list">
<view v-for="item in list" :key="item.id" class="notice-card" @tap="openDetail(item.id)">
<view class="notice-head">
<u-tag v-if="item.is_top" text="置顶" type="error" size="mini" />
<u-tag :text="getNoticeLevelLabel(item.level)" :type="levelTagType(item.level)" size="mini" plain />
<text class="notice-title">{{ item.title }}</text>
</view>
<text v-if="item.summary" class="notice-summary">{{ item.summary }}</text>
<view class="notice-meta">
<text class="meta-type">{{ getNoticeTypeLabel(item.notice_type) }}</text>
<text>{{ item.publisher_name || '系统' }}</text>
<text>·</text>
<text>{{ item.publish_time || '-' }}</text>
<text>·</text>
<text>阅读 {{ item.read_count || 0 }}</text>
</view>
</view>
</view>
<view class="bottom-space" />
</scroll-view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { fetchNotices, getNoticeTypeLabel, getNoticeLevelLabel } from '@/api/oa.js'
import { isLoggedIn } from '@/utils/auth.js'
const keyword = ref('')
const list = ref([])
const loading = ref(false)
onMounted(() => {
if (!isLoggedIn()) {
uni.reLaunch({ url: '/pages/login/login' })
return
}
loadNotices()
})
async function loadNotices() {
loading.value = true
try {
const res = await fetchNotices({ keyword: keyword.value, pageSize: 50 })
list.value = res.list
} catch (e) {
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
function clearSearch() {
keyword.value = ''
loadNotices()
}
/** 公告级别 → uview tag 类型 */
function levelTagType(level) {
const n = Number(level)
if (n === 1) return 'warning'
if (n === 2) return 'error'
return 'info'
}
function openDetail(id) {
uni.navigateTo({ url: `/pages/oa/notice/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;
padding: 20rpx $page-padding-x;
background: $color-card;
box-shadow: $shadow-header;
}
.list-scroll {
flex: 1;
height: 0;
}
.notice-list {
padding: 24rpx $page-padding-x 0;
}
.notice-card {
@include card;
padding: 26rpx 24rpx;
margin-bottom: 20rpx;
&:active {
background: $color-bg-page;
}
}
.notice-head {
display: flex;
align-items: flex-start;
gap: 10rpx;
}
.notice-title {
flex: 1;
min-width: 0;
font-size: 30rpx;
font-weight: 500;
line-height: 1.45;
color: $color-text;
}
.notice-summary {
display: block;
margin-top: 12rpx;
font-size: 26rpx;
line-height: 1.5;
color: $color-text-secondary;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.notice-meta {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8rpx;
margin-top: 16rpx;
font-size: 22rpx;
color: $color-text-muted;
}
.meta-type {
color: $color-primary;
background: $color-primary-bg;
padding: 2rpx 12rpx;
border-radius: $radius-sm;
}
.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>