综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <template>
  2. <view class="container">
  3. <!-- 搜索栏 -->
  4. <view class="search-bar">
  5. <view class="search-input">
  6. <input class="search-input-field" v-model="queryParams.nickName" placeholder="请输入姓名搜索" @input="handleQuery"
  7. @confirm="handleQuery" />
  8. </view>
  9. </view>
  10. <!-- 部门选择 -->
  11. <view class="dept-section" v-if="deptOptions.length > 0">
  12. <view class="dept-header">
  13. <text class="dept-title">部门</text>
  14. <text class="dept-name">{{ currentDeptName || '全部部门' }}</text>
  15. </view>
  16. <scroll-view class="dept-scroll" scroll-x>
  17. <view class="dept-list">
  18. <view class="dept-item" :class="{ active: !queryParams.deptId }" @click="selectDept(null, '全部部门')">
  19. 全部
  20. </view>
  21. <view v-for="dept in deptOptions" :key="dept.id" class="dept-item"
  22. :class="{ active: queryParams.deptId === dept.id }" @click="selectDept(dept.id, dept.label)">
  23. {{ dept.label }}
  24. </view>
  25. </view>
  26. </scroll-view>
  27. </view>
  28. <!-- 状态选择 -->
  29. <view class="status-section">
  30. <view class="status-header">
  31. <text class="status-title">状态</text>
  32. <text class="status-name">{{ getStatusLabel(queryParams.status) || '在职' }}</text>
  33. </view>
  34. <scroll-view class="status-scroll" scroll-x>
  35. <view class="status-list">
  36. <view class="status-item" :class="{ active: queryParams.status === '0' }" @click="selectStatus('0')">
  37. 在职
  38. </view>
  39. <view class="status-item" :class="{ active: queryParams.status === '1' }" @click="selectStatus('1')">
  40. 离职
  41. </view>
  42. <view class="status-item" :class="{ active: queryParams.status === '2' }" @click="selectStatus('2')">
  43. 退休
  44. </view>
  45. </view>
  46. </scroll-view>
  47. </view>
  48. <!-- 员工列表 -->
  49. <mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
  50. :up="upOption" :fixed="false" :top="10" style="padding: 30rpx;">
  51. <view class="staff-list">
  52. <view v-for="(item, index) in staffList" :key="index" class="staff-card" @click="handleView(item)">
  53. <view class="staff-header">
  54. <view class="staff-avatar">
  55. <image class="avatar-image" :src="item.avatar || '/static/images/user.png'" mode="aspectFill" />
  56. </view>
  57. <view class="staff-info">
  58. <view class="staff-name">{{ item.nickName }}</view>
  59. <view class="staff-dept">{{ (item.dept && item.dept.deptName) || '未分配部门' }}</view>
  60. <view class="staff-status">
  61. <text class="status-tag" :class="'status-' + item.status">
  62. {{ getStatusText(item.status) }}
  63. </text>
  64. </view>
  65. </view>
  66. <view class="staff-actions">
  67. <text class="arrow-icon" @click="goToDetail(item)">详情</text>
  68. </view>
  69. </view>
  70. <view class="staff-details">
  71. <view class="detail-item">
  72. <text class="detail-label">年龄:</text>
  73. <text class="detail-value">{{ String(getAgeByIdCard(item.idCard)).slice(0, 2) }}岁</text>
  74. </view>
  75. <view class="detail-item">
  76. <text class="detail-label">性别:</text>
  77. <text class="detail-value">{{ item.sex == 0 ? '男' : '女' }}</text>
  78. </view>
  79. <view class="detail-item">
  80. <text class="detail-label">手机:</text>
  81. <text class="detail-value">{{ item.phonenumber || '无' }}</text>
  82. </view>
  83. <view class="detail-item">
  84. <text class="detail-label">职称:</text>
  85. <text class="detail-value">{{ getTitleText(item.titles) || '无' }}</text>
  86. </view>
  87. <view class="detail-item">
  88. <text class="detail-label">职务:</text>
  89. <text class="detail-value">{{ item.postNames || '无' }}</text>
  90. </view>
  91. <view class="detail-item">
  92. <text class="detail-label">岗级:</text>
  93. <text class="detail-value">{{ formatPostLevel(item.postLevel, item.salaryLevel) || '无' }}</text>
  94. </view>
  95. <view class="detail-item">
  96. <text class="detail-label">入职时间:</text>
  97. <text class="detail-value">{{ formatDate(item.entryDate) || '无' }}</text>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </mescroll-uni>
  103. </view>
  104. </template>
  105. <script>
  106. import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus } from "@/api/system/user";
  107. import { deptTreeSelectNew } from "@/api/system/dept";
  108. import MescrollMixin from '@/uni_modules/mescroll/components/mescroll-uni/mescroll-mixins.js';
  109. export default {
  110. mixins: [MescrollMixin],
  111. data() {
  112. return {
  113. mescroll: null, // mescroll实例
  114. downOption: {
  115. auto: true,
  116. textOutOffset: '下拉刷新',
  117. textLoading: '加载中...'
  118. },
  119. upOption: {
  120. auto: false,
  121. page: { num: 1, size: 10 },
  122. noMoreSize: 5,
  123. empty: { tip: '暂无更多员工数据' },
  124. textNoMore: '~ 没有更多数据了 ~'
  125. },
  126. staffList: [],
  127. deptOptions: [],
  128. currentDeptName: '',
  129. queryParams: {
  130. pageNum: 1,
  131. pageSize: 10,
  132. nickName: '',
  133. titles: '',
  134. certificates: '',
  135. degree: '',
  136. status: '0',
  137. deptId: undefined
  138. },
  139. // 筛选选项
  140. titleOptions: [
  141. { label: '正高级工程师', value: '0' },
  142. { label: '高级工程师', value: '1' },
  143. { label: '工程师', value: '2' },
  144. { label: '助理工程师', value: '3' },
  145. { label: '技术员', value: '4' }
  146. ],
  147. certificateOptions: [
  148. { label: '注册测绘师', value: '1' },
  149. { label: '注册建筑师', value: '2' },
  150. { label: '注册结构师', value: '3' },
  151. { label: '注册造价师', value: '4' }
  152. ],
  153. degreeOptions: [
  154. { label: '博士', value: '1' },
  155. { label: '硕士', value: '2' },
  156. { label: '本科', value: '3' },
  157. { label: '专科', value: '4' },
  158. { label: '高中', value: '5' }
  159. ],
  160. statusOptions: [
  161. { label: '在职', value: '0' },
  162. { label: '离职', value: '1' },
  163. { label: '退休', value: '2' },
  164. { label: '试用', value: '3' },
  165. { label: '返聘', value: '4' }
  166. ]
  167. }
  168. },
  169. onLoad: function (options) {
  170. this.getDeptTree();
  171. uni.startPullDownRefresh();
  172. },
  173. methods: {
  174. mescrollInit(mescroll) {
  175. this.mescroll = mescroll;
  176. },
  177. // 获取部门树
  178. async getDeptTree() {
  179. try {
  180. const res = await deptTreeSelectNew();
  181. this.deptOptions = res.data[0].children || [];
  182. } catch (error) {
  183. console.error('获取部门树失败:', error);
  184. }
  185. },
  186. // 选择部门
  187. selectDept(deptId, deptName) {
  188. this.queryParams.deptId = deptId;
  189. this.currentDeptName = deptName;
  190. this.handleQuery();
  191. },
  192. // 选择状态
  193. selectStatus(status) {
  194. this.queryParams.status = status;
  195. this.handleQuery();
  196. },
  197. // 搜索
  198. handleQuery() {
  199. this.queryParams.pageNum = 1;
  200. this.staffList = [];
  201. this.downCallback();
  202. },
  203. // 重置查询
  204. resetQuery() {
  205. this.queryParams = {
  206. pageNum: 1,
  207. pageSize: 10,
  208. nickName: '',
  209. titles: '',
  210. certificates: '',
  211. degree: '',
  212. status: '0', // 默认选中在职
  213. deptId: undefined
  214. };
  215. this.currentDeptName = '';
  216. this.handleQuery();
  217. },
  218. // 获取职称标签
  219. getTitleLabel(value) {
  220. const item = this.titleOptions.find(item => item.value === value);
  221. return item ? item.label : '';
  222. },
  223. // 获取状态标签
  224. getStatusLabel(value) {
  225. const item = this.statusOptions.find(item => item.value === value);
  226. return item ? item.label : '';
  227. },
  228. // 加载数据
  229. async loadData() {
  230. try {
  231. const res = await listUser(this.queryParams);
  232. return { data: res.rows, total: res.total };
  233. } catch (e) {
  234. console.error('加载员工数据失败:', e);
  235. return { data: [], error: true };
  236. }
  237. },
  238. // mescroll下拉刷新回调
  239. async downCallback() {
  240. this.staffList = []; // 清空列表
  241. this.queryParams.pageNum = 1;
  242. const res = await this.loadData();
  243. if (res.error) {
  244. this.mescroll.endErr();
  245. } else {
  246. this.staffList = res.data;
  247. this.mescroll.endSuccess(res.data.length, res.total);
  248. }
  249. uni.stopPullDownRefresh();
  250. },
  251. // mescroll上拉加载回调
  252. async upCallback(page) {
  253. this.queryParams.pageNum = page.num;
  254. const res = await this.loadData();
  255. if (res.error) {
  256. this.mescroll.endErr();
  257. } else {
  258. this.staffList = this.staffList.concat(res.data);
  259. this.mescroll.endSuccess(res.data.length, res.total);
  260. }
  261. },
  262. // 查看员工详情
  263. handleView(item) {
  264. uni.navigateTo({
  265. url: `/pages/oa/staff/staffDetail?userId=${item.userId}&nickName=${item.nickName}`
  266. });
  267. },
  268. // 获取状态文本
  269. getStatusText(status) {
  270. const statusMap = {
  271. '0': '在职',
  272. '1': '离职',
  273. '2': '退休',
  274. '3': '试用',
  275. '4': '返聘'
  276. };
  277. return statusMap[status] || '未知';
  278. },
  279. // 获取状态类型
  280. getStatusType(status) {
  281. const typeMap = {
  282. '0': 'success',
  283. '1': 'error',
  284. '2': 'warning',
  285. '3': 'primary',
  286. '4': 'info'
  287. };
  288. return typeMap[status] || 'default';
  289. },
  290. // 获取职称文本
  291. getTitleText(titles) {
  292. const titleMap = {
  293. '0': '正高级工程师',
  294. '1': '高级工程师',
  295. '2': '工程师',
  296. '3': '助理工程师',
  297. '4': '技术员'
  298. };
  299. return titleMap[titles] || '';
  300. },
  301. // 根据身份证计算年龄
  302. getAgeByIdCard(idCard) {
  303. if (!idCard) return 0;
  304. const birthStr = idCard.substring(6, 14);
  305. const birthYear = parseInt(birthStr.substring(0, 4), 10);
  306. const birthMonth = parseInt(birthStr.substring(4, 6), 10) - 1;
  307. const birthDay = parseInt(birthStr.substring(6, 8), 10);
  308. const birthDate = new Date(birthYear, birthMonth, birthDay);
  309. const now = new Date();
  310. let age = now.getFullYear() - birthDate.getFullYear();
  311. const monthDiff = now.getMonth() - birthDate.getMonth();
  312. if (monthDiff < 0 || (monthDiff === 0 && now.getDate() < birthDate.getDate())) {
  313. age--;
  314. }
  315. return age;
  316. },
  317. // 格式化日期
  318. formatDate(dateStr) {
  319. if (!dateStr) return '';
  320. const date = new Date(dateStr);
  321. return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
  322. },
  323. // 格式化岗级
  324. formatPostLevel(postLevel, salaryLevel) {
  325. const postLevelMap = {
  326. '0': '一岗',
  327. '1': '二岗',
  328. '2': '三岗',
  329. '3': '四岗',
  330. '4': '五岗',
  331. '5': '六岗',
  332. '6': '七岗',
  333. '7': '八岗',
  334. };
  335. const salaryLevelMap = {
  336. '0': '一级',
  337. '1': '二级',
  338. '2': '三级',
  339. '3': '四级',
  340. };
  341. return postLevelMap[postLevel] + salaryLevelMap[salaryLevel] || '';
  342. },
  343. goToDetail(item) {
  344. uni.navigateTo({
  345. url: `/pages/oa/staff/staffDetail?userId=${item.userId}&nickName=${item.nickName}`
  346. });
  347. }
  348. },
  349. }
  350. </script>
  351. <style lang="scss" scoped>
  352. .container {
  353. padding: 10rpx;
  354. background-color: #f5f5f5;
  355. height: 100vh;
  356. display: flex;
  357. flex-direction: column;
  358. }
  359. .search-bar {
  360. display: flex;
  361. align-items: center;
  362. padding: 20rpx 30rpx;
  363. background-color: #fff;
  364. border-bottom: 1rpx solid #eee;
  365. .search-input {
  366. flex: 1;
  367. .search-input-field {
  368. width: 100%;
  369. height: 60rpx;
  370. padding: 0 20rpx;
  371. border: 1rpx solid #ddd;
  372. border-radius: 30rpx;
  373. font-size: 28rpx;
  374. }
  375. }
  376. }
  377. .dept-section {
  378. background-color: #fff;
  379. padding: 20rpx 30rpx;
  380. border-bottom: 1rpx solid #eee;
  381. .dept-header {
  382. display: flex;
  383. justify-content: space-between;
  384. align-items: center;
  385. margin-bottom: 20rpx;
  386. .dept-title {
  387. font-size: 28rpx;
  388. color: #333;
  389. font-weight: bold;
  390. }
  391. .dept-name {
  392. font-size: 24rpx;
  393. color: #666;
  394. }
  395. }
  396. .dept-scroll {
  397. white-space: nowrap;
  398. .dept-list {
  399. display: flex;
  400. .dept-item {
  401. display: inline-block;
  402. padding: 10rpx 20rpx;
  403. margin-right: 20rpx;
  404. background-color: #f5f5f5;
  405. border-radius: 20rpx;
  406. font-size: 24rpx;
  407. color: #666;
  408. white-space: nowrap;
  409. &.active {
  410. background-color: #007aff;
  411. color: #fff;
  412. }
  413. }
  414. }
  415. }
  416. }
  417. .status-section {
  418. background-color: #fff;
  419. padding: 20rpx 30rpx;
  420. border-bottom: 1rpx solid #eee;
  421. .status-header {
  422. display: flex;
  423. justify-content: space-between;
  424. align-items: center;
  425. margin-bottom: 20rpx;
  426. .status-title {
  427. font-size: 28rpx;
  428. color: #333;
  429. font-weight: bold;
  430. }
  431. .status-name {
  432. font-size: 24rpx;
  433. color: #666;
  434. }
  435. }
  436. .status-scroll {
  437. white-space: nowrap;
  438. .status-list {
  439. display: flex;
  440. .status-item {
  441. display: inline-block;
  442. padding: 10rpx 20rpx;
  443. margin-right: 20rpx;
  444. background-color: #f5f5f5;
  445. border-radius: 20rpx;
  446. font-size: 24rpx;
  447. color: #666;
  448. white-space: nowrap;
  449. &.active {
  450. background-color: #007aff;
  451. color: #fff;
  452. }
  453. }
  454. }
  455. }
  456. }
  457. .staff-list {
  458. .staff-card {
  459. background-color: #fff;
  460. border-radius: 20rpx;
  461. margin-bottom: 20rpx;
  462. padding: 30rpx;
  463. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  464. .staff-header {
  465. display: flex;
  466. align-items: center;
  467. margin-bottom: 20rpx;
  468. .staff-avatar {
  469. margin-right: 20rpx;
  470. .avatar-image {
  471. width: 60rpx;
  472. height: 60rpx;
  473. border-radius: 50%;
  474. }
  475. }
  476. .staff-info {
  477. flex: 1;
  478. .staff-name {
  479. font-size: 32rpx;
  480. font-weight: bold;
  481. color: #333;
  482. margin-bottom: 10rpx;
  483. }
  484. .staff-dept {
  485. font-size: 24rpx;
  486. color: #666;
  487. margin-bottom: 10rpx;
  488. }
  489. .staff-status {
  490. display: inline-block;
  491. .status-tag {
  492. padding: 4rpx 12rpx;
  493. border-radius: 10rpx;
  494. font-size: 20rpx;
  495. &.status-0 {
  496. background-color: #e6f7ff;
  497. color: #52c41a;
  498. }
  499. &.status-1 {
  500. background-color: #fff2e8;
  501. color: #fa8c16;
  502. }
  503. &.status-2 {
  504. background-color: #f6ffed;
  505. color: #1890ff;
  506. }
  507. &.status-3 {
  508. background-color: #f9f0ff;
  509. color: #722ed1;
  510. }
  511. &.status-4 {
  512. background-color: #f0f0f0;
  513. color: #8c8c8c;
  514. }
  515. }
  516. }
  517. }
  518. .staff-actions {
  519. padding: 10rpx;
  520. .arrow-icon {
  521. font-size: 24rpx;
  522. color: #999;
  523. }
  524. }
  525. }
  526. .staff-details {
  527. .detail-item {
  528. display: flex;
  529. margin-bottom: 15rpx;
  530. .detail-label {
  531. width: 140rpx;
  532. font-size: 26rpx;
  533. color: #999;
  534. }
  535. .detail-value {
  536. flex: 1;
  537. font-size: 26rpx;
  538. color: #333;
  539. }
  540. }
  541. }
  542. }
  543. }
  544. </style>