index.vue 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717
  1. <template>
  2. <view>
  3. <div class="title">
  4. <user-info :name="checkerName" :sub-title="subTitle" :hello="'欢迎您'" class="userInfo" />
  5. <!-- 排名区块 -->
  6. <div class="rank-container" v-if="!isZhanZhang">
  7. <div v-for="(item, index) in rankItems" :key="index" class="rank-item">
  8. <div class="rank-content">
  9. <div class="rank-label">{{ item.label }}</div>
  10. <div class="rank-value">{{ item.value }}</div>
  11. <image :src="item.iconSrc" class="rank-image" />
  12. </div>
  13. </div>
  14. </div>
  15. <!-- 出勤信息区块 -->
  16. <div class="attendance-container">
  17. <div class="attendance-grid">
  18. <div v-for="(item, index) in attendanceItems" :key="index" class="attendance-item"
  19. @click="handleAttendanceClick(item)">
  20. <div class="item-label">{{ item.label }}</div>
  21. <div class="item-value">{{ item.value }}</div>
  22. </div>
  23. </div>
  24. </div>
  25. <!-- 角色切换组件(班组长显示) -->
  26. <SelectTag v-if="role.includes('banzuzhang')" :tags="roleTags" :selected-value="selectedRole"
  27. @change="handleRoleChange" class="role-selector" />
  28. </div>
  29. <div class="content">
  30. <Notice ref="notice" />
  31. <!-- 时间范围选择 -->
  32. <div class="time-range-section">
  33. <div class="time-tags-container">
  34. <div v-for="tag in timeTags" :key="tag.value"
  35. :class="['time-tag', { 'active': selectedTimeRange === tag.value, 'time-range-label': tag.isLabel }]"
  36. @click="tag.isLabel ? null : handleTimeTagClick(tag)">
  37. {{ tag.label }}
  38. </div>
  39. <!-- 自定义时间显示 - 紧跟自定义时间标签 -->
  40. <div v-if="selectedTimeRange === 'custom'" class="custom-time-inline">
  41. <uni-datetime-picker v-model="dateRange" type="daterange" rangeSeparator="至"
  42. @change="handleDateRangeChange" class="date-range-picker" :clear-icon="false" />
  43. <div class="days-count">共 {{ totalDays }} 天</div>
  44. </div>
  45. </div>
  46. </div>
  47. <!-- TypeDetail组件 -->
  48. <TypeDetail :data-list="typeDetailData" @sort-change="handleSortChange" />
  49. <!-- TotalDetail组件 -->
  50. <TotalDetail :homePageWholeData="homePageWholeData" :start-date="startDate" :end-date="endDate"
  51. :time-range="selectedTimeRange" :selectedRole="selectedRole" />
  52. <!-- QualityControlAnalysis组件 -->
  53. <QualityControlAnalysis v-if="role.includes('zhijianke') || role.includes('test')"
  54. :checkProblemDistributionData="checkProblemDistributionData"
  55. :accuracyAnalysisData="accuracyAnalysisData" :prohibitedTop3Data="prohibitedTop3Data"
  56. :concealmentPositionTop1Data="concealmentPositionTop1Data" />
  57. <!-- PerformanceAnalysis组件 -->
  58. <PerformanceAnalysis v-if="role.includes('zhijianke') || role.includes('test')"
  59. :performanceData="performanceData" />
  60. </div>
  61. </view>
  62. </template>
  63. <script>
  64. import HomeContainer from "@/components/HomeContainer.vue";
  65. import UserInfo from "@/components/UserInfo.vue";
  66. import QualityControlAnalysis from "@/pages/home-new/components/qualityControlAnalysis.vue";
  67. import PerformanceAnalysis from "@/pages/home-new/components/performanceAnalysis.vue";
  68. import HeadTitle from "@/components/HeadTitle.vue";
  69. import Notice from "@/pages/home/components/notice.vue";
  70. import SelectTag from "@/components/select-tag/select-tag.vue";
  71. import TypeDetail from "@/pages/home-new/components/type-detail.vue";
  72. import TotalDetail from "@/pages/home-new/components/total-detail.vue";
  73. import { getUserProfile, getAppListByRoleId, getAppList } from "@/api/system/user";
  74. import { getAttendanceList } from "@/api/attendance/attendance"
  75. import { getUnreadCount } from "@/api/check/checkTask"
  76. import { checkRolePermission } from "@/utils/common.js";
  77. import { getHomePage, getSeizureReport, getAttendanceStats, getAccuracyStatistics, getSeizureRanking, getCheckRanking, getHomePageWhole, selectUserListByRoleKey, getMetrics, getCheckProblemDistribution, getAccuracyAnalysis, getProhibitedTop3, getConcealmentPositionTop1 } from "@/api/home-new/home-new";
  78. // 导入uni-datetime-picker组件
  79. import uniDatetimePicker from "@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue";
  80. export default {
  81. components: {
  82. HeadTitle,
  83. UserInfo,
  84. HomeContainer,
  85. Notice,
  86. SelectTag,
  87. TypeDetail,
  88. TotalDetail,
  89. QualityControlAnalysis,
  90. PerformanceAnalysis,
  91. uniDatetimePicker
  92. },
  93. data() {
  94. return {
  95. checkerId: this.$store.state.user.id,
  96. userInfo: '',
  97. todayCheckInTime: '未打卡',
  98. unreadCount: 0,
  99. appList: [], // 存储接口返回的应用列表
  100. // 角色切换相关数据
  101. selectedRole: 'individual',
  102. roleTags: [
  103. { label: '个人', value: 'individual' },
  104. { label: '班组', value: 'team' }
  105. ],
  106. // 排序状态管理
  107. sortStates: {
  108. '查获上报': { teamSortType: 'asc', deptSortType: 'asc', brigadeSortType: 'asc' },
  109. '抽问抽答': { teamSortType: 'asc', deptSortType: 'asc', brigadeSortType: 'asc' },
  110. '巡检': { teamSortType: 'asc', deptSortType: 'asc', brigadeSortType: 'asc' }
  111. },
  112. // 排名数据
  113. rankData: {
  114. seizeRank: 0,
  115. seizeModalType: 0,
  116. answerRank: 0,
  117. answerModalType: 0,
  118. checkRank: 0,
  119. checkModalType: 0
  120. },
  121. // 出勤信息数据
  122. attendanceData: {},
  123. // 时间选择相关数据
  124. showTimePicker: false,
  125. startDate: '',
  126. endDate: '',
  127. dateRange: [],
  128. totalDays: 0,
  129. selectedTimeRange: 'year',
  130. timeTags: [
  131. { label: '时间范围:', value: 'label', isLabel: true },
  132. { label: '近一周', value: 'week' },
  133. { label: '近一月', value: 'month' },
  134. { label: '近三月', value: 'quarter' },
  135. { label: '近半年', value: 'halfYear' },
  136. { label: '近一年', value: 'year' },
  137. { label: '自定义时间', value: 'custom' }
  138. ],
  139. inspectionData: {},
  140. seizeData: {},
  141. attendanceStats: {},
  142. accuracyStatistics: {},
  143. homePageWholeData: [],
  144. subTitleText: '',
  145. // 绩效分析数据
  146. performanceData: [],
  147. // 检查问题分布数据
  148. checkProblemDistributionData: {},
  149. // 类型详情数据
  150. accuracyAnalysisData: {},
  151. // 违禁品TOP3数据
  152. prohibitedTop3Data: [],
  153. // 隐匿重点部位TOP1数据
  154. concealmentPositionTop1Data: [],
  155. }
  156. },
  157. computed: {
  158. subTitle() {
  159. return this.isZhanZhang ? `今日上岗大队长:${this.subTitleText}` : this.userInfo
  160. },
  161. checkerName() {
  162. if (this.$store.state.user) {
  163. if (this.$store.state.user.userInfo && this.$store.state.user.userInfo.nickName) {
  164. return this.$store.state.user.userInfo.nickName
  165. }
  166. }
  167. return this.$store.state.user.name
  168. },
  169. role() {
  170. return this.$store?.state?.user?.roles
  171. },
  172. currentUser() {
  173. return this.$store.state.user.userInfo
  174. },
  175. // 是否为班组视图:角色是班组长或者selectedRole为team
  176. isTeamView() {
  177. return this.role.includes('banzuzhang') ? this.selectedRole === 'team' : this.role.includes('banzuzhang')
  178. },
  179. // 是否为个人视图:selectedRole为individual或者角色是SecurityCheck
  180. isIndividualView() {
  181. return this.role.includes('banzuzhang') ? this.selectedRole === 'individual' : this.role.includes('SecurityCheck')
  182. },
  183. isBrigade() {
  184. return this.role.includes('jingli') || this.role.includes('xingzheng')
  185. },
  186. // 是否为站长或质检科角色
  187. isZhanZhang() {
  188. return this.role.includes('test') || this.role.includes('zhijianke')
  189. },
  190. // TypeDetail组件数据
  191. typeDetailData() {
  192. console.log('this.seizeData', this.seizeData, this.seizeData.stationMasterData)
  193. return [
  194. {
  195. title: '查获上报',
  196. linkText: this.isZhanZhang ? "" : this.isIndividualView ? (this.seizePendingCount ? `${this.seizePendingCount}条草稿待处理` : '') : (this.seizePendingCount ? `${this.seizePendingCount}条数据待处理` : ''),
  197. link: this.isIndividualView ? '/pages/voiceSubmissionDraft/index' : '/pages/myToDoList/index',
  198. statTitle: '查获数量',
  199. teamSortType: this.sortStates['查获上报'].teamSortType,
  200. deptSortType: this.sortStates['查获上报'].deptSortType,
  201. brigadeSortType: this.sortStates['查获上报'].brigadeSortType,
  202. dividerIndex: this.isBrigade ? 1 : 0,
  203. dataItems: this.getSeizeDataItems(),
  204. rankList: this.getSeizeRankList(),
  205. departmentRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.topThreeDepartmentRankings ? this.seizeData.stationMasterData.topThreeDepartmentRankings.map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.departmentName })) : [],
  206. bottomDepartmentRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.botomThreeDepartmentRankings ? [...this.seizeData.stationMasterData.botomThreeDepartmentRankings].sort((a, b) => (a.seizureCount || 0) - (b.seizureCount || 0)).slice(0, 3).map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.departmentName })) : [],
  207. teamRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.topThreeTeamRankings ? this.seizeData.stationMasterData.topThreeTeamRankings.map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.teamName })) : [],
  208. bottomTeamRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.botomThreeTeamRankings ? this.seizeData.stationMasterData.botomThreeTeamRankings.map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.teamName })) : [],
  209. brigadeRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.brigadeRankings ? [...this.seizeData.stationMasterData.brigadeRankings].sort((a, b) => (b.seizureCount || 0) - (a.seizureCount || 0)).slice(0, 5).map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.brigadeName })) : [],
  210. bottomBrigadeRank: this.seizeData.stationMasterData && this.seizeData.stationMasterData.brigadeRankings ? [...this.seizeData.stationMasterData.brigadeRankings].sort((a, b) => (a.seizureCount || 0) - (b.seizureCount || 0)).slice(0, 5).map(item => ({ ...item, passRate: item.seizureCount.toFixed(2), name: item.brigadeName })) : [],
  211. },
  212. {
  213. title: '抽问抽答',
  214. linkText: this.isIndividualView || this.isTeamView ? this.accuracyStatistics.hasPendingTask ? '待答题' : '' : '',
  215. link: '/pages/daily-exam/task-list/index',
  216. statTitle: '正确率(%)',
  217. teamSortType: this.sortStates['抽问抽答'].teamSortType,
  218. deptSortType: this.sortStates['抽问抽答'].deptSortType,
  219. brigadeSortType: this.sortStates['抽问抽答'].brigadeSortType,
  220. dividerIndex: this.isBrigade ? 1 : 0,
  221. dataItems: this.getQuestionDataItems(),
  222. rankList: this.getQuestionRankList(),
  223. departmentRank: this.accuracyStatistics.topDepts && this.accuracyStatistics.topDepts.map(item => ({ ...item, passRate: item.accuracy.toFixed(2), name: item.name })),
  224. bottomDepartmentRank: this.accuracyStatistics.bottomDepts && [...this.accuracyStatistics.topDepts].sort((a, b) => (a.accuracy || 0) - (b.accuracy || 0)).map(item => ({ ...item, passRate: item.accuracy.toFixed(2), name: item.name })),
  225. teamRank: this.accuracyStatistics.topTeamsInSite && this.accuracyStatistics.topTeamsInSite.map(item => ({ ...item, passRate: item.accuracy.toFixed(2), name: item.name })),
  226. bottomTeamRank: this.accuracyStatistics.bottomTeamsInSite && this.accuracyStatistics.bottomTeamsInSite.map(item => ({ ...item, passRate: item.accuracy.toFixed(2), name: item.name })),
  227. brigadeRank: this.accuracyStatistics.brigadeRankingList && [...this.accuracyStatistics.brigadeRankingList].sort((a, b) => (b.accuracy || 0) - (a.accuracy || 0)).slice(0, 5).map(item => ({ ...item, passRate: item.accuracy.toFixed(2), name: item.name })),
  228. bottomBrigadeRank: this.accuracyStatistics.brigadeRankingList && [...this.accuracyStatistics.brigadeRankingList].sort((a, b) => (a.accuracy || 0) - (b.accuracy || 0)).slice(0, 5).map(item => ({ ...item, passRate: item.accuracy.toFixed(2), name: item.name })),
  229. },
  230. {
  231. title: '巡检',
  232. linkText: this.isZhanZhang ? "" : this.inspectionData.toDoNumber ? `${this.inspectionData.toDoNumber}条待处理任务` : "",
  233. link: '/pages/myToDoList/index',
  234. statTitle: '合格率(%)',
  235. teamSortType: this.sortStates['巡检'].teamSortType,
  236. deptSortType: this.sortStates['巡检'].deptSortType,
  237. brigadeSortType: this.sortStates['巡检'].brigadeSortType,
  238. dividerIndex: this.isBrigade ? 1 : 0,
  239. dataItems: this.getInspectionDataItems(),
  240. completed: this.inspectionData.doneNumber,
  241. pending: this.inspectionData.doingNumber,
  242. rankList: this.getRankList(),
  243. departmentRank: this.inspectionData.departmentRankingList && this.inspectionData.departmentRankingList.map(item => ({ ...item, passRate: (item.passRate * 100).toFixed(2) })),
  244. bottomDepartmentRank: this.inspectionData.reverseDepartmentRankingList && [...this.inspectionData.reverseDepartmentRankingList].sort((a, b) => (a.passRate || 0) - (b.passRate || 0)).slice(0, 5).map(item => ({ ...item, passRate: (item.passRate * 100).toFixed(2) })),
  245. teamRank: this.inspectionData.teamRankingList && this.inspectionData.teamRankingList.map(item => ({ ...item, passRate: (item.passRate * 100).toFixed(2) })),
  246. bottomTeamRank: this.inspectionData.reverseTeamRankingList && this.inspectionData.reverseTeamRankingList.map(item => ({ ...item, passRate: (item.passRate * 100).toFixed(2) })),
  247. brigadeRank: this.inspectionData.brigadeRankingList && [...this.inspectionData.brigadeRankingList].sort((a, b) => (a.rank || 0) - (b.rank || 0)).slice(0, 5).map(item => ({ ...item, passRate: (item.passRate * 100).toFixed(2), name: item.name })),
  248. bottomBrigadeRank: this.inspectionData.brigadeRankingList && [...this.inspectionData.brigadeRankingList].sort((a, b) => (b.rank || 0) - (a.rank || 0)).slice(0, 5).map(item => ({ ...item, passRate: (item.passRate * 100).toFixed(2), name: item.name })),
  249. }
  250. ]
  251. },
  252. // 排名项数组
  253. rankItems() {
  254. return [
  255. {
  256. label: '查获排名',
  257. value: `${this.rankData.seizeRank}`,
  258. iconSrc: this.getRankImage(this.rankData.seizeModalType)
  259. },
  260. {
  261. label: '答题排名',
  262. value: `${this.rankData.answerRank}`,
  263. iconSrc: this.getRankImage(this.rankData.answerModalType)
  264. },
  265. {
  266. label: '检查排名',
  267. value: `${this.rankData.checkRank}`,
  268. iconSrc: this.getRankImage(this.rankData.checkModalType)
  269. }
  270. ];
  271. },
  272. // 根据角色返回不同的出勤信息数组
  273. attendanceItems() {
  274. let res = {};
  275. if (this.role.includes('kezhang') || this.isZhanZhang || this.isBrigade) {
  276. // 班组长选择班组视图
  277. if (this.isZhanZhang) {
  278. res = this.attendanceStats.stationLeaderStats
  279. }
  280. if (this.role.includes('kezhang')) {
  281. res = this.attendanceStats.sectionLeaderStats
  282. }
  283. if (this.isBrigade) {
  284. res = this.attendanceStats.brigadeLeaderStats
  285. }
  286. // 抽离复杂的判断逻辑
  287. const isZhanZhang = this.isZhanZhang;
  288. const firstLabel = isZhanZhang ? '在岗大队' : this.isBrigade ? '执勤大队' : '在岗班组';
  289. const firstValue = (isZhanZhang || this.isBrigade) ? (res?.dutyDeptName || '暂无') : res?.onDutyTeamCount;
  290. const secondLabel = isZhanZhang || this.isBrigade ? '在岗班组' : '在岗人员';
  291. const secondValue = isZhanZhang || this.isBrigade ? res?.onDutyTeamCount : res?.onDutyPersonnelCount;
  292. const thirdLabel = isZhanZhang || this.isBrigade ? '在岗人员' : '出勤时间';
  293. const thirdValue = (isZhanZhang || this.isBrigade) ? res?.onDutyPersonnelCount : (res?.attendanceTime || res?.attendanceTimeTips);
  294. const thirdLink = isZhanZhang ? '' : (res?.attendanceTime ? '' : '/pages/attendance/index');
  295. return [
  296. { label: firstLabel, value: firstValue },
  297. { label: secondLabel, value: secondValue },
  298. { label: thirdLabel, value: thirdValue, link: thirdLink },
  299. { label: '今日查获上报', value: res?.todaySeizureReportCount },
  300. { label: '今日巡检问题', value: res?.todayCheckCorrectionCount },
  301. { label: '今日抽问抽答', value: `${this.accuracyStatistics?.todayTaskCompletion?.completedCount || 0}/${this.accuracyStatistics?.todayTaskCompletion?.totalCount || 0}` }
  302. ];
  303. } else {
  304. res = this.attendanceStats.teamLeaderStats || this.attendanceStats.securityCheckStats
  305. // 个人视图或非班组长角色
  306. return [
  307. { label: '出勤班组', value: res?.attendanceTeamName },
  308. { label: '出勤通道', value: res?.attendanceChannel },
  309. { label: '出勤时间', value: res?.attendanceTime || res?.attendanceTimeTips, link: res?.attendanceTime ? '' : '/pages/attendance/index' }
  310. ];
  311. }
  312. },
  313. seizePendingCount() {
  314. // 根据角色返回不同的排名数据
  315. if (this.isIndividualView) {
  316. const { securityCheckerData } = this.seizeData;
  317. const { pendingCount } = securityCheckerData || {};
  318. return pendingCount;
  319. } else if (this.role.includes('kezhang')) {
  320. const { sectionMasterData } = this.seizeData;
  321. const { pendingCount } = sectionMasterData || {};
  322. // 科长、SecurityCheck角色:显示班组、科级和站级排名
  323. return pendingCount;
  324. } else if (this.isTeamView) {
  325. const { teamLeaderData } = this.seizeData;
  326. const { pendingCount } = teamLeaderData || {}
  327. return pendingCount;
  328. } else {
  329. }
  330. }
  331. },
  332. async onShow() {
  333. // 使用统一的loadAllData方法并行加载所有数据
  334. await this.loadAllData();
  335. // 数据获取完成后执行其他函数
  336. this.updateCurrentDate();
  337. this.getUnreadCount();
  338. // 页面显示时,刷新子组件的数据 - 使用$nextTick确保DOM已渲染完成
  339. this.$nextTick(() => {
  340. console.log("notice====", this.$refs.notice)
  341. this.$refs.notice?.refreshData();
  342. this.$refs.announcement?.refreshData();
  343. });
  344. },
  345. onLoad() {
  346. this.getUser()
  347. this.loadTodayRecord();
  348. this.setDefaultDates();
  349. },
  350. methods: {
  351. // 设置默认日期
  352. setDefaultDates() {
  353. const today = new Date();
  354. const yesterday = new Date(today);
  355. yesterday.setDate(today.getDate() - 1);
  356. // 与calculateDateRange方法中的近一年计算方式保持一致:从365天前到昨天
  357. const startDate = new Date(yesterday);
  358. startDate.setDate(yesterday.getDate() - 364);
  359. // 使用本地时间格式化,避免UTC时间转换问题
  360. this.startDate = this.formatLocalDate(startDate)
  361. this.endDate = this.formatLocalDate(yesterday)
  362. // 初始化dateRange
  363. this.dateRange = [this.startDate, this.endDate]
  364. this.calculateDays()
  365. },
  366. // 格式化本地日期为YYYY-MM-DD格式
  367. formatLocalDate(date) {
  368. const year = date.getFullYear();
  369. const month = String(date.getMonth() + 1).padStart(2, '0');
  370. const day = String(date.getDate()).padStart(2, '0');
  371. return `${year}-${month}-${day}`;
  372. },
  373. // 计算天数
  374. calculateDays() {
  375. if (this.startDate && this.endDate) {
  376. const start = new Date(this.startDate)
  377. const end = new Date(this.endDate)
  378. const diffTime = Math.abs(end - start)
  379. const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1
  380. this.totalDays = diffDays
  381. }
  382. },
  383. // 处理日期范围变化
  384. async handleDateRangeChange(e) {
  385. if (e && Array.isArray(e) && e.length === 2) {
  386. this.startDate = e[0]
  387. this.endDate = e[1]
  388. this.calculateDays()
  389. await this.loadAllData();
  390. }
  391. },
  392. // 统一加载所有数据的方法
  393. async loadAllData() {
  394. try {
  395. // 使用Promise.allSettled并行执行所有数据接口请求
  396. const results = await Promise.allSettled([
  397. this.getInspectionData(), // 巡检数据
  398. this.getSeizeData(), // 查获上报数据
  399. this.getAttendanceStats(), // 出勤统计数据
  400. this.fetchAccuracyStatistics(), // 抽问抽答数据
  401. this.getRank(), // 排名数据
  402. this.getHomePageWholeData(), // 首页整体数据
  403. this.getTodayOnDutyKeZhang(), // 今日上岗科长信息
  404. this.getPerformanceData(), // 绩效分析数据
  405. this.getCheckProblemDistributionData(), // 检查问题分布数据
  406. this.getAccuracyAnalysis(), // 正确率分析数据
  407. this.getProhibitedTop3Data(), // 违禁品TOP3数据
  408. this.getConcealmentPositionTop1Data() // 隐匿重点部位TOP1数据
  409. ]);
  410. // 检查每个接口的请求结果
  411. results.forEach((result, index) => {
  412. const apiNames = [
  413. 'getInspectionData',
  414. 'getSeizeData',
  415. 'getAttendanceStats',
  416. 'fetchAccuracyStatistics',
  417. 'getRank',
  418. 'getHomePageWholeData',
  419. 'getTodayOnDutyKeZhang',
  420. 'getPerformanceData',
  421. 'getCheckProblemDistribution',
  422. 'getAccuracyAnalysis',
  423. 'getProhibitedTop3Data',
  424. 'getConcealmentPositionTop1Data'
  425. ];
  426. if (result.status === 'rejected') {
  427. console.warn(`${apiNames[index]} 接口请求失败:`, result.reason);
  428. } else {
  429. console.log(`${apiNames[index]} 接口请求成功`);
  430. }
  431. });
  432. return results;
  433. } catch (error) {
  434. console.error('加载数据失败:', error);
  435. throw error;
  436. }
  437. },
  438. // 获取检查问题分布数据
  439. async getCheckProblemDistributionData() {
  440. return new Promise((resolve, reject) => {
  441. const { startDate, endDate } = this.calculateDateRange(this.selectedTimeRange);
  442. const params = {
  443. startDate: startDate,
  444. endDate: endDate
  445. };
  446. getCheckProblemDistribution(params).then(res => {
  447. if (res && res.data) {
  448. console.log('检查问题分布数据:', res.data);
  449. this.checkProblemDistributionData = res.data;
  450. resolve(res.data);
  451. } else {
  452. this.checkProblemDistributionData = {};
  453. resolve(null);
  454. }
  455. }).catch(error => {
  456. console.error('获取检查问题分布数据失败:', error);
  457. this.checkProblemDistributionData = {};
  458. reject(error);
  459. });
  460. });
  461. },
  462. // 获取正确率分析数据
  463. getAccuracyAnalysis() {
  464. return new Promise((resolve, reject) => {
  465. const { startDate, endDate } = this.calculateDateRange(this.selectedTimeRange);
  466. const params = {
  467. startDate: startDate,
  468. endDate: endDate
  469. };
  470. getAccuracyAnalysis(params).then(res => {
  471. if (res && res.data) {
  472. console.log('正确率分析数据:', res.data);
  473. this.accuracyAnalysisData = res.data;
  474. resolve(res.data);
  475. } else {
  476. resolve(null);
  477. }
  478. }).catch(error => {
  479. console.error('获取正确率分析数据失败:', error);
  480. reject(error);
  481. });
  482. });
  483. },
  484. // 获取绩效分析数据
  485. getPerformanceData() {
  486. return new Promise((resolve, reject) => {
  487. const { startDate, endDate } = this.calculateDateRange(this.selectedTimeRange);
  488. const params = {
  489. startTime: startDate,
  490. endTime: endDate,
  491. sortField: 'totalScore',
  492. dimension: '4'
  493. };
  494. getMetrics(params).then(res => {
  495. if (res && res.data) {
  496. this.performanceData = res.data;
  497. resolve(res.data);
  498. } else {
  499. resolve([]);
  500. }
  501. }).catch(error => {
  502. console.error('获取绩效数据失败:', error);
  503. reject(error);
  504. });
  505. });
  506. },
  507. // 获取违禁品TOP3数据
  508. getProhibitedTop3Data() {
  509. return new Promise((resolve, reject) => {
  510. const { startDate, endDate } = this.calculateDateRange(this.selectedTimeRange);
  511. const params = {
  512. startDate: startDate,
  513. endDate: endDate
  514. };
  515. getProhibitedTop3(params).then(res => {
  516. if (res && res.data) {
  517. console.log('违禁品TOP3数据:', res.data);
  518. this.prohibitedTop3Data = res.data;
  519. resolve(res.data);
  520. } else {
  521. this.prohibitedTop3Data = {};
  522. resolve(null);
  523. }
  524. }).catch(error => {
  525. console.error('获取违禁品TOP3数据失败:', error);
  526. this.prohibitedTop3Data = {};
  527. reject(error);
  528. });
  529. });
  530. },
  531. // 获取隐匿重点部位TOP1数据
  532. getConcealmentPositionTop1Data() {
  533. return new Promise((resolve, reject) => {
  534. const { startDate, endDate } = this.calculateDateRange(this.selectedTimeRange);
  535. const params = {
  536. startDate: startDate,
  537. endDate: endDate
  538. };
  539. getConcealmentPositionTop1(params).then(res => {
  540. if (res && res.data) {
  541. console.log('隐匿重点部位TOP1数据:', res.data);
  542. this.concealmentPositionTop1Data = res.data;
  543. resolve(res.data);
  544. } else {
  545. this.concealmentPositionTop1Data = [];
  546. resolve(null);
  547. }
  548. }).catch(error => {
  549. console.error('获取隐匿重点部位TOP1数据失败:', error);
  550. this.concealmentPositionTop1Data = [];
  551. reject(error);
  552. });
  553. });
  554. },
  555. getRank() {
  556. return new Promise((resolve, reject) => {
  557. let params = {};
  558. // 根据时间范围计算开始时间和结束时间(不包括今天)
  559. const { startDate, endDate } = this.calculateDateRange(this.selectedTimeRange);
  560. params.startDate = startDate;
  561. params.endDate = endDate;
  562. params.dataSource = this.selectedRole;
  563. let idObj = {}
  564. if (this.isIndividualView) {
  565. idObj = { userId: this.currentUser.userId }
  566. } else {
  567. // 如果是班组视图,使用当前用户的部门ID
  568. if (this.selectedRole === 'team') {
  569. idObj = { deptId: this.currentUser.deptId }
  570. } else {
  571. // 个人视图,使用当前用户的部门ID
  572. idObj = { deptId: this.currentUser.deptId }
  573. }
  574. }
  575. // 构建API请求数组
  576. const apiRequests = [getSeizureRanking(params)];
  577. // 如果角色不是test,才请求getCheckRanking接口
  578. if (!this.role.includes('test')) {
  579. apiRequests.push(getCheckRanking({ ...params, ...idObj }));
  580. }
  581. // 使用Promise.allSettled并行执行API请求,即使有接口失败也不影响其他接口
  582. Promise.allSettled(apiRequests).then((results) => {
  583. // 处理每个接口的结果
  584. results.forEach((result, index) => {
  585. if (result.status === 'fulfilled') {
  586. const res = result.value;
  587. if (index === 0) {
  588. // 处理查获排名数据
  589. const { data: seizureData } = res || {};
  590. this.rankData.seizeRank = seizureData[0]?.rank;
  591. this.rankData.seizeModalType = seizureData[0]?.medalType;
  592. } else if (index === 1) {
  593. // 处理检查排名数据
  594. const { data: checkData } = res;
  595. const { checkLargeScreenHomePageRankingDto, dailyTaskAccuracyRankingDto } = checkData
  596. this.rankData.checkRank = checkLargeScreenHomePageRankingDto.rank;
  597. this.rankData.checkModalType = checkLargeScreenHomePageRankingDto.medalType;
  598. this.rankData.answerRank = dailyTaskAccuracyRankingDto.rank;
  599. this.rankData.answerModalType = dailyTaskAccuracyRankingDto.medalType;
  600. }
  601. } else {
  602. console.warn(`第${index + 1}个接口请求失败:`, result.reason);
  603. }
  604. });
  605. resolve({
  606. seizureData: results[0]?.status === 'fulfilled' ? results[0].value.data : null,
  607. checkData: results[1]?.status === 'fulfilled' ? results[1].value.data : null
  608. });
  609. });
  610. });
  611. },
  612. getInspectionData() {
  613. return new Promise((resolve, reject) => {
  614. let params = {}
  615. // 根据角色和selectedRole设置参数
  616. if (this.isIndividualView) {
  617. params = { userId: this.currentUser.userId }
  618. } else {
  619. // 如果是班组视图,使用当前用户的部门ID
  620. if (this.selectedRole === 'team') {
  621. params = { deptId: this.currentUser.deptId }
  622. } else {
  623. // 个人视图,使用当前用户的部门ID
  624. params = { deptId: this.currentUser.deptId }
  625. }
  626. }
  627. // 根据时间范围计算开始时间和结束时间(不包括今天)
  628. const { startDate, endDate } = this.calculateDateRange(this.selectedTimeRange);
  629. params.startDate = startDate;
  630. params.endDate = endDate;
  631. getHomePage(params).then(res => {
  632. // console.log("res", res)
  633. this.inspectionData = res.data || {};
  634. resolve(res.data);
  635. }).catch(error => {
  636. console.error("获取巡检数据失败:", error);
  637. reject(error);
  638. });
  639. });
  640. },
  641. getHomePageWholeData() {
  642. return new Promise((resolve, reject) => {
  643. let params = {}
  644. // 根据时间范围计算开始时间和结束时间(不包括今天)
  645. const { startDate, endDate } = this.calculateDateRange(this.selectedTimeRange);
  646. params.startDate = startDate;
  647. params.endDate = endDate;
  648. params.dataSource = this.selectedRole;
  649. getHomePageWhole(params).then(res => {
  650. this.homePageWholeData = res.data || [];
  651. // 这里可以处理getHomePageWhole接口返回的数据
  652. resolve(res.data);
  653. }).catch(error => {
  654. console.error("获取整体数据失败:", error);
  655. reject(error);
  656. });
  657. });
  658. },
  659. getSeizeData() {
  660. return new Promise((resolve, reject) => {
  661. let params = {}
  662. // 根据时间范围计算开始时间和结束时间(不包括今天)
  663. const { startDate, endDate } = this.calculateDateRange(this.selectedTimeRange);
  664. params.startDate = startDate;
  665. params.endDate = endDate;
  666. if (!this.isZhanZhang && !this.role.includes('kezhang')) {
  667. params.dataSource = this.selectedRole;
  668. }
  669. getSeizureReport(params).then(res => {
  670. // console.log("res", res)
  671. this.seizeData = res.data || {};
  672. resolve(res.data);
  673. }).catch(error => {
  674. console.error("获取查获数据失败:", error);
  675. reject(error);
  676. });
  677. });
  678. },
  679. getAttendanceStats() {
  680. return new Promise((resolve, reject) => {
  681. let params = {}
  682. // 根据时间范围计算开始时间和结束时间(不包括今天)
  683. const { startDate, endDate } = this.calculateDateRange(this.selectedTimeRange);
  684. params.startDate = startDate;
  685. params.endDate = endDate;
  686. params.dataSource = this.selectedRole;
  687. getAttendanceStats(params).then(res => {
  688. console.log("出勤统计数据:", res)
  689. this.attendanceStats = res.data || {};
  690. resolve(res.data);
  691. }).catch(error => {
  692. console.error("获取出勤统计数据失败:", error);
  693. reject(error);
  694. });
  695. });
  696. },
  697. fetchAccuracyStatistics() {
  698. return new Promise((resolve, reject) => {
  699. let params = {}
  700. // 根据时间范围计算开始时间和结束时间(不包括今天)
  701. const { startDate, endDate } = this.calculateDateRange(this.selectedTimeRange);
  702. params.startDate = startDate;
  703. params.endDate = endDate;
  704. params.dataSource = this.selectedRole;
  705. getAccuracyStatistics(params).then(res => {
  706. console.log("准确率统计数据:", res)
  707. this.accuracyStatistics = res.data || {};
  708. // this.rankData.answerRank = this.accuracyStatistics.deptInSiteRanking.rank;
  709. // this.rankData.answerRank = this.accuracyStatistics.deptInSiteRanking.rank;
  710. resolve(res.data);
  711. }).catch(error => {
  712. console.error("获取准确率统计数据失败:", error);
  713. reject(error);
  714. });
  715. });
  716. },
  717. // 根据时间范围计算开始时间和结束时间(不包括今天)
  718. calculateDateRange(timeRange) {
  719. const today = new Date();
  720. const yesterday = new Date(today);
  721. yesterday.setDate(today.getDate() - 1);
  722. let startDate = new Date(yesterday);
  723. let endDate = new Date(yesterday);
  724. switch (timeRange) {
  725. case 'week':
  726. // 近一周:从7天前到昨天
  727. startDate.setDate(yesterday.getDate() - 6);
  728. break;
  729. case 'month':
  730. // 近一月:从30天前到昨天
  731. startDate.setDate(yesterday.getDate() - 29);
  732. break;
  733. case 'quarter':
  734. // 近三月:从90天前到昨天
  735. startDate.setDate(yesterday.getDate() - 89);
  736. break;
  737. case 'halfYear':
  738. // 近半年:从180天前到昨天
  739. startDate.setDate(yesterday.getDate() - 179);
  740. break;
  741. case 'year':
  742. // 近一年:从365天前到昨天
  743. startDate.setDate(yesterday.getDate() - 364);
  744. break;
  745. case 'custom':
  746. // 自定义时间:使用用户选择的日期
  747. if (this.startDate && this.endDate) {
  748. startDate = new Date(this.startDate);
  749. endDate = new Date(this.endDate);
  750. }
  751. break;
  752. default:
  753. // 默认近一周
  754. startDate.setDate(yesterday.getDate() - 364);
  755. }
  756. return {
  757. startDate: this.formatDateForInput(startDate),
  758. endDate: this.formatDateForInput(endDate)
  759. };
  760. },
  761. // 处理角色切换
  762. async handleRoleChange(roleValue) {
  763. this.selectedRole = roleValue;
  764. // 根据角色切换重新加载所有数据
  765. try {
  766. // 使用Promise.allSettled并行执行所有接口请求,即使有接口失败也不影响其他接口
  767. const results = await Promise.allSettled([
  768. this.getInspectionData(),
  769. this.getSeizeData(),
  770. this.getAttendanceStats(),
  771. this.fetchAccuracyStatistics(),
  772. this.getRank(),
  773. this.getHomePageWholeData()
  774. ]);
  775. // 检查是否有接口失败
  776. results.forEach((result, index) => {
  777. if (result.status === 'rejected') {
  778. console.warn(`第${index + 1}个接口请求失败:`, result.reason);
  779. }
  780. });
  781. console.log('角色切换后数据重新加载完成');
  782. } catch (error) {
  783. console.error('角色切换后数据加载失败:', error);
  784. uni.showToast({
  785. title: '数据加载失败',
  786. icon: 'none'
  787. });
  788. }
  789. },
  790. // 显示自定义时间选择器
  791. showCustomTimePicker(timeRange) {
  792. this.selectedTimeRange = timeRange;
  793. this.showTimePicker = true;
  794. // 优先回显自定义的时间,如果已有自定义时间则使用,否则设置默认日期
  795. if (!this.startDate || !this.endDate) {
  796. const today = new Date();
  797. const oneWeekAgo = new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000);
  798. this.startDate = this.formatDateForInput(oneWeekAgo);
  799. this.endDate = this.formatDateForInput(today);
  800. }
  801. },
  802. // 处理时间标签点击
  803. handleTimeTagClick(tag) {
  804. if (tag.value === 'custom') {
  805. // 自定义时间:显示时间选择器
  806. this.showCustomTimePicker(tag.value);
  807. } else {
  808. // 预设时间范围:直接切换
  809. this.selectedTimeRange = tag.value;
  810. this.showTimePicker = false;
  811. this.loadDataByTimeRange(tag.value);
  812. }
  813. },
  814. // 处理日期变化
  815. handleDateChange() {
  816. // 只有当两个时间都选择了才请求接口
  817. if (this.startDate && this.endDate) {
  818. const customRange = {
  819. startDate: this.startDate,
  820. endDate: this.endDate
  821. };
  822. this.loadDataByCustomRange(customRange);
  823. }
  824. },
  825. // 处理排序切换
  826. handleSortChange(title, type, sortType) {
  827. if (this.sortStates[title]) {
  828. if (type === 'team') {
  829. this.sortStates[title].teamSortType = sortType;
  830. } else if (type === 'dept') {
  831. this.sortStates[title].deptSortType = sortType;
  832. } else if (type === 'brigade') {
  833. this.sortStates[title].brigadeSortType = sortType;
  834. }
  835. }
  836. },
  837. // 处理时间范围变化
  838. handleTimeRangeChange(timeRange) {
  839. this.selectedTimeRange = timeRange;
  840. this.showTimePicker = false;
  841. this.loadDataByTimeRange(timeRange);
  842. },
  843. // 取消时间选择
  844. cancelTimePicker() {
  845. this.showTimePicker = false;
  846. },
  847. // 格式化日期为输入框格式
  848. formatDateForInput(date) {
  849. const year = date.getFullYear();
  850. const month = String(date.getMonth() + 1).padStart(2, '0');
  851. const day = String(date.getDate()).padStart(2, '0');
  852. return `${year}-${month}-${day}`;
  853. },
  854. // 根据时间范围加载数据
  855. async loadDataByTimeRange(timeRange) {
  856. try {
  857. console.log('加载时间范围数据:', timeRange);
  858. // 使用统一的loadAllData方法加载所有数据
  859. await this.loadAllData();
  860. console.log('时间范围切换后数据重新加载完成');
  861. } catch (error) {
  862. console.error('加载时间范围数据失败:', error);
  863. uni.showToast({
  864. title: '数据加载失败',
  865. icon: 'none'
  866. });
  867. }
  868. },
  869. handleAttendanceClick(item) {
  870. if (item.link) {
  871. uni.navigateTo({
  872. url: item.link
  873. });
  874. }
  875. },
  876. // 根据自定义时间范围加载数据
  877. async loadDataByCustomRange(customRange) {
  878. try {
  879. console.log('加载自定义时间范围数据:', customRange);
  880. // 使用统一的loadAllData方法加载所有数据
  881. await this.loadAllData();
  882. console.log('自定义时间范围切换后数据重新加载完成');
  883. } catch (error) {
  884. console.error('加载自定义时间范围数据失败:', error);
  885. uni.showToast({
  886. title: '数据加载失败',
  887. icon: 'none'
  888. });
  889. }
  890. },
  891. // 根据排名类型和排名值获取图片路径
  892. getRankImage(type) {
  893. console.log('获取排名图片:', type);
  894. switch (type) {
  895. case 1: return '/static/images/icon/gold.png';
  896. case 2: return '/static/images/icon/silver.png';
  897. case 3: return '/static/images/icon/bronze.png';
  898. case 4: return '/static/images/icon/red-face.png';
  899. case 5: return '/static/images/icon/orange-face.png';
  900. case 6: return '/static/images/icon/yellow-face.png';
  901. }
  902. },
  903. // 根据角色获取检查项标签文字
  904. getInspectionItemLabel() {
  905. if (this.isIndividualView) {
  906. return '本人';
  907. } else if (this.isTeamView) {
  908. return '班组';
  909. } else if (this.role.includes('kezhang')) {
  910. return '主管';
  911. } else if (this.isZhanZhang) {
  912. return '全站';
  913. } else {
  914. return '检查项'; // 默认值
  915. }
  916. },
  917. // 根据角色获取巡检数据项数组
  918. getInspectionDataItems() {
  919. const { personalPassRate, teamPassRate, departmentPassRate, stationPassRate, teamRankingList, departmentRankingList, brigadeRankingList, brigadePassRate } = this.inspectionData;
  920. if (this.isIndividualView) {
  921. // SecurityCheck角色:本人、班平均、主管平均、站平均
  922. return [
  923. { label: '本人', value: ((personalPassRate || 0) * 100).toFixed(2), isImage: false },
  924. { label: '班平均', value: ((teamPassRate || 0) * 100).toFixed(2), isImage: false, color: teamPassRate < personalPassRate ? '#00AE41' : '#F96060' },
  925. { label: '主管平均', value: ((departmentPassRate || 0) * 100).toFixed(2), isImage: false, color: departmentPassRate < personalPassRate ? '#00AE41' : '#F96060' },
  926. { label: '大队平均', value: ((brigadePassRate || 0) * 100).toFixed(2), isImage: false, color: brigadePassRate < personalPassRate ? '#00AE41' : '#F96060' },
  927. { label: '站平均', value: ((stationPassRate || 0) * 100).toFixed(2), isImage: false, color: stationPassRate < personalPassRate ? '#00AE41' : '#F96060' }
  928. ];
  929. } else if (this.isTeamView) {
  930. // banzuzhang角色:班组、主管平均、站平均
  931. return [
  932. { label: '班组', value: ((teamPassRate || 0) * 100).toFixed(2), isImage: false },
  933. { label: '主管平均', value: ((departmentPassRate || 0) * 100).toFixed(2), isImage: false, color: departmentPassRate < teamPassRate ? '#00AE41' : '#F96060' },
  934. { label: '大队平均', value: ((brigadePassRate || 0) * 100).toFixed(2), isImage: false, color: brigadePassRate < personalPassRate ? '#00AE41' : '#F96060' },
  935. { label: '站平均', value: ((stationPassRate || 0) * 100).toFixed(2), isImage: false, color: stationPassRate < teamPassRate ? '#00AE41' : '#F96060' }
  936. ];
  937. } else if (this.role.includes('kezhang')) {
  938. // kezhang角色:主管、站平均、前三名班组(isImage: true)
  939. return [
  940. { label: '主管', value: ((departmentPassRate || 0) * 100).toFixed(2), isImage: false },
  941. { label: '大队平均', value: ((brigadePassRate || 0) * 100).toFixed(2), isImage: false, color: brigadePassRate < personalPassRate ? '#00AE41' : '#F96060' },
  942. { label: '站平均', value: ((stationPassRate || 0) * 100).toFixed(2), isImage: false, color: stationPassRate < departmentPassRate ? '#00AE41' : '#F96060' },
  943. ];
  944. } else if (this.isBrigade) {
  945. // brigade角色:主管、站平均、前三名班组(isImage: true)
  946. return [
  947. { label: '大队', value: ((brigadePassRate || 0) * 100).toFixed(2), isImage: false },
  948. { label: '站平均', value: ((stationPassRate || 0) * 100).toFixed(2), isImage: false, color: stationPassRate < brigadePassRate ? '#00AE41' : '#F96060' },
  949. { label: this.getObjByRank(departmentRankingList, 1).name, value: '/static/images/icon/one.png', isImage: true },
  950. { label: this.getObjByRank(departmentRankingList, 2).name, value: '/static/images/icon/two.png', isImage: true },
  951. { label: this.getObjByRank(departmentRankingList, 3).name, value: '/static/images/icon/three.png', isImage: true }
  952. ];
  953. } else if (this.isZhanZhang) {
  954. // test/zhijianke角色:全站、前三名的科室(isImage: true)
  955. return [
  956. { label: '全站', value: ((stationPassRate || 0) * 100).toFixed(2), isImage: false },
  957. { label: this.getObjByRank(brigadeRankingList, 1).name, value: '/static/images/icon/one.png', isImage: true },
  958. { label: this.getObjByRank(brigadeRankingList, 2).name, value: '/static/images/icon/two.png', isImage: true },
  959. { label: this.getObjByRank(brigadeRankingList, 3).name, value: '/static/images/icon/three.png', isImage: true }
  960. ];
  961. } else {
  962. // 默认角色:检查项、完成率
  963. return [
  964. { label: '检查项', value: '12', isImage: false },
  965. { label: '完成率', value: '92%', isImage: false }
  966. ];
  967. }
  968. },
  969. //获取抽问抽答
  970. getQuestionDataItems() {
  971. const { personalAccuracy, teamAvgAccuracy, deptAvgAccuracy, siteAvgAccuracy, topDepts, topKezhangInBrigade, brigadeAvgAccuracy, brigadeRankingList } = this.accuracyStatistics;
  972. if (this.isIndividualView) {
  973. // SecurityCheck角色:本人、班平均、主管平均、站平均
  974. return [
  975. { label: '本人', value: (personalAccuracy || 0), isImage: false },
  976. { label: '班平均', value: (teamAvgAccuracy || 0), isImage: false, color: teamAvgAccuracy < personalAccuracy ? '#00AE41' : '#F96060' },
  977. { label: '主管平均', value: (deptAvgAccuracy || 0), isImage: false, color: deptAvgAccuracy < personalAccuracy ? '#00AE41' : '#F96060' },
  978. { label: '大队平均', value: (brigadeAvgAccuracy || 0), isImage: false, color: deptAvgAccuracy < personalAccuracy ? '#00AE41' : '#F96060' },
  979. { label: '站平均', value: (siteAvgAccuracy || 0), isImage: false, color: siteAvgAccuracy < personalAccuracy ? '#00AE41' : '#F96060' }
  980. ];
  981. } else if (this.isTeamView) {
  982. // banzuzhang角色:班组、主管平均、站平均
  983. return [
  984. { label: '班组', value: (teamAvgAccuracy || 0), isImage: false },
  985. { label: '主管平均', value: (deptAvgAccuracy || 0), isImage: false, color: deptAvgAccuracy < teamAvgAccuracy ? '#00AE41' : '#F96060' },
  986. { label: '大队平均', value: (brigadeAvgAccuracy || 0), isImage: false, color: brigadeAvgAccuracy < teamAvgAccuracy ? '#00AE41' : '#F96060' },
  987. { label: '站平均', value: (siteAvgAccuracy || 0), isImage: false, color: siteAvgAccuracy < teamAvgAccuracy ? '#00AE41' : '#F96060' }
  988. ];
  989. } else if (this.role.includes('kezhang')) {
  990. // kezhang角色:主管、站平均、前三名班组(isImage: true)
  991. return [
  992. { label: '主管', value: (deptAvgAccuracy || 0), isImage: false, },
  993. { label: '大队平均', value: (brigadeAvgAccuracy || 0), isImage: false, color: brigadeAvgAccuracy < deptAvgAccuracy ? '#00AE41' : '#F96060' },
  994. { label: '站平均', value: (siteAvgAccuracy || 0), isImage: false, color: siteAvgAccuracy < deptAvgAccuracy ? '#00AE41' : '#F96060' },
  995. ];
  996. } else if (this.isBrigade) {
  997. // brigade角色:主管、站平均、前三名班组(isImage: true)
  998. return [
  999. { label: '大队', value: (brigadeAvgAccuracy || 0), isImage: false, },
  1000. { label: '站平均', value: (siteAvgAccuracy || 0), isImage: false, color: siteAvgAccuracy < deptAvgAccuracy ? '#00AE41' : '#F96060' },
  1001. { label: this.getObjByRank(topKezhangInBrigade, 1).name, value: '/static/images/icon/one.png', isImage: true },
  1002. { label: this.getObjByRank(topKezhangInBrigade, 2).name, value: '/static/images/icon/two.png', isImage: true },
  1003. { label: this.getObjByRank(topKezhangInBrigade, 3).name, value: '/static/images/icon/three.png', isImage: true }
  1004. ];
  1005. } else if (this.isZhanZhang) {
  1006. // test/zhijianke角色:全站、前三名的科室(isImage: true)
  1007. return [
  1008. { label: '全站', value: (siteAvgAccuracy || 0), isImage: false },
  1009. { label: this.getObjByRank(brigadeRankingList, 1).name, value: '/static/images/icon/one.png', isImage: true },
  1010. { label: this.getObjByRank(brigadeRankingList, 2).name, value: '/static/images/icon/two.png', isImage: true },
  1011. { label: this.getObjByRank(brigadeRankingList, 3).name, value: '/static/images/icon/three.png', isImage: true }
  1012. ];
  1013. } else {
  1014. // 默认角色:检查项、完成率
  1015. return [
  1016. { label: '检查项', value: '12', isImage: false },
  1017. { label: '完成率', value: '92%', isImage: false }
  1018. ];
  1019. }
  1020. },
  1021. //根据角色获取查获数据项目组
  1022. getSeizeDataItems() {
  1023. if (this.isIndividualView) {
  1024. // SecurityCheck角色:从securityCheckerData解构
  1025. const { securityCheckerData } = this.seizeData;
  1026. const { selfSeizureCount, teamAverage, departmentAverage, brigadeAverage, stationAverage } = securityCheckerData || {}
  1027. // SecurityCheck角色:本人、班平均、主管平均、站平均
  1028. return [
  1029. { label: '本人', value: selfSeizureCount || 0, isImage: false },
  1030. { label: '班平均', value: teamAverage || 0, isImage: false, color: teamAverage < selfSeizureCount ? '#00AE41' : '#F96060' },
  1031. { label: '主管平均', value: departmentAverage || 0, isImage: false, color: departmentAverage < selfSeizureCount ? '#00AE41' : '#F96060' },
  1032. { label: '大队平均', value: brigadeAverage || 0, isImage: false, color: brigadeAverage < selfSeizureCount ? '#00AE41' : '#F96060' },
  1033. { label: '站平均', value: (stationAverage && stationAverage.toFixed(2)) || 0, isImage: false, color: stationAverage < selfSeizureCount ? '#00AE41' : '#F96060' }
  1034. ];
  1035. } else if (this.isTeamView) {
  1036. // banzuzhang角色:从teamLeaderData解构
  1037. const { teamLeaderData } = this.seizeData;
  1038. const { departmentAverage, brigadeAverage, stationAverage, teamAverage } = teamLeaderData || {};
  1039. // banzuzhang角色:班组、主管平均、站平均
  1040. return [
  1041. { label: '班组', value: teamAverage || 0, isImage: false },
  1042. { label: '主管平均', value: departmentAverage || 0, isImage: false, color: departmentAverage < teamAverage ? '#00AE41' : '#F96060' },
  1043. { label: '大队平均', value: brigadeAverage || 0, isImage: false, color: brigadeAverage < teamAverage ? '#00AE41' : '#F96060' },
  1044. { label: '站平均', value: (stationAverage && stationAverage.toFixed(2)) || 0, isImage: false, color: stationAverage < teamAverage ? '#00AE41' : '#F96060' }
  1045. ];
  1046. } else if (this.role.includes('kezhang')) {
  1047. // kezhang角色:从securityCheckerData解构
  1048. const { sectionMasterData } = this.seizeData;
  1049. const { brigadeAverage, departmentAverage, stationAverage } = sectionMasterData || {}
  1050. // kezhang角色:主管、站平均、前三名班组(isImage: true)
  1051. return [
  1052. { label: '主管', value: departmentAverage || 0, isImage: false },
  1053. { label: '大队平均', value: brigadeAverage || 0, isImage: false, color: brigadeAverage < departmentAverage ? '#00AE41' : '#F96060' },
  1054. { label: '站平均', value: (stationAverage && stationAverage.toFixed(2)) || 0, isImage: false, color: stationAverage < departmentAverage ? '#00AE41' : '#F96060' }
  1055. // { label: this.getObjByRank(topThreeTeams, 1).teamName, value: '/static/images/icon/one.png', isImage: true },
  1056. // { label: this.getObjByRank(topThreeTeams, 2).teamName, value: '/static/images/icon/two.png', isImage: true },
  1057. // { label: this.getObjByRank(topThreeTeams, 3).teamName, value: '/static/images/icon/three.png', isImage: true }
  1058. ];
  1059. } else if (this.isBrigade) {
  1060. // brigade角色:从securityCheckerData解构
  1061. const { brigadeMasterData } = this.seizeData;
  1062. const { stationAverage, topThreeDepartment, brigadeAverage } = brigadeMasterData || {}
  1063. // brigade角色:主管、站平均、前三名班组(isImage: true)
  1064. return [
  1065. { label: '大队', value: brigadeAverage || 0, isImage: false },
  1066. { label: '站平均', value: (stationAverage && stationAverage.toFixed(2)) || 0, isImage: false, color: stationAverage < brigadeAverage ? '#00AE41' : '#F96060' },
  1067. { label: this.getObjByRank(topThreeDepartment, 1).departmentName, value: '/static/images/icon/one.png', isImage: true },
  1068. { label: this.getObjByRank(topThreeDepartment, 2).departmentName, value: '/static/images/icon/two.png', isImage: true },
  1069. { label: this.getObjByRank(topThreeDepartment, 3).departmentName, value: '/static/images/icon/three.png', isImage: true }
  1070. ];
  1071. } else if (this.isZhanZhang) {
  1072. // test/zhijianke角色:从securityCheckerData解构
  1073. const { stationMasterData } = this.seizeData;
  1074. const { totalStationSeizure, brigadeRankings } = stationMasterData || {}
  1075. // 对departmentRankings数组按照seizureCount由大到小排序
  1076. const sortedBrigadeRankings = Array.isArray(brigadeRankings)
  1077. ? [...brigadeRankings].sort((a, b) => (b.seizureCount || 0) - (a.seizureCount || 0))
  1078. : [];
  1079. if (sortedBrigadeRankings.length == 0) {
  1080. return []
  1081. }
  1082. // test/zhijianke角色:全站、前三名的科室(isImage: true)
  1083. return [
  1084. { label: '全站', value: totalStationSeizure || 0, isImage: false },
  1085. { label: sortedBrigadeRankings[0].brigadeName, value: '/static/images/icon/one.png', isImage: true },
  1086. { label: sortedBrigadeRankings[1].brigadeName, value: '/static/images/icon/two.png', isImage: true },
  1087. { label: sortedBrigadeRankings[2].brigadeName, value: '/static/images/icon/three.png', isImage: true }
  1088. ];
  1089. } else {
  1090. // 默认角色:检查项、完成率
  1091. return [
  1092. { label: '检查项', value: '12', isImage: false },
  1093. { label: '完成率', value: '92%', isImage: false }
  1094. ];
  1095. }
  1096. },
  1097. getObjByRank(arr, rank) {
  1098. if (!Array.isArray(arr)) return {}
  1099. let res = arr.find(item => item.rank == rank)
  1100. return res || {}
  1101. },
  1102. // 根据角色获取巡检排名列表
  1103. getRankList() {
  1104. const { teamRanking, teamTotal, departmentRanking, departmentTotal, stationRanking, stationTotal, brigadeTotal, brigadeRanking } = this.inspectionData;
  1105. // 根据角色返回不同的排名数据
  1106. if (this.isIndividualView) {
  1107. // 科长、SecurityCheck角色:显示班组、科级和站级排名
  1108. return [
  1109. { label: '班组排名', current: teamRanking || 0, total: teamTotal || 0, percentage: teamTotal ? ((teamRanking || 0) / teamTotal) * 100 : 0 },
  1110. { label: '主管排名', current: departmentRanking || 0, total: departmentTotal || 0, percentage: departmentTotal ? ((departmentRanking || 0) / departmentTotal) * 100 : 0 },
  1111. { label: '大队排名', current: brigadeRanking || 0, total: brigadeTotal || 0, percentage: brigadeTotal ? ((brigadeRanking || 0) / brigadeTotal) * 100 : 0 },
  1112. { label: '站级排名', current: stationRanking || 0, total: stationTotal || 0, percentage: stationTotal ? ((stationRanking || 0) / stationTotal) * 100 : 0, type: 'station' }
  1113. ];
  1114. } else if (this.role.includes('kezhang')) {
  1115. return [
  1116. { label: '大队排名', current: brigadeRanking || 0, total: brigadeTotal || 0, percentage: brigadeTotal ? ((brigadeRanking || 0) / brigadeTotal) * 100 : 0 },
  1117. { label: '站级排名', current: stationRanking || 0, total: stationTotal || 0, percentage: stationTotal ? ((stationRanking || 0) / stationTotal) * 100 : 0, type: 'station' }
  1118. ];
  1119. } else if (this.isBrigade) {
  1120. return [
  1121. { label: '站级排名', current: stationRanking || 0, total: stationTotal || 0, percentage: stationTotal ? ((stationRanking || 0) / stationTotal) * 100 : 0, type: 'station' }
  1122. ];
  1123. } else if (this.isTeamView) {
  1124. // 班组长角色:显示科级和站级排名
  1125. return [
  1126. { label: '主管排名', current: departmentRanking || 0, total: departmentTotal || 0, percentage: departmentTotal ? ((departmentRanking || 0) / departmentTotal) * 100 : 0 },
  1127. { label: '大队排名', current: departmentRanking || 0, total: departmentTotal || 0, percentage: departmentTotal ? ((departmentRanking || 0) / departmentTotal) * 100 : 0 },
  1128. { label: '站级排名', current: stationRanking || 0, total: stationTotal || 0, percentage: stationTotal ? ((stationRanking || 0) / stationTotal) * 100 : 0, type: 'station' }
  1129. ];
  1130. } else {
  1131. // 默认角色:显示个人排名
  1132. return [];
  1133. }
  1134. },
  1135. //获取抽问抽答排名
  1136. getQuestionRankList() {
  1137. // 根据角色返回不同的排名数据
  1138. if (this.isIndividualView) {
  1139. const { teamRanking, deptRanking, siteRanking } = this.accuracyStatistics;
  1140. // 科长、SecurityCheck角色:显示班组、科级和站级排名
  1141. return [
  1142. { label: '班组排名', current: teamRanking?.rank || 0, total: teamRanking?.total || 0, percentage: teamRanking?.total ? ((teamRanking.rank || 0) / teamRanking.total) * 100 : 0 },
  1143. { label: '主管排名', current: deptRanking?.rank || 0, total: deptRanking?.total || 0, percentage: deptRanking?.total ? ((deptRanking.rank || 0) / deptRanking.total) * 100 : 0 },
  1144. { label: '大队排名', current: deptRanking?.rank || 0, total: deptRanking?.total || 0, percentage: deptRanking?.total ? ((deptRanking.rank || 0) / deptRanking.total) * 100 : 0 },
  1145. { label: '站级排名', current: siteRanking?.rank || 0, total: siteRanking?.total || 0, percentage: siteRanking?.total ? ((siteRanking.rank || 0) / siteRanking.total) * 100 : 0, type: 'station' }
  1146. ];
  1147. } else if (this.role.includes('kezhang')) {
  1148. const { deptInSiteRanking, deptInBrigadeRanking } = this.accuracyStatistics;
  1149. return [
  1150. { label: '大队排名', current: deptInBrigadeRanking?.rank || 0, total: deptInBrigadeRanking?.total || 0, percentage: deptInBrigadeRanking?.total ? ((deptInBrigadeRanking.rank || 0) / deptInBrigadeRanking.total) * 100 : 0 },
  1151. { label: '站级排名', current: deptInSiteRanking?.rank || 0, total: deptInSiteRanking?.total || 0, percentage: deptInSiteRanking?.total ? ((deptInSiteRanking?.rank || 0) / deptInSiteRanking?.total) * 100 : 0, type: 'station' }
  1152. ];
  1153. } else if (this.isBrigade) {
  1154. const { brigadeInSiteRanking } = this.accuracyStatistics;
  1155. return [
  1156. { label: '站级排名', current: brigadeInSiteRanking?.rank || 0, total: brigadeInSiteRanking?.total || 0, percentage: brigadeInSiteRanking?.total ? ((brigadeInSiteRanking?.rank || 0) / brigadeInSiteRanking?.total) * 100 : 0, type: 'station' }
  1157. ];
  1158. } else if (this.isTeamView) {
  1159. const { teamInDeptRanking, deptRanking, teamInSiteRanking, teamInBrigadeRanking } = this.accuracyStatistics;
  1160. // 班组长角色:显示科级和站级排名
  1161. return [
  1162. { label: '主管排名', current: teamInDeptRanking?.rank || 0, total: teamInDeptRanking?.total || 0, percentage: teamInDeptRanking?.total ? ((teamInDeptRanking.rank || 0) / teamInDeptRanking.total) * 100 : 0 },
  1163. { label: '大队排名', current: teamInBrigadeRanking?.rank || 0, total: teamInBrigadeRanking?.total || 0, percentage: teamInBrigadeRanking?.total ? ((teamInBrigadeRanking.rank || 0) / teamInBrigadeRanking.total) * 100 : 0 },
  1164. { label: '站级排名', current: teamInSiteRanking?.rank || 0, total: teamInSiteRanking?.total || 0, percentage: teamInSiteRanking?.total ? ((teamInSiteRanking.rank || 0) / teamInSiteRanking.total) * 100 : 0, type: 'station' }
  1165. ];
  1166. } else {
  1167. // 默认角色:显示个人排名
  1168. return [];
  1169. }
  1170. },
  1171. // 根据角色获取巡检排名列表
  1172. getSeizeRankList() {
  1173. // 根据角色返回不同的排名数据
  1174. if (this.isIndividualView) {
  1175. const { securityCheckerData } = this.seizeData;
  1176. const { teamRanking, departmentRanking, stationRanking, brigadeRanking } = securityCheckerData || {}
  1177. // 科长、SecurityCheck角色:显示班组、科级和站级排名
  1178. return [
  1179. { label: '班组排名', current: teamRanking?.currentRank || 0, total: teamRanking?.totalItems || 0, percentage: teamRanking?.totalItems ? ((teamRanking.currentRank || 0) / teamRanking.totalItems) * 100 : 0 },
  1180. { label: '主管排名', current: departmentRanking?.currentRank || 0, total: departmentRanking?.totalItems || 0, percentage: departmentRanking?.totalItems ? ((departmentRanking.currentRank || 0) / departmentRanking.totalItems) * 100 : 0 },
  1181. { label: '大队排名', current: brigadeRanking?.currentRank || 0, total: brigadeRanking?.totalItems || 0, percentage: brigadeRanking?.totalItems ? ((brigadeRanking.currentRank || 0) / brigadeRanking.totalItems) * 100 : 0 },
  1182. { label: '站级排名', current: stationRanking?.currentRank || 0, total: stationRanking?.totalItems || 0, percentage: stationRanking?.totalItems ? ((stationRanking.currentRank || 0) / stationRanking.totalItems) * 100 : 0, type: 'station' }
  1183. ];
  1184. } else if (this.role.includes('kezhang')) {
  1185. const { sectionMasterData } = this.seizeData;
  1186. const { stationRanking, departmentRanking, brigadeRanking } = sectionMasterData || {};
  1187. // 科长、SecurityCheck角色:显示班组、科级和站级排名
  1188. return [
  1189. { label: '大队排名', current: brigadeRanking?.currentRank || 0, total: brigadeRanking?.totalItems || 0, percentage: brigadeRanking?.totalItems ? ((brigadeRanking.currentRank || 0) / brigadeRanking.totalItems) * 100 : 0 },
  1190. { label: '站级排名', current: stationRanking?.currentRank || 0, total: stationRanking?.totalItems || 0, percentage: stationRanking?.totalItems ? ((stationRanking.currentRank || 0) / stationRanking.totalItems) * 100 : 0, type: 'station' }
  1191. ];
  1192. } else if (this.isBrigade) {
  1193. const { brigadeMasterData } = this.seizeData;
  1194. const { stationRanking } = brigadeMasterData || {};
  1195. // brigade角色:显示站级排名
  1196. return [
  1197. { label: '站级排名', current: stationRanking?.currentRank || 0, total: stationRanking?.totalItems || 0, percentage: stationRanking?.totalItems ? ((stationRanking.currentRank || 0) / stationRanking.totalItems) * 100 : 0, type: 'station' }
  1198. ];
  1199. } else if (this.isTeamView) {
  1200. const { teamLeaderData } = this.seizeData;
  1201. const { departmentRanking, stationRanking, brigadeRanking } = teamLeaderData || {}
  1202. // 班组长角色:显示科级和站级排名
  1203. return [
  1204. { label: '主管排名', current: departmentRanking?.currentRank || 0, total: departmentRanking?.totalItems || 0, percentage: departmentRanking?.totalItems ? ((departmentRanking.currentRank || 0) / departmentRanking.totalItems) * 100 : 0 },
  1205. { label: '大队排名', current: brigadeRanking?.currentRank || 0, total: brigadeRanking?.totalItems || 0, percentage: brigadeRanking?.totalItems ? ((brigadeRanking.currentRank || 0) / brigadeRanking.totalItems) * 100 : 0 },
  1206. { label: '站级排名', current: stationRanking?.currentRank || 0, total: stationRanking?.totalItems || 0, percentage: stationRanking?.totalItems ? ((stationRanking.currentRank || 0) / stationRanking.totalItems) * 100 : 0, type: 'station' }
  1207. ];
  1208. } else {
  1209. // 默认角色:显示个人排名
  1210. return [];
  1211. }
  1212. },
  1213. goworkDocu() {
  1214. uni.navigateTo({
  1215. url: '/pages/workDocu/index'
  1216. });
  1217. },
  1218. async getUnreadCount() {
  1219. const res = await getUnreadCount();
  1220. this.unreadCount = res.data
  1221. },
  1222. async getUser() {
  1223. const data = await getUserProfile();
  1224. console.log("data====", data)
  1225. //data.postGroup + " " +
  1226. this.userInfo = data.data.dept.deptName
  1227. await this.loadAppList(data.data);
  1228. // this.formData.securityLocationText = data.data.dept.deptName
  1229. // this.formData.positionText = data.postGroup
  1230. },
  1231. formatDate(date) {
  1232. const year = date.getFullYear();
  1233. const month = (date.getMonth() + 1).toString().padStart(2, '0');
  1234. const day = date.getDate().toString().padStart(2, '0');
  1235. const week = ['日', '一', '二', '三', '四', '五', '六'][date.getDay()];
  1236. return `${year}年${month}月${day}日 星期${week}`;
  1237. },
  1238. updateCurrentDate() {
  1239. this.currentDate = this.formatDate(new Date());
  1240. },
  1241. handleGridClick(item) {
  1242. console.log('点击了宫格:', item);
  1243. if (item.path) {
  1244. uni.navigateTo({
  1245. url: item.path
  1246. });
  1247. } else {
  1248. this.$modal.showToast('功能开发中,敬请期待');
  1249. }
  1250. },
  1251. goToAttendance() {
  1252. uni.navigateTo({
  1253. url: '/pages/attendance/index'
  1254. });
  1255. },
  1256. changeGrid(e) {
  1257. const index = e.detail.index;
  1258. const item = this.items[index];
  1259. this.handleGridClick(item);
  1260. },
  1261. goToPage(path) {
  1262. // if (checkRolePermission(this.role, path)) {
  1263. uni.navigateTo({ url: path });
  1264. // } else {
  1265. // this.$modal.showToast('此角色不需要查看该功能,无需操作~');
  1266. // }
  1267. },
  1268. async loadAppList(userInfo) {
  1269. // const roleId = userInfo.roles && userInfo.roles.length ? userInfo.roles[0].roleId : null;
  1270. try {
  1271. // if (roleId) {
  1272. const res = await getAppList({ homePage: 1 });
  1273. if (res.code === 200) {
  1274. this.appList = res.data;
  1275. }
  1276. // }
  1277. } catch (error) {
  1278. console.error('获取应用列表失败:', error);
  1279. this.appList = [];
  1280. }
  1281. },
  1282. async loadTodayRecord() {
  1283. if (this.yesterday) {
  1284. return;
  1285. }
  1286. const today = this.formatDate(new Date());
  1287. const { data } = await getAttendanceList({
  1288. type: 1,
  1289. checkInDate: today,
  1290. userId: this.$store.state.user.id
  1291. });
  1292. // 接口 data 可能是多条(按天),我们取第一条里的 items
  1293. const todayData = data && data.length ? data[0] : null;
  1294. const items = todayData ? todayData.items : [];
  1295. const lastMorning = items.find(r => r.checkInType == 'CLOCK_IN');
  1296. if (lastMorning) {
  1297. console.log(lastMorning);
  1298. this.todayCheckInTime = '已打卡 ' + lastMorning.checkInTime
  1299. } else {
  1300. }
  1301. },
  1302. // 日期格式化(昨天、今天查询用)
  1303. formatDate(date) {
  1304. const y = date.getFullYear();
  1305. const m = String(date.getMonth() + 1).padStart(2, '0');
  1306. const d = String(date.getDate()).padStart(2, '0');
  1307. return `${y}-${m}-${d}`;
  1308. },
  1309. // 获取今日上岗科长信息
  1310. async getTodayOnDutyKeZhang() {
  1311. return new Promise((resolve, reject) => {
  1312. // 只有当角色包含test时才调用此接口
  1313. if (!this.isZhanZhang) {
  1314. resolve(null);
  1315. return;
  1316. }
  1317. // 调用接口获取今日上岗科长列表
  1318. selectUserListByRoleKey(["kezhang"]).then(res => {
  1319. if (res.code === 200 && res.data && res.data.length > 0) {
  1320. this.subTitleText = res.data && res.data.map(user => user.nickName).join('、');
  1321. resolve(res.data);
  1322. } else {
  1323. this.subTitleText = '';
  1324. resolve(null);
  1325. }
  1326. }).catch(error => {
  1327. console.error("获取今日上岗科长信息失败:", error);
  1328. this.subTitleText = '';
  1329. reject(error);
  1330. });
  1331. });
  1332. },
  1333. }
  1334. }
  1335. </script>
  1336. <style lang="scss" scoped>
  1337. img {
  1338. display: inline-flex;
  1339. }
  1340. .title {
  1341. padding: 34rpx 34rpx 34rpx;
  1342. height: auto;
  1343. border-radius: 0 0 20rpx 20rpx;
  1344. background: linear-gradient(136deg, #8FA5EC 0%, #978CED 99.29%);
  1345. transition: all 0.3s ease;
  1346. }
  1347. .content {
  1348. padding: 34rpx 34rpx 34rpx;
  1349. }
  1350. ::v-deep .userInfo {
  1351. .user-info {
  1352. font-size: 34rpx;
  1353. background-size: auto 90%;
  1354. padding: 4rpx 0 4rpx 100rpx;
  1355. background-position: 0rpx 6rpx;
  1356. }
  1357. }
  1358. /* 角色选择器样式 */
  1359. .role-selector {
  1360. margin-bottom: 10rpx;
  1361. }
  1362. /* 排名容器样式 */
  1363. .rank-container {
  1364. display: flex;
  1365. justify-content: flex-start;
  1366. margin: 0 0 34rpx 0;
  1367. }
  1368. .rank-item {
  1369. display: flex;
  1370. align-items: center;
  1371. background: rgba(255, 255, 255, 0.2);
  1372. border-radius: 20rpx;
  1373. padding: 10rpx 20rpx;
  1374. margin-right: 13rpx;
  1375. }
  1376. .rank-content {
  1377. text-align: center;
  1378. display: flex;
  1379. align-items: center;
  1380. font-size: 22rpx;
  1381. color: #fff;
  1382. }
  1383. .rank-value {
  1384. margin: 0 10rpx;
  1385. line-height: 24rpx;
  1386. }
  1387. .rank-label {
  1388. line-height: 24rpx;
  1389. }
  1390. .rank-image {
  1391. width: 24rpx;
  1392. height: 24rpx;
  1393. border-radius: 8rpx;
  1394. }
  1395. /* 出勤信息容器样式 */
  1396. .attendance-container {
  1397. margin-top: 20rpx;
  1398. }
  1399. .attendance-grid {
  1400. background: rgba(255, 255, 255, 0.15);
  1401. display: grid;
  1402. grid-template-columns: repeat(3, 1fr);
  1403. gap: 0;
  1404. border-radius: 20rpx;
  1405. position: relative;
  1406. }
  1407. .attendance-item {
  1408. padding: 24rpx 16rpx;
  1409. text-align: center;
  1410. position: relative;
  1411. }
  1412. /* 为每个attendance-item添加右侧竖线分隔线 */
  1413. .attendance-item:not(:nth-child(3n))::after {
  1414. content: '';
  1415. position: absolute;
  1416. right: 0;
  1417. top: 50%;
  1418. transform: translateY(-50%);
  1419. width: 1rpx;
  1420. height: 50%;
  1421. background: rgba(255, 255, 255, 0.5);
  1422. }
  1423. .item-value {
  1424. line-height: 1;
  1425. font-size: 32rpx;
  1426. font-weight: bold;
  1427. color: #FFFFFF;
  1428. margin-top: 13rpx;
  1429. }
  1430. .item-label {
  1431. font-size: 25rpx;
  1432. font-weight: 400;
  1433. color: rgba(255, 255, 255, 0.6);
  1434. opacity: 0.6;
  1435. }
  1436. /* 时间范围选择样式 */
  1437. .time-range-section {
  1438. margin: 15rpx 0;
  1439. padding: 0 0rpx;
  1440. }
  1441. .time-range-container {
  1442. display: flex;
  1443. align-items: flex-start;
  1444. gap: 20rpx;
  1445. }
  1446. .time-range-label {
  1447. font-size: 28rpx;
  1448. color: #333;
  1449. font-weight: 500;
  1450. white-space: nowrap;
  1451. line-height: 60rpx;
  1452. flex-shrink: 0;
  1453. }
  1454. .time-tags-container {
  1455. display: flex;
  1456. flex-wrap: wrap;
  1457. align-items: center;
  1458. flex: 1;
  1459. }
  1460. .time-tag {
  1461. margin-left: 4rpx;
  1462. padding: 7rpx 15rpx;
  1463. background: #fff;
  1464. border-radius: 20rpx;
  1465. font-size: 24rpx;
  1466. color: #666;
  1467. cursor: pointer;
  1468. transition: all 0.3s ease;
  1469. border: 2rpx solid transparent;
  1470. white-space: nowrap;
  1471. flex-shrink: 0;
  1472. }
  1473. .time-tag.active {
  1474. background: #8FA5EC;
  1475. color: #fff;
  1476. border-color: #8FA5EC;
  1477. }
  1478. /* 时间范围标签样式 - 作为普通文字显示 */
  1479. .time-tag.time-range-label {
  1480. background: transparent !important;
  1481. border: none !important;
  1482. padding: 0 !important;
  1483. font-size: 28rpx;
  1484. color: #333;
  1485. font-weight: 500;
  1486. cursor: default !important;
  1487. pointer-events: none;
  1488. margin-right: 0;
  1489. }
  1490. .time-tag.time-range-label:hover {
  1491. background: transparent !important;
  1492. border: none !important;
  1493. }
  1494. /* 内联自定义时间显示样式 */
  1495. .custom-time-inline {
  1496. position: relative;
  1497. display: flex;
  1498. align-items: center;
  1499. gap: 12rpx;
  1500. margin-left: 15rpx;
  1501. flex-wrap: wrap;
  1502. // width: 350rpx;
  1503. }
  1504. .date-range-picker {
  1505. ::v-deep .icon-calendar {
  1506. display: none !important;
  1507. }
  1508. ::v-deep .uni-date-range {
  1509. font-size: 16rpx !important;
  1510. background: transparent !important;
  1511. color: black !important;
  1512. }
  1513. ::v-deep .uni-date-x {
  1514. height: 25rpx !important;
  1515. line-height: 25rpx !important;
  1516. min-width: auto !important;
  1517. .range-separator {
  1518. font-size: 23rpx !important;
  1519. padding: 0 8rpx !important;
  1520. margin: 0 !important;
  1521. }
  1522. .uni-date__x-input {
  1523. width: auto !important;
  1524. min-width: auto !important;
  1525. height: 25rpx !important;
  1526. line-height: 25rpx !important;
  1527. padding: 0 !important;
  1528. margin: 0 !important;
  1529. }
  1530. }
  1531. ::v-deep .uni-date-x--border {
  1532. border: none !important;
  1533. padding: 0 !important;
  1534. margin: 0 !important;
  1535. }
  1536. }
  1537. .days-count {
  1538. // position: absolute;
  1539. // right: -102rpx;
  1540. // top: -8rpx;
  1541. height: 25rpx;
  1542. line-height: 25rpx;
  1543. font-size: 27rpx;
  1544. color: black;
  1545. font-weight: 500;
  1546. white-space: nowrap;
  1547. }
  1548. .speret {
  1549. font-size: 26rpx;
  1550. color: #999;
  1551. }
  1552. </style>