index.vue 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381
  1. <template>
  2. <view class="employee-profile-page">
  3. <view class="page-header">
  4. <view class="header-title">
  5. <view class="title-main">员工综合信息展示</view>
  6. <view class="header-right">
  7. <view class="current-time">{{ currentTime }}</view>
  8. </view>
  9. </view>
  10. <view class="time-filter">
  11. <scroll-view scroll-x class="time-scroll">
  12. <view class="time-tags">
  13. <view v-for="(tag, index) in timeTags" :key="index"
  14. :class="['time-tag', { active: selectedTimeTag === index }]" @click="onTimeTagClick(index)">
  15. {{ tag }}
  16. </view>
  17. </view>
  18. </scroll-view>
  19. <view v-if="selectedTimeTag === 4" class="date-range-picker">
  20. <picker mode="date" :value="beginTime" @change="onBeginTimeChange">
  21. <view class="date-input" :class="{ filled: beginTime }">
  22. {{ (beginTime || '').substring(0, 10) || '开始日期' }}
  23. </view>
  24. </picker>
  25. <text class="date-separator">至</text>
  26. <picker mode="date" :value="endTime" @change="onEndTimeChange">
  27. <view class="date-input" :class="{ filled: endTime }">
  28. {{ (endTime || '').substring(0, 10) || '结束日期' }}
  29. </view>
  30. </picker>
  31. </view>
  32. </view>
  33. <view class="search-selector">
  34. <view class="search-select-trigger" :class="{ 'search-select-trigger-disabled': isSecurityCheck }"
  35. @click="!isSecurityCheck && (showEmployeePicker = true)">
  36. <u-icon name="list" color="#A78BFA" size="16"></u-icon>
  37. <text class="search-name-text">{{ selectedEmployeeName || '请选择员工' }}</text>
  38. <u-icon v-if="!isSecurityCheck" name="arrow-down" color="#A78BFA" size="14"></u-icon>
  39. </view>
  40. </view>
  41. <!-- <view class="tab-nav">
  42. <view class="tab-item" :class="{ active: activeTab === 'profile' }" @click="activeTab = 'profile'">
  43. 能力画像
  44. </view>
  45. <view class="tab-item" :class="{ active: activeTab === 'data' }" @click="activeTab = 'data'">
  46. 运行数据
  47. </view>
  48. </view> -->
  49. </view>
  50. <view class="page-content">
  51. <view v-if="!portrait.personName" class="empty-state">
  52. <view class="empty-icon">📋</view>
  53. <view class="empty-text">搜索员工姓名以查看画像</view>
  54. </view>
  55. <view v-if="portrait.personName">
  56. <SectionTitle title="个人基本信息">
  57. <view class="user-info">
  58. <view class="user-header">
  59. <view class="avatar-area">
  60. <image v-if="portrait.avatar" :src="portrait.avatar" class="avatar" mode="aspectFill">
  61. </image>
  62. <view v-else class="avatar-placeholder">{{ portrait.personName ?
  63. portrait.personName.charAt(0) : '' }}</view>
  64. </view>
  65. <view class="name-row">
  66. <view class="name-label">姓名:</view>
  67. <view class="name-value">{{ portrait.personName }}</view>
  68. </view>
  69. </view>
  70. <view class="info-grid">
  71. <view class="info-item">
  72. <view class="info-label">所属部门及队室:</view>
  73. <view class="info-value">{{ portrait.deptPath || '-' }}</view>
  74. </view>
  75. <view class="info-item">
  76. <view class="info-label">学历:</view>
  77. <view class="info-value">{{ schoolingText }}</view>
  78. </view>
  79. <view class="info-item">
  80. <view class="info-label">出生日期:</view>
  81. <view class="info-value">{{ portrait.birthday || '-' }}</view>
  82. </view>
  83. <view class="info-item">
  84. <view class="info-label">专业:</view>
  85. <view class="info-value">{{ portrait.major || '-' }}</view>
  86. </view>
  87. <view class="info-item">
  88. <view class="info-label">技能等级:</view>
  89. <view class="info-value">{{ portrait.qualificationLevelText || '-' }}</view>
  90. </view>
  91. <view class="info-item">
  92. <view class="info-label">标签:</view>
  93. <view class="info-value" v-if="portrait.userTags">
  94. <text class="tag" v-for="tag in portrait.userTags.split(',')" :key="tag">{{ tag }}</text>
  95. </view>
  96. </view>
  97. </view>
  98. <view class="score-section">
  99. <div class="score-circle" ref="scoreCircle"></div>
  100. <view class="score-box">
  101. <!-- <view class="score-row">
  102. <text class="score-label">评分:</text>
  103. <text class="score-val">{{ portrait.totalScore || 0 }}</text>
  104. </view> -->
  105. <view class="score-row">
  106. <text class="score-label">附加分:</text>
  107. <text class="score-val">{{ tagScoreDisplay }}分</text>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </SectionTitle>
  113. <SectionTitle v-if="activeTab === 'profile'" title="工作履历">
  114. <view class="work-history">
  115. <text v-if="portrait.entryDate">
  116. {{ formatWorkDate(portrait.entryDate) }}入职 | 司龄{{ portrait.companyYears != null ?
  117. portrait.companyYears : '-' }}年
  118. | 开机年限{{ portrait.xrayOperatorYears != null ? portrait.xrayOperatorYears : '-' }}年
  119. | 现任职{{ portrait.roleNames || '-' }}
  120. </text>
  121. <text v-else>暂无数据</text>
  122. </view>
  123. </SectionTitle>
  124. <SectionTitle v-if="activeTab === 'profile'" title="获奖记录">
  125. <view class="honor-list">
  126. <view class="honor-item" v-for="(item, index) in portrait.awards" :key="index">
  127. <view class="honor-name">
  128. <text class="honor-dot"
  129. :style="{ background: item.color || honorColors[index % honorColors.length] }"></text>
  130. {{ item.level2Name }} {{ item.level4Name }}
  131. </view>
  132. <view class="honor-score">{{ item.score || '-' }}分</view>
  133. </view>
  134. <view v-if="!portrait.awards || portrait.awards.length === 0" class="no-data">暂无获奖记录</view>
  135. </view>
  136. </SectionTitle>
  137. <SectionTitle v-if="activeTab === 'profile'" title="个人能力">
  138. <div class="chart-container" ref="radarChart"></div>
  139. </SectionTitle>
  140. <SectionTitle v-if="activeTab === 'profile'" title="补充信息">
  141. <view class="supp-grid">
  142. <view class="supp-item">
  143. <text class="supp-label">政治面貌:</text>
  144. <text class="supp-value">{{ portrait.politicalStatusText || '-' }}</text>
  145. </view>
  146. <view class="supp-item">
  147. <text class="supp-label">性别:</text>
  148. <text class="supp-value">{{ portrait.sexText || '-' }}</text>
  149. </view>
  150. <view class="supp-item">
  151. <text class="supp-label">籍贯:</text>
  152. <text class="supp-value">{{ portrait.nativePlace || '-' }}</text>
  153. </view>
  154. <view class="supp-item">
  155. <text class="supp-label">民族:</text>
  156. <text class="supp-value">{{ portrait.nation || '-' }}</text>
  157. </view>
  158. <view class="supp-item">
  159. <text class="supp-label">年龄:</text>
  160. <text class="supp-value">{{ ageText }}</text>
  161. </view>
  162. <view class="supp-item">
  163. <text class="supp-label">司龄:</text>
  164. <text class="supp-value">{{ portrait.companyYears != null ? portrait.companyYears + '年' :
  165. '-' }}</text>
  166. </view>
  167. <view class="supp-item">
  168. <text class="supp-label">性格特征:</text>
  169. <text class="supp-value">{{ portrait.characterCharacteristics || '-' }}</text>
  170. </view>
  171. <view class="supp-item">
  172. <text class="supp-label">工作风格:</text>
  173. <text class="supp-value">{{ portrait.workingStyle || '-' }}</text>
  174. </view>
  175. <view class="supp-item">
  176. <text class="supp-label">业务岗位:</text>
  177. <text class="supp-value">{{ portrait.postNames || '-' }}</text>
  178. </view>
  179. </view>
  180. </SectionTitle>
  181. <!-- <SectionTitle v-if="activeTab === 'data'" title="预警信息">
  182. <view class="warning-content" @click="showWarning = true">
  183. <view class="warning-tip">点击查看详细预警信息</view>
  184. </view>
  185. </SectionTitle> -->
  186. </view>
  187. </view>
  188. <view class="warning-overlay" v-if="showWarning" @click="showWarning = false">
  189. <view class="warning-panel" @click.stop>
  190. <view class="warning-header">
  191. <text class="warning-title">预警中枢</text>
  192. <text class="warning-close" @click="showWarning = false">✕</text>
  193. </view>
  194. <view class="warning-body">
  195. <view class="warning-desc">员工综合评估(<75分红色预警 | ≥90分优秀)</view>
  196. <view class="warning-score">
  197. <view class="warning-score-item">
  198. <text class="warning-score-label">综合得分</text>
  199. <text class="warning-score-value" :class="scoreLevelClass">{{ portrait.totalScore || 0
  200. }}</text>
  201. </view>
  202. </view>
  203. <view class="warning-detail" v-if="scoreDetails.length">
  204. <view class="warning-detail-title">评分明细</view>
  205. <view class="warning-detail-item" v-for="(item, index) in scoreDetails" :key="index">
  206. <view class="detail-left">
  207. <text class="detail-dim">{{ item.dimensionName }}</text>
  208. <text class="detail-name">{{ item.level3Name }}</text>
  209. </view>
  210. <view class="detail-score"
  211. :class="{ 'add-text': item.totalScore > 0, 'deduct-text': item.totalScore < 0 }">
  212. {{ item.totalScore > 0 ? '+' : '' }}{{ item.totalScore }}
  213. </view>
  214. </view>
  215. </view>
  216. </view>
  217. </view>
  218. </view>
  219. <u-popup :show="showEmployeePicker" mode="bottom" :round="16" :mask-close-able="true"
  220. :safe-area-inset-bottom="true" @close="onEmployeePickerClose">
  221. <view class="employee-picker">
  222. <view class="picker-header">
  223. <text class="picker-title">选择员工</text>
  224. </view>
  225. <view class="search-box">
  226. <u-input v-model="employeeSearchKeyword" placeholder="搜索员工" @confirm="onEmployeeSearch"
  227. @input="onEmployeeSearch"></u-input>
  228. </view>
  229. <scroll-view v-if="!employeeSearchKeyword.trim()" scroll-y class="tree-list">
  230. <template v-for="(node, index) in deptTreeData">
  231. <employee-tree-node
  232. :key="node.id"
  233. :node="node"
  234. :expanded-ids="expandedDeptIds"
  235. :selected-id="selectedEmployeeId"
  236. @toggle="toggleDeptExpand"
  237. @select="onEmployeeSelect"
  238. />
  239. </template>
  240. </scroll-view>
  241. <scroll-view v-else scroll-y class="employee-list">
  242. <view class="employee-item" v-for="item in filteredEmployeeList" :key="item.userId"
  243. @click="onEmployeeSelect(item)">
  244. <text class="employee-item-name">{{ item.nickName }}</text>
  245. <u-icon v-if="item.userId === selectedEmployeeId" name="checkmark" color="#34D399"
  246. size="18"></u-icon>
  247. </view>
  248. <view v-if="filteredEmployeeList.length === 0 && !employeeLoading" class="empty-state">
  249. <text>暂无数据</text>
  250. </view>
  251. <view v-if="employeeLoading" class="loading-state">
  252. <u-loading-icon text="加载中" textSize="14"></u-loading-icon>
  253. </view>
  254. </scroll-view>
  255. </view>
  256. </u-popup>
  257. </view>
  258. </template>
  259. <script>
  260. import * as echarts from 'echarts'
  261. import { getEmployeePortrait, countTagScore } from '@/api/portraitManagement/portraitManagement'
  262. import { listAllUser, getDeptUserTree } from '@/api/system/user'
  263. import SectionTitle from '@/components/SectionTitle.vue'
  264. import EmployeeTreeNode from '@/pages/components/EmployeeTreeNode.vue'
  265. const honorColors = ['#60A5FA', '#34D399', '#FBBF24', '#EF4444', '#A78BFA', '#F472B6', '#6EE7B7', '#FB923C']
  266. const schoolingMap = {
  267. '1': '小学',
  268. '2': '初中',
  269. '3': '高中',
  270. '4': '中专',
  271. '5': '大专',
  272. '6': '本科',
  273. '7': '硕士',
  274. '8': '博士'
  275. }
  276. function getRandomHexColor() {
  277. return '#' + Math.floor(Math.random() * 0xffffff).toString(16).padStart(6, '0')
  278. }
  279. export default {
  280. name: 'EmployeeProfile',
  281. components: {
  282. SectionTitle,
  283. EmployeeTreeNode
  284. },
  285. data() {
  286. return {
  287. activeTab: 'profile',
  288. selectedTimeTag: 3,
  289. timeTags: ['近一周', '近一月', '近三月', '近一年', '自定义时间范围'],
  290. currentTime: '',
  291. timer: null,
  292. beginTime: '',
  293. endTime: '',
  294. searchKeyword: '',
  295. portrait: { dimensions: [], awards: [] },
  296. tagScoreData: null,
  297. scoreDetails: [],
  298. showWarning: false,
  299. radarChartInstance: null,
  300. scoreChartInstance: null,
  301. // 员工选择相关
  302. showEmployeePicker: false,
  303. selectedEmployeeId: null,
  304. selectedEmployeeName: '',
  305. deptTreeData: [],
  306. pickerTreeData: [],
  307. employeeList: [],
  308. employeeSearchKeyword: '',
  309. employeeLoading: false,
  310. expandedDeptIds: [],
  311. isSecurityCheck: false,
  312. userInfo: null
  313. }
  314. },
  315. computed: {
  316. schoolingText() {
  317. if (!this.portrait.schooling) return '-'
  318. return schoolingMap[this.portrait.schooling] || this.portrait.schooling
  319. },
  320. ageText() {
  321. if (!this.portrait.birthday) return '-'
  322. const birthDate = new Date(this.portrait.birthday)
  323. if (isNaN(birthDate.getTime())) return '-'
  324. const today = new Date()
  325. let age = today.getFullYear() - birthDate.getFullYear()
  326. const monthDiff = today.getMonth() - birthDate.getMonth()
  327. if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
  328. age--
  329. }
  330. return age + '岁'
  331. },
  332. tagScoreDisplay() {
  333. // if (this.tagScoreData == null) return '0'
  334. // if (typeof this.tagScoreData === 'object') {
  335. // return this.tagScoreData.totalScore ?? this.tagScoreData.score ?? this.tagScoreData ?? '0'
  336. // }
  337. return this.portrait?.userTags?.split(',').length || 0
  338. },
  339. scoreLevelClass() {
  340. if ((this.portrait.totalScore || 0) < 75) return 'score-danger'
  341. if ((this.portrait.totalScore || 0) >= 90) return 'score-excellent'
  342. return ''
  343. },
  344. currentDate() {
  345. const now = new Date()
  346. const year = now.getFullYear()
  347. const month = String(now.getMonth() + 1).padStart(2, '0')
  348. const day = String(now.getDate()).padStart(2, '0')
  349. const weekDays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
  350. const weekDay = weekDays[now.getDay()]
  351. return `${year}年${month}月${day}日 ${weekDay}`
  352. },
  353. filteredEmployeeList() {
  354. const keyword = this.employeeSearchKeyword.trim().toLowerCase()
  355. if (!keyword) return this.employeeList
  356. return this.employeeList.filter(item =>
  357. (item.nickName || '').toLowerCase().includes(keyword)
  358. )
  359. }
  360. },
  361. mounted() {
  362. this.updateTime()
  363. this.timer = setInterval(() => {
  364. this.updateTime()
  365. }, 1000)
  366. // 默认计算时间范围(近一年)
  367. this.onTimeTagClick(this.selectedTimeTag)
  368. this.fetchEmployeeList()
  369. },
  370. beforeDestroy() {
  371. if (this.timer) {
  372. clearInterval(this.timer)
  373. }
  374. if (this.radarChartInstance) {
  375. this.radarChartInstance.dispose()
  376. }
  377. if (this.scoreChartInstance) {
  378. this.scoreChartInstance.dispose()
  379. }
  380. },
  381. methods: {
  382. updateTime() {
  383. const now = new Date()
  384. const hours = String(now.getHours()).padStart(2, '0')
  385. const minutes = String(now.getMinutes()).padStart(2, '0')
  386. const seconds = String(now.getSeconds()).padStart(2, '0')
  387. this.currentTime = `${hours}:${minutes}:${seconds}`
  388. },
  389. // 员工相关方法
  390. // 扁平化部门树,提取人员
  391. flattenDeptTree(tree) {
  392. const result = []
  393. const traverse = (nodes) => {
  394. nodes.forEach(node => {
  395. const hasChildren = node.children && node.children.length > 0
  396. if (!hasChildren && node.nodeType !== 'dept') {
  397. result.push({
  398. nodeType: node.nodeType || '',
  399. userId: node.userId || node.id,
  400. nickName: node.nickName || node.label || node.userName || ''
  401. })
  402. }
  403. if (hasChildren) {
  404. traverse(node.children)
  405. }
  406. })
  407. }
  408. traverse(tree)
  409. return result
  410. },
  411. // 从树中查找第一个用户节点
  412. findFirstUser(nodes) {
  413. for (const node of nodes) {
  414. const hasChildren = node.children && node.children.length > 0
  415. if (!hasChildren && node.nodeType !== 'dept') {
  416. return node
  417. }
  418. if (hasChildren) {
  419. const found = this.findFirstUser(node.children)
  420. if (found) return found
  421. }
  422. }
  423. return null
  424. },
  425. // 展开所有部门节点
  426. expandAllDepts(nodes) {
  427. this.expandedDeptIds = []
  428. const traverse = (list) => {
  429. list.forEach(node => {
  430. const hasChildren = node.children && node.children.length > 0
  431. if (hasChildren || node.nodeType === 'dept') {
  432. this.expandedDeptIds.push(node.id)
  433. if (hasChildren) {
  434. traverse(node.children)
  435. }
  436. }
  437. })
  438. }
  439. traverse(nodes)
  440. },
  441. fetchEmployeeList() {
  442. this.employeeLoading = true
  443. const user = this.$store.state.user?.userInfo || this.$store.state.user?.user
  444. this.userInfo = user
  445. // 检查角色是否包含 SecurityCheck
  446. const roles = this.$store.state.user?.roles || []
  447. this.isSecurityCheck = roles.some(role => role.includes('SecurityCheck'))
  448. if (this.isSecurityCheck && user) {
  449. // SecurityCheck 角色,默认显示登录人,不可编辑
  450. this.selectedEmployeeId = user.userId || user.id
  451. this.selectedEmployeeName = user.nickName || user.userName || ''
  452. this.searchKeyword = this.selectedEmployeeName
  453. this.deptTreeData = []
  454. this.pickerTreeData = []
  455. this.employeeLoading = false
  456. // 自动加载画像数据
  457. this.fetchEmployeePortrait()
  458. } else {
  459. // 其他角色,使用 getDeptUserTree 接口
  460. if (user && user.deptId) {
  461. getDeptUserTree({ deptId: user.deptId }).then(res => {
  462. if (res.code === 200) {
  463. this.deptTreeData = res.data || []
  464. const allUsers = this.flattenDeptTree(this.deptTreeData)
  465. this.employeeList = allUsers.filter(user => user.nodeType === 'user')
  466. // 默认展开所有部门
  467. this.expandAllDepts(this.deptTreeData)
  468. // 默认选中第一个用户
  469. const firstUser = this.findFirstUser(this.deptTreeData)
  470. if (firstUser) {
  471. this.selectedEmployeeId = firstUser.userId || firstUser.id
  472. this.selectedEmployeeName = firstUser.nickName || firstUser.label || firstUser.userName || ''
  473. this.searchKeyword = this.selectedEmployeeName
  474. this.fetchEmployeePortrait()
  475. }
  476. }
  477. }).catch(() => {
  478. }).finally(() => {
  479. this.employeeLoading = false
  480. })
  481. } else {
  482. this.employeeLoading = false
  483. }
  484. }
  485. },
  486. onEmployeeSearch() {
  487. // 搜索由 computed 自动处理
  488. },
  489. toggleDeptExpand(id) {
  490. const index = this.expandedDeptIds.indexOf(id)
  491. if (index > -1) {
  492. this.expandedDeptIds.splice(index, 1)
  493. } else {
  494. this.expandedDeptIds.push(id)
  495. }
  496. },
  497. onEmployeeSelect(item) {
  498. this.selectedEmployeeId = item.userId
  499. this.selectedEmployeeName = item.nickName
  500. this.searchKeyword = item.nickName
  501. this.showEmployeePicker = false
  502. this.fetchEmployeePortrait()
  503. },
  504. onEmployeePickerClose() {
  505. this.showEmployeePicker = false
  506. },
  507. buildTimeParams() {
  508. const now = new Date()
  509. const today = this.formatDate(now)
  510. if (this.selectedTimeTag === 4) {
  511. if (this.startDate && this.endDate) {
  512. return { startDate: this.startDate, endDate: this.endDate }
  513. }
  514. return {}
  515. }
  516. let startDate
  517. switch (this.selectedTimeTag) {
  518. case 0:
  519. startDate = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000)
  520. break
  521. case 1:
  522. startDate = new Date(now.getFullYear(), now.getMonth() - 1, now.getDate())
  523. break
  524. case 2:
  525. startDate = new Date(now.getFullYear(), now.getMonth() - 3, now.getDate())
  526. break
  527. case 3:
  528. startDate = new Date(now.getFullYear() - 1, now.getMonth(), now.getDate())
  529. break
  530. default:
  531. return {}
  532. }
  533. return { startDate: this.formatDate(startDate), endDate: today }
  534. },
  535. formatDate(date) {
  536. const y = date.getFullYear()
  537. const m = String(date.getMonth() + 1).padStart(2, '0')
  538. const d = String(date.getDate()).padStart(2, '0')
  539. return `${y}-${m}-${d}`
  540. },
  541. onTimeTagClick(index) {
  542. this.selectedTimeTag = index
  543. if (index === 4) {
  544. this.beginTime = ''
  545. this.endTime = ''
  546. return
  547. }
  548. // 自动计算时间范围
  549. const now = new Date()
  550. // 设置结束时间为今天的 23:59:59
  551. const endTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59)
  552. // 设置开始时间
  553. let beginTime
  554. switch(index) {
  555. case 0: // 近一周
  556. beginTime = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000)
  557. break
  558. case 1: // 近一月
  559. beginTime = new Date(now.getFullYear(), now.getMonth() - 1, now.getDate())
  560. break
  561. case 2: // 近三月
  562. beginTime = new Date(now.getFullYear(), now.getMonth() - 3, now.getDate())
  563. break
  564. case 3: // 近一年
  565. beginTime = new Date(now.getFullYear() - 1, now.getMonth(), now.getDate())
  566. break
  567. default:
  568. beginTime = now
  569. }
  570. // 格式化日期为 YYYY-MM-DD HH:mm:ss
  571. this.beginTime = this.formatFullDate(beginTime)
  572. this.endTime = this.formatFullDate(endTime)
  573. // 选择时间标签后立即查询
  574. if (this.selectedEmployeeId) {
  575. this.fetchEmployeePortrait()
  576. }
  577. },
  578. formatFullDate(d) {
  579. const y = d.getFullYear()
  580. const m = String(d.getMonth() + 1).padStart(2, '0')
  581. const day = String(d.getDate()).padStart(2, '0')
  582. const h = String(d.getHours()).padStart(2, '0')
  583. const min = String(d.getMinutes()).padStart(2, '0')
  584. const s = String(d.getSeconds()).padStart(2, '0')
  585. return `${y}-${m}-${day} ${h}:${min}:${s}`
  586. },
  587. onBeginTimeChange(e) {
  588. const dateStr = e.detail.value
  589. this.beginTime = dateStr + ' 00:00:00'
  590. // 自定义时间选择后立即查询
  591. if (this.selectedEmployeeId && this.endTime) {
  592. this.fetchEmployeePortrait()
  593. }
  594. },
  595. onEndTimeChange(e) {
  596. const dateStr = e.detail.value
  597. this.endTime = dateStr + ' 23:59:59'
  598. // 自定义时间选择后立即查询
  599. if (this.selectedEmployeeId && this.beginTime) {
  600. this.fetchEmployeePortrait()
  601. }
  602. },
  603. formatWorkDate(d) {
  604. if (!d) return '-'
  605. const str = String(d)
  606. const parts = str.substring(0, 10).split('-')
  607. if (parts.length < 3) return str
  608. return parts[0] + '.' + Number(parts[1]) + '.' + Number(parts[2])
  609. },
  610. onSearch() {
  611. if (!this.searchKeyword.trim()) return
  612. this.fetchEmployeePortrait()
  613. },
  614. fetchEmployeePortrait() {
  615. const params = {}
  616. if (this.searchKeyword.trim()) {
  617. params.personName = this.searchKeyword.trim()
  618. }
  619. // 添加时间参数
  620. if (this.beginTime) {
  621. params.beginTime = this.beginTime
  622. }
  623. if (this.endTime) {
  624. params.endTime = this.endTime
  625. }
  626. const portraitPromise = getEmployeePortrait(params).then(res => {
  627. if (res.code === 200 && res.data) {
  628. this.portrait = res.data || { dimensions: [], awards: [] }
  629. this.portrait.awards.forEach(item => {
  630. item.color = getRandomHexColor()
  631. })
  632. // 只取数组中最后一个元素的 scoreDetails
  633. const allScoreDetails = res.data.scoreDetails || []
  634. this.scoreDetails = allScoreDetails.length > 0 ? allScoreDetails[allScoreDetails.length - 1] : []
  635. }
  636. }).catch(() => { })
  637. const tagPromise = countTagScore(params).then(res => {
  638. const data = res.data
  639. if (Array.isArray(data)) {
  640. const found = data.find(item => item.userId === this.selectedEmployeeId)
  641. this.tagScoreData = found ? (found.totalScore ?? found.score) : null
  642. } else {
  643. this.tagScoreData = data
  644. }
  645. }).catch(() => { })
  646. Promise.all([portraitPromise, tagPromise]).finally(() => {
  647. this.$nextTick(() => {
  648. this.initRadarChart()
  649. this.initScoreChart()
  650. })
  651. })
  652. },
  653. initScoreChart() {
  654. if (!this.$refs.scoreCircle) return
  655. if (this.scoreChartInstance) {
  656. this.scoreChartInstance.dispose()
  657. }
  658. this.scoreChartInstance = echarts.init(this.$refs.scoreCircle)
  659. const score = this.portrait.totalScore || 0
  660. const option = {
  661. series: [
  662. {
  663. type: 'gauge',
  664. startAngle: 90,
  665. endAngle: -270,
  666. pointer: {
  667. show: false
  668. },
  669. progress: {
  670. show: true,
  671. overlap: false,
  672. roundCap: true,
  673. clip: false,
  674. itemStyle: {
  675. borderWidth: 1,
  676. borderColor: '#464646'
  677. }
  678. },
  679. axisLine: {
  680. lineStyle: {
  681. width: 5,
  682. color: [[1, '#34D399']]
  683. }
  684. },
  685. splitLine: {
  686. show: false,
  687. distance: 0,
  688. length: 10
  689. },
  690. axisTick: {
  691. show: false
  692. },
  693. axisLabel: {
  694. show: false,
  695. distance: 50
  696. },
  697. data: [
  698. {
  699. value: score,
  700. name: '综合得分'
  701. }
  702. ],
  703. title: {
  704. fontSize: 14
  705. },
  706. detail: {
  707. width: 50,
  708. height: 14,
  709. fontSize: 20,
  710. color: 'inherit',
  711. padding: [0, 0, 80, 0],
  712. borderColor: 'inherit',
  713. formatter: '{value}',
  714. rich: {
  715. value: {
  716. fontSize: 14,
  717. color: '#333',
  718. lineHeight: 35,
  719. }
  720. }
  721. }
  722. }
  723. ]
  724. }
  725. this.scoreChartInstance.setOption(option)
  726. },
  727. initRadarChart() {
  728. if (!this.$refs.radarChart) return
  729. if (this.radarChartInstance) {
  730. this.radarChartInstance.dispose()
  731. }
  732. this.radarChartInstance = echarts.init(this.$refs.radarChart)
  733. const dimensions = this.portrait.dimensions || []
  734. const maxScore = dimensions.length > 0 ? Math.max(...dimensions.map(d => d.score || 0)) : 100
  735. const indicator = dimensions.map(d => ({
  736. name: d.name + '\n' + d.score,
  737. max: maxScore
  738. }))
  739. const option = {
  740. radar: {
  741. indicator: indicator,
  742. center: ['50%', '52%'],
  743. radius: '60%',
  744. splitNumber: 8,
  745. axisLine: {
  746. lineStyle: { color: 'rgba(0,0,0,0.15)' }
  747. },
  748. splitLine: {
  749. lineStyle: {
  750. color: ['rgba(0,0,0,0.1)', 'rgba(0,0,0,0.1)', 'rgba(0,0,0,0.1)', 'rgba(0,0,0,0.1)', 'rgba(0,0,0,0.1)', 'rgba(0,0,0,0.1)', '#fe4322', '#8EC742', 'rgba(0,0,0,0.1)']
  751. }
  752. },
  753. splitArea: { show: false },
  754. axisName: {
  755. color: '#333',
  756. fontSize: 12
  757. }
  758. },
  759. series: [{
  760. type: 'radar',
  761. data: [{
  762. name: '个人能力',
  763. value: dimensions.map(d => d.score),
  764. areaStyle: { color: 'rgba(77, 200, 254, 0.2)' },
  765. lineStyle: { color: '#4DC8FE', width: 2 },
  766. itemStyle: {
  767. color: '#333',
  768. borderWidth: 1,
  769. borderColor: '#00C8DA'
  770. },
  771. symbol: 'circle',
  772. symbolSize: 8
  773. }]
  774. }]
  775. }
  776. this.radarChartInstance.setOption(option)
  777. }
  778. }
  779. }
  780. </script>
  781. <style lang="scss" scoped>
  782. .employee-profile-page {
  783. min-height: 100vh;
  784. background: #fff;
  785. padding-bottom: 40rpx;
  786. }
  787. .page-header {
  788. position: sticky;
  789. top: 0;
  790. z-index: 100;
  791. color: black;
  792. background: #fff;
  793. backdrop-filter: blur(10px);
  794. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.2);
  795. }
  796. .header-title {
  797. padding: 24rpx 32rpx;
  798. display: flex;
  799. justify-content: space-between;
  800. align-items: center;
  801. .title-main {
  802. font-size: 36rpx;
  803. font-weight: bold;
  804. color: black;
  805. }
  806. }
  807. .header-right {
  808. display: flex;
  809. align-items: center;
  810. gap: 16rpx;
  811. .current-time {
  812. font-size: 24rpx;
  813. color: #999;
  814. }
  815. }
  816. .time-filter {
  817. padding: 16rpx 32rpx;
  818. background: #fff;
  819. }
  820. .time-scroll {
  821. width: 100%;
  822. }
  823. .time-tags {
  824. display: flex;
  825. gap: 16rpx;
  826. white-space: nowrap;
  827. }
  828. .time-tag {
  829. padding: 8rpx 10rpx;
  830. border-radius: 50rpx;
  831. background: #f0f0f0;
  832. font-size: 24rpx;
  833. color: #666;
  834. transition: all 0.3s;
  835. &.active {
  836. background: #60A5FA;
  837. color: #fff;
  838. font-weight: 500;
  839. }
  840. }
  841. .date-range-picker {
  842. display: flex;
  843. align-items: center;
  844. gap: 16rpx;
  845. margin-top: 16rpx;
  846. padding-top: 16rpx;
  847. border-top: 1rpx solid #e0e0e0;
  848. }
  849. .date-input {
  850. flex: 1;
  851. padding: 12rpx 24rpx;
  852. border-radius: 12rpx;
  853. background: #f5f5f5;
  854. font-size: 24rpx;
  855. color: #999;
  856. text-align: center;
  857. &.filled {
  858. color: #333;
  859. }
  860. }
  861. .date-separator {
  862. font-size: 24rpx;
  863. color: #999;
  864. flex-shrink: 0;
  865. }
  866. .search-selector {
  867. padding: 16rpx 32rpx;
  868. background: #fff;
  869. }
  870. .search-select-trigger {
  871. display: flex;
  872. align-items: center;
  873. justify-content: center;
  874. gap: 12rpx;
  875. padding: 16rpx 24rpx;
  876. background: #f5f5f5;
  877. border: 1rpx solid #e0e0e0;
  878. border-radius: 50rpx;
  879. }
  880. .search-select-trigger-disabled {
  881. opacity: 0.5;
  882. pointer-events: none;
  883. }
  884. .search-name-text {
  885. font-size: 26rpx;
  886. color: #333;
  887. }
  888. .employee-picker {
  889. background: #fff;
  890. display: flex;
  891. flex-direction: column;
  892. border-radius: 16rpx 16rpx 0 0;
  893. width: 100%;
  894. height: 70vh;
  895. }
  896. .picker-header {
  897. padding: 24rpx 32rpx;
  898. border-bottom: 1rpx solid #eee;
  899. display: flex;
  900. justify-content: center;
  901. flex-shrink: 0;
  902. }
  903. .picker-title {
  904. font-size: 32rpx;
  905. font-weight: 600;
  906. color: #333;
  907. }
  908. .search-box {
  909. padding: 16rpx 32rpx;
  910. flex-shrink: 0;
  911. }
  912. .tree-list {
  913. flex: 1;
  914. padding: 0;
  915. height: 0;
  916. overflow: hidden;
  917. }
  918. .employee-list {
  919. flex: 1;
  920. padding: 0 32rpx;
  921. height: 0;
  922. overflow: hidden;
  923. }
  924. .employee-item {
  925. display: flex;
  926. align-items: center;
  927. justify-content: space-between;
  928. padding: 24rpx 0;
  929. border-bottom: 1rpx solid #f0f0f0;
  930. }
  931. .employee-item-name {
  932. font-size: 28rpx;
  933. color: #333;
  934. }
  935. .tab-nav {
  936. padding: 16rpx 32rpx;
  937. display: flex;
  938. justify-content: center;
  939. gap: 64rpx;
  940. }
  941. .tab-item {
  942. font-size: 28rpx;
  943. color: #999;
  944. padding-bottom: 8rpx;
  945. border-bottom: 2rpx solid transparent;
  946. transition: all 0.3s;
  947. &.active {
  948. color: #333;
  949. border-bottom-color: #333;
  950. }
  951. }
  952. .page-content {
  953. padding: 32rpx;
  954. display: flex;
  955. flex-direction: column;
  956. }
  957. .empty-state {
  958. display: flex;
  959. flex-direction: column;
  960. align-items: center;
  961. justify-content: center;
  962. padding: 120rpx 0;
  963. .empty-icon {
  964. font-size: 80rpx;
  965. margin-bottom: 24rpx;
  966. }
  967. .empty-text {
  968. font-size: 28rpx;
  969. color: #999;
  970. }
  971. }
  972. .user-info {
  973. .user-header {
  974. display: flex;
  975. align-items: center;
  976. gap: 32rpx;
  977. margin-bottom: 32rpx;
  978. padding-bottom: 24rpx;
  979. border-bottom: 1rpx solid #e0e0e0;
  980. }
  981. .avatar-area {
  982. width: 120rpx;
  983. height: 120rpx;
  984. border-radius: 50%;
  985. background: #f0f0f0;
  986. display: flex;
  987. align-items: center;
  988. justify-content: center;
  989. flex-shrink: 0;
  990. .avatar {
  991. width: 100%;
  992. height: 100%;
  993. border-radius: 50%;
  994. object-fit: cover;
  995. }
  996. .avatar-placeholder {
  997. font-size: 48rpx;
  998. font-weight: bold;
  999. color: #999;
  1000. }
  1001. }
  1002. .name-row {
  1003. display: flex;
  1004. align-items: baseline;
  1005. .name-label {
  1006. font-size: 26rpx;
  1007. color: #999;
  1008. }
  1009. .name-value {
  1010. font-size: 36rpx;
  1011. font-weight: bold;
  1012. color: #333;
  1013. }
  1014. }
  1015. }
  1016. .info-grid {
  1017. display: grid;
  1018. grid-template-columns: 1fr 1fr;
  1019. gap: 20rpx;
  1020. margin-bottom: 32rpx;
  1021. .info-item {
  1022. .info-label {
  1023. font-size: 22rpx;
  1024. color: #999;
  1025. margin-bottom: 4rpx;
  1026. }
  1027. .info-value {
  1028. font-size: 26rpx;
  1029. color: #333;
  1030. .tag {
  1031. display: inline-block;
  1032. padding: 4rpx 16rpx;
  1033. margin-left: 2rpx;
  1034. background: #f0f0f0;
  1035. border-radius: 8rpx;
  1036. color: #333;
  1037. font-size: 22rpx;
  1038. }
  1039. }
  1040. }
  1041. }
  1042. .score-section {
  1043. display: flex;
  1044. align-items: center;
  1045. justify-content: center;
  1046. gap: 48rpx;
  1047. padding-top: 24rpx;
  1048. border-top: 1rpx solid #e0e0e0;
  1049. .score-circle {
  1050. width: 280rpx;
  1051. height: 280rpx;
  1052. }
  1053. .score-box {
  1054. .score-row {
  1055. display: flex;
  1056. align-items: center;
  1057. margin-bottom: 16rpx;
  1058. .score-label {
  1059. font-size: 26rpx;
  1060. color: #999;
  1061. }
  1062. .score-val {
  1063. font-size: 32rpx;
  1064. font-weight: bold;
  1065. color: #333;
  1066. }
  1067. }
  1068. }
  1069. }
  1070. .work-history {
  1071. font-size: 26rpx;
  1072. color: #555;
  1073. line-height: 1.8;
  1074. }
  1075. .honor-list {
  1076. display: flex;
  1077. flex-direction: column;
  1078. gap: 16rpx;
  1079. .honor-item {
  1080. display: flex;
  1081. justify-content: space-between;
  1082. align-items: center;
  1083. padding: 16rpx;
  1084. background: #f5f5f5;
  1085. border-radius: 12rpx;
  1086. .honor-name {
  1087. display: flex;
  1088. align-items: center;
  1089. gap: 12rpx;
  1090. font-size: 26rpx;
  1091. color: #333;
  1092. flex: 1;
  1093. .honor-dot {
  1094. width: 12rpx;
  1095. height: 12rpx;
  1096. border-radius: 50%;
  1097. flex-shrink: 0;
  1098. }
  1099. }
  1100. .honor-score {
  1101. font-size: 26rpx;
  1102. color: #A78BFA;
  1103. font-weight: 500;
  1104. flex-shrink: 0;
  1105. }
  1106. }
  1107. .no-data {
  1108. font-size: 26rpx;
  1109. color: #999;
  1110. text-align: center;
  1111. padding: 24rpx 0;
  1112. }
  1113. }
  1114. .chart-container {
  1115. width: 100%;
  1116. height: 500rpx;
  1117. }
  1118. .supp-grid {
  1119. display: grid;
  1120. grid-template-columns: 1fr 1fr;
  1121. gap: 20rpx;
  1122. .supp-item {
  1123. .supp-label {
  1124. font-size: 22rpx;
  1125. color: #666;
  1126. margin-bottom: 4rpx;
  1127. display: block;
  1128. }
  1129. .supp-value {
  1130. font-size: 26rpx;
  1131. color: #333;
  1132. }
  1133. }
  1134. }
  1135. .warning-content {
  1136. padding: 32rpx;
  1137. text-align: center;
  1138. cursor: pointer;
  1139. .warning-tip {
  1140. font-size: 26rpx;
  1141. color: #666;
  1142. }
  1143. }
  1144. .warning-overlay {
  1145. position: fixed;
  1146. top: 0;
  1147. left: 0;
  1148. right: 0;
  1149. bottom: 0;
  1150. background: rgba(0, 0, 0, 0.7);
  1151. z-index: 200;
  1152. display: flex;
  1153. align-items: center;
  1154. justify-content: center;
  1155. padding: 48rpx;
  1156. }
  1157. .warning-panel {
  1158. width: 100%;
  1159. max-height: 80vh;
  1160. background: #fff;
  1161. border-radius: 24rpx;
  1162. border: 1rpx solid #e0e0e0;
  1163. overflow: hidden;
  1164. display: flex;
  1165. flex-direction: column;
  1166. }
  1167. .warning-header {
  1168. display: flex;
  1169. justify-content: space-between;
  1170. align-items: center;
  1171. padding: 32rpx;
  1172. border-bottom: 1rpx solid #eee;
  1173. .warning-title {
  1174. font-size: 32rpx;
  1175. font-weight: bold;
  1176. color: #333;
  1177. }
  1178. .warning-close {
  1179. width: 48rpx;
  1180. height: 48rpx;
  1181. display: flex;
  1182. align-items: center;
  1183. justify-content: center;
  1184. font-size: 32rpx;
  1185. color: #999;
  1186. border-radius: 50%;
  1187. background: #f0f0f0;
  1188. }
  1189. }
  1190. .warning-body {
  1191. padding: 32rpx;
  1192. overflow-y: auto;
  1193. }
  1194. .warning-desc {
  1195. font-size: 24rpx;
  1196. color: #666;
  1197. margin-bottom: 32rpx;
  1198. }
  1199. .warning-score {
  1200. margin-bottom: 32rpx;
  1201. .warning-score-item {
  1202. display: flex;
  1203. justify-content: space-between;
  1204. align-items: center;
  1205. padding: 24rpx;
  1206. background: #f5f5f5;
  1207. border-radius: 16rpx;
  1208. .warning-score-label {
  1209. font-size: 28rpx;
  1210. color: #333;
  1211. }
  1212. .warning-score-value {
  1213. font-size: 40rpx;
  1214. font-weight: bold;
  1215. &.score-danger {
  1216. color: #EF4444;
  1217. }
  1218. &.score-excellent {
  1219. color: #34D399;
  1220. }
  1221. color: #60A5FA;
  1222. }
  1223. }
  1224. }
  1225. .warning-detail {
  1226. .warning-detail-title {
  1227. font-size: 28rpx;
  1228. color: #333;
  1229. margin-bottom: 20rpx;
  1230. font-weight: 500;
  1231. }
  1232. .warning-detail-item {
  1233. display: flex;
  1234. justify-content: space-between;
  1235. align-items: center;
  1236. padding: 16rpx 0;
  1237. border-bottom: 1rpx solid #f0f0f0;
  1238. .detail-left {
  1239. display: flex;
  1240. flex-direction: column;
  1241. gap: 4rpx;
  1242. .detail-dim {
  1243. font-size: 22rpx;
  1244. color: #999;
  1245. }
  1246. .detail-name {
  1247. font-size: 26rpx;
  1248. color: #333;
  1249. }
  1250. }
  1251. .detail-score {
  1252. font-size: 28rpx;
  1253. font-weight: 500;
  1254. &.add-text {
  1255. color: #34D399;
  1256. }
  1257. &.deduct-text {
  1258. color: #EF4444;
  1259. }
  1260. }
  1261. }
  1262. }
  1263. </style>