综合办公系统
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

staffDetail.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <view class="container">
  3. <!-- 头部信息 -->
  4. <view class="header-section">
  5. <view class="avatar-section">
  6. <uv-avatar
  7. :src="staffInfo.avatar || '/static/images/user.png'"
  8. size="120"
  9. />
  10. </view>
  11. <view class="basic-info">
  12. <view class="name">{{ staffInfo.nickName }}</view>
  13. <view class="dept">{{ staffInfo.dept?.deptName || '未分配部门' }}</view>
  14. <view class="status">
  15. <uv-tag
  16. :text="getStatusText(staffInfo.status)"
  17. :type="getStatusType(staffInfo.status)"
  18. />
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 基本信息 -->
  23. <view class="info-section">
  24. <view class="section-title">基本信息</view>
  25. <view class="info-grid">
  26. <view class="info-item">
  27. <text class="label">姓名</text>
  28. <text class="value">{{ staffInfo.nickName }}</text>
  29. </view>
  30. <view class="info-item">
  31. <text class="label">年龄</text>
  32. <text class="value">{{ String(getAgeByIdCard(staffInfo.idCard)).slice(0,2) }}岁</text>
  33. </view>
  34. <view class="info-item">
  35. <text class="label">性别</text>
  36. <text class="value">{{ staffInfo.sex == 0 ? '男' : '女' }}</text>
  37. </view>
  38. <view class="info-item">
  39. <text class="label">手机号码</text>
  40. <text class="value">{{ staffInfo.phonenumber || '未填写' }}</text>
  41. </view>
  42. <view class="info-item">
  43. <text class="label">身份证</text>
  44. <text class="value">{{ staffInfo.idCard || '未填写' }}</text>
  45. </view>
  46. <view class="info-item">
  47. <text class="label">籍贯</text>
  48. <text class="value">{{ staffInfo.nativePlace || '未填写' }}</text>
  49. </view>
  50. <view class="info-item">
  51. <text class="label">民族</text>
  52. <text class="value">{{ staffInfo.ethnic || '未填写' }}</text>
  53. </view>
  54. <view class="info-item">
  55. <text class="label">政治面貌</text>
  56. <text class="value">{{ getPoliticalText(staffInfo.politicalAffiliation) || '未填写' }}</text>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 工作信息 -->
  61. <view class="info-section">
  62. <view class="section-title">工作信息</view>
  63. <view class="info-grid">
  64. <view class="info-item">
  65. <text class="label">部门</text>
  66. <text class="value">{{ staffInfo.dept?.deptName || '未分配部门' }}</text>
  67. </view>
  68. <view class="info-item">
  69. <text class="label">职务</text>
  70. <text class="value">{{ staffInfo.postNames || '未填写' }}</text>
  71. </view>
  72. <view class="info-item">
  73. <text class="label">职称</text>
  74. <text class="value">{{ getTitleText(staffInfo.titles) || '未填写' }}</text>
  75. </view>
  76. <view class="info-item">
  77. <text class="label">职业资格</text>
  78. <text class="value">{{ getCertificateText(staffInfo.certificates) || '未填写' }}</text>
  79. </view>
  80. <view class="info-item">
  81. <text class="label">岗级</text>
  82. <text class="value">{{ getPostLevelText(staffInfo.postLevel, staffInfo.salaryLevel) || '未填写' }}</text>
  83. </view>
  84. <view class="info-item">
  85. <text class="label">入职时间</text>
  86. <text class="value">{{ formatDate(staffInfo.entryDate) || '未填写' }}</text>
  87. </view>
  88. <view class="info-item">
  89. <text class="label">合同签订</text>
  90. <text class="value">{{ formatDate(staffInfo.contractSign) || '未填写' }}</text>
  91. </view>
  92. <view class="info-item">
  93. <text class="label">合同期满</text>
  94. <text class="value">{{ formatDate(staffInfo.contractExpire) || '未填写' }}</text>
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 教育背景 -->
  99. <view class="info-section">
  100. <view class="section-title">教育背景</view>
  101. <view class="info-grid">
  102. <view class="info-item">
  103. <text class="label">最高学历</text>
  104. <text class="value">{{ getDegreeText(staffInfo.degree) || '未填写' }}</text>
  105. </view>
  106. <view class="info-item">
  107. <text class="label">最高学历专业</text>
  108. <text class="value">{{ staffInfo.major || '未填写' }}</text>
  109. </view>
  110. <view class="info-item">
  111. <text class="label">最高学历毕业院校</text>
  112. <text class="value">{{ staffInfo.graduateSchool || '未填写' }}</text>
  113. </view>
  114. <view class="info-item">
  115. <text class="label">初始学历</text>
  116. <text class="value">{{ getDegreeText(staffInfo.initialDegree) || '未填写' }}</text>
  117. </view>
  118. <view class="info-item">
  119. <text class="label">初始学历专业</text>
  120. <text class="value">{{ staffInfo.initialMajor || '未填写' }}</text>
  121. </view>
  122. <view class="info-item">
  123. <text class="label">初始学历毕业院校</text>
  124. <text class="value">{{ staffInfo.initialSchool || '未填写' }}</text>
  125. </view>
  126. </view>
  127. </view>
  128. <!-- 其他信息 -->
  129. <view class="info-section">
  130. <view class="section-title">其他信息</view>
  131. <view class="info-grid">
  132. <view class="info-item">
  133. <text class="label">家庭住址</text>
  134. <text class="value">{{ staffInfo.homePlace || '未填写' }}</text>
  135. </view>
  136. <view class="info-item">
  137. <text class="label">紧急联系人</text>
  138. <text class="value">{{ staffInfo.contact || '未填写' }}</text>
  139. </view>
  140. <view class="info-item">
  141. <text class="label">紧急联系电话</text>
  142. <text class="value">{{ staffInfo.telephone || '未填写' }}</text>
  143. </view>
  144. <view class="info-item">
  145. <text class="label">备注</text>
  146. <text class="value">{{ staffInfo.remark || '无' }}</text>
  147. </view>
  148. </view>
  149. </view>
  150. <!-- 操作按钮 -->
  151. <view class="action-section">
  152. <uv-button type="primary" @click="handleEdit">编辑信息</uv-button>
  153. </view>
  154. </view>
  155. </template>
  156. <script>
  157. import { getUser } from "@/api/system/user";
  158. export default {
  159. data() {
  160. return {
  161. staffInfo: {},
  162. userId: '',
  163. nickName: ''
  164. }
  165. },
  166. onLoad(options) {
  167. this.userId = options.userId;
  168. this.nickName = options.nickName;
  169. this.getStaffInfo();
  170. },
  171. methods: {
  172. // 获取员工信息
  173. async getStaffInfo() {
  174. try {
  175. const res = await getUser(this.userId);
  176. this.staffInfo = res.data;
  177. } catch (error) {
  178. console.error('获取员工信息失败:', error);
  179. uni.showToast({
  180. title: '获取员工信息失败',
  181. icon: 'none'
  182. });
  183. }
  184. },
  185. // 获取状态文本
  186. getStatusText(status) {
  187. const statusMap = {
  188. '0': '在职',
  189. '1': '离职',
  190. '2': '退休',
  191. '3': '试用',
  192. '4': '返聘'
  193. };
  194. return statusMap[status] || '未知';
  195. },
  196. // 获取状态类型
  197. getStatusType(status) {
  198. const typeMap = {
  199. '0': 'success',
  200. '1': 'error',
  201. '2': 'warning',
  202. '3': 'primary',
  203. '4': 'info'
  204. };
  205. return typeMap[status] || 'default';
  206. },
  207. // 获取职称文本
  208. getTitleText(titles) {
  209. const titleMap = {
  210. '1': '高级工程师',
  211. '2': '工程师',
  212. '3': '助理工程师',
  213. '4': '技术员'
  214. };
  215. return titleMap[titles] || '';
  216. },
  217. // 获取职业资格文本
  218. getCertificateText(certificates) {
  219. if (!certificates) return '';
  220. const certificateMap = {
  221. '1': '注册测绘师',
  222. '2': '注册建筑师',
  223. '3': '注册结构师',
  224. '4': '注册造价师'
  225. };
  226. const certArray = certificates.split(',');
  227. return certArray.map(cert => certificateMap[cert] || cert).join('、');
  228. },
  229. // 获取学历文本
  230. getDegreeText(degree) {
  231. const degreeMap = {
  232. '1': '博士',
  233. '2': '硕士',
  234. '3': '本科',
  235. '4': '专科',
  236. '5': '高中'
  237. };
  238. return degreeMap[degree] || '';
  239. },
  240. // 获取政治面貌文本
  241. getPoliticalText(politicalAffiliation) {
  242. if (!politicalAffiliation) return '';
  243. const politicalMap = {
  244. '1': '中共党员',
  245. '2': '中共预备党员',
  246. '3': '共青团员',
  247. '4': '民革党员',
  248. '5': '民盟盟员',
  249. '6': '民建会员',
  250. '7': '民进会员',
  251. '8': '农工党党员',
  252. '9': '致公党党员',
  253. '10': '九三学社社员',
  254. '11': '台盟盟员',
  255. '12': '无党派人士',
  256. '13': '群众'
  257. };
  258. const politicalArray = politicalAffiliation.split(',');
  259. return politicalArray.map(political => politicalMap[political] || political).join('、');
  260. },
  261. // 获取岗级文本
  262. getPostLevelText(postLevel, salaryLevel) {
  263. const postLevelMap = {
  264. '1': '一级',
  265. '2': '二级',
  266. '3': '三级',
  267. '4': '四级',
  268. '5': '五级'
  269. };
  270. const salaryLevelMap = {
  271. '1': 'A',
  272. '2': 'B',
  273. '3': 'C',
  274. '4': 'D',
  275. '5': 'E'
  276. };
  277. const postText = postLevelMap[postLevel] || '';
  278. const salaryText = salaryLevelMap[salaryLevel] || '';
  279. return postText && salaryText ? `${postText}${salaryText}` : '';
  280. },
  281. // 根据身份证计算年龄
  282. getAgeByIdCard(idCard) {
  283. if (!idCard) return 0;
  284. const birthStr = idCard.substring(6, 14);
  285. const birthYear = parseInt(birthStr.substring(0, 4), 10);
  286. const birthMonth = parseInt(birthStr.substring(4, 6), 10) - 1;
  287. const birthDay = parseInt(birthStr.substring(6, 8), 10);
  288. const birthDate = new Date(birthYear, birthMonth, birthDay);
  289. const now = new Date();
  290. let age = now.getFullYear() - birthDate.getFullYear();
  291. const monthDiff = now.getMonth() - birthDate.getMonth();
  292. if (monthDiff < 0 || (monthDiff === 0 && now.getDate() < birthDate.getDate())) {
  293. age--;
  294. }
  295. return age;
  296. },
  297. // 格式化日期
  298. formatDate(dateStr) {
  299. if (!dateStr) return '';
  300. const date = new Date(dateStr);
  301. return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
  302. },
  303. // 编辑信息
  304. handleEdit() {
  305. uni.navigateTo({
  306. url: `/pages/oa/staff/staffEdit?userId=${this.userId}`
  307. });
  308. }
  309. }
  310. }
  311. </script>
  312. <style lang="scss" scoped>
  313. .container {
  314. background-color: #f5f5f5;
  315. min-height: 100vh;
  316. padding-bottom: 120rpx;
  317. }
  318. .header-section {
  319. background-color: #fff;
  320. padding: 40rpx 30rpx;
  321. display: flex;
  322. align-items: center;
  323. margin-bottom: 20rpx;
  324. .avatar-section {
  325. margin-right: 30rpx;
  326. }
  327. .basic-info {
  328. flex: 1;
  329. .name {
  330. font-size: 36rpx;
  331. font-weight: bold;
  332. color: #333;
  333. margin-bottom: 10rpx;
  334. }
  335. .dept {
  336. font-size: 28rpx;
  337. color: #666;
  338. margin-bottom: 15rpx;
  339. }
  340. .status {
  341. display: inline-block;
  342. }
  343. }
  344. }
  345. .info-section {
  346. background-color: #fff;
  347. margin-bottom: 20rpx;
  348. padding: 30rpx;
  349. .section-title {
  350. font-size: 32rpx;
  351. font-weight: bold;
  352. color: #333;
  353. margin-bottom: 30rpx;
  354. border-left: 6rpx solid #007aff;
  355. padding-left: 20rpx;
  356. }
  357. .info-grid {
  358. .info-item {
  359. display: flex;
  360. margin-bottom: 25rpx;
  361. .label {
  362. width: 200rpx;
  363. font-size: 28rpx;
  364. color: #666;
  365. }
  366. .value {
  367. flex: 1;
  368. font-size: 28rpx;
  369. color: #333;
  370. word-break: break-all;
  371. }
  372. }
  373. }
  374. }
  375. .action-section {
  376. position: fixed;
  377. bottom: 0;
  378. left: 0;
  379. right: 0;
  380. background-color: #fff;
  381. padding: 20rpx 30rpx;
  382. border-top: 1rpx solid #eee;
  383. .uv-button {
  384. width: 100%;
  385. }
  386. }
  387. </style>