123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423 |
- <template>
- <view class="container">
- <!-- 头部信息 -->
- <view class="header-section">
- <view class="avatar-section">
- <uv-avatar :src="staffInfo.avatar || '/static/images/user.png'" size="120" />
- </view>
- <view class="basic-info">
- <view class="name">{{ staffInfo.nickName }}</view>
- <view class="dept">{{ staffInfo.dept ? staffInfo.dept.deptName : '未分配部门' }}</view>
- <view class="status">
- <u-tag :text="getStatusText(staffInfo.status)" :type="getStatusType(staffInfo.status)" />
- </view>
- </view>
- </view>
- <!-- 基本信息 -->
- <view class="info-section">
- <view class="section-title">基本信息</view>
- <view class="info-grid">
- <view class="info-item">
- <text class="label">姓名</text>
- <text class="value">{{ staffInfo.nickName }}</text>
- </view>
- <view class="info-item">
- <text class="label">年龄</text>
- <text class="value">{{ String(getAgeByIdCard(staffInfo.idCard)).slice(0, 2) }}岁</text>
- </view>
- <view class="info-item">
- <text class="label">性别</text>
- <text class="value">{{ staffInfo.sex == 0 ? '男' : '女' }}</text>
- </view>
- <view class="info-item">
- <text class="label">手机号码</text>
- <text class="value">{{ staffInfo.phonenumber || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">身份证</text>
- <text class="value">{{ staffInfo.idCard || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">籍贯</text>
- <text class="value">{{ staffInfo.nativePlace || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">民族</text>
- <text class="value">{{ staffInfo.ethnic || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">政治面貌</text>
- <text class="value">{{ getPoliticalText(staffInfo.politicalAffiliation) || '' }}</text>
- </view>
- </view>
- </view>
-
- <!-- 工作信息 -->
- <view class="info-section">
- <view class="section-title">工作信息</view>
- <view class="info-grid">
- <view class="info-item">
- <text class="label">部门</text>
- <text class="value">{{ staffInfo.dept ? staffInfo.dept.deptName : '未分配部门' }}</text>
- </view>
- <view class="info-item">
- <text class="label">职务</text>
- <text class="value">{{ postData || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">职称</text>
- <text class="value">{{ titlesMap[staffInfo.titles] || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">职业资格</text>
- <text class="value">{{ getCertificateText(staffInfo.certificates) || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">岗级</text>
- <text class="value">{{ getPostLevelText(staffInfo.postLevel, staffInfo.salaryLevel) || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">工程师岗级</text>
- <text class="value">{{ engineerLevelData[staffInfo.engineerLevel] || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">技工等级</text>
- <text class="value">{{ operatorLevelData[staffInfo.operatorLevel] || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">项目经理等级</text>
- <text class="value">{{ pmLevelData[staffInfo.pmLevel] || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">入职时间</text>
- <text class="value">{{ parseTime(staffInfo.entryDate, "{y}-{m}-{d}") || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">合同签订</text>
- <text class="value">{{ parseTime(staffInfo.contractSign, "{y}-{m}-{d}") || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">合同期满</text>
- <text class="value">{{ parseTime(staffInfo.contractExpire, "{y}-{m}-{d}") || '' }}</text>
- </view>
- </view>
- </view>
-
- <!-- 教育背景 -->
- <view class="info-section">
- <view class="section-title">教育背景</view>
- <view class="info-grid">
- <view class="info-item">
- <text class="label">最高学历</text>
- <text class="value">{{ getDegreeText(staffInfo.degree) || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">最高学历专业</text>
- <text class="value">{{ staffInfo.major || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">最高学历毕业院校</text>
- <text class="value">{{ staffInfo.graduateSchool || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">初始学历</text>
- <text class="value">{{ getDegreeText(staffInfo.initialDegree) || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">初始学历专业</text>
- <text class="value">{{ staffInfo.initialMajor || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">初始学历毕业院校</text>
- <text class="value">{{ staffInfo.initialSchool || '' }}</text>
- </view>
- </view>
- </view>
-
-
- <!-- 其他信息 -->
- <view class="info-section">
- <view class="section-title">其他信息</view>
- <view class="info-grid">
- <view class="info-item">
- <text class="label">家庭住址</text>
- <text class="value">{{ staffInfo.homePlace || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">紧急联系人</text>
- <text class="value">{{ staffInfo.contact || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">紧急联系电话</text>
- <text class="value">{{ staffInfo.telephone || '' }}</text>
- </view>
- <view class="info-item">
- <text class="label">备注</text>
- <text class="value">{{ staffInfo.remark || '无' }}</text>
- </view>
- </view>
- </view>
- </view>
- </template>
-
- <script>
- import { parseTime } from "@/utils/common.js"
- import { getUser } from "@/api/system/user"
- import { listType, getType } from "@/api/system/dict/type"
- import { listData } from "@/api/system/dict/data"
-
- export default {
- data() {
- return {
- staffInfo: {},
- userId: '',
- nickName: '',
- postData: '',
- engineerLevelData: {},
- operatorLevelData: {},
- pmLevelData: {},
- politicalMap: {},
- titlesMap: {},
- certificateMap: {},
- postLevelMap: {},
- salaryLevelMap: {}
- }
- },
- onLoad(options) {
- this.userId = options.userId
- this.nickName = options.nickName
- this.getDictLabelValue();
- this.getStaffInfo();
- },
- methods: {
- parseTime,
- // 获取员工信息
- async getStaffInfo() {
- try {
- const res = await getUser(this.userId);
- this.staffInfo = res.data;
- let postArr = [];
- for (let post of res.posts) {
- for (let postid of res.postIds) {
- if (postid == post.postId) {
- postArr.push(post.postName)
- }
- }
- }
- this.postData = postArr.join('/')
- } catch (error) {
- console.error('获取员工信息失败:', error);
- uni.showToast({
- title: '获取员工信息失败',
- icon: 'none'
- });
- }
- },
- getDictLabelValue() {
- listData({ pageSize: 100, dictType: 'sys_user_engineerlevel' }).then(res => {
- res.rows.map(item => {
- this.engineerLevelData[item.dictValue] = item.dictLabel
- })
- })
- listData({ pageSize: 100, dictType: 'sys_user_operatorlevel' }).then(res => {
- res.rows.map(item => {
- this.operatorLevelData[item.dictValue] = item.dictLabel
- })
- })
- listData({ pageSize: 100, dictType: 'sys_user_pmlevel' }).then(res => {
- res.rows.map(item => {
- this.pmLevelData[item.dictValue] = item.dictLabel
- })
- })
- listData({ pageSize: 100, dictType: 'sys_user_political' }).then(res => {
- res.rows.map(item => {
- this.politicalMap[item.dictValue] = item.dictLabel
- })
- })
- listData({ pageSize: 100, dictType: 'sys_user_titles' }).then(res => {
- res.rows.map(item => {
- this.titlesMap[item.dictValue] = item.dictLabel
- })
- })
- listData({ pageSize: 100, dictType: 'sys_user_certificates' }).then(res => {
- res.rows.map(item => {
- this.certificateMap[item.dictValue] = item.dictLabel
- })
- })
- listData({ pageSize: 100, dictType: 'sys_user_postlevel' }).then(res => {
- res.rows.map(item => {
- this.postLevelMap[item.dictValue] = item.dictLabel
- })
- })
- listData({ pageSize: 100, dictType: 'sys_user_salarylevel' }).then(res => {
- res.rows.map(item => {
- this.salaryLevelMap[item.dictValue] = item.dictLabel
- })
- })
- },
- // 获取状态文本
- getStatusText(status) {
- const statusMap = {
- '0': '在职',
- '1': '离职',
- '2': '退休',
- '3': '试用',
- '4': '返聘'
- };
- return statusMap[status] || '未知';
- },
- // 获取状态类型
- getStatusType(status) {
- const typeMap = {
- '0': 'success',
- '1': 'error',
- '2': 'warning',
- '3': 'primary',
- '4': 'info'
- };
- return typeMap[status] || 'default';
- },
- // 根据身份证计算年龄
- getAgeByIdCard(idCard) {
- if (!idCard) return 0;
- const birthStr = idCard.substring(6, 14);
- const birthYear = parseInt(birthStr.substring(0, 4), 10);
- const birthMonth = parseInt(birthStr.substring(4, 6), 10) - 1;
- const birthDay = parseInt(birthStr.substring(6, 8), 10);
- const birthDate = new Date(birthYear, birthMonth, birthDay);
- const now = new Date();
- let age = now.getFullYear() - birthDate.getFullYear();
- const monthDiff = now.getMonth() - birthDate.getMonth();
- if (monthDiff < 0 || (monthDiff === 0 && now.getDate() < birthDate.getDate())) {
- age--;
- }
- return age;
- },
- // 获取政治面貌文本
- getPoliticalText(politicalAffiliation) {
- if (!politicalAffiliation) return '';
- const politicalArray = politicalAffiliation.split(',');
- let politicalText = politicalArray.map(political => this.politicalMap[political] || political).join('、');
- return politicalText;
- },
-
- // 获取职业资格文本
- getCertificateText(certificates) {
- if (!certificates) return '';
- const certArray = certificates.split(',');
- return certArray.map(cert => this.certificateMap[cert] || cert).join('、');
- },
-
- // 获取岗级文本
- getPostLevelText(postLevel, salaryLevel) {
- const postText = this.postLevelMap[postLevel] || '';
- const salaryText = this.salaryLevelMap[salaryLevel] || '';
- return postText && salaryText ? `${postText}${salaryText}` : '';
- },
- // 获取学历文本
- getDegreeText(degree) {
- const degreeMap = {
- '0': '博士',
- '1': '硕士',
- '2': '本科',
- '3': '专科',
- '4': '高中',
- '5': '中专',
- '6': '初中'
- };
- return degreeMap[degree] || '';
- },
- },
- }
- </script>
-
- <style lang="scss" scoped>
- .container {
- background-color: #f5f5f5;
- min-height: 100vh;
- padding: 30rpx;
- padding-bottom: 120rpx;
- }
-
- .header-section {
- background-color: #fff;
- padding: 40rpx 30rpx;
- display: flex;
- align-items: center;
- margin-bottom: 20rpx;
-
- .avatar-section {
- margin-right: 30rpx;
- }
-
- .basic-info {
- flex: 1;
-
- .name {
- font-size: 36rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 10rpx;
- }
-
- .dept {
- font-size: 28rpx;
- color: #666;
- margin-bottom: 15rpx;
- }
-
- .status {
- display: inline-block;
- }
- }
- }
-
- .info-section {
- background-color: #fff;
- margin-bottom: 20rpx;
- padding: 30rpx;
-
- .section-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 30rpx;
- border-left: 6rpx solid #007aff;
- padding-left: 20rpx;
- }
-
- .info-grid {
- .info-item {
- display: flex;
- margin-bottom: 25rpx;
-
- .label {
- width: 200rpx;
- font-size: 28rpx;
- color: #666;
- }
-
- .value {
- flex: 1;
- font-size: 28rpx;
- color: #333;
- word-break: break-all;
- }
- }
- }
- }
-
- .action-section {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: #fff;
- padding: 20rpx 30rpx;
- border-top: 1rpx solid #eee;
-
- .uv-button {
- width: 100%;
- }
- }
- </style>
|