index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. <template>
  2. <main class="home-dashboard">
  3. <section class="metric-grid" aria-label="核心指标">
  4. <button
  5. v-for="item in dashboard.metrics"
  6. :key="item.key"
  7. type="button"
  8. class="metric-card"
  9. :class="`metric-card--${item.tone}`"
  10. @click="showMetric(item)"
  11. >
  12. <span class="metric-icon"><i :class="item.icon"></i></span>
  13. <span class="metric-main">
  14. <span class="metric-label">{{ item.label }}</span>
  15. <span class="metric-number"
  16. ><strong>{{ item.value.toLocaleString() }}</strong
  17. ><em>{{ item.unit }}</em></span
  18. >
  19. <span class="metric-note">{{ item.note }}</span>
  20. </span>
  21. <span class="metric-trend">{{ item.trend }}</span>
  22. </button>
  23. </section>
  24. <section class="content-grid">
  25. <article class="panel flow-panel">
  26. <div class="section-heading">
  27. <div>
  28. <h2>人员流动趋势</h2>
  29. <p>近 7 个月入职与离职人数变化</p>
  30. </div>
  31. <div class="chart-legend" aria-label="图例">
  32. <span><i class="onboard-dot"></i>入职人数</span
  33. ><span><i class="offboard-dot"></i>离职人数</span>
  34. </div>
  35. </div>
  36. <div ref="flowChart" class="chart flow-chart"></div>
  37. </article>
  38. <article class="panel staffing-panel">
  39. <div class="section-heading">
  40. <div>
  41. <h2>部门编制占比</h2>
  42. <p>各业务单元在岗编制结构</p>
  43. </div>
  44. <button
  45. type="button"
  46. class="text-button"
  47. @click="$router.push('/personnel-structure-dashboard')"
  48. >
  49. 查看看板 <i class="el-icon-arrow-right"></i>
  50. </button>
  51. </div>
  52. <div ref="staffingChart" class="chart staffing-chart"></div>
  53. </article>
  54. <article class="panel todo-panel">
  55. <div class="section-heading">
  56. <div>
  57. <h2>紧急待办</h2>
  58. <p>优先处理即将超期事项</p>
  59. </div>
  60. <el-badge :value="totalTodoCount" class="todo-badge"
  61. ><i class="el-icon-bell"></i
  62. ></el-badge>
  63. </div>
  64. <div class="todo-list">
  65. <button
  66. v-for="item in dashboard.todos"
  67. :key="item.id"
  68. type="button"
  69. class="todo-item"
  70. @click="openTodo(item)"
  71. >
  72. <span class="todo-icon" :class="`todo-icon--${item.level}`"
  73. ><i :class="item.icon"></i
  74. ></span>
  75. <span class="todo-content"
  76. ><strong>{{ item.title }}</strong
  77. ><small>{{ item.deadline }} · {{ item.owner }}</small></span
  78. >
  79. <span class="todo-count">{{ item.count }}</span>
  80. <i class="el-icon-arrow-right todo-arrow"></i>
  81. </button>
  82. </div>
  83. <button type="button" class="todo-footer" @click="showAllTodos">
  84. 查看全部待办 <i class="el-icon-arrow-right"></i>
  85. </button>
  86. </article>
  87. <article class="panel workforce-panel">
  88. <div class="section-heading">
  89. <div>
  90. <h2>人员结构快照</h2>
  91. <p>员工类型与关键结构指标</p>
  92. </div>
  93. <span class="panel-chip panel-chip--green">在岗率 96.4%</span>
  94. </div>
  95. <div class="workforce-body">
  96. <div class="workforce-distribution">
  97. <div>
  98. <span>员工类型分布</span><strong>1,286<small>人</small></strong>
  99. </div>
  100. <div class="workforce-stack" aria-label="员工类型分布">
  101. <i
  102. v-for="item in dashboard.workforce"
  103. :key="item.label"
  104. :class="`stack-${item.tone}`"
  105. :style="{ width: `${item.rate}%` }"
  106. ></i>
  107. </div>
  108. </div>
  109. <div class="workforce-list">
  110. <div
  111. v-for="item in dashboard.workforce"
  112. :key="item.label"
  113. class="workforce-item"
  114. :class="`workforce-item--${item.tone}`"
  115. >
  116. <i class="workforce-dot"></i>
  117. <div class="workforce-copy">
  118. <span>{{ item.label }}</span
  119. ><strong
  120. >{{ item.value.toLocaleString() }}<small>人</small></strong
  121. >
  122. </div>
  123. <em>{{ item.rate }}%</em>
  124. </div>
  125. </div>
  126. <div class="workforce-summary">
  127. <div v-for="item in dashboard.workforceSummary" :key="item.label">
  128. <span>{{ item.label }}</span
  129. ><strong
  130. >{{ item.value }}<small>{{ item.unit }}</small></strong
  131. >
  132. </div>
  133. </div>
  134. </div>
  135. </article>
  136. <article class="panel movement-panel">
  137. <div class="section-heading">
  138. <div>
  139. <h2>本月人事动态</h2>
  140. <p>入转调离业务办理概况</p>
  141. </div>
  142. <span class="panel-chip">本月</span>
  143. </div>
  144. <div class="movement-summary">
  145. <div>
  146. <span>本月累计变动</span
  147. ><strong
  148. >{{ dashboard.movementSummary.total }}<small>人次</small></strong
  149. >
  150. </div>
  151. <span
  152. ><i class="el-icon-top-right"></i> 净增
  153. {{ dashboard.movementSummary.net }} 人</span
  154. >
  155. <em>环比 +{{ dashboard.movementSummary.monthRate }}%</em>
  156. </div>
  157. <div class="movement-grid">
  158. <div
  159. v-for="item in dashboard.movements"
  160. :key="item.label"
  161. class="movement-item"
  162. :class="`movement-item--${item.tone}`"
  163. >
  164. <span class="movement-icon"><i :class="item.icon"></i></span>
  165. <div>
  166. <span>{{ item.label }}</span
  167. ><strong>{{ item.value }}<small>人</small></strong
  168. ><em>{{ item.note }}</em>
  169. </div>
  170. </div>
  171. </div>
  172. </article>
  173. <article class="panel efficiency-panel">
  174. <div class="section-heading">
  175. <div>
  176. <h2>待办处理效率</h2>
  177. <p>本周审批处理质量</p>
  178. </div>
  179. <span class="panel-chip panel-chip--green">运行正常</span>
  180. </div>
  181. <div class="efficiency-body">
  182. <div class="efficiency-ring">
  183. <el-progress
  184. type="circle"
  185. :percentage="dashboard.efficiency.completionRate"
  186. :width="92"
  187. :stroke-width="8"
  188. color="#20a87c"
  189. />
  190. <span>本周完成率</span>
  191. </div>
  192. <div class="efficiency-stats">
  193. <div>
  194. <span>已处理</span
  195. ><strong>{{ dashboard.efficiency.handled }}</strong>
  196. </div>
  197. <div>
  198. <span>处理中</span
  199. ><strong>{{ dashboard.efficiency.pending }}</strong>
  200. </div>
  201. <div class="danger">
  202. <span>已逾期</span
  203. ><strong>{{ dashboard.efficiency.overdue }}</strong>
  204. </div>
  205. </div>
  206. </div>
  207. <div class="efficiency-meters">
  208. <div>
  209. <span
  210. >按时完成率<strong
  211. >{{ dashboard.efficiency.approvalRate }}%</strong
  212. ></span
  213. >
  214. <el-progress
  215. :percentage="dashboard.efficiency.approvalRate"
  216. :stroke-width="5"
  217. :show-text="false"
  218. color="#3478f6"
  219. />
  220. </div>
  221. <div>
  222. <span
  223. >一次通过率<strong
  224. >{{ dashboard.efficiency.firstPassRate }}%</strong
  225. ></span
  226. >
  227. <el-progress
  228. :percentage="dashboard.efficiency.firstPassRate"
  229. :stroke-width="5"
  230. :show-text="false"
  231. color="#8068dc"
  232. />
  233. </div>
  234. </div>
  235. <div class="efficiency-footer">
  236. <span
  237. >平均处理时长
  238. <strong>{{ dashboard.efficiency.averageDuration }} 天</strong></span
  239. >
  240. <span class="duration-trend"
  241. ><i class="el-icon-bottom"></i>
  242. {{ dashboard.efficiency.durationTrend }}</span
  243. >
  244. </div>
  245. </article>
  246. </section>
  247. <el-dialog
  248. :title="dialogTitle"
  249. :visible.sync="dialogVisible"
  250. width="520px"
  251. append-to-body
  252. custom-class="home-detail-dialog"
  253. >
  254. <div v-if="dialogData" class="dialog-detail">
  255. <span class="dialog-detail__icon"
  256. ><i :class="dialogData.icon || 'el-icon-bell'"></i
  257. ></span>
  258. <div>
  259. <small>{{
  260. dialogData.category || dialogData.owner || "人力资源工作台"
  261. }}</small>
  262. <h3>{{ dialogData.title || dialogData.label }}</h3>
  263. <p>
  264. {{
  265. dialogData.detail ||
  266. dialogData.note ||
  267. "该事项当前使用模拟数据展示,后续接入业务接口后可查看完整办理记录。"
  268. }}
  269. </p>
  270. </div>
  271. </div>
  272. <span slot="footer">
  273. <el-button @click="dialogVisible = false">关闭</el-button>
  274. <el-button type="primary" @click="handleDialogConfirm"
  275. >立即处理</el-button
  276. >
  277. </span>
  278. </el-dialog>
  279. </main>
  280. </template>
  281. <script>
  282. import * as echarts from "echarts";
  283. import { dashboardMock } from "./mock";
  284. export default {
  285. name: "HomeView",
  286. data() {
  287. return {
  288. dashboard: dashboardMock,
  289. dialogVisible: false,
  290. dialogTitle: "事项详情",
  291. dialogData: null,
  292. charts: {},
  293. resizeObserver: null,
  294. chartResizeFrame: null,
  295. chartSizeSignature: "",
  296. };
  297. },
  298. computed: {
  299. totalTodoCount() {
  300. return this.dashboard.todos.reduce((sum, item) => sum + item.count, 0);
  301. },
  302. },
  303. mounted() {
  304. this.$nextTick(() => {
  305. this.initCharts();
  306. this.observeResize();
  307. });
  308. },
  309. beforeDestroy() {
  310. cancelAnimationFrame(this.chartResizeFrame);
  311. if (this.resizeObserver) this.resizeObserver.disconnect();
  312. window.removeEventListener("resize", this.resizeCharts);
  313. Object.values(this.charts).forEach((chart) => chart && chart.dispose());
  314. },
  315. methods: {
  316. initCharts() {
  317. this.charts.flow = echarts.init(this.$refs.flowChart);
  318. this.charts.staffing = echarts.init(this.$refs.staffingChart);
  319. this.renderCharts();
  320. },
  321. observeResize() {
  322. if (window.ResizeObserver) {
  323. this.resizeObserver = new ResizeObserver((entries) => {
  324. const signature = entries
  325. .map(
  326. (entry) =>
  327. `${Math.round(entry.contentRect.width)}x${Math.round(
  328. entry.contentRect.height,
  329. )}`,
  330. )
  331. .join("|");
  332. if (signature === this.chartSizeSignature) return;
  333. this.chartSizeSignature = signature;
  334. cancelAnimationFrame(this.chartResizeFrame);
  335. this.chartResizeFrame = requestAnimationFrame(this.resizeCharts);
  336. });
  337. this.resizeObserver.observe(this.$refs.flowChart);
  338. this.resizeObserver.observe(this.$refs.staffingChart);
  339. } else {
  340. window.addEventListener("resize", this.resizeCharts);
  341. }
  342. },
  343. resizeCharts() {
  344. Object.values(this.charts).forEach((chart) => chart && chart.resize());
  345. },
  346. renderCharts() {
  347. this.renderFlowChart();
  348. this.renderStaffingChart();
  349. },
  350. tooltipStyle() {
  351. return {
  352. backgroundColor: "rgba(35, 45, 61, .94)",
  353. borderWidth: 0,
  354. padding: [9, 12],
  355. textStyle: { color: "#fff", fontSize: 12 },
  356. extraCssText:
  357. "border-radius:6px;box-shadow:0 10px 24px rgba(22,34,52,.18)",
  358. };
  359. },
  360. renderFlowChart() {
  361. this.charts.flow.setOption(
  362. {
  363. animationDuration: 650,
  364. tooltip: {
  365. trigger: "axis",
  366. axisPointer: { type: "shadow" },
  367. ...this.tooltipStyle(),
  368. },
  369. grid: { top: 22, right: 18, bottom: 30, left: 42 },
  370. xAxis: {
  371. type: "category",
  372. data: this.dashboard.flow.months,
  373. axisLine: { lineStyle: { color: "#dfe5ec" } },
  374. axisTick: { show: false },
  375. axisLabel: { color: "#8490a3", fontSize: 11 },
  376. },
  377. yAxis: {
  378. type: "value",
  379. axisLine: { show: false },
  380. axisTick: { show: false },
  381. axisLabel: { color: "#9aa4b2", fontSize: 10 },
  382. splitLine: { lineStyle: { color: "#edf0f4", type: "dashed" } },
  383. },
  384. series: [
  385. {
  386. name: "入职人数",
  387. type: "bar",
  388. data: this.dashboard.flow.onboard,
  389. barMaxWidth: 24,
  390. itemStyle: { color: "#3478f6", borderRadius: [4, 4, 0, 0] },
  391. emphasis: { itemStyle: { color: "#1f65df" } },
  392. },
  393. {
  394. name: "离职人数",
  395. type: "bar",
  396. data: this.dashboard.flow.offboard,
  397. barMaxWidth: 24,
  398. itemStyle: { color: "#f3a53b", borderRadius: [4, 4, 0, 0] },
  399. emphasis: { itemStyle: { color: "#e18a16" } },
  400. },
  401. ],
  402. },
  403. true,
  404. );
  405. },
  406. renderStaffingChart() {
  407. const data = this.dashboard.staffing.map((item) => ({
  408. ...item,
  409. itemStyle: { color: item.color },
  410. }));
  411. this.charts.staffing.setOption(
  412. {
  413. animationDuration: 700,
  414. tooltip: {
  415. trigger: "item",
  416. formatter: "{b}<br/>编制占比:<b>{d}%</b>",
  417. ...this.tooltipStyle(),
  418. },
  419. legend: {
  420. orient: "horizontal",
  421. left: 18,
  422. right: 18,
  423. bottom: 12,
  424. itemWidth: 8,
  425. itemHeight: 8,
  426. itemGap: 10,
  427. icon: "circle",
  428. textStyle: { color: "#647084", fontSize: 11 },
  429. formatter: (name) => {
  430. const item = this.dashboard.staffing.find(
  431. (row) => row.name === name,
  432. );
  433. return `${name} ${item?.value || 0}%`;
  434. },
  435. },
  436. series: [
  437. {
  438. type: "pie",
  439. radius: ["39%", "59%"],
  440. center: ["50%", "40%"],
  441. avoidLabelOverlap: true,
  442. itemStyle: { borderColor: "#fff", borderWidth: 3 },
  443. label: { show: false },
  444. emphasis: { scale: true, scaleSize: 5 },
  445. data,
  446. },
  447. ],
  448. graphic: [
  449. {
  450. type: "text",
  451. left: "center",
  452. top: "33%",
  453. style: { text: "编制使用率", fill: "#8a95a5", fontSize: 11 },
  454. },
  455. {
  456. type: "text",
  457. left: "center",
  458. top: "42%",
  459. style: {
  460. text: "94.6%",
  461. fill: "#263244",
  462. fontSize: 22,
  463. fontWeight: 600,
  464. },
  465. },
  466. ],
  467. },
  468. true,
  469. );
  470. },
  471. showMetric(item) {
  472. this.dialogTitle = `${item.label}概览`;
  473. this.dialogData = {
  474. ...item,
  475. title: `${item.value.toLocaleString()} ${item.unit}`,
  476. category: item.label,
  477. };
  478. this.dialogVisible = true;
  479. },
  480. openTodo(item) {
  481. this.dialogTitle = "待办事项";
  482. this.dialogData = {
  483. ...item,
  484. detail: `${item.deadline},当前共有 ${item.count} 条待处理记录。请进入业务页面完成审核或办理。`,
  485. };
  486. this.dialogVisible = true;
  487. },
  488. handleDialogConfirm() {
  489. this.dialogVisible = false;
  490. this.$router.push("/employee-archive");
  491. },
  492. showAllTodos() {
  493. this.$message.info("待办中心接口暂未接入,当前展示模拟待办");
  494. },
  495. },
  496. };
  497. </script>
  498. <style src="../../styles/views/HomeView.scss" scoped lang="scss"></style>