index.vue 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442
  1. <template>
  2. <div class="app-container">
  3. <!-- 查询条件 -->
  4. <div class="filter-section">
  5. <el-card>
  6. <div class="filter-container">
  7. <el-form :model="queryParams" ref="queryFormRef" :inline="true" class="search-form">
  8. <el-form-item label="考核月份" prop="assessmentMonth">
  9. <el-date-picker v-model="queryParams.assessmentMonth" type="month" placeholder="请选择考核月份"
  10. value-format="YYYY-MM" style="width: 200px" />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="Search" @click="handleQuery">查询</el-button>
  14. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <div class="export-button">
  18. <el-button type="warning" icon="Document" @click="handleExport">导出文档</el-button>
  19. </div>
  20. </div>
  21. </el-card>
  22. </div>
  23. <!-- 非干部月度考核分数汇总 -->
  24. <div class="main-section">
  25. <h2 class="section-title">非干部月度考核分数汇总</h2>
  26. <!-- 第一行:两个区块 -->
  27. <div class="chart-row">
  28. <!-- 整体分值分布柱状图 -->
  29. <el-card class="chart-card">
  30. <div class="chart-header">整体分值分布柱状图</div>
  31. <div ref="overallBarChart" class="chart-container"></div>
  32. </el-card>
  33. <!-- 参与人数占比饼图 -->
  34. <el-card class="chart-card">
  35. <div class="chart-header">参与人数占比饼图</div>
  36. <div ref="participantPieChart" class="chart-container"></div>
  37. </el-card>
  38. </div>
  39. <!-- 第二行:两个区块 -->
  40. <div class="chart-row">
  41. <!-- 各部门分值分布对比图 -->
  42. <el-card class="chart-card">
  43. <div class="chart-header">各部门分值分布对比图</div>
  44. <div ref="departmentComparisonChart" class="chart-container"></div>
  45. </el-card>
  46. <!-- 汇总表 -->
  47. <el-card class="chart-card">
  48. <div class="chart-header">汇总表</div>
  49. <el-table :data="summaryTableData" border style="width: 100%; margin-top: 10px;">
  50. <el-table-column prop="rangeLabel" label="区间" align="center" min-width="100" />
  51. <el-table-column prop="totalCount" :label="summaryTableTitle" align="center" min-width="150" />
  52. <el-table-column v-for="col in summaryTableColumns" :key="col.deptId" :prop="'team' + col.deptId"
  53. :label="col.deptName" align="center" min-width="100" />
  54. </el-table>
  55. </el-card>
  56. </div>
  57. </div>
  58. <!-- 非干部月度考核分类结果汇总 -->
  59. <div class="main-section">
  60. <h2 class="section-title">非干部月度考核分类结果汇总</h2>
  61. <!-- 汇总统计表格 -->
  62. <el-card class="summary-table-card">
  63. <div class="chart-header">汇总统计</div>
  64. <el-table :data="classificationTableData" border style="width: 100%; margin-top: 10px;">
  65. <el-table-column prop="assessmentTeamCount" label="考核组人数" align="center" min-width="120" />
  66. <el-table-column prop="estimatedImprovementCount" label="测算待改进人数" align="center" min-width="140" />
  67. <el-table-column prop="improvementTotalCount" label="待改进总人数" align="center" min-width="120" />
  68. <el-table-column prop="improvementExemptedCount" label="待改进豁免" align="center" min-width="100" />
  69. <el-table-column prop="actualImprovementCount" label="实际待改进总人数" align="center" min-width="140" />
  70. <el-table-column prop="incompetentTotalCount" label="不称职总人数" align="center" min-width="120" />
  71. <el-table-column prop="incompetentExemptedCount" label="不称职豁免" align="center" min-width="100" />
  72. <el-table-column prop="actualIncompetentCount" label="实际不称职人数" align="center" min-width="140" />
  73. </el-table>
  74. </el-card>
  75. <!-- 第四行:两个区块 -->
  76. <div class="chart-row">
  77. <!-- 大队分布统计图 -->
  78. <el-card class="chart-card">
  79. <div class="chart-header">大队分布统计图</div>
  80. <div class="pie-charts-container">
  81. <div ref="brigadePieChart1" class="pie-chart"></div>
  82. <div ref="brigadePieChart2" class="pie-chart"></div>
  83. </div>
  84. </el-card>
  85. <!-- 岗位分布统计图 -->
  86. <el-card class="chart-card">
  87. <div class="chart-header">岗位分布统计图</div>
  88. <div class="pie-charts-container">
  89. <div ref="positionPieChart1" class="pie-chart"></div>
  90. <div ref="positionPieChart2" class="pie-chart"></div>
  91. </div>
  92. </el-card>
  93. </div>
  94. </div>
  95. <!-- 第一个遍历:表格和两个饼状图 -->
  96. <div class="traversal-section">
  97. <div v-for="(item, index) in traversalData1" :key="index" class="traversal-container">
  98. <div class="traversal-header">{{ item.title }}</div>
  99. <div class="traversal-content">
  100. <!-- 左边表格 -->
  101. <div class="table-section">
  102. <el-table :data="item.tableData" border style="width: 100%;">
  103. <el-table-column prop="assessmentTeam" label="考核组" align="center" min-width="100" />
  104. <el-table-column prop="assessmentTeamCount" label="考核组人数" align="center" min-width="120" />
  105. <el-table-column prop="estimatedImprovementCount" label="测算待改进人数" align="center" min-width="140" />
  106. <el-table-column prop="improvementTotalCount" label="待改进总人数" align="center" min-width="120" />
  107. <el-table-column prop="improvementExemptedCount" label="待改进豁免人数" align="center" min-width="140" />
  108. <el-table-column prop="actualImprovementCount" label="实际待改进人数" align="center" min-width="140" />
  109. <el-table-column prop="incompetentTotalCount" label="不称职总人数" align="center" min-width="120" />
  110. <el-table-column prop="incompetentExemptedCount" label="不称职豁免人数" align="center" min-width="140" />
  111. <el-table-column prop="actualIncompetentCount" label="实际不称职人数" align="center" min-width="140" />
  112. </el-table>
  113. </div>
  114. <!-- 右边两个饼状图 -->
  115. <div class="chart-section">
  116. <div class="pie-chart-container">
  117. <div class="pie-chart-title">{{ item.title }}实际待改进人数分布</div>
  118. <div :ref="el => setTraversalChartRef(el, `pieChart1_${index}`)" class="pie-chart"></div>
  119. </div>
  120. <div class="pie-chart-container">
  121. <div class="pie-chart-title">{{ item.title }}实际不称职人数分布</div>
  122. <div :ref="el => setTraversalChartRef(el, `pieChart2_${index}`)" class="pie-chart"></div>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. <!-- 第二个遍历:表格、柱状图和饼状图 -->
  129. <div class="traversal-section">
  130. <div v-for="(item, index) in traversalData2" :key="index" class="traversal-container">
  131. <div class="traversal-header">{{ item.title }}</div>
  132. <div class="traversal-content">
  133. <!-- 左边表格 -->
  134. <div class="table-section">
  135. <el-table :data="item.tableData" border style="width: 100%;">
  136. <el-table-column prop="brigade" label="大队" align="center" min-width="100" />
  137. <el-table-column prop="assessmentGroup" label="考核组" align="center" min-width="100" />
  138. <el-table-column prop="groupCount" label="考核组人数" align="center" min-width="120" />
  139. <el-table-column prop="calculatedImprovement" label="测算待改进人数" align="center" min-width="140" />
  140. <el-table-column prop="improvementCount" label="待改进人数" align="center" min-width="120" />
  141. <el-table-column prop="exemption1" label="豁免" align="center" min-width="80" />
  142. <el-table-column prop="actualImprovement" label="实际待改进人数" align="center" min-width="140" />
  143. <el-table-column prop="unqualifiedCount" label="不称职人数" align="center" min-width="120" />
  144. <el-table-column prop="exemption2" label="豁免" align="center" min-width="80" />
  145. <el-table-column prop="actualUnqualified" label="实际不称职人数" align="center" min-width="140" />
  146. </el-table>
  147. </div>
  148. <!-- 右边柱状图和饼状图 -->
  149. <div class="chart-section">
  150. <div class="bar-chart-container">
  151. <div class="chart-title">考核分数分布</div>
  152. <div :ref="el => setTraversalChartRef(el, `barChart_${index}`)" class="bar-chart"></div>
  153. </div>
  154. <div class="pie-chart-container">
  155. <div class="pie-chart-title">岗位分布</div>
  156. <div :ref="el => setTraversalChartRef(el, `pieChart3_${index}`)" class="pie-chart"></div>
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. </template>
  164. <script setup>
  165. import { ref, reactive, onMounted, onUnmounted, nextTick, computed } from 'vue'
  166. import { ElMessage, ElLoading } from 'element-plus'
  167. import * as echarts from 'echarts'
  168. import html2canvas from 'html2canvas'
  169. import { Document, Packer, Paragraph, ImageRun, HeadingLevel, AlignmentType } from 'docx'
  170. import { saveAs } from 'file-saver'
  171. // API导入
  172. import {
  173. getScoreDistribution,
  174. getDeptParticipation,
  175. getDeptScoreDistribution,
  176. getAssessmentSummary,
  177. getActualImprovementDistribution,
  178. getActualIncompetentDistribution,
  179. getAssessmentTeamImprovementDistribution,
  180. getAssessmentTeamIncompetentDistribution,
  181. getDeptAssessmentTeamStatistics,
  182. getBrigadeImprovementDistribution,
  183. getBrigadeIncompetentDistribution,
  184. getFunctionalDeptSummary,
  185. getFunctionalDeptPersonnelDistribution,
  186. getFunctionalDeptDistributionPie
  187. } from '@/api/performance/monthlyAssessSum.js'
  188. import { listDept } from '@/api/system/dept.js'
  189. // 响应式数据
  190. const loading = ref(false)
  191. const queryFormRef = ref()
  192. // 查询参数
  193. const currentMonth = `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, '0')}`
  194. const queryParams = reactive({
  195. assessmentMonth: currentMonth
  196. })
  197. const summaryTableTitle = computed(() => {
  198. if (queryParams.assessmentMonth) {
  199. const [year, month] = queryParams.assessmentMonth.split('-')
  200. return `${year}年${parseInt(month)}月模拟分数汇总`
  201. }
  202. return '模拟分数汇总'
  203. })
  204. // 图表引用
  205. const overallBarChart = ref(null)
  206. const participantPieChart = ref(null)
  207. const departmentComparisonChart = ref(null)
  208. const brigadePieChart1 = ref(null)
  209. const brigadePieChart2 = ref(null)
  210. const positionPieChart1 = ref(null)
  211. const positionPieChart2 = ref(null)
  212. // 遍历图表引用
  213. const traversalChartsRefs = ref({})
  214. // 表格数据
  215. const summaryTableData = ref([])
  216. const summaryTableColumns = ref([])
  217. const classificationTableData = ref([
  218. ])
  219. // 遍历数据
  220. const traversalData1 = ref([
  221. ])
  222. const traversalData2 = ref([
  223. ])
  224. // 图表实例
  225. let overallBarChartInstance = null
  226. let participantPieChartInstance = null
  227. let departmentComparisonChartInstance = null
  228. let brigadePieChart1Instance = null
  229. let brigadePieChart2Instance = null
  230. let positionPieChart1Instance = null
  231. let positionPieChart2Instance = null
  232. // 初始化图表
  233. const initCharts = () => {
  234. nextTick(() => {
  235. // 整体分值分布柱状图
  236. if (overallBarChart.value) {
  237. overallBarChartInstance = echarts.init(overallBarChart.value)
  238. overallBarChartInstance.setOption({
  239. tooltip: { trigger: 'axis' },
  240. xAxis: { type: 'category', data: ['90-100分', '80-89分', '70-79分', '60-69分', '60分以下'] },
  241. yAxis: { type: 'value' },
  242. series: [{ type: 'bar', data: [85, 120, 95, 60, 20], itemStyle: { color: '#3b82f6' } }]
  243. })
  244. }
  245. // 参与人数占比饼图
  246. if (participantPieChart.value) {
  247. participantPieChartInstance = echarts.init(participantPieChart.value)
  248. participantPieChartInstance.setOption({
  249. tooltip: { trigger: 'item' },
  250. series: [{
  251. type: 'pie',
  252. radius: '70%',
  253. data: [
  254. { value: 380, name: '参与考核' },
  255. { value: 20, name: '未参与考核' }
  256. ]
  257. }]
  258. })
  259. }
  260. // 各部门分值分布对比图
  261. if (departmentComparisonChart.value) {
  262. departmentComparisonChartInstance = echarts.init(departmentComparisonChart.value)
  263. departmentComparisonChartInstance.setOption({
  264. tooltip: { trigger: 'axis' },
  265. legend: { data: ['一队', '二队', '三队'] },
  266. xAxis: { type: 'category', data: ['90-100分', '80-89分', '70-79分', '60-69分', '60分以下'] },
  267. yAxis: { type: 'value' },
  268. series: [
  269. { name: '一队', type: 'bar', data: [15, 30, 25, 15, 5] },
  270. { name: '二队', type: 'bar', data: [20, 35, 30, 20, 8] },
  271. { name: '三队', type: 'bar', data: [25, 40, 35, 25, 7] }
  272. ]
  273. })
  274. }
  275. // 大队分布饼图1
  276. if (brigadePieChart1.value) {
  277. brigadePieChart1Instance = echarts.init(brigadePieChart1.value)
  278. brigadePieChart1Instance.setOption({
  279. tooltip: { trigger: 'item' },
  280. series: [{
  281. type: 'pie',
  282. radius: '70%',
  283. data: [
  284. { value: 120, name: '一队' },
  285. { value: 150, name: '二队' },
  286. { value: 130, name: '三队' }
  287. ]
  288. }]
  289. })
  290. }
  291. // 大队分布饼图2
  292. if (brigadePieChart2.value) {
  293. brigadePieChart2Instance = echarts.init(brigadePieChart2.value)
  294. brigadePieChart2Instance.setOption({
  295. tooltip: { trigger: 'item' },
  296. series: [{
  297. type: 'pie',
  298. radius: '70%',
  299. data: [
  300. { value: 45, name: '优秀' },
  301. { value: 280, name: '合格' },
  302. { value: 75, name: '待改进' }
  303. ]
  304. }]
  305. })
  306. }
  307. // 岗位分布饼图1
  308. if (positionPieChart1.value) {
  309. positionPieChart1Instance = echarts.init(positionPieChart1.value)
  310. positionPieChart1Instance.setOption({
  311. tooltip: { trigger: 'item' },
  312. series: [{
  313. type: 'pie',
  314. radius: '70%',
  315. data: [
  316. { value: 150, name: '安检员' },
  317. { value: 120, name: '设备操作员' },
  318. { value: 80, name: '管理人员' },
  319. { value: 50, name: '其他' }
  320. ]
  321. }]
  322. })
  323. }
  324. // 岗位分布饼图2
  325. if (positionPieChart2.value) {
  326. positionPieChart2Instance = echarts.init(positionPieChart2.value)
  327. positionPieChart2Instance.setOption({
  328. tooltip: { trigger: 'item' },
  329. series: [{
  330. type: 'pie',
  331. radius: '70%',
  332. data: [
  333. { value: 35, name: '优秀' },
  334. { value: 320, name: '合格' },
  335. { value: 45, name: '待改进' }
  336. ]
  337. }]
  338. })
  339. }
  340. })
  341. }
  342. // 设置遍历图表引用
  343. const setTraversalChartRef = (el, key) => {
  344. if (el) {
  345. traversalChartsRefs.value[key] = el
  346. }
  347. }
  348. // 初始化遍历图表
  349. const initTraversalCharts = () => {
  350. nextTick(() => {
  351. // 第一个遍历的饼状图
  352. traversalData1.value.forEach((item, index) => {
  353. // 饼状图1:考核结果分布
  354. const pieChart1Key = `pieChart1_${index}`
  355. if (traversalChartsRefs.value[pieChart1Key]) {
  356. const pieChart1 = echarts.init(traversalChartsRefs.value[pieChart1Key])
  357. pieChart1.setOption({
  358. tooltip: { trigger: 'item' },
  359. series: [{
  360. type: 'pie',
  361. radius: '70%',
  362. data: [
  363. { value: 120, name: '优秀' },
  364. { value: 280, name: '合格' },
  365. { value: 75, name: '待改进' }
  366. ]
  367. }]
  368. })
  369. }
  370. // 饼状图2:改进情况分布
  371. const pieChart2Key = `pieChart2_${index}`
  372. if (traversalChartsRefs.value[pieChart2Key]) {
  373. const pieChart2 = echarts.init(traversalChartsRefs.value[pieChart2Key])
  374. pieChart2.setOption({
  375. tooltip: { trigger: 'item' },
  376. series: [{
  377. type: 'pie',
  378. radius: '70%',
  379. data: [
  380. { value: 15, name: '已改进' },
  381. { value: 60, name: '待改进' },
  382. { value: 5, name: '未改进' }
  383. ]
  384. }]
  385. })
  386. }
  387. })
  388. // 第二个遍历的图表
  389. traversalData2.value.forEach((item, index) => {
  390. // 柱状图:考核分数分布
  391. const barChartKey = `barChart_${index}`
  392. if (traversalChartsRefs.value[barChartKey]) {
  393. const barChart = echarts.init(traversalChartsRefs.value[barChartKey])
  394. barChart.setOption({
  395. tooltip: { trigger: 'axis' },
  396. xAxis: { type: 'category', data: ['90-100分', '80-89分', '70-79分', '60-69分', '60分以下'] },
  397. yAxis: { type: 'value' },
  398. series: [{ type: 'bar', data: [85, 120, 95, 60, 20], itemStyle: { color: '#3b82f6' } }]
  399. })
  400. }
  401. // 饼状图:岗位分布
  402. const pieChart3Key = `pieChart3_${index}`
  403. if (traversalChartsRefs.value[pieChart3Key]) {
  404. const pieChart3 = echarts.init(traversalChartsRefs.value[pieChart3Key])
  405. pieChart3.setOption({
  406. tooltip: { trigger: 'item' },
  407. series: [{
  408. type: 'pie',
  409. radius: '70%',
  410. data: [
  411. { value: 150, name: '安检员' },
  412. { value: 120, name: '设备操作员' },
  413. { value: 80, name: '管理人员' },
  414. { value: 50, name: '其他' }
  415. ]
  416. }]
  417. })
  418. }
  419. })
  420. })
  421. }
  422. // 窗口大小变化时重绘图表
  423. const handleResize = () => {
  424. const charts = [
  425. overallBarChartInstance,
  426. participantPieChartInstance,
  427. departmentComparisonChartInstance,
  428. brigadePieChart1Instance,
  429. brigadePieChart2Instance,
  430. positionPieChart1Instance,
  431. positionPieChart2Instance
  432. ]
  433. charts.forEach(chart => {
  434. if (chart) chart.resize()
  435. })
  436. }
  437. // 获取数据
  438. const getList = async () => {
  439. loading.value = true
  440. try {
  441. // 格式化参数:YYYY-MM -> YYYYMM
  442. const formatParams = (params) => {
  443. const formatted = { ...params }
  444. if (formatted.assessmentMonth) {
  445. formatted.assessmentMonth = formatted.assessmentMonth.replace('-', '')
  446. }
  447. return formatted
  448. }
  449. // 获取大队列表
  450. const brigadeListRes = await listDept()
  451. const brigadeList = (brigadeListRes.data || []).filter(item => item.deptType === 'BRIGADE' && item.isFunctionalDept == 0)
  452. // 其他接口调用
  453. const formattedQueryParams = formatParams(queryParams)
  454. const results = await Promise.allSettled([
  455. getScoreDistribution(formattedQueryParams),
  456. getDeptParticipation(formattedQueryParams),
  457. getDeptScoreDistribution(formattedQueryParams),
  458. getAssessmentSummary(formattedQueryParams),
  459. getActualImprovementDistribution(formattedQueryParams),
  460. getActualIncompetentDistribution(formattedQueryParams),
  461. getAssessmentTeamImprovementDistribution(formattedQueryParams),
  462. getAssessmentTeamIncompetentDistribution(formattedQueryParams),
  463. getFunctionalDeptSummary(formattedQueryParams),
  464. getFunctionalDeptPersonnelDistribution(formattedQueryParams),
  465. getFunctionalDeptDistributionPie(formattedQueryParams)
  466. ])
  467. const [scoreDistRes, deptPartRes, deptScoreRes, assessmentSumRes, actualImproveRes, actualIncompRes, teamImproveRes, teamIncompRes, functionalDeptRes, functionalDeptPersonnelRes, functionalDeptPieRes] = results
  468. // 对每个大队调用三个接口
  469. const brigadeDataPromises = brigadeList.map(async (brigade) => {
  470. const brigadeParams = formatParams({ ...queryParams, deptId: brigade.deptId })
  471. const brigadeResults = await Promise.allSettled([
  472. getDeptAssessmentTeamStatistics(brigadeParams),
  473. getBrigadeImprovementDistribution(brigadeParams),
  474. getBrigadeIncompetentDistribution(brigadeParams)
  475. ])
  476. const [deptTeamStatRes, brigadeImproveRes, brigadeIncompRes] = brigadeResults
  477. const statisticsData = deptTeamStatRes.status === 'fulfilled' ? (deptTeamStatRes.value.data || []) : []
  478. const brigadeImproveData = brigadeImproveRes.status === 'fulfilled' ? (brigadeImproveRes.value.data || []) : []
  479. const brigadeIncompData = brigadeIncompRes.status === 'fulfilled' ? (brigadeIncompRes.value.data || []) : []
  480. // 解析表格数据
  481. let tableData = []
  482. if (statisticsData.length > 0 && statisticsData[0].assessmentTeams) {
  483. tableData = statisticsData[0].assessmentTeams
  484. }
  485. // 计算总计用于标题
  486. const totalImprovement = tableData.reduce((sum, item) => sum + (item.actualImprovementCount || 0), 0)
  487. const totalIncompetent = tableData.reduce((sum, item) => sum + (item.actualIncompetentCount || 0), 0)
  488. return {
  489. title: brigade.deptName,
  490. deptId: brigade.deptId,
  491. tableData,
  492. improveData: brigadeImproveData,
  493. incompData: brigadeIncompData,
  494. totalImprovement,
  495. totalIncompetent
  496. }
  497. })
  498. traversalData1.value = await Promise.all(brigadeDataPromises.filter(item => item.tableData?.length > 0 || item.improveData?.length > 0 || item.incompData?.length > 0))
  499. if (scoreDistRes.status === 'fulfilled' && scoreDistRes.value.data) {
  500. const data = scoreDistRes.value.data
  501. if (overallBarChartInstance && Array.isArray(data)) {
  502. overallBarChartInstance.setOption({
  503. xAxis: { data: data.map(item => item.scoreRange) },
  504. series: [{ data: data.map(item => item.count) }]
  505. })
  506. }
  507. }
  508. if (deptPartRes.status === 'fulfilled' && deptPartRes.value.data) {
  509. const data = deptPartRes.value.data
  510. if (participantPieChartInstance && Array.isArray(data)) {
  511. participantPieChartInstance.setOption({
  512. series: [{ data: data.map(item => ({ name: item.deptName, value: item.count })) }]
  513. })
  514. }
  515. }
  516. if (deptScoreRes.status === 'fulfilled' && deptScoreRes.value.data) {
  517. const data = deptScoreRes.value.data
  518. if (departmentComparisonChartInstance && Array.isArray(data)) {
  519. const xAxisData = data.map(item => item.rangeLabel)
  520. const firstDeptCounts = data.length > 0 ? data[0].deptCounts : []
  521. const series = firstDeptCounts.map(dept => ({
  522. name: dept.deptName,
  523. type: 'bar',
  524. data: data.map(item => {
  525. const deptData = item.deptCounts.find(d => d.deptId === dept.deptId)
  526. return deptData ? deptData.count : 0
  527. })
  528. }))
  529. departmentComparisonChartInstance.setOption({
  530. legend: { data: firstDeptCounts.map(d => d.deptName) },
  531. xAxis: { data: xAxisData },
  532. series: series
  533. })
  534. summaryTableColumns.value = firstDeptCounts
  535. summaryTableData.value = data.map(item => {
  536. const row = {
  537. rangeLabel: item.rangeLabel,
  538. totalCount: item.totalCount
  539. }
  540. item.deptCounts.forEach(dept => {
  541. row['team' + dept.deptId] = dept.count
  542. })
  543. return row
  544. })
  545. }
  546. }
  547. if (assessmentSumRes.status === 'fulfilled' && assessmentSumRes.value.data) {
  548. const data = assessmentSumRes.value.data
  549. if (data && typeof data === 'object') {
  550. classificationTableData.value = [data]
  551. }
  552. }
  553. if (actualImproveRes.status === 'fulfilled' && actualImproveRes.value.data) {
  554. const data = actualImproveRes.value.data
  555. if (brigadePieChart1Instance && Array.isArray(data)) {
  556. brigadePieChart1Instance.setOption({
  557. series: [{ data: data.map(item => ({ name: item.deptName, value: item.count })) }]
  558. })
  559. }
  560. }
  561. if (actualIncompRes.status === 'fulfilled' && actualIncompRes.value.data) {
  562. const data = actualIncompRes.value.data
  563. if (brigadePieChart2Instance && Array.isArray(data)) {
  564. brigadePieChart2Instance.setOption({
  565. series: [{ data: data.map(item => ({ name: item.deptName, value: item.count })) }]
  566. })
  567. }
  568. }
  569. if (teamImproveRes.status === 'fulfilled' && teamImproveRes.value.data) {
  570. const data = teamImproveRes.value.data
  571. if (positionPieChart1Instance && Array.isArray(data)) {
  572. positionPieChart1Instance.setOption({
  573. series: [{ data: data.map(item => ({ name: item.assessmentTeam, value: item.count })) }]
  574. })
  575. }
  576. }
  577. if (teamIncompRes.status === 'fulfilled' && teamIncompRes.value.data) {
  578. const data = teamIncompRes.value.data
  579. if (positionPieChart2Instance && Array.isArray(data)) {
  580. positionPieChart2Instance.setOption({
  581. series: [{ data: data.map(item => ({ name: item.assessmentTeam, value: item.count })) }]
  582. })
  583. }
  584. }
  585. // 初始化traversalData1对应的图表
  586. nextTick(() => {
  587. traversalData1.value.forEach((item, index) => {
  588. const chartKey1 = `pieChart1_${index}`
  589. const chartKey2 = `pieChart2_${index}`
  590. if (traversalChartsRefs.value[chartKey1] && item.improveData) {
  591. const pieChart1 = echarts.init(traversalChartsRefs.value[chartKey1])
  592. pieChart1.setOption({
  593. tooltip: { trigger: 'item' },
  594. series: [{
  595. type: 'pie',
  596. radius: '70%',
  597. data: item.improveData.map(d => ({ name: d.assessmentTeam, value: d.count }))
  598. }]
  599. })
  600. }
  601. if (traversalChartsRefs.value[chartKey2] && item.incompData) {
  602. const pieChart2 = echarts.init(traversalChartsRefs.value[chartKey2])
  603. pieChart2.setOption({
  604. tooltip: { trigger: 'item' },
  605. series: [{
  606. type: 'pie',
  607. radius: '70%',
  608. data: item.incompData.map(d => ({ name: d.assessmentTeam, value: d.count }))
  609. }]
  610. })
  611. }
  612. })
  613. })
  614. if (functionalDeptRes.status === 'fulfilled' && functionalDeptRes.value.data) {
  615. const summaryData = functionalDeptRes.value.data || []
  616. const personnelData = functionalDeptPersonnelRes.status === 'fulfilled' ? (functionalDeptPersonnelRes.value.data || []) : []
  617. const pieData = functionalDeptPieRes.status === 'fulfilled' ? (functionalDeptPieRes.value.data || []) : []
  618. traversalData2.value = summaryData.map(item => {
  619. // 匹配人员数据
  620. const personnelItem = personnelData.find(p => p.deptId === item.deptId)
  621. // 匹配饼图数据
  622. const deptPieData = pieData.filter(p => p.deptId === item.deptId)
  623. return {
  624. title: item.deptName,
  625. deptId: item.deptId,
  626. tableData: item.assessmentTeams || [],
  627. barData: personnelItem ? [
  628. { name: '考核组人数', value: personnelItem.assessmentTeamCount || 0 },
  629. { name: '实际待改进人数', value: personnelItem.actualImprovementCount || 0 },
  630. { name: '实际不称职人数', value: personnelItem.actualIncompetentCount || 0 }
  631. ] : [],
  632. pieData: deptPieData.map(p => ({ name: p.assessmentTeam, value: p.count }))
  633. }
  634. })
  635. nextTick(() => {
  636. traversalData2.value.forEach((item, index) => {
  637. const chartKey = `barChart_${index}`
  638. const pieChartKey = `pieChart3_${index}`
  639. if (traversalChartsRefs.value[chartKey] && item.barData.length > 0) {
  640. const barChart = echarts.init(traversalChartsRefs.value[chartKey])
  641. barChart.setOption({
  642. tooltip: { trigger: 'axis' },
  643. xAxis: { type: 'category', data: item.barData.map(d => d.name) },
  644. yAxis: { type: 'value' },
  645. series: [{ type: 'bar', data: item.barData.map(d => d.value), itemStyle: { color: '#3b82f6' } }]
  646. })
  647. }
  648. if (traversalChartsRefs.value[pieChartKey] && item.pieData.length > 0) {
  649. const pieChart = echarts.init(traversalChartsRefs.value[pieChartKey])
  650. pieChart.setOption({
  651. tooltip: { trigger: 'item' },
  652. series: [{ type: 'pie', radius: '70%', data: item.pieData }]
  653. })
  654. }
  655. })
  656. })
  657. }
  658. } catch (error) {
  659. console.error('获取汇总数据失败:', error)
  660. ElMessage.error('获取汇总数据失败')
  661. } finally {
  662. loading.value = false
  663. }
  664. }
  665. // 查询
  666. const handleQuery = () => {
  667. getList()
  668. }
  669. // 重置查询
  670. const resetQuery = () => {
  671. queryFormRef.value?.resetFields()
  672. getList()
  673. }
  674. // 导出
  675. const handleExport = async () => {
  676. const loading = ElLoading.service({
  677. lock: true,
  678. text: '正在生成Word文档...',
  679. background: 'rgba(0, 0, 0, 0.7)'
  680. })
  681. try {
  682. const children = []
  683. // 生成动态文档标题
  684. let reportTitle = '非干部月度考核汇总报告'
  685. if (queryParams.assessmentMonth) {
  686. const [year, month] = queryParams.assessmentMonth.split('-')
  687. reportTitle = `${year}年${parseInt(month)}月非干部月度考核汇总报告`
  688. }
  689. // 添加文档标题
  690. children.push(
  691. new Paragraph({
  692. text: reportTitle,
  693. heading: HeadingLevel.TITLE,
  694. alignment: AlignmentType.CENTER,
  695. }),
  696. new Paragraph({
  697. text: `导出时间: ${new Date().toLocaleString('zh-CN')}`,
  698. alignment: AlignmentType.CENTER,
  699. }),
  700. new Paragraph({ text: '' })
  701. )
  702. // 获取所有 main-section(两大区块)
  703. const mainSections = document.querySelectorAll('.main-section')
  704. for (let i = 0; i < mainSections.length; i++) {
  705. const section = mainSections[i]
  706. const sectionTitle = section.querySelector('.section-title')
  707. const sectionName = sectionTitle ? sectionTitle.textContent : `第${i + 1}部分`
  708. children.push(
  709. new Paragraph({
  710. text: `${i + 1}. ${sectionName}`,
  711. heading: HeadingLevel.HEADING_1,
  712. }),
  713. new Paragraph({ text: '' })
  714. )
  715. if (i === 0) {
  716. // 第一部分:非干部月度考核分数汇总
  717. // 处理第一行的两个图表
  718. const chartRow1 = section.querySelector('.chart-row')
  719. if (chartRow1) {
  720. const chartCards = chartRow1.querySelectorAll('.chart-card')
  721. for (let j = 0; j < chartCards.length; j++) {
  722. const card = chartCards[j]
  723. const header = card.querySelector('.chart-header')
  724. const chartTitle = header ? header.textContent : `图表${j + 1}`
  725. children.push(
  726. new Paragraph({
  727. text: `${i + 1}.${j + 1} ${chartTitle}`,
  728. heading: HeadingLevel.HEADING_2,
  729. }),
  730. new Paragraph({ text: '' })
  731. )
  732. const chartContainer = card.querySelector('.chart-container')
  733. if (chartContainer) {
  734. await captureAndAddImage(chartContainer, children)
  735. }
  736. }
  737. }
  738. // 处理第二行的图表和汇总表
  739. const chartRow2 = section.querySelectorAll('.chart-row')
  740. if (chartRow2.length > 1) {
  741. const secondRow = chartRow2[1]
  742. const cards = secondRow.querySelectorAll('.chart-card')
  743. for (let j = 0; j < cards.length; j++) {
  744. const card = cards[j]
  745. const header = card.querySelector('.chart-header')
  746. const chartTitle = header ? header.textContent : `图表${j + 1}`
  747. children.push(
  748. new Paragraph({
  749. text: `${i + 1}.${j + 3} ${chartTitle}`,
  750. heading: HeadingLevel.HEADING_2,
  751. }),
  752. new Paragraph({ text: '' })
  753. )
  754. if (j === 0) {
  755. // 各部门分值分布对比图
  756. const chartContainer = card.querySelector('.chart-container')
  757. if (chartContainer) {
  758. await captureAndAddImage(chartContainer, children)
  759. }
  760. } else {
  761. // 汇总表
  762. const table = card.querySelector('.el-table')
  763. if (table) {
  764. await captureTable(table, children)
  765. }
  766. }
  767. }
  768. }
  769. } else {
  770. // 第二部分:非干部月度考核分类结果汇总
  771. // 汇总统计表格
  772. const summaryTableCard = section.querySelector('.summary-table-card')
  773. if (summaryTableCard) {
  774. const header = summaryTableCard.querySelector('.chart-header')
  775. const tableTitle = header ? header.textContent : '汇总统计'
  776. children.push(
  777. new Paragraph({
  778. text: `${i + 1}.1 ${tableTitle}`,
  779. heading: HeadingLevel.HEADING_2,
  780. }),
  781. new Paragraph({ text: '' })
  782. )
  783. const table = summaryTableCard.querySelector('.el-table')
  784. if (table) {
  785. await captureTable(table, children)
  786. }
  787. }
  788. // 第四行的两个图表
  789. const chartRows = section.querySelectorAll('.chart-row')
  790. if (chartRows.length > 0) {
  791. const chartRow = chartRows[0]
  792. const chartCards = chartRow.querySelectorAll('.chart-card')
  793. for (let j = 0; j < chartCards.length; j++) {
  794. const card = chartCards[j]
  795. const header = card.querySelector('.chart-header')
  796. const chartTitle = header ? header.textContent : `图表${j + 1}`
  797. children.push(
  798. new Paragraph({
  799. text: `${i + 1}.${j + 2} ${chartTitle}`,
  800. heading: HeadingLevel.HEADING_2,
  801. }),
  802. new Paragraph({ text: '' })
  803. )
  804. const pieChartsContainer = card.querySelector('.pie-charts-container')
  805. if (pieChartsContainer) {
  806. await captureAndAddImage(pieChartsContainer, children)
  807. }
  808. }
  809. }
  810. }
  811. }
  812. // 处理第一个遍历区域(traversalData1)
  813. const traversalSections = document.querySelectorAll('.traversal-section')
  814. let sectionCounter = mainSections.length + 1
  815. if (traversalSections.length > 0) {
  816. const firstTraversal = traversalSections[0]
  817. const traversalContainers = firstTraversal.querySelectorAll('.traversal-container')
  818. for (let t = 0; t < traversalContainers.length; t++) {
  819. const container = traversalContainers[t]
  820. const headerEl = container.querySelector('.traversal-header')
  821. const title = headerEl ? headerEl.textContent : `部门${t + 1}`
  822. children.push(
  823. new Paragraph({
  824. text: `${sectionCounter}. ${title}`,
  825. heading: HeadingLevel.HEADING_1,
  826. }),
  827. new Paragraph({ text: '' })
  828. )
  829. const content = container.querySelector('.traversal-content')
  830. if (content) {
  831. // 左边表格
  832. const tableSection = content.querySelector('.table-section')
  833. if (tableSection) {
  834. const table = tableSection.querySelector('.el-table')
  835. if (table) {
  836. children.push(
  837. new Paragraph({
  838. text: `${sectionCounter}.1 考核组统计表`,
  839. heading: HeadingLevel.HEADING_2,
  840. }),
  841. new Paragraph({ text: '' })
  842. )
  843. await captureTable(table, children)
  844. }
  845. }
  846. // 右边两个饼状图
  847. const chartSection = content.querySelector('.chart-section')
  848. if (chartSection) {
  849. const pieContainers = chartSection.querySelectorAll('.pie-chart-container')
  850. for (let p = 0; p < pieContainers.length; p++) {
  851. const pieContainer = pieContainers[p]
  852. const pieTitleEl = pieContainer.querySelector('.pie-chart-title')
  853. const pieTitle = pieTitleEl ? pieTitleEl.textContent : `饼图${p + 1}`
  854. children.push(
  855. new Paragraph({
  856. text: `${sectionCounter}.${p + 2} ${pieTitle}`,
  857. heading: HeadingLevel.HEADING_2,
  858. }),
  859. new Paragraph({ text: '' })
  860. )
  861. const pieChart = pieContainer.querySelector('.pie-chart')
  862. if (pieChart) {
  863. await captureAndAddImage(pieChart, children)
  864. }
  865. }
  866. }
  867. }
  868. sectionCounter++
  869. }
  870. }
  871. // 处理第二个遍历区域(traversalData2)
  872. if (traversalSections.length > 1) {
  873. const secondTraversal = traversalSections[1]
  874. const traversalContainers = secondTraversal.querySelectorAll('.traversal-container')
  875. for (let t = 0; t < traversalContainers.length; t++) {
  876. const container = traversalContainers[t]
  877. const headerEl = container.querySelector('.traversal-header')
  878. const title = headerEl ? headerEl.textContent : `部门${t + 1}`
  879. children.push(
  880. new Paragraph({
  881. text: `${sectionCounter}. ${title}`,
  882. heading: HeadingLevel.HEADING_1,
  883. }),
  884. new Paragraph({ text: '' })
  885. )
  886. const content = container.querySelector('.traversal-content')
  887. if (content) {
  888. // 左边表格
  889. const tableSection = content.querySelector('.table-section')
  890. if (tableSection) {
  891. const table = tableSection.querySelector('.el-table')
  892. if (table) {
  893. children.push(
  894. new Paragraph({
  895. text: `${sectionCounter}.1 考核组统计表`,
  896. heading: HeadingLevel.HEADING_2,
  897. }),
  898. new Paragraph({ text: '' })
  899. )
  900. await captureTable(table, children)
  901. }
  902. }
  903. // 右边柱状图和饼状图
  904. const chartSection = content.querySelector('.chart-section')
  905. if (chartSection) {
  906. const barContainer = chartSection.querySelector('.bar-chart-container')
  907. if (barContainer) {
  908. const chartTitleEl = barContainer.querySelector('.chart-title')
  909. const chartTitle = chartTitleEl ? chartTitleEl.textContent : '考核分数分布'
  910. children.push(
  911. new Paragraph({
  912. text: `${sectionCounter}.2 ${chartTitle}`,
  913. heading: HeadingLevel.HEADING_2,
  914. }),
  915. new Paragraph({ text: '' })
  916. )
  917. const barChart = barContainer.querySelector('.bar-chart')
  918. if (barChart) {
  919. await captureAndAddImage(barChart, children)
  920. }
  921. }
  922. const pieContainer = chartSection.querySelector('.pie-chart-container')
  923. if (pieContainer) {
  924. const pieTitleEl = pieContainer.querySelector('.pie-chart-title')
  925. const pieTitle = pieTitleEl ? pieTitleEl.textContent : '岗位分布'
  926. children.push(
  927. new Paragraph({
  928. text: `${sectionCounter}.3 ${pieTitle}`,
  929. heading: HeadingLevel.HEADING_2,
  930. }),
  931. new Paragraph({ text: '' })
  932. )
  933. const pieChart = pieContainer.querySelector('.pie-chart')
  934. if (pieChart) {
  935. await captureAndAddImage(pieChart, children)
  936. }
  937. }
  938. }
  939. }
  940. sectionCounter++
  941. }
  942. }
  943. // 创建文档
  944. const doc = new Document({
  945. sections: [{
  946. properties: {},
  947. children: children
  948. }]
  949. })
  950. // 生成并下载
  951. const blob = await Packer.toBlob(doc)
  952. const fileName = `${reportTitle}_${new Date().toISOString().slice(0, 10)}.docx`
  953. saveAs(blob, fileName)
  954. ElMessage.success('Word文档导出成功')
  955. } catch (error) {
  956. console.error('导出失败:', error)
  957. ElMessage.error('导出失败: ' + (error.message || '请重试'))
  958. } finally {
  959. loading.close()
  960. }
  961. }
  962. // 截图图表容器并添加为图片
  963. const captureAndAddImage = async (element, children) => {
  964. try {
  965. const canvas = await html2canvas(element, {
  966. backgroundColor: '#ffffff',
  967. scale: 2,
  968. logging: false
  969. })
  970. const imageData = canvas.toDataURL('image/png')
  971. const base64Data = imageData.replace(/^data:image\/png;base64,/, '')
  972. if (!base64Data || base64Data.trim() === '') {
  973. return
  974. }
  975. const maxWidth = 500
  976. const originalWidth = canvas.width
  977. const originalHeight = canvas.height
  978. const aspectRatio = originalWidth / originalHeight
  979. let finalWidth = maxWidth
  980. let finalHeight = maxWidth / aspectRatio
  981. const maxHeight = 400
  982. if (finalHeight > maxHeight) {
  983. finalHeight = maxHeight
  984. finalWidth = maxHeight * aspectRatio
  985. }
  986. const imageBytes = Uint8Array.from(atob(base64Data), c => c.charCodeAt(0))
  987. children.push(
  988. new Paragraph({
  989. children: [
  990. new ImageRun({
  991. data: imageBytes,
  992. transformation: {
  993. width: Math.round(finalWidth),
  994. height: Math.round(finalHeight)
  995. }
  996. })
  997. ],
  998. alignment: AlignmentType.CENTER,
  999. }),
  1000. new Paragraph({ text: '' })
  1001. )
  1002. } catch (error) {
  1003. console.error('截图失败:', error)
  1004. }
  1005. }
  1006. // 截图表格并添加为图片
  1007. const captureTable = async (table, children) => {
  1008. try {
  1009. const originalMaxHeight = table.style.maxHeight || ''
  1010. const originalOverflowY = table.style.overflowY || ''
  1011. const originalOverflowX = table.style.overflowX || ''
  1012. const originalTableWidth = table.style.width || ''
  1013. table.style.maxHeight = 'none'
  1014. table.style.overflowY = 'visible'
  1015. table.style.overflowX = 'visible'
  1016. table.style.width = '800px'
  1017. let originalTableHeight = ''
  1018. let originalTableWidthStyle = ''
  1019. originalTableHeight = table.style.height || ''
  1020. originalTableWidthStyle = table.style.width || ''
  1021. table.style.height = 'auto'
  1022. table.style.width = '800px'
  1023. const bodyWrapper = table.querySelector('.el-table__body-wrapper')
  1024. if (bodyWrapper) {
  1025. bodyWrapper.style.overflowX = 'visible'
  1026. bodyWrapper.style.overflowY = 'visible'
  1027. }
  1028. await new Promise(resolve => setTimeout(resolve, 200))
  1029. const canvas = await html2canvas(table, {
  1030. backgroundColor: '#ffffff',
  1031. scale: 1.5,
  1032. logging: false,
  1033. useCORS: true,
  1034. allowTaint: true,
  1035. scrollX: 0,
  1036. scrollY: 0,
  1037. width: 800,
  1038. height: table.scrollHeight
  1039. })
  1040. table.style.maxHeight = originalMaxHeight
  1041. table.style.overflowY = originalOverflowY
  1042. table.style.overflowX = originalOverflowX
  1043. table.style.width = originalTableWidth
  1044. table.style.height = originalTableHeight
  1045. table.style.width = originalTableWidthStyle
  1046. if (bodyWrapper) {
  1047. bodyWrapper.style.overflowX = ''
  1048. bodyWrapper.style.overflowY = ''
  1049. }
  1050. const imageData = canvas.toDataURL('image/png')
  1051. const base64Data = imageData.replace(/^data:image\/png;base64,/, '')
  1052. if (!base64Data || base64Data.trim() === '') {
  1053. return
  1054. }
  1055. const maxWidth = 500
  1056. const originalWidth = canvas.width
  1057. const originalHeight = canvas.height
  1058. const aspectRatio = originalWidth / originalHeight
  1059. let finalWidth = maxWidth
  1060. let finalHeight = maxWidth / aspectRatio
  1061. const maxHeight = 400
  1062. if (finalHeight > maxHeight) {
  1063. finalHeight = maxHeight
  1064. finalWidth = maxHeight * aspectRatio
  1065. }
  1066. const imageBytes = Uint8Array.from(atob(base64Data), c => c.charCodeAt(0))
  1067. children.push(
  1068. new Paragraph({
  1069. children: [
  1070. new ImageRun({
  1071. data: imageBytes,
  1072. transformation: {
  1073. width: Math.round(finalWidth),
  1074. height: Math.round(finalHeight)
  1075. }
  1076. })
  1077. ],
  1078. alignment: AlignmentType.CENTER,
  1079. }),
  1080. new Paragraph({ text: '' })
  1081. )
  1082. } catch (error) {
  1083. console.error('表格截图失败:', error)
  1084. }
  1085. }
  1086. onMounted(() => {
  1087. initCharts()
  1088. initTraversalCharts()
  1089. window.addEventListener('resize', handleResize)
  1090. getList()
  1091. })
  1092. // 组件卸载时移除事件监听器
  1093. onUnmounted(() => {
  1094. window.removeEventListener('resize', handleResize)
  1095. // 销毁图表实例
  1096. const charts = [
  1097. overallBarChartInstance,
  1098. participantPieChartInstance,
  1099. departmentComparisonChartInstance,
  1100. brigadePieChart1Instance,
  1101. brigadePieChart2Instance,
  1102. positionPieChart1Instance,
  1103. positionPieChart2Instance
  1104. ]
  1105. charts.forEach(chart => {
  1106. if (chart) chart.dispose()
  1107. })
  1108. })
  1109. </script>
  1110. <style lang="less" scoped>
  1111. .app-container {
  1112. padding: 20px;
  1113. }
  1114. .filter-section {
  1115. margin-bottom: 20px;
  1116. }
  1117. .filter-container {
  1118. display: flex;
  1119. justify-content: space-between;
  1120. align-items: center;
  1121. }
  1122. .search-form {
  1123. display: flex;
  1124. align-items: center;
  1125. gap: 10px;
  1126. }
  1127. .export-button {
  1128. margin-left: auto;
  1129. }
  1130. .main-section {
  1131. margin-bottom: 30px;
  1132. }
  1133. .section-title {
  1134. font-size: 20px;
  1135. font-weight: bold;
  1136. color: #333;
  1137. margin-bottom: 20px;
  1138. text-align: center;
  1139. }
  1140. .chart-row {
  1141. display: grid;
  1142. grid-template-columns: 1fr 1fr;
  1143. gap: 20px;
  1144. margin-bottom: 20px;
  1145. }
  1146. .chart-card {
  1147. height: 400px;
  1148. }
  1149. .summary-table-card {
  1150. margin-bottom: 20px;
  1151. }
  1152. .chart-header {
  1153. font-size: 16px;
  1154. font-weight: 600;
  1155. color: #333;
  1156. margin-bottom: 10px;
  1157. text-align: center;
  1158. }
  1159. .chart-container {
  1160. width: 100%;
  1161. height: 350px;
  1162. }
  1163. .pie-charts-container {
  1164. display: grid;
  1165. grid-template-columns: 1fr 1fr;
  1166. gap: 10px;
  1167. height: 350px;
  1168. }
  1169. .pie-chart {
  1170. width: 100%;
  1171. height: 100%;
  1172. }
  1173. :deep(.el-table) {
  1174. .el-table__header th {
  1175. background-color: #f5f7fa;
  1176. font-weight: 600;
  1177. }
  1178. }
  1179. /* 遍历样式 */
  1180. .traversal-section {
  1181. margin-bottom: 30px;
  1182. }
  1183. .traversal-container {
  1184. border: 1px solid #dcdfe6;
  1185. border-radius: 8px;
  1186. overflow: hidden;
  1187. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  1188. margin-bottom: 20px;
  1189. }
  1190. .traversal-header {
  1191. background-color: #f5f7fa;
  1192. padding: 15px 20px;
  1193. font-size: 18px;
  1194. font-weight: 600;
  1195. color: #303133;
  1196. border-bottom: 1px solid #dcdfe6;
  1197. text-align: left;
  1198. }
  1199. .traversal-content {
  1200. display: grid;
  1201. grid-template-columns: 1fr 1fr;
  1202. gap: 20px;
  1203. padding: 20px;
  1204. }
  1205. .table-section {
  1206. min-height: 400px;
  1207. }
  1208. .chart-section {
  1209. display: grid;
  1210. grid-template-columns: 1fr 1fr;
  1211. gap: 15px;
  1212. height: 400px;
  1213. }
  1214. .pie-chart-container,
  1215. .bar-chart-container {
  1216. display: flex;
  1217. flex-direction: column;
  1218. border: 1px solid #e4e7ed;
  1219. border-radius: 6px;
  1220. padding: 10px;
  1221. background-color: #fff;
  1222. }
  1223. .pie-chart-title,
  1224. .chart-title {
  1225. font-size: 14px;
  1226. font-weight: 600;
  1227. color: #606266;
  1228. margin-bottom: 10px;
  1229. text-align: center;
  1230. }
  1231. .pie-chart,
  1232. .bar-chart {
  1233. flex: 1;
  1234. min-height: 300px;
  1235. }
  1236. /* 响应式布局 */
  1237. @media (max-width: 1200px) {
  1238. .chart-row {
  1239. grid-template-columns: 1fr;
  1240. }
  1241. .pie-charts-container {
  1242. grid-template-columns: 1fr;
  1243. }
  1244. .traversal-content {
  1245. grid-template-columns: 1fr;
  1246. gap: 15px;
  1247. }
  1248. .chart-section {
  1249. grid-template-columns: 1fr;
  1250. height: auto;
  1251. }
  1252. .pie-chart,
  1253. .bar-chart {
  1254. min-height: 250px;
  1255. }
  1256. }
  1257. @media (max-width: 768px) {
  1258. .traversal-content {
  1259. padding: 15px;
  1260. }
  1261. .chart-section {
  1262. gap: 10px;
  1263. }
  1264. .pie-chart-container,
  1265. .bar-chart-container {
  1266. padding: 8px;
  1267. }
  1268. }
  1269. </style>